This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH]: Implement fwide (was Re: swprintf() and friends?)


On Nov  3 16:26, Jeff Johnston wrote:
> Adding additional fields to __sFILE and __sFILE64 should be ok and no, I 
> wouldn't just support wide I/O only on large files.
>
> I would start by adding a _flags2 field in a regular __sFILE which makes it 
> consistent with __sFILE64.  This will be outside of the fake std stream 
> support.  Anything that can be checked on a non-resolved fake std stream 
> "has" to be in _flags.  This includes operations where we don't want to 
> resolve the stream (e.g. checking the error or EOF flags).  After that, it 
> is optional where a flag goes.
>
> At quick glance, the __SMOD flag can definitely be moved to _flags2 as it 
> is never set in newlib code and never checked except by fseek and only 
> after resolving any std stream.  I assume it is a Cygwin creation as it was 
> added by  cgf in 2000 for fgetline.c which doesn't exist in newlib.  If 
> this is not used by Cygwin, we should toss it altogether.  Either way, it 
> frees up one bit.
>
> For fwide support, I assume you mean two bits and yes, I believe two bits 
> would work.  One bit would mean decided (0 = undecided) and this should 
> take the free bit I mention above.  The __srefill_r and __sfvwrite_r 
> functions could be modified to stamp a file as being narrow/wide and 
> decided, if currently undecided (an extra argument would be needed to these 
> functions to say which type of fn was calling).  If setting and the file is 
> already undecided, then we must resolve any std stream first.  The decided 
> orientation bit would be in _flags (0 = narrow, 1 = wide).
>
> Mixing of narrow/wide functions is undefined behavior.

As a starting point I removed the __SMOD flag and created two new flags
__SORD and __SWID, the latter for _flags2 and using the same bit mask
as __SORD.  I also created two functions fwide and _fwide_r.  Other than
that the new orientation bits are not used so far.  We can build the other
missing functionality slowly around this.

Is that ok?


Thanks,
Corinna


	* libc/include/stdio.h (__SMOD): Remove.
	(__SORD): Add using the same bit mask as the former __SMOD.
	(__SWID): Add as first flag for the _flags2 member.
	* libc/include/wchar.h (fwide): Declare.
	(_fwide_r): Declare.
	* libc/include/sys/reent.h (struct __sFILE): Add _flags2 member.
	(struct __sFILE64): Tweak _flags2 comment.
	* libc/stdio/Makefile.am: Accommodate new fwide.c.
	* libc/stdio/Makefile.in: Regenerate.
	* libc/stdio/findfp.c (std): Set _flags2 to 0.
	(__sfp): Ditto.
	* libc/stdio/fwide.c: New file implementing fwide and _fwide_r.
	* libc/stdio/refill.c (__srefill_r): Drop resetting __SMOD flag.
	* libc/stdio/vfscanf.c (__ssrefill_r): Ditto.
	* libc/stdio/fseek.c (_fseek_r): Drop checking __SMOD flag.
	* libc/stdio64/fseeko64.c (_fseeko64_r): Ditto.


Index: libc/include/stdio.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/stdio.h,v
retrieving revision 1.49
diff -u -p -r1.49 stdio.h
--- libc/include/stdio.h	23 Apr 2008 11:13:24 -0000	1.49
+++ libc/include/stdio.h	7 Nov 2008 14:07:05 -0000
@@ -78,12 +78,15 @@ typedef _fpos64_t fpos64_t;
 #define	__SOPT	0x0400		/* do fseek() optimisation */
 #define	__SNPT	0x0800		/* do not do fseek() optimisation */
 #define	__SOFF	0x1000		/* set iff _offset is in fact correct */
-#define	__SMOD	0x2000		/* true => fgetline modified _p text */
+#define	__SORD	0x2000		/* true => stream orientation (byte/wide) decided */
 #if defined(__CYGWIN__)
 #  define __SCLE  0x4000        /* convert line endings CR/LF <-> NL */
 #endif
 #define	__SL64	0x8000		/* is 64-bit offset large file */
 
