History log of /freebsd-current/lib/libc/stdio/vfscanf.c
Revision Date Author Comments
# dc36d6f9 23-Nov-2023 Warner Losh <imp@FreeBSD.org>

lib: Remove ancient SCCS tags.

Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by: Netflix


# 559a218c 01-Nov-2023 Warner Losh <imp@FreeBSD.org>

libc: Purge unneeded cdefs.h

These sys/cdefs.h are not needed. Purge them. They are mostly left-over
from the $FreeBSD$ removal. A few in libc are still required for macros
that cdefs.h defines. Keep those.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D42385


# bce0bef3 07-Sep-2023 Dag-Erling Smørgrav <des@FreeBSD.org>

libc: Implement N2680.

This adds specific width length modifiers in the form of wN and wfN (where N is 8, 16, 32, or 64) which allow printing intN_t and int_fastN_t without resorting to casts or PRI macros.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D41725


# aca3bd16 28-Aug-2023 Dag-Erling Smørgrav <des@FreeBSD.org>

libc: Fix fixed-width case in the new integer parser.

Fixes: d9dc1603d6e4
Differential Revision: https://reviews.freebsd.org/D41622


# d9dc1603 28-Aug-2023 Dag-Erling Smørgrav <des@FreeBSD.org>

libc: Implement N2630.

This adds formatted input/output of binary integer numbers to the printf(), scanf(), and strtol() families, including their wide-character counterparts.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D41511


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 5b5fa75a 04-Aug-2022 Ed Maste <emaste@FreeBSD.org>

libc: drop "All rights reserved" from Foundation copyrights

This has already been done for most files that have the Foundation as
the only listed copyright holder. Do it now for files that list
multiple copyright holders, but have the Foundation copyright in its own
section.

Sponsored by: The FreeBSD Foundation


# 8a16b7a1 20-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

General further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.


# fda0a14f 29-Jun-2017 Konstantin Belousov <kib@FreeBSD.org>

Make stdio deferred cancel-safe.

If used with fopen(3)/fdopen(3)-ed FILEs, stdio accurately uses
non-cancellable internal versions of the functions, i.e. it seems to
be fine with regard to cancellation. But if the funopen(3) and
f{r,w}open(3) functions were used to open the FILE, and corresponding
user functions create cancellation points (they typically have no
other choice), then stdio code at least leaks FILE' lock.

The change installs cleanup handler which unlocks FILE. Some minimal
restructuring of the code was required to make it use common return
place to satisfy hand-rolled pthread_cleanup_pop() requirements.

Noted by: eugen
Reviewed by: eugen, vangyzen
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D11246


# 12eae8c8 14-Jul-2016 Andrey A. Chernov <ache@FreeBSD.org>

1) Eliminate possibility to call __*collate_range_cmp() with inclomplete
locale (which cause core dump) by removing whole 'table' argument
by which it passed.

2) Restore __collate_range_cmp() in __sccl().

3) Collating [a-z] range in regcomp() only for single bytes locales
(we can't do it now for other ones). In previous state only first 256
wchars are considered and all others are just silently dropped from the
range.


# 1daad8f5 14-Jul-2016 Andrey A. Chernov <ache@FreeBSD.org>

Back out non-collating [a-z] ranges.
Instead of changing whole course to another POSIX-permitted way
for consistency and uniformity I decide to completely ignore missing
regex fucntionality and concentrace on fixing bugs in what we have now,
too many small obstacles instead, counting ports.


# 5a5807dd 09-Jul-2016 Andrey A. Chernov <ache@FreeBSD.org>

Remove broken support for collation in [a-z] type ranges.
Only first 256 wide chars are considered currently, all other are just
dropped from the range. Proper implementation require reverse tables
database lookup, since objects are really big as max UTF-8 (1114112
code points), so just the same scanning as it was for 256 chars will
slow things down.

POSIX does not require collation for [a-z] type ranges and does not
prohibit it for non-POSIX locales. POSIX require collation for ranges
only for POSIX (or C) locale which is equal to ASCII and binary for
other chars, so we already have it.

No other *BSD implements collation for [a-z] type ranges.

Restore ABI compatibility with unused now __collate_range_cmp() which
is visible from outside (will be removed later).


# b2f8f05c 09-Jun-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

Fix regression from r301461.

The fix to the __collate_range_cmp() ABI breakage missed some replacements
in libc's vfscanf(). Replace them with __wcollate_range_cmp() which
does what is expected.

This was breaking applications like xterm and pidgin when using wide
characters.

Reported by: Vitalij Satanivskij
Approved by: re


# 32223c1b 29-Apr-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

libc: spelling fixes.

Mostly on comments.


# 25070501 20-Sep-2015 Craig Rodrigues <rodrigc@FreeBSD.org>

Use ANSI C prototypes. Eliminates -Wold-style-definition warnings.


# 1d8053c5 23-Apr-2013 Ed Maste <emaste@FreeBSD.org>

Renumber clauses to reduce diffs to other versions

NetBSD, OpenBSD, and Android's Bionic all number the clauses 1 through 3,
so follow suit to make comparison easier.

Acked-by: imp@


# 671c0336 30-Apr-2012 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

Remove incorrect __restrict qualifier on several pointers

The typical case was:
static __inline int
convert_ccl(FILE *fp, char * __restrict p, [...])
{
[...]

if (p == SUPPRESS_PTR) {
[...]
} else {
[...]
}

[...]
}

This qualifier says that the pointer is the only one at that time
pointing to the resource.

Here, clang considers that "p" will never match "SUPPRESS_PTR" and
optimize the if{} block out. This leads to segfaults in programs calling
vfscanf(3) and vfwscanf(3) with just the format string (no arguments
following it).

The following softwares were reported to abort with segmentation fault
and this patch fixes it:
o cmake
o smartd
o devel/ORBit2

dim@ opened an LLVM PR to discuss this clang optimization:
http://llvm.org/bugs/show_bug.cgi?id=12656

Tested by: bsam@


# d7af8cf1 29-Apr-2012 David Schultz <das@FreeBSD.org>

Previously, vfscanf()'s wide character processing functions were
reading wide characters manually. With this change, they now use
fgetwc(). To make this work, we use an internal version of fgetwc()
with a few extensions: it takes an mbstate * because non-wide streams
don't have a built-in mbstate, and it indicates the number of bytes
read.

vfscanf() now resembles vfwscanf() more closely. Minor functional
improvements include working xlocale support in vfscanf(), setting the
stream error indicator on encoding errors, and proper handling of
shift-based encodings. (Actually, making shift-based encodings work
with non-wide streams is hopeless, but the implementation now matches
the broken specification.)


# f010dc7d 22-Apr-2012 David Schultz <das@FreeBSD.org>

Bugfix: Correctly count the number of characters read for %l[ conversions.


# 01d2a785 22-Apr-2012 David Schultz <das@FreeBSD.org>

Bugfix: %n doesn't count as a conversion, so
sscanf("abc", "ab%ncd", &i) returns EOF, not 0.


# 51300896 22-Apr-2012 David Schultz <das@FreeBSD.org>

Refactor scanf to improve modularity. Conversions are now performed
by separate conversion functions. This will hopefully make bugs more
noticeable (I noticed several already) and provide opportunities to
reduce code duplication.


# 3c87aa1d 20-Nov-2011 David Chisnall <theraven@FreeBSD.org>

Implement xlocale APIs from Darwin, mainly for use by libc++. This adds a
load of _l suffixed versions of various standard library functions that use
the global locale, making them take an explicit locale parameter. Also
adds support for per-thread locales. This work was funded by the FreeBSD
Foundation.

Please test any code you have that uses the C standard locale functions!

Reviewed by: das (gdtoa changes)
Approved by: dim (mentor)


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# f8f57193 18-Jan-2009 David Schultz <das@FreeBSD.org>

- Add support for multibyte decimal_point encodings, e.g., U+066B.
A forthcoming gdtoa import is needed to make this fully work.
- Improve the way "nan(...)" is parsed.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 1b12fbb1 09-Dec-2007 David Schultz <das@FreeBSD.org>

Remove some test instrumentation. (The Symbol.map changes broke it anyway.)


# c879ae35 08-Jan-2007 Warner Losh <imp@FreeBSD.org>

Per Regents of the University of Calfornia letter, remove advertising
clause.

# If I've done so improperly on a file, please let me know.


# 75239a01 01-Apr-2006 Poul-Henning Kamp <phk@FreeBSD.org>

Add missing #if's for NO_FLOATING_POINT


# 3b52e4d1 15-Dec-2005 David Xu <davidxu@FreeBSD.org>

With current pthread implementations, a mutex initialization will
allocate a memory block. sscanf calls __svfscanf which in turn calls
fread, fread triggers mutex initialization but the mutex is not
destroyed in sscanf, this leads to memory leak. To avoid the memory
leak and performance issue, we create a none MT-safe version of fread:
__fread, and instead let __svfscanf call __fread.

PR: threads/90392
Patch submitted by: dhartmei
MFC after: 7 days


# e413b7d2 08-Apr-2005 Stefan Farfeleder <stefanf@FreeBSD.org>

Remove unused variable.


# 8de9e897 02-May-2004 David Schultz <das@FreeBSD.org>

- To make it easier to compile *printf() and *scanf() without
floating-point support, remove default definition of FLOATING_POINT
from the source, and change the compile-time option to
NO_FLOATING_POINT.
- Remove the HEXFLOAT option. It saves an insignificant amount of
space (<0.1% of the size of libc on i386) and complicates vfprintf()
and checkfmt().


# 93996f6d 07-Apr-2004 Tim J. Robbins <tjr@FreeBSD.org>

Prepare to handle trivial state-dependent encodings. Full support for
state-dependent encodings with locking shifts will come later if there
is demand for it.


# ff813456 31-Jan-2004 David Schultz <das@FreeBSD.org>

Fix the handling of negative hexadecimal numbers in integer formats.
Note that this bug is unrelated to recent work in this area; it seems
to have been present since revision 1.1.

Obtained from: NetBSD


# 27a97dff 06-Jan-2004 Jacques Vidrine <nectar@FreeBSD.org>

Make intentions explicit with additional parenthesis.


# 2a49d376 05-Nov-2003 Tim J. Robbins <tjr@FreeBSD.org>

Pass NULL instead of a pointer to a zeroed mbstate_t object.


# 370077c7 28-Jun-2003 David Schultz <das@FreeBSD.org>

Revamp scanf's floating-point-parsing algorithm to support
[+|-]Inf, [+|-]NaN, nan(...), and hexidecimal FP constants.
While here, add %a and %A, which are aliases for %e, and
add support for long doubles.

Reviewed by: standards@


# 14ffdae9 31-Oct-2002 Tim J. Robbins <tjr@FreeBSD.org>

No need to include floatio.h here: vfscanf() no longer uses anything
it defines.


# 0145ba86 17-Oct-2002 Tim J. Robbins <tjr@FreeBSD.org>

Fix off-by-one error when pushing back a multibyte sequence in
wide character class (%l[) and wide string (%ls) conversions.


# 63b01047 16-Oct-2002 Tim J. Robbins <tjr@FreeBSD.org>

Make part of the previous change clearer; check flags for SUPPRESS directly
instead of checking whether we're using a temporary buffer.


# 35739e07 16-Oct-2002 Tim J. Robbins <tjr@FreeBSD.org>

Count field width correctly for suppressed multibyte fields (%*lc,
%*ls, %*l[).


# 6180233f 15-Oct-2002 Tim J. Robbins <tjr@FreeBSD.org>

Set the error bit on the stream if an encoding error occurs. Improve
handling of multibyte sequences representing null wide characters.


# af1c9c0e 14-Oct-2002 Tim J. Robbins <tjr@FreeBSD.org>

Use a weak reference instead of a macro to make vfscanf an alias
for __vfscanf.


# 4712aa3b 23-Sep-2002 Tim J. Robbins <tjr@FreeBSD.org>

Implement the %lc, %ls and %[ conversions, which read sequences of wide
characters, non-whitespace wide character strings and wide character
strings in a scanset.


# e74101e4 13-Aug-2002 Tim J. Robbins <tjr@FreeBSD.org>

Basic support for wide character I/O: getwc(), fgetwc(), getwchar(),
putwc(), fputwc(), putwchar(), ungetwc(), fwide().


# a82bbc73 28-May-2002 Alfred Perlstein <alfred@FreeBSD.org>

Assume __STDC__, remove non-__STDC__ code.

Submitted by: keramida


# 946b2d00 20-Apr-2002 Bill Fenner <fenner@FreeBSD.org>

Implement several of the c99 updates to scanf(3):
- New length modifiers: hh, j, ll, t, z.

Still to do:
- %C, %S, %lc, %ls (wide character support)
- %a/%A (exact hex representation of floating-point numbers)

Removed old compatability equivalents:
- %D for %ld, %O for %lo, %X for %lx, %E and %F for %le & %lf (these
were buggy anyway, since they should have represented %Le & %Lf).
- %[unknown uppercase char] for %ld, %[unknown lowercase char] for %d


# 333fc21e 22-Mar-2002 David E. O'Brien <obrien@FreeBSD.org>

Fix the style of the SCM ID's.
I believe have made all of libc .c's as consistent as possible.


# 8fb3f3f6 21-Mar-2002 David E. O'Brien <obrien@FreeBSD.org>

Remove 'register' keyword.


# 2209d8a2 28-Nov-2001 Andrey A. Chernov <ache@FreeBSD.org>

Back out national digits support, POSIX explicetely disallows it:

The definition of character class digit requires that only ten characters
-the ones defining digits- can be specified; alternate digits (for
example, Hindi or Kanji) cannot be specified here. However, the encoding
may vary if an implementation supports more than one encoding.

The definition of character class xdigit requires that the characters
included in character class digit are included here also and allows for
different symbols for the hexadecimal digits 10 through 15.


# 87c25490 27-Nov-2001 Andrey A. Chernov <ache@FreeBSD.org>

Don't ever assume that isdigit() is always subset of isxdigit()


# 997aec5b 27-Nov-2001 Andrey A. Chernov <ache@FreeBSD.org>

Allow national (non-ASCII) digits


# a2a135c9 09-Feb-2001 Andrey A. Chernov <ache@FreeBSD.org>

Use decimal point from localeconv() instead of hardcoded '.' (SUSv2)


# d201fe46 24-Jan-2001 Daniel Eischen <deischen@FreeBSD.org>

Remove _THREAD_SAFE and make libc thread-safe by default by
adding (weak definitions to) stubs for some of the pthread
functions. If the threads library is linked in, the real
pthread functions will pulled in.

Use the following convention for system calls wrapped by the
threads library:
__sys_foo - actual system call
_foo - weak definition to __sys_foo
foo - weak definition to __sys_foo

Change all libc uses of system calls wrapped by the threads
library from foo to _foo. In order to define the prototypes
for _foo(), we introduce namespace.h and un-namespace.h
(suggested by bde). All files that need to reference these
system calls, should include namespace.h before any standard
includes, then include un-namespace.h after the standard
includes and before any local includes. <db.h> is an exception
and shouldn't be included in between namespace.h and
un-namespace.h namespace.h will define foo to _foo, and
un-namespace.h will undefine foo.

Try to eliminate some of the recursive calls to MT-safe
functions in libc/stdio in preparation for adding a mutex
to FILE. We have recursive mutexes, but would like to avoid
using them if possible.

Remove uneeded includes of <errno.h> from a few files.

Add $FreeBSD$ to a few files in order to pass commitprep.

Approved by: -arch


# 7f3dea24 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 5846581c 24-Sep-1998 David E. O'Brien <obrien@FreeBSD.org>

Apply patch to properly sscanf(3) when there is whitespace in the format
string. From the submitted patch:

Credit for patch: Chris Torek <torek@bsdi.com>
Tod Miller <millert@openbsd.org>

This makes us in line with SunOS 4.1.3_U1, Solaris 2.6, OpenBSD 2.3,
HP-UX 10.20, Irix 5.3. The previous behavior was in line with Ultrix 4.4.

PR: bin/7970
Submitted by: Niall Smart nialls@euristix.ie


# 8fddd060 22-Nov-1997 Bruce Evans <bde@FreeBSD.org>

Fixed long double formats. They were mostly not implemented except
on systems where long doubles are just doubles. FreeBSD hasn't
been such a system since it started using gcc-2.5 many years ago.
The fix is of low quality. It loses precision.

scanf() of long doubles doesn't seem to be used much, but gdb-4.16
uses %Lg format in its expression parser if it thinks that the
system supports printf'ing of long doubles. The symptom was that
floating point literals were usually interpreted to be 0.0.


# 5e17038f 01-Jul-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Add 64 bit int support to scanf()
PR: 2080
Submitted by: David Dawes <dawes@rf900.physics.usyd.edu.au>


# ed2bf9a9 04-Apr-1997 Andrey A. Chernov <ache@FreeBSD.org>

Eliminate yet one function call when locale not used


# 350498c5 04-Apr-1997 Andrey A. Chernov <ache@FreeBSD.org>

Speedup in case locale not used


# e836e480 03-Mar-1997 Bruce Evans <bde@FreeBSD.org>

Fixed handling of input failure by the scanf family.
- 0 was returned instead of EOF when an input failure occured while
skipping white-space after 0 assignments. This fixes PR2606. The
diagnosis in PR2606 is wrong.
- EOF was returned instead of 0 when an input failure occurred after
zero assignments and nonzero suppressed assignments.
- EOF was spelled -1.

This should be in 2.2.


# 7e546392 22-Feb-1997 Peter Wemm <peter@FreeBSD.org>

Revert $FreeBSD$ to $Id$


# 628abd1b 05-Feb-1997 Andrey A. Chernov <ache@FreeBSD.org>

Add XXX comment describing potential memset non-portable issue

Nitpicked-by: joerg


# ea295661 16-Jan-1997 Andrey A. Chernov <ache@FreeBSD.org>

Use collate for national [a-z]-like ranges

Should go in 2.2


# 1130b656 14-Jan-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# ce51cf03 22-Jun-1996 James Raynard <jraynard@FreeBSD.org>

Suggested by: Bruce Evans, Jeffrey Hsu, Gary Palmer

Added $Id$'s to files that were lacking them (gpalmer), made some
cosmetic changes to conform to style guidelines (bde) and checked
against NetBSD and Lite2 to remove unnecessary divergences (hsu, bde)

One last code cleanup:-

Removed spurious casts in fseek.c and stdio.c.
Added missing function argument in fwalk.c.
Added missing header include in flags.c and rget.c.
Put in casts where int's were being passed as size_t's.
Put in missing prototypes for static functions.
Changed second args of __sflags() inflags.c and writehook() in vasprintf.c
from char * to const char * to conform to prototypes.

This directory now compiles with no warnings with -Wall under
gcc-2.6.3 and with considerably less warnings than before with the
ultra-pedantic script I used for testing. (Most of the remaining ones
are due to const poisoning).


# 45f6af02 12-Jun-1996 James Raynard <jraynard@FreeBSD.org>

Code cleanup:-

The usual stuff, adding missing function prototypes, argument types,
return values, etc.

This directory now compiles with no warnings with -Wall on gcc2.6.3!


# 58f0484f 26-May-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

BSD 4.4 Lite Lib Sources