summaryrefslogtreecommitdiff
path: root/libc/stdio/vfprintf.cpp
AgeCommit message (Collapse)Author
2018-09-06Use strerror_r(3) for the printf family %m.Elliott Hughes
There's TLS space used for unknown errno values, and a call to printf shouldn't clobber that. No-one will ever hit this in real life, but since it's easily fixed... Bug: http://b/112776560 Test: ran tests Change-Id: I8c2437f2e5214e652119791d4e162a197b049d5b
2018-08-30Add the %m GNU extension to printf/wprintf.Elliott Hughes
And remove the local hack from syslog(3). Bug: http://b/112776560 Test: ran tests Change-Id: I5807e729a978df26187ea0ee255bba4ca74220c8
2018-08-15libc: enable -Wimplicit-fallthroughGeorge Burgess IV
libc had some -Wimplicit-fallthrough warnings. They all seem to be benign. We're trying to enable this flag globally, so we need to annotate these breaks here. Bug: 112564944 Test: Builds Change-Id: I5afae694cc4cf26ad1a61e2c8ae91f00cda7c733
2018-08-02Modernize codebase by replacing NULL with nullptrYi Kong
Fixes -Wzero-as-null-pointer-constant warning. Test: m Bug: 68236239 Change-Id: I5b4123bc6709641315120a191e36cc57541349b2
2018-03-07Call __fortify_fatal if printf sees %n.Elliott Hughes
We've ignored %n for a long time, but that's dangerous too because it makes it unclear whether the corresponding pointer argument should be supplied or not. Remove the ambiguity by just rejecting %n outright. Bug: http://b/31832608 Test: ran tests Change-Id: Ic046ad3436a30c6f8f580ea738bdcaeb01c858f8
2017-11-13Remove more trivial char/wchar_t printf differences.Elliott Hughes
Bug: http://b/67371539 Test: ran tests Change-Id: I899458af92517dc21f874519716fa3f3a0f0e3d6
2017-11-10Yet more printf de-duplication.Elliott Hughes
Bug: http://b/67371539 Test: ran tests Change-Id: Iae38055426596919c0de4f5080c99eba95fac3a9
2017-11-08Move shared parts of the two printfs out.Elliott Hughes
Bug: http://b/67371539 Test: ran tests Change-Id: I24eae6a5d2c64ff4fd65c8d508a3709bab5a11c4
2017-11-07More printf de-duplication.Elliott Hughes
Just trivial use of macros. The %s/%ls case in __find_arguments was backwards in the wide copy of the code, but not problematically so because all pointers are the same size anyway. Bug: http://b/67371539 Test: ran tests Change-Id: I8d34915d75ae5425c56c59510a16c328fc481d20
2017-11-0310x printf speedup.Elliott Hughes
Android is UTF-8. Don't make everyone pay to convert UTF-8 to ASCII just so we can recognize '%'. With UTF-8 we can just strchr forwards. Before: --------------------------------------------------------------- Benchmark Time CPU Iterations --------------------------------------------------------------- BM_stdio_printf_literal 1290 ns 1290 ns 442554 BM_stdio_printf_s 1204 ns 1204 ns 582446 BM_stdio_printf_d 1206 ns 1206 ns 578311 BM_stdio_printf_1$s 2263 ns 2263 ns 310002 After: --------------------------------------------------------------- Benchmark Time CPU Iterations --------------------------------------------------------------- BM_stdio_printf_literal 178 ns 178 ns 3394001 BM_stdio_printf_s 246 ns 246 ns 2850284 BM_stdio_printf_d 252 ns 252 ns 2778610 BM_stdio_printf_1$s 363 ns 363 ns 1929011 Add missing __find_arguments error checking to the wide variant to match the regular one. Also replace various char/wchar_t differences with the macro. Bug: http://b/67371539 Test: ran tests Change-Id: I18f122009c22699943ab5d666a98ea594a972c40
2017-11-02More printf de-duplication.Elliott Hughes
Fix the 'j' (intmax_t/uintmax_t) length qualifier in the wide variant. (With new tests that fail without this fix.) Fix a typo in the wide support for intmax_t*, which isn't testable because %n is disabled on Android (and will be removed in a later cleanup pass). Also move the public vfprintf/vfwprint functions into stdio.cpp. Bug: http://b/67371539 Test: ran tests Change-Id: Ib003599b1e9cb789044a068940b59e447f2cb7cb
2017-11-01Start de-duplicating the regular and wide printf implementations.Elliott Hughes
This patch switches to C++ (in anticipation of needing it later), removes a little duplication (via a macro for now), and ensures uniform support for %C/%lc and %S/%ls between regular and wide (with new tests). Since it's so hard to debug problems in printf (as the time I've wasted already today will testify), that's all I want to do in this change. The other 500 lines of diff can wait... (Also merge "floatio.h" into "local.h" now all the users are in forked code.) Bug: http://b/67371539 Test: ran tests Change-Id: I083353d89c32b9302d759ca6967cc6d8a62cd8a5