X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Finclude.c;h=3ea80ef04b352926d1dc7295da2824b592d04f70;hb=29c51e39acf3554a56aa2adc9451cc5fd70318ae;hp=78557bdd3777c07141369ee543a31a3c218af80f;hpb=4944c86a9318bc5b5578ab145a95c116ffd2c9fd;p=pspp-builds.git diff --git a/src/include.c b/src/include.c index 78557bdd..3ea80ef0 100644 --- a/src/include.c +++ b/src/include.c @@ -28,48 +28,19 @@ #include "str.h" int -cmd_include_at (void) +cmd_include (void) { - char *incfn, *s, *bp, *ep; - - s = bp = lex_entire_line (); - while (isspace ((unsigned char) *bp)) - bp++; - bp++; /* skip `@' */ - while (isspace ((unsigned char) *bp)) - bp++; - if (*bp == '\'') - bp++; - - ep = bp + strlen (bp); - while (isspace ((unsigned char) *--ep)); - if (*ep != '\'') - ep++; + /* Skip optional FILE=. */ + if (lex_match_id ("FILE")) + lex_match ('='); - if (ep <= bp) + /* Filename can be identifier or string. */ + if (token != T_ID && token != T_STRING) { - msg (SE, _("Unrecognized filename format.")); + lex_error (_("expecting filename")); return CMD_FAILURE; } - - /* Now the filename is trapped between bp and ep. */ - incfn = xmalloc (ep - bp + 1); - strncpy (incfn, bp, ep - bp); - incfn[ep - bp] = 0; - getl_include (incfn); - free (incfn); - - return CMD_SUCCESS; -} - -int -cmd_include (void) -{ - lex_get (); - - if (!lex_force_string ()) - return CMD_SUCCESS; - getl_include (ds_value (&tokstr)); + getl_include (ds_c_str (&tokstr)); lex_get (); return lex_end_of_command ();