mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-10-10 00:25:06 -04:00
quote.c: let nasm_skip_string() return NULL for a non-string
Returning NULL makes more sense than returning the initial pointer (the only other sensible alternative would be to return a pointer the final null character.) This currently can't happen, as all callers to nasm_skip_string() currently explicitly tests for an initial quote. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
15
asm/quote.c
15
asm/quote.c
@@ -484,7 +484,7 @@ size_t nasm_unquote_cstr(char *str, char **ep)
|
||||
/*
|
||||
* Find the end of a quoted string; returns the pointer to the terminating
|
||||
* character (either the ending quote or the null character, if unterminated.)
|
||||
* If the input is not a quoted string,
|
||||
* If the input is not a quoted string, return NULL.
|
||||
*/
|
||||
char *nasm_skip_string(const char *str)
|
||||
{
|
||||
@@ -499,11 +499,15 @@ char *nasm_skip_string(const char *str)
|
||||
|
||||
bq = str[0];
|
||||
p = str+1;
|
||||
if (bq == '\'' || bq == '\"') {
|
||||
switch (bq) {
|
||||
case '\'':
|
||||
case '\"':
|
||||
/* '...' or "..." string */
|
||||
while ((c = *p++) && (c != bq))
|
||||
;
|
||||
} else if (bq == '`') {
|
||||
break;
|
||||
|
||||
case '`':
|
||||
/* `...` string */
|
||||
state = st_start;
|
||||
while (state != st_done) {
|
||||
@@ -537,6 +541,11 @@ char *nasm_skip_string(const char *str)
|
||||
panic();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Not a string at all... */
|
||||
return NULL;
|
||||
}
|
||||
return (char *)p - 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user