utils/gprintf.c: Return the correct number of output characters.
[mLib] / utils / gprintf.c
index b575e1f..8825bd1 100644 (file)
@@ -416,9 +416,13 @@ int vgprintf(const struct gprintf_ops *ops, void *out,
 
     if (fs->fmt == fmt_unset) {
       switch (fs->ch) {
-       case 0: break;
-       case '%': ops->putch(out, '%'); break;
-       default: abort();
+       case 0:
+         break;
+       case '%':
+         if (ops->putch(out, '%')) return (-1);
+         tot++; break;
+       default:
+         abort();
       }
       continue;
     }
@@ -497,7 +501,7 @@ int vgprintf(const struct gprintf_ops *ops, void *out,
 #else
 #  define MSG "<no float support>"
        if (ops->putm(out, MSG, sizeof(MSG) - 1)) return (-1);
-       continue;
+       tot += sizeof(MSG) - 1; continue;
 #  undef MSG
 #endif
       case 's':