Deleted Added
full compact
ftell.c (14790) ftell.c (14840)
1/*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 47 unchanged lines hidden (view full) ---

56 register fpos_t pos;
57
58 if (fp->_seek == NULL) {
59 errno = ESPIPE; /* historic practice */
60 return (-1L);
61 }
62
63#ifdef _THREAD_SAFE
1/*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 47 unchanged lines hidden (view full) ---

56 register fpos_t pos;
57
58 if (fp->_seek == NULL) {
59 errno = ESPIPE; /* historic practice */
60 return (-1L);
61 }
62
63#ifdef _THREAD_SAFE
64 _thread_flockfile((FILE *) fp,__FILE__,__LINE__);
64 _thread_flockfile(fp, __FILE__, __LINE__);
65#endif
66 /*
67 * Find offset of underlying I/O object, then
68 * adjust for buffered bytes.
69 */
70 if (fp->_flags & __SOFF)
71 pos = fp->_offset;
72 else {
73 pos = (*fp->_seek)(fp->_cookie, (fpos_t)0, SEEK_CUR);
65#endif
66 /*
67 * Find offset of underlying I/O object, then
68 * adjust for buffered bytes.
69 */
70 if (fp->_flags & __SOFF)
71 pos = fp->_offset;
72 else {
73 pos = (*fp->_seek)(fp->_cookie, (fpos_t)0, SEEK_CUR);
74 if (pos == -1L) {
74 if (pos == -1) {
75#ifdef _THREAD_SAFE
75#ifdef _THREAD_SAFE
76 _thread_funlockfile((FILE *) fp);
76 _thread_funlockfile(fp);
77#endif
78 return (pos);
79 }
80 }
81 if (fp->_flags & __SRD) {
82 /*
83 * Reading. Any unread characters (including
84 * those from ungetc) cause the position to be

--- 6 unchanged lines hidden (view full) ---

91 /*
92 * Writing. Any buffered characters cause the
93 * position to be greater than that in the
94 * underlying object.
95 */
96 pos += fp->_p - fp->_bf._base;
97 }
98#ifdef _THREAD_SAFE
77#endif
78 return (pos);
79 }
80 }
81 if (fp->_flags & __SRD) {
82 /*
83 * Reading. Any unread characters (including
84 * those from ungetc) cause the position to be

--- 6 unchanged lines hidden (view full) ---

91 /*
92 * Writing. Any buffered characters cause the
93 * position to be greater than that in the
94 * underlying object.
95 */
96 pos += fp->_p - fp->_bf._base;
97 }
98#ifdef _THREAD_SAFE
99 _thread_funlockfile((FILE *) fp);
99 _thread_funlockfile(fp);
100#endif
101 return (pos);
102}
100#endif
101 return (pos);
102}