X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Flexer%2Fq2c.c;h=f503730f1059a09504ac22f4d9b0e90283c939b8;hb=c708736bdd0fea4b79f3ee4a10e00c3abb95d9e3;hp=df6f5d9f3998443474fd0ef403da90c56ec6d2db;hpb=82a9572a7a0ec2f7fc572cc9807bc5205a5e8a8d;p=pspp-builds.git diff --git a/src/language/lexer/q2c.c b/src/language/lexer/q2c.c index df6f5d9f..f503730f 100644 --- a/src/language/lexer/q2c.c +++ b/src/language/lexer/q2c.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include "exit.h" @@ -42,7 +43,7 @@ char *program_name; /* Have the input and output files been opened yet? */ -int is_open; +bool is_open; /* Input, output files. */ FILE *in, *out; @@ -79,7 +80,7 @@ finish_up (void) { if (!is_open) return; - is_open = 0; + is_open = false; fclose (in); fclose (out); if (remove (ofn) == -1) @@ -224,7 +225,7 @@ skip_ws (const char *s) /* Read one line from the input file into buf. Lines having special formats are handled specially. */ -static int +static bool get_line (void) { ln++; @@ -232,7 +233,7 @@ get_line (void) { if (ferror (in)) fail ("%s: fgets: %s", ifn, strerror (errno)); - return 0; + return false; } cp = strchr (buf, '\n'); @@ -240,7 +241,7 @@ get_line (void) *cp = '\0'; cp = buf; - return 1; + return true; } /* Symbol table manager. */ @@ -417,29 +418,29 @@ force_string (void) } /* Checks whether the current token is the identifier S; if so, skips - the token and returns 1; otherwise, returns 0. */ -static int + the token and returns true; otherwise, returns false. */ +static bool match_id (const char *s) { if (token == T_ID && !strcmp (tokstr, s)) { lex_get (); - return 1; + return true; } - return 0; + return false; } /* Checks whether the current token is T. If so, skips the token and - returns 1; otherwise, returns 0. */ -static int + returns true; otherwise, returns false. */ +static bool match_token (int t) { if (token == t) { lex_get (); - return 1; + return true; } - return 0; + return false; } /* Force the current token to be T, and skip it. */ @@ -947,8 +948,8 @@ dump_specifier_vars (const specifier *spec, const subcommand *sbc) } } -/* Returns 1 if string T is a PSPP keyword, 0 otherwise. */ -static int +/* Returns true if string T is a PSPP keyword, false otherwise. */ +static bool is_keyword (const char *t) { static const char *kw[] = @@ -960,8 +961,8 @@ is_keyword (const char *t) for (cp = kw; *cp; cp++) if (!strcmp (t, *cp)) - return 1; - return 0; + return true; + return false; } /* Transforms a string NAME into a valid C identifier: makes @@ -1164,7 +1165,7 @@ dump_declarations (void) /* Write out prototypes for custom_*() functions as necessary. */ { - int seen = 0; + bool seen = false; subcommand *sbc; for (sbc = subcommands; sbc; sbc = sbc->next) @@ -1172,7 +1173,7 @@ dump_declarations (void) { if (!seen) { - seen = 1; + seen = true; dump (0, "/* Prototype for custom subcommands of %s. */", cmdname); } @@ -1321,7 +1322,7 @@ dump_vars_init (int persistent) break; default: - assert (0); + NOT_REACHED (); } } } @@ -1609,7 +1610,7 @@ dump_subcommand (const subcommand *sbc) dump (0, "int x;"); } dump (1, "if (!lex_force_string ())"); - dump (0, "return 0;"); + dump (0, "return false;"); outdent (); if (sbc->restriction) { @@ -1709,7 +1710,7 @@ dump_subcommand (const subcommand *sbc) dump (0, "goto lossage;"); dump (-1, "default:"); indent (); - dump (0, "assert (0);"); + dump (0, "NOT_REACHED ();"); dump (-1, "}"); outdent (); } @@ -1775,7 +1776,7 @@ dump_parser (int persistent) dump (0, "break;"); dump (-1, "default:"); indent (); - dump (0, "assert (0);"); + dump (0, "NOT_REACHED ();"); dump (-1, "}"); outdent (); } @@ -1859,12 +1860,12 @@ dump_parser (int persistent) } } - dump (-1, "return 1;"); + dump (-1, "return true;"); dump (0, nullstr); dump (-1, "lossage:"); indent (); dump (0, "free_%s (p);", make_identifier (cmdname)); - dump (0, "return 0;"); + dump (0, "return false;"); dump (-1, "}"); dump (0, nullstr); } @@ -1994,7 +1995,7 @@ main (int argc, char *argv[]) if (!out) fail ("%s: open: %s.", ofn, strerror (errno)); - is_open = 1; + is_open = true; buf = xmalloc (MAX_LINE_LEN); tokstr = xmalloc (MAX_TOK_LEN); @@ -2030,6 +2031,7 @@ main (int argc, char *argv[]) dump (0, "#include "); dump (0, "#include "); + dump (0, "#include "); dump (0, "#include "); dump (0, "#include "); dump (0, "#include ");