#include <stdarg.h>
#include <time.h>
#include <errno.h>
-#if HAVE_UNISTD_H
#include <unistd.h>
-#endif
#include <libpspp/compiler.h>
#include <libpspp/str.h>
-
-
-/* Brokenness. */
-#ifndef EXIT_SUCCESS
-#define EXIT_SUCCESS 0
-#endif
-
-#ifndef EXIT_FAILURE
-#define EXIT_FAILURE 1
-#endif
+#include "exit.h"
-#include <libpspp/debug-print.h>
-
/* Max length of an input line. */
#define MAX_LINE_LEN 1024
return iter;
}
-#if DEBUGGING
+#if DUMP_TOKENS
/* Writes a printable representation of the current token to
stdout. */
static void
printf ("PUNCT\t%c\n", token);
}
}
-#endif /* DEBUGGING */
+#endif /* DUMP_TOKENS */
/* Reads a token from the input file. */
static int
else
token = *cp++;
-#if DEBUGGING
+#if DUMP_TOKENS
dump_token ();
#endif
dump (0, "/* Prototype for custom subcommands of %s. */",
cmdname);
}
- dump (0, "static int %scustom_%s (struct cmd_%s *);",
+ dump (0, "static int %scustom_%s (struct cmd_%s *, void *);",
st_lower (prefix), st_lower (sbc->name),
make_identifier (cmdname));
}
/* Prototypes for parsing and freeing functions. */
{
dump (0, "/* Command parsing functions. */");
- dump (0, "static int parse_%s (struct cmd_%s *);",
+ dump (0, "static int parse_%s (struct cmd_%s *, void *);",
make_identifier (cmdname), make_identifier (cmdname));
dump (0, "static void free_%s (struct cmd_%s *);",
make_identifier (cmdname), make_identifier (cmdname));
outdent ();
}
dump (0, "free(p->s_%s);", st_lower(sbc->name) );
- dump (0, "p->s_%s = xstrdup (ds_c_str (&tokstr));",
+ dump (0, "p->s_%s = ds_xstrdup (&tokstr);",
st_lower (sbc->name));
dump (0, "lex_get ();");
if (sbc->restriction)
}
else if (sbc->type == SBC_CUSTOM)
{
- dump (1, "switch (%scustom_%s (p))",
+ dump (1, "switch (%scustom_%s (p, aux))",
st_lower (prefix), st_lower (sbc->name));
dump (0, "{");
dump (1, "case 0:");
indent = 0;
dump (0, "static int");
- dump (0, "parse_%s (struct cmd_%s *p)", make_identifier (cmdname),
+ dump (0, "parse_%s (struct cmd_%s *p, void *aux UNUSED)",
+ make_identifier (cmdname),
make_identifier (cmdname));
dump (1, "{");
}
else if (def && def->type == SBC_CUSTOM)
{
- dump (1, "switch (%scustom_%s (p))",
+ dump (1, "switch (%scustom_%s (p, aux))",
st_lower (prefix), st_lower (def->name));
dump (0, "{");
dump (1, "case 0:");
dump (0, "free (p->s_%s);", st_lower (sbc->name));
break;
case SBC_DBL_LIST:
- dump (0, "int i;");
- dump (1, "for(i = 0; i < MAXLISTS ; ++i)");
- dump (0, "subc_list_double_destroy(&p->dl_%s[i]);", st_lower (sbc->name));
+ dump (0, "{");
+ dump (1, "int i;");
+ dump (2, "for(i = 0; i < MAXLISTS ; ++i)");
+ dump (1, "subc_list_double_destroy(&p->dl_%s[i]);", st_lower (sbc->name));
+ dump (0, "}");
outdent();
break;
default:
dump (0, "#include <libpspp/alloc.h>");
dump (0, "#include <libpspp/message.h>");
dump (0, "#include <language/lexer/lexer.h>");
+ dump (0, "#include <language/lexer/variable-parser.h>");
dump (0, "#include <data/settings.h>");
dump (0, "#include <libpspp/str.h>");
dump (0, "#include <language/lexer/subcommand-list.h>");