Commit Graph

10 Commits (master)

Author SHA1 Message Date
kvik bc1cc79225 libstdio: sync bits of vfprintf from APE
* Add the %ll length modifier,
* Convert nil to "<nil>" under %s (not in APE),
* Cast void* to uintptr under %p,
* Use "0x" hex prefix under %p,
* Fix manual page mentions of %P to %p,
* Fix empty result for fp conversions,
* Fix zero padding of left-aligned fp conversions,
* Remove deprecated #pragma ref uses.

Most of these were introduced in APE prior to 9front.

I've omitted the %z conversion specifier since Plan 9 code
rarely uses the usize type. This may need to be added later
for the benefit of native ports of alien code.
2021-02-19 23:04:09 +01:00
Ori Bernstein 0719ce2aa7 stdio: remove erronous assert in dtoa
The value of `k` in dtoa() is an estimate of
floor(log10(d)), where `d` is the number being
converted. The code was asserting that 'k' was
less than 100, but the full range of a double
goes to 10^308 or so.

This means that the majority of the range of
a double would trigger that assert.
2021-02-09 13:57:38 -08:00
Ori Bernstein bd4b6bda9b #pragma ref no longer exists
It appears to be an antiquated form of 'USED(x)'
2020-05-15 16:56:59 -07:00
Ori Bernstein 78aec6d5c6 Fix scans of more than one character in %[]
This got broken in d8e877a89dae, where we returned 0 on the
first mismatch; we want to return 0 only when we consumed no
characters.
2020-05-15 16:46:20 -07:00
Ori Bernstein bfc8cdfff5 fix '%[]' specifiers and '%n' (thanks phil9)
When a match() fails, we need to unget the character we
tried to match against, rather than leaving it consumed.

Also, we can't break out of a conversion before we reach
the end of a format string, because things like the '%n'
conversion do not consume anything, and should still be
handled.
2020-05-09 15:10:39 -07:00
cinap_lenrek 6d42467411 stdio: fix sclose() buffer overrun when terminating string, realloc() error handling (thanks porlock)
theres a bug is in sclose() where it doesnt check if wp is beyond
the buffer. also wp was not updated after realloc().

bug was reported by porlock on 9fans:

Plan 9's implementation of the standard C functions snprintf and
vsnprintf have a buffer overrun bug.

If the buffer length equals the output length (without the terminating
null), then one too many characters is written to the buffer.

For example,
              snprintf(buf, 4, "ABCD");

will write 5 characters to buf.
2016-11-27 21:20:27 +01:00
ftrvxmtrx ed76659c05 /sys/src/lib*: clean up 2016-11-17 22:58:16 +01:00
cinap_lenrek 63ac70281a libstdio: avoid issues with aliasing in dtoa() on amd64 (from 9atom, thanks to erik and charles) 2014-06-12 20:14:12 +02:00
Taru Karttunen a9060cc06b Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
Taru Karttunen e5888a1ffd Import sources from 2011-03-30 iso image 2011-03-30 15:46:40 +03:00