#include "misc/strerror.c"
#endif
-#undef DEBUGGING
-/*#define DEBUGGING 1*/
#include "debug-print.h"
/* Max length of an input line. */
char nullstr[] = "";
/* Close all open files and delete the output file, on failure. */
-void
+static void
finish_up (void)
{
if (!is_open)
/* Allocate a block of SIZE bytes and return a pointer to its
beginning. */
-void *
+static void *
xmalloc (size_t size)
{
void *vp;
vp = malloc (size);
if (!vp)
- {
-#if DEBUGGING && __CHECKER__
- error ("xmalloc(%lu): Inducing segfault.", (unsigned long) size);
- *((int *) 0) = 0;
-#endif
- fail ("xmalloc(%lu): %s", (unsigned long) size, VME);
- }
-
- return vp;
-}
-
-/* Resize the block at PTR to size SIZE and return a pointer to the
- beginning of the new block. */
-void *
-xrealloc (void *ptr, size_t size)
-{
- void *vp;
-
- if (!size)
- {
- if (ptr)
- free (ptr);
- return NULL;
- }
-
- if (ptr)
- vp = realloc (ptr, size);
- else
- vp = malloc (size);
-
- if (!vp)
- fail ("xrealloc(%lu): %s", (unsigned long) size, VME);
+ fail ("xmalloc(%lu): %s", (unsigned long) size, VME);
return vp;
}
/* Make a dynamically allocated copy of string S and return a pointer
to the first character. */
-char *
+static char *
xstrdup (const char *s)
{
size_t size;
/* Returns a pointer to one of 8 static buffers. The buffers are used
in rotation. */
-char *
+static char *
get_buffer (void)
{
static char b[8][256];
/* Copies a string to a static buffer, converting it to lowercase in
the process, and returns a pointer to the static buffer. */
-char *
+static char *
st_lower (const char *s)
{
char *p, *cp;
/* Copies a string to a static buffer, converting it to uppercase in
the process, and returns a pointer to the static buffer. */
-char *
+static char *
st_upper (const char *s)
{
char *p, *cp;
/* Returns the address of the first non-whitespace character in S, or
the address of the null terminator if none. */
-char *
+static char *
skip_ws (const char *s)
{
while (isspace ((unsigned char) *s))
/* Read one line from the input file into buf. Lines having special
formats are handled specially. */
-int
+static int
get_line (void)
{
ln++;
in the symbol table, its sequence number is returned and the symbol
table is not modified. Otherwise, the symbol is added and the next
available sequence number is returned. */
-int
+static int
add_symbol (const char *name, int unique, int value)
{
symbol *iter, *sym;
/* Finds the symbol having given sequence number X within the symbol
table, and returns the associated symbol structure. */
-symbol *
+static symbol *
find_symbol (int x)
{
symbol *iter;
#endif /* DEBUGGING */
/* Reads a token from the input file. */
-int
+static int
lex_get (void)
{
/* Skip whitespace and check for end of file. */
}
/* Force the current token to be an identifier token. */
-void
+static void
force_id (void)
{
if (token != T_ID)
}
/* Force the current token to be a string token. */
-void
+static void
force_string (void)
{
if (token != T_STRING)
/* Checks whether the current token is the identifier S; if so, skips
the token and returns 1; otherwise, returns 0. */
-int
+static int
match_id (const char *s)
{
if (token == T_ID && !strcmp (tokstr, s))
/* Checks whether the current token is T. If so, skips the token and
returns 1; otherwise, returns 0. */
-int
+static int
match_token (int t)
{
if (token == t)
}
/* Force the current token to be T, and skip it. */
-void
+static void
skip_token (int t)
{
if (token != t)
void parse_subcommands (void);
/* Parse an entire specification. */
-void
+static void
parse (void)
{
/* Get the command name and prefix. */
/* Parses a single setting into S, given subcommand information SBC
and specifier information SPEC. */
-void
+static void
parse_setting (setting *s, specifier *spec)
{
s->parent = spec;
/* Parse a single specifier into SPEC, given subcommand information
SBC. */
-void
+static void
parse_specifier (specifier *spec, subcommand *sbc)
{
spec->index = 0;
}
/* Parse a list of specifiers for subcommand SBC. */
-void
+static void
parse_specifiers (subcommand *sbc)
{
specifier **spec = &sbc->spec;
}
/* Parse a subcommand into SBC. */
-void
+static void
parse_subcommand (subcommand *sbc)
{
if (match_token ('*'))
/* Write the structure members for specifier SPEC to the output file.
SBC is the including subcommand. */
-void
+static void
dump_specifier_vars (const specifier *spec, const subcommand *sbc)
{
if (spec->varname)
}
/* Returns 1 if string T is a PSPP keyword, 0 otherwise. */
-int
+static int
is_keyword (const char *t)
{
static const char *kw[] =
/* Transforms a string NAME into a valid C identifier: makes
everything lowercase and maps nonalphabetic characters to
underscores. Returns a pointer to a static buffer. */
-char *
+static char *
make_identifier (const char *name)
{
char *p = get_buffer ();
}
/* Writes the struct and enum declarations for the parser. */
-void
+static void
dump_declarations (void)
{
indent = 0;
/* Writes out code to initialize all the variables that need
initialization for particular specifier SPEC inside subcommand SBC. */
-void
+static void
dump_specifier_init (const specifier *spec, const subcommand *sbc)
{
if (spec->varname)
}
/* Write code to initialize all variables. */
-void
+static void
dump_vars_init (void)
{
/* Loop through all the subcommands. */
/* Return a pointer to a static buffer containing an expression that
will match token T. */
-char *
+static char *
make_match (const char *t)
{
char *s;
/* Write out the parsing code for specifier SPEC within subcommand
SBC. */
-void
+static void
dump_specifier_parse (const specifier *spec, const subcommand *sbc)
{
setting *s;
}
/* Write out the code to parse subcommand SBC. */
-void
+static void
dump_subcommand (const subcommand *sbc)
{
if (sbc->type == SBC_PLAIN || sbc->type == SBC_ARRAY)
}
else if (sbc->type == SBC_VARLIST)
{
- dump (1, "if (!parse_variables (NULL, &p->%sv_%s, &p->%sn_%s, "
+ dump (1, "if (!parse_variables (default_dict, &p->%sv_%s, &p->%sn_%s, "
"PV_APPEND%s%s))",
st_lower (sbc->prefix), st_lower (sbc->name),
st_lower (sbc->prefix), st_lower (sbc->name),
}
/* Write out entire parser. */
-void
+static void
dump_parser (void)
{
int f;
if (def && (def->type == SBC_VARLIST))
{
if (def->type == SBC_VARLIST)
- dump (1, "if (token == T_ID && is_varname (tokid) && "
- "lex_look_ahead () != '=')");
+ dump (1, "if (token == T_ID "
+ "&& dict_lookup_var (default_dict, tokid) != NULL "
+ "&& lex_look_ahead () != '=')");
else
{
- dump (0, "if ((token == T_ID && is_varname (tokid) && "
- "lex_look_ahead () != '=')");
+ dump (0, "if ((token == T_ID "
+ "&& dict_lookup_var (default_dict, tokid) "
+ "&& lex_look_ahead () != '=')");
dump (1, " || token == T_ALL)");
}
dump (1, "{");
dump (0, "p->sbc_%s++;", st_lower (def->name));
- dump (1, "if (!parse_variables (NULL, &p->%sv_%s, &p->%sn_%s, "
+ dump (1, "if (!parse_variables (default_dict, &p->%sv_%s, &p->%sn_%s, "
"PV_APPEND))",
st_lower (def->prefix), st_lower (def->name),
st_lower (def->prefix), st_lower (def->name));
}
/* Write the output file header. */
-void
+static void
dump_header (void)
{
time_t curtime;
}
/* Write out commands to free variable state. */
-void
+static void
dump_free (void)
{
subcommand *sbc;
/* Returns the name of a directive found on the current input line, if
any, or a null pointer if none found. */
-const char *
+static const char *
recognize_directive (void)
{
static char directive[16];