<<< Date Index >>>     <<< Thread Index >>>

[PATCH] snprintf "%lld" support



It seems easy and straightforward
to support %ll in snprintf.c.

Now config.h determines OFF_T_FMT,
snprintf should support %ll.

Otherwise, index_format="%c" displays
"dK" for medium-sized messages.

If you decide not to support %ll,
you should avoid %ll in config.h
or mutt_pretty_size.

-- 
tamo
diff -r 10a1f06bc8aa snprintf.c
--- a/snprintf.c        Tue Oct 07 19:22:53 2008 -0700
+++ b/snprintf.c        Wed Oct 22 14:55:47 2008 +0900
@@ -120,9 +120,10 @@
 #define DP_F_UNSIGNED  (1 << 6)
 
 /* Conversion Flags */
-#define DP_C_SHORT   1
-#define DP_C_LONG    2
-#define DP_C_LDOUBLE 3
+#define DP_C_SHORT    1
+#define DP_C_LONG     2
+#define DP_C_LONGLONG 3
+#define DP_C_LDOUBLE  4
 
 #define char_to_int(p) (p - '0')
 #undef MAX
@@ -230,7 +231,6 @@
        state = DP_S_MOD;
       break;
     case DP_S_MOD:
-      /* Currently, we don't support Long Long, bummer */
       switch (ch) 
       {
       case 'h':
@@ -240,6 +240,11 @@
       case 'l':
        cflags = DP_C_LONG;
        ch = *format++;
+       if (ch == 'l')
+       {
+         cflags = DP_C_LONGLONG;
+         ch = *format++;
+       }
        break;
       case 'L':
        cflags = DP_C_LDOUBLE;
@@ -259,6 +264,8 @@
          value = va_arg (args, short int);
        else if (cflags == DP_C_LONG)
          value = va_arg (args, long int);
+       else if (cflags == DP_C_LONGLONG)
+         value = va_arg (args, long long int);
        else
          value = va_arg (args, int);
        fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
@@ -269,6 +276,8 @@
          value = va_arg (args, unsigned short int);
        else if (cflags == DP_C_LONG)
          value = va_arg (args, unsigned long int);
+       else if (cflags == DP_C_LONGLONG)
+         value = va_arg (args, unsigned long long int);
        else
          value = va_arg (args, unsigned int);
        fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags);
@@ -279,6 +288,8 @@
          value = va_arg (args, unsigned short int);
        else if (cflags == DP_C_LONG)
          value = va_arg (args, unsigned long int);
+       else if (cflags == DP_C_LONGLONG)
+         value = va_arg (args, unsigned long long int);
        else
          value = va_arg (args, unsigned int);
        fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
@@ -291,6 +302,8 @@
          value = va_arg (args, unsigned short int);
        else if (cflags == DP_C_LONG)
          value = va_arg (args, unsigned long int);
+       else if (cflags == DP_C_LONGLONG)
+         value = va_arg (args, unsigned long long int);
        else
          value = va_arg (args, unsigned int);
        fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags);
@@ -341,6 +354,12 @@
        {
          long int *num;
          num = va_arg (args, long int *);
+         *num = currlen;
+        } 
+       else if (cflags == DP_C_LONGLONG) 
+       {
+         long long int *num;
+         num = va_arg (args, long long int *);
          *num = currlen;
         } 
        else