summaryrefslogtreecommitdiff
path: root/sprintf.c
diff options
context:
space:
mode:
Diffstat (limited to 'sprintf.c')
-rw-r--r--sprintf.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sprintf.c b/sprintf.c
index de997098ba..e32c456b63 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -18,6 +18,8 @@
#include <math.h>
#define BIT_DIGITS(N) (((N)*146)/485 + 1) /* log2(10) =~ 146/485 */
+#define BITSPERDIG (SIZEOF_BDIGITS*CHAR_BIT)
+#define EXTENDSIGN(n, l) (((~0 << (n)) >> (((n)*(l)) % BITSPERDIG)) & ~(~0 << (n)))
static void fmt_setup _((char*,int,int,int,int));
@@ -36,7 +38,7 @@ remove_sign_bits(str, base)
}
}
else if (base == 8) {
- if (*t == '3') t++;
+ *t |= EXTENDSIGN(3, strlen(t));
while (*t == '7') {
t++;
}