home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / C / LEX.ZIP / LEXGET.C < prev    next >
Encoding:
C/C++ Source or Header  |  1984-02-06  |  718 b   |  36 lines

  1. /*
  2.  * lexget.c
  3.  *
  4.  * Bob Denny     28-Aug-82    Move stdio dependencies to lexerr(), lexget(),
  5.  *                            lexech() and mapch(). This is one of 4 modules
  6.  *                            in lexlib which depend upon the standard I/O package.
  7.  *
  8.  * Scott Guthery 20-Nov-83  Adapt for IBM PC & DeSmet C.  Endow DeSmet getc
  9.  *                            with ungetc capabilities.    
  10.  */
  11.  
  12. #include <stdio.h>
  13. #include <lex.h>
  14.  
  15. lexgetc()
  16. {
  17.         return(unix_getc(lexin));
  18. }
  19.  
  20. static char getbuf[30], *getbufptr = getbuf;
  21.  
  22. unix_getc(iop)
  23. FILE iop;
  24. {
  25.     if(getbufptr == getbuf)
  26.         return(getc(iop));
  27.     else
  28.         return(*--getbufptr);
  29. }
  30.  
  31. ungetc(c, iop)
  32. char c;
  33. FILE iop; /* WARNING: iop ignored ... ungetc's are multiplexed!!! */
  34. {
  35.     *getbufptr++ = c;
  36. }