/* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ /* gos720 src/gos/2d/XTOP/contrib/programs/xditview/lex.c 1.2 */ /* */ /* Licensed Materials - Property of IBM */ /* */ /* COPYRIGHT International Business Machines Corp. 1996 */ /* All Rights Reserved */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /* */ /* IBM_PROLOG_END_TAG */ /* SCCSID_BEGIN_TAG */ #ifndef lint static char sccsid[] = "@(#)00 1.2 src/gos/2d/XTOP/contrib/programs/xditview/lex.c, xsample, gos720 12/9/96 15:10:16"; #endif /* SCCSID_END_TAG */ #define _ILS_MACROS #include #include #include #include #include #include "DviP.h" DviGetAndPut(dw, cp) DviWidget dw; int *cp; { if (dw->dvi.ungot) { dw->dvi.ungot = 0; *cp = getc (dw->dvi.file); } else { *cp = getc (dw->dvi.file); putc (*cp, dw->dvi.tmpFile); } return *cp; } char * GetLine(dw, Buffer, Length) DviWidget dw; char *Buffer; int Length; { int i = 0, c; char *p = Buffer; Length--; /* Save room for final NULL */ while (i < Length && DviGetC (dw, &c) != EOF && c != '\n') if (p) *p++ = c; if (c == '\n' && p) /* Retain the newline like fgets */ *p++ = c; if (c == '\n') DviUngetC(dw, c); if (p) *p = '\0'; return (Buffer); } char * GetWord(dw, Buffer, Length) DviWidget dw; char *Buffer; int Length; { int i = 0, c; char *p = Buffer; Length--; /* Save room for final NULL */ while (DviGetC(dw, &c) != EOF && isspace(c)) ; if (c != EOF) DviUngetC(dw, c); while (i < Length && DviGetC(dw, &c) != EOF && !isspace(c)) if (p) *p++ = c; if (c != EOF) DviUngetC(dw, c); if (p) *p = '\0'; return (Buffer); } GetNumber(dw) DviWidget dw; { int i = 0, c; while (DviGetC(dw, &c) != EOF && isspace(c)) ; if (c != EOF) DviUngetC(dw, c); while (DviGetC(dw, &c) != EOF && isdigit(c)) i = i*10 + c - '0'; if (c != EOF) DviUngetC(dw, c); return (i); }