Changeset 2133

Show
Ignore:
Timestamp:
04/17/08 21:18:55 (1 month ago)
Author:
karpet
Message:

make test now works under linux. this was an issue with s[n]printf

Files:

Legend:

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

    r2124 r2133  
    1111# -pg is for profiling -- don't use in production 
    1212 
    13 bin_PROGRAMS = swish_lint swish_words swish_isw utf8test swish_header 
     13bin_PROGRAMS = swish_lint swish_words swish_isw swish_header 
     14#bin_PROGRAMS = swish_lint swish_words swish_isw utf8test swish_header 
    1415check_PROGRAMS = swish_lint swish_header 
    1516swish_lint_SOURCES = swish_lint.c $(myheaders) 
     
    1718swish_isw_SOURCES = swish_isw.c 
    1819swish_header_SOURCES = swish_header.c $(myheaders) 
    19 utf8test_SOURCES = utf8test.c $(myheaders) 
     20#utf8test_SOURCES = utf8test.c $(myheaders) 
    2021 
    2122TESTS = $(check_PROGRAMS) test.sh 
  • libswish3/trunk/src/libswish3/config.c

    r2125 r2133  
    263263    config->mimes = swish_mime_hash(); 
    264264 
     265    if (SWISH_DEBUG & SWISH_DEBUG_CONFIG) 
     266        SWISH_DEBUG_MSG("mime hash set"); 
     267 
    265268/* metanames */ 
    266269    // default 
     
    272275    swish_hash_add(config->metanames, (xmlChar *)SWISH_DEFAULT_METANAME, tmpmeta); 
    273276    swish_xfree(tmpbuf); 
     277    if (SWISH_DEBUG & SWISH_DEBUG_CONFIG) 
     278        SWISH_DEBUG_MSG("swishdefault metaname set"); 
    274279 
    275280    // title 
     
    281286    swish_hash_add(config->metanames, (xmlChar *)SWISH_TITLE_METANAME, tmpmeta); 
    282287    swish_xfree(tmpbuf); 
     288    if (SWISH_DEBUG & SWISH_DEBUG_CONFIG) 
     289        SWISH_DEBUG_MSG("swishtitle metaname set"); 
    283290 
    284291/* properties */ 
  • libswish3/trunk/src/libswish3/hash.c

    r2108 r2133  
    2626extern int SWISH_DEBUG; 
    2727 
    28 int swish_hash_add( 
    29     xmlHashTablePtr hash, 
    30     xmlChar *key, 
    31     void *value 
    32 ); 
    33 int swish_hash_replace( 
    34     xmlHashTablePtr hash, 
    35     xmlChar *key, 
    36     void *value 
    37 ); 
    38 int swish_hash_delete( 
    39     xmlHashTablePtr hash, 
    40     xmlChar *key 
    41 ); 
    42 boolean swish_hash_exists( 
    43     xmlHashTablePtr hash, 
    44     xmlChar *key 
    45 ); 
    46 void *swish_hash_fetch( 
    47     xmlHashTablePtr hash, 
    48     xmlChar *key 
    49 ); 
    50 xmlHashTablePtr swish_init_hash( 
    51     int size 
    52 ); 
    53 void swish_hash_merge( 
    54     xmlHashTablePtr hash1, 
    55     xmlHashTablePtr hash2 
    56 ); 
    5728static void free_hashval( 
    5829    void *val, 
  • libswish3/trunk/src/libswish3/mem.c

    r2104 r2133  
    8484) 
    8585{ 
     86    xmlChar *copy; 
    8687    memcount++; 
    8788    if (SWISH_DEBUG & SWISH_DEBUG_MEMORY) 
    8889        SWISH_DEBUG_MSG("memcount = %ld", memcount); 
    89     return (xmlStrdup(ptr)); 
     90    copy = xmlStrdup(ptr); 
     91    if (copy == NULL)  
     92        SWISH_CROAK("strdup returned NULL for %s", ptr); 
     93 
     94    return copy; 
    9095} 
    9196 
     
    114119     
    115120    if (SWISH_DEBUG & SWISH_DEBUG_MEMORY) 
    116         SWISH_DEBUG_MSG("freeing %s 0x%x", ptr, (int)ptr); 
     121        SWISH_DEBUG_MSG("freeing %s 0x%x", (char*)ptr, (int)ptr); 
    117122 
    118123    xmlFree(ptr); 
  • libswish3/trunk/src/libswish3/mime_types.c

    r2116 r2133  
    198198    int i; 
    199199    xmlHashTablePtr mimes; 
    200     mimes = xmlHashCreate(SWISH_MIME_TABLE_COUNT / 2); 
     200    mimes = swish_init_hash(SWISH_MIME_TABLE_COUNT / 2); 
    201201 
    202202    for (i = 0; i <= SWISH_MIME_TABLE_COUNT; i += 2) { 
  • libswish3/trunk/src/libswish3/string.c

    r2122 r2133  
    3131#include <locale.h> 
    3232#include <err.h> 
     33#include <limits.h> 
     34#include <errno.h> 
    3335 
    3436#include "libswish3.h" 
     
    5759#define BUFSIZE 100 
    5860 
    59 #ifdef SNPRINTF 
    6061#define CONVERT_TO_STRING(FMT) \ 
    61     char buf[BUFSIZE+1];\ 
    62     int len = SNPRINTF(buf, BUFSIZE, (FMT), val);\ 
    63     if (len == -1 || len > BUFSIZE) buf[BUFSIZE+1] = '\0';\ 
    64     else buf[len+1] = '\0';\ 
    65     return swish_xstrdup((xmlChar*)buf); 
    66 #else 
    67 #define CONVERT_TO_STRING(FMT) \ 
    68     char buf[BUFSIZE+1];\ 
    69     buf[BUFSIZE+1] = '\0';\ 
    70     sprintf(buf, (FMT), val);\ 
    71     if (buf[BUFSIZE]) abort();\ 
    72     return swish_xstrdup((xmlChar*)buf); 
    73 #endif 
     62    xmlChar *str;\ 
     63    int ret;\ 
     64    str = swish_xmalloc(BUFSIZE);\ 
     65    ret = snprintf(str, BUFSIZE, (FMT), val);\ 
     66    if (ret<0) SWISH_CROAK("snprintf failed with %d", ret);\ 
     67    return str; 
    7468 
    7569int swish_string_to_int( 
     
    7771)  
    7872{ 
    79     return (int)strtol(buf, (char **)NULL, 10); 
     73    long i; 
     74    errno = 0; 
     75    i = strtol(buf, (char **)NULL, 10); 
     76    /* Check for various possible errors */ 
     77    if ((errno == ERANGE && (i == LONG_MAX || i == LONG_MIN)) 
     78         || (errno != 0 && i == 0)) { 
     79         perror("strtol"); 
     80         exit(EXIT_FAILURE); 
     81    } 
     82    return (int)i; 
    8083} 
    8184