Check the return value of various calls to lex_force_match.
authorJohn Darrington <john@darrington.wattle.id.au>
Fri, 1 Apr 2016 10:16:15 +0000 (12:16 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Fri, 1 Apr 2016 13:38:55 +0000 (15:38 +0200)
20 files changed:
src/language/data-io/get-data.c
src/language/expressions/evaluate.c
src/language/stats/aggregate.c
src/language/stats/crosstabs.q
src/language/stats/descriptives.c
src/language/stats/factor.c
src/language/stats/frequencies.c
src/language/stats/glm.c
src/language/stats/logistic.c
src/language/stats/means.c
src/language/stats/npar.c
src/language/stats/oneway.c
src/language/stats/quick-cluster.c
src/language/stats/rank.c
src/language/stats/regression.c
src/language/stats/reliability.c
src/language/stats/roc.c
src/language/stats/t-test-parser.c
src/language/tests/moments-test.c
src/language/utilities/permissions.c

index 9d1e28100e32f5beb8e2a52401c80deacd7b1aba..e3a93b1738d0324be41f34c49200b7c5b5b3b0ce 100644 (file)
@@ -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;
index afb742ffeae06de29b57ba327bd85a41a753aaeb..bd3f46def36a81f922e97c61354c1591d72c44f4 100644 (file)
@@ -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)
index 678ea5334afd6e7c9692252fe0f049468cda30d4..03117a5e6135ce4b30ac1eee01e0529654c450af 100644 (file)
@@ -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;
            }
        }
index 2edf248b2b0660ac82152d048995d7860758a5e7..c9827396e2534d9cdebfe7a38cf72e2c5e4d8370 100644 (file)
@@ -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;
        }
index 1ffe861552b6aaae990816bb08097a2e4db7f617..ce472567595f4073f2b9f56a825317664d887a2c 100644 (file)
@@ -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)
index ed10d16d6d25ee24ed98bf9770eb7b90e2560355..38c66cc751d7b920e698b540224cf6ee64241b46 100644 (file)
@@ -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"))
index cb963897786d6f19c9c44cb8b12dca5cc4f1a460..34da71c8aaf00b776d0c6a77731b077b310f5c0b 100644 (file)
@@ -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;
                }
index d51d53faa054d8ccd2530319617de1cea7a1e1df..625de2d2a9f9200986f98e453cb3fcf5a7d4513b 100644 (file)
@@ -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,
index d5dbad360544789fedfc257849cbba0303841454..f8debbaaa379898277ee1f7bf05c76da261238ee 100644 (file)
@@ -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,
index f1726b9af1aef0d02773ea7aa32726aafd4569f4..4d5d83fa92aa71104844cfc2f8a8b865227ec543 100644 (file)
@@ -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);
            }
        }
     }
index 92b86252e4f50ba4dddc5dc7b5ab5c03490225b6..a7822d30b6d66fe07217031d96cd7a531f184a20 100644 (file)
@@ -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;
            }
        }
     }
index 8d7867234b0ce687a94502dfd990fdb0168c606e..791ee86978dabe586e1d41ae6bf2d01f968de094 100644 (file)
@@ -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))
index 61f0cea02ade6c2477c19f3855371ec9df866a9c..1570e34d3e4a736b1cd147f1171612d088f89ce7 100644 (file)
@@ -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"))
index dd3bea12832cf11887e28983932369454c0a838b..9a9ee74969861ac42e42646c17ed602daa8ce33e 100644 (file)
@@ -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;
index 66a5abaf7c8aa7011d071bc5a9837c06904451e5..a534a8e8eaced2556a34fdd77dce7c687bb654f9 100644 (file)
@@ -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
index 90baa51fe2b861539291996bb6286858150b4232..fd6af69448a59200195994aa7ebfc208c43a10a7 100644 (file)
@@ -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
index b8086dd6599b4e3d679034db53ef905b75df89d5..8cae062057c5a43309e3bddcab6309e491efcb77 100644 (file)
@@ -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"))
                {
index bc9de94a4014db42ab3580539d6ed7a22d17d85e..7af0dfc9c606b24f72e8c5be5d44327732f78db2 100644 (file)
@@ -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 
index af328928abddbff93e5cb6ac59ef955ef4367e0f..b218ad4f528ce384034b7831ea5d63e6b61ef3ba 100644 (file)
@@ -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)
     {
index a52cd198aa2c8aa15d8698806f677124d38c696e..904ba95b270e2a7de6c5a22e729f64b8b3247cf1 100644 (file)
@@ -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) )
     {