Run through clang-format before editing.

This commit is contained in:
David Given 2018-09-02 11:49:40 +02:00
parent dd00b81080
commit 274ed3cb6a
2 changed files with 96 additions and 59 deletions

View file

@ -5,55 +5,61 @@
/* $Id$ */ /* $Id$ */
/* PREPROCESSOR: INPUT SKIP FUNCTIONS */ /* PREPROCESSOR: INPUT SKIP FUNCTIONS */
#include "parameters.h" #include "parameters.h"
#include "arith.h" #include "arith.h"
#include "LLlex.h" #include "LLlex.h"
#include "class.h" #include "class.h"
#include "input.h" #include "input.h"
#ifndef NOPP #ifndef NOPP
extern int InputLevel; extern int InputLevel;
int int skipspaces(ch, skipnl) register int ch;
skipspaces(ch, skipnl)
register int ch;
{ {
/* skipspaces() skips any white space and returns the first /* skipspaces() skips any white space and returns the first
non-space character. non-space character.
*/ */
register int nlseen = 0; register int nlseen = 0;
for (;;) { for (;;)
{
while (class(ch) == STSKIP) while (class(ch) == STSKIP)
ch = GetChar(); ch = GetChar();
if (skipnl && class(ch) == STNL) { if (skipnl && class(ch) == STNL)
{
ch = GetChar(); ch = GetChar();
LineNumber++; LineNumber++;
nlseen++; nlseen++;
continue; continue;
} }
if (ch == TOKSEP && InputLevel) { if (ch == TOKSEP && InputLevel)
{
ch = GetChar(); ch = GetChar();
continue; continue;
} }
/* \\\n are handled by trigraph */ /* \\\n are handled by trigraph */
if (ch == '/') { if (ch == '/')
{
ch = GetChar(); ch = GetChar();
if (ch == '*' && !InputLevel) { if (ch == '*' && !InputLevel)
{
skipcomment(); skipcomment();
ch = GetChar(); ch = GetChar();
} }
else { else
{
UnGetChar(); UnGetChar();
return '/'; return '/';
} }
} }
else if (nlseen && ch == '#') { else if (nlseen && ch == '#')
{
domacro(); domacro();
ch = GetChar(); ch = GetChar();
} else }
else
return ch; return ch;
} }
} }
@ -63,41 +69,52 @@ SkipToNewLine()
{ {
register int ch; register int ch;
register int garbage = 0; register int garbage = 0;
#ifndef NOPP #ifndef NOPP
register int delim = 0; register int delim = 0;
#endif #endif
while ((ch = GetChar()) != '\n') { while ((ch = GetChar()) != '\n')
{
#ifndef NOPP #ifndef NOPP
if (delim) { if (delim)
if (ch == '\\') { {
if (GetChar() == '\n') break; if (ch == '\\')
} else if (ch == delim) { {
if (GetChar() == '\n')
break;
}
else if (ch == delim)
{
delim = 0; delim = 0;
} }
continue; continue;
} }
else if (ch == '\'' || ch == '\"') { else if (ch == '\'' || ch == '\"')
{
delim = ch; delim = ch;
garbage = 1; garbage = 1;
} else if (ch == '/') { }
if (GetChar() == '*' else if (ch == '/')
&& !InputLevel {
) { if (GetChar() == '*' && !InputLevel)
{
skipcomment(); skipcomment();
continue; continue;
} }
else UnGetChar(); else
UnGetChar();
} }
else if (ch == TOKSEP && InputLevel) { else if (ch == TOKSEP && InputLevel)
{
continue; continue;
} }
#endif #endif
if (!is_wsp(ch)) if (!is_wsp(ch))
garbage = 1; garbage = 1;
} }
#ifndef NOPP #ifndef NOPP
if (delim) strict("unclosed opening %c", delim); if (delim)
strict("unclosed opening %c", delim);
#endif #endif
++LineNumber; ++LineNumber;
return garbage; return garbage;

View file

@ -5,53 +5,59 @@
/* $Id$ */ /* $Id$ */
/* PREPROCESSOR: INPUT SKIP FUNCTIONS */ /* PREPROCESSOR: INPUT SKIP FUNCTIONS */
#include "arith.h" #include "arith.h"
#include "LLlex.h" #include "LLlex.h"
#include "class.h" #include "class.h"
#include "input.h" #include "input.h"
extern int InputLevel; extern int InputLevel;
int int skipspaces(ch, skipnl) register int ch;
skipspaces(ch, skipnl)
register int ch;
{ {
/* skipspaces() skips any white space and returns the first /* skipspaces() skips any white space and returns the first
non-space character. non-space character.
*/ */
register int nlseen = 0; register int nlseen = 0;
for (;;) { for (;;)
{
while (class(ch) == STSKIP) while (class(ch) == STSKIP)
ch = GetChar(); ch = GetChar();
if (skipnl && class(ch) == STNL) { if (skipnl && class(ch) == STNL)
{
ch = GetChar(); ch = GetChar();
LineNumber++; LineNumber++;
nlseen++; nlseen++;
continue; continue;
} }
if (ch == TOKSEP && InputLevel) { if (ch == TOKSEP && InputLevel)
{
ch = GetChar(); ch = GetChar();
continue; continue;
} }
/* \\\n are handled by trigraph */ /* \\\n are handled by trigraph */
if (ch == '/') { if (ch == '/')
{
ch = GetChar(); ch = GetChar();
if (ch == '*' && !InputLevel) { if (ch == '*' && !InputLevel)
{
skipcomment(); skipcomment();
ch = GetChar(); ch = GetChar();
} }
else { else
{
UnGetChar(); UnGetChar();
return '/'; return '/';
} }
} }
else if (nlseen && ch == '#') { else if (nlseen && ch == '#')
{
domacro(); domacro();
ch = GetChar(); ch = GetChar();
} else }
else
return ch; return ch;
} }
} }
@ -62,31 +68,45 @@ SkipToNewLine()
register int garbage = 0; register int garbage = 0;
register int delim = 0; register int delim = 0;
while ((ch = GetChar()) != '\n') { while ((ch = GetChar()) != '\n')
if (delim) { {
if (ch == '\\') { if (delim)
if (GetChar() == '\n') break; {
} else if (ch == delim) { if (ch == '\\')
{
if (GetChar() == '\n')
break;
}
else if (ch == delim)
{
delim = 0; delim = 0;
} }
continue; continue;
} else if (ch == '\'' || ch == '\"') { }
else if (ch == '\'' || ch == '\"')
{
delim = ch; delim = ch;
garbage = 1; garbage = 1;
} else if (ch == '/') { }
if (GetChar() == '*' && !InputLevel) { else if (ch == '/')
{
if (GetChar() == '*' && !InputLevel)
{
skipcomment(); skipcomment();
continue; continue;
} }
else UnGetChar(); else
UnGetChar();
} }
else if (ch == TOKSEP && InputLevel) { else if (ch == TOKSEP && InputLevel)
{
continue; continue;
} }
if (!is_wsp(ch)) if (!is_wsp(ch))
garbage = 1; garbage = 1;
} }
if (delim) strict("unclosed opening %c", delim); if (delim)
strict("unclosed opening %c", delim);
++LineNumber; ++LineNumber;
return garbage; return garbage;
} }