| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
| |
Use a correct errno in freopen.
Use EBADF instead of EINVAL when working around incorrect O_ACCMODE.
Adjust errno on failed prepwrite.
rewind: always clear error indicator as required by POSIX.
Obtained from: Apple Inc. (Libc 997.90.3)
Phabric: D442
|
|
|
|
|
|
|
| |
NetBSD, OpenBSD, and Android's Bionic all number the clauses 1 through 3,
so follow suit to make comparison easier.
Acked-by: imp@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(i.e., the return value would overflow), set errno to EOVERFLOW
and return an error. This improves the chances that buggy
applications -- for instance, ones that pass in a negative integer
as the size due to a bogus calculation -- will fail in safe ways.
Returning an error in these situations is specified by POSIX, but
POSIX appears to have an off-by-one error that isn't duplicated in
this change.
Previously, some of these functions would silently cap the size at
INT_MAX+1, and others would exit with an error after writing more
than INT_MAX characters.
PR: 39256
MFC after: 2 weeks
|
|
|
|
|
|
|
|
|
|
|
|
| |
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)
|
|
|
|
|
|
|
|
|
| |
uninitialized. Initialize it to a safe value so that there's no
chance of returning an error if stack garbage happens to be equal to
(size_t)-1 or (size_t)-2.
Found by: Clang static analyzer
MFC after: 7 days
|
| |
|
|
|
|
|
|
|
| |
Fix harmless but related bugs in %_$zd and %_$tu.
PR: 131880
MFC after: 1 week
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
sets up a fake buffered FILE and then effectively calls itself
recursively. Unfortunately, gcc doesn't know how to do tail call
elimination in this case, and actually makes things worse by
inlining __sbprintf(). This means that f[w]printf() to stderr was
allocating about 5k of stack on 64-bit platforms, much of which was
never used.
I've reorganized things to eliminate the waste. In addition to saving
some stack space, this improves performance in my tests by anywhere
from 5% to 17% (depending on the test) when -fstack-protector is
enabled. I found no statistically significant performance difference
when stack protection is turned off. (The tests redirected stderr to
/dev/null.)
|
|
|
|
|
| |
vfprintf.c and vfwprintf.c (except for char/wchar_t differences) to a
common header file.
|
|
|
|
|
|
|
|
|
|
|
| |
slightly less evil inline functions, and move the buffering state into
a struct. This will make it possible for helper routines to produce
output for printf() directly, making it possible to untangle the code
somewhat.
In wprintf(), use the same buffering mechanism to reduce diffs to
printf(). This has the side-effect of causing wprintf() to catch write
errors that it previously ignored.
|
| |
|
|
|
|
|
|
|
| |
this commit, sprintf("%s", "") could fail depending on what happened
to be on the stack.
Found by: LLVM/Clang Static Checker
|
|
|
|
| |
bit by removing some calls to the inline function addtype().
|
|
|
|
|
|
| |
by moving the positional argument handling code to a new file,
printf-pos.c, and moving common definitions to printflocal.h.
No functional change intended.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In particular, encapsulate the state of the type table in a struct,
and add inline functions to initialize, free, and manipulate that
state. This replaces some ugly macros that made proper error handling
impossible.
While here, remove an unneeded test for NULL and a variable that is
initialized (many times!) but never used. The compiler didn't catch
these because of rampant use of the same variable to mean different
things in different places.
This commit should not cause any changes in functionality.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
__sFILE. This was supposed to be done in 6.0. Some notes:
- Where possible I restored the various lines to their pre-__sFILEX state.
- Retire INITEXTRA() and just initialize the wchar bits (orientation and
mbstate) explicitly instead. The various places that used INITEXTRA
didn't need the locking fields or _up initialized. (Some places needed
_up to exist and not be off the end of a NULL or garbage pointer, but
they didn't require it to be initialized to a specific value.)
- For now, stdio.h "knows" that pthread_t is a 'struct pthread *' to
avoid namespace pollution of including all the pthread types in stdio.h.
Once we remove all the inlines and make __sFILE private it can go back
to using pthread_t, etc.
- This does not remove any of the inlines currently and does not change
any of the public ABI of 'FILE'.
MFC after: 1 month
Reviewed by: peter
|
| |
|
|
|
|
|
|
| |
clause.
# If I've done so improperly on a file, please let me know.
|
| |
|
| |
|
|
|
|
| |
printf("%#.0o", 0). Cite an amusing passage from a defect report.
|
|
|
|
|
| |
Submitted by: Sean McNeil <sean@mcneil.com>
MFC after: 3 days
|
|
|
|
| |
Approved by: das (mentor)
|
|
|
|
| |
since the macro isn't really a predicate, and it has side-effects.
|
| |
|
|
|
|
|
| |
- s/#ifdef FLOATING_POINT/#ifndef NO_FLOATING_POINT/
- Remove HEXFLOAT
|
|
|
|
|
|
|
|
|
|
| |
after their change from an array of char to an array of enum.
This fixes problems that occurred when using positional arguments in
format strings, particularly with more than STATIC_ARG_TBL_SIZE (8)
of them.
PR: 65841
Submitted by: Steven Smith (mostly)
|
|
|
|
|
| |
state-dependent encodings with locking shifts will come later if there
is demand for it.
|
|
|
|
|
|
|
| |
and to reduce diffs between vfprintf.c and vfwprintf.c, declare xdigs*
to be char arrays rather than wchar_t arrays.
In collaboration with: tjr
|
| |
|
|
|
|
|
|
|
|
| |
string files (__SSTR flag set). This is necessary because __sputc()
does not respect the __SALC flag, and crashes trying to flush the buffer
instead of resizing it.
PR: 59167
|
| |
|
|
|
|
|
|
|
|
| |
the # flag is present. Implement this behavior and add a comment
describing it.
Noticed by: Enache Adrian <enache@rdslink.ro>
Pointy hat to: das
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
- __vfprintf()'s 'buf' has never been used for floating point, so
don't define it in terms of (incorrect) constants describing
floating point numbers. The actual size needed depends on
sizeof(uintmax_t) and locale details, so I slightly overestimated.
- We don't need a 308-character buffer to store the string "308".
With long doubles and %a we need more than three characters, though.
|
| |
|
| |
|
|
|
|
| |
last argument.
|
|
|
|
| |
handling of multibyte sequences representing null wide characters.
|
|
|
|
| |
and %ls.
|
|
|
|
|
|
|
|
| |
assignment. This is needed on powerpc but is also more correct for the
other ports.
Submitted by: grehan
Tested on: alpha, i386, sparc64
|
|
formatted wide-character output.
|