better error checking

This commit is contained in:
ceriel
1989-12-07 16:28:05 +00:00
parent 4724283d0f
commit 0795da732f
2 changed files with 21 additions and 10 deletions

View File

@@ -9,8 +9,8 @@ symbol2str(tok)
{
#define SIZBUF 8
/* allow for a few invocations in f.i. an argument list */
static char buf[SIZBUF];
static int index;
static char buf[SIZBUF] = { '\'', 0, '\'', 0, '\'', 0, '\'', 0};
static int index = 1;
switch (tok) {
--EOT--
@@ -27,15 +27,9 @@ cat <<'--EOT--'
if (tok < 040 || tok >= 0177) {
return "bad token";
}
/* fall through */
case '\n':
case '\f':
case '\v':
case '\r':
case '\t':
index = (index+2) & (SIZBUF-1);
index = (index+4) & (SIZBUF-1);
buf[index] = tok;
return &buf[index];
return &buf[index-1];
}
}
--EOT--