diff options
author | Jakob Kaivo <jkk@ung.org> | 2019-03-15 15:54:38 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2019-03-15 15:54:38 -0400 |
commit | 5747b1a1ada4f77e37c61f3fd7b2bfd97ae29a35 (patch) | |
tree | 5ffd1745edb678ccbc370813476f8308e7d22461 | |
parent | 00a1b0aff0700353a4464a64722d8334b580ad9e (diff) |
add more explicit diagnosis for non-numeric conversion
-rw-r--r-- | printf.c | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -165,7 +165,11 @@ static const char *convert(const char *conv, const char *operand) diagnose("overflow converting \"%s\"", operand); } if (*end != '\0') { - diagnose("\"%s\" not completely converted", operand); + if (end == operand) { + diagnose("\"%s\" expected numeric value", operand); + } else { + diagnose("\"%s\" not completely converted", operand); + } } sprintf(fconv, "%c", *conv); strcat(oconv, fconv); @@ -180,7 +184,11 @@ static const char *convert(const char *conv, const char *operand) } else { i = strtoll(operand, &end, 0); if (*end != '\0') { - diagnose("\"%s\" not completely converted", operand); + if (end == operand) { + diagnose("\"%s\" expected numeric value", operand); + } else { + diagnose("\"%s\" not completely converted", operand); + } } } @@ -203,7 +211,11 @@ static const char *convert(const char *conv, const char *operand) } else { u = strtoull(operand, &end, 0); if (errno != 0) { - diagnose("overflow converting \"%s\"", operand); + if (end == operand) { + diagnose("\"%s\" expected numeric value", operand); + } else { + diagnose("overflow converting \"%s\"", operand); + } } } |