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]

Re: [PATCH 1/6 v3] Reformat libio files


On Mon, Jun 03, 2013 at 04:55:45PM +0000, Joseph S. Myers wrote:
> On Mon, 3 Jun 2013, Ondrej Bilka wrote:
> 
> > > The indentation was correct formatting for K&R C.
> > > If you change anything at all, move to ISO C:
> > > 
> > > void
> > > _IO_new_file_init (struct _IO_FILE_plus *fp)
> > > {
> > > 
> > I updated my formatter to handle this and other. Here is v2
> 
> I don't think the patch should be doing so many different things.  It's 
> more than reformatting (so your ChangeLog entry is misleading); you're 
> changing function definitions to ISO C format, and using __glibc_unlikely, 
> as well.  I think a patch should do one thing and do it well.  So separate 
> pure formatting changes (changes that don't affect the sequence of 
> preprocessing tokens at all, just whitespace and maybe comment formatting) 
> from conversion of function definitions to ISO C format, from use of 
> __glibc_likely / __glibc_unlikely, from removal of "register".  Each such 
> cleanup is generally appropriate, but should be separated from different 
> cleanups to make it as clear as possible what the patch does.
> 
I disabled cleanups and now do formating only.

These cleanups do not do formating and you cannot avoid doing formating
before or after cleanup and in both cases its somewhat messy.

Just do not complain that formating of pre ISO C function definitions is
wrong and I should rewrite them to ISO C format.

I could prepend it by rewrite to ISO C which is unformated.

> > -#define CLOSED_FILEBUF_FLAGS \
> > -  (_IO_IS_FILEBUF+_IO_NO_READS+_IO_NO_WRITES+_IO_TIED_PUT_GET)
> > +#define CLOSED_FILEBUF_FLAGS                                                  \
> > +  (_IO_IS_FILEBUF + _IO_NO_READS + _IO_NO_WRITES + _IO_TIED_PUT_GET)
> 
> That appears to be putting the backslash further to the right than Emacs 
> C-C C-\ does (in most cases I think of Emacs formatting as a good guide if 
> the GNU Coding Standards don't specify some detail).

What does this do? a C-C C-\ is undefined at emacs that I installed. Is
possible to make it standalone?

Now I put \ at position 80. This has advantage that it will stay fixed 
no matter how macro is changed.

Alternatives are

#define foo \
  bar \
  baz 

that has syntactic clutter.

Or

#define foo \
  bar       \
  baz       

Which is also possible.

A program cannot guess what alternative is selected so it is better to
stick with one.

> > @@ -600,7 +577,7 @@ _IO_new_file_underflow (fp)
> >    fp->_IO_read_base = fp->_IO_read_ptr = fp->_IO_buf_base;
> >    fp->_IO_read_end = fp->_IO_buf_base;
> >    fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end
> > -    = fp->_IO_buf_base;
> > +					     = fp->_IO_buf_base;
> 
> No, two-column indent is what Emacs does here.
>
This is mishandled by uncrustify. I could put feature request or
write additional pass.

> > @@ -894,7 +868,7 @@ _IO_new_file_sync (fp)
> >  	fp->_IO_read_end = fp->_IO_read_ptr;
> >  #ifdef ESPIPE
> >        else if (errno == ESPIPE)
> > -	; /* Ignore error from unseekable devices. */
> > +	;  /* Ignore error from unseekable devices. */
> 
> What rule do you think there is for indentation of comments after code 
> that is followed in glibc (or generally in the GNU system)?  I wasn't 
> aware of one, and without consensus on one, existing code shouldn't be 
> changed like this; formatting changes should be when code clearly deviates 
> from the established desired style.
> 
Again uncrustify does this. I do not know how turn it specially off. As
it is minor I would accept this noise.


Here is v3.

	* libio/fileops.c: Reformat.
	* libio/iofdopen.c: Likewise.
	* libio/iofopen.c: Likewise.

---
 libio/fileops.c  |  424 ++++++++++++++++++++++++++----------------------------
 libio/iofdopen.c |   45 +++---
 libio/iofopen.c  |   21 ++-
 3 files changed, 232 insertions(+), 258 deletions(-)

diff --git a/libio/fileops.c b/libio/fileops.c
index 61b61b3..ab2b7d8 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -130,15 +130,14 @@ extern struct __gconv_trans_data __libio_translit attribute_hidden;
 
    UNBUFFERED STREAMS:
    If a filebuf is unbuffered(), the _shortbuf[1] is used as the buffer.
-*/
+ */
 
-#define CLOSED_FILEBUF_FLAGS \
-  (_IO_IS_FILEBUF+_IO_NO_READS+_IO_NO_WRITES+_IO_TIED_PUT_GET)
+#define CLOSED_FILEBUF_FLAGS                                                  \
+  (_IO_IS_FILEBUF + _IO_NO_READS + _IO_NO_WRITES + _IO_TIED_PUT_GET)
 
 
-void
-_IO_new_file_init (fp)
-     struct _IO_FILE_plus *fp;
+void _IO_new_file_init (fp)
+struct _IO_FILE_plus *fp;
 {
   /* POSIX.1 allows another file handle to be used to change the position
      of our file descriptor.  Hence we actually don't know the actual
@@ -151,9 +150,8 @@ _IO_new_file_init (fp)
 }
 libc_hidden_ver (_IO_new_file_init, _IO_file_init)
 
-int
-_IO_new_file_close_it (fp)
-     _IO_FILE *fp;
+int _IO_new_file_close_it (fp)
+_IO_FILE * fp;
 {
   int write_status;
   if (!_IO_file_is_open (fp))
@@ -186,7 +184,7 @@ _IO_new_file_close_it (fp)
   _IO_setp (fp, NULL, NULL);
 
   _IO_un_link ((struct _IO_FILE_plus *) fp);
-  fp->_flags = _IO_MAGIC|CLOSED_FILEBUF_FLAGS;
+  fp->_flags = _IO_MAGIC | CLOSED_FILEBUF_FLAGS;
   fp->_fileno = -1;
   fp->_offset = _IO_pos_BAD;
 
@@ -194,10 +192,9 @@ _IO_new_file_close_it (fp)
 }
 libc_hidden_ver (_IO_new_file_close_it, _IO_file_close_it)
 
-void
-_IO_new_file_finish (fp, dummy)
-     _IO_FILE *fp;
-     int dummy;
+void _IO_new_file_finish (fp, dummy)
+_IO_FILE * fp;
+int dummy;
 {
   if (_IO_file_is_open (fp))
     {
@@ -211,12 +208,12 @@ libc_hidden_ver (_IO_new_file_finish, _IO_file_finish)
 
 _IO_FILE *
 _IO_file_open (fp, filename, posix_mode, prot, read_write, is32not64)
-     _IO_FILE *fp;
-     const char *filename;
-     int posix_mode;
-     int prot;
-     int read_write;
-     int is32not64;
+_IO_FILE * fp;
+const char *filename;
+int posix_mode;
+int prot;
+int read_write;
+int is32not64;
 {
   int fdesc;
 #ifdef _LIBC
@@ -231,9 +228,11 @@ _IO_file_open (fp, filename, posix_mode, prot, read_write, is32not64)
   if (fdesc < 0)
     return NULL;
   fp->_fileno = fdesc;
-  _IO_mask_flags (fp, read_write,_IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING);
+  _IO_mask_flags (fp, read_write,
+		  _IO_NO_READS + _IO_NO_WRITES + _IO_IS_APPENDING);
   if ((read_write & _IO_IS_APPENDING) && (read_write & _IO_NO_READS))
-    if (_IO_SEEKOFF (fp, (_IO_off64_t)0, _IO_seek_end, _IOS_INPUT|_IOS_OUTPUT)
+    if (_IO_SEEKOFF (fp, (_IO_off64_t) 0, _IO_seek_end, _IOS_INPUT |
+		     _IOS_OUTPUT)
 	== _IO_pos_BAD && errno != ESPIPE)
       {
 	close_not_cancel (fdesc);
@@ -246,10 +245,10 @@ libc_hidden_def (_IO_file_open)
 
 _IO_FILE *
 _IO_new_file_fopen (fp, filename, mode, is32not64)
-     _IO_FILE *fp;
-     const char *filename;
-     const char *mode;
-     int is32not64;
+_IO_FILE * fp;
+const char *filename;
+const char *mode;
+int is32not64;
 {
   int oflags = 0, omode;
   int read_write;
@@ -271,13 +270,13 @@ _IO_new_file_fopen (fp, filename, mode, is32not64)
       break;
     case 'w':
       omode = O_WRONLY;
-      oflags = O_CREAT|O_TRUNC;
+      oflags = O_CREAT | O_TRUNC;
       read_write = _IO_NO_READS;
       break;
     case 'a':
       omode = O_WRONLY;
-      oflags = O_CREAT|O_APPEND;
-      read_write = _IO_NO_READS|_IO_IS_APPENDING;
+      oflags = O_CREAT | O_APPEND;
+      read_write = _IO_NO_READS | _IO_IS_APPENDING;
       break;
     default:
       __set_errno (EINVAL);
@@ -329,7 +328,7 @@ _IO_new_file_fopen (fp, filename, mode, is32not64)
       break;
     }
 
-  result = _IO_file_open (fp, filename, omode|oflags, oprot, read_write,
+  result = _IO_file_open (fp, filename, omode | oflags, oprot, read_write,
 			  is32not64);
 
   if (result != NULL)
@@ -425,19 +424,19 @@ libc_hidden_ver (_IO_new_file_fopen, _IO_file_fopen)
 
 _IO_FILE *
 _IO_new_file_attach (fp, fd)
-     _IO_FILE *fp;
-     int fd;
+_IO_FILE * fp;
+int fd;
 {
   if (_IO_file_is_open (fp))
     return NULL;
   fp->_fileno = fd;
-  fp->_flags &= ~(_IO_NO_READS+_IO_NO_WRITES);
+  fp->_flags &= ~(_IO_NO_READS + _IO_NO_WRITES);
   fp->_flags |= _IO_DELETE_DONT_CLOSE;
   /* Get the current position of the file. */
   /* We have to do that since that may be junk. */
   fp->_offset = _IO_pos_BAD;
   int save_errno = errno;
-  if (_IO_SEEKOFF (fp, (_IO_off64_t)0, _IO_seek_cur, _IOS_INPUT|_IOS_OUTPUT)
+  if (_IO_SEEKOFF (fp, (_IO_off64_t) 0, _IO_seek_cur, _IOS_INPUT | _IOS_OUTPUT)
       == _IO_pos_BAD && errno != ESPIPE)
     return NULL;
   __set_errno (save_errno);
@@ -447,15 +446,15 @@ libc_hidden_ver (_IO_new_file_attach, _IO_file_attach)
 
 _IO_FILE *
 _IO_new_file_setbuf (fp, p, len)
-     _IO_FILE *fp;
-     char *p;
-     _IO_ssize_t len;
+_IO_FILE * fp;
+char *p;
+_IO_ssize_t len;
 {
   if (_IO_default_setbuf (fp, p, len) == NULL)
     return NULL;
 
   fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end
-    = fp->_IO_buf_base;
+					     = fp->_IO_buf_base;
   _IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
 
   return fp;
@@ -465,9 +464,9 @@ libc_hidden_ver (_IO_new_file_setbuf, _IO_file_setbuf)
 
 _IO_FILE *
 _IO_file_setbuf_mmap (fp, p, len)
-     _IO_FILE *fp;
-     char *p;
-     _IO_ssize_t len;
+_IO_FILE * fp;
+char *p;
+_IO_ssize_t len;
 {
   _IO_FILE *result;
 
@@ -493,11 +492,10 @@ static _IO_size_t new_do_write (_IO_FILE *, const char *, _IO_size_t);
 /* Write TO_DO bytes from DATA to FP.
    Then mark FP as having empty buffers. */
 
-int
-_IO_new_do_write (fp, data, to_do)
-     _IO_FILE *fp;
-     const char *data;
-     _IO_size_t to_do;
+int _IO_new_do_write (fp, data, to_do)
+_IO_FILE * fp;
+const char *data;
+_IO_size_t to_do;
 {
   return (to_do == 0
 	  || (_IO_size_t) new_do_write (fp, data, to_do) == to_do) ? 0 : EOF;
@@ -505,11 +503,10 @@ _IO_new_do_write (fp, data, to_do)
 libc_hidden_ver (_IO_new_do_write, _IO_do_write)
 
 static
-_IO_size_t
-new_do_write (fp, data, to_do)
-     _IO_FILE *fp;
-     const char *data;
-     _IO_size_t to_do;
+_IO_size_t new_do_write (fp, data, to_do)
+_IO_FILE * fp;
+const char *data;
+_IO_size_t to_do;
 {
   _IO_size_t count;
   if (fp->_flags & _IO_IS_APPENDING)
@@ -533,14 +530,13 @@ new_do_write (fp, data, to_do)
   _IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
   fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_buf_base;
   fp->_IO_write_end = (fp->_mode <= 0
-		       && (fp->_flags & (_IO_LINE_BUF+_IO_UNBUFFERED))
+		       && (fp->_flags & (_IO_LINE_BUF + _IO_UNBUFFERED))
 		       ? fp->_IO_buf_base : fp->_IO_buf_end);
   return count;
 }
 
-int
-_IO_new_file_underflow (fp)
-     _IO_FILE *fp;
+int _IO_new_file_underflow (fp)
+_IO_FILE * fp;
 {
   _IO_ssize_t count;
 #if 0
@@ -571,7 +567,7 @@ _IO_new_file_underflow (fp)
 
   /* Flush all line buffered files before reading. */
   /* FIXME This can/should be moved to genops ?? */
-  if (fp->_flags & (_IO_LINE_BUF|_IO_UNBUFFERED))
+  if (fp->_flags & (_IO_LINE_BUF | _IO_UNBUFFERED))
     {
 #if 0
       _IO_flush_all_linebuffered ();
@@ -600,7 +596,7 @@ _IO_new_file_underflow (fp)
   fp->_IO_read_base = fp->_IO_read_ptr = fp->_IO_buf_base;
   fp->_IO_read_end = fp->_IO_buf_base;
   fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end
-    = fp->_IO_buf_base;
+					     = fp->_IO_buf_base;
 
   count = _IO_SYSREAD (fp, fp->_IO_buf_base,
 		       fp->_IO_buf_end - fp->_IO_buf_base);
@@ -610,7 +606,7 @@ _IO_new_file_underflow (fp)
 	fp->_flags |= _IO_EOF_SEEN;
       else
 	fp->_flags |= _IO_ERR_SEEN, count = 0;
-  }
+    }
   fp->_IO_read_end += count;
   if (count == 0)
     return EOF;
@@ -632,10 +628,10 @@ mmap_remap_check (_IO_FILE *fp)
   if (_IO_SYSSTAT (fp, &st) == 0
       && S_ISREG (st.st_mode) && st.st_size != 0
       /* Limit the file size to 1MB for 32-bit machines.  */
-      && (sizeof (ptrdiff_t) > 4 || st.st_size < 1*1024*1024))
+      && (sizeof (ptrdiff_t) > 4 || st.st_size < 1 * 1024 * 1024))
     {
       const size_t pagesize = __getpagesize ();
-# define ROUNDED(x)	(((x) + pagesize - 1) & ~(pagesize - 1))
+#define ROUNDED(x)     (((x) + pagesize - 1) & ~(pagesize - 1))
       if (ROUNDED (st.st_size) < ROUNDED (fp->_IO_buf_end
 					  - fp->_IO_buf_base))
 	{
@@ -672,11 +668,10 @@ mmap_remap_check (_IO_FILE *fp)
 	  fp->_IO_buf_end = fp->_IO_buf_base + st.st_size;
 	}
       else
-	{
-	  /* The number of pages didn't change.  */
-	  fp->_IO_buf_end = fp->_IO_buf_base + st.st_size;
-	}
-# undef ROUNDED
+	/* The number of pages didn't change.  */
+	fp->_IO_buf_end = fp->_IO_buf_base + st.st_size;
+
+#undef ROUNDED
 
       fp->_offset -= fp->_IO_read_end - fp->_IO_read_ptr;
       _IO_setg (fp, fp->_IO_buf_base,
@@ -750,7 +745,7 @@ decide_maybe_mmap (_IO_FILE *fp)
   if (_IO_SYSSTAT (fp, &st) == 0
       && S_ISREG (st.st_mode) && st.st_size != 0
       /* Limit the file size to 1MB for 32-bit machines.  */
-      && (sizeof (ptrdiff_t) > 4 || st.st_size < 1*1024*1024)
+      && (sizeof (ptrdiff_t) > 4 || st.st_size < 1 * 1024 * 1024)
       /* Sanity check.  */
       && (fp->_offset == _IO_pos_BAD || fp->_offset <= st.st_size))
     {
@@ -780,9 +775,9 @@ decide_maybe_mmap (_IO_FILE *fp)
 	      fp->_offset = st.st_size;
 
 	      if (fp->_mode <= 0)
-		_IO_JUMPS ((struct _IO_FILE_plus *)fp) = &_IO_file_jumps_mmap;
+		_IO_JUMPS ((struct _IO_FILE_plus *) fp) = &_IO_file_jumps_mmap;
 	      else
-		_IO_JUMPS ((struct _IO_FILE_plus *)fp) = &_IO_wfile_jumps_mmap;
+		_IO_JUMPS ((struct _IO_FILE_plus *) fp) = &_IO_wfile_jumps_mmap;
 	      fp->_wide_data->_wide_vtable = &_IO_wfile_jumps_mmap;
 
 	      return;
@@ -809,10 +804,9 @@ _IO_file_underflow_maybe_mmap (_IO_FILE *fp)
 }
 
 
-int
-_IO_new_file_overflow (f, ch)
-      _IO_FILE *f;
-      int ch;
+int _IO_new_file_overflow (f, ch)
+_IO_FILE * f;
+int ch;
 {
   if (f->_flags & _IO_NO_WRITES) /* SET ERROR */
     {
@@ -853,13 +847,13 @@ _IO_new_file_overflow (f, ch)
       f->_IO_read_base = f->_IO_read_ptr = f->_IO_read_end;
 
       f->_flags |= _IO_CURRENTLY_PUTTING;
-      if (f->_mode <= 0 && f->_flags & (_IO_LINE_BUF+_IO_UNBUFFERED))
+      if (f->_mode <= 0 && f->_flags & (_IO_LINE_BUF + _IO_UNBUFFERED))
 	f->_IO_write_end = f->_IO_write_ptr;
     }
   if (ch == EOF)
     return _IO_do_write (f, f->_IO_write_base,
 			 f->_IO_write_ptr - f->_IO_write_base);
-  if (f->_IO_write_ptr == f->_IO_buf_end ) /* Buffer is really full */
+  if (f->_IO_write_ptr == f->_IO_buf_end)  /* Buffer is really full */
     if (_IO_do_flush (f) == EOF)
       return EOF;
   *f->_IO_write_ptr++ = ch;
@@ -872,16 +866,16 @@ _IO_new_file_overflow (f, ch)
 }
 libc_hidden_ver (_IO_new_file_overflow, _IO_file_overflow)
 
-int
-_IO_new_file_sync (fp)
-     _IO_FILE *fp;
+int _IO_new_file_sync (fp)
+_IO_FILE * fp;
 {
   _IO_ssize_t delta;
   int retval = 0;
 
   /*    char* ptr = cur_ptr(); */
   if (fp->_IO_write_ptr > fp->_IO_write_base)
-    if (_IO_do_flush(fp)) return EOF;
+    if (_IO_do_flush (fp))
+      return EOF;
   delta = fp->_IO_read_ptr - fp->_IO_read_end;
   if (delta != 0)
     {
@@ -894,7 +888,7 @@ _IO_new_file_sync (fp)
 	fp->_IO_read_end = fp->_IO_read_ptr;
 #ifdef ESPIPE
       else if (errno == ESPIPE)
-	; /* Ignore error from unseekable devices. */
+	;  /* Ignore error from unseekable devices. */
 #endif
       else
 	retval = EOF;
@@ -930,12 +924,11 @@ _IO_file_sync_mmap (_IO_FILE *fp)
 }
 
 
-_IO_off64_t
-_IO_new_file_seekoff (fp, offset, dir, mode)
-     _IO_FILE *fp;
-     _IO_off64_t offset;
-     int dir;
-     int mode;
+_IO_off64_t _IO_new_file_seekoff (fp, offset, dir, mode)
+_IO_FILE * fp;
+_IO_off64_t offset;
+int dir;
+int mode;
 {
   _IO_off64_t result;
   _IO_off64_t delta, new_offset;
@@ -949,7 +942,7 @@ _IO_new_file_seekoff (fp, offset, dir, mode)
 		      || _IO_in_put_mode (fp));
 
   if (mode == 0)
-    dir = _IO_seek_cur, offset = 0; /* Don't move any pointers. */
+    dir = _IO_seek_cur, offset = 0;  /* Don't move any pointers. */
 
   /* Flush unwritten characters.
      (This may do an unneeded write if we seek within the buffer.
@@ -981,13 +974,11 @@ _IO_new_file_seekoff (fp, offset, dir, mode)
       if (mode != 0 || !was_writing)
 	offset -= fp->_IO_read_end - fp->_IO_read_ptr;
       else
-	{
-	  /* _IO_read_end coincides with fp._offset, so the actual file position
-	     is fp._offset - (_IO_read_end - new_write_ptr).  This is fine
-	     even if fp._offset is not set, since fp->_IO_read_end is then at
-	     _IO_buf_base and this adjustment is for unbuffered output.  */
-	  offset -= fp->_IO_read_end - fp->_IO_write_ptr;
-	}
+	/* _IO_read_end coincides with fp._offset, so the actual file position
+	   is fp._offset - (_IO_read_end - new_write_ptr).  This is fine
+	   even if fp._offset is not set, since fp->_IO_read_end is then at
+	   _IO_buf_base and this adjustment is for unbuffered output.  */
+	offset -= fp->_IO_read_end - fp->_IO_write_ptr;
 
       if (fp->_offset == _IO_pos_BAD)
 	{
@@ -1015,16 +1006,16 @@ _IO_new_file_seekoff (fp, offset, dir, mode)
     case _IO_seek_set:
       break;
     case _IO_seek_end:
-      {
-	struct stat64 st;
-	if (_IO_SYSSTAT (fp, &st) == 0 && S_ISREG (st.st_mode))
-	  {
-	    offset += st.st_size;
-	    dir = _IO_seek_set;
-	  }
-	else
-	  goto dumb;
-      }
+    {
+      struct stat64 st;
+      if (_IO_SYSSTAT (fp, &st) == 0 && S_ISREG (st.st_mode))
+	{
+	  offset += st.st_size;
+	  dir = _IO_seek_set;
+	}
+      else
+	goto dumb;
+    }
     }
   /* At this point, dir==_IO_seek_set. */
 
@@ -1074,7 +1065,7 @@ _IO_new_file_seekoff (fp, offset, dir, mode)
       if (count < delta)
 	{
 	  /* We weren't allowed to read, but try to seek the remainder. */
-	  offset = count == EOF ? delta : delta-count;
+	  offset = count == EOF ? delta : delta - count;
 	  dir = _IO_seek_cur;
 	  goto dumb;
 	}
@@ -1085,7 +1076,7 @@ _IO_new_file_seekoff (fp, offset, dir, mode)
   fp->_offset = result + count;
   _IO_mask_flags (fp, 0, _IO_EOF_SEEN);
   return offset;
- dumb:
+dumb:
 
   _IO_unsave_markers (fp);
   result = _IO_SYSSEEK (fp, offset, dir);
@@ -1110,12 +1101,11 @@ resync:
 }
 libc_hidden_ver (_IO_new_file_seekoff, _IO_file_seekoff)
 
-_IO_off64_t
-_IO_file_seekoff_mmap (fp, offset, dir, mode)
-     _IO_FILE *fp;
-     _IO_off64_t offset;
-     int dir;
-     int mode;
+_IO_off64_t _IO_file_seekoff_mmap (fp, offset, dir, mode)
+_IO_FILE * fp;
+_IO_off64_t offset;
+int dir;
+int mode;
 {
   _IO_off64_t result;
 
@@ -1185,11 +1175,10 @@ _IO_file_seekoff_maybe_mmap (_IO_FILE *fp, _IO_off64_t offset, int dir,
   return result;
 }
 
-_IO_ssize_t
-_IO_file_read (fp, buf, size)
-     _IO_FILE *fp;
-     void *buf;
-     _IO_ssize_t size;
+_IO_ssize_t _IO_file_read (fp, buf, size)
+_IO_FILE * fp;
+void *buf;
+_IO_ssize_t size;
 {
   return (__builtin_expect (fp->_flags2 & _IO_FLAGS2_NOTCANCEL, 0)
 	  ? read_not_cancel (fp->_fileno, buf, size)
@@ -1197,28 +1186,25 @@ _IO_file_read (fp, buf, size)
 }
 libc_hidden_def (_IO_file_read)
 
-_IO_off64_t
-_IO_file_seek (fp, offset, dir)
-     _IO_FILE *fp;
-     _IO_off64_t offset;
-     int dir;
+_IO_off64_t _IO_file_seek (fp, offset, dir)
+_IO_FILE * fp;
+_IO_off64_t offset;
+int dir;
 {
   return __lseek64 (fp->_fileno, offset, dir);
 }
 libc_hidden_def (_IO_file_seek)
 
-int
-_IO_file_stat (fp, st)
-     _IO_FILE *fp;
-     void *st;
+int _IO_file_stat (fp, st)
+_IO_FILE * fp;
+void *st;
 {
   return __fxstat64 (_STAT_VER, fp->_fileno, (struct stat64 *) st);
 }
 libc_hidden_def (_IO_file_stat)
 
-int
-_IO_file_close_mmap (fp)
-     _IO_FILE *fp;
+int _IO_file_close_mmap (fp)
+_IO_FILE * fp;
 {
   /* In addition to closing the file descriptor we have to unmap the file.  */
   (void) __munmap (fp->_IO_buf_base, fp->_IO_buf_end - fp->_IO_buf_base);
@@ -1228,9 +1214,8 @@ _IO_file_close_mmap (fp)
   return close_not_cancel (fp->_fileno);
 }
 
-int
-_IO_file_close (fp)
-     _IO_FILE *fp;
+int _IO_file_close (fp)
+_IO_FILE * fp;
 {
   /* Cancelling close should be avoided if possible since it leaves an
      unrecoverable state behind.  */
@@ -1238,11 +1223,10 @@ _IO_file_close (fp)
 }
 libc_hidden_def (_IO_file_close)
 
-_IO_ssize_t
-_IO_new_file_write (f, data, n)
-     _IO_FILE *f;
-     const void *data;
-     _IO_ssize_t n;
+_IO_ssize_t _IO_new_file_write (f, data, n)
+_IO_FILE * f;
+const void *data;
+_IO_ssize_t n;
 {
   _IO_ssize_t to_do = n;
   _IO_ssize_t count = 0;
@@ -1266,11 +1250,10 @@ _IO_new_file_write (f, data, n)
   return count < 0 ? count : n;
 }
 
-_IO_size_t
-_IO_new_file_xsputn (f, data, n)
-     _IO_FILE *f;
-     const void *data;
-     _IO_size_t n;
+_IO_size_t _IO_new_file_xsputn (f, data, n)
+_IO_FILE * f;
+const void *data;
+_IO_size_t n;
 {
   register const char *s = (const char *) data;
   _IO_size_t to_do = n;
@@ -1291,18 +1274,16 @@ _IO_new_file_xsputn (f, data, n)
 	{
 	  register const char *p;
 	  for (p = s + n; p > s; )
-	    {
-	      if (*--p == '\n')
-		{
-		  count = p - s + 1;
-		  must_flush = 1;
-		  break;
-		}
-	    }
+	    if (*--p == '\n')
+	      {
+		count = p - s + 1;
+		must_flush = 1;
+		break;
+	      }
 	}
     }
   else if (f->_IO_write_end > f->_IO_write_ptr)
-    count = f->_IO_write_end - f->_IO_write_ptr; /* Space available. */
+    count = f->_IO_write_end - f->_IO_write_ptr;  /* Space available. */
 
   /* Then fill the buffer. */
   if (count > 0)
@@ -1345,17 +1326,16 @@ _IO_new_file_xsputn (f, data, n)
 	 buffer, but it's somewhat messier for line-buffered files,
 	 so we let _IO_default_xsputn handle the general case. */
       if (to_do)
-	to_do -= _IO_default_xsputn (f, s+do_write, to_do);
+	to_do -= _IO_default_xsputn (f, s + do_write, to_do);
     }
   return n - to_do;
 }
 libc_hidden_ver (_IO_new_file_xsputn, _IO_file_xsputn)
 
-_IO_size_t
-_IO_file_xsgetn (fp, data, n)
-     _IO_FILE *fp;
-     void *data;
-     _IO_size_t n;
+_IO_size_t _IO_file_xsgetn (fp, data, n)
+_IO_FILE * fp;
+void *data;
+_IO_size_t n;
 {
   register _IO_size_t want, have;
   register _IO_ssize_t count;
@@ -1453,11 +1433,10 @@ _IO_file_xsgetn (fp, data, n)
 libc_hidden_def (_IO_file_xsgetn)
 
 static _IO_size_t _IO_file_xsgetn_mmap (_IO_FILE *, void *, _IO_size_t);
-static _IO_size_t
-_IO_file_xsgetn_mmap (fp, data, n)
-     _IO_FILE *fp;
-     void *data;
-     _IO_size_t n;
+static _IO_size_t _IO_file_xsgetn_mmap (fp, data, n)
+_IO_FILE * fp;
+void *data;
+_IO_size_t n;
 {
   register _IO_size_t have;
   char *read_ptr = fp->_IO_read_ptr;
@@ -1512,11 +1491,10 @@ _IO_file_xsgetn_mmap (fp, data, n)
 }
 
 static _IO_size_t _IO_file_xsgetn_maybe_mmap (_IO_FILE *, void *, _IO_size_t);
-static _IO_size_t
-_IO_file_xsgetn_maybe_mmap (fp, data, n)
-     _IO_FILE *fp;
-     void *data;
-     _IO_size_t n;
+static _IO_size_t _IO_file_xsgetn_maybe_mmap (fp, data, n)
+_IO_FILE * fp;
+void *data;
+_IO_size_t n;
 {
   /* We only get here if this is the first attempt to read something.
      Decide which operations to use and then punt to the chosen one.  */
@@ -1544,72 +1522,72 @@ versioned_symbol (libc, _IO_new_file_xsputn, _IO_file_xsputn, GLIBC_2_1);
 const struct _IO_jump_t _IO_file_jumps =
 {
   JUMP_INIT_DUMMY,
-  JUMP_INIT(finish, _IO_file_finish),
-  JUMP_INIT(overflow, _IO_file_overflow),
-  JUMP_INIT(underflow, _IO_file_underflow),
-  JUMP_INIT(uflow, _IO_default_uflow),
-  JUMP_INIT(pbackfail, _IO_default_pbackfail),
-  JUMP_INIT(xsputn, _IO_file_xsputn),
-  JUMP_INIT(xsgetn, _IO_file_xsgetn),
-  JUMP_INIT(seekoff, _IO_new_file_seekoff),
-  JUMP_INIT(seekpos, _IO_default_seekpos),
-  JUMP_INIT(setbuf, _IO_new_file_setbuf),
-  JUMP_INIT(sync, _IO_new_file_sync),
-  JUMP_INIT(doallocate, _IO_file_doallocate),
-  JUMP_INIT(read, _IO_file_read),
-  JUMP_INIT(write, _IO_new_file_write),
-  JUMP_INIT(seek, _IO_file_seek),
-  JUMP_INIT(close, _IO_file_close),
-  JUMP_INIT(stat, _IO_file_stat),
-  JUMP_INIT(showmanyc, _IO_default_showmanyc),
-  JUMP_INIT(imbue, _IO_default_imbue)
+  JUMP_INIT (finish, _IO_file_finish),
+  JUMP_INIT (overflow, _IO_file_overflow),
+  JUMP_INIT (underflow, _IO_file_underflow),
+  JUMP_INIT (uflow, _IO_default_uflow),
+  JUMP_INIT (pbackfail, _IO_default_pbackfail),
+  JUMP_INIT (xsputn, _IO_file_xsputn),
+  JUMP_INIT (xsgetn, _IO_file_xsgetn),
+  JUMP_INIT (seekoff, _IO_new_file_seekoff),
+  JUMP_INIT (seekpos, _IO_default_seekpos),
+  JUMP_INIT (setbuf, _IO_new_file_setbuf),
+  JUMP_INIT (sync, _IO_new_file_sync),
+  JUMP_INIT (doallocate, _IO_file_doallocate),
+  JUMP_INIT (read, _IO_file_read),
+  JUMP_INIT (write, _IO_new_file_write),
+  JUMP_INIT (seek, _IO_file_seek),
+  JUMP_INIT (close, _IO_file_close),
+  JUMP_INIT (stat, _IO_file_stat),
+  JUMP_INIT (showmanyc, _IO_default_showmanyc),
+  JUMP_INIT (imbue, _IO_default_imbue)
 };
 libc_hidden_data_def (_IO_file_jumps)
 
 const struct _IO_jump_t _IO_file_jumps_mmap =
 {
   JUMP_INIT_DUMMY,
-  JUMP_INIT(finish, _IO_file_finish),
-  JUMP_INIT(overflow, _IO_file_overflow),
-  JUMP_INIT(underflow, _IO_file_underflow_mmap),
-  JUMP_INIT(uflow, _IO_default_uflow),
-  JUMP_INIT(pbackfail, _IO_default_pbackfail),
-  JUMP_INIT(xsputn, _IO_new_file_xsputn),
-  JUMP_INIT(xsgetn, _IO_file_xsgetn_mmap),
-  JUMP_INIT(seekoff, _IO_file_seekoff_mmap),
-  JUMP_INIT(seekpos, _IO_default_seekpos),
-  JUMP_INIT(setbuf, (_IO_setbuf_t) _IO_file_setbuf_mmap),
-  JUMP_INIT(sync, _IO_file_sync_mmap),
-  JUMP_INIT(doallocate, _IO_file_doallocate),
-  JUMP_INIT(read, _IO_file_read),
-  JUMP_INIT(write, _IO_new_file_write),
-  JUMP_INIT(seek, _IO_file_seek),
-  JUMP_INIT(close, _IO_file_close_mmap),
-  JUMP_INIT(stat, _IO_file_stat),
-  JUMP_INIT(showmanyc, _IO_default_showmanyc),
-  JUMP_INIT(imbue, _IO_default_imbue)
+  JUMP_INIT (finish, _IO_file_finish),
+  JUMP_INIT (overflow, _IO_file_overflow),
+  JUMP_INIT (underflow, _IO_file_underflow_mmap),
+  JUMP_INIT (uflow, _IO_default_uflow),
+  JUMP_INIT (pbackfail, _IO_default_pbackfail),
+  JUMP_INIT (xsputn, _IO_new_file_xsputn),
+  JUMP_INIT (xsgetn, _IO_file_xsgetn_mmap),
+  JUMP_INIT (seekoff, _IO_file_seekoff_mmap),
+  JUMP_INIT (seekpos, _IO_default_seekpos),
+  JUMP_INIT (setbuf, (_IO_setbuf_t) _IO_file_setbuf_mmap),
+  JUMP_INIT (sync, _IO_file_sync_mmap),
+  JUMP_INIT (doallocate, _IO_file_doallocate),
+  JUMP_INIT (read, _IO_file_read),
+  JUMP_INIT (write, _IO_new_file_write),
+  JUMP_INIT (seek, _IO_file_seek),
+  JUMP_INIT (close, _IO_file_close_mmap),
+  JUMP_INIT (stat, _IO_file_stat),
+  JUMP_INIT (showmanyc, _IO_default_showmanyc),
+  JUMP_INIT (imbue, _IO_default_imbue)
 };
 
 const struct _IO_jump_t _IO_file_jumps_maybe_mmap =
 {
   JUMP_INIT_DUMMY,
-  JUMP_INIT(finish, _IO_file_finish),
-  JUMP_INIT(overflow, _IO_file_overflow),
-  JUMP_INIT(underflow, _IO_file_underflow_maybe_mmap),
-  JUMP_INIT(uflow, _IO_default_uflow),
-  JUMP_INIT(pbackfail, _IO_default_pbackfail),
-  JUMP_INIT(xsputn, _IO_new_file_xsputn),
-  JUMP_INIT(xsgetn, _IO_file_xsgetn_maybe_mmap),
-  JUMP_INIT(seekoff, _IO_file_seekoff_maybe_mmap),
-  JUMP_INIT(seekpos, _IO_default_seekpos),
-  JUMP_INIT(setbuf, (_IO_setbuf_t) _IO_file_setbuf_mmap),
-  JUMP_INIT(sync, _IO_new_file_sync),
-  JUMP_INIT(doallocate, _IO_file_doallocate),
-  JUMP_INIT(read, _IO_file_read),
-  JUMP_INIT(write, _IO_new_file_write),
-  JUMP_INIT(seek, _IO_file_seek),
-  JUMP_INIT(close, _IO_file_close),
-  JUMP_INIT(stat, _IO_file_stat),
-  JUMP_INIT(showmanyc, _IO_default_showmanyc),
-  JUMP_INIT(imbue, _IO_default_imbue)
+  JUMP_INIT (finish, _IO_file_finish),
+  JUMP_INIT (overflow, _IO_file_overflow),
+  JUMP_INIT (underflow, _IO_file_underflow_maybe_mmap),
+  JUMP_INIT (uflow, _IO_default_uflow),
+  JUMP_INIT (pbackfail, _IO_default_pbackfail),
+  JUMP_INIT (xsputn, _IO_new_file_xsputn),
+  JUMP_INIT (xsgetn, _IO_file_xsgetn_maybe_mmap),
+  JUMP_INIT (seekoff, _IO_file_seekoff_maybe_mmap),
+  JUMP_INIT (seekpos, _IO_default_seekpos),
+  JUMP_INIT (setbuf, (_IO_setbuf_t) _IO_file_setbuf_mmap),
+  JUMP_INIT (sync, _IO_new_file_sync),
+  JUMP_INIT (doallocate, _IO_file_doallocate),
+  JUMP_INIT (read, _IO_file_read),
+  JUMP_INIT (write, _IO_new_file_write),
+  JUMP_INIT (seek, _IO_file_seek),
+  JUMP_INIT (close, _IO_file_close),
+  JUMP_INIT (stat, _IO_file_stat),
+  JUMP_INIT (showmanyc, _IO_default_showmanyc),
+  JUMP_INIT (imbue, _IO_default_imbue)
 };
diff --git a/libio/iofdopen.c b/libio/iofdopen.c
index a65a5a6..72b0f58 100644
--- a/libio/iofdopen.c
+++ b/libio/iofdopen.c
@@ -33,17 +33,16 @@
 #endif
 
 #ifndef _IO_fcntl
-#ifdef _LIBC
-#define _IO_fcntl __fcntl
-#else
-#define _IO_fcntl fcntl
-#endif
+# ifdef _LIBC
+#  define _IO_fcntl __fcntl
+# else
+#  define _IO_fcntl fcntl
+# endif
 #endif
 
-_IO_FILE *
-_IO_new_fdopen (fd, mode)
-     int fd;
-     const char *mode;
+_IO_FILE *_IO_new_fdopen (fd, mode)
+int fd;
+const char *mode;
 {
   int read_write;
   int posix_mode = 0;
@@ -69,12 +68,12 @@ _IO_new_fdopen (fd, mode)
       break;
     case 'a':
       posix_mode = O_APPEND;
-      read_write = _IO_NO_READS|_IO_IS_APPENDING;
+      read_write = _IO_NO_READS | _IO_IS_APPENDING;
       break;
     default:
       MAYBE_SET_EINVAL;
       return NULL;
-  }
+    }
   for (i = 1; i < 5; ++i)
     {
       switch (*++mode)
@@ -97,9 +96,9 @@ _IO_new_fdopen (fd, mode)
     }
 #ifdef F_GETFL
   fd_flags = _IO_fcntl (fd, F_GETFL);
-#ifndef O_ACCMODE
-#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
-#endif
+# ifndef O_ACCMODE
+#  define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
+# endif
   if (fd_flags == -1)
     return NULL;
 
@@ -115,9 +114,9 @@ _IO_new_fdopen (fd, mode)
      Realtime Extensions], Rationale B.8.3.3
      Open a Stream on a File Descriptor says:
 
-         Although not explicitly required by POSIX.1, a good
-         implementation of append ("a") mode would cause the
-         O_APPEND flag to be set.
+	 Although not explicitly required by POSIX.1, a good
+	 implementation of append ("a") mode would cause the
+	 O_APPEND flag to be set.
 
      (Historical implementations [such as Solaris2] do a one-time
      seek in fdopen.)
@@ -125,13 +124,13 @@ _IO_new_fdopen (fd, mode)
      However, we do not turn O_APPEND off if the mode is "w" (even
      though that would seem consistent) because that would be more
      likely to break historical programs.
-     */
+   */
   if ((posix_mode & O_APPEND) && !(fd_flags & O_APPEND))
     {
-#ifdef F_SETFL
+# ifdef F_SETFL
       if (_IO_fcntl (fd, F_SETFL, fd_flags | O_APPEND) == -1)
-#endif
-	return NULL;
+# endif
+      return NULL;
     }
 #endif
 
@@ -154,7 +153,7 @@ _IO_new_fdopen (fd, mode)
 #ifdef _G_HAVE_MMAP
     (use_mmap && (read_write & _IO_NO_WRITES)) ? &_IO_file_jumps_maybe_mmap :
 #endif
-      &_IO_file_jumps;
+    &_IO_file_jumps;
   _IO_file_init (&new_f->fp);
 #if  !_IO_UNIFIED_JUMPTABLES
   new_f->fp.vtable = NULL;
@@ -169,7 +168,7 @@ _IO_new_fdopen (fd, mode)
   new_f->fp.file._flags &= ~_IO_DELETE_DONT_CLOSE;
 
   _IO_mask_flags (&new_f->fp.file, read_write,
-		  _IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING);
+		  _IO_NO_READS + _IO_NO_WRITES + _IO_IS_APPENDING);
 
   return &new_f->fp.file;
 }
diff --git a/libio/iofopen.c b/libio/iofopen.c
index 5a859c6..776012e 100644
--- a/libio/iofopen.c
+++ b/libio/iofopen.c
@@ -34,9 +34,8 @@
 # define _IO_new_fopen fopen
 #endif
 
-_IO_FILE *
-__fopen_maybe_mmap (fp)
-     _IO_FILE *fp;
+_IO_FILE *__fopen_maybe_mmap (fp)
+_IO_FILE * fp;
 {
 #ifdef _G_HAVE_MMAP
   if ((fp->_flags2 & _IO_FLAGS2_MMAP) && (fp->_flags & _IO_NO_WRITES))
@@ -57,11 +56,10 @@ __fopen_maybe_mmap (fp)
 }
 
 
-_IO_FILE *
-__fopen_internal (filename, mode, is32)
-     const char *filename;
-     const char *mode;
-     int is32;
+_IO_FILE *__fopen_internal (filename, mode, is32)
+const char *filename;
+const char *mode;
+int is32;
 {
   struct locked_FILE
   {
@@ -95,10 +93,9 @@ __fopen_internal (filename, mode, is32)
   return NULL;
 }
 
-_IO_FILE *
-_IO_new_fopen (filename, mode)
-     const char *filename;
-     const char *mode;
+_IO_FILE *_IO_new_fopen (filename, mode)
+const char *filename;
+const char *mode;
 {
   return __fopen_internal (filename, mode, 1);
 }
-- 
1.7.10.4


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