comp.lang.ada
 help / color / mirror / Atom feed
From: jmartin@oahu.cs.ucla.edu (Jay Martin)
Subject: Re: "Subtract C, add Ada"
Date: 30 Jan 1995 19:30:12 -0800
Date: 1995-01-30T19:30:12-08:00	[thread overview]
Message-ID: <3gkas4$ibs@oahu.cs.ucla.edu> (raw)
In-Reply-To: 1995Jan29.202418@hobbit

First there was:
  Newtons Principia....
then came:
  Einstein's Theory of Relativity...
And Now....
  G E T C H A R ()!!!  BOM-BOM BOM-BOM BOM-BOM...
---------------------------------

For some laughs lets look at the man page for getchar():

NAME
     getc, getchar, fgetc, getw - get character or  integer  from
     stream

SYNOPSIS
     #include <stdio.h>

     int getc(stream)
     FILE *stream;

     int getchar()

     int fgetc(stream)
     FILE *stream;

     int getw(stream)
     FILE *stream;

DESCRIPTION
     getc() returns the next character (that is, byte)  from  the
     named  input  stream, as an integer.  It also moves the file
     pointer,  if  defined,  ahead  one  character   in   stream.
     getchar()  is  defined as getc(stdin).  getc() and getchar()
     are macros.

>> Hee Hee, are we getting a char or an "int"?  Well it returns
>> an int and then we need to do an implicit conversion back into
>> a char.  Assuming c is a char in "c = getchar()" then we have
>> just lost the ability to check for EOF since we may have read
>> a char with value 255 (assuming EOF = -1).  Implicit conversions
>> rule!!! 

     fgetc() behaves like getc(), but is a function rather than a
     macro.   fgetc()  runs more slowly than getc(), but it takes
     less space per invocation and its name can be passed  as  an
     argument to a function.

> Macros, ZOOOOOOOM!!!!!!

     getw() returns the next C int (word) from  the  named  input
     stream.   getw()  increments the associated file pointer, if
     defined, to point to the next word.  The size of a  word  is
     the  size  of an integer and varies from machine to machine.
     getw() assumes no special alignment in the file.

RETURN VALUES
     On success, getc(), getchar() and fgetc()  return  the  next
     character  from  the  named  input stream as an integer.  On
     failure, or on EOF, they return EOF. The  EOF  condition  is
     remembered,  even  on  a terminal, and all subsequent opera-
     tions which attempt to read from the stream will return  EOF
     until   the   condition  is  cleared  with  clearerr()  (see
     ferror(3V)).

>> Hey, maybe we could use this ferror() thingy to tell the difference
>> between EOF and char 255.  Well we probably should anyway to detect
>> the difference between EOF and failure. Oh, the elegance of it all!

     getw() returns the next C int from the named input stream on
     success.   On  failure, or on EOF, it returns EOF, but since
     EOF is a valid integer,  use  ferror(3V)  to  detect  getw()
     errors.

>> Oops! Sorry about that. 

SYSTEM V RETURN VALUES

     On failure, or on EOF, these functions return EOF.  The  EOF
     condition is remembered, even on a terminal, however, opera-
     tions which attempt to read from the stream will ignore  the
     current state of the EOF indication and attempt to read from
     the file descriptor associated with the stream.

>> Don't want to restrict the programmer!  Damn the torpedos!  Full
>> steam ahead!  Lets here it for SYSTEM V!!

SEE ALSO
     ferror(3V),  fopen(3V),   fread(3S),   gets(3S),   putc(3S),
     scanf(3V), ungetc(3S)

WARNINGS
     If the integer  value  returned  by  getc(),  getchar(),  or
     fgetc()  is  stored  into a character variable and then com-
     pared against the integer constant EOF, the  comparison  may
     never  succeed,  because  sign-extension  of  a character on
     widening to integer is machine-dependent.

BUGS
     Because it is implemented as a macro, getc() treats a stream
     argument  with  side  effects  incorrectly.   In particular,
     getc(*f++) does not work sensibly.  fgetc() should  be  used
     instead.

     Because of possible differences in word length and byte ord-
     ering, files written using putw() are machine-dependent, and
     may not be readable using getw() on a different processor.

>> We don't need these stinking warnings, they are obvious from the
>> include file!

------------------------------------------------------------------

Well this is what happens when you let incompetent pinheads
design operating system and languages.  Of course the clowns
in industry and academia standing around drooling at this shit
with the look of adoration on their faces doesn't help either.

I think I'll go punch a brick wall until my hands bleed.