+/* _flags2 flags */
+#define	__SWID	0x2000		/* true => stream orientation wide, false => byte, only valid if __SORD in _flags is true */
+
 /*
  * The following three definitions are for ANSI C, which took them
  * from System V, which stupidly took internal interface macros and
Index: libc/include/wchar.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/wchar.h,v
retrieving revision 1.16
diff -u -p -r1.16 wchar.h
--- libc/include/wchar.h	19 Dec 2007 17:33:11 -0000	1.16
+++ libc/include/wchar.h	7 Nov 2008 14:07:05 -0000
@@ -90,6 +90,9 @@ long long _EXFUN(_wcstoll_r, (struct _re
 unsigned long _EXFUN(_wcstoul_r, (struct _reent *, const wchar_t *, wchar_t **, int));
 unsigned long long _EXFUN(_wcstoull_r, (struct _reent *, const wchar_t *, wchar_t **, int));
 
+int _EXFUN (fwide, (FILE *, int));
+int _EXFUN (_fwide_r, (struct _reent *, FILE *, int));
+
 _END_STD_C
 
 #endif /* _WCHAR_H_ */
Index: libc/include/sys/reent.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/sys/reent.h,v
retrieving revision 1.43
diff -u -p -r1.43 reent.h
--- libc/include/sys/reent.h	2 Oct 2008 16:43:23 -0000	1.43
+++ libc/include/sys/reent.h	7 Nov 2008 14:07:05 -0000
@@ -212,6 +212,7 @@ struct __sFILE {
 #ifndef __SINGLE_THREAD__
   _flock_t _lock;	/* for thread-safety locking */
 #endif
+  int   _flags2;        /* More flags. */
 };
 
 #ifdef __CUSTOM_FILE_IO__
