From 5747b1a1ada4f77e37c61f3fd7b2bfd97ae29a35 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Fri, 15 Mar 2019 15:54:38 -0400 Subject: add more explicit diagnosis for non-numeric conversion --- printf.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/printf.c b/printf.c index 7b6ef76..71f0e60 100644 --- a/printf.c +++ b/printf.c @@ -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); + } } } -- cgit v1.2.1