summaryrefslogtreecommitdiffstats
path: root/gnu/lib/libg++/libio
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/lib/libg++/libio')
-rw-r--r--gnu/lib/libg++/libio/fileops.c32
-rw-r--r--gnu/lib/libg++/libio/floatconv.c72
-rw-r--r--gnu/lib/libg++/libio/ioassign.cc55
-rw-r--r--gnu/lib/libg++/libio/iofclose.c4
-rw-r--r--gnu/lib/libg++/libio/iofgetpos.c2
-rw-r--r--gnu/lib/libg++/libio/iofread.c2
-rw-r--r--gnu/lib/libg++/libio/iofscanf.c2
-rw-r--r--gnu/lib/libg++/libio/iofsetpos.c2
-rw-r--r--gnu/lib/libg++/libio/iogetdelim.c102
-rw-r--r--gnu/lib/libg++/libio/iostream.cc17
-rw-r--r--gnu/lib/libg++/libio/ioungetc.c2
-rw-r--r--gnu/lib/libg++/libio/iovfprintf.c14
-rw-r--r--gnu/lib/libg++/libio/iovfscanf.c4
-rw-r--r--gnu/lib/libg++/libio/stdiostream.cc13
-rw-r--r--gnu/lib/libg++/libio/strstream.cc2
15 files changed, 256 insertions, 69 deletions
diff --git a/gnu/lib/libg++/libio/fileops.c b/gnu/lib/libg++/libio/fileops.c
index 47398a8..2bd7c24 100644
--- a/gnu/lib/libg++/libio/fileops.c
+++ b/gnu/lib/libg++/libio/fileops.c
@@ -44,7 +44,8 @@ extern int errno;
The position in the buffer that corresponds to the position
in external file system is file_ptr().
- This is normally egptr(), except in putback mode, when it is _save_egptr.
+ This is normally _IO_read_end, except in putback mode,
+ when it is _IO_save_end.
If the field _fb._offset is >= 0, it gives the offset in
the file as a whole corresponding to eGptr(). (???)
@@ -238,7 +239,7 @@ _IO_do_write(fp, data, to_do)
fp->_cur_column = _IO_adjust_column(fp->_cur_column - 1, data, to_do) + 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_buf_base
+ fp->_IO_write_end = (fp->_flags & (_IO_LINE_BUF+_IO_UNBUFFERED)) ? fp->_IO_buf_base
: fp->_IO_buf_end;
return count != to_do ? EOF : 0;
}
@@ -311,7 +312,7 @@ int _IO_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;
}
@@ -389,10 +390,10 @@ _IO_file_seekoff(fp, offset, mode)
switch (dir)
{
case _IO_seek_cur:
- if (fp->_offset == _IO_pos_BAD)
- goto dumb;
/* Adjust for read-ahead (bytes is buffer). */
offset -= fp->_IO_read_end - fp->_IO_read_ptr;
+ if (fp->_offset == _IO_pos_BAD)
+ goto dumb;
/* Make offset absolute, assuming current pointer is file_ptr(). */
offset += _IO_pos_as_off(fp->_offset);
@@ -414,24 +415,27 @@ _IO_file_seekoff(fp, offset, mode)
}
/* At this point, dir==_IO_seek_set. */
-#ifdef TODO
/* If destination is within current buffer, optimize: */
- if (fp->_offset != IO_pos_BAD && fp->_IO_read_base != NULL)
+ if (fp->_offset != _IO_pos_BAD && fp->_IO_read_base != NULL
+ && !_IO_in_backup (fp))
{
/* Offset relative to start of main get area. */
- _IO_pos_t rel_offset = offset - _fb._offset
- + (eGptr()-Gbase());
+ _IO_pos_t rel_offset = offset - fp->_offset
+ + (fp->_IO_read_end - fp->_IO_read_base);
if (rel_offset >= 0)
{
+#if 0
if (_IO_in_backup(fp))
_IO_switch_to_main_get_area(fp);
- if (rel_offset <= _IO_read_end - _IO_read_base)
+#endif
+ if (rel_offset <= fp->_IO_read_end - fp->_IO_read_base)
{
- _IO_setg(fp->_IO_buf_base, fp->_IO_buf_base + rel_offset,
+ _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base + rel_offset,
fp->_IO_read_end);
- _IO_setp(fp->_IO_buf_base, fp->_IO_buf_base);
+ _IO_setp(fp, fp->_IO_buf_base, fp->_IO_buf_base);
return offset;
}
+#ifdef TODO
/* If we have streammarkers, seek forward by reading ahead. */
if (_IO_have_markers(fp))
{
@@ -441,7 +445,9 @@ _IO_file_seekoff(fp, offset, mode)
goto dumb;
return offset;
}
+#endif
}
+#ifdef TODO
if (rel_offset < 0 && rel_offset >= Bbase() - Bptr())
{
if (!_IO_in_backup(fp))
@@ -449,8 +455,10 @@ _IO_file_seekoff(fp, offset, mode)
gbump(fp->_IO_read_end + rel_offset - fp->_IO_read_ptr);
return offset;
}
+#endif
}
+#ifdef TODO
_IO_unsave_markers(fp);
#endif
diff --git a/gnu/lib/libg++/libio/floatconv.c b/gnu/lib/libg++/libio/floatconv.c
index 84eb848..ff300bb 100644
--- a/gnu/lib/libg++/libio/floatconv.c
+++ b/gnu/lib/libg++/libio/floatconv.c
@@ -23,7 +23,7 @@ This exception does not however invalidate any other reasons why
the executable file might be covered by the GNU General Public License. */
#include <libioP.h>
-#ifdef USE_DTOA
+#ifdef _IO_USE_DTOA
/****************************************************************
*
* The author of this software is David M. Gay.
@@ -489,7 +489,7 @@ s2b
#endif
{
int i, k;
- long x, y;
+ _G_int32_t x, y;
x = (nd + 8) / 9;
for(k = 0, y = 1; x > y; y <<= 1, k++) ;
@@ -643,7 +643,7 @@ mult
xbe = xb + wb;
xc0 = c->x;
for(; xb < xbe; xb++, xc0++) {
- if (y = *xb & 0xffff) {
+ if ((y = *xb & 0xffff)) {
x = xa;
xc = xc0;
carry = 0;
@@ -657,7 +657,7 @@ mult
while(x < xae);
*xc = carry;
}
- if (y = *xb >> 16) {
+ if ((y = *xb >> 16)) {
x = xa;
xc = xc0;
carry = 0;
@@ -794,9 +794,9 @@ diff
#endif
{
int i, wa, wb;
- long borrow, y; /* We need signed shifts here. */
+ _G_int32_t borrow, y; /* We need signed shifts here. */
unsigned32 *xa, *xae, *xb, *xbe, *xc;
- long z;
+ _G_int32_t z;
i = cmp(a,b);
if (!i) {
@@ -856,7 +856,7 @@ ulp
(double x)
#endif
{
- register long L;
+ register _G_int32_t L;
double a;
L = (word0(x) & Exp_mask) - (P-1)*Exp_msk1;
@@ -879,7 +879,7 @@ ulp
else {
word0(a) = 0;
L -= Exp_shift;
- word1(a) = L >= 31 ? 1 : 1 << 31 - L;
+ word1(a) = L >= 31 ? 1 : 1 << (31 - L);
}
}
#endif
@@ -913,16 +913,16 @@ b2d
k = hi0bits(y);
*e = 32 - k;
if (k < Ebits) {
- d0 = Exp_1 | y >> Ebits - k;
+ d0 = Exp_1 | y >> (Ebits - k);
w = xa > xa0 ? *--xa : 0;
- d1 = y << (32-Ebits) + k | w >> Ebits - k;
+ d1 = y << ((32-Ebits) + k) | w >> (Ebits - k);
goto ret_d;
}
z = xa > xa0 ? *--xa : 0;
if (k -= Ebits) {
- d0 = Exp_1 | y << k | z >> 32 - k;
+ d0 = Exp_1 | y << k | z >> (32 - k);
y = xa > xa0 ? *--xa : 0;
- d1 = z << k | y >> 32 - k;
+ d1 = z << k | y >> (32 - k);
}
else {
d0 = Exp_1 | y;
@@ -974,9 +974,9 @@ d2b
z |= Exp_msk11;
#endif
- if (y = d1) {
- if (k = lo0bits(&y)) {
- x[0] = y | z << 32 - k;
+ if ((y = d1)) {
+ if ((k = lo0bits(&y))) {
+ x[0] = y | z << (32 - k);
z >>= k;
}
else
@@ -1091,7 +1091,7 @@ _IO_strtod
e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign;
CONST char *s, *s0, *s1;
double aadj, aadj1, adj, rv, rv0;
- long L;
+ _G_int32_t L;
unsigned32 y, z;
Bigint _bb, _b_avail, _bd, _bd0, _bs, _delta;
Bigint *bb = Binit(&_bb);
@@ -1280,7 +1280,7 @@ _IO_strtod
/* Get starting approximation = rv * 10**e1 */
if (e1 > 0) {
- if (i = e1 & 15)
+ if ((i = e1 & 15))
rv *= tens[i];
if (e1 &= ~15) {
if (e1 > DBL_MAX_10_EXP) {
@@ -1320,7 +1320,7 @@ _IO_strtod
}
else if (e1 < 0) {
e1 = -e1;
- if (i = e1 & 15)
+ if ((i = e1 & 15))
rv /= tens[i];
if (e1 &= ~15) {
e1 >>= 4;
@@ -1588,7 +1588,7 @@ _IO_strtod
z = word0(rv) & Exp_mask;
if (y == z) {
/* Can we stop now? */
- L = (long)aadj;
+ L = (_G_int32_t)aadj;
aadj -= L;
/* The tolerances below are conservative. */
if (dsign || word1(rv) || word0(rv) & Bndry_mask) {
@@ -1620,10 +1620,10 @@ quorem
#endif
{
int n;
- long borrow, y;
+ _G_int32_t borrow, y;
unsigned32 carry, q, ys;
unsigned32 *bx, *bxe, *sx, *sxe;
- long z;
+ _G_int32_t z;
unsigned32 si, zs;
n = S->wds;
@@ -1777,7 +1777,7 @@ _IO_dtoa
int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1,
j, j1, k, k0, k_check, leftright, m2, m5, s2, s5,
spec_case, try_quick;
- long L;
+ _G_int32_t L;
#ifndef Sudden_Underflow
int denorm;
#endif
@@ -1874,8 +1874,8 @@ _IO_dtoa
unsigned32 x;
i = bbits + be + (Bias + (P-1) - 1);
- x = i > 32 ? word0(d) << 64 - i | word1(d) >> i - 32
- : word1(d) << 32 - i;
+ x = i > 32 ? word0(d) << (64 - i) | word1(d) >> (i - 32)
+ : word1(d) << (32 - i);
d2 = x;
word0(d2) -= 31*Exp_msk1; /* adjust exponent */
i -= (Bias + (P-1) - 1) + 1;
@@ -2006,7 +2006,7 @@ _IO_dtoa
}
d /= ds;
}
- else if (j1 = -k) {
+ else if ((j1 = -k)) {
d *= tens[j1 & 0xf];
for(j = j1 >> 4; j; j >>= 1, i++)
if (j & 1) {
@@ -2039,7 +2039,7 @@ _IO_dtoa
*/
eps = 0.5/tens[ilim-1] - eps;
for(i = 0;;) {
- L = (long)d;
+ L = (_G_int32_t)d;
d -= L;
*s++ = '0' + (int)L;
if (d < eps)
@@ -2057,7 +2057,7 @@ _IO_dtoa
/* Generate ilim digits, then fix them up. */
eps *= tens[ilim-1];
for(i = 1;; i++, d *= 10.) {
- L = (long)d;
+ L = (_G_int32_t)d;
d -= L;
*s++ = '0' + (int)L;
if (i == ilim) {
@@ -2092,7 +2092,7 @@ _IO_dtoa
goto one_digit;
}
for(i = 1;; i++) {
- L = (long)(d / ds);
+ L = (_G_int32_t)(d / ds);
d -= L*ds;
#ifdef Check_FLT_ROUNDS
/* If FLT_ROUNDS == 2, L will usually be high by 1 */
@@ -2104,7 +2104,7 @@ _IO_dtoa
*s++ = '0' + (int)L;
if (i == ilim) {
d += d;
- if (d > ds || d == ds && L & 1) {
+ if (d > ds || (d == ds && L & 1)) {
bump_up:
while(*--s == '9')
if (s == s0) {
@@ -2169,7 +2169,7 @@ _IO_dtoa
b_avail = b;
b = b_tmp;
}
- if (j = b5 - m5)
+ if ((j = b5 - m5))
b = pow5mult(b, j);
}
else
@@ -2203,7 +2203,7 @@ _IO_dtoa
* and for all and pass them and a shift to quorem, so it
* can do shifts and ors to compute the numerator for q.
*/
- if (i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f)
+ if ((i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f))
i = 32 - i;
if (i > 4) {
i -= 4;
@@ -2276,15 +2276,15 @@ _IO_dtoa
goto ret;
}
#endif
- if (j < 0 || j == 0 && !mode
+ if (j < 0 || (j == 0 && !mode
#ifndef ROUND_BIASED
&& !(word1(d) & 1)
#endif
- ) {
+ )) {
if (j1 > 0) {
b = lshift(b, 1);
j1 = cmp(b, S);
- if ((j1 > 0 || j1 == 0 && dig & 1)
+ if ((j1 > 0 || (j1 == 0 && dig & 1))
&& dig++ == '9')
goto round_9_up;
}
@@ -2324,7 +2324,7 @@ _IO_dtoa
b = lshift(b, 1);
j = cmp(b, S);
- if (j > 0 || j == 0 && dig & 1) {
+ if (j > 0 || (j == 0 && dig & 1)) {
roundoff:
while(*--s == '9')
if (s == s0) {
@@ -2354,4 +2354,4 @@ _IO_dtoa
*rve = s;
return s0;
}
-#endif /* USE_DTOA */
+#endif /* _IO_USE_DTOA */
diff --git a/gnu/lib/libg++/libio/ioassign.cc b/gnu/lib/libg++/libio/ioassign.cc
new file mode 100644
index 0000000..5441ae7
--- /dev/null
+++ b/gnu/lib/libg++/libio/ioassign.cc
@@ -0,0 +1,55 @@
+/* This is part of libio/iostream, providing -*- C++ -*- input/output.
+Copyright (C) 1994 Free Software Foundation
+
+This file is part of the GNU IO Library. This library is free
+software; you can redistribute it and/or modify it under the
+terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+As a special exception, if you link this library with files
+compiled with a GNU compiler to produce an executable, this does not cause
+the resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why
+the executable file might be covered by the GNU General Public License. */
+
+/* Written by Per Bothner (bothner@cygnus.com). */
+
+#include <iostream.h>
+#include "libioP.h"
+
+// These method are provided for backward compatibility reasons.
+// It's generally poor style to use them.
+// They are not supported by the ANSI/ISO working paper.
+
+_IO_istream_withassign& _IO_istream_withassign::operator=(istream& rhs)
+{
+ if (&rhs != (istream*)this)
+ {
+ if (!(_flags & (unsigned int)ios::dont_close)) delete rdbuf();
+ init (rhs.rdbuf ());
+ _flags |= ios::dont_close;
+ _gcount = 0;
+ }
+ return *this;
+}
+
+_IO_ostream_withassign& _IO_ostream_withassign::operator=(ostream& rhs)
+{
+ if (&rhs != (ostream*)this)
+ {
+ if (!(_flags & (unsigned int)ios::dont_close)) delete rdbuf();
+ init (rhs.rdbuf ());
+ _flags |= ios::dont_close;
+ }
+ return *this;
+}
diff --git a/gnu/lib/libg++/libio/iofclose.c b/gnu/lib/libg++/libio/iofclose.c
index 44664d9..03be451 100644
--- a/gnu/lib/libg++/libio/iofclose.c
+++ b/gnu/lib/libg++/libio/iofclose.c
@@ -32,9 +32,7 @@ _IO_fclose(fp)
register _IO_FILE *fp;
{
int status = 0;
- COERCE_FILE(fp);
- if ((fp->_IO_file_flags & _IO_MAGIC_MASK) != _IO_MAGIC)
- return EOF;
+ CHECK_FILE(fp, EOF);
if (fp->_IO_file_flags & _IO_IS_FILEBUF)
status = _IO_file_close_it(fp);
fp->_jumps->__finish(fp);
diff --git a/gnu/lib/libg++/libio/iofgetpos.c b/gnu/lib/libg++/libio/iofgetpos.c
index 16ecec0..ac417f5 100644
--- a/gnu/lib/libg++/libio/iofgetpos.c
+++ b/gnu/lib/libg++/libio/iofgetpos.c
@@ -32,7 +32,7 @@ _IO_fgetpos(fp, posp)
_IO_fpos_t *posp;
{
_IO_fpos_t pos;
- COERCE_FILE(fp);
+ CHECK_FILE(fp, EOF);
pos = _IO_seekoff(fp, 0, _IO_seek_cur|_IO_seek_not_in|_IO_seek_not_out);
if (pos == _IO_pos_BAD)
{
diff --git a/gnu/lib/libg++/libio/iofread.c b/gnu/lib/libg++/libio/iofread.c
index c72c70f..4bfe717 100644
--- a/gnu/lib/libg++/libio/iofread.c
+++ b/gnu/lib/libg++/libio/iofread.c
@@ -33,7 +33,7 @@ _IO_fread(buf, size, count, fp)
{
_IO_size_t bytes_requested = size*count;
_IO_size_t bytes_read;
- COERCE_FILE(fp);
+ CHECK_FILE(fp, 0);
if (bytes_requested == 0)
return 0;
bytes_read = _IO_sgetn(fp, (char *)buf, bytes_requested);
diff --git a/gnu/lib/libg++/libio/iofscanf.c b/gnu/lib/libg++/libio/iofscanf.c
index 7110401..5daef91 100644
--- a/gnu/lib/libg++/libio/iofscanf.c
+++ b/gnu/lib/libg++/libio/iofscanf.c
@@ -40,7 +40,7 @@ _IO_fscanf
{
int ret;
va_list args;
- COERCE_FILE(fp);
+ CHECK_FILE(fp, EOF);
_IO_va_start(args, format);
ret = _IO_vfscanf(fp, format, args, NULL);
va_end(args);
diff --git a/gnu/lib/libg++/libio/iofsetpos.c b/gnu/lib/libg++/libio/iofsetpos.c
index 763fbe6..0a6fff2 100644
--- a/gnu/lib/libg++/libio/iofsetpos.c
+++ b/gnu/lib/libg++/libio/iofsetpos.c
@@ -30,7 +30,7 @@ _IO_fsetpos(fp, posp)
_IO_FILE* fp;
const _IO_fpos_t *posp;
{
- COERCE_FILE(fp);
+ CHECK_FILE(fp, EOF);
if (_IO_seekpos(fp, *posp, 0) == _IO_pos_BAD)
{
/*ANSI explicily requires setting errno to a positive value on failure.*/
diff --git a/gnu/lib/libg++/libio/iogetdelim.c b/gnu/lib/libg++/libio/iogetdelim.c
new file mode 100644
index 0000000..3dc5cd1
--- /dev/null
+++ b/gnu/lib/libg++/libio/iogetdelim.c
@@ -0,0 +1,102 @@
+/*
+Copyright (C) 1994 Free Software Foundation
+
+This file is part of the GNU IO Library. This library is free
+software; you can redistribute it and/or modify it under the
+terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+As a special exception, if you link this library with files
+compiled with a GNU compiler to produce an executable, this does not cause
+the resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why
+the executable file might be covered by the GNU General Public License. */
+
+#ifdef __STDC__
+#include <stdlib.h>
+#endif
+#include "libioP.h"
+#include <string.h>
+#include <errno.h>
+
+/* Read up to (and including) a TERMINATOR from FP into *LINEPTR
+ (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
+ NULL), pointing to *N characters of space. It is realloc'ed as
+ necessary. Returns the number of characters read (not including the
+ null terminator), or -1 on error or EOF. */
+
+_IO_ssize_t
+_IO_getdelim (lineptr, n, delimiter, fp)
+ char **lineptr;
+ _IO_size_t *n;
+ int delimiter;
+ _IO_FILE *fp;
+{
+ register _IO_ssize_t cur_len = 0;
+ _IO_ssize_t len;
+
+ if (lineptr == NULL || n == NULL)
+ {
+#ifdef EINVAL
+ errno = EINVAL;
+#endif
+ return -1;
+ }
+ CHECK_FILE (fp, -1);
+ if (_IO_ferror (fp))
+ return -1;
+
+ if (*lineptr == NULL || *n == 0)
+ {
+ *n = 120;
+ *lineptr = (char *) malloc (*n);
+ if (*lineptr == NULL)
+ return -1;
+ }
+
+ len = fp->_IO_read_end - fp->_IO_read_ptr;
+ if (len <= 0)
+ {
+ if (__underflow (fp) == EOF)
+ return -1;
+ len = fp->_IO_read_end - fp->_IO_read_ptr;
+ }
+
+ for (;;)
+ {
+ _IO_size_t needed;
+ char *t;
+ t = (char *) memchr ((void *) fp->_IO_read_ptr, delimiter, len);
+ if (t != NULL)
+ len = (t - fp->_IO_read_ptr) + 1;
+ /* make enough space for len+1 (for final NUL) bytes. */
+ needed = cur_len + len + 1;
+ if (needed > *n)
+ {
+ if (t == NULL && needed < 2 * *n)
+ needed = 2 * *n; /* Be generous. */
+ *n = needed;
+ *lineptr = (char *) realloc (*lineptr, needed);
+ if (*lineptr == NULL)
+ return -1;
+ }
+ memcpy (*lineptr + cur_len, (void *) fp->_IO_read_ptr, len);
+ fp->_IO_read_ptr += len;
+ cur_len += len;
+ if (t != NULL || __underflow (fp) == EOF)
+ break;
+ len = fp->_IO_read_end - fp->_IO_read_ptr;
+ }
+ lineptr[cur_len] = '\0';
+ return cur_len;
+}
diff --git a/gnu/lib/libg++/libio/iostream.cc b/gnu/lib/libg++/libio/iostream.cc
index db953d4..0c241f8 100644
--- a/gnu/lib/libg++/libio/iostream.cc
+++ b/gnu/lib/libg++/libio/iostream.cc
@@ -70,6 +70,8 @@ istream& istream::get(char& c)
_gcount = 1;
}
}
+ else
+ _gcount = 0;
return *this;
}
@@ -87,13 +89,13 @@ int istream::peek()
istream& istream::ignore(int n /* = 1 */, int delim /* = EOF */)
{
+ _gcount = 0;
if (ipfx1()) {
register streambuf* sb = _strbuf;
if (delim == EOF) {
_gcount = sb->ignore(n);
return *this;
}
- _gcount = 0;
for (;;) {
#if 0
if (n != MAXINT) // FIXME
@@ -120,6 +122,8 @@ istream& istream::read(char *s, int n)
if (_gcount != n)
set(ios::failbit|ios::eofbit);
}
+ else
+ _gcount = 0;
return *this;
}
@@ -307,6 +311,13 @@ READ_INT(unsigned long long)
READ_INT(bool)
#endif
+istream& istream::operator>>(long double& x)
+{
+ if (ipfx0())
+ scan("%lg", &x);
+ return *this;
+}
+
istream& istream::operator>>(double& x)
{
if (ipfx0())
@@ -552,7 +563,7 @@ ostream& ostream::operator<<(double n)
prec = 6; /* default */
// Do actual conversion.
-#ifdef USE_DTOA
+#ifdef _IO_USE_DTOA
if (_IO_outfloat(n, rdbuf(), format_char, width(0),
prec, flags(),
flags() & ios::showpos ? '+' : 0,
@@ -710,7 +721,7 @@ streampos ostream::tellp()
ostream& ostream::flush()
{
- if (_strbuf->_jumps->__sync(_strbuf))
+ if (_strbuf->sync())
set(ios::badbit);
return *this;
}
diff --git a/gnu/lib/libg++/libio/ioungetc.c b/gnu/lib/libg++/libio/ioungetc.c
index 7b983ed..b52e4a2 100644
--- a/gnu/lib/libg++/libio/ioungetc.c
+++ b/gnu/lib/libg++/libio/ioungetc.c
@@ -29,7 +29,7 @@ _IO_ungetc(c, fp)
int c;
_IO_FILE *fp;
{
- COERCE_FILE(fp);
+ CHECK_FILE(fp, EOF);
if (c == EOF)
return EOF;
return _IO_sputbackc(fp, (unsigned char)c);
diff --git a/gnu/lib/libg++/libio/iovfprintf.c b/gnu/lib/libg++/libio/iovfprintf.c
index feda569..e3fb2da 100644
--- a/gnu/lib/libg++/libio/iovfprintf.c
+++ b/gnu/lib/libg++/libio/iovfprintf.c
@@ -196,7 +196,7 @@ _IO_vfprintf(fp, fmt0, ap)
#ifdef FLOATING_POINT
int softsign; /* temporary negative sign for floats */
double _double; /* double precision arguments %[eEfgG] */
-#ifndef USE_DTOA
+#ifndef _IO_USE_DTOA
int fpprec; /* `extra' floating precision in [eEfgG] */
#endif
#endif
@@ -256,7 +256,7 @@ _IO_vfprintf(fp, fmt0, ap)
flags = 0;
dprec = 0;
-#if defined(FLOATING_POINT) && !defined (USE_DTOA)
+#if defined(FLOATING_POINT) && !defined (_IO_USE_DTOA)
fpprec = 0;
#endif
width = 0;
@@ -362,7 +362,7 @@ reswitch: switch (ch) {
case 'g':
case 'G':
_double = va_arg(ap, double);
-#ifdef USE_DTOA
+#ifdef _IO_USE_DTOA
{
int fmt_flags = 0;
int fill = ' ';
@@ -564,7 +564,7 @@ number: if ((dprec = prec) >= 0)
/*
* compute actual size, so we know how much to pad.
*/
-#if defined(FLOATING_POINT) && !defined (USE_DTOA)
+#if defined(FLOATING_POINT) && !defined (_IO_USE_DTOA)
fieldsz = size + fpprec;
#else
fieldsz = size;
@@ -602,7 +602,7 @@ number: if ((dprec = prec) >= 0)
/* the string or number proper */
PRINT(cp, size);
-#if defined(FLOATING_POINT) && !defined (USE_DTOA)
+#if defined(FLOATING_POINT) && !defined (_IO_USE_DTOA)
/* trailing f.p. zeroes */
PAD_0(fpprec);
#endif
@@ -622,7 +622,7 @@ error:
/* NOTREACHED */
}
-#if defined(FLOATING_POINT) && !defined(USE_DTOA)
+#if defined(FLOATING_POINT) && !defined(_IO_USE_DTOA)
static char *exponent(register char *p, register int exp, int fmtch)
{
@@ -882,4 +882,4 @@ eformat: if (expcnt) {
return (t - startp);
}
-#endif /* defined(FLOATING_POINT) && !defined(USE_DTOA) */
+#endif /* defined(FLOATING_POINT) && !defined(_IO_USE_DTOA) */
diff --git a/gnu/lib/libg++/libio/iovfscanf.c b/gnu/lib/libg++/libio/iovfscanf.c
index abf1e58..85168af 100644
--- a/gnu/lib/libg++/libio/iovfscanf.c
+++ b/gnu/lib/libg++/libio/iovfscanf.c
@@ -105,7 +105,7 @@ static char sccsid[] = "%W% (Berkeley) %G%";
extern u_long strtoul __P((const char*, char**, int));
extern long strtol __P((const char*, char**, int));
static const u_char *__sccl __P((char *tab, const u_char *fmt));
-#ifndef USE_DTOA
+#ifndef _IO_USE_DTOA
extern double atof();
#endif
@@ -655,7 +655,7 @@ literal:
if ((flags & SUPPRESS) == 0) {
double res;
*p = 0;
-#ifdef USE_DTOA
+#ifdef _IO_USE_DTOA
res = _IO_strtod(buf, NULL);
#else
res = atof(buf);
diff --git a/gnu/lib/libg++/libio/stdiostream.cc b/gnu/lib/libg++/libio/stdiostream.cc
index eb3dd16..f6de524 100644
--- a/gnu/lib/libg++/libio/stdiostream.cc
+++ b/gnu/lib/libg++/libio/stdiostream.cc
@@ -68,6 +68,19 @@ stdiobuf::~stdiobuf()
streamsize stdiobuf::sys_read(char* buf, streamsize size)
{
+ // A minor optimization, but it makes a noticable difference.
+ // A bigger optimization would be to write stdiobuf::underflow,
+ // but that has some modularity disadvantages. Re-evaluate that
+ // after we have gotten rid of the double indirection. FIXME
+ if (size == 1)
+ {
+ register ch = getc(_file);
+ if (ch == EOF)
+ return 0;
+ *buf = (char)ch;
+ return 1;
+ }
+ else
return fread(buf, 1, size, _file);
}
diff --git a/gnu/lib/libg++/libio/strstream.cc b/gnu/lib/libg++/libio/strstream.cc
index c17d683..e5917f0 100644
--- a/gnu/lib/libg++/libio/strstream.cc
+++ b/gnu/lib/libg++/libio/strstream.cc
@@ -76,7 +76,7 @@ char *strstreambuf::str()
return base();
}
-_IO_ssize_t strstreambuf::pcount() { return _IO_str_count (this); }
+_IO_ssize_t strstreambuf::pcount () { return _IO_write_ptr - _IO_write_base; }
int strstreambuf::overflow(int c /* = EOF */)
{
OpenPOWER on IntegriCloud