X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Flexer%2Fq2c.c;h=a62cf9171b30442fdc5adb4ebe2d075a76425b24;hb=18f6e8958244f938e9e9a03a4230cacf0d22a470;hp=9e8af0a246998d55babd943e2a6de952b8de52be;hpb=a19b858e0ac3c69e4a28c0ca6d8674427268a863;p=pspp diff --git a/src/language/lexer/q2c.c b/src/language/lexer/q2c.c index 9e8af0a246..a62cf9171b 100644 --- a/src/language/lexer/q2c.c +++ b/src/language/lexer/q2c.c @@ -26,25 +26,12 @@ #include #include #include -#if HAVE_UNISTD_H #include -#endif #include #include - - -/* Brokenness. */ -#ifndef EXIT_SUCCESS -#define EXIT_SUCCESS 0 -#endif - -#ifndef EXIT_FAILURE -#define EXIT_FAILURE 1 -#endif +#include "exit.h" -#include - /* Max length of an input line. */ #define MAX_LINE_LEN 1024 @@ -338,7 +325,7 @@ find_symbol (int x) return iter; } -#if DEBUGGING +#if DUMP_TOKENS /* Writes a printable representation of the current token to stdout. */ static void @@ -356,7 +343,7 @@ dump_token (void) printf ("PUNCT\t%c\n", token); } } -#endif /* DEBUGGING */ +#endif /* DUMP_TOKENS */ /* Reads a token from the input file. */ static int @@ -406,7 +393,7 @@ lex_get (void) else token = *cp++; -#if DEBUGGING +#if DUMP_TOKENS dump_token (); #endif @@ -1190,7 +1177,7 @@ dump_declarations (void) 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)); } @@ -1202,7 +1189,7 @@ dump_declarations (void) /* 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)); @@ -1637,7 +1624,7 @@ dump_subcommand (const subcommand *sbc) 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) @@ -1709,7 +1696,7 @@ dump_subcommand (const subcommand *sbc) } 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:"); @@ -1738,7 +1725,8 @@ dump_parser (int persistent) 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, "{"); @@ -1774,7 +1762,7 @@ dump_parser (int persistent) } 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:"); @@ -1944,9 +1932,11 @@ dump_free (int persistent) 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: @@ -2043,6 +2033,7 @@ main (int argc, char *argv[]) dump (0, "#include "); dump (0, "#include "); dump (0, "#include "); + dump (0, "#include "); dump (0, "#include "); dump (0, "#include "); dump (0, "#include ");