PennMUSH Community
Show
Ignore:
Timestamp:
06/12/07 15:21:47 (1 year ago)
Author:
shawnw
Message:

1.8.3p3

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 1.8.3/trunk/src/comp_w.c

    r846 r919  
    128128#include "confmagic.h" 
    129129 
    130 #define MAXTABLE 32768     /**< Maximum words in the table */ 
    131 #define MAXWORDS 100       /**< Maximum size of a word */ 
    132 #define COLLISION_LIMIT 20 /**< Maximum allowed collisions */ 
    133  
    134 #define COMPRESS_HASH_MASK 0x7FFF  /**< 32767 in hex */ 
    135  
    136 #define TABLE_FLAG 0x80        /**< Distinguish a table */ 
    137 #define TABLE_MASK 0x7F        /**< Mask out words within a table */ 
     130#define MAXTABLE 32768          /**< Maximum words in the table */ 
     131#define MAXWORDS 100            /**< Maximum size of a word */ 
     132#define COLLISION_LIMIT 20      /**< Maximum allowed collisions */ 
     133 
     134#define COMPRESS_HASH_MASK 0x7FFF       /**< 32767 in hex */ 
     135 
     136#define TABLE_FLAG 0x80         /**< Distinguish a table */ 
     137#define TABLE_MASK 0x7F         /**< Mask out words within a table */ 
    138138 
    139139/* Table of words */ 
     
    163163#ifdef COMP_STATS 
    164164void compress_stats(long *entries, long *mem_used, 
    165            long *total_uncompressed, long *total_compressed); 
     165                    long *total_uncompressed, long *total_compressed); 
    166166#endif 
    167167static unsigned int hash_fn(const char *s, int hashtab_mask); 
     
    173173  int i, j; 
    174174 
    175   word[wordpos++] = 0;     /* word's trailing null */ 
     175  word[wordpos++] = 0;          /* word's trailing null */ 
    176176 
    177177  /* Don't bother putting single or double letter words in the table */ 
     
    190190    if (words[i]) 
    191191      if (strcmp(word, words[i]) == 0) { 
    192    *b++ = (i >> 8) | TABLE_FLAG; 
    193    *b++ = i & 0xFF; 
    194    return; 
     192        *b++ = (i >> 8) | TABLE_FLAG; 
     193        *b++ = i & 0xFF; 
     194        return; 
    195195      } 
    196196  /* not in table, add to it */ 
    197197 
    198198  if ((i & 0xFF) == 0) { 
    199     i++;           /* make sure we don't have a null in the message */ 
     199    i++;                        /* make sure we don't have a null in the message */ 
    200200    j++; 
    201201  } 
     
    224224  *b++ = i & 0xFF; 
    225225 
    226 }              /* end of output_previous_word */ 
     226}                               /* end of output_previous_word */ 
    227227 
    228228/** Word-compress a string. 
     
    250250/* break up input into words */ 
    251251  while (*p) { 
    252     if (!(isdigit(*p) || isalpha(*p)) || wordpos >= MAXWORDS) { 
     252    if (!isalnum(*p) || wordpos >= MAXWORDS) { 
    253253      if (wordpos) { 
    254    word[wordpos++] = *p & 0x7F;    /* add trailing punctuation */ 
    255    output_previous_word(); 
    256    wordpos = 0; 
     254        word[wordpos++] = *p & 0x7F;    /* add trailing punctuation */ 
     255        output_previous_word(); 
     256        wordpos = 0; 
    257257      } else 
    258    *b++ = *p & 0x7F; 
     258        *b++ = *p & 0x7F; 
    259259    } else 
    260260      word[wordpos++] = *p & 0x7F; 
     
    265265    output_previous_word(); 
    266266 
    267   *b = 0;          /* trailing null */ 
    268  
    269 #ifdef COMP_STATS 
    270   total_comp += u_strlen(buf); /* calculate size of compressed   text */ 
    271   total_uncomp += strlen(s);   /* calculate size of uncompressed text */ 
     267  *b = 0;                       /* trailing null */ 
     268 
     269#ifdef COMP_STATS 
     270  total_comp += u_strlen(buf);  /* calculate size of compressed   text */ 
     271  total_uncomp += strlen(s);    /* calculate size of uncompressed text */ 
    272272#endif 
    273273 
    274274  return u_strdup(buf); 
    275 }              /* end of compress; */ 
     275}                               /* end of compress; */ 
    276276 
    277277 
     
    309309      i = ((c & TABLE_MASK) << 8) | *(++p); 
    310310      if (i >= MAXTABLE || words[i] == NULL) { 
    311    static int panicking = 0; 
    312    if (panicking) { 
    313      do_rawlog(LT_ERR, 
    314            "Error in string decompression occurred during panic dump."); 
    315      exit(1); 
    316    } else { 
    317      panicking = 1;    /* don't panic from within panic */ 
    318      do_rawlog(LT_ERR, "Error in string decompression, i = %i", i); 
    319      mush_panic("Fatal error in decompression"); 
    320    
     311        static int panicking = 0; 
     312        if (panicking) { 
     313          do_rawlog(LT_ERR, 
     314                    "Error in string decompression occurred during panic dump."); 
     315          exit(1); 
     316        } else { 
     317          panicking = 1;        /* don't panic from within panic */ 
     318          do_rawlog(LT_ERR, "Error in string decompression, i = %i", i); 
     319          mush_panic("Fatal error in decompression"); 
     320       
    321321      } 
    322322      strncpy((char *) b, words[i], words_len[i]); 
     
    327327  } 
    328328 
    329   *b++ = 0;            /* trailing null */ 
     329  *b++ = 0;                     /* trailing null */ 
    330330 
    331331  return buf; 
    332332 
    333 }              /* end of uncompress; */ 
     333}                               /* end of uncompress; */ 
    334334 
    335335/** Word-uncompress a string, allocating memory. 
     
    372372void 
    373373compress_stats(long *entries, long *mem_used, long *total_uncompressed, 
    374           long *total_compressed) 
     374               long *total_compressed) 
    375375{ 
    376376