This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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][BZ #12685] Allow arbitrary number of modes in fopen.


Hi,

I implemented  Michael Kerrisk's suggestion from
http://sourceware.org/bugzilla/show_bug.cgi?id=12685
to read mode until NULL or comma (for ,ccs=) is reached.

OK to commit?

Ondra

	* libio/fileops.c (_IO_new_file_fopen): Allow arbitrary number of modes.
	* libio/iofdopen.c (_IO_new_fdopen): Likewise.

---
 libio/fileops.c  |    4 +---
 libio/iofdopen.c |    4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/libio/fileops.c b/libio/fileops.c
index 61b61b3..50c3eb2 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -286,12 +286,10 @@ _IO_new_file_fopen (fp, filename, mode, is32not64)
 #ifdef _LIBC
   last_recognized = mode;
 #endif
-  for (i = 1; i < 7; ++i)
+  while (*mode && *mode != ',')
     {
       switch (*++mode)
 	{
-	case '\0':
-	  break;
 	case '+':
 	  omode = O_RDWR;
 	  read_write &= _IO_IS_APPENDING;
diff --git a/libio/iofdopen.c b/libio/iofdopen.c
index a65a5a6..2c3045f 100644
--- a/libio/iofdopen.c
+++ b/libio/iofdopen.c
@@ -75,12 +75,10 @@ _IO_new_fdopen (fd, mode)
       MAYBE_SET_EINVAL;
       return NULL;
   }
-  for (i = 1; i < 5; ++i)
+  while (*mode && *mode != ',')
     {
       switch (*++mode)
 	{
-	case '\0':
-	  break;
 	case '+':
 	  read_write &= _IO_IS_APPENDING;
 	  break;
-- 
1.7.4.4


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