Groups | Search | Server Info | Login | Register


Groups > comp.lang.awk > #9927

What is getchar? (Was: getchar implementation without GNUishms)

From gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups comp.lang.awk
Subject What is getchar? (Was: getchar implementation without GNUishms)
Date 2025-03-26 06:07 +0000
Organization The official candy of the new Millennium
Message-ID <vs05in$nf97$2@news.xmission.com> (permalink)
References <slrnvu4v4s.1su2.anthk@openbsd.home> <vrua0r$3d1du$1@dont-email.me> <vrvv30$spj$1@nnrp.usenet.blueworldhosting.com> <vs038p$12n0d$1@dont-email.me>

Show all headers | View raw


In article <vs038p$12n0d$1@dont-email.me>,
Janis Papanagnou  <janis_papanagnou+ng@hotmail.com> wrote:
...
>I don't know. - When I read 'getchar' I associated a character oriented
>function like awk's 'getline'. That would mean not reading from stdin
>with some I/O buffered return-terminated input but just processing the
>data as Awk would read its input from stdin or using 'getline' would.
>You need to maintain some state, though; here the actual read in line
>which acts like a buffer in buffered OS reads.

It is an interesting question.

In strict C terms, getchar() is well-known, and well-defined and is pretty
much as you describe it.  But in an AWK context, that sort of function
doesn't seem like it would ever be useful, so we should probably assume
that what most of the posters on the thread are talking about is something
more akin to getch() - which is what I assumed in my two posted solutions.

Now, in old languages, like Turbo C and Turbo Pascal, there were generally
two function with similar names): getchar() - which behaved as Janis
suggests and is there primarily for standards conformance and getch() -
which function as as I describe above.  Note that in a Unix/Linux context,
doing single char input requires messing with TTY modes (which is ugly),
whereas in DOS/Windows, it comes pretty much "for free".

-- 
    Nov 4, 2008 - the day when everything went
    from being Clinton's fault to being Obama's fault.

Back to comp.lang.awk | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

getchar implementation without GNUishms anthk <anthk@openbsd.home> - 2025-03-25 09:51 +0000
  Re: getchar implementation without GNUishms Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-03-25 14:10 +0100
    Re: getchar implementation without GNUishms "Arti F. Idiot" <addr@is.invalid> - 2025-03-25 22:16 -0600
      Re: getchar implementation without GNUishms gazelle@shell.xmission.com (Kenny McCormack) - 2025-03-26 05:08 +0000
        Re: getchar implementation without GNUishms gazelle@shell.xmission.com (Kenny McCormack) - 2025-03-26 05:48 +0000
      Re: getchar implementation without GNUishms Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-03-26 06:27 +0100
        What is getchar? (Was: getchar implementation without GNUishms) gazelle@shell.xmission.com (Kenny McCormack) - 2025-03-26 06:07 +0000
          Re: What is getchar? (Was: getchar implementation without GNUishms) Kaz Kylheku <643-408-1753@kylheku.com> - 2025-03-26 06:10 +0000

csiph-web