home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / alde_c / misc / comm / yaccunx / ygtnm.4c < prev    next >
Encoding:
Text File  |  1983-12-25  |  580 b   |  30 lines

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