summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--printf.c18
1 files 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);
+ }
}
}