diff --git a/src/language.yacc b/src/language.yacc index 3f9fa70ce4d4957c3007198c9d67aeab9d58db6e..7f4398535bd0fefa87fd26b1d24a2b0bf58a5426 100644 --- a/src/language.yacc +++ b/src/language.yacc @@ -162,7 +162,7 @@ /* This is the grammar definition of Pike. */ #include "global.h" -RCSID("$Id: language.yacc,v 1.51 1998/01/13 22:56:43 hubbe Exp $"); +RCSID("$Id: language.yacc,v 1.52 1998/01/19 18:38:45 hubbe Exp $"); #ifdef HAVE_MEMORY_H #include <memory.h> #endif @@ -1272,11 +1272,17 @@ low_idents: F_IDENTIFIER if(throw_value.type == T_STRING) { - my_yyerror("%s",throw_value.u.string->str); + if(compiler_pass==2) + my_yyerror("%s",throw_value.u.string->str); + else + $$=mknode(F_UNDEFINED,0,0); } else if(IS_ZERO(sp-1) && sp[-1].subtype==1) { - my_yyerror("'%s' undefined.", $1->str); + if(compiler_pass==2) + my_yyerror("'%s' undefined.", $1->str); + else + $$=mknode(F_UNDEFINED,0,0); }else{ $$=mkconstantsvaluenode(sp-1); } diff --git a/src/las.c b/src/las.c index d194fa4b5943163decfa39af1d6e62c17bf8b83b..2b8a6092c3afc48727eee184d32f276e2d365e72 100644 --- a/src/las.c +++ b/src/las.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: las.c,v 1.41 1998/01/15 05:59:41 hubbe Exp $"); +RCSID("$Id: las.c,v 1.42 1998/01/19 18:38:46 hubbe Exp $"); #include "language.h" #include "interpret.h" @@ -1285,8 +1285,28 @@ void fix_type_field(node *n) break; case F_CONSTANT: + switch(CAR(n)->u.sval.type) + { + case T_FUNCTION: + name=ID_FROM_INT(CAR(n)->u.sval.u.object->prog, + CAR(n)->u.sval.subtype)->name->str; + break; + + case T_ARRAY: + name="array call"; + break; + + case T_PROGRAM: + name="clone call"; + break; + + default: + name="`() (function call)"; + break; + } + default: - name="`() (function call)"; + name="unknown function"; } if(max_correct_args == count_arguments(s)) diff --git a/src/stralloc.c b/src/stralloc.c index 4ab1c7838de35c079560faf371e9ed7ac7d977b1..22e60ca2d400fede9a7c4a63d04f1dda643e5d9d 100644 --- a/src/stralloc.c +++ b/src/stralloc.c @@ -15,6 +15,7 @@ #define BEGIN_HASH_SIZE 997 #define MAX_AVG_LINK_LENGTH 3 +#define HASH_PREFIX 20 unsigned INT32 htable_size=0; static unsigned int hashprimes_entry=0; @@ -25,7 +26,7 @@ unsigned INT32 num_strings=0; /*** Main string hash function ***/ static unsigned int StrHash(const char *s,int len) { - full_hash_value=hashmem((unsigned char *)s, len, 20); + full_hash_value=hashmem((unsigned char *)s, len, HASH_PREFIX); return full_hash_value % htable_size; } @@ -484,6 +485,42 @@ struct pike_string *realloc_shared_string(struct pike_string *a, INT32 size) } } +/* Modify one index in a shared string + * Not suitable for building new strings or changing multiple characters + * within a string! + */ +struct pike_string *modify_shared_string(struct pike_string *a, + INT32 index, + char c) +{ +#ifdef DEBUG + if(index<0 || index>=a->len) + fatal("Index out of range in modify_shared_string()\n"); +#endif + + if(a->str[index]==c) return a; + + if(a->refs==1) + { + if(index>=HASH_PREFIX && index<a->len-8) + { + a->str[index]=c; + return a; + }else{ + unlink_pike_string(a); + a->str[index]=c; + return end_shared_string(a); + } + }else{ + struct pike_string *r; + r=begin_shared_string(a->len); + MEMCPY(r->str, a->str, a->len); + a->str[index]=c; + free_string(a); + return end_shared_string(r); + } +} + /*** Add strings ***/ struct pike_string *add_shared_strings(struct pike_string *a, struct pike_string *b)