ack/lang/cem/cemcom.ansi/skip.c

84 lines
1.3 KiB
C
Raw Normal View History

1989-02-07 11:04:05 +00:00
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Header$ */
/* PREPROCESSOR: INPUT SKIP FUNCTIONS */
#include "nopp.h"
#include "arith.h"
#include "LLlex.h"
#include "class.h"
#include "input.h"
#ifndef NOPP
extern int InputLevel;
1989-02-07 11:04:05 +00:00
int
skipspaces(ch, skipnl)
register int ch;
{
/* skipspaces() skips any white space and returns the first
non-space character.
*/
register int nlseen = 0;
1989-02-07 11:04:05 +00:00
for (;;) {
while (class(ch) == STSKIP)
ch = GetChar();
if (skipnl && class(ch) == STNL) {
ch = GetChar();
LineNumber++;
nlseen++;
continue;
}
if (ch == TOKSEP && InputLevel) {
ch = GetChar();
1989-02-07 11:04:05 +00:00
continue;
}
/* \\\n are handled by trigraph */
if (ch == '/') {
ch = GetChar();
if (ch == '*' && !InputLevel) {
1989-02-07 11:04:05 +00:00
skipcomment();
ch = GetChar();
}
else {
UnGetChar();
return '/';
}
}
else if (nlseen && ch == '#') {
domacro();
ch = GetChar();
} else
1989-02-07 11:04:05 +00:00
return ch;
}
}
#endif NOPP
1989-10-18 13:12:31 +00:00
SkipToNewLine()
1989-02-07 11:04:05 +00:00
{
register int ch;
1989-10-18 13:12:31 +00:00
register int garbage = 0;
1989-02-07 11:04:05 +00:00
while ((ch = GetChar()) != '\n') {
#ifndef NOPP
1989-02-07 11:04:05 +00:00
if (ch == '/') {
if ((ch = GetChar()) == '*'
&& !InputLevel
) {
1989-02-07 11:04:05 +00:00
skipcomment();
continue;
}
}
#endif
1989-10-18 13:12:31 +00:00
if (!is_wsp(ch))
garbage = 1;
1989-02-07 11:04:05 +00:00
}
++LineNumber;
1989-10-18 13:12:31 +00:00
return garbage;
1989-02-07 11:04:05 +00:00
}