/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1999-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* tmscan(3) tmfmt(3) tester
*
* testdate [-c] [-v] < testre.dat
*
* -c catch signals and non-terminating tmscan()
* -v list each test line
*
* see comments in testdate.dat for description of format
*/
#include <ast.h>
#include <ctype.h>
#include <setjmp.h>
#include <signal.h>
#include <tm.h>
#ifdef __STDC__
#include <stdlib.h>
#endif
#ifndef NiL
#ifdef __STDC__
#define NiL 0
#else
#define NiL (char*)0
#endif
#endif
#ifndef elementsof
#define elementsof(x) (sizeof(x)/sizeof(x[0]))
#endif
#ifndef streq
#endif
static struct
{
int errors;
int lineno;
int sig;
int signals;
int warnings;
} state;
static void
normal(char* s)
{
unsigned char* u = (unsigned char*)s;
int c;
if (!u)
else if (!*u)
else for (;;)
switch (c = *u++)
{
case 0:
return;
case '\n':
break;
case '\r':
break;
case '\t':
break;
default:
if (isprint(c))
else
break;
}
}
static void
{
if (str)
{
if (pat)
{
}
}
if (flags & TM_PEDANTIC)
{
}
{
if (*rem == '\n')
{
if (comment)
{
comment = 0;
}
}
else
{
}
}
if (comment)
}
static void
{
exit(1);
}
static int
hex(int c)
{
}
static void
escape(char* s)
{
char* t;
for (t = s; *t = *s; s++, t++)
{
if (*s != '\\')
continue;
switch (*++s)
{
case 0:
*++t = 0;
break;
case 'n':
*t = '\n';
break;
case 'r':
*t = '\r';
break;
case 't':
*t = '\t';
break;
case 'x':
*t = hex(*++s) << 4;
*t |= hex(*++s);
break;
default:
s--;
break;
}
}
}
static void
sigunblock(int s)
{
#ifdef SIG_SETMASK
int op;
sigemptyset(&mask);
if (s)
{
op = SIG_UNBLOCK;
}
else
op = SIG_SETMASK;
#else
#ifdef sigmask
#endif
#endif
}
static void
{
alarm(0);
}
int
{
int i;
long flags;
char* p;
char* s;
char* e;
char* f;
char* str;
char* fmt;
char* ans;
int catch = 0;
int testno = 0;
int verbose = 0;
while ((p = *++argv) && *p == '-')
for (;;)
{
switch (*++p)
{
case 0:
break;
case 'c':
catch = 1;
continue;
case 'v':
verbose = 1;
continue;
default:
continue;
}
break;
}
if (p)
if (catch)
{
}
{
/* parse: */
if (*p == 0 || *p == '#')
continue;
if (*p == ':')
{
while (*++p == ' ');
continue;
}
i = 0;
field[i++] = p;
for (;;)
{
switch (*p++)
{
case 0:
p--;
goto checkfield;
case '\t':
*(p - 1) = 0;
s = field[i - 1];
if (streq(s, "NIL"))
field[i - 1] = 0;
else if (streq(s, "NULL"))
*s = 0;
while (*p == '\t')
p++;
if (!*p)
break;
if (i >= elementsof(field))
field[i++] = p;
/*FALLTHROUGH*/
default:
continue;
}
break;
}
/* interpret: */
if (i < 3)
while (i < elementsof(field))
field[i++] = 0;
if (str)
{
{
if (!fmt)
{
if (*e)
}
else
continue;
}
{
str = 0;
if (!fmt)
{
continue;
}
if (*e)
}
}
flags = 0;
if (verbose)
if (!str)
{
testno++;
continue;
}
if (*e)
{
testno++;
}
else for (;;)
{
testno++;
if (*e)
{
break;
}
else if (*f)
{
break;
}
{
int n;
break;
}
if (flags & TM_PEDANTIC)
break;
flags |= TM_PEDANTIC;
}
}
return 0;
}