Fix strncmp bug
This commit is contained in:
parent
0548b71a72
commit
360cf24ae2
@ -2,6 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "icmd.h"
|
||||
#include "common.h"
|
||||
|
||||
@ -12,7 +13,7 @@
|
||||
#define ICMD(name) \
|
||||
{ \
|
||||
.cmd = TOSTR(name), \
|
||||
.len = sizeof(TOSTR(name)), \
|
||||
.len = sizeof(TOSTR(name))-1, \
|
||||
.func = CONCAT(icmd_, name), \
|
||||
}
|
||||
|
||||
@ -32,11 +33,13 @@ call_icmds(char *line)
|
||||
|
||||
for (i = 0; i < ICMDS_SIZE; i++)
|
||||
{
|
||||
printf("cmp: %s : %s \n", g_icmds[i].cmd, line);
|
||||
printf("cmp: '%s' : '%s' with len %d \n", g_icmds[i].cmd, line, g_icmds[i].len);
|
||||
if (strncmp(g_icmds[i].cmd, line, g_icmds[i].len) == 0)
|
||||
return g_icmds[i].func(line);
|
||||
}
|
||||
|
||||
/* todo: find better way to signal this? */
|
||||
/* maybe return function pointer? */
|
||||
return INT_MAX;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user