From 888964a880dbeead14ce316c4cae5b819aa877e3 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Tue, 6 Apr 2010 17:00:12 -0700 Subject: [PATCH] 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 --- directives.pl | 12 +++++++----- nasm.c | 8 ++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/directives.pl b/directives.pl index d8bc6e8e..558c6a1f 100755 --- a/directives.pl +++ b/directives.pl @@ -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"; diff --git a/nasm.c b/nasm.c index d8f64c5f..70f8c9e4 100644 --- a/nasm.c +++ b/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; -- 2.11.4.GIT