annotate sources/patches/busybox-1.13.1-printf64.patch @ 680:924527b0b454

Fix ppc bios, this is the one from qemu svn 6657.
author Rob Landley <rob@landley.net>
date Mon, 30 Mar 2009 04:50:02 -0500
parents 8bd1aee4209f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
628
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
1 diff -d -urpN busybox.0/coreutils/printf.c busybox.1/coreutils/printf.c
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
2 --- busybox.0/coreutils/printf.c 2008-12-10 12:51:17.000000000 +0100
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
3 +++ busybox.1/coreutils/printf.c 2009-01-04 03:37:57.000000000 +0100
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
4 @@ -75,13 +75,13 @@ static int multiconvert(const char *arg,
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
5 return 0;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
6 }
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
7
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
8 -static void FAST_FUNC conv_strtoul(const char *arg, void *result)
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
9 +static void FAST_FUNC conv_strtoull(const char *arg, void *result)
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
10 {
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
11 - *(unsigned long*)result = bb_strtoul(arg, NULL, 0);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
12 + *(unsigned long long*)result = bb_strtoull(arg, NULL, 0);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
13 }
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
14 -static void FAST_FUNC conv_strtol(const char *arg, void *result)
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
15 +static void FAST_FUNC conv_strtoll(const char *arg, void *result)
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
16 {
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
17 - *(long*)result = bb_strtol(arg, NULL, 0);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
18 + *(long long*)result = bb_strtoll(arg, NULL, 0);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
19 }
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
20 static void FAST_FUNC conv_strtod(const char *arg, void *result)
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
21 {
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
22 @@ -96,17 +96,17 @@ static void FAST_FUNC conv_strtod(const
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
23 }
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
24
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
25 /* Callers should check errno to detect errors */
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
26 -static unsigned long my_xstrtoul(const char *arg)
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
27 +static unsigned long long my_xstrtoull(const char *arg)
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
28 {
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
29 - unsigned long result;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
30 - if (multiconvert(arg, &result, conv_strtoul))
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
31 + unsigned long long result;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
32 + if (multiconvert(arg, &result, conv_strtoull))
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
33 result = 0;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
34 return result;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
35 }
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
36 -static long my_xstrtol(const char *arg)
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
37 +static long long my_xstrtoll(const char *arg)
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
38 {
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
39 - long result;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
40 - if (multiconvert(arg, &result, conv_strtol))
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
41 + long long result;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
42 + if (multiconvert(arg, &result, conv_strtoll))
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
43 result = 0;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
44 return result;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
45 }
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
46 @@ -134,7 +134,7 @@ static void print_direc(char *format, un
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
47 int field_width, int precision,
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
48 const char *argument)
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
49 {
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
50 - long lv;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
51 + long long llv;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
52 double dv;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
53 char saved;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
54 char *have_prec, *have_width;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
55 @@ -153,42 +153,44 @@ static void print_direc(char *format, un
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
56 break;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
57 case 'd':
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
58 case 'i':
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
59 - lv = my_xstrtol(argument);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
60 + llv = my_xstrtoll(argument);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
61 print_long:
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
62 /* if (errno) return; - see comment at the top */
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
63 if (!have_width) {
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
64 if (!have_prec)
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
65 - printf(format, lv);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
66 + printf(format, llv);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
67 else
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
68 - printf(format, precision, lv);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
69 + printf(format, precision, llv);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
70 } else {
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
71 if (!have_prec)
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
72 - printf(format, field_width, lv);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
73 + printf(format, field_width, llv);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
74 else
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
75 - printf(format, field_width, precision, lv);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
76 + printf(format, field_width, precision, llv);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
77 }
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
78 break;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
79 case 'o':
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
80 case 'u':
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
81 case 'x':
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
82 case 'X':
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
83 - lv = my_xstrtoul(argument);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
84 + llv = my_xstrtoull(argument);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
85 /* cheat: unsigned long and long have same width, so... */
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
86 goto print_long;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
87 case 's':
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
88 - /* Are char* and long the same? (true for most arches) */
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
89 - if (sizeof(argument) == sizeof(lv)) {
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
90 - lv = (long)(ptrdiff_t)argument;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
91 + /* Are char* and long long the same? */
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
92 + if (sizeof(argument) == sizeof(llv)) {
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
93 + llv = (long long)(ptrdiff_t)argument;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
94 goto print_long;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
95 - } else { /* Hope compiler will optimize it out */
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
96 + } else {
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
97 + /* Hope compiler will optimize it out by moving call
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
98 + * instruction after the ifs... */
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
99 if (!have_width) {
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
100 if (!have_prec)
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
101 - printf(format, argument);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
102 + printf(format, argument, /*unused:*/ argument, argument);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
103 else
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
104 - printf(format, precision, argument);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
105 + printf(format, precision, argument, /*unused:*/ argument);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
106 } else {
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
107 if (!have_prec)
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
108 - printf(format, field_width, argument);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
109 + printf(format, field_width, argument, /*unused:*/ argument);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
110 else
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
111 printf(format, field_width, precision, argument);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
112 }
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
113 @@ -286,37 +288,48 @@ static char **print_formatted(char *f, c
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
114 }
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
115 }
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
116 }
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
117 - /* Remove size modifiers - "%Ld" would try to printf
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
118 - * long long, we pass long, and it spews garbage */
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
119 - if ((*f | 0x20) == 'l' || *f == 'h' || *f == 'z') {
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
120 - overlapping_strcpy(f, f + 1);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
121 - }
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
122 -//FIXME: actually, the same happens with bare "%d":
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
123 -//it printfs an int, but we pass long!
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
124 -//What saves us is that on most arches stack slot
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
125 -//is pointer-sized -> long-sized -> ints are promoted to longs
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
126 -// for variadic functions -> printf("%d", int_v) is in reality
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
127 -// indistinqushable from printf("%d", long_v) ->
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
128 -// since printf("%d", int_v) works, printf("%d", long_v) has to work.
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
129 -//But "clean" solution would be to add "l" to d,i,o,x,X.
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
130 -//Probably makes sense to go all the way to "ll" then.
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
131 -//Coreutils support long long-sized arguments.
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
132
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
133 - /* needed - try "printf %" without it */
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
134 - if (!strchr("diouxXfeEgGcs", *f)) {
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
135 - bb_error_msg("%s: invalid format", direc_start);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
136 - /* causes main() to exit with error */
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
137 - return saved_argv - 1;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
138 + /* Remove "lLhz" size modifiers. Repeatadly:
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
139 + * bash does not like "%lld", but coreutils
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
140 + * would happily take even "%Llllhhzhhzd"! */
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
141 + while ((*f | 0x20) == 'l' || *f == 'h' || *f == 'z') {
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
142 + overlapping_strcpy(f, f + 1);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
143 }
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
144 - ++direc_length;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
145 - if (*argv) {
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
146 - print_direc(direc_start, direc_length, field_width,
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
147 - precision, *argv);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
148 - ++argv;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
149 - } else {
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
150 - print_direc(direc_start, direc_length, field_width,
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
151 - precision, "");
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
152 + /* Add "ll" if integer modifier, then print */
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
153 + {
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
154 + static const char format_chars[] ALIGN1 = "diouxXfeEgGcs";
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
155 + char *p = strchr(format_chars, *f);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
156 + /* needed - try "printf %" without it */
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
157 + if (p == NULL) {
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
158 + bb_error_msg("%s: invalid format", direc_start);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
159 + /* causes main() to exit with error */
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
160 + return saved_argv - 1;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
161 + }
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
162 + ++direc_length;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
163 + if (p - format_chars <= 5) {
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
164 + /* it is one of "diouxX" */
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
165 + p = xmalloc(direc_length + 3);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
166 + memcpy(p, direc_start, direc_length);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
167 + p[direc_length + 1] = p[direc_length - 1];
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
168 + p[direc_length - 1] = 'l';
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
169 + p[direc_length] = 'l';
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
170 + //bb_error_msg("<%s>", p);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
171 + direc_length += 2;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
172 + direc_start = p;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
173 + } else {
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
174 + p = NULL;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
175 + }
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
176 + if (*argv) {
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
177 + print_direc(direc_start, direc_length, field_width,
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
178 + precision, *argv);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
179 + ++argv;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
180 + } else {
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
181 + print_direc(direc_start, direc_length, field_width,
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
182 + precision, "");
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
183 + }
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
184 + free(p);
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
185 }
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
186 +
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
187 /* if (errno) return saved_argv - 1; */
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
188 break;
8bd1aee4209f Need busybox svn 24680 to use the perl removal patches on a 32 bit host.
Rob Landley <rob@landley.net>
parents:
diff changeset
189 case '\\':