This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC 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]

libstdc++/5003: read in istream(new filebuf(popen())) read only first N bytes



>Number:         5003
>Category:       libstdc++
>Synopsis:       read in istream(new filebuf(popen())) read only first N bytes
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Dec 04 00:06:03 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Jean MUller
>Release:        gcc version 3.0.2
>Organization:
>Environment:
$ uname -imprsv
SunOS 5.6 Generic_105181-17 sun4m sparc SUNW,SPARCstation-5
$ g++ -v       
Reading specs from /opt/gnu/lib/gcc-lib/sparc-sun-solaris2.6/3.0.2/specs
Configured with: ../gcc-3.0.2/configure --prefix=/opt/gnu -enable-languages=c,c++
Thread model: posix
gcc version 3.0.2
>Description:
read with getline() in
  new istream(new filebuf(fopen(), ios::in, 100))
works good BUT read in
  new istream(new filebuf(popen(), ios::in, 100))
retruns only 100 first bytes then set eof true, even if a
truss shows that read() system call have read more than
100 bytes.
>How-To-Repeat:
$ g++ -o toto toto.cc
$ ./toto
 gcount()=20 length()=19 eof=0 bad=0 good=1
 gcount()=19 length()=18 eof=0 bad=0 good=1
 gcount()=1 length()=0 eof=0 bad=0 good=1
 gcount()=21 length()=20 eof=0 bad=0 good=1
 gcount()=1 length()=0 eof=0 bad=0 good=1
 gcount()=21 length()=20 eof=0 bad=0 good=1
 gcount()=1 length()=0 eof=0 bad=0 good=1
 gcount()=16 length()=16 eof=1 bad=0 good=0
nb lines=8
total=100
# READ ONLY 100 first bytes !
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="toto.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="toto.cc"

I2luY2x1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Qo=


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