summaryrefslogtreecommitdiff
path: root/lib/libc/stdio
Commit message (Collapse)AuthorAgeFilesLines
* When __SOPT is cleared, clear __SOFF too.Andrey A. Chernov2001-09-031-1/+1
| | | | | | | NOTE: original stdio bug. Notes: svn path=/head/; revision=82839
* Re-arrange my funopen(3) fix to minimize differences with original stdio code,Andrey A. Chernov2001-09-036-83/+91
| | | | | | | | | no functional changes. Add fp->_offset optimization in _SAPP+_SOPT case Notes: svn path=/head/; revision=82838
* Internal seeks are overoptimized. They should remember fp->_offset only forAndrey A. Chernov2001-09-022-3/+1
| | | | | | | | | | plain regular files, i.e. files with __SOPT flag set. Fix it, so ftell(stdout) always returns the same as lseek(1, 0, 1) now. NOTE: this bug was in original stdio code Notes: svn path=/head/; revision=82827
* Fix bug in off_t overflow checking: if fp->_offset overflows, just removeAndrey A. Chernov2001-09-021-5/+3
| | | | | | | | __SOFF flag (i.e. we don't have offset) instead of returning EOVERFLOW. It allows again continious reading from non-stop stream. Notes: svn path=/head/; revision=82818
* Typo seek(2) -> lseek(2)Andrey A. Chernov2001-09-021-1/+1
| | | | Notes: svn path=/head/; revision=82810
* Move all stdio internal flags processing and setting out of __sread(),Andrey A. Chernov2001-09-029-55/+89
| | | | | | | | | | | | | __swrite() and __sseek() to higher level. According to funopen(3) they all are just wrappers to something like standard read(2), write(2) and lseek(2), i.e. must not touch stdio internals because they are replaceable with any other functions knows nothing about stdio internals. See example of funopen(3) usage in sendmail sources f.e. NOTE: this is original stdio bug, not result of my range checkin added. Notes: svn path=/head/; revision=82807
* Save errno before function call and restore it on success (because manyAndrey A. Chernov2001-09-012-2/+11
| | | | | | | | | internal functions there may fail and set (i.e. overwrite) errno in normal (not error) situation). In original variant errno testing after call (as POSIX suggest) is wrong when errno overwrite happens. Notes: svn path=/head/; revision=82743
* Remove even more unneded checks, original code can't overflows in that placeAndrey A. Chernov2001-09-011-5/+1
| | | | Notes: svn path=/head/; revision=82742
* Remove two checks unneeded now (can't happens)Andrey A. Chernov2001-09-011-4/+0
| | | | Notes: svn path=/head/; revision=82741
* Make fseek(... SEEK_CUR) fails if current file-position is unspecified.Andrey A. Chernov2001-09-012-8/+8
| | | | Notes: svn path=/head/; revision=82740
* Note that prev. commit addition is for ftell/ftelloAndrey A. Chernov2001-09-011-2/+6
| | | | Notes: svn path=/head/; revision=82739
* Describe ESPIPE as result of unspecified file-position indicator value.Andrey A. Chernov2001-09-011-2/+7
| | | | | | | Add more to SEE ALSO section. Notes: svn path=/head/; revision=82738
* Describe file-position behaviour from POSIXAndrey A. Chernov2001-09-011-0/+5
| | | | Notes: svn path=/head/; revision=82737
* Strict in the POSIX sence, if file position is unspecified after ungetc() atAndrey A. Chernov2001-09-011-6/+4
| | | | | | | | | | 0, return that we can't specify it, i.e. error with ESPIPE. (hint from: "Peter S. Housel" <housel@acm.org>) Back out sinit() addition, not needed after various code simplifications. Notes: svn path=/head/; revision=82736
* If lseek to wrong value sucessfully happens despite all pre-checks, set __SERRAndrey A. Chernov2001-09-012-1/+4
| | | | | | | to indicate that stream becomes inconsistent. Notes: svn path=/head/; revision=82735
* If position is underflowed, don't try to hide that fact by recovery, justAndrey A. Chernov2001-09-011-17/+7
| | | | | | | return EIO and set __SERR to mark stream as inconsistent. Notes: svn path=/head/; revision=82734
* Back out disabling ungetc() at 0, use different solution:Andrey A. Chernov2001-09-015-34/+48
| | | | | | | | keep negative offset internally, but return 0 externally in ftell*() I.e. use 0 now as 'unspecified value' per POSIX ungetc() description. Notes: svn path=/head/; revision=82709
* Add originally missing __sinit() call.Andrey A. Chernov2001-08-311-0/+4
| | | | Notes: svn path=/head/; revision=82684
* Simplify offset underflow checks even moreAndrey A. Chernov2001-08-311-12/+2
| | | | Notes: svn path=/head/; revision=82683
* Describe that we disallow ungetc at offset 0 now.Andrey A. Chernov2001-08-311-1/+4
| | | | Notes: svn path=/head/; revision=82679
* Disallow ungetc at offset 0 (to prevent negative offset happens), so simplifyAndrey A. Chernov2001-08-312-22/+15
| | | | | | | checks in ftell. Notes: svn path=/head/; revision=82673
* Drop buffer first, _then_ ask for real positionAndrey A. Chernov2001-08-311-4/+4
| | | | Notes: svn path=/head/; revision=82670
* The same big piece of ftell code repeated in 3 places. Simplify things movingAndrey A. Chernov2001-08-313-94/+30
| | | | | | | | it into one subfunction instead. Try to use real offset in strange cases. Notes: svn path=/head/; revision=82668
* If file offset is smaller than internal buffer character left count, just dropAndrey A. Chernov2001-08-312-16/+30
| | | | | | | internal buffer and trust offset, not return error. Notes: svn path=/head/; revision=82659
* Initialize _offset to 0 in fopen(), it helps to optimize fseek/ftellAndrey A. Chernov2001-08-311-0/+2
| | | | Notes: svn path=/head/; revision=82654
* Detect fp->_offset overflow on readAndrey A. Chernov2001-08-311-9/+23
| | | | | | | Use errno to catch negative seek with -1 offset Notes: svn path=/head/; revision=82653
* Use ``.Rv -std'' wherever possible.Ruslan Ermilov2001-08-311-7/+3
| | | | | | | Submitted by: yar Notes: svn path=/head/; revision=82642
* Try to discard some ungetc data in saved internal buffer checks too,Andrey A. Chernov2001-08-302-7/+25
| | | | | | | if offset tends to be negative. Notes: svn path=/head/; revision=82591
* goto dumb; if can't obtain curoff for whence != SEEK_CUR cases, as supposedAndrey A. Chernov2001-08-301-8/+4
| | | | Notes: svn path=/head/; revision=82590
* Add more EOVERFLOW checks.Andrey A. Chernov2001-08-302-31/+94
| | | | | | | | | | | | | | | When file offset tends to be negative due to internal and ungetc buffers additions counted, try to discard some ungetc data first, then return EBADF. Later one can happens if lseek(fileno(fd),...) called f.e. POSIX says that ungetc beyond beginning of the file results are undefined, so we can just discard some of ungetc data in that case. Don't rely on gcc cast when checking for overflow, use OFF_MAX. Cosmetique. Notes: svn path=/head/; revision=82588
* Cosmetique fixes from bdeAndrey A. Chernov2001-08-261-2/+0
| | | | Notes: svn path=/head/; revision=82348
* Cosmetique: correct English in commentsAndrey A. Chernov2001-08-231-2/+2
| | | | Notes: svn path=/head/; revision=82197
* Mark some functions as __printflike() and/or taking const char * argumentsKris Kennaway2001-08-201-1/+1
| | | | | | | | | instead of char *. MFC after: 2 weeks Notes: svn path=/head/; revision=81975
* Add about rewind+errno, describe ESPIPE, minor formatting.Andrey A. Chernov2001-08-191-6/+23
| | | | Notes: svn path=/head/; revision=81912
* Simplify overflow calculations a bitAndrey A. Chernov2001-08-171-4/+2
| | | | Notes: svn path=/head/; revision=81822
* Remove extra check, already done in upper level caller, i.e. inAndrey A. Chernov2001-08-171-5/+1
| | | | | | | _fseeko() Notes: svn path=/head/; revision=81821
* Mention ftell & ftello in EOVERFLOW section too.Andrey A. Chernov2001-08-171-1/+5
| | | | Notes: svn path=/head/; revision=81820
* Add more overflow checks in case of fseek()Andrey A. Chernov2001-08-171-0/+8
| | | | Notes: svn path=/head/; revision=81819
* Don't clear "we have offset" flag even if long is overflow for fseek(),Andrey A. Chernov2001-08-171-1/+0
| | | | | | | there is no harm to have it, it will reduce next call efforts. Notes: svn path=/head/; revision=81818
* fseek.c:Andrey A. Chernov2001-08-174-10/+36
| | | | | | | | | | | | | | | Resulting fseek() offset must fit in long, required by POSIX (pointed by bde), so add LONG_MAX and final tests for it. rewind.c: 1) add missing __sinit() as in fseek() it pretends to be. 2) use clearerr_unlocked() since we already lock stream before _fseeko() 3) don't zero errno at the end, it explicitely required by POSIX as the only one method to test rewind() error condition. 4) don't clearerr() if error happens in _fseeko() Notes: svn path=/head/; revision=81817
* Explain the relation of getchar() to getc() in less words.Dima Dorfman2001-08-161-5/+1
| | | | | | | Submitted by: ru Notes: svn path=/head/; revision=81745
* Use smarter overflow testsAndrey A. Chernov2001-08-151-3/+6
| | | | | | | Suggested by: bde Notes: svn path=/head/; revision=81730
* 1) Disallow negative seek as POSIX require for fseek{o} (but not for lseek):Andrey A. Chernov2001-08-153-13/+45
| | | | | | | | | | | | | | | "[EINVAL] ... The resulting file-position indicator would be set to a negative value." Moreover, in real life negative seek in stdio cause EOF indicator cleared and not set again forever even if EOF returned. 2) Catch few possible off_t overflows. Reviewed by: arch discussion Notes: svn path=/head/; revision=81666
* Rip out the old __stdin/out/err stuff. It was completely 100% useless. :-(Peter Wemm2001-08-131-15/+6
| | | | | | | | | | | | | | | | | | | It was foiled because of dynamic copy relocations that caused compile-time space to be reserved in .bss and at run time a blob of data was copied to that space and everything used the .bss version.. The problem is that the space is reserved at compile time, not runtime... So we *still* could not change the size of FILE. Sigh. :-( Replace it with something that does actually work and really does let us make 'FILE' extendable. It also happens to be the same as Linux does in glibc, but has the slight cost of a pointer. Note that this is the same cost that 'fp = fopen(), fprintf(fp, ...); fclose(fp);' has. Fortunately, actual references to stdin/out/err are not all that common since we have implicit stdin/out/err-using versions of functions (printf() vs. fprintf()). Notes: svn path=/head/; revision=81600
* Use .Fn, .Fa, and .Dv where appropriate.Dima Dorfman2001-08-101-2/+6
| | | | Notes: svn path=/head/; revision=81478
* Use the ``.Rv -std'' mdoc(7) macro in appropriate cases.Yaroslav Tykhiy2001-08-091-6/+1
| | | | | | | Reviewed by: ru Notes: svn path=/head/; revision=81352
* mdoc(7) police:Ruslan Ermilov2001-08-071-4/+2
| | | | | | | | | | Avoid using parenthesis enclosure macros (.Pq and .Po/.Pc) with plain text. Not only this slows down the mdoc(7) processing significantly, but it also has an undesired (in this case) effect of disabling hyphenation within the entire enclosed block. Notes: svn path=/head/; revision=81251
* Avoid any chance of being misunderstood as having libelled developersSheldon Hearn2001-07-291-1/+1
| | | | | | | | | | | or developers' vendors without compromising the importance of warning against bad practice. Reported by: mjacob MFC after: 1 week Notes: svn path=/head/; revision=80541
* Remove whitespace at EOL.Dima Dorfman2001-07-159-29/+29
| | | | Notes: svn path=/head/; revision=79754
* mdoc(7) police: removed HISTORY info from the .Os call.Ruslan Ermilov2001-07-102-2/+2
| | | | Notes: svn path=/head/; revision=79531