X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fexpressions%2Fparse.c;h=15efe00bed59f56a8bddeeee0b3ef6fe374fb8cd;hb=1195caf0c998e80d3e7195a0452a14e7b4194077;hp=be0b9d7973dadb207c6e3fb6a3cc4bcf03ee238b;hpb=3bd4593ef9a57f23062c61ec465389f749ba3089;p=pspp-builds.git diff --git a/src/expressions/parse.c b/src/expressions/parse.c index be0b9d79..15efe00b 100644 --- a/src/expressions/parse.c +++ b/src/expressions/parse.c @@ -14,8 +14,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ #include #include "private.h" @@ -336,7 +336,8 @@ type_coercion_core (struct expression *e, case OP_ni_format: if ((*node)->type == OP_format - && check_input_specifier (&(*node)->format.f, 0)) + && check_input_specifier (&(*node)->format.f, false) + && check_specifier_type (&(*node)->format.f, NUMERIC, false)) { if (do_coercion) (*node)->type = OP_ni_format; @@ -346,7 +347,8 @@ type_coercion_core (struct expression *e, case OP_no_format: if ((*node)->type == OP_format - && check_output_specifier (&(*node)->format.f, 0)) + && check_output_specifier (&(*node)->format.f, false) + && check_specifier_type (&(*node)->format.f, NUMERIC, false)) { if (do_coercion) (*node)->type = OP_no_format; @@ -879,14 +881,14 @@ word_matches (const char **test, const char **name) size_t name_len = strcspn (*name, "."); if (test_len == name_len) { - if (memcmp (*test, *name, test_len)) + if (mm_case_compare (*test, *name, test_len)) return false; } else if (test_len < 3 || test_len > name_len) return false; else { - if (memcmp (*test, *name, test_len)) + if (mm_case_compare (*test, *name, test_len)) return false; } @@ -915,6 +917,12 @@ compare_names (const char *test, const char *name) } } +static int +compare_strings (const char *test, const char *name) +{ + return strcasecmp (test, name); +} + static bool lookup_function_helper (const char *name, int (*compare) (const char *test, const char *name), @@ -945,7 +953,7 @@ lookup_function (const char *name, const struct operation **last) { *first = *last = NULL; - return (lookup_function_helper (name, strcmp, first, last) + return (lookup_function_helper (name, compare_strings, first, last) || lookup_function_helper (name, compare_names, first, last)); } @@ -1098,14 +1106,12 @@ no_match (const char *func_name, } else { - ds_create (&s, _("Function invocation ")); + ds_puts (&s, _("Function invocation ")); put_invocation (&s, func_name, args, arg_cnt); ds_puts (&s, _(" does not match any known function. Candidates are:")); for (f = first; f < last; f++) - { - ds_printf (&s, "\n%s", f->prototype); - } + ds_printf (&s, "\n%s", f->prototype); } ds_putc (&s, '.'); @@ -1204,13 +1210,18 @@ parse_function (struct expression *e) n = expr_allocate_composite (e, f - operations, args, arg_cnt); n->composite.min_valid = min_valid != -1 ? min_valid : f->array_min_elems; - if (n->type == OP_LAG_Vnn || n->type == OP_LAG_Vsn) + if (n->type == OP_LAG_Vn || n->type == OP_LAG_Vs) + { + if (n_lag < 1) + n_lag = 1; + } + else if (n->type == OP_LAG_Vnn || n->type == OP_LAG_Vsn) { int n_before; assert (n->composite.arg_cnt == 2); assert (n->composite.args[1]->type == OP_pos_int); n_before = n->composite.args[1]->integer.i; - if (n_before > n_lag) + if (n_lag < n_before) n_lag = n_before; } @@ -1268,7 +1279,7 @@ expr_allocate_nullary (struct expression *e, operation_type op) union any_node * expr_allocate_unary (struct expression *e, operation_type op, -union any_node *arg0) + union any_node *arg0) { return expr_allocate_composite (e, op, &arg0, 1); }