Echoing chars and input functions

Scott Wilson swilson%thetone at Sun.COM
Sat Aug 20 03:57:06 AEST 1988


>Most operating
>systems will do this before the characters reach the C library, but some
>may be deficient so that the C library has to take care of such details.

For clarification, my original post on this subject was in reference
to getchar() as implemented in THINK's LightspeedC 3.0 for the Macintosh.
getchar() in this environment does not echo what is read interactively
(interestingly, LSC has a Set_Echo function that can turn echo on and
off but I don't think getchar() is one of the functions effected by it).
The Macintosh environment is quite different from more traditional
environments like DOS or UNIX and there really is no notion of a "terminal".
I think it is unfair to characterize OS's that don't echo as being
"deficient".  LSC, in an attempt to provide to provide compatibility,
takes on the responsibility of creating a terminal-like window so stdio
functions will work as expected.  I don't think it is reasonable to say
that the C environment need not be concerned about things such as echoing
because it is an OS problem when the host OS has no concept of a terminal.

What I would like to see from ANSI C is something like:  in the abscence
of a language-independent method of altering interactive i/o behavior
(such as provided by stty under UNIX), the standard library implementation
should provide calls to alter behavior such as input echoing, buffering,
and editing.  I realize that this would be difficult or impossible to
enforce because of the connection to the OS.

All that I really want is some portable way to read interactive input
that looks roughly the same across implmentations of C.  As long as
most implementations echo input fetched with getchar() and LSC doesn't
(and the OS can't) then this isn't possible.  My complaint is that ANSI
doesn't do anything to solve the problem.  Ultimately the best way to
solve this may be to bitch to THINK about their poor "UNIX compatibility"
with respect to getchar().

BTW, I do realize that LSC does allow input that is echoed by way of the
gethce() function, but that isn't exactly portable.


--
Scott Wilson		arpa: swilson at sun.com
Sun Microsystems	uucp: ...!sun!swilson
Mt. View, CA



More information about the Comp.lang.c mailing list