From 7388b1a84a0dc8253dcebfded31071ebd84d86e2 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 30 Jan 1998 17:21:34 +0000 Subject: [PATCH] (process_arg): Fix printing of octal zero in alternate form with precision of zero, which must produce "0". Add braces to avoid ambiguous `else'. --- stdio-common/vfprintf.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c index 82348af2377..0bcb1174927 100644 --- a/stdio-common/vfprintf.c +++ b/stdio-common/vfprintf.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc. +/* Copyright (C) 1991,92,93,94,95,96,97,98 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -531,12 +531,14 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap) else \ { \ if (fspec == NULL) \ - if (is_long) \ - number.word = va_arg (ap, unsigned long int); \ - else if (!is_short) \ - number.word = va_arg (ap, unsigned int); \ - else \ - number.word = (unsigned short int) va_arg (ap, unsigned int); \ + { \ + if (is_long) \ + number.word = va_arg (ap, unsigned long int); \ + else if (!is_short) \ + number.word = va_arg (ap, unsigned int); \ + else \ + number.word = (unsigned short int) va_arg (ap, unsigned int); \ + } \ else \ if (is_long) \ number.word = args_value[fspec->data_arg].pa_u_long_int; \ @@ -558,7 +560,11 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap) /* If the precision is 0 and the number is 0 nothing has to \ be written for the number. */ \ if (prec == 0 && number.word == 0) \ - string = workend; \ + { \ + string = workend; \ + if (base == 8 && alt) \ + *string-- = '0'; \ + } \ else \ { \ /* Put the number in WORK. */ \ @@ -838,14 +844,16 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap) LABEL (form_number): \ /* Answer the count of characters written. */ \ if (fspec == NULL) \ - if (is_longlong) \ - *(long long int *) va_arg (ap, void *) = done; \ - else if (is_long) \ - *(long int *) va_arg (ap, void *) = done; \ - else if (!is_short) \ - *(int *) va_arg (ap, void *) = done; \ - else \ - *(short int *) va_arg (ap, void *) = done; \ + { \ + if (is_longlong) \ + *(long long int *) va_arg (ap, void *) = done; \ + else if (is_long) \ + *(long int *) va_arg (ap, void *) = done; \ + else if (!is_short) \ + *(int *) va_arg (ap, void *) = done; \ + else \ + *(short int *) va_arg (ap, void *) = done; \ + } \ else \ if (is_longlong) \ *(long long int *) args_value[fspec->data_arg].pa_pointer = done; \ -- 2.47.2