Branch: Tag:

1998-01-19

1998-01-19 18:38:46 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

fixed better error messages and a bug in forward declaring (no longer needed)

Rev: src/language.yacc:1.52
Rev: src/las.c:1.42
Rev: src/stralloc.c:1.22

15:      #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:   /*** 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:    }   }    + /* 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)