Changeset 2129

Show
Ignore:
Timestamp:
04/15/08 10:29:48 (1 month ago)
Author:
karpet
Message:

use our string_to_int instead of strtol() directly

Files:

Legend:

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

    r2125 r2129  
    373373     
    374374    if (xmlStrEqual(attr, (xmlChar *)"ignore_case")) { 
    375         prop->ignore_case = (boolean)strtol((char *)attr_val, (char **)NULL, 10); 
     375        prop->ignore_case = (boolean)swish_string_to_int((char *)attr_val); 
    376376    } 
    377377    else if (xmlStrEqual(attr, (xmlChar *)"max")) { 
    378         prop->max = (int)strtol((char *)attr_val, (char **)NULL, 10); 
     378        prop->max = swish_string_to_int((char *)attr_val); 
    379379    } 
    380380    else if (xmlStrEqual(attr, (xmlChar *)"verbatim")) { 
    381         prop->verbatim = (boolean)strtol((char *)attr_val, (char **)NULL, 10); 
     381        prop->verbatim = (boolean)swish_string_to_int((char *)attr_val); 
    382382    } 
    383383    else if (xmlStrEqual(attr, (xmlChar *)"sort")) { 
    384         prop->sort = (boolean)strtol((char *)attr_val, (char **)NULL, 10); 
     384        prop->sort = (boolean)swish_string_to_int((char *)attr_val); 
    385385    } 
    386386    else if (xmlStrEqual(attr, (xmlChar *)"id")) { 
  • libswish3/trunk/src/libswish3/parser.c

    r2128 r2129  
    13021302                SWISH_WARN("Failed to parse Content-Length header '%s'", line); 
    13031303 
    1304             info->size = strtol((char *)val, NULL, 10); 
     1304            info->size = swish_string_to_int((char *)val); 
    13051305            continue; 
    13061306        } 
     
    13101310                SWISH_WARN("Failed to parse Last-Modified header '%s'", line); 
    13111311 
    1312             info->mtime = strtol((char *)val, NULL, 10); 
     1312            info->mtime = swish_string_to_int((char *)val); 
    13131313            continue; 
    13141314        } 
     
    13201320                SWISH_WARN("Failed to parse Last-Mtime header '%s'", line); 
    13211321 
    1322             info->mtime = strtol((char *)val, NULL, 10); 
     1322            info->mtime = swish_string_to_int((char *)val); 
    13231323            continue; 
    13241324        } 
     
    14641464 
    14651465    setenv("SWISH_PARSER_ERROR", "0", 0); 
    1466     SWISH_PARSER_ERROR = (int)strtol(getenv("SWISH_PARSER_ERROR"), (char **)NULL, 10); 
     1466    SWISH_PARSER_ERROR = swish_string_to_int(getenv("SWISH_PARSER_ERROR")); 
    14671467 
    14681468    setenv("SWISH_PARSER_WARNING", "0", 0); 
    1469     SWISH_PARSER_WARNING = (int)strtol(getenv("SWISH_PARSER_WARNING"), (char **)NULL, 10); 
     1469    SWISH_PARSER_WARNING = swish_string_to_int(getenv("SWISH_PARSER_WARNING")); 
    14701470 
    14711471    setenv("SWISH_PARSER_FATAL", "0", 0); 
    1472     SWISH_PARSER_FATAL = (int)strtol(getenv("SWISH_PARSER_FATAL"), (char **)NULL, 10); 
     1472    SWISH_PARSER_FATAL = swish_string_to_int(getenv("SWISH_PARSER_FATAL")); 
    14731473 
    14741474    if (SWISH_DEBUG) { 
     
    14791479} 
    14801480 
    1481 /*  
    1482  * TODO there's a memory leak somewhere in here. one more malloc than free  
    1483  */ 
    14841481int 
    14851482swish_parse_fh( 
  • libswish3/trunk/src/libswish3/swish.c

    r2104 r2129  
    9696    if (!SWISH_DEBUG) { 
    9797 
    98         SWISH_DEBUG += (int)strtol(getenv("SWISH_DEBUG"), (char **)NULL, 10); 
     98        SWISH_DEBUG += swish_string_to_int(getenv("SWISH_DEBUG")); 
    9999 
    100100/* additional env vars just increase the global var value */ 
    101101 
    102         if ((int)strtol(getenv("SWISH_DEBUG_MEMORY"), (char **)NULL, 10)) { 
     102        if (swish_string_to_int(getenv("SWISH_DEBUG_MEMORY"))) { 
    103103            SWISH_DEBUG += SWISH_DEBUG_MEMORY; 
    104104        } 
    105         if ((int)strtol(getenv("SWISH_DEBUG_CONFIG"), (char **)NULL, 10)) { 
     105        if (swish_string_to_int(getenv("SWISH_DEBUG_CONFIG"))) { 
    106106            SWISH_DEBUG += SWISH_DEBUG_CONFIG; 
    107107        } 
    108         if ((int)strtol(getenv("SWISH_DEBUG_DOCINFO"), (char **)NULL, 10)) { 
     108        if (swish_string_to_int(getenv("SWISH_DEBUG_DOCINFO"))) { 
    109109            SWISH_DEBUG += SWISH_DEBUG_DOCINFO; 
    110110        } 
    111         if ((int)strtol(getenv("SWISH_DEBUG_WORDLIST"), (char **)NULL, 10)) { 
     111        if (swish_string_to_int(getenv("SWISH_DEBUG_WORDLIST"))) { 
    112112            SWISH_DEBUG += SWISH_DEBUG_WORDLIST; 
    113113        } 
    114         if ((int)strtol(getenv("SWISH_DEBUG_PARSER"), (char **)NULL, 10)) { 
     114        if (swish_string_to_int(getenv("SWISH_DEBUG_PARSER"))) { 
    115115            SWISH_DEBUG += SWISH_DEBUG_PARSER; 
    116116        } 
    117         if ((int)strtol(getenv("SWISH_DEBUG_NAMEDBUFFER"), (char **)NULL, 10)) { 
     117        if (swish_string_to_int(getenv("SWISH_DEBUG_NAMEDBUFFER"))) { 
    118118            SWISH_DEBUG += SWISH_DEBUG_NAMEDBUFFER; 
    119119        } 
  • libswish3/trunk/src/swish_header.c

    r2097 r2129  
    8686                err(1, "-d option requires a positive integer as argument\n"); 
    8787 
    88             SWISH_DEBUG = (int) strtol(optarg, (char **) NULL, 10); 
     88            SWISH_DEBUG = swish_string_to_int(optarg); 
    8989            break; 
    9090 
  • libswish3/trunk/src/swish_isw.c

    r2105 r2129  
    3434#include <ctype.h> 
    3535#include <locale.h> 
     36 
     37#include "libswish3.h" 
    3638 
    3739void report( 
     
    7678            err(1, "arg %s is not a positive integer\n", argv[i]); 
    7779 
    78         n = (int)strtol(argv[i], (char **)NULL, 10); 
     80        n = swish_string_to_int(argv[i]); 
    7981 
    8082        report(curlocale, n); 
  • libswish3/trunk/src/swish_lint.c

    r2121 r2129  
    181181                err(1, "-d option requires a positive integer as argument\n"); 
    182182 
    183             SWISH_DEBUG = (int)strtol(optarg, (char **)NULL, 10); 
     183            SWISH_DEBUG = swish_string_to_int(optarg); 
    184184            break; 
    185185 
  • libswish3/trunk/src/xapian/swish_xapian.cpp

    r2112 r2129  
    622622                err(1, "-d option requires a positive integer as argument\n"); 
    623623 
    624             SWISH_DEBUG = (int)strtol(optarg, (char **)NULL, 10); 
     624            SWISH_DEBUG = swish_string_to_int(optarg); 
    625625            break; 
    626626 
     
    634634 
    635635        case 's': 
    636             skip_duplicates = (int)strtol(optarg, (char **)NULL, 10); 
     636            skip_duplicates = swish_string_to_int(optarg); 
    637637            break; 
    638638