mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-01-18 16:25:05 +08:00
strfunc: better error messages if a string transform fails
Let the user know what string transform actually failed on them. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
parent
d4b20355d2
commit
236f4a832b
@ -746,7 +746,7 @@ static expr *eval_floatize(enum floatize type)
|
|||||||
return finishtemp();
|
return finishtemp();
|
||||||
}
|
}
|
||||||
|
|
||||||
static expr *eval_strfunc(enum strfunc type)
|
static expr *eval_strfunc(enum strfunc type, const char *name)
|
||||||
{
|
{
|
||||||
char *string;
|
char *string;
|
||||||
size_t string_len;
|
size_t string_len;
|
||||||
@ -760,13 +760,13 @@ static expr *eval_strfunc(enum strfunc type)
|
|||||||
scan();
|
scan();
|
||||||
}
|
}
|
||||||
if (tt != TOKEN_STR) {
|
if (tt != TOKEN_STR) {
|
||||||
nasm_nonfatal("expecting string");
|
nasm_nonfatal("expecting string as argument to %s", name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
string_len = string_transform(tokval->t_charptr, tokval->t_inttwo,
|
string_len = string_transform(tokval->t_charptr, tokval->t_inttwo,
|
||||||
&string, type);
|
&string, type);
|
||||||
if (string_len == (size_t)-1) {
|
if (string_len == (size_t)-1) {
|
||||||
nasm_nonfatal("invalid string for transform");
|
nasm_nonfatal("invalid input string to %s", name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -908,7 +908,7 @@ static expr *expr6(void)
|
|||||||
return eval_floatize(tokval->t_integer);
|
return eval_floatize(tokval->t_integer);
|
||||||
|
|
||||||
case TOKEN_STRFUNC:
|
case TOKEN_STRFUNC:
|
||||||
return eval_strfunc(tokval->t_integer);
|
return eval_strfunc(tokval->t_integer, tokval->t_charptr);
|
||||||
|
|
||||||
case '(':
|
case '(':
|
||||||
scan();
|
scan();
|
||||||
|
@ -612,14 +612,14 @@ restart_parse:
|
|||||||
if (i != TOKEN_STR) {
|
if (i != TOKEN_STR) {
|
||||||
nasm_nonfatal("%s must be followed by a string constant",
|
nasm_nonfatal("%s must be followed by a string constant",
|
||||||
funcname);
|
funcname);
|
||||||
eop->type = EOT_NOTHING;
|
eop->type = EOT_NOTHING;
|
||||||
} else {
|
} else {
|
||||||
eop->type = EOT_DB_STRING_FREE;
|
eop->type = EOT_DB_STRING_FREE;
|
||||||
eop->stringlen =
|
eop->stringlen =
|
||||||
string_transform(tokval.t_charptr, tokval.t_inttwo,
|
string_transform(tokval.t_charptr, tokval.t_inttwo,
|
||||||
&eop->stringval, func);
|
&eop->stringval, func);
|
||||||
if (eop->stringlen == (size_t)-1) {
|
if (eop->stringlen == (size_t)-1) {
|
||||||
nasm_nonfatal("invalid string for transform");
|
nasm_nonfatal("invalid input string to %s", funcname);
|
||||||
eop->type = EOT_NOTHING;
|
eop->type = EOT_NOTHING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,16 @@
|
|||||||
./travis/test/utf.asm:65: error: unterminated __utf16__ function
|
./travis/test/utf.asm:65: error: unterminated __utf16__ function
|
||||||
./travis/test/utf.asm:65: error: comma expected after operand 2
|
./travis/test/utf.asm:65: error: comma expected after operand 2
|
||||||
./travis/test/utf.asm:66: error: unterminated __utf16__ function
|
./travis/test/utf.asm:66: error: unterminated __utf16__ function
|
||||||
./travis/test/utf.asm:67: error: invalid string for transform
|
./travis/test/utf.asm:67: error: invalid input string to __utf16__
|
||||||
./travis/test/utf.asm:69: error: __utf16le__ must be followed by a string constant
|
./travis/test/utf.asm:69: error: __utf16le__ must be followed by a string constant
|
||||||
./travis/test/utf.asm:70: error: __utf16le__ must be followed by a string constant
|
./travis/test/utf.asm:70: error: __utf16le__ must be followed by a string constant
|
||||||
./travis/test/utf.asm:71: error: unterminated __utf16le__ function
|
./travis/test/utf.asm:71: error: unterminated __utf16le__ function
|
||||||
./travis/test/utf.asm:71: error: comma expected after operand 2
|
./travis/test/utf.asm:71: error: comma expected after operand 2
|
||||||
./travis/test/utf.asm:72: error: unterminated __utf16le__ function
|
./travis/test/utf.asm:72: error: unterminated __utf16le__ function
|
||||||
./travis/test/utf.asm:73: error: invalid string for transform
|
./travis/test/utf.asm:73: error: invalid input string to __utf16le__
|
||||||
./travis/test/utf.asm:75: error: __utf16be__ must be followed by a string constant
|
./travis/test/utf.asm:75: error: __utf16be__ must be followed by a string constant
|
||||||
./travis/test/utf.asm:76: error: __utf16be__ must be followed by a string constant
|
./travis/test/utf.asm:76: error: __utf16be__ must be followed by a string constant
|
||||||
./travis/test/utf.asm:77: error: unterminated __utf16be__ function
|
./travis/test/utf.asm:77: error: unterminated __utf16be__ function
|
||||||
./travis/test/utf.asm:77: error: comma expected after operand 2
|
./travis/test/utf.asm:77: error: comma expected after operand 2
|
||||||
./travis/test/utf.asm:78: error: unterminated __utf16be__ function
|
./travis/test/utf.asm:78: error: unterminated __utf16be__ function
|
||||||
./travis/test/utf.asm:79: error: invalid string for transform
|
./travis/test/utf.asm:79: error: invalid input string to __utf16be__
|
||||||
|
Loading…
Reference in New Issue
Block a user