Some fixes to make it compile on FreeBSD.
This commit is contained in:
parent
2e8bd52b01
commit
34dbad1653
1 changed files with 7 additions and 10 deletions
17
src/parser.c
17
src/parser.c
|
|
@ -2068,15 +2068,12 @@ static void parse_block(Bytecode *bc, const char *src, size_t len, size_t *pos,
|
||||||
memset(param_kind, 0, sizeof(param_kind));
|
memset(param_kind, 0, sizeof(param_kind));
|
||||||
|
|
||||||
/* kind: 1=Number (numeric types incl. boolean), 2=String, 3=Nil */
|
/* kind: 1=Number (numeric types incl. boolean), 2=String, 3=Nil */
|
||||||
auto int map_type_kind(const char *t) {
|
/* helper macro instead of nested function (C99 compliant) */
|
||||||
if (!t) return 0;
|
#define MAP_TYPE_KIND(t) ( \
|
||||||
if (strcmp(t, "string") == 0) return 2;
|
((t) && strcmp((t), "string")==0) ? 2 : \
|
||||||
if (strcmp(t, "nil") == 0) return 3;
|
((t) && strcmp((t), "nil")==0) ? 3 : \
|
||||||
if (strcmp(t, "boolean") == 0) return 1;
|
((t) && (strcmp((t), "boolean")==0 || strcmp((t), "number")==0 || strncmp((t), "uint", 4)==0 || strncmp((t), "sint", 4)==0 || strncmp((t), "int", 3)==0)) ? 1 : \
|
||||||
if (strcmp(t, "number") == 0) return 1;
|
0 )
|
||||||
if (strncmp(t, "uint", 4) == 0 || strncmp(t, "sint", 4) == 0 || strncmp(t, "int", 3) == 0) return 1;
|
|
||||||
return 0; /* unknown -> treat as number-like? keep as 0 => no check */
|
|
||||||
}
|
|
||||||
|
|
||||||
skip_spaces(src, len, pos);
|
skip_spaces(src, len, pos);
|
||||||
if (*pos < len && src[*pos] == '(') {
|
if (*pos < len && src[*pos] == '(') {
|
||||||
|
|
@ -2106,7 +2103,7 @@ static void parse_block(Bytecode *bc, const char *src, size_t len, size_t *pos,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
param_names[pcount] = pname;
|
param_names[pcount] = pname;
|
||||||
param_kind[pcount] = map_type_kind(tname);
|
param_kind[pcount] = MAP_TYPE_KIND(tname);
|
||||||
free(tname);
|
free(tname);
|
||||||
pcount++;
|
pcount++;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue