summaryrefslogtreecommitdiff
path: root/lib/libc/stdio/vfwscanf.c
Commit message (Collapse)AuthorAgeFilesLines
* The function fwscanf() return value is wrong when encountering an earlyStephen J. Kiernan2017-12-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | matching failure. According to the Open Group documentation for fwscanf: "Upon successful completion, these functions shall return the number of successfully matched and assigned input items; this number can be zero in the event of an early matching failure." Without this change, fwscanf would return EOF in the case of an early matching failure, instead of the proper return value of 0. This change aligns fwscanf(3) with the implementation in fscanf(3). PR: 202240 Submitted by: rajendra.sy@gmail.com Reviewed by: jhb, cem Approved by: sjg (mentor) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D13288 Notes: svn path=/head/; revision=326635
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-0/+2
| | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=326025
* Make stdio deferred cancel-safe.Konstantin Belousov2017-06-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=320472
* Renumber clauses to reduce diffs to other versionsEd Maste2013-04-231-1/+1
| | | | | | | | | | NetBSD, OpenBSD, and Android's Bionic all number the clauses 1 through 3, so follow suit to make comparison easier. Acked-by: imp@ Notes: svn path=/head/; revision=249808
* Remove incorrect __restrict qualifier on several pointersJean-Sébastien Pédron2012-04-301-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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@ Notes: svn path=/head/; revision=234836
* Fix a bug in *wscanf's handling of non-wide %s, %c, and %[David Schultz2012-04-301-44/+9
| | | | | | | | | | | | | | | | conversions. Both the specification and the documentation say the width is interpreted as the max number of wide characters to read, but the implementation was interpreting it as the number of bytes to convert. (See also r105317.) This change has security implications for any applications that depend on the buggy behavior, but the impact in practice is probably nil. Any such application would already be buggy on other platforms that get the semantics right. Also, these conversions are rarely used; %ls, %lc, and %l[ are more appropriate. Notes: svn path=/head/; revision=234825
* Bugfix: Include whitespace characters in the count of the number ofDavid Schultz2012-04-221-1/+1
| | | | | | | characters read. Notes: svn path=/head/; revision=234588
* Bugfix: %n doesn't count as a conversion, soDavid Schultz2012-04-221-1/+0
| | | | | | | sscanf("abc", "ab%ncd", &i) returns EOF, not 0. Notes: svn path=/head/; revision=234586
* Refactor scanf to improve modularity. Conversions are now performedDavid Schultz2012-04-221-300/+394
| | | | | | | | | by separate conversion functions. This will hopefully make bugs more noticeable (I noticed several already) and provide opportunities to reduce code duplication. Notes: svn path=/head/; revision=234585
* Implement xlocale APIs from Darwin, mainly for use by libc++. This adds aDavid Chisnall2011-11-201-39/+49
| | | | | | | | | | | | | | | 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) Notes: svn path=/head/; revision=227753
* - Add support for multibyte decimal_point encodings, e.g., U+066B.David Schultz2009-01-191-9/+17
| | | | | | | | A forthcoming gdtoa import is needed to make this fully work. - Improve the way "nan(...)" is parsed. Notes: svn path=/head/; revision=187422
* Remove some test instrumentation. (The Symbol.map changes broke it anyway.)David Schultz2007-12-091-4/+0
| | | | Notes: svn path=/head/; revision=174495
* Per Regents of the University of Calfornia letter, remove advertisingWarner Losh2007-01-091-4/+0
| | | | | | | | | clause. # If I've done so improperly on a file, please let me know. Notes: svn path=/head/; revision=165903
* Add missing #if's for NO_FLOATING_POINTPoul-Henning Kamp2006-04-011-0/+2
| | | | Notes: svn path=/head/; revision=157381
* Include <sys/types.h> and <limits.h> ourselves, don't assume they are includedStefan Farfeleder2005-08-201-0/+1
| | | | | | | | | | | | | through <pthread.h>. gen/sem.c: Prerequisite for <_semaphore.h> net/getprotoent.c: USHRT_MAX net/getservent.c: USHRT_MAX stdio/ungetwc.c: MB_LEN_MAX stdio/vfwscanf.c: MB_LEN_MAX Notes: svn path=/head/; revision=149313
* Remove bogus FBSDID.David E. O'Brien2004-05-021-3/+1
| | | | Notes: svn path=/head/; revision=128844
* Merge vfscanf.c, v1.37:David Schultz2004-05-021-8/+7
| | | | | | | - s/#ifdef FLOATING_POINT/#ifndef NO_FLOATING_POINT/ Notes: svn path=/head/; revision=128822
* Prepare to handle trivial state-dependent encodings. Full support forTim J. Robbins2004-04-071-6/+11
| | | | | | | | state-dependent encodings with locking shifts will come later if there is demand for it. Notes: svn path=/head/; revision=128002
* Merge vfscanf.c,v 1.35.David Schultz2004-01-311-4/+10
| | | | Notes: svn path=/head/; revision=125283
* Make intentions explicit with additional parenthesis.Jacques Vidrine2004-01-061-4/+4
| | | | Notes: svn path=/head/; revision=124175
* Pass NULL instead of a pointer to a zeroed mbstate_t object.Tim J. Robbins2003-11-051-10/+6
| | | | Notes: svn path=/head/; revision=122105
* Fix two incorrect uses of sizeof: we need to divide the size of the bufferTim J. Robbins2003-07-051-11/+6
| | | | | | | | | by sizeof(wchar_t) to get the number of wide characters it contains. Remove the !hardway micro-optimisation from the CT_INT case to avoid having to fix it for wide characters. Notes: svn path=/head/; revision=117250
* Merge recent floating point conversion changes from vfscanf.c.Tim J. Robbins2003-07-051-93/+175
| | | | Notes: svn path=/head/; revision=117249
* No need to include floatio.h here: vfscanf() no longer uses anythingTim J. Robbins2002-11-011-1/+0
| | | | | | | it defines. Notes: svn path=/head/; revision=106282
* The field width for single-byte string conversions (%c, %s, %[) is theTim J. Robbins2002-10-171-33/+88
| | | | | | | | | maximum number of bytes that may be stored in the array, not the maximum number of wide characters to read. The wording of the standard unfortunately does not make this clear. Notes: svn path=/head/; revision=105317
* Remove an unneeded call to _sfrefill() that was missed in the conversionTim J. Robbins2002-09-241-6/+0
| | | | | | | | from vfscanf() to vfwscanf(). It doesn't hurt to have it there, but it's redundant since __fgetwc() will refill the buffer if it needs to. Notes: svn path=/head/; revision=103890
* Add implementations of wscanf() and related functions: fwscanf(), swscanf(),Tim J. Robbins2002-09-231-0/+748
vfwscanf(), vswscanf(), vwscanf(). As the name suggests, these are wide- character versions of the scanf() family of functions. Notes: svn path=/head/; revision=103856