Jay




  reply	other threads:[~1995-01-31  3:30 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-01-20 10:20 "Subtract C, add Ada" R.A.L Williams
1995-01-20 13:22 ` Renaud HEBERT
1995-01-24  3:35   ` David Moore
1995-01-25  5:38     ` Robert Dewar
1995-01-28 16:35     ` Jules
1995-01-29  8:06       ` Matt Kennel
1995-01-30  5:31       ` Michael Feldman
1995-01-31 22:22         ` David O'Brien
1995-01-24 20:23   ` N. Mellor
1995-01-25  8:50     ` Robb Nebbe
1995-01-25 14:19     ` John Volan
1995-01-26  5:07     ` Samuel Mize
1995-01-26 18:51       ` Mark A Biggar
1995-01-21 15:18 ` Robert Dewar
1995-01-21 21:03 ` David O'Brien
1995-01-23  3:09   ` Jay Martin
1995-01-23 12:50     ` Andrew McConnell
1995-01-24  0:54     ` Matt Kennel
1995-01-25 17:03       ` Norman H. Cohen
1995-01-26  1:13         ` Dr. Richard Botting
1995-01-26 14:32         ` Anders Juul Munch
1995-01-24  0:17   ` Bob Kitzberger
1995-01-23 20:46 ` Robert Firth
1995-01-24 14:25   ` Samuel Mize
1995-01-25  7:27     ` David O'Brien
1995-01-25 12:14     ` Robert A Duff
1995-01-25  5:57   ` David O'Brien
     [not found]     ` <3g9rf0$71k@Starbase.NeoSoft.COM>
1995-01-28 21:08       ` David O'Brien
1995-01-31 18:07         ` Samuel Mize
1995-02-01 10:23         ` Samuel Mize
1995-01-30  0:24     ` Mark S. Hathaway
1995-01-31  3:30       ` Jay Martin [this message]
1995-02-01 13:25         ` Jesper Kaagaard
  -- strict thread matches above, loose matches on Subject: below --
1995-02-10 13:49 R.A.L Williams
     [not found] <3gsr0e$oin@miranda.gmrc.gecm.com>
1995-02-07 16:58 ` Mark S. Hathaway
1995-02-08  7:39   ` Travis C. Porco
1995-02-08 16:07     ` Fred J. McCall
1995-02-08 21:30       ` Garlington KE
1995-01-31  9:34 R.A.L Williams
1995-02-01 16:45 ` Charles H. Sampson
1995-01-23  8:49 R.A.L Williams
1995-01-25 23:18 ` Charles H. Sampson
1995-01-20  9:33 R.A.L Williams
     [not found] <3fgphd$sc3@rational.rational.com>
1995-01-20  5:51 ` RonaldS60
1995-02-07 13:55   ` Robert C. Soong
     [not found] <3fdcoi$chn@miranda.gmrc.gecm.com>
1995-01-20  5:01 ` Samuel Mize
1995-01-20 22:07   ` Garlington KE
1995-01-24  5:02     ` R_Tim_Coslet
     [not found] <3etund$hnr@miranda.gmrc.gecm.com>
1995-01-12  9:56 ` Erik Svensson
1995-01-12 14:44 ` Norman H. Cohen
1995-01-13  1:51 ` David O'Brien
1995-01-13 12:38   ` Laurent Gasser
1995-01-13 20:53     ` John DiCamillo
     [not found]       ` <3f8fnf$c8p@gamma.ois.com>
1995-01-16 11:02         ` Matt Kennel
     [not found]         ` <milodD2IFpG.329@netcom.com>
1995-01-17 21:39           ` R. William Beckwith
     [not found]       ` <3fa11q$sdh@gnat.cs.nyu.edu>
1995-01-16 20:20         ` David Moore
1995-01-14  0:24     ` David O'Brien
1995-01-20  4:43     ` Samuel Mize
1995-01-21 20:28       ` David O'Brien
1995-01-22 21:12         ` Robert Dewar
1995-01-23 18:35         ` Norman H. Cohen
1995-01-23 19:18         ` John Cosby - The Coz
1995-01-24 14:11         ` Samuel Mize
1995-01-14 10:37   ` Keith Thompson
     [not found]     ` <3fcjgt$b0v@cronkite.seas.gwu.edu>
1995-01-16 18:47       ` Robert Dewar
     [not found]   ` <D2It0r.4rp@inmet.camb.inmet.com>
1995-01-17 14:11     ` Norman H. Cohen
1994-12-30 16:06 Mitch Gart
1995-01-03 19:04 ` whiting_ms@corning.com (Matt Whiting)
1995-01-05  4:31   ` Michael Feldman
1995-01-04 21:40 ` Fred McCall
1995-01-05  4:30   ` Richard Pattis
1995-01-05 16:07   ` Kevin Weise
1995-01-06 13:06   ` Jahn Rentmeister
1995-01-06 16:47     ` Laurent Gasser
1995-01-06 17:29       ` David Weller
1995-01-06 17:30         ` David Weller
1995-01-10 18:28       ` Bob Kitzberger
1995-01-06 23:36   ` Kenneth Almquist
1995-01-04 22:45 ` Jay M. Martin
1995-01-05  4:37   ` Michael Feldman
1995-01-05 18:08     ` Jay Martin
1995-01-05 23:56       ` Robert Dewar
1995-01-08  8:04         ` Jay Martin
1995-01-06  0:07       ` Michael M. Bishop
1995-01-10 21:30         ` Jay Martin
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox