X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Flexer%2Fvariable-parser.c;h=390b98dae36860019f90638f02c45bbfb9e443d2;hb=8445256dab6065706005508e87cfbd02a06191ec;hp=c1e1c28cdf404441cd701edd1ef62fdbaee2d6a8;hpb=48ec61d954cc032c773daf96851cf3b78f27b112;p=pspp diff --git a/src/language/lexer/variable-parser.c b/src/language/lexer/variable-parser.c index c1e1c28cdf..390b98dae3 100644 --- a/src/language/lexer/variable-parser.c +++ b/src/language/lexer/variable-parser.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2009, 2010, 2011 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,6 +30,7 @@ #include "libpspp/assertion.h" #include "libpspp/cast.h" #include "libpspp/hash-functions.h" +#include "libpspp/i18n.h" #include "libpspp/hmapx.h" #include "libpspp/message.h" #include "libpspp/misc.h" @@ -200,9 +201,9 @@ add_variable (struct variable ***v, size_t *nv, size_t *mv, "All variables in this variable list must have the " "same width. %s will be omitted from the list."), var_get_name ((*v)[0]), add_name, add_name); - else if ((pv_opts & PV_NO_DUPLICATE) && included[idx]) + else if ((pv_opts & PV_NO_DUPLICATE) && included && included[idx]) msg (SE, _("Variable %s appears twice in variable list."), add_name); - else if ((pv_opts & PV_DUPLICATE) || !included[idx]) + else if ((pv_opts & PV_DUPLICATE) || !included || !included[idx]) { if (*nv >= *mv) { @@ -632,7 +633,10 @@ parse_mixed_vars (struct lexer *lexer, const struct dictionary *dict, else if (!parse_DATA_LIST_vars (lexer, dict, names, nnames, PV_APPEND)) goto fail; } - return 1; + if (*nnames == 0) + goto fail; + + return true; fail: for (i = 0; i < *nnames; i++) @@ -640,7 +644,7 @@ fail: free (*names); *names = NULL; *nnames = 0; - return 0; + return false; } /* Parses a list of variables where some of the variables may be @@ -819,9 +823,9 @@ array_var_set_lookup_var_idx (const struct var_set *vs, const char *name, struct hmapx_node *node; struct variable **varp; - HMAPX_FOR_EACH_WITH_HASH (varp, node, hash_case_string (name, 0), + HMAPX_FOR_EACH_WITH_HASH (varp, node, utf8_hash_case_string (name, 0), &avs->vars_by_name) - if (!strcasecmp (name, var_get_name (*varp))) + if (!utf8_strcasecmp (name, var_get_name (*varp))) { *idx = varp - avs->var; return true; @@ -869,7 +873,7 @@ var_set_create_from_array (struct variable *const *var, size_t var_cnt) return NULL; } hmapx_insert (&avs->vars_by_name, CONST_CAST (void *, &avs->var[i]), - hash_case_string (name, 0)); + utf8_hash_case_string (name, 0)); } return vs; @@ -893,8 +897,8 @@ lex_match_variable (struct lexer *lexer, const struct dictionary *dict, const st } /* An interaction is a variable followed by {*, BY} followed by an interaction */ -bool -parse_design_interaction (struct lexer *lexer, const struct dictionary *dict, struct interaction **iact) +static bool +parse_internal_interaction (struct lexer *lexer, const struct dictionary *dict, struct interaction **iact, struct interaction **it) { const struct variable *v = NULL; assert (iact); @@ -915,7 +919,8 @@ parse_design_interaction (struct lexer *lexer, const struct dictionary *dict, st if (! lex_match_variable (lexer, dict, &v)) { - interaction_destroy (*iact); + if (it) + interaction_destroy (*it); *iact = NULL; return false; } @@ -929,9 +934,15 @@ parse_design_interaction (struct lexer *lexer, const struct dictionary *dict, st if ( lex_match (lexer, T_ASTERISK) || lex_match (lexer, T_BY)) { - return parse_design_interaction (lexer, dict, iact); + return parse_internal_interaction (lexer, dict, iact, iact); } return true; } +bool +parse_design_interaction (struct lexer *lexer, const struct dictionary *dict, struct interaction **iact) +{ + return parse_internal_interaction (lexer, dict, iact, NULL); +} +