Distinguish no directive present from unknown directive
Distinguish the case of no directive present (D_none) from the case of an unknown specified directive (D_unknown). This is reflected in different error messages. Furthermore, change the special case symbols to lower case in case we ever have a directive called [none] or [unknown]. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This commit is contained in:
parent
cdcd1f7ac4
commit
888964a880
2 changed files with 11 additions and 9 deletions
|
@ -69,13 +69,14 @@ if ($output eq 'h') {
|
|||
print H "\n";
|
||||
|
||||
print H "enum directives {\n";
|
||||
print H " D_NONE";
|
||||
print H " D_none,\n";
|
||||
print H " D_unknown";
|
||||
foreach $d (@directives) {
|
||||
print H ",\n D_\U$d";
|
||||
}
|
||||
print H "\n};\n\n";
|
||||
printf H "extern const char * const directives[%d];\n",
|
||||
scalar(@directives)+1;
|
||||
scalar(@directives)+2;
|
||||
print H "enum directives find_directive(const char *token);\n\n";
|
||||
print H "#endif /* NASM_DIRECTIVES_H */\n";
|
||||
} elsif ($output eq 'c') {
|
||||
|
@ -118,7 +119,8 @@ if ($output eq 'h') {
|
|||
print C "\n";
|
||||
|
||||
printf C "const char * const directives[%d] = {\n",
|
||||
scalar(@directives)+1;
|
||||
scalar(@directives)+2;
|
||||
print C " NULL,\n";
|
||||
print C " NULL";
|
||||
foreach $d (@directives) {
|
||||
print C ",\n \"$d\"";
|
||||
|
@ -160,11 +162,11 @@ if ($output eq 'h') {
|
|||
print C "\n";
|
||||
printf C " ix = hash1[k1 & 0x%x] + hash2[k2 & 0x%x];\n", $n-1, $n-1;
|
||||
printf C " if (ix >= %d)\n", scalar(@directives);
|
||||
print C " return D_NONE;\n";
|
||||
print C " return D_unknown;\n";
|
||||
print C "\n";
|
||||
print C " ix++;\n"; # Account for D_NONE
|
||||
print C " if (nasm_stricmp(token, directives[ix]))\n";
|
||||
print C " return D_NONE;\n";
|
||||
print C " return D_unknown;\n";
|
||||
print C "\n";
|
||||
print C " return ix;\n";
|
||||
print C "}\n";
|
||||
|
|
8
nasm.c
8
nasm.c
|
@ -1750,16 +1750,16 @@ static enum directives getkw(char **directive, char **value)
|
|||
|
||||
/* it should be enclosed in [ ] */
|
||||
if (*buf != '[')
|
||||
return D_NONE;
|
||||
return D_none;
|
||||
q = strchr(buf, ']');
|
||||
if (!q)
|
||||
return D_NONE;
|
||||
return D_none;
|
||||
|
||||
/* stip off the comments */
|
||||
p = strchr(buf, ';');
|
||||
if (p) {
|
||||
if (p < q) /* ouch! somwhere inside */
|
||||
return D_NONE;
|
||||
return D_none;
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
|
@ -1771,7 +1771,7 @@ static enum directives getkw(char **directive, char **value)
|
|||
p = nasm_skip_spaces(++buf);
|
||||
q = nasm_skip_word(p);
|
||||
if (!q)
|
||||
return D_NONE; /* sigh... no value there */
|
||||
return D_none; /* sigh... no value there */
|
||||
*q = '\0';
|
||||
*directive = p;
|
||||
|
||||
|
|
Loading…
Reference in a new issue