X-Git-Url: https://git.llucax.com/software/mutt-debian.git/blobdiff_plain/14c29200cb58d3c4a0830265f2433849781858d0..1bab28984d8d360498fe316bf13187c907273b47:/snprintf.c diff --git a/snprintf.c b/snprintf.c index 549a7a7..827b362 100644 --- a/snprintf.c +++ b/snprintf.c @@ -120,9 +120,10 @@ static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c ); #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 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args) 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 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args) 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 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args) 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 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args) 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 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args) 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 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args) 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); @@ -343,6 +356,12 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args) 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 { int *num; @@ -387,7 +406,7 @@ static void fmtstr (char *buffer, size_t *currlen, size_t maxlen, int padlen, strln; /* amount to pad */ int cnt = 0; - if (value == 0) + if (!value) { value = ""; }