Changeset 2106

Show
Ignore:
Timestamp:
03/30/08 22:55:55 (2 months ago)
Author:
karpet
Message:

test that all ids are unique

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • libswish3/trunk/src/libswish3/config.c

    r2104 r2106  
    181181} 
    182182 
     183swish_ConfigFlags * 
     184swish_init_config_flags( 
     185) 
     186{ 
     187    swish_ConfigFlags   *flags; 
     188    int                  i; 
     189     
     190    flags               = swish_xmalloc(sizeof(swish_ConfigFlags)); 
     191    flags->tokenize     = 1; 
     192        
     193    /* set all defaults to 0 */ 
     194    for(i=0; i<SWISH_MAX_IDS; i++) { 
     195        flags->meta_ids[i] = 0; 
     196    } 
     197    for(i=0; i<SWISH_MAX_IDS; i++) { 
     198        flags->prop_ids[i] = 0; 
     199    } 
     200     
     201    return flags; 
     202} 
     203 
     204     
     205 
    183206/* init config object */ 
    184  
    185207swish_Config * 
    186208swish_init_config( 
     
    195217/* the hashes will automatically grow as needed so we init with sane starting size */ 
    196218    config = swish_xmalloc(sizeof(swish_Config)); 
    197     config->flags = swish_xmalloc(sizeof(swish_ConfigFlags)); 
     219    config->flags = swish_init_config_flags(); 
    198220    config->misc = swish_init_hash(8); 
    199221    config->metanames = swish_init_hash(8); 
     
    205227    config->ref_cnt = 0; 
    206228    config->stash = NULL; 
    207  
    208 /* misc default flags */ 
    209     config->flags->tokenize = 1; 
    210229     
    211230    if (SWISH_DEBUG & SWISH_DEBUG_MEMORY) { 
  • libswish3/trunk/src/libswish3/header.c

    r2103 r2106  
    108108    xmlChar *name 
    109109); 
     110static void 
     111test_meta_unique_ids( 
     112    swish_MetaName *meta, 
     113    swish_Config *c, 
     114    xmlChar *name 
     115); 
     116static void 
     117test_prop_unique_ids( 
     118    swish_Property *prop, 
     119    swish_Config *c, 
     120    xmlChar *name 
     121); 
    110122static headmaker *init_headmaker( 
    111123); 
     
    744756} 
    745757 
     758static void 
     759test_meta_unique_ids( 
     760    swish_MetaName *meta, 
     761    swish_Config *c, 
     762    xmlChar *name 
     763) 
     764{ 
     765    c->flags->meta_ids[ meta->id ]++; 
     766} 
     767 
     768static void 
     769test_prop_unique_ids( 
     770    swish_Property *prop, 
     771    swish_Config *c, 
     772    xmlChar *name 
     773) 
     774{ 
     775    c->flags->prop_ids[ prop->id ]++; 
     776} 
     777 
     778void 
     779swish_config_test_unique_ids( 
     780    swish_Config *c 
     781) 
     782{ 
     783    int i; 
     784    xmlHashScan(c->metanames,  (xmlHashScanner) test_meta_unique_ids, c); 
     785    xmlHashScan(c->properties, (xmlHashScanner) test_prop_unique_ids, c); 
     786    for(i=0; i<SWISH_MAX_IDS; i++) { 
     787        if (c->flags->meta_ids[i] > 1) { 
     788            SWISH_WARN("meta id %d == %d", i, c->flags->meta_ids[i]); 
     789        } 
     790        if (c->flags->prop_ids[i] > 1) { 
     791            SWISH_WARN("prop id %d == %d", i, c->flags->prop_ids[i]); 
     792        } 
     793         
     794        /* set back to 0 in case we are called again */ 
     795        c->flags->prop_ids[i] = 0; 
     796        c->flags->meta_ids[i] = 0; 
     797    }  
     798} 
     799 
    746800static headmaker * 
    747801init_headmaker( 
     
    769823    h = init_headmaker(); 
    770824    read_header(filename, h); 
     825     
     826/*  test that all the alias_for links resolve ok */ 
     827    swish_config_test_alias_fors(h->config); 
     828     
     829/*  make sure ids are all unique */ 
     830    swish_config_test_unique_ids(h->config); 
     831 
    771832    swish_debug_config(h->config); 
    772833    swish_free_config(h->config); 
     
    794855    swish_xfree(h); 
    795856 
    796 /*  now test that all the alias_for links resolve ok */ 
     857/*  test that all the alias_for links resolve ok */ 
    797858    swish_config_test_alias_fors(c); 
     859     
     860/*  make sure ids are all unique */ 
     861    swish_config_test_unique_ids(c); 
    798862 
    799863    return 1; 
  • libswish3/trunk/src/libswish3/libswish3.h

    r2097 r2106  
    2929#include <libxml/xmlstring.h> 
    3030 
    31 #define SWISH_LIB_VERSION         "0.1.0" 
    32 #define SWISH_VERSION             "3.0.0" 
    33 #define SWISH_BUFFER_CHUNK_SIZE   10000 
    34 #define SWISH_MAXSTRLEN           2000 
    35 #define SWISH_MAX_HEADERS         
    36 #define SWISH_RD_BUFFER_SIZE      65356 
    37 #define SWISH_MAX_WORD_LEN        256 
    38 #define SWISH_MIN_WORD_LEN       
    39  
    40 #define SWISH_STACK_SIZE          255  /* starting size for metaname/tag stack */ 
    41  
    42  
    43 #define SWISH_CONTRACTIONS         1 
    44  
    45 #define SWISH_SPECIAL_ARG         
    46 #define SWISH_MAX_SORT_STRING_LEN 100 
    47  
    48 #define SWISH_DATE_FORMAT_STRING   "%Y-%m-%d %H:%M:%S %Z" 
    49 #define SWISH_URL_LENGTH           255 
     31#define SWISH_LIB_VERSION           "0.1.0" 
     32#define SWISH_VERSION               "3.0.0" 
     33#define SWISH_BUFFER_CHUNK_SIZE     10000 
     34#define SWISH_MAXSTRLEN             2000 
     35#define SWISH_MAX_HEADERS          
     36#define SWISH_RD_BUFFER_SIZE        65356 
     37#define SWISH_MAX_WORD_LEN          256 
     38#define SWISH_MIN_WORD_LEN         
     39 
     40#define SWISH_STACK_SIZE            255  /* starting size for metaname/tag stack */ 
     41 
     42#define SWISH_CONTRACTIONS          1 
     43 
     44#define SWISH_MAX_IDS               1024 
     45#define SWISH_SPECIAL_ARG          
     46#define SWISH_MAX_SORT_STRING_LEN   100 
     47 
     48#define SWISH_DATE_FORMAT_STRING    "%Y-%m-%d %H:%M:%S %Z" 
     49#define SWISH_URL_LENGTH            255 
    5050 
    5151/* default config hash key names */ 
     
    245245{ 
    246246    boolean         tokenize; 
     247    boolean         meta_ids[SWISH_MAX_IDS]; 
     248    boolean         prop_ids[SWISH_MAX_IDS]; 
    247249     
    248250}; 
     
    488490xmlChar *       swish_get_mime_type( swish_Config * config, xmlChar * fileext ); 
    489491xmlChar *       swish_get_parser( swish_Config * config, xmlChar *mime ); 
     492void            swish_config_test_unique_ids( swish_Config *c ); 
     493void            swish_config_test_alias_fors( swish_Config *c ); 
    490494/* 
    491495=cut