Branch: Tag:

2004-11-05

2004-11-05 16:21:23 by Henrik Grubbström (Grubba) <grubba@grubba.org>

my_yyerror() now uses string_builder_vsprintf().
Corrected the arguments for a lot of my_yyerror() invocations.

Rev: src/language.yacc:1.350
Rev: src/las.c:1.352
Rev: src/pike_types.c:1.239
Rev: src/program.c:1.575
Rev: src/treeopt.in:1.75

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: las.c,v 1.351 2004/10/30 11:38:26 mast Exp $ + || $Id: las.c,v 1.352 2004/11/05 16:21:23 grubba Exp $   */      #include "global.h"
3506:    if (flags & YYTE_IS_WARNING)    yywarning("%s", msg);    else -  my_yyerror("%s", msg); +  yyerror(msg);    }       yyexplain_nonmatching_types(expected_t, got_t, flags);
3569:       case F_ASSIGN:    if (!CAR(n) || (CAR(n)->type == void_type_string)) { -  my_yyerror("Assigning a void expression."); +  yyerror("Assigning a void expression.");    copy_pike_type(n->type, void_type_string);    break;    } else if(CAR(n) && CDR(n)) {
3647:    case F_INDEX:    case F_ARROW:    if (!CAR(n) || (CAR(n)->type == void_type_string)) { -  my_yyerror("Indexing a void expression."); +  yyerror("Indexing a void expression.");    /* The optimizer converts this to an expression returning 0. */    copy_pike_type(n->type, zero_type_string);    } else {
3655:    type_b=CDR(n)->type;    if(!check_indexing(type_a, type_b, n))    if(!Pike_compiler->catch_level) -  my_yyerror("Indexing on illegal type."); +  yyerror("Indexing on illegal type.");    n->type=index_type(type_a, type_b,n);    }    break;
3677:       case F_AUTO_MAP_MARKER:    if (!CAR(n) || (CAR(n)->type == void_type_string)) { -  my_yyerror("Indexing a void expression."); +  yyerror("Indexing a void expression.");    /* The optimizer converts this to an expression returning 0. */    copy_pike_type(n->type, zero_type_string);    } else {    type_a=CAR(n)->type;    if(!match_types(type_a, array_type_string))    if(!Pike_compiler->catch_level) -  my_yyerror("[*] on non-array."); +  yyerror("[*] on non-array.");    n->type=index_type(type_a, int_type_string, n);    }    break;
3692:    case F_AUTO_MAP:    case F_APPLY:    if (!CAR(n) || (CAR(n)->type == void_type_string)) { -  my_yyerror("Calling a void expression."); +  yyerror("Calling a void expression.");    } else {    struct pike_type *f; /* Expected type. */    struct pike_type *s; /* Actual type */ -  char *name; +  struct pike_string *name = NULL; +  char *alternate_name;    INT32 max_args,args;      #ifdef NEW_ARG_CHECK
3771:    case F_TRAMPOLINE:   #endif    case F_IDENTIFIER: -  name=ID_FROM_INT(Pike_compiler->new_program, CAR(n)->u.id.number)->name->str; +  name=ID_FROM_INT(Pike_compiler->new_program, CAR(n)->u.id.number)->name;    break;       case F_ARROW:
3779:    if(CDAR(n)->token == F_CONSTANT &&    CDAR(n)->u.sval.type == T_STRING)    { -  name=CDAR(n)->u.sval.u.string->str; +  name=CDAR(n)->u.sval.u.string;    }else{ -  name="dynamically resolved function"; +  alternate_name="dynamically resolved function";    }    break;   
3791:    case T_FUNCTION:    if(CAR(n)->u.sval.subtype == FUNCTION_BUILTIN)    { -  name=CAR(n)->u.sval.u.efun->name->str; +  name=CAR(n)->u.sval.u.efun->name;    }else{    name=ID_FROM_INT(CAR(n)->u.sval.u.object->prog, -  CAR(n)->u.sval.subtype)->name->str; +  CAR(n)->u.sval.subtype)->name;    }    break;       case T_ARRAY: -  name="array call"; +  alternate_name="array call";    break;       case T_PROGRAM: -  name="clone call"; +  alternate_name="clone call";    break;       default: -  name="`() (function call)"; +  alternate_name="`() (function call)";    break;    }    break;
3817:    int id_no = CAR(n)->u.integer.b;       if (id_no == IDREF_MAGIC_THIS) -  name = "this"; /* Should perhaps qualify it. */ +  alternate_name = "this"; /* Should perhaps qualify it. */       else {    int program_id = CAR(n)->u.integer.a;    struct program_state *state = Pike_compiler;    -  name="external symbol"; +  alternate_name="external symbol";       while (state && (state->new_program->id != program_id)) {    state = state->previous;
3857:    break;       default: -  name="unknown function"; +  alternate_name="unknown function";    }       if(max_args < args)
3868:    copy_pike_type(n->type, mixed_type_string);    break;    } -  my_yyerror("Too many arguments to %s.",name); +  if (name) { +  my_yyerror("Too many arguments to %S.", name); +  } else { +  my_yyerror("Too many arguments to %s.", alternate_name);    } -  +  }    else if(max_correct_args == args)    { -  my_yyerror("Too few arguments to %s.",name); -  }else{ -  my_yyerror("Bad argument %d to %s.", +  if (name) { +  my_yyerror("Too few arguments to %S.", name); +  } else { +  my_yyerror("Too few arguments to %s.", alternate_name); +  } +  } else if (name) { +  my_yyerror("Bad argument %d to %S.",    max_correct_args+1, name); -  +  } else { +  my_yyerror("Bad argument %d to %s.", +  max_correct_args+1, alternate_name);    }       yytype_error(NULL, f, s, 0);