aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2019-06-06 17:17:16 -0700
committerH. Peter Anvin <hpa@zytor.com>2019-06-06 17:17:16 -0700
commit236f4a832b9a226a4492b873aeead022e4ea63b9 (patch)
tree4a4353bc9b01543ab5c8134aa533dcf20c8e1242
parentd4b20355d224d58944faf0731365f8a3764eb2e5 (diff)
downloadnasm-236f4a832b9a226a4492b873aeead022e4ea63b9.tar.gz
nasm-236f4a832b9a226a4492b873aeead022e4ea63b9.tar.xz
nasm-236f4a832b9a226a4492b873aeead022e4ea63b9.zip
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>
-rw-r--r--asm/eval.c8
-rw-r--r--asm/parser.c4
-rw-r--r--travis/test/utf-error.stderr6
3 files changed, 9 insertions, 9 deletions
diff --git a/asm/eval.c b/asm/eval.c
index d8fe34ae..9ec093a0 100644
--- a/asm/eval.c
+++ b/asm/eval.c
@@ -746,7 +746,7 @@ static expr *eval_floatize(enum floatize type)
return finishtemp();
}
-static expr *eval_strfunc(enum strfunc type)
+static expr *eval_strfunc(enum strfunc type, const char *name)
{
char *string;
size_t string_len;
@@ -760,13 +760,13 @@ static expr *eval_strfunc(enum strfunc type)
scan();
}
if (tt != TOKEN_STR) {
- nasm_nonfatal("expecting string");
+ nasm_nonfatal("expecting string as argument to %s", name);
return NULL;
}
string_len = string_transform(tokval->t_charptr, tokval->t_inttwo,
&string, type);
if (string_len == (size_t)-1) {
- nasm_nonfatal("invalid string for transform");
+ nasm_nonfatal("invalid input string to %s", name);
return NULL;
}
@@ -908,7 +908,7 @@ static expr *expr6(void)
return eval_floatize(tokval->t_integer);
case TOKEN_STRFUNC:
- return eval_strfunc(tokval->t_integer);
+ return eval_strfunc(tokval->t_integer, tokval->t_charptr);
case '(':
scan();
diff --git a/asm/parser.c b/asm/parser.c
index 9f38844f..fce973b9 100644
--- a/asm/parser.c
+++ b/asm/parser.c
@@ -612,14 +612,14 @@ restart_parse:
if (i != TOKEN_STR) {
nasm_nonfatal("%s must be followed by a string constant",
funcname);
- eop->type = EOT_NOTHING;
+ eop->type = EOT_NOTHING;
} else {
eop->type = EOT_DB_STRING_FREE;
eop->stringlen =
string_transform(tokval.t_charptr, tokval.t_inttwo,
&eop->stringval, func);
if (eop->stringlen == (size_t)-1) {
- nasm_nonfatal("invalid string for transform");
+ nasm_nonfatal("invalid input string to %s", funcname);
eop->type = EOT_NOTHING;
}
}
diff --git a/travis/test/utf-error.stderr b/travis/test/utf-error.stderr
index 07ff4fb8..2d2caf1f 100644
--- a/travis/test/utf-error.stderr
+++ b/travis/test/utf-error.stderr
@@ -3,16 +3,16 @@
./travis/test/utf.asm:65: error: unterminated __utf16__ function
./travis/test/utf.asm:65: error: comma expected after operand 2
./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: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: comma expected after operand 2
./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: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: comma expected after operand 2
./travis/test/utf.asm:78: error: unterminated __utf16be__ function
-./travis/test/utf.asm:79: error: invalid string for transform \ No newline at end of file
+./travis/test/utf.asm:79: error: invalid input string to __utf16be__