summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2010-08-30 23:08:08 +0000
committerRafaël Carré <rafael.carre@gmail.com>2010-08-30 23:08:08 +0000
commit640c4107f3bd657015486f2d487230aa5e6f6e33 (patch)
tree4b204a687a95a487329bee656a92d85e840d9929
parent99207d647533f995fe05fbd15ed8d0c829ee6006 (diff)
downloadrockbox-640c4107f3bd657015486f2d487230aa5e6f6e33.tar.gz
rockbox-640c4107f3bd657015486f2d487230aa5e6f6e33.zip
format: supports %zd (ssize_t) and %zu (ssize_t)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27953 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/common/format.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/firmware/common/format.c b/firmware/common/format.c
index 2655a871c9..0fa838f511 100644
--- a/firmware/common/format.c
+++ b/firmware/common/format.c
@@ -42,6 +42,8 @@ int format(
long lval, lsign;
unsigned int uval;
unsigned long ulval;
+ size_t uszval;
+ ssize_t szval, szsign;
bool ok = true;
tmpbuf[sizeof tmpbuf - 1] = '\0';
@@ -167,6 +169,40 @@ int format(
break;
+ case 'z':
+ ch = *fmt++;
+ switch(ch) {
+ case 'd':
+ szval = szsign = va_arg (ap, long);
+ if (szval < 0)
+ szval = -szval;
+ do
+ {
+ *--str = (szval % 10) + '0';
+ szval /= 10;
+ }
+ while (szval > 0);
+ if (szsign < 0)
+ *--str = '-';
+ break;
+
+ case 'u':
+ uszval = va_arg(ap, size_t);
+ do
+ {
+ *--str = (uszval % 10) + '0';
+ uszval /= 10;
+ }
+ while (uszval > 0);
+ break;
+
+ default:
+ *--str = 'z';
+ *--str = ch;
+ }
+
+ break;
+
default:
*--str = ch;
break;