X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fdictionary%2Fsys-file-info.c;h=f719ba2fb1e8c0b9e508c49017fc0f3811120faa;hb=f23643cfa3b4c6b9a5fe0cd890a8d1b7240a8552;hp=2fdbdaf3c2a1609107bbb1ff9e81325407978555;hpb=14f4522a17db23e67a6fa17876633cc6260cb42b;p=pspp diff --git a/src/language/dictionary/sys-file-info.c b/src/language/dictionary/sys-file-info.c index 2fdbdaf3c2..f719ba2fb1 100644 --- a/src/language/dictionary/sys-file-info.c +++ b/src/language/dictionary/sys-file-info.c @@ -73,21 +73,50 @@ cmd_sysfile_info (struct lexer *lexer, struct dataset *ds UNUSED) struct tab_table *t; struct casereader *reader; struct sfm_read_info info; + char *encoding; int r, i; - lex_match_id (lexer, "FILE"); - lex_match (lexer, T_EQUALS); + h = NULL; + encoding = NULL; + for (;;) + { + lex_match (lexer, T_SLASH); - h = fh_parse (lexer, FH_REF_FILE, NULL); - if (!h) - return CMD_FAILURE; + if (lex_match_id (lexer, "FILE") || lex_is_string (lexer)) + { + lex_match (lexer, T_EQUALS); - reader = sfm_open_reader (h, NULL, &d, &info); - if (!reader) + fh_unref (h); + h = fh_parse (lexer, FH_REF_FILE, NULL); + if (h == NULL) + goto error; + } + else if (lex_match_id (lexer, "ENCODING")) + { + lex_match (lexer, T_EQUALS); + + if (!lex_force_string (lexer)) + goto error; + + free (encoding); + encoding = ss_xstrdup (lex_tokss (lexer)); + + lex_get (lexer); + } + else + break; + } + + if (h == NULL) { - fh_unref (h); - return CMD_FAILURE; + lex_sbc_missing ("FILE"); + goto error; } + + reader = sfm_open_reader (h, encoding, &d, &info); + if (!reader) + goto error; + casereader_destroy (reader); t = tab_create (2, 11 + (info.product_ext != NULL)); @@ -184,6 +213,11 @@ cmd_sysfile_info (struct lexer *lexer, struct dataset *ds UNUSED) fh_unref (h); sfm_read_info_destroy (&info); return CMD_SUCCESS; + +error: + fh_unref (h); + free (encoding); + return CMD_FAILURE; } /* DISPLAY utility. */