1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #include "_stdio.h"
- int attribute_hidden __stdio_adjust_position(register FILE * __restrict stream,
- register __offmax_t *pos)
- {
- __offmax_t oldpos;
- int corr;
- if ((corr = stream->__modeflags & __MASK_READING) != 0) {
- --corr;
- }
- #ifdef __UCLIBC_HAS_WCHAR__
- if (corr && __STDIO_STREAM_IS_WIDE(stream)) {
-
- if ((corr > 1) || stream->__ungot[1]) {
- return -1;
- }
- corr -= (1 + stream->__ungot_width[1]);
- if (stream->__state.__mask > 0) {
- corr -= stream->__ungot_width[0];
- }
- }
- #endif
- #ifdef __STDIO_BUFFERS
- corr += (((__STDIO_STREAM_IS_WRITING(stream))
- ? stream->__bufstart : stream->__bufread)
- - stream->__bufpos);
- #endif
- oldpos = *pos;
-
- if ((*pos -= corr) > oldpos) {
- corr = -corr;
- }
- if (corr < 0) {
- __set_errno(EOVERFLOW);
- }
- return corr;
- }
|