diff options
author | H. Peter Anvin <hpa@zytor.com> | 2019-04-22 14:29:29 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2019-04-22 14:34:22 -0700 |
commit | bb42d30737f28485c6a1133e73038840b5bf920c (patch) | |
tree | e1257690dba04296b713b4f9a12271edac167e22 /include | |
parent | 982186a1a3139763f2aa2710b32236009f64270d (diff) | |
download | nasm-bb42d30737f28485c6a1133e73038840b5bf920c.tar.gz nasm-bb42d30737f28485c6a1133e73038840b5bf920c.tar.xz nasm-bb42d30737f28485c6a1133e73038840b5bf920c.zip |
quote: disallow control characters in C strings; concatendate; cleanups
In nasm_unquote_cstr(), disallow any control character, not just
NUL. This will matter when allowing quoting symbols.
Merge nasm_unquote() and nasm_unquote_cstr().
Strings can now be concatenated, C style: adjacent quoted strings
(including whitespace-separated) are merged into a single string.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/nasmlib.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/include/nasmlib.h b/include/nasmlib.h index c41a5bad..e9cc4474 100644 --- a/include/nasmlib.h +++ b/include/nasmlib.h @@ -199,8 +199,12 @@ char *nasm_strsep(char **stringp, const char *delim); size_t pure_func strnlen(const char *, size_t); #endif -/* This returns the numeric value of a given 'digit'. */ -#define numvalue(c) ((c) >= 'a' ? (c) - 'a' + 10 : (c) >= 'A' ? (c) - 'A' + 10 : (c) - '0') +/* This returns the numeric value of a given 'digit'; no check for validity */ +static inline unsigned int numvalue(unsigned char c) +{ + c |= 0x20; + return c >= 'a' ? c - 'a' + 10 : c - '0'; +} /* * Convert a string into a number, using NASM number rules. Sets |