DragonFly-2.3.0.765.ge0f95 master include Makefile printf.h stdarg.h stdio.h lib/libc/include libc_private.h lib/libc/stdio Makefile.inc _flock_stub.c asprintf.c clrerr.c dprintf.c fclose.3 fclose.c fcloseall.c fdopen.c feof.c ferror.3 ferror.c fflush.3 fflush.c fgetc.c fgetln.3 fgetln.c fgetpos.c fgets.3 fgets.c fgetwc.c fgetwln.3 fgetwln.c fgetws.c fileno.c findfp.c flags.c floatio.h fopen.3 fopen.c fprintf.c fpurge.c fputc.c fputs.3 fputs.c fread.3 fread.c freopen.c fscanf.c fseek.3 fseek.c fsetpos.c ftell.c funopen.3 funopen.c fvwrite.c fwalk.c fwprintf.c fwrite.c fwscanf.c getc.3 getc.c getchar.c getdelim.c getline.3 getline.c gets.c getw.c getwc.3 getwc.c getwchar.c local.h makebuf.c mktemp.3 mktemp.c perror.c printf-pos.c printf.3 printf.c printfcommon.h printflocal.h priv_stdio.h putc.3 putc.c putchar.c puts.c putw.c putwc.3 putwc.c putwchar.c refill.c remove.3 remove.c rewind.c rget.c scanf.3 scanf.c setbuf.3 setbuf.c setbuffer.c setvbuf.c snprintf.c sprintf.c sscanf.c stdio.3 stdio.c swprintf.c swscanf.c tempnam.c tmpfile.c tmpnam.3 tmpnam.c ungetc.3 ungetc.c vasprintf.c vdprintf.c vfprintf.c vfscanf.c vfwprintf.c vfwscanf.c vprintf.c vscanf.c vsnprintf.c vsprintf.c vsscanf.c vswprintf.c vswscanf.c vwprintf.c vwscanf.c wbuf.c wprintf.3 wprintf.c wscanf.3 wscanf.c wsetup.c xprintf.c xprintf_errno.c xprintf_float.c xprintf_hexdump.c xprintf_int.c xprintf_quote.c xprintf_str.c xprintf_time.c xprintf_vis.c sys/sys cdefs.h

Peter Avalos pavalos at crater.dragonflybsd.org
Mon Apr 20 23:24:25 PDT 2009


