This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 1/6] Reformat libio files
- From: Ondrej Bilka <neleai at seznam dot cz>
- To: libc-alpha at sourceware dot org
- Cc: Ondrej Bilka <neleai at seznam dot cz>
- Date: Sat, 1 Jun 2013 17:11:23 +0200
- Subject: [PATCH 1/6] Reformat libio files
- References: <1370099488-13916-1-git-send-email-neleai at seznam dot cz>
This prelimitary patch does consistent formating of files that I will change.
Most changes are according to style and it should be relatively uncontroversional.
The formatter applied is kam.mff.cuni.cz/~ondra/spatch.tar.bz2
* libio/fileops.c: Reformat.
* libio/fmemopen.c: Likewise.
* libio/iofdopen.c: Likewise.
* libio/iofopen.c: Likewise.
---
libio/fileops.c | 1155 +++++++++++++++++++++++++++---------------------------
libio/fmemopen.c | 36 +-
libio/iofdopen.c | 72 ++--
libio/iofopen.c | 22 +-
4 files changed, 643 insertions(+), 642 deletions(-)
diff --git a/libio/fileops.c b/libio/fileops.c
index 61b61b3..2931e2f 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -130,15 +130,15 @@ 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)
+ (_IO_IS_FILEBUF + _IO_NO_READS + _IO_NO_WRITES + _IO_TIED_PUT_GET)
void
_IO_new_file_init (fp)
- struct _IO_FILE_plus *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
@@ -153,7 +153,7 @@ libc_hidden_ver (_IO_new_file_init, _IO_file_init)
int
_IO_new_file_close_it (fp)
- _IO_FILE *fp;
+_IO_FILE * fp;
{
int write_status;
if (!_IO_file_is_open (fp))
@@ -168,14 +168,14 @@ _IO_new_file_close_it (fp)
_IO_unsave_markers (fp);
int close_status = ((fp->_flags2 & _IO_FLAGS2_NOCLOSE) == 0
- ? _IO_SYSCLOSE (fp) : 0);
+ ? _IO_SYSCLOSE (fp) : 0);
/* Free buffer. */
#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
if (fp->_mode > 0)
{
if (_IO_have_wbackup (fp))
- _IO_free_wbackup_area (fp);
+ _IO_free_wbackup_area (fp);
_IO_wsetb (fp, NULL, NULL, 0);
_IO_wsetg (fp, NULL, NULL, NULL);
_IO_wsetp (fp, NULL, NULL);
@@ -186,7 +186,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;
@@ -196,14 +196,14 @@ libc_hidden_ver (_IO_new_file_close_it, _IO_file_close_it)
void
_IO_new_file_finish (fp, dummy)
- _IO_FILE *fp;
- int dummy;
+_IO_FILE * fp;
+int dummy;
{
if (_IO_file_is_open (fp))
{
_IO_do_flush (fp);
if (!(fp->_flags & _IO_DELETE_DONT_CLOSE))
- _IO_SYSCLOSE (fp);
+ _IO_SYSCLOSE (fp);
}
_IO_default_finish (fp, 0);
}
@@ -211,18 +211,18 @@ 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
if (__builtin_expect (fp->_flags2 & _IO_FLAGS2_NOTCANCEL, 0))
fdesc = open_not_cancel (filename,
- posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
+ posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
else
fdesc = open (filename, posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
#else
@@ -231,13 +231,15 @@ _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)
- == _IO_pos_BAD && errno != ESPIPE)
+ if (_IO_SEEKOFF (fp, (_IO_off64_t) 0, _IO_seek_end, _IOS_INPUT |
+ _IOS_OUTPUT)
+ == _IO_pos_BAD && errno != ESPIPE)
{
- close_not_cancel (fdesc);
- return NULL;
+ close_not_cancel (fdesc);
+ return NULL;
}
_IO_link_in ((struct _IO_FILE_plus *) fp);
return fp;
@@ -246,10 +248,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 +273,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);
@@ -289,134 +291,134 @@ _IO_new_file_fopen (fp, filename, mode, is32not64)
for (i = 1; i < 7; ++i)
{
switch (*++mode)
- {
- case '\0':
- break;
- case '+':
- omode = O_RDWR;
- read_write &= _IO_IS_APPENDING;
+ {
+ case '\0':
+ break;
+ case '+':
+ omode = O_RDWR;
+ read_write &= _IO_IS_APPENDING;
#ifdef _LIBC
- last_recognized = mode;
+ last_recognized = mode;
#endif
- continue;
- case 'x':
- oflags |= O_EXCL;
+ continue;
+ case 'x':
+ oflags |= O_EXCL;
#ifdef _LIBC
- last_recognized = mode;
+ last_recognized = mode;
#endif
- continue;
- case 'b':
+ continue;
+ case 'b':
#ifdef _LIBC
- last_recognized = mode;
+ last_recognized = mode;
#endif
- continue;
- case 'm':
- fp->_flags2 |= _IO_FLAGS2_MMAP;
- continue;
- case 'c':
- fp->_flags2 |= _IO_FLAGS2_NOTCANCEL;
- continue;
- case 'e':
+ continue;
+ case 'm':
+ fp->_flags2 |= _IO_FLAGS2_MMAP;
+ continue;
+ case 'c':
+ fp->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+ continue;
+ case 'e':
#ifdef O_CLOEXEC
- oflags |= O_CLOEXEC;
+ oflags |= O_CLOEXEC;
#endif
- fp->_flags2 |= _IO_FLAGS2_CLOEXEC;
- continue;
- default:
- /* Ignore. */
- continue;
- }
+ fp->_flags2 |= _IO_FLAGS2_CLOEXEC;
+ continue;
+ default:
+ /* Ignore. */
+ continue;
+ }
break;
}
- result = _IO_file_open (fp, filename, omode|oflags, oprot, read_write,
- is32not64);
+ result = _IO_file_open (fp, filename, omode | oflags, oprot, read_write,
+ is32not64);
if (result != NULL)
{
#ifndef __ASSUME_O_CLOEXEC
if ((fp->_flags2 & _IO_FLAGS2_CLOEXEC) != 0 && __have_o_cloexec <= 0)
- {
- int fd = _IO_fileno (fp);
- if (__have_o_cloexec == 0)
- {
- int flags = __fcntl (fd, F_GETFD);
- __have_o_cloexec = (flags & FD_CLOEXEC) == 0 ? -1 : 1;
- }
- if (__have_o_cloexec < 0)
- __fcntl (fd, F_SETFD, FD_CLOEXEC);
- }
+ {
+ int fd = _IO_fileno (fp);
+ if (__have_o_cloexec == 0)
+ {
+ int flags = __fcntl (fd, F_GETFD);
+ __have_o_cloexec = (flags & FD_CLOEXEC) == 0 ? -1 : 1;
+ }
+ if (__have_o_cloexec < 0)
+ __fcntl (fd, F_SETFD, FD_CLOEXEC);
+ }
#endif
/* Test whether the mode string specifies the conversion. */
cs = strstr (last_recognized + 1, ",ccs=");
if (cs != NULL)
- {
- /* Yep. Load the appropriate conversions and set the orientation
- to wide. */
- struct gconv_fcts fcts;
- struct _IO_codecvt *cc;
- char *endp = __strchrnul (cs + 5, ',');
- char ccs[endp - (cs + 5) + 3];
-
- *((char *) __mempcpy (ccs, cs + 5, endp - (cs + 5))) = '\0';
- strip (ccs, ccs);
-
- if (__wcsmbs_named_conv (&fcts, ccs[2] == '\0'
- ? upstr (ccs, cs + 5) : ccs) != 0)
- {
- /* Something went wrong, we cannot load the conversion modules.
- This means we cannot proceed since the user explicitly asked
- for these. */
- (void) _IO_file_close_it (fp);
- __set_errno (EINVAL);
- return NULL;
- }
-
- assert (fcts.towc_nsteps == 1);
- assert (fcts.tomb_nsteps == 1);
-
- fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_end;
- fp->_wide_data->_IO_write_ptr = fp->_wide_data->_IO_write_base;
-
- /* Clear the state. We start all over again. */
- memset (&fp->_wide_data->_IO_state, '\0', sizeof (__mbstate_t));
- memset (&fp->_wide_data->_IO_last_state, '\0', sizeof (__mbstate_t));
-
- cc = fp->_codecvt = &fp->_wide_data->_codecvt;
-
- /* The functions are always the same. */
- *cc = __libio_codecvt;
-
- cc->__cd_in.__cd.__nsteps = fcts.towc_nsteps;
- cc->__cd_in.__cd.__steps = fcts.towc;
-
- cc->__cd_in.__cd.__data[0].__invocation_counter = 0;
- cc->__cd_in.__cd.__data[0].__internal_use = 1;
- cc->__cd_in.__cd.__data[0].__flags = __GCONV_IS_LAST;
- cc->__cd_in.__cd.__data[0].__statep = &result->_wide_data->_IO_state;
-
- /* XXX For now no transliteration. */
- cc->__cd_in.__cd.__data[0].__trans = NULL;
-
- cc->__cd_out.__cd.__nsteps = fcts.tomb_nsteps;
- cc->__cd_out.__cd.__steps = fcts.tomb;
-
- cc->__cd_out.__cd.__data[0].__invocation_counter = 0;
- cc->__cd_out.__cd.__data[0].__internal_use = 1;
- cc->__cd_out.__cd.__data[0].__flags = __GCONV_IS_LAST;
- cc->__cd_out.__cd.__data[0].__statep =
- &result->_wide_data->_IO_state;
-
- /* And now the transliteration. */
- cc->__cd_out.__cd.__data[0].__trans = &__libio_translit;
-
- /* From now on use the wide character callback functions. */
- ((struct _IO_FILE_plus *) fp)->vtable = fp->_wide_data->_wide_vtable;
-
- /* Set the mode now. */
- result->_mode = 1;
- }
+ {
+ /* Yep. Load the appropriate conversions and set the orientation
+ to wide. */
+ struct gconv_fcts fcts;
+ struct _IO_codecvt *cc;
+ char *endp = __strchrnul (cs + 5, ',');
+ char ccs[endp - (cs + 5) + 3];
+
+ *((char *) __mempcpy (ccs, cs + 5, endp - (cs + 5))) = '\0';
+ strip (ccs, ccs);
+
+ if (__wcsmbs_named_conv (&fcts, ccs[2] == '\0'
+ ? upstr (ccs, cs + 5) : ccs) != 0)
+ {
+ /* Something went wrong, we cannot load the conversion modules.
+ This means we cannot proceed since the user explicitly asked
+ for these. */
+ (void) _IO_file_close_it (fp);
+ __set_errno (EINVAL);
+ return NULL;
+ }
+
+ assert (fcts.towc_nsteps == 1);
+ assert (fcts.tomb_nsteps == 1);
+
+ fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_end;
+ fp->_wide_data->_IO_write_ptr = fp->_wide_data->_IO_write_base;
+
+ /* Clear the state. We start all over again. */
+ memset (&fp->_wide_data->_IO_state, '\0', sizeof (__mbstate_t));
+ memset (&fp->_wide_data->_IO_last_state, '\0', sizeof (__mbstate_t));
+
+ cc = fp->_codecvt = &fp->_wide_data->_codecvt;
+
+ /* The functions are always the same. */
+ *cc = __libio_codecvt;
+
+ cc->__cd_in.__cd.__nsteps = fcts.towc_nsteps;
+ cc->__cd_in.__cd.__steps = fcts.towc;
+
+ cc->__cd_in.__cd.__data[0].__invocation_counter = 0;
+ cc->__cd_in.__cd.__data[0].__internal_use = 1;
+ cc->__cd_in.__cd.__data[0].__flags = __GCONV_IS_LAST;
+ cc->__cd_in.__cd.__data[0].__statep = &result->_wide_data->_IO_state;
+
+ /* XXX For now no transliteration. */
+ cc->__cd_in.__cd.__data[0].__trans = NULL;
+
+ cc->__cd_out.__cd.__nsteps = fcts.tomb_nsteps;
+ cc->__cd_out.__cd.__steps = fcts.tomb;
+
+ cc->__cd_out.__cd.__data[0].__invocation_counter = 0;
+ cc->__cd_out.__cd.__data[0].__internal_use = 1;
+ cc->__cd_out.__cd.__data[0].__flags = __GCONV_IS_LAST;
+ cc->__cd_out.__cd.__data[0].__statep =
+ &result->_wide_data->_IO_state;
+
+ /* And now the transliteration. */
+ cc->__cd_out.__cd.__data[0].__trans = &__libio_translit;
+
+ /* From now on use the wide character callback functions. */
+ ((struct _IO_FILE_plus *) fp)->vtable = fp->_wide_data->_wide_vtable;
+
+ /* Set the mode now. */
+ result->_mode = 1;
+ }
}
return result;
@@ -425,19 +427,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 +449,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 +467,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;
@@ -488,28 +490,29 @@ _IO_file_setbuf_mmap (fp, p, len)
return result;
}
-static _IO_size_t new_do_write (_IO_FILE *, const char *, _IO_size_t);
+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;
+_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;
+ || (_IO_size_t) new_do_write (fp, data, to_do) == to_do) ? 0 : EOF;
}
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_FILE * fp;
+const char *data;
+_IO_size_t to_do;
{
_IO_size_t count;
if (fp->_flags & _IO_IS_APPENDING)
@@ -522,9 +525,9 @@ new_do_write (fp, data, to_do)
else if (fp->_IO_read_end != fp->_IO_write_base)
{
_IO_off64_t new_pos
- = _IO_SYSSEEK (fp, fp->_IO_write_base - fp->_IO_read_end, 1);
+ = _IO_SYSSEEK (fp, fp->_IO_write_base - fp->_IO_read_end, 1);
if (new_pos == _IO_pos_BAD)
- return 0;
+ return 0;
fp->_offset = new_pos;
}
count = _IO_SYSWRITE (fp, data, to_do);
@@ -533,14 +536,14 @@ 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->_IO_buf_base : fp->_IO_buf_end);
+ && (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;
+_IO_FILE * fp;
{
_IO_ssize_t count;
#if 0
@@ -562,30 +565,30 @@ _IO_new_file_underflow (fp)
{
/* Maybe we already have a push back pointer. */
if (fp->_IO_save_base != NULL)
- {
- free (fp->_IO_save_base);
- fp->_flags &= ~_IO_IN_BACKUP;
- }
+ {
+ free (fp->_IO_save_base);
+ fp->_flags &= ~_IO_IN_BACKUP;
+ }
_IO_doallocbuf (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 ();
#else
/* We used to flush all line-buffered stream. This really isn't
- required by any standard. My recollection is that
- traditional Unix systems did this for stdout. stderr better
- not be line buffered. So we do just that here
- explicitly. --drepper */
+ required by any standard. My recollection is that
+ traditional Unix systems did this for stdout. stderr better
+ not be line buffered. So we do just that here
+ explicitly. --drepper */
_IO_acquire_lock (_IO_stdout);
if ((_IO_stdout->_flags & (_IO_LINKED | _IO_NO_WRITES | _IO_LINE_BUF))
- == (_IO_LINKED | _IO_LINE_BUF))
- _IO_OVERFLOW (_IO_stdout, EOF);
+ == (_IO_LINKED | _IO_LINE_BUF))
+ _IO_OVERFLOW (_IO_stdout, EOF);
_IO_release_lock (_IO_stdout);
#endif
@@ -600,17 +603,17 @@ _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);
+ fp->_IO_buf_end - fp->_IO_buf_base);
if (count <= 0)
{
if (count == 0)
- fp->_flags |= _IO_EOF_SEEN;
+ fp->_flags |= _IO_EOF_SEEN;
else
- fp->_flags |= _IO_ERR_SEEN, count = 0;
- }
+ fp->_flags |= _IO_ERR_SEEN, count = 0;
+ }
fp->_IO_read_end += count;
if (count == 0)
return EOF;
@@ -632,72 +635,71 @@ 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))
- {
- /* We can trim off some pages past the end of the file. */
- (void) __munmap (fp->_IO_buf_base + ROUNDED (st.st_size),
- ROUNDED (fp->_IO_buf_end - fp->_IO_buf_base)
- - ROUNDED (st.st_size));
- fp->_IO_buf_end = fp->_IO_buf_base + st.st_size;
- }
+ - fp->_IO_buf_base))
+ {
+ /* We can trim off some pages past the end of the file. */
+ (void) __munmap (fp->_IO_buf_base + ROUNDED (st.st_size),
+ ROUNDED (fp->_IO_buf_end - fp->_IO_buf_base)
+ - ROUNDED (st.st_size));
+ fp->_IO_buf_end = fp->_IO_buf_base + st.st_size;
+ }
else if (ROUNDED (st.st_size) > ROUNDED (fp->_IO_buf_end
- - fp->_IO_buf_base))
- {
- /* The file added some pages. We need to remap it. */
- void *p;
+ - fp->_IO_buf_base))
+ {
+ /* The file added some pages. We need to remap it. */
+ void *p;
#ifdef _G_HAVE_MREMAP
- p = __mremap (fp->_IO_buf_base, ROUNDED (fp->_IO_buf_end
- - fp->_IO_buf_base),
- ROUNDED (st.st_size), MREMAP_MAYMOVE);
- if (p == MAP_FAILED)
- {
- (void) __munmap (fp->_IO_buf_base,
- fp->_IO_buf_end - fp->_IO_buf_base);
- goto punt;
- }
+ p = __mremap (fp->_IO_buf_base, ROUNDED (fp->_IO_buf_end
+ - fp->_IO_buf_base),
+ ROUNDED (st.st_size), MREMAP_MAYMOVE);
+ if (p == MAP_FAILED)
+ {
+ (void) __munmap (fp->_IO_buf_base,
+ fp->_IO_buf_end - fp->_IO_buf_base);
+ goto punt;
+ }
#else
- (void) __munmap (fp->_IO_buf_base,
- fp->_IO_buf_end - fp->_IO_buf_base);
- p = __mmap64 (NULL, st.st_size, PROT_READ, MAP_SHARED,
- fp->_fileno, 0);
- if (p == MAP_FAILED)
- goto punt;
+ (void) __munmap (fp->_IO_buf_base,
+ fp->_IO_buf_end - fp->_IO_buf_base);
+ p = __mmap64 (NULL, st.st_size, PROT_READ, MAP_SHARED,
+ fp->_fileno, 0);
+ if (p == MAP_FAILED)
+ goto punt;
#endif
- fp->_IO_buf_base = p;
- fp->_IO_buf_end = fp->_IO_buf_base + st.st_size;
- }
+ fp->_IO_buf_base = p;
+ 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,
- fp->_offset < fp->_IO_buf_end - fp->_IO_buf_base
- ? fp->_IO_buf_base + fp->_offset : fp->_IO_buf_end,
- fp->_IO_buf_end);
+ fp->_offset < fp->_IO_buf_end - fp->_IO_buf_base
+ ? fp->_IO_buf_base + fp->_offset : fp->_IO_buf_end,
+ fp->_IO_buf_end);
/* If we are already positioned at or past the end of the file, don't
- change the current offset. If not, seek past what we have mapped,
- mimicking the position left by a normal underflow reading into its
- buffer until EOF. */
+ change the current offset. If not, seek past what we have mapped,
+ mimicking the position left by a normal underflow reading into its
+ buffer until EOF. */
if (fp->_offset < fp->_IO_buf_end - fp->_IO_buf_base)
- {
- if (__lseek64 (fp->_fileno, fp->_IO_buf_end - fp->_IO_buf_base,
- SEEK_SET)
- != fp->_IO_buf_end - fp->_IO_buf_base)
- fp->_flags |= _IO_ERR_SEEN;
- else
- fp->_offset = fp->_IO_buf_end - fp->_IO_buf_base;
- }
+ {
+ if (__lseek64 (fp->_fileno, fp->_IO_buf_end - fp->_IO_buf_base,
+ SEEK_SET)
+ != fp->_IO_buf_end - fp->_IO_buf_base)
+ fp->_flags |= _IO_ERR_SEEN;
+ else
+ fp->_offset = fp->_IO_buf_end - fp->_IO_buf_base;
+ }
return 0;
}
@@ -705,14 +707,14 @@ mmap_remap_check (_IO_FILE *fp)
{
/* Life is no longer good for mmap. Punt it. */
(void) __munmap (fp->_IO_buf_base,
- fp->_IO_buf_end - fp->_IO_buf_base);
- punt:
+ fp->_IO_buf_end - fp->_IO_buf_base);
+punt:
fp->_IO_buf_base = fp->_IO_buf_end = NULL;
_IO_setg (fp, NULL, NULL, NULL);
if (fp->_mode <= 0)
- _IO_JUMPS ((struct _IO_FILE_plus *) fp) = &_IO_file_jumps;
+ _IO_JUMPS ((struct _IO_FILE_plus *) fp) = &_IO_file_jumps;
else
- _IO_JUMPS ((struct _IO_FILE_plus *) fp) = &_IO_wfile_jumps;
+ _IO_JUMPS ((struct _IO_FILE_plus *) fp) = &_IO_wfile_jumps;
fp->_wide_data->_wide_vtable = &_IO_wfile_jumps;
return 1;
@@ -750,7 +752,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))
{
@@ -759,35 +761,35 @@ decide_maybe_mmap (_IO_FILE *fp)
p = __mmap64 (NULL, st.st_size, PROT_READ, MAP_SHARED, fp->_fileno, 0);
if (p != MAP_FAILED)
- {
- /* OK, we managed to map the file. Set the buffer up and use a
- special jump table with simplified underflow functions which
- never tries to read anything from the file. */
-
- if (__lseek64 (fp->_fileno, st.st_size, SEEK_SET) != st.st_size)
- {
- (void) __munmap (p, st.st_size);
- fp->_offset = _IO_pos_BAD;
- }
- else
- {
- _IO_setb (fp, p, (char *) p + st.st_size, 0);
-
- if (fp->_offset == _IO_pos_BAD)
- fp->_offset = 0;
-
- _IO_setg (fp, p, p + fp->_offset, p + st.st_size);
- fp->_offset = st.st_size;
-
- if (fp->_mode <= 0)
- _IO_JUMPS ((struct _IO_FILE_plus *)fp) = &_IO_file_jumps_mmap;
- else
- _IO_JUMPS ((struct _IO_FILE_plus *)fp) = &_IO_wfile_jumps_mmap;
- fp->_wide_data->_wide_vtable = &_IO_wfile_jumps_mmap;
-
- return;
- }
- }
+ {
+ /* OK, we managed to map the file. Set the buffer up and use a
+ special jump table with simplified underflow functions which
+ never tries to read anything from the file. */
+
+ if (__lseek64 (fp->_fileno, st.st_size, SEEK_SET) != st.st_size)
+ {
+ (void) __munmap (p, st.st_size);
+ fp->_offset = _IO_pos_BAD;
+ }
+ else
+ {
+ _IO_setb (fp, p, (char *) p + st.st_size, 0);
+
+ if (fp->_offset == _IO_pos_BAD)
+ fp->_offset = 0;
+
+ _IO_setg (fp, p, p + fp->_offset, p + st.st_size);
+ fp->_offset = st.st_size;
+
+ if (fp->_mode <= 0)
+ _IO_JUMPS ((struct _IO_FILE_plus *) fp) = &_IO_file_jumps_mmap;
+ else
+ _IO_JUMPS ((struct _IO_FILE_plus *) fp) = &_IO_wfile_jumps_mmap;
+ fp->_wide_data->_wide_vtable = &_IO_wfile_jumps_mmap;
+
+ return;
+ }
+ }
}
/* We couldn't use mmap, so revert to the vanilla file operations. */
@@ -811,8 +813,8 @@ _IO_file_underflow_maybe_mmap (_IO_FILE *fp)
int
_IO_new_file_overflow (f, ch)
- _IO_FILE *f;
- int ch;
+_IO_FILE * f;
+int ch;
{
if (f->_flags & _IO_NO_WRITES) /* SET ERROR */
{
@@ -825,48 +827,48 @@ _IO_new_file_overflow (f, ch)
{
/* Allocate a buffer if needed. */
if (f->_IO_write_base == NULL)
- {
- _IO_doallocbuf (f);
- _IO_setg (f, f->_IO_buf_base, f->_IO_buf_base, f->_IO_buf_base);
- }
+ {
+ _IO_doallocbuf (f);
+ _IO_setg (f, f->_IO_buf_base, f->_IO_buf_base, f->_IO_buf_base);
+ }
/* Otherwise must be currently reading.
- If _IO_read_ptr (and hence also _IO_read_end) is at the buffer end,
- logically slide the buffer forwards one block (by setting the
- read pointers to all point at the beginning of the block). This
- makes room for subsequent output.
- Otherwise, set the read pointers to _IO_read_end (leaving that
- alone, so it can continue to correspond to the external position). */
+ If _IO_read_ptr (and hence also _IO_read_end) is at the buffer end,
+ logically slide the buffer forwards one block (by setting the
+ read pointers to all point at the beginning of the block). This
+ makes room for subsequent output.
+ Otherwise, set the read pointers to _IO_read_end (leaving that
+ alone, so it can continue to correspond to the external position). */
if (__builtin_expect (_IO_in_backup (f), 0))
- {
- size_t nbackup = f->_IO_read_end - f->_IO_read_ptr;
- _IO_free_backup_area (f);
- f->_IO_read_base -= MIN (nbackup,
- f->_IO_read_base - f->_IO_buf_base);
- f->_IO_read_ptr = f->_IO_read_base;
- }
+ {
+ size_t nbackup = f->_IO_read_end - f->_IO_read_ptr;
+ _IO_free_backup_area (f);
+ f->_IO_read_base -= MIN (nbackup,
+ f->_IO_read_base - f->_IO_buf_base);
+ f->_IO_read_ptr = f->_IO_read_base;
+ }
if (f->_IO_read_ptr == f->_IO_buf_end)
- f->_IO_read_end = f->_IO_read_ptr = f->_IO_buf_base;
+ f->_IO_read_end = f->_IO_read_ptr = f->_IO_buf_base;
f->_IO_write_ptr = f->_IO_read_ptr;
f->_IO_write_base = f->_IO_write_ptr;
f->_IO_write_end = f->_IO_buf_end;
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))
- f->_IO_write_end = f->_IO_write_ptr;
+ 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 */
+ f->_IO_write_ptr - f->_IO_write_base);
+ 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;
if ((f->_flags & _IO_UNBUFFERED)
|| ((f->_flags & _IO_LINE_BUF) && ch == '\n'))
if (_IO_do_write (f, f->_IO_write_base,
- f->_IO_write_ptr - f->_IO_write_base) == EOF)
+ f->_IO_write_ptr - f->_IO_write_base) == EOF)
return EOF;
return (unsigned char) ch;
}
@@ -874,30 +876,31 @@ libc_hidden_ver (_IO_new_file_overflow, _IO_file_overflow)
int
_IO_new_file_sync (fp)
- _IO_FILE *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)
{
#ifdef TODO
if (_IO_in_backup (fp))
- delta -= eGptr () - Gbase ();
+ delta -= eGptr () - Gbase ();
#endif
_IO_off64_t new_pos = _IO_SYSSEEK (fp, delta, 1);
if (new_pos != (_IO_off64_t) EOF)
- fp->_IO_read_end = fp->_IO_read_ptr;
+ 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;
+ retval = EOF;
}
if (retval != EOF)
fp->_offset = _IO_pos_BAD;
@@ -914,15 +917,15 @@ _IO_file_sync_mmap (_IO_FILE *fp)
{
#ifdef TODO
if (_IO_in_backup (fp))
- delta -= eGptr () - Gbase ();
+ delta -= eGptr () - Gbase ();
#endif
if (__lseek64 (fp->_fileno, fp->_IO_read_ptr - fp->_IO_buf_base,
- SEEK_SET)
- != fp->_IO_read_ptr - fp->_IO_buf_base)
- {
- fp->_flags |= _IO_ERR_SEEN;
- return EOF;
- }
+ SEEK_SET)
+ != fp->_IO_read_ptr - fp->_IO_buf_base)
+ {
+ fp->_flags |= _IO_ERR_SEEN;
+ return EOF;
+ }
}
fp->_offset = fp->_IO_read_ptr - fp->_IO_buf_base;
fp->_IO_read_end = fp->_IO_read_ptr = fp->_IO_read_base;
@@ -932,10 +935,10 @@ _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_FILE * fp;
+_IO_off64_t offset;
+int dir;
+int mode;
{
_IO_off64_t result;
_IO_off64_t delta, new_offset;
@@ -943,13 +946,13 @@ _IO_new_file_seekoff (fp, offset, dir, mode)
/* POSIX.1 8.2.3.7 says that after a call the fflush() the file
offset of the underlying file must be exact. */
int must_be_exact = (fp->_IO_read_base == fp->_IO_read_end
- && fp->_IO_write_base == fp->_IO_write_ptr);
+ && fp->_IO_write_base == fp->_IO_write_ptr);
bool was_writing = (fp->_IO_write_ptr > fp->_IO_write_base
- || _IO_in_put_mode (fp));
+ || _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.
@@ -965,10 +968,10 @@ _IO_new_file_seekoff (fp, offset, dir, mode)
{
/* It could be that we already have a pushback buffer. */
if (fp->_IO_read_base != NULL)
- {
- free (fp->_IO_read_base);
- fp->_flags &= ~_IO_IN_BACKUP;
- }
+ {
+ free (fp->_IO_read_base);
+ fp->_flags &= ~_IO_IN_BACKUP;
+ }
_IO_doallocbuf (fp);
_IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
_IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
@@ -979,52 +982,50 @@ _IO_new_file_seekoff (fp, offset, dir, mode)
case _IO_seek_cur:
/* Adjust for read-ahead (bytes is buffer). */
if (mode != 0 || !was_writing)
- offset -= fp->_IO_read_end - fp->_IO_read_ptr;
+ 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)
- {
- if (mode != 0)
- goto dumb;
- else
- {
- result = _IO_SYSSEEK (fp, 0, dir);
- if (result == EOF)
- return result;
-
- fp->_offset = result;
- }
- }
+ {
+ if (mode != 0)
+ goto dumb;
+ else
+ {
+ result = _IO_SYSSEEK (fp, 0, dir);
+ if (result == EOF)
+ return result;
+
+ fp->_offset = result;
+ }
+ }
/* Make offset absolute, assuming current pointer is file_ptr(). */
offset += fp->_offset;
if (offset < 0)
- {
- __set_errno (EINVAL);
- return EOF;
- }
+ {
+ __set_errno (EINVAL);
+ return EOF;
+ }
dir = _IO_seek_set;
break;
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. */
@@ -1037,17 +1038,17 @@ _IO_new_file_seekoff (fp, offset, dir, mode)
&& !_IO_in_backup (fp))
{
_IO_off64_t start_offset = (fp->_offset
- - (fp->_IO_read_end - fp->_IO_buf_base));
+ - (fp->_IO_read_end - fp->_IO_buf_base));
if (offset >= start_offset && offset < fp->_offset)
- {
- _IO_setg (fp, fp->_IO_buf_base,
- fp->_IO_buf_base + (offset - start_offset),
- fp->_IO_read_end);
- _IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
-
- _IO_mask_flags (fp, 0, _IO_EOF_SEEN);
- goto resync;
- }
+ {
+ _IO_setg (fp, fp->_IO_buf_base,
+ fp->_IO_buf_base + (offset - start_offset),
+ fp->_IO_read_end);
+ _IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
+
+ _IO_mask_flags (fp, 0, _IO_EOF_SEEN);
+ goto resync;
+ }
}
if (fp->_flags & _IO_NO_READS)
@@ -1069,23 +1070,23 @@ _IO_new_file_seekoff (fp, offset, dir, mode)
else
{
count = _IO_SYSREAD (fp, fp->_IO_buf_base,
- (must_be_exact
- ? delta : fp->_IO_buf_end - fp->_IO_buf_base));
+ (must_be_exact
+ ? delta : fp->_IO_buf_end - fp->_IO_buf_base));
if (count < delta)
- {
- /* We weren't allowed to read, but try to seek the remainder. */
- offset = count == EOF ? delta : delta-count;
- dir = _IO_seek_cur;
- goto dumb;
- }
+ {
+ /* We weren't allowed to read, but try to seek the remainder. */
+ offset = count == EOF ? delta : delta - count;
+ dir = _IO_seek_cur;
+ goto dumb;
+ }
}
_IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base + delta,
- fp->_IO_buf_base + count);
+ fp->_IO_buf_base + count);
_IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
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);
@@ -1112,10 +1113,10 @@ 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_FILE * fp;
+_IO_off64_t offset;
+int dir;
+int mode;
{
_IO_off64_t result;
@@ -1160,7 +1161,7 @@ _IO_file_seekoff_mmap (fp, offset, dir, mode)
/* Adjust the read pointers to match the file position,
but so the next read attempt will call underflow. */
_IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base + offset,
- fp->_IO_buf_base + offset);
+ fp->_IO_buf_base + offset);
fp->_offset = result;
@@ -1171,7 +1172,7 @@ _IO_file_seekoff_mmap (fp, offset, dir, mode)
static _IO_off64_t
_IO_file_seekoff_maybe_mmap (_IO_FILE *fp, _IO_off64_t offset, int dir,
- int mode)
+ int mode)
{
/* We only get here when we haven't tried to read anything yet.
So there is nothing more useful for us to do here than just
@@ -1187,21 +1188,21 @@ _IO_file_seekoff_maybe_mmap (_IO_FILE *fp, _IO_off64_t offset, int dir,
_IO_ssize_t
_IO_file_read (fp, buf, size)
- _IO_FILE *fp;
- void *buf;
- _IO_ssize_t 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)
- : read (fp->_fileno, buf, size));
+ ? read_not_cancel (fp->_fileno, buf, size)
+ : read (fp->_fileno, 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_FILE * fp;
+_IO_off64_t offset;
+int dir;
{
return __lseek64 (fp->_fileno, offset, dir);
}
@@ -1209,8 +1210,8 @@ libc_hidden_def (_IO_file_seek)
int
_IO_file_stat (fp, st)
- _IO_FILE *fp;
- void *st;
+_IO_FILE * fp;
+void *st;
{
return __fxstat64 (_STAT_VER, fp->_fileno, (struct stat64 *) st);
}
@@ -1218,7 +1219,7 @@ libc_hidden_def (_IO_file_stat)
int
_IO_file_close_mmap (fp)
- _IO_FILE *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);
@@ -1230,7 +1231,7 @@ _IO_file_close_mmap (fp)
int
_IO_file_close (fp)
- _IO_FILE *fp;
+_IO_FILE * fp;
{
/* Cancelling close should be avoided if possible since it leaves an
unrecoverable state behind. */
@@ -1240,23 +1241,23 @@ 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_FILE * f;
+const void *data;
+_IO_ssize_t n;
{
_IO_ssize_t to_do = n;
_IO_ssize_t count = 0;
while (to_do > 0)
{
count = (__builtin_expect (f->_flags2
- & _IO_FLAGS2_NOTCANCEL, 0)
- ? write_not_cancel (f->_fileno, data, to_do)
- : write (f->_fileno, data, to_do));
+ & _IO_FLAGS2_NOTCANCEL, 0)
+ ? write_not_cancel (f->_fileno, data, to_do)
+ : write (f->_fileno, data, to_do));
if (count < 0)
- {
- f->_flags |= _IO_ERR_SEEN;
- break;
- }
+ {
+ f->_flags |= _IO_ERR_SEEN;
+ break;
+ }
to_do -= count;
data = (void *) ((char *) data + count);
}
@@ -1268,9 +1269,9 @@ _IO_new_file_write (f, data, n)
_IO_size_t
_IO_new_file_xsputn (f, data, n)
- _IO_FILE *f;
- const void *data;
- _IO_size_t n;
+_IO_FILE * f;
+const void *data;
+_IO_size_t n;
{
register const char *s = (const char *) data;
_IO_size_t to_do = n;
@@ -1288,27 +1289,25 @@ _IO_new_file_xsputn (f, data, n)
{
count = f->_IO_buf_end - f->_IO_write_ptr;
if (count >= n)
- {
- register const char *p;
- for (p = s + n; p > s; )
- {
- if (*--p == '\n')
- {
- count = p - s + 1;
- must_flush = 1;
- break;
- }
- }
- }
+ {
+ register const char *p;
+ for (p = s + n; p > s; )
+ 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)
{
if (count > to_do)
- count = to_do;
+ count = to_do;
#ifdef _LIBC
f->_IO_write_ptr = __mempcpy (f->_IO_write_ptr, s, count);
#else
@@ -1323,29 +1322,29 @@ _IO_new_file_xsputn (f, data, n)
_IO_size_t block_size, do_write;
/* Next flush the (full) buffer. */
if (_IO_OVERFLOW (f, EOF) == EOF)
- /* If nothing else has to be written or nothing has been written, we
- must not signal the caller that the call was even partially
- successful. */
- return (to_do == 0 || to_do == n) ? EOF : n - to_do;
+ /* If nothing else has to be written or nothing has been written, we
+ must not signal the caller that the call was even partially
+ successful. */
+ return (to_do == 0 || to_do == n) ? EOF : n - to_do;
/* Try to maintain alignment: write a whole number of blocks.
- dont_write is what gets left over. */
+ dont_write is what gets left over. */
block_size = f->_IO_buf_end - f->_IO_buf_base;
do_write = to_do - (block_size >= 128 ? to_do % block_size : 0);
if (do_write)
- {
- count = new_do_write (f, s, do_write);
- to_do -= count;
- if (count < do_write)
- return n - to_do;
- }
+ {
+ count = new_do_write (f, s, do_write);
+ to_do -= count;
+ if (count < do_write)
+ return n - to_do;
+ }
/* Now write out the remainder. Normally, this will fit in the
- buffer, but it's somewhat messier for line-buffered files,
- so we let _IO_default_xsputn handle the general case. */
+ 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;
}
@@ -1353,9 +1352,9 @@ 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_FILE * fp;
+void *data;
+_IO_size_t n;
{
register _IO_size_t want, have;
register _IO_ssize_t count;
@@ -1367,10 +1366,10 @@ _IO_file_xsgetn (fp, data, n)
{
/* Maybe we already have a push back pointer. */
if (fp->_IO_save_base != NULL)
- {
- free (fp->_IO_save_base);
- fp->_flags &= ~_IO_IN_BACKUP;
- }
+ {
+ free (fp->_IO_save_base);
+ fp->_flags &= ~_IO_IN_BACKUP;
+ }
_IO_doallocbuf (fp);
}
@@ -1378,86 +1377,87 @@ _IO_file_xsgetn (fp, data, n)
{
have = fp->_IO_read_end - fp->_IO_read_ptr;
if (want <= have)
- {
- memcpy (s, fp->_IO_read_ptr, want);
- fp->_IO_read_ptr += want;
- want = 0;
- }
+ {
+ memcpy (s, fp->_IO_read_ptr, want);
+ fp->_IO_read_ptr += want;
+ want = 0;
+ }
else
- {
- if (have > 0)
- {
+ {
+ if (have > 0)
+ {
#ifdef _LIBC
- s = __mempcpy (s, fp->_IO_read_ptr, have);
+ s = __mempcpy (s, fp->_IO_read_ptr, have);
#else
- memcpy (s, fp->_IO_read_ptr, have);
- s += have;
+ memcpy (s, fp->_IO_read_ptr, have);
+ s += have;
#endif
- want -= have;
- fp->_IO_read_ptr += have;
- }
-
- /* Check for backup and repeat */
- if (_IO_in_backup (fp))
- {
- _IO_switch_to_main_get_area (fp);
- continue;
- }
-
- /* If we now want less than a buffer, underflow and repeat
- the copy. Otherwise, _IO_SYSREAD directly to
- the user buffer. */
- if (fp->_IO_buf_base
- && want < (size_t) (fp->_IO_buf_end - fp->_IO_buf_base))
- {
- if (__underflow (fp) == EOF)
- break;
-
- continue;
- }
-
- /* These must be set before the sysread as we might longjmp out
- waiting for input. */
- _IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
- _IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
-
- /* Try to maintain alignment: read a whole number of blocks. */
- count = want;
- if (fp->_IO_buf_base)
- {
- _IO_size_t block_size = fp->_IO_buf_end - fp->_IO_buf_base;
- if (block_size >= 128)
- count -= want % block_size;
- }
-
- count = _IO_SYSREAD (fp, s, count);
- if (count <= 0)
- {
- if (count == 0)
- fp->_flags |= _IO_EOF_SEEN;
- else
- fp->_flags |= _IO_ERR_SEEN;
-
- break;
- }
-
- s += count;
- want -= count;
- if (fp->_offset != _IO_pos_BAD)
- _IO_pos_adjust (fp->_offset, count);
- }
+ want -= have;
+ fp->_IO_read_ptr += have;
+ }
+
+ /* Check for backup and repeat */
+ if (_IO_in_backup (fp))
+ {
+ _IO_switch_to_main_get_area (fp);
+ continue;
+ }
+
+ /* If we now want less than a buffer, underflow and repeat
+ the copy. Otherwise, _IO_SYSREAD directly to
+ the user buffer. */
+ if (fp->_IO_buf_base
+ && want < (size_t) (fp->_IO_buf_end - fp->_IO_buf_base))
+ {
+ if (__underflow (fp) == EOF)
+ break;
+
+ continue;
+ }
+
+ /* These must be set before the sysread as we might longjmp out
+ waiting for input. */
+ _IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
+ _IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
+
+ /* Try to maintain alignment: read a whole number of blocks. */
+ count = want;
+ if (fp->_IO_buf_base)
+ {
+ _IO_size_t block_size = fp->_IO_buf_end - fp->_IO_buf_base;
+ if (block_size >= 128)
+ count -= want % block_size;
+ }
+
+ count = _IO_SYSREAD (fp, s, count);
+ if (count <= 0)
+ {
+ if (count == 0)
+ fp->_flags |= _IO_EOF_SEEN;
+ else
+ fp->_flags |= _IO_ERR_SEEN;
+
+ break;
+ }
+
+ s += count;
+ want -= count;
+ if (fp->_offset != _IO_pos_BAD)
+ _IO_pos_adjust (fp->_offset, count);
+ }
}
return n - want;
}
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 (_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;
+_IO_FILE * fp;
+void *data;
+_IO_size_t n;
{
register _IO_size_t have;
char *read_ptr = fp->_IO_read_ptr;
@@ -1468,29 +1468,29 @@ _IO_file_xsgetn_mmap (fp, data, n)
if (have < n)
{
if (__builtin_expect (_IO_in_backup (fp), 0))
- {
+ {
#ifdef _LIBC
- s = __mempcpy (s, read_ptr, have);
+ s = __mempcpy (s, read_ptr, have);
#else
- memcpy (s, read_ptr, have);
- s += have;
+ memcpy (s, read_ptr, have);
+ s += have;
#endif
- n -= have;
- _IO_switch_to_main_get_area (fp);
- read_ptr = fp->_IO_read_ptr;
- have = fp->_IO_read_end - fp->_IO_read_ptr;
- }
+ n -= have;
+ _IO_switch_to_main_get_area (fp);
+ read_ptr = fp->_IO_read_ptr;
+ have = fp->_IO_read_end - fp->_IO_read_ptr;
+ }
if (have < n)
- {
- /* Check that we are mapping all of the file, in case it grew. */
- if (__builtin_expect (mmap_remap_check (fp), 0))
- /* We punted mmap, so complete with the vanilla code. */
- return s - (char *) data + _IO_XSGETN (fp, data, n);
-
- read_ptr = fp->_IO_read_ptr;
- have = fp->_IO_read_end - read_ptr;
- }
+ {
+ /* Check that we are mapping all of the file, in case it grew. */
+ if (__builtin_expect (mmap_remap_check (fp), 0))
+ /* We punted mmap, so complete with the vanilla code. */
+ return s - (char *) data + _IO_XSGETN (fp, data, n);
+
+ read_ptr = fp->_IO_read_ptr;
+ have = fp->_IO_read_end - read_ptr;
+ }
}
if (have < n)
@@ -1511,12 +1511,13 @@ _IO_file_xsgetn_mmap (fp, data, n)
return s - (char *) data;
}
-static _IO_size_t _IO_file_xsgetn_maybe_mmap (_IO_FILE *, void *, _IO_size_t);
+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;
+_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 +1545,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/fmemopen.c b/libio/fmemopen.c
index 02c764f..c897a3c 100644
--- a/libio/fmemopen.c
+++ b/libio/fmemopen.c
@@ -98,7 +98,7 @@ fmemopen_read (void *cookie, char *b, size_t s)
if (c->pos + s > c->size)
{
if ((size_t) c->pos == c->size)
- return 0;
+ return 0;
s = c->size - c->pos;
}
@@ -125,10 +125,10 @@ fmemopen_write (void *cookie, const char *b, size_t s)
if (c->pos + s + addnullc > c->size)
{
if ((size_t) (c->pos + addnullc) == c->size)
- {
- __set_errno (ENOSPC);
- return 0;
- }
+ {
+ __set_errno (ENOSPC);
+ return 0;
+ }
s = c->size - c->pos - addnullc;
}
@@ -139,7 +139,7 @@ fmemopen_write (void *cookie, const char *b, size_t s)
{
c->maxpos = c->pos;
if (addnullc)
- c->buffer[c->maxpos] = '\0';
+ c->buffer[c->maxpos] = '\0';
}
return s;
@@ -202,9 +202,9 @@ fmemopen (void *buf, size_t len, const char *mode)
cookie_io_functions_t iof;
fmemopen_cookie_t *c;
- if (__builtin_expect (len == 0, 0))
+ if (__glibc_unlikely (len == 0))
{
- einval:
+einval:
__set_errno (EINVAL);
return NULL;
}
@@ -219,25 +219,25 @@ fmemopen (void *buf, size_t len, const char *mode)
{
c->buffer = (char *) malloc (len);
if (c->buffer == NULL)
- {
- free (c);
- return NULL;
- }
+ {
+ free (c);
+ return NULL;
+ }
c->buffer[0] = '\0';
c->maxpos = 0;
}
else
{
- if (__builtin_expect ((uintptr_t) len > -(uintptr_t) buf, 0))
- {
- free (c);
- goto einval;
- }
+ if (__glibc_unlikely ((uintptr_t) len > -(uintptr_t) buf))
+ {
+ free (c);
+ goto einval;
+ }
c->buffer = buf;
if (mode[0] == 'w')
- c->buffer[0] = '\0';
+ c->buffer[0] = '\0';
c->maxpos = strnlen (c->buffer, len);
}
diff --git a/libio/iofdopen.c b/libio/iofdopen.c
index a65a5a6..2f8f202 100644
--- a/libio/iofdopen.c
+++ b/libio/iofdopen.c
@@ -33,17 +33,17 @@
#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;
+int fd;
+const char *mode;
{
int read_write;
int posix_mode = 0;
@@ -69,37 +69,37 @@ _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)
- {
- case '\0':
- break;
- case '+':
- read_write &= _IO_IS_APPENDING;
- break;
- case 'm':
- use_mmap = 1;
- continue;
- case 'x':
- case 'b':
- default:
- /* Ignore */
- continue;
- }
+ {
+ case '\0':
+ break;
+ case '+':
+ read_write &= _IO_IS_APPENDING;
+ break;
+ case 'm':
+ use_mmap = 1;
+ continue;
+ case 'x':
+ case 'b':
+ default:
+ /* Ignore */
+ continue;
+ }
break;
}
#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;
@@ -125,13 +125,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
@@ -146,15 +146,15 @@ _IO_new_fdopen (fd, mode)
call _IO_file_attach or else it will allocate a buffer immediately. */
_IO_no_init (&new_f->fp.file, 0, 0, &new_f->wd,
#ifdef _G_HAVE_MMAP
- (use_mmap && (read_write & _IO_NO_WRITES))
- ? &_IO_wfile_jumps_maybe_mmap :
+ (use_mmap && (read_write & _IO_NO_WRITES))
+ ? &_IO_wfile_jumps_maybe_mmap :
#endif
- &_IO_wfile_jumps);
+ &_IO_wfile_jumps);
_IO_JUMPS (&new_f->fp) =
#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 +169,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..ed05435 100644
--- a/libio/iofopen.c
+++ b/libio/iofopen.c
@@ -36,20 +36,20 @@
_IO_FILE *
__fopen_maybe_mmap (fp)
- _IO_FILE *fp;
+_IO_FILE * fp;
{
#ifdef _G_HAVE_MMAP
if ((fp->_flags2 & _IO_FLAGS2_MMAP) && (fp->_flags & _IO_NO_WRITES))
{
/* Since this is read-only, we might be able to mmap the contents
- directly. We delay the decision until the first read attempt by
- giving it a jump table containing functions that choose mmap or
- vanilla file operations and reset the jump table accordingly. */
+ directly. We delay the decision until the first read attempt by
+ giving it a jump table containing functions that choose mmap or
+ vanilla file operations and reset the jump table accordingly. */
if (fp->_mode <= 0)
- _IO_JUMPS ((struct _IO_FILE_plus *) fp) = &_IO_file_jumps_maybe_mmap;
+ _IO_JUMPS ((struct _IO_FILE_plus *) fp) = &_IO_file_jumps_maybe_mmap;
else
- _IO_JUMPS ((struct _IO_FILE_plus *) fp) = &_IO_wfile_jumps_maybe_mmap;
+ _IO_JUMPS ((struct _IO_FILE_plus *) fp) = &_IO_wfile_jumps_maybe_mmap;
fp->_wide_data->_wide_vtable = &_IO_wfile_jumps_maybe_mmap;
}
#endif
@@ -59,9 +59,9 @@ __fopen_maybe_mmap (fp)
_IO_FILE *
__fopen_internal (filename, mode, is32)
- const char *filename;
- const char *mode;
- int is32;
+const char *filename;
+const char *mode;
+int is32;
{
struct locked_FILE
{
@@ -97,8 +97,8 @@ __fopen_internal (filename, mode, is32)
_IO_FILE *
_IO_new_fopen (filename, mode)
- const char *filename;
- const char *mode;
+const char *filename;
+const char *mode;
{
return __fopen_internal (filename, mode, 1);
}
--
1.7.10.4