diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/vsprintf.c | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 7536acea135b..b56f6d039d21 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -408,6 +408,8 @@ enum format_type { | |||
408 | FORMAT_TYPE_LONG_LONG, | 408 | FORMAT_TYPE_LONG_LONG, |
409 | FORMAT_TYPE_ULONG, | 409 | FORMAT_TYPE_ULONG, |
410 | FORMAT_TYPE_LONG, | 410 | FORMAT_TYPE_LONG, |
411 | FORMAT_TYPE_UBYTE, | ||
412 | FORMAT_TYPE_BYTE, | ||
411 | FORMAT_TYPE_USHORT, | 413 | FORMAT_TYPE_USHORT, |
412 | FORMAT_TYPE_SHORT, | 414 | FORMAT_TYPE_SHORT, |
413 | FORMAT_TYPE_UINT, | 415 | FORMAT_TYPE_UINT, |
@@ -853,11 +855,15 @@ qualifier: | |||
853 | spec->qualifier = -1; | 855 | spec->qualifier = -1; |
854 | if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || | 856 | if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || |
855 | *fmt == 'Z' || *fmt == 'z' || *fmt == 't') { | 857 | *fmt == 'Z' || *fmt == 'z' || *fmt == 't') { |
856 | spec->qualifier = *fmt; | 858 | spec->qualifier = *fmt++; |
857 | ++fmt; | 859 | if (unlikely(spec->qualifier == *fmt)) { |
858 | if (spec->qualifier == 'l' && *fmt == 'l') { | 860 | if (spec->qualifier == 'l') { |
859 | spec->qualifier = 'L'; | 861 | spec->qualifier = 'L'; |
860 | ++fmt; | 862 | ++fmt; |
863 | } else if (spec->qualifier == 'h') { | ||
864 | spec->qualifier = 'H'; | ||
865 | ++fmt; | ||
866 | } | ||
861 | } | 867 | } |
862 | } | 868 | } |
863 | 869 | ||
@@ -919,6 +925,11 @@ qualifier: | |||
919 | spec->type = FORMAT_TYPE_SIZE_T; | 925 | spec->type = FORMAT_TYPE_SIZE_T; |
920 | } else if (spec->qualifier == 't') { | 926 | } else if (spec->qualifier == 't') { |
921 | spec->type = FORMAT_TYPE_PTRDIFF; | 927 | spec->type = FORMAT_TYPE_PTRDIFF; |
928 | } else if (spec->qualifier == 'H') { | ||
929 | if (spec->flags & SIGN) | ||
930 | spec->type = FORMAT_TYPE_BYTE; | ||
931 | else | ||
932 | spec->type = FORMAT_TYPE_UBYTE; | ||
922 | } else if (spec->qualifier == 'h') { | 933 | } else if (spec->qualifier == 'h') { |
923 | if (spec->flags & SIGN) | 934 | if (spec->flags & SIGN) |
924 | spec->type = FORMAT_TYPE_SHORT; | 935 | spec->type = FORMAT_TYPE_SHORT; |
@@ -1087,6 +1098,12 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) | |||
1087 | case FORMAT_TYPE_PTRDIFF: | 1098 | case FORMAT_TYPE_PTRDIFF: |
1088 | num = va_arg(args, ptrdiff_t); | 1099 | num = va_arg(args, ptrdiff_t); |
1089 | break; | 1100 | break; |
1101 | case FORMAT_TYPE_UBYTE: | ||
1102 | num = (unsigned char) va_arg(args, int); | ||
1103 | break; | ||
1104 | case FORMAT_TYPE_BYTE: | ||
1105 | num = (signed char) va_arg(args, int); | ||
1106 | break; | ||
1090 | case FORMAT_TYPE_USHORT: | 1107 | case FORMAT_TYPE_USHORT: |
1091 | num = (unsigned short) va_arg(args, int); | 1108 | num = (unsigned short) va_arg(args, int); |
1092 | break; | 1109 | break; |
@@ -1363,6 +1380,10 @@ do { \ | |||
1363 | case FORMAT_TYPE_PTRDIFF: | 1380 | case FORMAT_TYPE_PTRDIFF: |
1364 | save_arg(ptrdiff_t); | 1381 | save_arg(ptrdiff_t); |
1365 | break; | 1382 | break; |
1383 | case FORMAT_TYPE_UBYTE: | ||
1384 | case FORMAT_TYPE_BYTE: | ||
1385 | save_arg(char); | ||
1386 | break; | ||
1366 | case FORMAT_TYPE_USHORT: | 1387 | case FORMAT_TYPE_USHORT: |
1367 | case FORMAT_TYPE_SHORT: | 1388 | case FORMAT_TYPE_SHORT: |
1368 | save_arg(short); | 1389 | save_arg(short); |
@@ -1538,6 +1559,12 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf) | |||
1538 | case FORMAT_TYPE_PTRDIFF: | 1559 | case FORMAT_TYPE_PTRDIFF: |
1539 | num = get_arg(ptrdiff_t); | 1560 | num = get_arg(ptrdiff_t); |
1540 | break; | 1561 | break; |
1562 | case FORMAT_TYPE_UBYTE: | ||
1563 | num = get_arg(unsigned char); | ||
1564 | break; | ||
1565 | case FORMAT_TYPE_BYTE: | ||
1566 | num = get_arg(signed char); | ||
1567 | break; | ||
1541 | case FORMAT_TYPE_USHORT: | 1568 | case FORMAT_TYPE_USHORT: |
1542 | num = get_arg(unsigned short); | 1569 | num = get_arg(unsigned short); |
1543 | break; | 1570 | break; |