|
@@ -5,10 +5,11 @@
|
5
|
5
|
#include "errno.h"
|
6
|
6
|
#include "vsprintf.h"
|
7
|
7
|
|
8
|
|
-#define LONG_SHIFT ((int)((sizeof(unsigned long)*CHAR_BIT) - 4))
|
9
|
|
-#define INT_SHIFT ((int)((sizeof(unsigned int)*CHAR_BIT) - 4))
|
10
|
|
-#define SHRT_SHIFT ((int)((sizeof(unsigned short)*CHAR_BIT) - 4))
|
11
|
|
-#define CHAR_SHIFT ((int)((sizeof(unsigned char)*CHAR_BIT) - 4))
|
|
8
|
+#define LONGLONG_SHIFT ((int)((sizeof(unsigned long long)*CHAR_BIT) - 4))
|
|
9
|
+#define LONG_SHIFT ((int)((sizeof(unsigned long)*CHAR_BIT) - 4))
|
|
10
|
+#define INT_SHIFT ((int)((sizeof(unsigned int)*CHAR_BIT) - 4))
|
|
11
|
+#define SHRT_SHIFT ((int)((sizeof(unsigned short)*CHAR_BIT) - 4))
|
|
12
|
+#define CHAR_SHIFT ((int)((sizeof(unsigned char)*CHAR_BIT) - 4))
|
12
|
13
|
|
13
|
14
|
/** @file */
|
14
|
15
|
|
|
@@ -62,7 +63,11 @@ static int vsprintf(char *buf, const char *fmt, va_list args)
|
62
|
63
|
shift = LONG_SHIFT;
|
63
|
64
|
fmt++;
|
64
|
65
|
}
|
65
|
|
- else if (*fmt == 'h') {
|
|
66
|
+ if (*fmt == 'l') {
|
|
67
|
+ shift = LONGLONG_SHIFT;
|
|
68
|
+ fmt++;
|
|
69
|
+ }
|
|
70
|
+ if (*fmt == 'h') {
|
66
|
71
|
shift = SHRT_SHIFT;
|
67
|
72
|
fmt++;
|
68
|
73
|
if (*fmt == 'h') {
|
|
@@ -79,7 +84,9 @@ static int vsprintf(char *buf, const char *fmt, va_list args)
|
79
|
84
|
/* With x86 gcc, sizeof(long) == sizeof(int) */
|
80
|
85
|
unsigned long h;
|
81
|
86
|
int ncase;
|
82
|
|
- if (shift > INT_SHIFT) {
|
|
87
|
+ if (shift > LONG_SHIFT) {
|
|
88
|
+ h = va_arg(args, unsigned long long);
|
|
89
|
+ } else if (shift > INT_SHIFT) {
|
83
|
90
|
h = va_arg(args, unsigned long);
|
84
|
91
|
} else {
|
85
|
92
|
h = va_arg(args, unsigned int);
|
|
@@ -95,7 +102,9 @@ static int vsprintf(char *buf, const char *fmt, va_list args)
|
95
|
102
|
else if (*fmt == 'd') {
|
96
|
103
|
char *r, *t;
|
97
|
104
|
long i;
|
98
|
|
- if (shift > INT_SHIFT) {
|
|
105
|
+ if (shift > LONG_SHIFT) {
|
|
106
|
+ i = va_arg(args, long long);
|
|
107
|
+ } else if (shift > INT_SHIFT) {
|
99
|
108
|
i = va_arg(args, long);
|
100
|
109
|
} else {
|
101
|
110
|
i = va_arg(args, int);
|