Changeset 2133 for libswish3/trunk
- Timestamp:
- 04/17/08 21:18:55 (9 months ago)
- Files:
-
- libswish3/trunk/src/Makefile.am (modified) (2 diffs)
- libswish3/trunk/src/libswish3/config.c (modified) (3 diffs)
- libswish3/trunk/src/libswish3/hash.c (modified) (1 diff)
- libswish3/trunk/src/libswish3/mem.c (modified) (2 diffs)
- libswish3/trunk/src/libswish3/mime_types.c (modified) (1 diff)
- libswish3/trunk/src/libswish3/string.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libswish3/trunk/src/Makefile.am
r2124 r2133 11 11 # -pg is for profiling -- don't use in production 12 12 13 bin_PROGRAMS = swish_lint swish_words swish_isw utf8test swish_header 13 bin_PROGRAMS = swish_lint swish_words swish_isw swish_header 14 #bin_PROGRAMS = swish_lint swish_words swish_isw utf8test swish_header 14 15 check_PROGRAMS = swish_lint swish_header 15 16 swish_lint_SOURCES = swish_lint.c $(myheaders) … … 17 18 swish_isw_SOURCES = swish_isw.c 18 19 swish_header_SOURCES = swish_header.c $(myheaders) 19 utf8test_SOURCES = utf8test.c $(myheaders)20 #utf8test_SOURCES = utf8test.c $(myheaders) 20 21 21 22 TESTS = $(check_PROGRAMS) test.sh libswish3/trunk/src/libswish3/config.c
r2125 r2133 263 263 config->mimes = swish_mime_hash(); 264 264 265 if (SWISH_DEBUG & SWISH_DEBUG_CONFIG) 266 SWISH_DEBUG_MSG("mime hash set"); 267 265 268 /* metanames */ 266 269 // default … … 272 275 swish_hash_add(config->metanames, (xmlChar *)SWISH_DEFAULT_METANAME, tmpmeta); 273 276 swish_xfree(tmpbuf); 277 if (SWISH_DEBUG & SWISH_DEBUG_CONFIG) 278 SWISH_DEBUG_MSG("swishdefault metaname set"); 274 279 275 280 // title … … 281 286 swish_hash_add(config->metanames, (xmlChar *)SWISH_TITLE_METANAME, tmpmeta); 282 287 swish_xfree(tmpbuf); 288 if (SWISH_DEBUG & SWISH_DEBUG_CONFIG) 289 SWISH_DEBUG_MSG("swishtitle metaname set"); 283 290 284 291 /* properties */ libswish3/trunk/src/libswish3/hash.c
r2108 r2133 26 26 extern int SWISH_DEBUG; 27 27 28 int swish_hash_add(29 xmlHashTablePtr hash,30 xmlChar *key,31 void *value32 );33 int swish_hash_replace(34 xmlHashTablePtr hash,35 xmlChar *key,36 void *value37 );38 int swish_hash_delete(39 xmlHashTablePtr hash,40 xmlChar *key41 );42 boolean swish_hash_exists(43 xmlHashTablePtr hash,44 xmlChar *key45 );46 void *swish_hash_fetch(47 xmlHashTablePtr hash,48 xmlChar *key49 );50 xmlHashTablePtr swish_init_hash(51 int size52 );53 void swish_hash_merge(54 xmlHashTablePtr hash1,55 xmlHashTablePtr hash256 );57 28 static void free_hashval( 58 29 void *val, libswish3/trunk/src/libswish3/mem.c
r2104 r2133 84 84 ) 85 85 { 86 xmlChar *copy; 86 87 memcount++; 87 88 if (SWISH_DEBUG & SWISH_DEBUG_MEMORY) 88 89 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; 90 95 } 91 96 … … 114 119 115 120 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); 117 122 118 123 xmlFree(ptr); libswish3/trunk/src/libswish3/mime_types.c
r2116 r2133 198 198 int i; 199 199 xmlHashTablePtr mimes; 200 mimes = xmlHashCreate(SWISH_MIME_TABLE_COUNT / 2);200 mimes = swish_init_hash(SWISH_MIME_TABLE_COUNT / 2); 201 201 202 202 for (i = 0; i <= SWISH_MIME_TABLE_COUNT; i += 2) { libswish3/trunk/src/libswish3/string.c
r2122 r2133 31 31 #include <locale.h> 32 32 #include <err.h> 33 #include <limits.h> 34 #include <errno.h> 33 35 34 36 #include "libswish3.h" … … 57 59 #define BUFSIZE 100 58 60 59 #ifdef SNPRINTF60 61 #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; 74 68 75 69 int swish_string_to_int( … … 77 71 ) 78 72 { 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; 80 83 } 81 84