@@ -256,7 +257,7 @@ struct __sFILE64 {
 
   /* Unix stdio files get aligned to block boundaries on fseek() */
   int	_blksize;	/* stat.st_blksize (may be != _bf._size) */
-  int   _flags2;        /* for future use */
+  int   _flags2;        /* More flags. */
 
   _off64_t _offset;     /* current lseek offset */
   _fpos64_t _EXFUN((*_seek64),(struct _reent *, _PTR, _fpos64_t, int));
Index: libc/stdio/Makefile.am
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/Makefile.am,v
retrieving revision 1.28
diff -u -p -r1.28 Makefile.am
--- libc/stdio/Makefile.am	14 Apr 2008 21:14:55 -0000	1.28
+++ libc/stdio/Makefile.am	7 Nov 2008 14:07:05 -0000
@@ -31,6 +31,7 @@ GENERAL_SOURCES = \
 	ftell.c			\
 	fvwrite.c			\
 	fwalk.c			\
+	fwide.c			\
 	fwrite.c			\
 	getc.c				\
 	getchar.c			\
@@ -206,6 +207,7 @@ CHEWOUT_FILES = \
 	fsetpos.def		\
 	ftell.def		\
 	funopen.def		\
+	fwide.def		\
 	fwrite.def		\
 	getc.def		\
 	getc_u.def		\
@@ -273,6 +275,7 @@ $(lpfx)ftell.$(oext): local.h
 $(lpfx)funopen.$(oext): local.h
 $(lpfx)fvwrite.$(oext): local.h fvwrite.h
 $(lpfx)fwalk.$(oext): local.h
+$(lpfx)fwide.$(oext): local.h
 $(lpfx)fwrite.$(oext): local.h fvwrite.h
 $(lpfx)iscanf.$(oext): local.h
 $(lpfx)makebuf.$(oext): local.h
Index: libc/stdio/Makefile.in
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/Makefile.in,v
retrieving revision 1.42
diff -u -p -r1.42 Makefile.in
--- libc/stdio/Makefile.in	29 Sep 2008 15:40:41 -0000	1.42
+++ libc/stdio/Makefile.in	7 Nov 2008 14:07:05 -0000
@@ -74,33 +74,33 @@ am__objects_1 = lib_a-clearerr.$(OBJEXT)
 	lib_a-fiscanf.$(OBJEXT) lib_a-fseek.$(OBJEXT) \
 	lib_a-fsetpos.$(OBJEXT) lib_a-ftell.$(OBJEXT) \
 	lib_a-fvwrite.$(OBJEXT) lib_a-fwalk.$(OBJEXT) \
-	lib_a-fwrite.$(OBJEXT) lib_a-getc.$(OBJEXT) \
-	lib_a-getchar.$(OBJEXT) lib_a-getc_u.$(OBJEXT) \
-	lib_a-getchar_u.$(OBJEXT) lib_a-getdelim.$(OBJEXT) \
-	lib_a-getline.$(OBJEXT) lib_a-gets.$(OBJEXT) \
-	lib_a-iprintf.$(OBJEXT) lib_a-iscanf.$(OBJEXT) \
-	lib_a-makebuf.$(OBJEXT) lib_a-perror.$(OBJEXT) \
-	lib_a-printf.$(OBJEXT) lib_a-putc.$(OBJEXT) \
-	lib_a-putchar.$(OBJEXT) lib_a-putc_u.$(OBJEXT) \
-	lib_a-putchar_u.$(OBJEXT) lib_a-puts.$(OBJEXT) \
-	lib_a-refill.$(OBJEXT) lib_a-remove.$(OBJEXT) \
-	lib_a-rename.$(OBJEXT) lib_a-rewind.$(OBJEXT) \
-	lib_a-rget.$(OBJEXT) lib_a-scanf.$(OBJEXT) \
-	lib_a-sccl.$(OBJEXT) lib_a-setbuf.$(OBJEXT) \
-	lib_a-setbuffer.$(OBJEXT) lib_a-setlinebuf.$(OBJEXT) \
-	lib_a-setvbuf.$(OBJEXT) lib_a-siprintf.$(OBJEXT) \
-	lib_a-siscanf.$(OBJEXT) lib_a-sniprintf.$(OBJEXT) \
-	lib_a-snprintf.$(OBJEXT) lib_a-sprintf.$(OBJEXT) \
-	lib_a-sscanf.$(OBJEXT) lib_a-stdio.$(OBJEXT) \
-	lib_a-tmpfile.$(OBJEXT) lib_a-tmpnam.$(OBJEXT) \
-	lib_a-ungetc.$(OBJEXT) lib_a-vdiprintf.$(OBJEXT) \
-	lib_a-vdprintf.$(OBJEXT) lib_a-viprintf.$(OBJEXT) \
-	lib_a-viscanf.$(OBJEXT) lib_a-vprintf.$(OBJEXT) \
-	lib_a-vscanf.$(OBJEXT) lib_a-vsiprintf.$(OBJEXT) \
-	lib_a-vsiscanf.$(OBJEXT) lib_a-vsnprintf.$(OBJEXT) \
-	lib_a-vsniprintf.$(OBJEXT) lib_a-vsprintf.$(OBJEXT) \
-	lib_a-vsscanf.$(OBJEXT) lib_a-wbuf.$(OBJEXT) \
-	lib_a-wsetup.$(OBJEXT)
+	lib_a-fwide.$(OBJEXT) lib_a-fwrite.$(OBJEXT) \
+	lib_a-getc.$(OBJEXT) lib_a-getchar.$(OBJEXT) \
+	lib_a-getc_u.$(OBJEXT) lib_a-getchar_u.$(OBJEXT) \
+	lib_a-getdelim.$(OBJEXT) lib_a-getline.$(OBJEXT) \
+	lib_a-gets.$(OBJEXT) lib_a-iprintf.$(OBJEXT) \
+	lib_a-iscanf.$(OBJEXT) lib_a-makebuf.$(OBJEXT) \
+	lib_a-perror.$(OBJEXT) lib_a-printf.$(OBJEXT) \
+	lib_a-putc.$(OBJEXT) lib_a-putchar.$(OBJEXT) \
+	lib_a-putc_u.$(OBJEXT) lib_a-putchar_u.$(OBJEXT) \
+	lib_a-puts.$(OBJEXT) lib_a-refill.$(OBJEXT) \
+	lib_a-remove.$(OBJEXT) lib_a-rename.$(OBJEXT) \
+	lib_a-rewind.$(OBJEXT) lib_a-rget.$(OBJEXT) \
+	lib_a-scanf.$(OBJEXT) lib_a-sccl.$(OBJEXT) \
+	lib_a-setbuf.$(OBJEXT) lib_a-setbuffer.$(OBJEXT) \
+	lib_a-setlinebuf.$(OBJEXT) lib_a-setvbuf.$(OBJEXT) \
+	lib_a-siprintf.$(OBJEXT) lib_a-siscanf.$(OBJEXT) \
+	lib_a-sniprintf.$(OBJEXT) lib_a-snprintf.$(OBJEXT) \
+	lib_a-sprintf.$(OBJEXT) lib_a-sscanf.$(OBJEXT) \
+	lib_a-stdio.$(OBJEXT) lib_a-tmpfile.$(OBJEXT) \
+	lib_a-tmpnam.$(OBJEXT) lib_a-ungetc.$(OBJEXT) \
+	lib_a-vdiprintf.$(OBJEXT) lib_a-vdprintf.$(OBJEXT) \
+	lib_a-viprintf.$(OBJEXT) lib_a-viscanf.$(OBJEXT) \
+	lib_a-vprintf.$(OBJEXT) lib_a-vscanf.$(OBJEXT) \
+	lib_a-vsiprintf.$(OBJEXT) lib_a-vsiscanf.$(OBJEXT) \
+	lib_a-vsnprintf.$(OBJEXT) lib_a-vsniprintf.$(OBJEXT) \
+	lib_a-vsprintf.$(OBJEXT) lib_a-vsscanf.$(OBJEXT) \
+	lib_a-wbuf.$(OBJEXT) lib_a-wsetup.$(OBJEXT)
 @ELIX_LEVEL_1_FALSE@am__objects_2 = lib_a-asiprintf.$(OBJEXT) \
 @ELIX_LEVEL_1_FALSE@	lib_a-asprintf.$(OBJEXT) \
 @ELIX_LEVEL_1_FALSE@	lib_a-fcloseall.$(OBJEXT) \
@@ -129,7 +129,7 @@ am__objects_4 = clearerr.lo fclose.lo fd
 	fflush.lo fgetc.lo fgetpos.lo fgets.lo fileno.lo findfp.lo \
 	fiprintf.lo flags.lo fopen.lo fprintf.lo fputc.lo fputs.lo \
 	fread.lo freopen.lo fscanf.lo fiscanf.lo fseek.lo fsetpos.lo \
-	ftell.lo fvwrite.lo fwalk.lo fwrite.lo getc.lo getchar.lo \
+	ftell.lo fvwrite.lo fwalk.lo fwide.lo fwrite.lo getc.lo getchar.lo \
 	getc_u.lo getchar_u.lo getdelim.lo getline.lo gets.lo \
 	iprintf.lo iscanf.lo makebuf.lo perror.lo printf.lo putc.lo \
 	putchar.lo putc_u.lo putchar_u.lo puts.lo refill.lo remove.lo \
@@ -370,6 +370,7 @@ GENERAL_SOURCES = \
 	ftell.c			\
 	fvwrite.c			\
 	fwalk.c			\
+	fwide.c			\
 	fwrite.c			\
 	getc.c				\
 	getchar.c			\
@@ -497,6 +498,7 @@ CHEWOUT_FILES = \
 	fsetpos.def		\
 	ftell.def		\
 	funopen.def		\
+	fwide.def		\
 	fwrite.def		\
 	getc.def		\
 	getc_u.def		\
@@ -761,6 +763,12 @@ lib_a-fwalk.o: fwalk.c
 lib_a-fwalk.obj: fwalk.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fwalk.obj `if test -f 'fwalk.c'; then $(CYGPATH_W) 'fwalk.c'; else $(CYGPATH_W) '$(srcdir)/fwalk.c'; fi`
 
+lib_a-fwide.o: fwide.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fwide.o `test -f 'fwide.c' || echo '$(srcdir)/'`fwide.c
+
+lib_a-fwide.obj: fwide.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fwide.obj `if test -f 'fwide.c'; then $(CYGPATH_W) 'fwide.c'; else $(CYGPATH_W) '$(srcdir)/fwide.c'; fi`
+
 lib_a-fwrite.o: fwrite.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fwrite.o `test -f 'fwrite.c' || echo '$(srcdir)/'`fwrite.c
 
@@ -1402,6 +1410,7 @@ $(lpfx)ftell.$(oext): local.h
 $(lpfx)funopen.$(oext): local.h
 $(lpfx)fvwrite.$(oext): local.h fvwrite.h
 $(lpfx)fwalk.$(oext): local.h
+$(lpfx)fwide.$(oext): local.h
 $(lpfx)fwrite.$(oext): local.h fvwrite.h
 $(lpfx)iscanf.$(oext): local.h
 $(lpfx)makebuf.$(oext): local.h
Index: libc/stdio/findfp.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/findfp.c,v
retrieving revision 1.19
diff -u -p -r1.19 findfp.c
--- libc/stdio/findfp.c	31 Jul 2007 20:49:40 -0000	1.19
+++ libc/stdio/findfp.c	7 Nov 2008 14:07:05 -0000
@@ -46,6 +46,7 @@ _DEFUN(std, (ptr, flags, file, data),
   ptr->_r = 0;
   ptr->_w = 0;
   ptr->_flags = flags;
+  ptr->_flags2 = 0;
   ptr->_file = file;
   ptr->_bf._base = 0;
   ptr->_bf._size = 0;
@@ -126,6 +127,7 @@ _DEFUN(__sfp, (d),
 found:
   fp->_file = -1;		/* no file */
   fp->_flags = 1;		/* reserve this slot; caller sets real flags */
+  fp->_flags2 = 0;
 #ifndef __SINGLE_THREAD__
   __lock_init_recursive (fp->_lock);
 #endif
Index: libc/stdio/fseek.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/fseek.c,v
retrieving revision 1.18
diff -u -p -r1.18 fseek.c
--- libc/stdio/fseek.c	13 Jul 2007 20:37:53 -0000	1.18
+++ libc/stdio/fseek.c	7 Nov 2008 14:07:05 -0000
@@ -304,12 +304,10 @@ _DEFUN(_fseek_r, (ptr, fp, offset, whenc
   /*
    * If the target offset is within the current buffer,
    * simply adjust the pointers, clear EOF, undo ungetc(),
-   * and return.  (If the buffer was modified, we have to
-   * skip this; see fgetline.c.)
+   * and return.
    */
 
-  if ((fp->_flags & __SMOD) == 0 &&
-      target >= curoff && target < curoff + n)
+  if (target >= curoff && target < curoff + n)
     {
       register int o = target - curoff;
 
Index: libc/stdio/fwide.c
===================================================================
RCS file: libc/stdio/fwide.c
diff -N libc/stdio/fwide.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libc/stdio/fwide.c	7 Nov 2008 14:07:05 -0000
@@ -0,0 +1,92 @@
+/*
+FUNCTION
+<<fwide>>---set and determine the orientation of a FILE stream
+
+INDEX
+	fwide
+INDEX
+	_fwide_r
+
+ANSI_SYNOPSIS
+	#include <wchar.h>
+	int fwide(FILE *<[fp]>, int <[mode]>)
+
+	int _fwide_r(struct _reent *<[ptr]>, FILE *<[fp]>, int <[mode]>)
+
+TRAD_SYNOPSIS
+	#include <wchar.h>
+	int fwide(<[fp]>, <[mode]>)
+	FILE *<[fp]>;
+	int <[mode]>;
+
+	int fwide(<[ptr]>, <[fp]>, <[mode]>)
+	struct _reent *<[ptr]>;
+	FILE *<[fp]>;
+	int <[mode]>;
+
+DESCRIPTION
+When <[mode]> is zero, the <<fwide>> function determines the current
+orientation of <[fp]>. It returns a value > 0 if <[fp]> is
+wide-character oriented, i.e. if wide character I/O is permitted but
+char I/O is disallowed. It returns a value < 0 if <[fp]> is byte
+oriented, i.e. if char I/O is permitted but wide character I/O is
+disallowed. It returns zero if <[fp]> has no orientation yet; in
+this case the next I/O operation might change the orientation (to byte
+oriented if it is a char I/O operation, or to wide-character oriented
+if it is a wide character I/O operation).
+
+Once a stream has an orientation, it cannot be changed and persists
+until the stream is closed.
+
+When <[mode]> is non-zero, the <<fwide>> function first attempts to set
+<[fp]>'s orientation (to wide-character oriented if <[mode]> > 0, or to
+byte oriented if <[mode]> < 0). It then returns a value denoting the
+current orientation, as above.
+
+RETURNS
+The <<fwide>> function returns <[fp]>'s orientation, after possibly
+changing it. A return value > 0 means wide-character oriented. A return
+value < 0 means byte oriented. A return value of zero means undecided.
+
+PORTABILITY
+C99, POSIX.1-2001.
+
+*/
+
+#include <_ansi.h>
+#include "local.h"
+
+int
+_DEFUN(_fwide_r, (ptr, fp, mode),
+	struct _reent *ptr _AND
+	FILE *fp _AND
+	int mode)
+{
+  int ret;
+
+  CHECK_INIT(ptr, fp);
+
+  _flockfile (fp);
+  if (mode && !(fp->_flags & __SORD))
+    {
+      fp->_flags |= __SORD;
+      if (mode > 0)
+	fp->_flags2 |= __SWID;
+      else
+	fp->_flags2 &= ~__SWID;
+    }
+  if (!(fp->_flags & __SORD))
+    ret = 0;
+  else
+    ret = (fp->_flags2 & __SWID) ? 1 : -1;
+  _funlockfile (fp);
+  return ret;
+}
+
+int
+_DEFUN(fwide, (fp, mode),
+	FILE *fp _AND
+	int mode)
+{
+  return _fwide_r (_REENT, fp, mode);
+}
Index: libc/stdio/refill.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/refill.c,v
retrieving revision 1.11
diff -u -p -r1.11 refill.c
--- libc/stdio/refill.c	13 Jul 2007 20:37:53 -0000	1.11
+++ libc/stdio/refill.c	7 Nov 2008 14:07:05 -0000
@@ -105,7 +105,6 @@ _DEFUN(__srefill_r, (ptr, fp),
     _CAST_VOID _fwalk (_GLOBAL_REENT, lflush);
   fp->_p = fp->_bf._base;
   fp->_r = fp->_read (ptr, fp->_cookie, (char *) fp->_p, fp->_bf._size);
-  fp->_flags &= ~__SMOD;	/* buffer contents are again pristine */
 #ifndef __CYGWIN__
   if (fp->_r <= 0)
 #else
Index: libc/stdio/vfscanf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/vfscanf.c,v
retrieving revision 1.42
diff -u -p -r1.42 vfscanf.c
--- libc/stdio/vfscanf.c	31 Oct 2008 21:08:03 -0000	1.42
+++ libc/stdio/vfscanf.c	7 Nov 2008 14:07:05 -0000
@@ -379,7 +379,6 @@ _DEFUN(__ssrefill_r, (ptr, fp),
   /* Otherwise we are out of character input.  */
   fp->_p = fp->_bf._base;
   fp->_r = 0;
-  fp->_flags &= ~__SMOD;	/* buffer contents are again pristine */
   fp->_flags |= __SEOF;
   return EOF;
 }
Index: libc/stdio64/fseeko64.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio64/fseeko64.c,v
retrieving revision 1.12
diff -u -p -r1.12 fseeko64.c
--- libc/stdio64/fseeko64.c	13 Jul 2007 20:37:53 -0000	1.12
+++ libc/stdio64/fseeko64.c	7 Nov 2008 14:07:05 -0000
@@ -282,12 +282,10 @@ _DEFUN (_fseeko64_r, (ptr, fp, offset, w
   /*
    * If the target offset is within the current buffer,
    * simply adjust the pointers, clear EOF, undo ungetc(),
-   * and return.  (If the buffer was modified, we have to
-   * skip this; see fgetline.c.)
+   * and return.
    */
 
-  if ((fp->_flags & __SMOD) == 0 &&
-      target >= curoff && target < curoff + n)
+  if (target >= curoff && target < curoff + n)
     {
       register int o = target - curoff;
 

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]