Commit Graph

67 Commits

Author SHA1 Message Date
Jonas 'Sortie' Termansen e9877d8080 Fix fmemopen(3) fseeko(3) overflow detection. 2023-03-19 11:08:01 +01:00
Jonas 'Sortie' Termansen 50543d3c36 Fix printf(3) handling of negative precision. 2021-02-13 22:33:03 +01:00
Jonas 'Sortie' Termansen 221fa7d954 Rewrite scanf(3) to be standards compliant.
This change adds missing features:

* %[ for pattern matching with a scanset.
* %m for allocation of strings.
* %p for pointers.
* Field width for integers.

The following features remain unimplemented, like with printf(3):

* Floating point support.
* Wide character support.
* %n$ positional parameters.

The code has been completely refactored to be much more maintainable.

The implemented features should now be standards compliant. A large number
of edge cases have been fixed.

The vscanf_callback(3) function has been renamed to vcbscanf(3) and a new
cbscanf(3) function has been added.
2020-03-07 23:31:05 +01:00
Jonas 'Sortie' Termansen 976d686779 Fix fputc(3) potentially miswriting the next byte after flushing. 2020-03-06 00:08:59 +01:00
Jonas 'Sortie' Termansen 9c3af039ca Fix <stdio.h> pulling in <pthread.h> through <FILE.h> when __is_sortix_libc. 2018-07-17 12:25:52 +02:00
Jonas 'Sortie' Termansen 53592a6e3f Fix getdelim(3) not returning a final line without a delimiter. 2018-04-08 20:35:30 +02:00
Ralph Holmes 5d774cce1d Fix execl(3) sentinel undefined behaviour.
execl(3) and its variants use a sentinel to terminate the variadic
argument list, in the form of a null pointer constant of type pointer to
char. POSIX mandates that NULL is a null pointer constant of type
pointer to void, which is not of an equivalent type to that required by
execl(3) and its variants, resulting in undefined behaviour.

This commit casts all such instances of NULL to pointer to char type.
For consistency, it also adds const-qualification to any such instances
which had already been casted, and were not const-qualified.
2016-09-30 23:36:49 +02:00
Jonas 'Sortie' Termansen 0756a7ee96 Add scanf(3) %n support. 2016-09-25 22:28:18 +02:00
Jonas 'Sortie' Termansen 2b72262b4f Relicense Sortix to the ISC license.
I hereby relicense all my work on Sortix under the ISC license as below.

All Sortix contributions by other people are already under this license,
are not substantial enough to be copyrightable, or have been removed.

All imported code from other projects is compatible with this license.

All GPL licensed code from other projects had previously been removed.

Copyright 2011-2016 Jonas 'Sortie' Termansen and contributors.

Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2016-03-05 22:21:50 +01:00
Jonas 'Sortie' Termansen 01b59c1947 Convert libc to C. 2016-03-03 23:02:23 +01:00
Jonas 'Sortie' Termansen 8b03a9ab94 Update printf family to current coding conventions. 2016-01-26 21:17:08 +01:00
Jonas 'Sortie' Termansen 9e6876ff14 Split fdio into multiple files. 2016-01-26 19:01:36 +01:00
Jonas 'Sortie' Termansen 4d2901b90e Split stdin, stdout and stderr into their own files. 2016-01-26 19:01:36 +01:00
Jonas 'Sortie' Termansen 56085108b6 Use fflush_unlocked as stdio's fflush_indirect.
exit(3) already locks the file before calling fflush_indirect.
2016-01-26 18:39:49 +01:00
Jonas 'Sortie' Termansen bb73362d23 Create stdio buffers at FILE creation time.
This removes support for user-supplied buffers with setvbuf.
2016-01-26 18:39:48 +01:00
Jonas 'Sortie' Termansen dbe6b32b1f Fix scanf integer parsing. 2016-01-22 20:01:33 +01:00
Jonas 'Sortie' Termansen 23810c1a48 Fix snprintf(NULL, 0, ...) undefined behavior. 2015-12-12 16:53:42 +01:00
Jonas 'Sortie' Termansen ef36a94912 Fix incorrect flush error check in fputc_unlocked(3). 2015-12-12 16:53:42 +01:00
Jonas 'Sortie' Termansen b8f12a6856 Fix fread/fwrite zero division when size is zero. 2015-12-12 16:53:42 +01:00
Jonas 'Sortie' Termansen 0100b61855 Fix fflush(NULL) flushing input streams. 2015-12-12 16:53:42 +01:00
Jonas 'Sortie' Termansen f0f82fcb23 Fix tmpfile(3) insecure file creation. 2015-10-11 23:25:21 +02:00
Jonas 'Sortie' Termansen 213b3636bb Add open_memstream(3). 2015-08-26 18:10:24 +02:00
Jonas 'Sortie' Termansen fb29ff42e0 Optimize puts and fputs. 2015-08-26 16:29:18 +02:00
Jonas 'Sortie' Termansen a79aeed0c1 Remove __BEGIN_DECLS and __END_DECLS. 2015-08-26 14:52:44 +02:00
Jonas 'Sortie' Termansen 91ab47f99c Deprecate stdio_ext API. 2015-08-21 21:25:01 +02:00
Jonas 'Sortie' Termansen 423fbad835 Fix perror(3) compliance. 2015-06-27 17:06:32 +02:00
Jonas 'Sortie' Termansen f3e4be0d83 Fix getdelim(3). 2015-05-15 16:18:40 +02:00
Jonas 'Sortie' Termansen 38f8384d78 Fix ungetc EOF having side effects. 2015-04-05 01:20:09 +02:00
Jonas 'Sortie' Termansen 472bba3db3 Add __fseterr for gnulib compatibility. 2015-02-08 22:58:32 +01:00
Jonas 'Sortie' Termansen 3a3fc76c8c Remove tmpnam(3). 2014-12-02 18:00:38 +01:00
Jonas 'Sortie' Termansen ec7e0cc9a6 Add cbprintf(3) and vcbprintf(3).
Thanks to Owen Shepherd of the Public Domain C Library for helping design
and formalize these interfaces.
2014-12-01 21:39:05 +01:00
Jonas 'Sortie' Termansen 8643c37102 Remove __flbf(3). 2014-12-01 21:39:05 +01:00
Jonas 'Sortie' Termansen 2f393b2646 Remove _flushlbf(3). 2014-12-01 21:39:05 +01:00
Jonas 'Sortie' Termansen 3778dae725 Remove __fsetlocking(3). 2014-12-01 21:39:05 +01:00
Jonas 'Sortie' Termansen a25f1a931e Initialize stdin, stdout and stderr at compile time. 2014-12-01 18:45:11 +01:00
Jonas 'Sortie' Termansen 8570f46734 Indirectly fflush(3) from fshutdown(3). 2014-12-01 18:45:11 +01:00
Jonas 'Sortie' Termansen 97e1551c81 Indirectly free(3) buffers in fshutdown(3). 2014-12-01 18:45:11 +01:00
Jonas 'Sortie' Termansen 5e60007904 Remove dcloseall() and fcloseall(). 2014-12-01 16:29:43 +01:00
Jonas 'Sortie' Termansen bb84370c34 Add type limits and print/scan specifiers to <sys/types.h>. 2014-11-26 23:34:14 +01:00
Jonas 'Sortie' Termansen c428ec4d83 Add fmemopen(3). 2014-11-17 18:47:44 +01:00
Jonas 'Sortie' Termansen d7c54161b2 Revise stdio implementation. 2014-10-19 17:13:49 +02:00
Jonas 'Sortie' Termansen ecccf4e1f7 Fix getdelim(2) leaking a freed pointer. 2014-09-25 17:27:53 +02:00
Jonas 'Sortie' Termansen fdc41cac76 Fix wrong return type of init_stdio(). 2014-08-04 19:04:16 +02:00
Jonas 'Sortie' Termansen 1ddd404ff9 Thread-secure stdio. 2014-07-08 17:41:52 +02:00
Jonas 'Sortie' Termansen 534eb3ddd8 Fix libk being built with -mmmx, -msse and -msse2 on x86_64. 2014-05-28 17:42:19 +02:00
Jonas 'Sortie' Termansen 7db2ea81ab Fix warning about converting a signed value to an unsigned value. 2014-05-16 15:12:59 +02:00
Jonas 'Sortie' Termansen 159d8881ec Fix files relying on <unistd.h> including <ioleast.h>. 2014-04-06 00:19:05 +02:00
Jonas 'Sortie' Termansen e8cfd5bf85 Handle NULL strings in vprintf_callback(3). 2014-03-17 19:22:13 +01:00
Jonas 'Sortie' Termansen 2fe13d33c9 Add asprintf(3) and vasprintf(3). 2014-03-17 19:22:12 +01:00
Jonas 'Sortie' Termansen 02c18f868f Fix vscanf_callback(3) not ungetcing the last character when stopping. 2014-03-17 19:22:12 +01:00