home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / program / c / yaccsrc2 / ygtnm.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-19  |  717 b   |  40 lines

  1.  
  2. # include "y4.h"    
  3. # include <ctype.h> 
  4.  
  5. int gtnm( )
  6. {
  7.  
  8.   register s,
  9.            val,
  10.            c;
  11.  
  12.   /* read and convert an integer from the standard input */
  13.   /* return the terminating character */
  14.   /* blanks, tabs, and newlines are ignored */
  15.  
  16.   s       = 1;
  17.   val     = 0;
  18.  
  19.   while ( ( c = unix_getc( finput ) ) != EOF )
  20.     {
  21.       if ( isdigit( c ) )
  22.         {
  23.           val = val * 10 + c - '0';
  24.         }
  25.       else
  26.         if ( c == '-' )
  27.           s = -1;
  28.         else
  29.           if ( c == '\r' )
  30.             continue ;
  31.           else
  32.             break ;
  33.     }
  34.   *pmem++ = s * val;
  35.   if ( pmem > &mem0[ MEMSIZE ] )
  36.     error( "out of space" );
  37.   return ( c );
  38.  
  39. }
  40.