Show
Ignore:
Timestamp:
09/18/08 23:51:41 (4 months ago)
Author:
karpet
Message:

avoid xmlStrncat because (a) it fails under linux and (b) the realloc is unnecessary

Files:

Legend:

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

    r2153 r2155  
    144144#define SWISH_DEFAULT_ENCODING    "UTF-8" 
    145145#define SWISH_LOCALE              "en_US.UTF-8" 
    146  
     146#define SWISH_ENCODING_ERROR      100 
    147147 
    148148/* debugging levels */ 
  • libswish3/trunk/src/libswish3/parser.c

    r2153 r2155  
    19441944 
    19451945    if (parser_data->docinfo->encoding != (xmlChar *)SWISH_DEFAULT_ENCODING) { 
     1946        SWISH_WARN("%s docinfo->encoding %s != %s",  
     1947            parser_data->docinfo->uri, parser_data->docinfo->encoding, SWISH_DEFAULT_ENCODING); 
     1948 
    19461949        if (!xmlStrncasecmp(parser_data->docinfo->encoding, (xmlChar *)"iso-8859-1", 10)) { 
    19471950            out = swish_xmalloc(size * 2); 
     
    19701973 
    19711974            if (!isolat1ToUTF8(out, &outlen, buffer, &size)) { 
    1972                 SWISH_WARN("could not convert buf from iso-8859-1"); 
     1975                SWISH_WARN("could not convert buf from iso-8859-1: %s", buffer); 
     1976                swish_xfree(out); 
     1977                return SWISH_ENCODING_ERROR; 
     1978            } 
     1979            else { 
     1980                SWISH_WARN("converted %s from %s to %s",  
     1981                    parser_data->docinfo->uri, "iso-8859-1", SWISH_DEFAULT_ENCODING); 
    19731982            } 
    19741983 
  • libswish3/trunk/src/libswish3/tokenizer.c

    r2153 r2155  
    677677            if (inside_token) { 
    678678 
     679                /* edge case */ 
     680                if ((chr_len + token_len) > s3->analyzer->maxwordlen) { 
     681                    if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER) 
     682                        SWISH_DEBUG_MSG("token_len = %d  forcing end of token: '%s'", 
     683                                        token_len, chr); 
     684                    continue; 
     685                } 
     686 
    679687                if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER) 
    680688                    SWISH_DEBUG_MSG("adding to token: '%s'", chr); 
    681689 
    682                 xmlStrncat(token, (const xmlChar *)chr, chr_len); 
     690                memcpy(&token[token_len], chr, chr_len * sizeof(xmlChar)); 
     691                token[token_len + chr_len] = '\0'; 
    683692                token_len += chr_len; 
    684693 
     
    727736                token_len = 0; 
    728737                inside_token = 1;       /*  turn on flag */ 
    729                 xmlStrncat(token, (const xmlChar *)chr, chr_len); 
     738                /* edge case */ 
     739                if (chr_len > s3->analyzer->maxwordlen) 
     740                    continue; 
     741 
     742                memcpy(&token[0], chr, chr_len * sizeof(xmlChar)); 
     743                token[chr_len] = '\0'; 
    730744                token_len += chr_len; 
    731745