commit e0f95098eeba0176864b9cafe6d69b5b7bc0e73f
Author: Peter Avalos <pavalos at dragonflybsd.org>
Date:   Sun Apr 19 05:26:39 2009 +0000

    Sync libc/stdio with FreeBSD:
    
    * Rewrite asprintf() as a wrapper around vasprintf().
    
    * Add dprintf() and vdprintf() from POSIX.1-2008.
    
    * Remove an obsolete comment from fclose.3 regarding the placement
    of a FUNLOCKFILE() call.
    
    * Remove useless variable 'nofile' in fdopen().
    
    * Remove comment about clearerr() being the only method of clearing
    the EOF indicator, fseek() may also be used for this.
    
    * Add commentary explaining why we return EBADF upon attempts to fflush()
    a read-only file.
    
    * Fix a few style and whitespace nits.
    
    * Suggest that fgets() be used instead of gets().
    
    * Don't use __sgetc() to avoid overwriting fwide(3) orientation
    (__srget() call by __sgetc() uses _SET_ORIENTATION macro).
    
    * Fix a sign-compare issue in fgetwln().
    
    * Use C99-style initializers.
    
    * Correct some buffer sizes.
    
    * Rework the floating point code in printf().  Significant changes:
    
     - We used to round long double arguments to double.  Now we print
     them properly.
    
     - Bugs involving '%F', corner cases of '#' and 'g' format
     specifiers, and the '.*' precision specifier have been fixed.
    
     - Added support for the "'" specifier to print thousands' grouping
     characters in a locale-dependent manner.
    
     - Implement the __vfprintf() side of hexadecimal floating point
     support.  All that is still needed is a routine to convert the
     mantissa to hex digits one nibble at a time in the style of ultoa().
    
    * Add restrict qualifier.
    
    * Add rewind() to the list of functions which may fail and set errno.
    
    * Improve documentation for fgetpos() and fsetpos(), and discourage
    users from assuming that fpos_t is an integral type.
    
    * Describe the restrictions on seeking on wide character streams, and also
    point out that fseek() clears the ungetwc() buffer.
    
    * Save errno from getting clobbered where appropriate.
    
    * Resulting fseek() offset must fit in long, required by POSIX,
    so add LONG_MAX and final tests for it.
    
    * Disallow negative seek as POSIX requires for fseek{o}.
    
    * Catch few possible off_t overflows.
    
    * Make fseek(... SEEK_CUR) fails if current file-position is unspecified.
    
    * Move all stdio internal flags processing and setting out of __sread(),
    __swrite() and __sseek() to higher level. According to funopen(3) they all
    are just wrappers to something like standard read(2), write(2) and
    lseek(2), i.e. must not touch stdio internals because they are replaceable
    with any other functions knows nothing about stdio internals.
    
    * Rename cantwrite() to prepwrite().  The latter is less confusing,
    since the macro isn't really a predicate, and it has side-effects.
    Also, don't set errno if prepwrite() fails, since this is done in
    prepwrite() now.
    
    * Fix a potential deadlock in _fwalk in a threaded environment.
    A file flag (__SIGN) was added to stdio.h that, when set, tells
    _fwalk to ignore it in its walk.  This seemed to be needed in
    refill.c because each file needs to be locked when flushing.
    
    * Call __sgetc() directly in getchar() instead of taking an expensive
    detour through getc().
    
    * Add getdelim() and getline().
    
    * Document dependence of mktemp(3) on the non-reentrant arc4random(3).
    
    * Fix a few bugs with the _gettemp() routine which implements mkstemp(),
    mkstemps(), and mkdtemp().
     - Add proper range checking for the 'slen' parameter passed to mkstemps().
     - Try all possible permutations of a template if a collision is encountered.
     Previously, once a single template character reached 'z', it would not wrap
     around to '0' and keep going until it encountered the original starting
     letter.  In the edge case that the randomly generated starting name used
     all 'z' characters, only that single name would be tried before giving up.
    
    * Use arc4random_uniform(3) since modulo size is not power of 2 in _gettemp.
    
    * Write the message to stderr, not file descriptor 2, so that perror()
    writes to the correct stream if stderr has been redirected with freopen().
    
    * Use strerror_r() to format the error message so that strerror()'s static
    buffer does not get clobbered in perror().
    
    * Move the positional argument handling code for vfprintf() to a new file,
    printf-pos.c, and move common definitions to printflocal.h.
    
    * Remove advertising clause in the copyrights.
    
    * In rewind.c:
     1) add missing __sinit() as in fseek() it pretends to be.
     2) use clearerr_unlocked() since we already lock stream before _fseeko()
     3) don't zero errno at the end, it explicitely required by POSIX as the
     only one method to test rewind() error condition.
     4) don't clearerr() if error happens in _fseeko()
    
    * When __SOPT is cleared, clear __SOFF too.
    
    * Save a few cycles and don't initialize the locking fields in FILE if
    they aren't going to be used later.
    
    * Add ENVIRONMENT section to tmpnam(3) and mention there that TMPDIR is
    ignored when issetugid(3) is true.  Also add a SECURITY CONSIDERATIONS
    section.
    
    * Describe file-position behaviour from POSIX in ungetc(3).
    
    * Remove duplicate check for EOF from ungetc(); __ungetc() already checks.
    
    * In vasprintf, free the buffer when __vfprintf() fails and don't bother
    trying to shrink the buffer with realloc() before returning it.
    
    * Rework the floating point code in printf().  Significant changes:
     - We used to round long double arguments to double.  Now we print
     them properly.
     - Bugs involving '%F', corner cases of '#' and 'g' format
     specifiers, and the '.*' precision specifier have been fixed.
     - Added support for the "'" specifier to print thousands' grouping
     characters in a locale-dependent manner.
     - Implement the __vfprintf() side of hexadecimal floating point
     support.  All that is still needed is a routine to convert the
     mantissa to hex digits one nibble at a time in the style of ultoa().
    
    * %e conversions with precision 0 should not cause a decimal point to
      be printed.
    
    * Fix %f conversions where the number of significant digits is < expt.
    
    * %E-like %g and %G conversions should remove trailing zeroes unless
    the # flag is present.  Implement this behavior and add a comment
    describing it.
    
    * Implement __hdtoa() and __hldtoa() and enable printf() support for %a
    and %A, which print floating-point numbers in hexadecimal.
    
    * Add an extensible printf implementation compatible with GLIBC.
    
    * Add support for multibyte decimal_point encodings, e.g., U+066B.
    
    * Add support for multibyte thousands_sep encodings, e.g., U+066C.
    The integer thousands' separator code is rewritten in order to
    avoid having to preallocate a buffer for the largest possible
    digit string with the most possible instances of the longest
    possible multibyte thousands' separator. The new version inserts
    thousands' separators for integers using the same code as floating point.
    
    * Introduce a local variable and use it instead of passed in parameter
    to get rid of restrict qualifier discarding in vswscanf().
    
    * Set the error indicator on an attempt to write to a read-only stream
    in wsetup.c.
    
    * Move the format_arg() attribute handling to <sys/cdefs.h> where it
    belongs.
    
    Obtained-from:  FreeBSD & NetBSD

