Problems with cin.getline on solaris 2.x

Neulinger, Nathan R. nneul@umr.edu
Tue Mar 20 12:18:00 GMT 2001


I am running the latest (03/20/01) cvs for the 3.0 branch. The following
code does not work properly on solaris builds. You have to hit enter twice,
and it only gets the first character of the entered string.

---cut---
#include <iostream.h>
int main() {
        char str[50];
        while (cin.getline(str,40))
                cout << "string = \"" << str << "\"" << endl;
}
---cut---

---run on sol 2.7---
arstest(37)> ./getln 
fred

string = "f"
---cut---

or

---run on sol 2.7 piped---
arstest(40)> echo fred | ./getln
string = "f"
arstest(41)>
---

---run on linux and any other box---
infinity(97)>./getln 
fred
string = "fred"
infinity(98)>
---cut---

I have this problem on sol 2.6, sol 2.7, but not on HP-UX 10.20, 11.X, or
linux. 

GCC is built with binutils 2.10.1.0.7, with the following options:

---
#!/bin/sh
# This file was generated automatically by configure.  Do not edit.
# This directory was configured as follows:
/afs/umr.edu/software/egcs3/src/gcc-latest/configure
--with-gcc-version-trigger=
/afs/.umr.edu/software/egcs3/src/gcc/gcc/version.c
--host=sparc-sun-solaris2.7 -
-prefix=/afs/umr.edu/software/egcs3/install/solaris27 --with-gnu-as
--with-gnu-l
d --disable-nls --disable-checking --disable-shared --disable-libtool-lock
--wit
h-local-prefix=/afs/umr.edu/software/egcs3/install/solaris27/local
--enable-vers
ion-specific-runtime-libs --norecursion 
# using "mh-frag"
---

I believe this was reported fixed in bug number 1620, but it still occurs
for me, and from the looks of the bug report, was also still occuring for
the person who reported it then but the problem was closed regardless.

Any suggestions? I've attached the .s.bz2, .cpp, and .ii.bz2 files. 

-- Nathan

------------------------------------------------------------
Nathan Neulinger                       EMail:  nneul@umr.edu
University of Missouri - Rolla         Phone: (573) 341-4841
Computing Services                       Fax: (573) 341-4216

-------------- next part --------------
A non-text attachment was scrubbed...
Name: getln.cpp
Type: text/x-c
Size: 129 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20010320/6b3dbcb1/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: getln.ii.bz2
Type: application/x-bzip2
Size: 48763 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20010320/6b3dbcb1/attachment.bz2>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: getln.s.bz2
Type: application/x-bzip2
Size: 2575 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20010320/6b3dbcb1/attachment-0001.bz2>


More information about the Libstdc++ mailing list