aboutsummaryrefslogtreecommitdiff
path: root/dtc-parser.y
diff options
context:
space:
mode:
authorMilton Miller <miltonm@bga.com>2007-07-07 01:18:48 -0500
committerJon Loeliger <jdl@freescale.com>2007-07-07 10:07:44 -0500
commit85ab5cc6ec8442245a969a2f5a0e05962e0e7e67 (patch)
tree820fb817f035112f9a0108b5069c38bf00931a35 /dtc-parser.y
parent6d7b22243045dc514b5ea6c004fc50af8581ed9b (diff)
downloaddtc-85ab5cc6ec8442245a969a2f5a0e05962e0e7e67.zip
dtc-85ab5cc6ec8442245a969a2f5a0e05962e0e7e67.tar.gz
dtc-85ab5cc6ec8442245a969a2f5a0e05962e0e7e67.tar.bz2
dtc: complain about unparsed digits in cell lists
Check that strtoul() parsed the complete string. As with the number overflow case, write a non-fatal error message to stdout. Signed-off-by: Milton Miller <miltonm@bga.com>
Diffstat (limited to 'dtc-parser.y')
-rw-r--r--dtc-parser.y14
1 files changed, 11 insertions, 3 deletions
diff --git a/dtc-parser.y b/dtc-parser.y
index 15caf5a..9e7fbcc 100644
--- a/dtc-parser.y
+++ b/dtc-parser.y
@@ -192,19 +192,27 @@ void yyerror (char const *s)
* Convert a string representation of a numeric cell
* in the given base into a cell.
*
- * FIXME: The string "abc123", base 10, should be flagged
- * as an error due to the leading "a", but isn't yet.
+ * FIXME: should these specification errors be fatal instead?
*/
cell_t cell_from_string(char *s, unsigned int base)
{
cell_t c;
+ char *e;
+
+ c = strtoul(s, &e, base);
+ if (*e) {
+ fprintf(stderr,
+ "Line %d: Invalid cell value '%s' : "
+ "%c is not a base %d digit; %d assumed\n",
+ yylloc.first_line, s, *e, base, c);
+ }
- c = strtoul(s, NULL, base);
if (errno == EINVAL || errno == ERANGE) {
fprintf(stderr,
"Line %d: Invalid cell value '%s'; %d assumed\n",
yylloc.first_line, s, c);
+ errno = 0;
}
return c;