Skip to content

Commit

Permalink
Use "|" instead of "+" when combine the _IO_LINE_BUF and _IO_UNBUFFER…
Browse files Browse the repository at this point in the history
…ED flags

Both of "_IO_UNBUFFERED" and "_IO_LINE_BUF"  are the bit flags, but I
find there are some codes looks like "_IO_LINE_BUF+_IO_UNBUFFERED",
while some codes are "_IO_LINE_BUF|_IO_UNBUFFERED".

I think the former is not good, even though the final result is same.
  • Loading branch information
Feng Gao authored and Siddhesh Poyarekar committed Jul 8, 2015
1 parent 8086966 commit 2e42502
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2015-07-08 Feng Gao <gfree.wind@gmail.com>

* libio/fileops.c: Use "|" instead of "+" when combine _IO_LINE_BUF
and _IO_UNBUFFERED.
* libio/oldfileops.c: Likewise.
* libio/wfileops.c: Likewise.

2015-07-08 Mike Frysinger <vapier@gentoo.org>

* nscd/selinux.c: Delete selinux/flask.h include.
Expand Down
4 changes: 2 additions & 2 deletions libio/fileops.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ new_do_write (_IO_FILE *fp, const char *data, _IO_size_t 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;
}
Expand Down Expand Up @@ -844,7 +844,7 @@ _IO_new_file_overflow (_IO_FILE *f, int 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)
Expand Down
4 changes: 2 additions & 2 deletions libio/oldfileops.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ old_do_write (fp, data, to_do)
fp->_cur_column = _IO_adjust_column (fp->_cur_column - 1, data, count) + 1;
_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->_flags & (_IO_LINE_BUF+_IO_UNBUFFERED))
fp->_IO_write_end = ((fp->_flags & (_IO_LINE_BUF | _IO_UNBUFFERED))
? fp->_IO_buf_base : fp->_IO_buf_end);
return count;
}
Expand Down Expand Up @@ -418,7 +418,7 @@ _IO_old_file_overflow (f, ch)
f->_IO_write_end = f->_IO_buf_end;
f->_IO_read_base = f->_IO_read_ptr = f->_IO_read_end;

if (f->_flags & (_IO_LINE_BUF+_IO_UNBUFFERED))
if (f->_flags & (_IO_LINE_BUF | _IO_UNBUFFERED))
f->_IO_write_end = f->_IO_write_ptr;
f->_flags |= _IO_CURRENTLY_PUTTING;
}
Expand Down
6 changes: 3 additions & 3 deletions libio/wfileops.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ _IO_wdo_write (_IO_FILE *fp, const wchar_t *data, _IO_size_t to_do)
fp->_wide_data->_IO_buf_base);
fp->_wide_data->_IO_write_base = fp->_wide_data->_IO_write_ptr
= fp->_wide_data->_IO_buf_base;
fp->_wide_data->_IO_write_end = ((fp->_flags & (_IO_LINE_BUF+_IO_UNBUFFERED))
fp->_wide_data->_IO_write_end = ((fp->_flags & (_IO_LINE_BUF | _IO_UNBUFFERED))
? fp->_wide_data->_IO_buf_base
: fp->_wide_data->_IO_buf_end);

Expand Down Expand Up @@ -216,7 +216,7 @@ _IO_wfile_underflow (_IO_FILE *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 ();
Expand Down Expand Up @@ -477,7 +477,7 @@ _IO_wfile_overflow (_IO_FILE *f, wint_t wch)
f->_IO_read_base = f->_IO_read_ptr = f->_IO_read_end;

f->_flags |= _IO_CURRENTLY_PUTTING;
if (f->_flags & (_IO_LINE_BUF+_IO_UNBUFFERED))
if (f->_flags & (_IO_LINE_BUF | _IO_UNBUFFERED))
f->_wide_data->_IO_write_end = f->_wide_data->_IO_write_ptr;
}
if (wch == WEOF)
Expand Down

0 comments on commit 2e42502

Please sign in to comment.