1
0
mirror of https://github.com/adtools/clib2.git synced 2025-12-08 14:59:05 +00:00

- The printf() family no longer adds a 0 or 0x prefix if the alternate

conversion modifier is present for the %o and %x conversions and the
  value to be converted is 0 already. Put another way, printf("%#x %#o",0,0);
  now prints "0 0". This required another change so that %p always includes
  the 0x prefix even if the pointer involved is a NULL pointer.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15162 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
Olaf Barthel
2006-11-13 09:32:28 +00:00
parent e789564429
commit 7e1d5d6f6a
2 changed files with 18 additions and 10 deletions

View File

@ -1,3 +1,9 @@
- The printf() family no longer adds a 0 or 0x prefix if the alternate
conversion modifier is present for the %o and %x conversions and the
value to be converted is 0 already. Put another way, printf("%#x %#o",0,0);
now prints "0 0". This required another change so that %p always includes
the 0x prefix even if the pointer involved is a NULL pointer.
- readlink() no longer sort-of-works for files and directories. It now only
works for soft linked objects and returns an error for everything else.
This is based upon a fix by Peter Bengtsson. Thank you very much!

View File

@ -1,5 +1,5 @@
/*
* $Id: stdio_vfprintf.c,v 1.24 2006-09-25 14:51:15 obarthel Exp $
* $Id: stdio_vfprintf.c,v 1.25 2006-11-13 09:32:28 obarthel Exp $
*
* :ts=4
*
@ -580,7 +580,7 @@ vfprintf(FILE * stream,const char * format, va_list arg)
conversion_type = 'x';
SET_FLAG(format_flags,FORMATF_AlternateConversion);
SET_FLAG(format_flags,FORMATF_HexPrefix);
fill_character = '0';
minimum_field_width = 8;
@ -1269,6 +1269,16 @@ vfprintf(FILE * stream,const char * format, va_list arg)
const char * digit_encoding;
int radix;
/* Only add the zero (%o) or hex (%x) prefix if the value to
be converted is non-zero. */
if(FLAG_IS_SET(format_flags,FORMATF_AlternateConversion) && v != 0)
{
if(conversion_type == 'o')
SET_FLAG(format_flags,FORMATF_ZeroPrefix);
else if (conversion_type == 'x')
SET_FLAG(format_flags,FORMATF_HexPrefix);
}
if(conversion_type == 'o')
radix = 8;
else if (conversion_type == 'x')
@ -1291,14 +1301,6 @@ vfprintf(FILE * stream,const char * format, va_list arg)
}
while(v > 0 && buffer < output_buffer);
if(FLAG_IS_SET(format_flags,FORMATF_AlternateConversion))
{
if(conversion_type == 'o')
SET_FLAG(format_flags,FORMATF_ZeroPrefix);
else if (conversion_type == 'x')
SET_FLAG(format_flags,FORMATF_HexPrefix);
}
while(output_len < precision && output_buffer > buffer)
{
output_buffer--;