summaryrefslogtreecommitdiffstats
path: root/libc/stdio/stdio.c
Commit message (Collapse)AuthorAgeFilesLines
* New stdio core. Should be more maintainable. Fixes a couple of bugs.Manuel Novoa III2004-02-111-3677/+0
| | | | | | | | Codepaths streamlined. Improved performance for nonthreaded apps when linked with a thread-enabled libc. Minor iconv bug and some locale/thread related startup issues fixed. These showed up in getting a gcj-compiled java helloworld app running. Removed some old extension functions... _stdio_fdout and _stdio_fsfopen.
* Fix __freadable and __fwritable... were using '~' instead of '!'. (ugh)Manuel Novoa III2004-01-021-10/+13
| | | | | | Fix (hopefully) a potential problem with failed freopen() calls. The fix isn't tested since I've been working on the replacement stdio core code which will go in after the next release.
* Fix a long-standing bug with pthreads. A couple of linuxthreads filesManuel Novoa III2003-12-271-6/+6
| | | | | | | | | | | | | | | | were including libc-lock.h which had a bunch of weak pragmas. Also, uClibc supplied a number of no-op weak thread functions even though many weren't needed. This combined result was that sometimes the functional versions of thread functions in pthread would not override the weaks in libc. While fixing this, I also prepended double-underscore to all necessary weak thread funcs in uClibc, and removed all unused weaks. I did a test build, but haven't tested this since these changes are a backport from my working tree. I did test the changes there and no longer need to explicitly add -lpthread in the perl build for perl to pass its thread self tests.
* Fix the return value for fputs when passed an empty string.Manuel Novoa III2003-11-191-1/+4
| | | | | Indirectly detected by gmp-4.1.2 self-tests and reported by "Peter S. Mazinger" <ps.m@gmx.net>.
* Modify _stdio_READ to conform with C99, as stdio input behavior uponManuel Novoa III2003-09-221-28/+66
| | | | | | | | | | | | encountering EOF changed with Defect Report #141. In the current standard, the stream's EOF indicator is "sticky". Once it is set, all further input from the stream should fail until the application explicitly clears the EOF indicator (clearerr(), file positioning), even if more data becomes available. Fixed a bug in fgets. Wasn't checking for read errors. Minor thread locking optimizations to avoid some unnecessary locking. Remove the explicit calls to __builtin_* funcs, as we really need to implement a more general solution.
* Signifcantly speed out integer to string conversion for printf.Manuel Novoa III2003-09-081-49/+38
| | | | | Printf still needs some performance work done though. Also some bufferless stdio cleanups.
* Add a new *scanf implementation, includeing the *wscanf functions.Manuel Novoa III2003-08-011-75/+125
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Should be standards compliant and with several optional features, including support for hexadecimal float notation, locale awareness, glibc-like locale-specific digit grouping with the `'' flag, and positional arg support. I tested it pretty well (finding several bugs in glibc's scanf in the process), but it is brand new so be aware. The *wprintf functions now support floating point output. Also, a couple of bugs were squashed. Finally, %a/%A conversions are now implemented. Implement the glibc xlocale interface for thread-specific locale support. Also add the various *_l(args, locale_t loc_arg) funcs. NOTE!!! setlocale() is NOT threadsafe! NOTE!!! The strto{floating point} conversion functions are now locale aware. The also now support hexadecimal floating point notation. Add the wcsto{floating point} conversion functions. Fix a bug in mktime() related to dst. Note that unlike glibc's mktime, uClibc's version always normalizes the struct tm before attempting to determine the correct dst setting if tm_isdst == -1 on entry. Add a stub version of the libintl functions. (untested) Fixed a known memory leak in setlocale() related to the collation data. Add lots of new config options (which Erik agreed to sort out :-), including finally exposing some of the stripped down stdio configs. Be careful with those though, as they haven't been tested in a long time. (temporary) GOTCHAs... The ctype functions are currently incorrect for 8-bit locales. They will be fixed shortly. The ctype functions are now table-based, resulting in larger staticly linked binaries. I'll be adding an option to use the old approach in the stub locale configuration.
* Do not let isatty mess up errnoEric Andersen2003-06-271-3/+11
|
* Change 'undefined behavior' of fflush() on readonly or reading streamsManuel Novoa III2003-06-241-8/+18
| | | | | | | to match that of current glibc; i.e. don't do anything and return success. Apparently, php calls fflush() on a file opened as readonly before trying to read. Eventually I'll add some config options to flag this and several other instances of nonportable code.
* Fix (hopefully) scanf behavior for nul bytes in the stream when processingManuel Novoa III2003-05-151-1/+10
| | | | | | | %c, %s, and %[ specifiers. Note that scanf is undergoing rewrite so I didn't bother optimizing this. I did run all my regression tests though. Set EOF correctly for fmemopen on readonly streams. I really need to check what glibc behavior is for the various open modes though.
* Wasn't thinking... we don't need to seek to end when appending if stdioManuel Novoa III2003-01-231-12/+0
| | | | is built without buffer support.
* Fixed a bug related file position in append mode. _stdio_fwrite nowManuel Novoa III2003-01-221-11/+52
| | | | | | | | | seeks to the end of the stream when append mode is set and we are transitioning to write mode, so that subsequent ftell() return values are correct. Also fix _stdio_fopen to support fdopen() with append specified when the underlying file didn't have O_APPEND set. It now sets the O_APPEND flag as recommended by SUSv3 and is done by glibc.
* Fix a silly bug in _wstdio_fwrite. wprintf %s should now work correctly.Manuel Novoa III2003-01-051-1/+3
|
* The big thing is locale dependent collation support.Manuel Novoa III2002-12-201-5/+32
| | | | Also added outdigit support and (legacy) YESSTR/NOSTR support.
* Ok... here's the summary:Manuel Novoa III2002-11-221-0/+58
| | | | | | | | | | | | | | Hopefully locale support will build when cross compiling now. Collation is still not supported, but that's what I'm currently working on. In the next couple of days, I'll probably put up a couple of files for download that will save people the trouble of generating all the glibc locales. Added *wprintf functions, although they currently don't support floating point. That will be fixed when I rewrite _dtostr... or possibly before. Added the wcsto{inttype} functions. Added iconv() and a mini iconv utility. The require locale support and only provide for conversions involving the various unicode encodings { UCS-4*, UCS-2*, UTF-32*, UTF-16*, UTF-8 }, the 8-bit codesets built with the locale data, and the internal WCHAR_T.
* For now, leave the "Oddly enough, __fsetlocking() is NOT threadsafe."Eric Andersen2002-11-051-0/+2
| | | | comment as an mjn3 only item.
* Implement locale-specific grouping in printf for base 10 integer conversionsManuel Novoa III2002-11-031-0/+75
| | | | | when the grouping flag "'" is specified. Grouping for floating point values may wait until I do a rewrite of the floating pt to string code...
* Changed fclose behavior when custom streams were enabled. Previously,Manuel Novoa III2002-08-251-2/+21
| | | | | | | | | | | the cookie pointer was set to NULL as a debugging aid. However, some of the perl 5.8 test rely on being able to close stderr and still try writing to it. So now, the cookie pointer and handler function pointers are set to that it is a "normal" file with a file descriptor of -1. Note: The cookie pointer is reset to NULL if the FILE struct is free'd by fclose.
* __fsetlocking() and FILE field user_locking were completely broken. :-(Manuel Novoa III2002-08-131-9/+20
| | | | | | I think they're fixed now (I've run a few tests). Note: __fsetlocking() is not threadsafe... but glibc's doesn't appear to be either.
* Revert commit by davidm to printf.c that initialized conv_numManuel Novoa III2002-08-121-3/+3
| | | | | | | | | needlessly. To do so increases the generated code size with bcc. Eliminate duplicate define warnings in wstring.c. Fix potentially broken preprocessor comparisons. The preprocessor converts integers to maximal signed type, so inequality comparisons involving UINTMAX_MAX, ULLONG_MAX, and (if no long long) ULONG_MAX were potentially broken.
* Changed fflush() behavior to no-op for r/w streams in read-mode.Manuel Novoa III2002-08-061-17/+33
| | | | | | | | | | | | | This falls under undefined behavior wrt ANSI/ISO C99, but SUSv3 seems to treat it as a no-op and it occurs in some apps. Fixed a problem with _stdio_fwrite() not checking for underlying write() failures. Fixed both _stdio_fwrite() and _stdio_fread() to make sure that the putc and getc macros were disabled if the stream was in and error state. The above changes should take care of a problem initially reported by "Steven J. Hill" <sjhill@realitydiluted.com>.
* A couple of little cleanups I forgot to check in.Manuel Novoa III2002-08-031-2/+0
|
* Attempt to clean up the strerror_r situation.Manuel Novoa III2002-07-071-36/+2
|
* Enable WCHAR support for C/POSIX stub locales.Manuel Novoa III2002-07-031-134/+244
| | | | | | Implemented unformatted wide i/o functions. (ungetwc still needs testing) Fix a few bugs in wchar.c. Modifications for bcc/elks support.
* Fix perror() and printf("%m") to not call strerror(), as required by theManuel Novoa III2002-06-181-5/+48
| | | | | | | | | standards. Temporarily added a utility function to wrap Erik's strerror_r so that "Unknown error xxx" strings can be generated for errno's which cause strerror_r to fail. That utility function will eventually be merged in with the strerror/strerror_r functions when I change over to optionallly mmap'ing the system error strings to provide for lower mem comsumption on non-MMU platforms, as well as locale-specific system error messages.
* Revert Erik's patch to vasprintf and fix the real issue.Manuel Novoa III2002-06-111-0/+1
| | | | | The writer for the stream returned by open_memstream was supposed to keep the buffer nul-terminated. I apparently left out a statement.
* Fix the read/write auto-transition bugs. Note that if we can'tManuel Novoa III2002-04-091-29/+36
| | | | | | | | | | | | auto-transition, we fail the operation. This is different than glibc's apparent behavior for writing of clearing the read buffer and still failing the write without setting the stream's error flag. Also, change a number of "errno = xxx" assignments to use __set_errno(). Also, change setvbuf(file, NULL, _IO{LF}BF, 0) behavior to more closely match glibc's by keeping the current buffer and only changing the buffering mode. Update setlinebuf() in the process to match the man page behavior.
* Compile in flockfile and friends by defaultEric Andersen2002-03-211-0/+8
| | | | -Erik
* Fix a pointer bug in setvbuf reported by Bart Visscher <magick@Linux-Fan.com>.Manuel Novoa III2002-03-161-2/+6
|
* I vow to rerun _all_ the tests before making commits. :-(Manuel Novoa III2002-03-141-2/+2
| | | | | I successfully managed to blow away all the modeflags for the file _except_ the one dealing with buffering...
* Fix stdin/stdout initialization of buffering type. I had changed theManuel Novoa III2002-03-131-2/+2
| | | | default static initiailization and forgotten to update _stdio_init().
* Fix another O_LARGEFILE bug. Also, I forget to make floating point optionalManuel Novoa III2002-03-121-2/+10
| | | | in the new printf code.
* So much for fcntl flags being resonably consistent across archs... (hopefully)Manuel Novoa III2002-03-121-10/+14
| | | | | fix O_APPEND and O_LARGEFILE handling in _stdio_fopen(). Someone else will have to check of course...
* Fix fflush(NULL) and tweak _stdio_term() for the unbuffered stdio option.Manuel Novoa III2002-03-121-2/+10
|
* Deal with cvs "feature"... or is that cvs _user_...Manuel Novoa III2002-03-121-0/+3171
|
* Swap in the new stdio code.Manuel Novoa III2002-03-121-1117/+0
|
* Be consistant and use an unsigned char * throughoutEric Andersen2002-02-261-2/+3
|
* I shouldn't try to program when sleepy, since I totally botchedEric Andersen2002-02-251-4/+4
| | | | | the fcntl interface... -Erik
* When messing with fd NONBLOCK status, put things back the way we foundEric Andersen2002-02-251-1/+4
| | | | | | them afterwards. As was, this hosed things up for fds shared with a parent process. Very bad for shells... Oops. -Erik
* IEEE Std 1003.1-2001 says that the "fclose() function shall fail [with]Eric Andersen2002-02-231-7/+1
| | | | | | | | EINTR [when] the fclose() function was interrupted by a signal". But looking in the current uClibc stdio.c for some bizarre reason we had a special case where when errno was EINTR, we would keep on trying instead. Doh! Fix that, -Erik
* Per discussion with Manuel, when we call __stdio_flush_buffersEric Andersen2002-02-231-1/+9
| | | | | | from abort() and from _exit(), we need to ensure that flushing will not cause us to block. So use fcntl to set the fd's to non-block mode...
* Rename __stdio_close_all to __stdio_flush_buffers. Eliminate anEric Andersen2002-02-181-2/+2
| | | | unnecessary variable
* Add missing ctermid. Also add putc and getc (in case they getEric Andersen2001-11-211-0/+19
| | | | | undefined which is a valid thing to do) -Erik
* This commit makes large file support actually work (when enabled inEric Andersen2001-10-171-9/+25
| | | | | the config file). I've tested this and it works for me. -Erik
* Fix fseek behavior.Manuel Novoa III2001-09-251-2/+3
|
* Use "stdin", "stdout", and "stderr", not "_stdin", "_stdout", andEric Andersen2001-08-241-10/+10
| | | | | "_stderr", since this is what gcc and libgcc expect... -Erik
* Add the __fopen prototype, since I pulled it from stdio.hEric Andersen2001-08-241-0/+4
|
* Oops... left in a debugging line.Manuel Novoa III2001-07-281-1/+0
|
* Back out the changes to _uClibc_fread and loop in fread() if incomplete, toManuel Novoa III2001-07-281-22/+21
| | | | | | | | | | avoid problems with fgets on tty streams. I actually did some testing this time. ;-) Note: there is a difference in behavior between glibc and uClibc here regarding fread() on a tty stream. glibc's fread() seems to return after reading all _available_ data even if not at end-of-file, while uClibc's fread() continues reading until all requested or eof or error. The latter behavior seems correct w.r.t. the standards.
* Yes... the previous "fix" was broken too... the result of careless cuttingManuel Novoa III2001-07-261-1/+1
| | | | and pasting while pressed for time. I haven't checked this one either. :-(