Changeset 2116

Show
Ignore:
Timestamp:
04/12/08 00:00:40 (1 month ago)
Author:
karpet
Message:

restructure tests and add substr to namedbuffer debugging

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • libswish3/trunk/src/Makefile.am

    r2090 r2116  
    1919utf8test_SOURCES = utf8test.c $(myheaders) 
    2020 
    21 TESTS = $(check_PROGRAMS) test.pl 
     21TESTS = $(check_PROGRAMS) test.sh 
    2222 
    2323test: check 
  • libswish3/trunk/src/libswish3/docinfo.c

    r2103 r2116  
    4040{ 
    4141 
    42     if (SWISH_DEBUG > 9
     42    if (SWISH_DEBUG & SWISH_DEBUG_DOCINFO
    4343        SWISH_DEBUG_MSG("init'ing docinfo"); 
    4444 
     
    5555    docinfo->update = NULL; 
    5656 
    57     if (SWISH_DEBUG > 9) { 
     57    if (SWISH_DEBUG & SWISH_DEBUG_DOCINFO) { 
    5858        SWISH_DEBUG_MSG("docinfo all ready"); 
    5959        swish_debug_docinfo(docinfo); 
     
    212212    } 
    213213 
    214     if (SWISH_DEBUG > 9
     214    if (SWISH_DEBUG & SWISH_DEBUG_DOCINFO
    215215        SWISH_DEBUG_MSG("handling url %s", filename); 
    216216 
     
    222222    i->size = info.st_size; 
    223223 
    224     if (SWISH_DEBUG > 9
     224    if (SWISH_DEBUG & SWISH_DEBUG_DOCINFO
    225225        SWISH_DEBUG_MSG("handling mime"); 
    226226 
     
    230230    i->mime = swish_get_mime_type(parser_data->s3->config, i->ext); 
    231231 
    232     if (SWISH_DEBUG > 9
     232    if (SWISH_DEBUG & SWISH_DEBUG_DOCINFO
    233233        SWISH_DEBUG_MSG("handling parser"); 
    234234 
  • libswish3/trunk/src/libswish3/mime_types.c

    r2103 r2116  
    238238    parser = swish_hash_fetch(config->parsers, mime); 
    239239 
    240     if (SWISH_DEBUG > 9
     240    if (SWISH_DEBUG & SWISH_DEBUG_DOCINFO
    241241        SWISH_DEBUG_MSG("using parser '%s' based on MIME '%s'", parser, mime); 
    242242 
  • libswish3/trunk/src/libswish3/namedbuffer.c

    r2103 r2116  
    6161        SWISH_DEBUG_MSG("  adding %s to NamedBuffer\n", name); 
    6262 
    63     swish_hash_add(nbhash, name, 
    64                    xmlBufferCreateSize((size_t) SWISH_BUFFER_CHUNK_SIZE)); 
     63    swish_hash_add(nbhash, name, xmlBufferCreateSize((size_t) SWISH_BUFFER_CHUNK_SIZE)); 
    6564} 
    6665 
     
    8887 
    8988/* init a buffer for each key in confhash */ 
    90     xmlHashScan(confhash, (xmlHashScanner) add_name_to_hash, nb->hash); 
     89    xmlHashScan(confhash, (xmlHashScanner)add_name_to_hash, nb->hash); 
    9190 
    9291    return nb; 
     
    9897) 
    9998{ 
    100     xmlHashFree(nb->hash, (xmlHashDeallocator) free_name_from_hash); 
     99    xmlHashFree(nb->hash, (xmlHashDeallocator)free_name_from_hash); 
    101100 
    102101    if (nb->ref_cnt != 0) { 
     
    117116) 
    118117{ 
    119     SWISH_DEBUG_MSG("%s:\n<%s>%s</%s>", label, name, xmlBufferContent(buffer), 
    120                     name); 
     118    const xmlChar *substr; 
     119    const xmlChar *buf; 
     120    int sub_len; 
     121 
     122    SWISH_DEBUG_MSG("%d %s:\n<%s>%s</%s>", xmlBufferLength(buffer),  
     123                        label, name, xmlBufferContent(buffer), name); 
     124     
     125    buf = xmlBufferContent(buffer); 
     126    while ((substr = xmlStrstr(buf, (const xmlChar *)SWISH_META_CONNECTOR)) != NULL) { 
     127        sub_len = substr - buf; 
     128        SWISH_DEBUG_MSG("%d <%s> substr: %s", sub_len, name, xmlStrsub(buf, 0, sub_len) ); 
     129        buf = substr + 2; 
     130    } 
     131    if (buf != NULL) { 
     132        SWISH_DEBUG_MSG("%d <%s> substr: %s", xmlStrlen(buf), name, buf ); 
     133    } 
    121134} 
    122135 
     
    127140) 
    128141{ 
    129     xmlHashScan(nb->hash, (xmlHashScanner) print_buffer, label); 
     142    xmlHashScan(nb->hash, (xmlHashScanner)print_buffer, label); 
    130143} 
    131144 
     
    140153) 
    141154{ 
    142     swish_add_str_to_nb(nb, name, (xmlChar *)xmlBufferContent(buf), 
    143                         xmlBufferLength(buf), joiner, cleanwsp, autovivify); 
     155    swish_add_str_to_nb(nb, name, (xmlChar *)xmlBufferContent(buf), xmlBufferLength(buf), 
     156                        joiner, cleanwsp, autovivify); 
    144157} 
    145158 
     
    208221    ret = xmlBufferAdd(buf, (const xmlChar *)txt, txtlen); 
    209222    if (ret) { 
    210         SWISH_CROAK("problem adding \n>>%s<<\n length %d to buffer. Err: %d", 
    211                     txt, txtlen, ret); 
    212     } 
    213  
     223        SWISH_CROAK("problem adding \n>>%s<<\n length %d to buffer. Err: %d", txt, txtlen, 
     224                    ret); 
     225    } 
    214226} 
    215227 
  • libswish3/trunk/src/libswish3/parser.c

    r2108 r2116  
    891891    } 
    892892 
    893     if (SWISH_DEBUG
     893    if (SWISH_DEBUG & SWISH_DEBUG_PARSER
    894894        SWISH_DEBUG_MSG("%s -- using %s parser", parser_data->docinfo->uri, 
    895895                        parser); 
     
    17281728    free_parser_data(parser_data); 
    17291729 
    1730     if (SWISH_DEBUG) { 
     1730    if (SWISH_DEBUG & SWISH_DEBUG_PARSER) { 
    17311731        etime = swish_print_fine_time(swish_time_elapsed() - curTime); 
    17321732        SWISH_DEBUG_MSG("%s elapsed time", etime); 
  • libswish3/trunk/src/libswish3/string.c

    r2110 r2116  
    225225    if (enc != NULL) { 
    226226        enc++; 
    227         if (SWISH_DEBUG
     227        if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER
    228228            SWISH_DEBUG_MSG("encoding = %s", enc); 
    229229    } 
    230230    else { 
    231         if (SWISH_DEBUG
     231        if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER
    232232            SWISH_DEBUG_MSG("no encoding in %s, using %s", loc, SWISH_DEFAULT_ENCODING); 
    233233 
     
    256256    } 
    257257 
    258     if (SWISH_DEBUG
     258    if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER
    259259        SWISH_DEBUG_MSG("locale set to %s", loc); 
    260260 
     
    676676*/ 
    677677 
    678     if (SWISH_DEBUG > 10
     678    if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER
    679679        SWISH_DEBUG_MSG("parsing url %s for extension", url); 
    680680 
    681681    p = findlast(url, (xmlChar *)SWISH_EXT_SEP);        /* look for . or /         */ 
    682682 
    683     if (SWISH_DEBUG > 10
     683    if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER
    684684        SWISH_DEBUG_MSG("p = %s", p); 
    685685 
     
    690690        return NULL;            /* ... if not, ignore / */ 
    691691 
    692     if (SWISH_DEBUG > 10
     692    if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER
    693693        SWISH_DEBUG_MSG("p = %s", p); 
    694694 
     
    696696        p++;                    /* skip to next char after . */ 
    697697 
    698     if (SWISH_DEBUG > 10
     698    if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER
    699699        SWISH_DEBUG_MSG("ext is %s", p); 
    700700 
  • libswish3/trunk/src/swish_lint.c

    r2105 r2116  
    9999    printf("nwords: %d\n", parser_data->docinfo->nwords); 
    100100 
    101     if (SWISH_DEBUG
     101    if (SWISH_DEBUG & SWISH_DEBUG_MEMORY
    102102        swish_mem_debug(); 
    103103 
     
    195195    } 
    196196 
    197     if (SWISH_DEBUG == 20) { 
     197    if (SWISH_DEBUG & SWISH_DEBUG_CONFIG) { 
    198198        swish_debug_config(s3->config); 
    199199    }