Summary of changes:
 include/Makefile                 |    2 +-
 include/printf.h                 |  163 +++++
 include/stdarg.h                 |    3 +
 include/stdio.h                  |  320 ++++++----
 lib/libc/include/libc_private.h  |    8 -
 lib/libc/stdio/Makefile.inc      |   29 +-
 lib/libc/stdio/_flock_stub.c     |   75 +--
 lib/libc/stdio/asprintf.c        |   73 +--
 lib/libc/stdio/clrerr.c          |   16 +-
 lib/libc/stdio/dprintf.c         |   45 ++
 lib/libc/stdio/fclose.3          |   24 +-
 lib/libc/stdio/fclose.c          |   22 +-
 lib/libc/stdio/fcloseall.c       |   37 +
 lib/libc/stdio/fdopen.c          |   17 +-
 lib/libc/stdio/feof.c            |   21 +-
 lib/libc/stdio/ferror.3          |   51 ++-
 lib/libc/stdio/ferror.c          |   20 +-
 lib/libc/stdio/fflush.3          |    6 +-
 lib/libc/stdio/fflush.c          |   46 +-
 lib/libc/stdio/fgetc.c           |    6 +-
 lib/libc/stdio/fgetln.3          |    8 +-
 lib/libc/stdio/fgetln.c          |   19 +-
 lib/libc/stdio/fgetpos.c         |   23 +-
 lib/libc/stdio/fgets.3           |   17 +-
 lib/libc/stdio/fgets.c           |    8 +-
 lib/libc/stdio/fgetwc.c          |   56 +-
 lib/libc/stdio/fgetwln.3         |    9 +-
 lib/libc/stdio/fgetwln.c         |    4 +-
 lib/libc/stdio/fgetws.c          |    8 +-
 lib/libc/stdio/fileno.c          |   13 +-
 lib/libc/stdio/findfp.c          |   83 +--
 lib/libc/stdio/flags.c           |    6 +-
 lib/libc/stdio/floatio.h         |   24 +-
 lib/libc/stdio/fopen.3           |   10 +-
 lib/libc/stdio/fopen.c           |   16 +-
 lib/libc/stdio/fprintf.c         |    8 +-
 lib/libc/stdio/fpurge.c          |    7 +-
 lib/libc/stdio/fputc.c           |    9 +-
 lib/libc/stdio/fputs.3           |   20 +-
 lib/libc/stdio/fputs.c           |   14 +-
 lib/libc/stdio/fread.3           |   10 +-
 lib/libc/stdio/fread.c           |   18 +-
 lib/libc/stdio/freopen.c         |   40 +-
 lib/libc/stdio/fscanf.c          |    9 +-
 lib/libc/stdio/fseek.3           |  110 +++-
 lib/libc/stdio/fseek.c           |  134 +++--
 lib/libc/stdio/fsetpos.c         |    6 +-
 lib/libc/stdio/ftell.c           |   64 ++-
 lib/libc/stdio/funopen.3         |   20 +-
 lib/libc/stdio/funopen.c         |   12 +-
 lib/libc/stdio/fvwrite.c         |   39 +-
 lib/libc/stdio/fwalk.c           |   16 +-
 lib/libc/stdio/fwprintf.c        |    6 +-
 lib/libc/stdio/fwrite.c          |   11 +-
 lib/libc/stdio/fwscanf.c         |    8 +-
 lib/libc/stdio/getc.3            |   22 +-
 lib/libc/stdio/getc.c            |   10 +-
 lib/libc/stdio/getchar.c         |   18 +-
 lib/libc/stdio/getdelim.c        |  160 +++++
 lib/libc/stdio/getline.3         |  164 +++++
 lib/libc/stdio/getline.c         |   37 +
 lib/libc/stdio/gets.c            |   19 +-
 lib/libc/stdio/getw.c            |    6 +-
 lib/libc/stdio/getwc.3           |   26 +-
 lib/libc/stdio/getwc.c           |   21 +-
 lib/libc/stdio/getwchar.c        |   20 +-
 lib/libc/stdio/local.h           |   82 ++-
 lib/libc/stdio/makebuf.c         |   10 +-
 lib/libc/stdio/mktemp.3          |   17 +-
 lib/libc/stdio/mktemp.c          |   57 +-
 lib/libc/stdio/perror.c          |   23 +-
 lib/libc/stdio/printf-pos.c      |  755 +++++++++++++++++++++
 lib/libc/stdio/printf.3          |  201 +++++--
 lib/libc/stdio/printf.c          |    8 +-
 lib/libc/stdio/printfcommon.h    |  301 +++++++++
 lib/libc/stdio/printflocal.h     |   94 +++
 lib/libc/stdio/priv_stdio.h      |   20 +-
 lib/libc/stdio/putc.3            |   27 +-
 lib/libc/stdio/putc.c            |   19 +-
 lib/libc/stdio/putchar.c         |   30 +-
 lib/libc/stdio/puts.c            |   11 +-
 lib/libc/stdio/putw.c            |    6 +-
 lib/libc/stdio/putwc.3           |   40 +-
 lib/libc/stdio/putwc.c           |   21 +-
 lib/libc/stdio/putwchar.c        |   20 +-
 lib/libc/stdio/refill.c          |   35 +-
 lib/libc/stdio/remove.3          |    6 +-
 lib/libc/stdio/remove.c          |    6 +-
 lib/libc/stdio/rewind.c          |   19 +-
 lib/libc/stdio/rget.c            |    7 +-
 lib/libc/stdio/scanf.3           |   24 +-
 lib/libc/stdio/scanf.c           |    9 +-
 lib/libc/stdio/setbuf.3          |   28 +-
 lib/libc/stdio/setbuf.c          |    7 +-
 lib/libc/stdio/setbuffer.c       |    6 +-
 lib/libc/stdio/setvbuf.c         |   11 +-
 lib/libc/stdio/snprintf.c        |   14 +-
 lib/libc/stdio/sprintf.c         |   15 +-
 lib/libc/stdio/sscanf.c          |   15 +-
 lib/libc/stdio/stdio.3           |   88 ++-
 lib/libc/stdio/stdio.c           |  124 +++-
 lib/libc/stdio/swprintf.c        |    6 +-
 lib/libc/stdio/swscanf.c         |    6 +-
 lib/libc/stdio/tempnam.c         |    8 +-
 lib/libc/stdio/tmpfile.c         |    9 +-
 lib/libc/stdio/tmpnam.3          |  101 ++--
 lib/libc/stdio/tmpnam.c          |   11 +-
 lib/libc/stdio/ungetc.3          |   14 +-
 lib/libc/stdio/ungetc.c          |   27 +-
 lib/libc/stdio/vasprintf.c       |   21 +-
 lib/libc/stdio/vdprintf.c        |   65 ++
 lib/libc/stdio/vfprintf.c        | 1340 +++++++++++---------------------------
 lib/libc/stdio/vfscanf.c         |   77 ++-
 lib/libc/stdio/vfwprintf.c       | 1185 +++++++--------------------------
 lib/libc/stdio/vfwscanf.c        |   85 ++--
 lib/libc/stdio/vprintf.c         |   10 +-
 lib/libc/stdio/vscanf.c          |   10 +-
 lib/libc/stdio/vsnprintf.c       |   17 +-
 lib/libc/stdio/vsprintf.c        |   14 +-
 lib/libc/stdio/vsscanf.c         |   16 +-
 lib/libc/stdio/vswprintf.c       |   17 +-
 lib/libc/stdio/vswscanf.c        |   26 +-
 lib/libc/stdio/vwprintf.c        |    6 +-
 lib/libc/stdio/vwscanf.c         |    6 +-
 lib/libc/stdio/wbuf.c            |   11 +-
 lib/libc/stdio/wprintf.3         |    9 +-
 lib/libc/stdio/wprintf.c         |    6 +-
 lib/libc/stdio/wscanf.3          |    9 +-
 lib/libc/stdio/wscanf.c          |    6 +-
 lib/libc/stdio/wsetup.c          |   15 +-
 lib/libc/stdio/xprintf.c         |  694 ++++++++++++++++++++
 lib/libc/stdio/xprintf_errno.c   |   68 ++
 lib/libc/stdio/xprintf_float.c   |  429 ++++++++++++
 lib/libc/stdio/xprintf_hexdump.c |   99 +++
 lib/libc/stdio/xprintf_int.c     |  478 ++++++++++++++
 lib/libc/stdio/xprintf_quote.c   |  103 +++
 lib/libc/stdio/xprintf_str.c     |  190 ++++++
 lib/libc/stdio/xprintf_time.c    |  118 ++++
 lib/libc/stdio/xprintf_vis.c     |   80 +++
 sys/sys/cdefs.h                  |    8 +
 140 files changed, 6486 insertions(+), 3422 deletions(-)
 create mode 100644 include/printf.h
 create mode 100644 lib/libc/stdio/dprintf.c
 create mode 100644 lib/libc/stdio/fcloseall.c
 create mode 100644 lib/libc/stdio/getdelim.c
 create mode 100644 lib/libc/stdio/getline.3
 create mode 100644 lib/libc/stdio/getline.c
 create mode 100644 lib/libc/stdio/printf-pos.c
 create mode 100644 lib/libc/stdio/printfcommon.h
 create mode 100644 lib/libc/stdio/printflocal.h
 create mode 100644 lib/libc/stdio/vdprintf.c
 create mode 100644 lib/libc/stdio/xprintf.c
 create mode 100644 lib/libc/stdio/xprintf_errno.c
 create mode 100644 lib/libc/stdio/xprintf_float.c
 create mode 100644 lib/libc/stdio/xprintf_hexdump.c
 create mode 100644 lib/libc/stdio/xprintf_int.c
 create mode 100644 lib/libc/stdio/xprintf_quote.c
 create mode 100644 lib/libc/stdio/xprintf_str.c
 create mode 100644 lib/libc/stdio/xprintf_time.c
 create mode 100644 lib/libc/stdio/xprintf_vis.c

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/e0f95098eeba0176864b9cafe6d69b5b7bc0e73f


-- 
DragonFly BSD source repository





More information about the Commits mailing list