From: John Darrington Date: Fri, 1 Apr 2016 10:16:15 +0000 (+0200) Subject: Check the return value of various calls to lex_force_match. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7635ce0697c163bd9c80adb8b382df7a9aa97f42;p=pspp Check the return value of various calls to lex_force_match. --- diff --git a/src/language/data-io/get-data.c b/src/language/data-io/get-data.c index 9d1e28100e..e3a93b1738 100644 --- a/src/language/data-io/get-data.c +++ b/src/language/data-io/get-data.c @@ -88,7 +88,8 @@ cmd_get_data (struct lexer *lexer, struct dataset *ds) opts.read_names = false; opts.asw = -1; - lex_force_match (lexer, T_SLASH); + if (! lex_force_match (lexer, T_SLASH)) + goto error; if (!lex_force_match_id (lexer, "TYPE")) goto error; @@ -160,12 +161,14 @@ parse_get_psql (struct lexer *lexer, struct dataset *ds) psql.bsize = -1; ds_init_empty (&psql.sql); - lex_force_match (lexer, T_SLASH); + if (! lex_force_match (lexer, T_SLASH)) + goto error; if (!lex_force_match_id (lexer, "CONNECT")) goto error; - lex_force_match (lexer, T_EQUALS); + if (! lex_force_match (lexer, T_EQUALS)) + goto error; if (!lex_force_string (lexer)) goto error; @@ -242,12 +245,14 @@ parse_spreadsheet (struct lexer *lexer, char **filename, opts->read_names = true; opts->asw = -1; - lex_force_match (lexer, T_SLASH); + if (! lex_force_match (lexer, T_SLASH)) + goto error; if (!lex_force_match_id (lexer, "FILE")) goto error; - lex_force_match (lexer, T_EQUALS); + if (! lex_force_match (lexer, T_EQUALS)) + goto error; if (!lex_force_string (lexer)) goto error; @@ -391,11 +396,13 @@ parse_get_txt (struct lexer *lexer, struct dataset *ds) enum data_parser_type type; bool has_type; - lex_force_match (lexer, T_SLASH); + if (! lex_force_match (lexer, T_SLASH)) + goto error; if (!lex_force_match_id (lexer, "FILE")) goto error; - lex_force_match (lexer, T_EQUALS); + if (! lex_force_match (lexer, T_EQUALS)) + goto error; fh = fh_parse (lexer, FH_REF_FILE | FH_REF_INLINE, NULL); if (fh == NULL) goto error; diff --git a/src/language/expressions/evaluate.c b/src/language/expressions/evaluate.c index afb742ffea..bd3f46def3 100644 --- a/src/language/expressions/evaluate.c +++ b/src/language/expressions/evaluate.c @@ -181,13 +181,9 @@ cmd_debug_evaluate (struct lexer *lexer, struct dataset *dsother UNUSED) else break; } - if (lex_token (lexer) != T_SLASH) - { - lex_force_match (lexer, T_SLASH); + + if (!lex_force_match (lexer, T_SLASH)) goto done; - } - - lex_get (lexer); expr = expr_parse_any (lexer, ds, optimize); if (!expr || lex_end_of_command (lexer) != CMD_SUCCESS) diff --git a/src/language/stats/aggregate.c b/src/language/stats/aggregate.c index 678ea5334a..03117a5e61 100644 --- a/src/language/stats/aggregate.c +++ b/src/language/stats/aggregate.c @@ -470,7 +470,6 @@ parse_aggregate_functions (struct lexer *lexer, const struct dictionary *dict, { if (function->src_vars == AGR_SV_YES) { - lex_force_match (lexer, T_LPAREN); goto error; } } diff --git a/src/language/stats/crosstabs.q b/src/language/stats/crosstabs.q index 2edf248b2b..c9827396e2 100644 --- a/src/language/stats/crosstabs.q +++ b/src/language/stats/crosstabs.q @@ -404,14 +404,11 @@ crs_custom_tables (struct lexer *lexer, struct dataset *ds, } nx *= by_nvar[n_by]; n_by++; - + if (!lex_match (lexer, T_BY)) { if (n_by < 2) - { - lex_force_match (lexer, T_BY); - goto done; - } + goto done; else break; } diff --git a/src/language/stats/descriptives.c b/src/language/stats/descriptives.c index 1ffe861552..ce47256759 100644 --- a/src/language/stats/descriptives.c +++ b/src/language/stats/descriptives.c @@ -309,7 +309,8 @@ cmd_descriptives (struct lexer *lexer, struct dataset *ds) dsc->sort_ascending = 0; else lex_error (lexer, NULL); - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + goto error; } } else if (var_cnt == 0) diff --git a/src/language/stats/factor.c b/src/language/stats/factor.c index ed10d16d6d..38c66cc751 100644 --- a/src/language/stats/factor.c +++ b/src/language/stats/factor.c @@ -1139,7 +1139,8 @@ cmd_factor (struct lexer *lexer, struct dataset *ds) { factor.promax_power = lex_integer (lexer); lex_get (lexer); - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + goto error; } factor.rotation = ROT_PROMAX; } @@ -1167,7 +1168,8 @@ cmd_factor (struct lexer *lexer, struct dataset *ds) { factor.n_factors = lex_integer (lexer); lex_get (lexer); - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + goto error; } } else if (lex_match_id (lexer, "MINEIGEN")) @@ -1177,7 +1179,8 @@ cmd_factor (struct lexer *lexer, struct dataset *ds) { factor.min_eigen = lex_number (lexer); lex_get (lexer); - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + goto error; } } else if (lex_match_id (lexer, "ECONVERGE")) @@ -1187,7 +1190,8 @@ cmd_factor (struct lexer *lexer, struct dataset *ds) { factor.econverge = lex_number (lexer); lex_get (lexer); - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + goto error; } } else if (lex_match_id (lexer, "RCONVERGE")) @@ -1197,7 +1201,8 @@ cmd_factor (struct lexer *lexer, struct dataset *ds) { factor.rconverge = lex_number (lexer); lex_get (lexer); - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + goto error; } } else if (lex_match_id (lexer, "ITERATE")) @@ -1207,7 +1212,8 @@ cmd_factor (struct lexer *lexer, struct dataset *ds) { n_iterations = lex_integer (lexer); lex_get (lexer); - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + goto error; } } else if (lex_match_id (lexer, "DEFAULT")) @@ -1268,7 +1274,8 @@ cmd_factor (struct lexer *lexer, struct dataset *ds) { factor.blank = lex_number (lexer); lex_get (lexer); - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + goto error; } } else if (lex_match_id (lexer, "DEFAULT")) diff --git a/src/language/stats/frequencies.c b/src/language/stats/frequencies.c index cb96389778..34da71c8aa 100644 --- a/src/language/stats/frequencies.c +++ b/src/language/stats/frequencies.c @@ -914,7 +914,8 @@ cmd_frequencies (struct lexer *lexer, struct dataset *ds) lex_error (lexer, _("Histogram frequency must be greater than zero.")); } lex_get (lexer); - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + goto error; } } } @@ -931,29 +932,34 @@ cmd_frequencies (struct lexer *lexer, struct dataset *ds) lex_error (lexer, _("Histogram percentage must be greater than zero.")); } lex_get (lexer); - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + goto error; } } } else if (lex_match_id (lexer, "MINIMUM")) { - lex_force_match (lexer, T_LPAREN); + if (! lex_force_match (lexer, T_LPAREN)) + goto error; if (lex_force_num (lexer)) { hi_min = lex_number (lexer); lex_get (lexer); } - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + goto error; } else if (lex_match_id (lexer, "MAXIMUM")) { - lex_force_match (lexer, T_LPAREN); + if (! lex_force_match (lexer, T_LPAREN)) + goto error; if (lex_force_num (lexer)) { hi_max = lex_number (lexer); lex_get (lexer); } - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + goto error; } else { @@ -970,23 +976,27 @@ cmd_frequencies (struct lexer *lexer, struct dataset *ds) { if (lex_match_id (lexer, "MINIMUM")) { - lex_force_match (lexer, T_LPAREN); + if (! lex_force_match (lexer, T_LPAREN)) + goto error; if (lex_force_num (lexer)) { pie_min = lex_number (lexer); lex_get (lexer); } - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + goto error; } else if (lex_match_id (lexer, "MAXIMUM")) { - lex_force_match (lexer, T_LPAREN); + if (! lex_force_match (lexer, T_LPAREN)) + goto error; if (lex_force_num (lexer)) { pie_max = lex_number (lexer); lex_get (lexer); } - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + goto error; } else if (lex_match_id (lexer, "MISSING")) { @@ -1012,23 +1022,27 @@ cmd_frequencies (struct lexer *lexer, struct dataset *ds) { if (lex_match_id (lexer, "MINIMUM")) { - lex_force_match (lexer, T_LPAREN); + if (! lex_force_match (lexer, T_LPAREN)) + goto error; if (lex_force_num (lexer)) { bar_min = lex_number (lexer); lex_get (lexer); } - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + goto error; } else if (lex_match_id (lexer, "MAXIMUM")) { - lex_force_match (lexer, T_LPAREN); + if (! lex_force_match (lexer, T_LPAREN)) + goto error; if (lex_force_num (lexer)) { bar_max = lex_number (lexer); lex_get (lexer); } - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + goto error; } else if (lex_match_id (lexer, "FREQ")) { @@ -1039,7 +1053,8 @@ cmd_frequencies (struct lexer *lexer, struct dataset *ds) lex_number (lexer); lex_get (lexer); } - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + goto error; } bar_freq = true; } @@ -1052,7 +1067,8 @@ cmd_frequencies (struct lexer *lexer, struct dataset *ds) lex_number (lexer); lex_get (lexer); } - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + goto error; } bar_freq = false; } diff --git a/src/language/stats/glm.c b/src/language/stats/glm.c index d51d53faa0..625de2d2a9 100644 --- a/src/language/stats/glm.c +++ b/src/language/stats/glm.c @@ -155,7 +155,8 @@ cmd_glm (struct lexer *lexer, struct dataset *ds) PV_NO_DUPLICATE | PV_NUMERIC)) goto error; - lex_force_match (lexer, T_BY); + if (! lex_force_match (lexer, T_BY)) + goto error; if (!parse_variables_const (lexer, glm.dict, &glm.factor_vars, &glm.n_factor_vars, diff --git a/src/language/stats/logistic.c b/src/language/stats/logistic.c index d5dbad3605..f8debbaaa3 100644 --- a/src/language/stats/logistic.c +++ b/src/language/stats/logistic.c @@ -783,7 +783,8 @@ cmd_logistic (struct lexer *lexer, struct dataset *ds) if (! (lr.dep_var = parse_variable_const (lexer, lr.dict))) goto error; - lex_force_match (lexer, T_WITH); + if (! lex_force_match (lexer, T_WITH)) + goto error; if (!parse_variables_const (lexer, lr.dict, &pred_vars, &n_pred_vars, diff --git a/src/language/stats/means.c b/src/language/stats/means.c index f1726b9af1..4d5d83fa92 100644 --- a/src/language/stats/means.c +++ b/src/language/stats/means.c @@ -597,7 +597,8 @@ cmd_means (struct lexer *lexer, struct dataset *ds) /* Optional TABLES = */ if (lex_match_id (lexer, "TABLES")) { - lex_force_match (lexer, T_EQUALS); + if (! lex_force_match (lexer, T_EQUALS)) + goto error; } @@ -621,7 +622,7 @@ cmd_means (struct lexer *lexer, struct dataset *ds) if (lex_is_variable (lexer, means.dict, 1) ) { more_tables = true; - lex_force_match (lexer, T_SLASH); + lex_match (lexer, T_SLASH); } } } diff --git a/src/language/stats/npar.c b/src/language/stats/npar.c index 92b86252e4..a7822d30b6 100644 --- a/src/language/stats/npar.c +++ b/src/language/stats/npar.c @@ -835,7 +835,7 @@ npar_chisquare (struct lexer *lexer, struct dataset *ds, if ( ! lex_force_num (lexer)) return 0; cstp->lo = lex_number (lexer); lex_get (lexer); - lex_force_match (lexer, T_COMMA); + if (! lex_force_match (lexer, T_COMMA)) return 0; if (! lex_force_num (lexer) ) return 0; cstp->hi = lex_number (lexer); if ( cstp->lo >= cstp->hi ) @@ -854,8 +854,8 @@ npar_chisquare (struct lexer *lexer, struct dataset *ds, cstp->expected = NULL; if (lex_match_phrase (lexer, "/EXPECTED")) { - lex_force_match (lexer, T_EQUALS); - if ( ! lex_match_id (lexer, "EQUAL") ) + if (! lex_force_match (lexer, T_EQUALS)) return 0; + if (! lex_match_id (lexer, "EQUAL") ) { double f; int n; @@ -934,7 +934,8 @@ npar_binomial (struct lexer *lexer, struct dataset *ds, { btp->p = lex_number (lexer); lex_get (lexer); - lex_force_match (lexer, T_RPAREN); + if (!lex_force_match (lexer, T_RPAREN)) + return 0; } else return 0; @@ -968,7 +969,8 @@ npar_binomial (struct lexer *lexer, struct dataset *ds, btp->cutpoint = btp->category1; } - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + return 0; } } else @@ -1289,7 +1291,8 @@ npar_median (struct lexer *lexer, { mt->median = lex_number (lexer); lex_get (lexer); - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + return 0; } lex_match (lexer, T_EQUALS); @@ -1477,12 +1480,13 @@ npar_method (struct lexer *lexer, struct npar_specs *specs) if ( lex_match (lexer, T_LPAREN)) { - if ( lex_force_num (lexer) ) + if (lex_force_num (lexer) ) { specs->timer = lex_number (lexer); lex_get (lexer); } - lex_force_match (lexer, T_RPAREN); + if (lex_force_match (lexer, T_RPAREN)) + return 0; } } } diff --git a/src/language/stats/oneway.c b/src/language/stats/oneway.c index 8d7867234b..791ee86978 100644 --- a/src/language/stats/oneway.c +++ b/src/language/stats/oneway.c @@ -450,7 +450,8 @@ cmd_oneway (struct lexer *lexer, struct dataset *ds) PV_NO_DUPLICATE | PV_NUMERIC)) goto error; - lex_force_match (lexer, T_BY); + if (!lex_force_match (lexer, T_BY)) + goto error; oneway.indep_var = parse_variable_const (lexer, dict); if (oneway.indep_var == NULL) @@ -504,7 +505,8 @@ cmd_oneway (struct lexer *lexer, struct dataset *ds) { if ( !lex_force_match (lexer, T_LPAREN)) goto error; - lex_force_num (lexer); + if (! lex_force_num (lexer)) + goto error; oneway.alpha = lex_number (lexer); lex_get (lexer); if ( !lex_force_match (lexer, T_RPAREN)) diff --git a/src/language/stats/quick-cluster.c b/src/language/stats/quick-cluster.c index 61f0cea02a..1570e34d3e 100644 --- a/src/language/stats/quick-cluster.c +++ b/src/language/stats/quick-cluster.c @@ -748,7 +748,8 @@ cmd_quick_cluster (struct lexer *lexer, struct dataset *ds) goto error; } lex_get (lexer); - lex_force_match (lexer, T_RPAREN); + if (!lex_force_match (lexer, T_RPAREN)) + goto error; } } else if (lex_match_id (lexer, "CONVERGE")) @@ -763,7 +764,8 @@ cmd_quick_cluster (struct lexer *lexer, struct dataset *ds) goto error; } lex_get (lexer); - lex_force_match (lexer, T_RPAREN); + if (!lex_force_match (lexer, T_RPAREN)) + goto error; } } else if (lex_match_id (lexer, "MXITER")) @@ -778,7 +780,8 @@ cmd_quick_cluster (struct lexer *lexer, struct dataset *ds) goto error; } lex_get (lexer); - lex_force_match (lexer, T_RPAREN); + if (!lex_force_match (lexer, T_RPAREN)) + goto error; } } else if (lex_match_id (lexer, "NOINITIAL")) diff --git a/src/language/stats/rank.c b/src/language/stats/rank.c index dd3bea1283..9a9ee74969 100644 --- a/src/language/stats/rank.c +++ b/src/language/stats/rank.c @@ -668,7 +668,8 @@ cmd_rank (struct lexer *lexer, struct dataset *ds) string_set_init (&new_names); if (lex_match_id (lexer, "VARIABLES")) - lex_force_match (lexer, T_EQUALS); + if (! lex_force_match (lexer, T_EQUALS)) + goto error; if (!parse_sort_criteria (lexer, rank.dict, &rank.sc, @@ -688,10 +689,12 @@ cmd_rank (struct lexer *lexer, struct dataset *ds) while (lex_token (lexer) != T_ENDCMD ) { - lex_force_match (lexer, T_SLASH); + if (! lex_force_match (lexer, T_SLASH)) + goto error; if (lex_match_id (lexer, "TIES")) { - lex_force_match (lexer, T_EQUALS); + if (! lex_force_match (lexer, T_EQUALS)) + goto error; if (lex_match_id (lexer, "MEAN")) { rank.ties = TIES_MEAN; @@ -716,7 +719,8 @@ cmd_rank (struct lexer *lexer, struct dataset *ds) } else if (lex_match_id (lexer, "FRACTION")) { - lex_force_match (lexer, T_EQUALS); + if (! lex_force_match (lexer, T_EQUALS)) + goto error; if (lex_match_id (lexer, "BLOM")) { rank.fraction = FRAC_BLOM; @@ -741,7 +745,8 @@ cmd_rank (struct lexer *lexer, struct dataset *ds) } else if (lex_match_id (lexer, "PRINT")) { - lex_force_match (lexer, T_EQUALS); + if (! lex_force_match (lexer, T_EQUALS)) + goto error; if (lex_match_id (lexer, "YES")) { rank.print = true; @@ -758,7 +763,8 @@ cmd_rank (struct lexer *lexer, struct dataset *ds) } else if (lex_match_id (lexer, "MISSING")) { - lex_force_match (lexer, T_EQUALS); + if (! lex_force_match (lexer, T_EQUALS)) + goto error; if (lex_match_id (lexer, "INCLUDE")) { rank.exclude = MV_SYSTEM; diff --git a/src/language/stats/regression.c b/src/language/stats/regression.c index 66a5abaf7c..a534a8e8ea 100644 --- a/src/language/stats/regression.c +++ b/src/language/stats/regression.c @@ -286,7 +286,8 @@ cmd_regression (struct lexer *lexer, struct dataset *ds) { regression.ci = lex_number (lexer) / 100.0; lex_get (lexer); - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + goto error; } } else diff --git a/src/language/stats/reliability.c b/src/language/stats/reliability.c index 90baa51fe2..fd6af69448 100644 --- a/src/language/stats/reliability.c +++ b/src/language/stats/reliability.c @@ -234,7 +234,8 @@ cmd_reliability (struct lexer *lexer, struct dataset *ds) { reliability.split_point = lex_number (lexer); lex_get (lexer); - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + goto error; } } else diff --git a/src/language/stats/roc.c b/src/language/stats/roc.c index b8086dd659..8cae062057 100644 --- a/src/language/stats/roc.c +++ b/src/language/stats/roc.c @@ -160,8 +160,10 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) if (lex_match (lexer, T_LPAREN)) { roc.reference = true; - lex_force_match_id (lexer, "REFERENCE"); - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match_id (lexer, "REFERENCE")) + goto error; + if (! lex_force_match (lexer, T_RPAREN)) + goto error; } } else if (lex_match_id (lexer, "NONE")) @@ -201,7 +203,8 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) { if (lex_match_id (lexer, "CUTOFF")) { - lex_force_match (lexer, T_LPAREN); + if (! lex_force_match (lexer, T_LPAREN)) + goto error; if (lex_match_id (lexer, "INCLUDE")) { roc.exclude = MV_SYSTEM; @@ -215,11 +218,13 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) lex_error (lexer, NULL); goto error; } - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + goto error; } else if (lex_match_id (lexer, "TESTPOS")) { - lex_force_match (lexer, T_LPAREN); + if (! lex_force_match (lexer, T_LPAREN)) + goto error; if (lex_match_id (lexer, "LARGE")) { roc.invert = false; @@ -233,7 +238,8 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) lex_error (lexer, NULL); goto error; } - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + goto error; } else if (lex_match_id (lexer, "CI")) { diff --git a/src/language/stats/t-test-parser.c b/src/language/stats/t-test-parser.c index bc9de94a40..7af0dfc9c6 100644 --- a/src/language/stats/t-test-parser.c +++ b/src/language/stats/t-test-parser.c @@ -109,7 +109,8 @@ cmd_t_test (struct lexer *lexer, struct dataset *ds) cut = false; } - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + goto parse_failed; } else { @@ -281,7 +282,8 @@ cmd_t_test (struct lexer *lexer, struct dataset *ds) goto parse_failed; tt.confidence = lex_number (lexer); lex_get (lexer); - lex_force_match (lexer, T_RPAREN); + if (! lex_force_match (lexer, T_RPAREN)) + goto parse_failed; } } else diff --git a/src/language/tests/moments-test.c b/src/language/tests/moments-test.c index af328928ab..b218ad4f52 100644 --- a/src/language/tests/moments-test.c +++ b/src/language/tests/moments-test.c @@ -82,12 +82,8 @@ cmd_debug_moments (struct lexer *lexer, struct dataset *ds UNUSED) if (lex_match_id (lexer, "ONEPASS")) two_pass = 0; - if (lex_token (lexer) != T_SLASH) - { - lex_force_match (lexer, T_SLASH); + if (!lex_force_match (lexer, T_SLASH)) goto done; - } - lex_get (lexer); if (two_pass) { diff --git a/src/language/utilities/permissions.c b/src/language/utilities/permissions.c index a52cd198aa..904ba95b27 100644 --- a/src/language/utilities/permissions.c +++ b/src/language/utilities/permissions.c @@ -43,19 +43,18 @@ int change_permissions(const char *file_name, enum PER per); int cmd_permissions (struct lexer *lexer, struct dataset *ds UNUSED) { - char *fn = 0; - + char *fn = NULL; + const char *str = NULL; lex_match (lexer, T_SLASH); if (lex_match_id (lexer, "FILE")) lex_match (lexer, T_EQUALS); - if (!lex_force_string (lexer)) - return CMD_FAILURE; - - fn = ss_xstrdup (lex_tokss (lexer)); - lex_force_match (lexer, T_STRING); + str = lex_tokcstr (lexer); + fn = strdup (str); + if (!lex_force_match (lexer, T_STRING)) + goto error; lex_match (lexer, T_SLASH); @@ -66,12 +65,12 @@ cmd_permissions (struct lexer *lexer, struct dataset *ds UNUSED) if ( lex_match_id (lexer, "READONLY")) { - if ( ! change_permissions(fn, PER_RO ) ) + if (! change_permissions (fn, PER_RO)) goto error; } - else if ( lex_match_id (lexer, "WRITEABLE")) + else if (lex_match_id (lexer, "WRITEABLE")) { - if ( ! change_permissions(fn, PER_RW ) ) + if (! change_permissions (fn, PER_RW )) goto error; } else @@ -80,7 +79,7 @@ cmd_permissions (struct lexer *lexer, struct dataset *ds UNUSED) goto error; } - free(fn); + free (fn); return CMD_SUCCESS; @@ -106,7 +105,6 @@ change_permissions (const char *file_name, enum PER per) return 0; } - locale_file_name = utf8_to_filename (file_name); if ( -1 == stat(locale_file_name, &buf) ) {