Changeset 2105

Show
Ignore:
Timestamp:
03/28/08 23:04:21 (2 months ago)
Author:
karpet
Message:

whitespace only

Files:

Legend:

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

    r1913 r2105  
    1717 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
    1818 */ 
    19   
     19 
    2020/* report on the isw* functions for any decimal character value. 
    2121 *  
     
    3535#include <locale.h> 
    3636 
    37 void report(char *locale, int n); 
    38 void usage(); 
    39 int main(int argc, char **argv); 
     37void report( 
     38    char *locale, 
     39    int n 
     40); 
     41void usage( 
     42); 
     43int main( 
     44    int argc, 
     45    char **argv 
     46); 
    4047 
    41 char           *types[] = 
    42 
     48char *types[] = { 
    4349    "alnum", "cntrl", "ideogram", "print", "special", 
    4450    "alpha", "digit", "lower", "punct", "upper", 
     
    4652}; 
    4753 
    48 int             ntypes = 15; 
     54int ntypes = 15; 
    4955 
    5056int 
    51 main(int argc, char **argv) 
     57main( 
     58    int argc, 
     59    char **argv 
     60
    5261{ 
    53     int             i, n; 
    54     char           *curlocale, *locale; 
     62    int i, n; 
     63    char *curlocale, *locale; 
    5564 
    5665    if (argc == 1) 
    5766        usage(); 
    58  
    5967 
    6068    locale = getenv("LC_ALL"); 
     
    6270    setlocale(LC_ALL, locale); 
    6371    curlocale = strdup(locale); 
    64      
    65          
    66     for (i = 1; i < argc; i++) 
    67     { 
    68      
     72 
     73    for (i = 1; i < argc; i++) { 
     74 
    6975        if (!iswdigit(argv[i][0])) 
    70            err(1, "arg %s is not a positive integer\n", argv[i]); 
    71      
    72         n = (int) strtol(argv[i], (char **) NULL, 10); 
     76            err(1, "arg %s is not a positive integer\n", argv[i]); 
     77 
     78        n = (int)strtol(argv[i], (char **)NULL, 10); 
    7379 
    7480        report(curlocale, n); 
     
    7985} 
    8086 
    81 void usage() 
     87void 
     88usage( 
     89
    8290{ 
    8391    printf("usage: swish_isw N\n\n"); 
     
    8896} 
    8997 
    90 void  
    91 report(char *locale, int n) 
     98void 
     99report( 
     100    char *locale, 
     101    int n 
     102
    92103{ 
    93104    int j; 
    94      
     105 
    95106    setlocale(LC_ALL, locale); 
    96107    printf("locale: %s\n", setlocale(LC_ALL, NULL)); 
    97      
     108 
    98109    printf("%lc  %d  \\x%04x\n", n, n, n); 
    99          
    100     for (j = 0; j < ntypes; j++) 
    101     { 
     110 
     111    for (j = 0; j < ntypes; j++) { 
    102112        printf("%10s => %d\n", types[j], iswctype(n, wctype(types[j]))); 
    103113    } 
  • libswish3/trunk/src/swish_lint.c

    r2098 r2105  
    1717 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
    1818 */ 
    19   
     19 
    2020/* swish_lint.c -- test libswish3 */ 
    2121 
     
    3131#include "libswish3.h" 
    3232 
    33 int             debug = 0; 
    34  
    35 int             main(int argc, char **argv); 
    36 int             usage(); 
    37 void            handler(swish_ParserData * parser_data); 
    38 void            libxml2_version(); 
    39 void            swish_version(); 
    40  
    41 int             twords = 0; 
     33int debug = 0; 
     34 
     35int main( 
     36    int argc, 
     37    char **argv 
     38); 
     39int usage( 
     40); 
     41void handler( 
     42    swish_ParserData *parser_data 
     43); 
     44void libxml2_version( 
     45); 
     46void swish_version( 
     47); 
     48 
     49int twords = 0; 
    4250 
    4351extern int SWISH_DEBUG; 
    4452 
    45 static struct option longopts[] = 
    46 
     53static struct option longopts[] = { 
    4754    {"config", required_argument, 0, 'c'}, 
    48     {"debug", required_argument, 0, 'd'}, 
    49     {"help",   no_argument, 0, 'h'}, 
     55    {"debug", required_argument, 0, 'd'}, 
     56    {"help", no_argument, 0, 'h'}, 
    5057    {0, 0, 0, 0} 
    5158}; 
    5259 
    53  
    54 void libxml2_version() 
    55 
    56     printf("libxml2 version: %s\n",  LIBXML_DOTTED_VERSION);    
    57 
    58  
    59 void swish_version() 
     60void 
     61libxml2_version( 
     62
     63
     64    printf("libxml2 version: %s\n", LIBXML_DOTTED_VERSION); 
     65
     66 
     67void 
     68swish_version( 
     69
    6070{ 
    6171    printf("libswish3 version %s\n", SWISH_LIB_VERSION); 
     
    6373} 
    6474 
    65 int  
    66 usage() 
    67 
    68  
    69     char * descr = "swish_lint is an example program for using libswish3\n"; 
     75int 
     76usage( 
     77
     78
     79 
     80    char *descr = "swish_lint is an example program for using libswish3\n"; 
    7081    printf("swish_lint [opts] [- | file(s)]\n"); 
    7182    printf("opts:\n --config conf_file.xml\n --debug [lvl]\n --help\n"); 
     
    7687} 
    7788 
    78 void  
    79 handler(swish_ParserData * parser_data) 
    80 
    81  
    82     /* return; */ 
     89void 
     90handler( 
     91    swish_ParserData *parser_data 
     92
     93
     94 
     95    /* 
     96       return;  
     97     */ 
    8398 
    8499    printf("nwords: %d\n", parser_data->docinfo->nwords); 
    85      
     100 
    86101    if (SWISH_DEBUG) 
    87102        swish_mem_debug(); 
    88      
     103 
    89104    twords += parser_data->docinfo->nwords; 
    90105 
    91106    if (SWISH_DEBUG & SWISH_DEBUG_DOCINFO) 
    92107        swish_debug_docinfo(parser_data->docinfo); 
    93          
     108 
    94109    if (SWISH_DEBUG & SWISH_DEBUG_WORDLIST) 
    95110        swish_debug_wordlist(parser_data->wordlist); 
    96          
     111 
    97112    if (SWISH_DEBUG & SWISH_DEBUG_NAMEDBUFFER) { 
    98         swish_debug_nb(parser_data->properties, (xmlChar*)"Property"); 
    99         swish_debug_nb(parser_data->metanames,  (xmlChar*)"MetaName"); 
    100     } 
    101 
    102  
    103 int  
    104 main(int argc, char **argv) 
    105 
    106     int             i, ch; 
    107     extern char    *optarg; 
    108     extern int      optind; 
    109     int             option_index; 
    110     int             files; 
    111     int             overwrite; 
    112     char           *etime; 
    113     double          start_time; 
    114     xmlChar        *config_file = NULL; 
    115     swish_3        *s3; 
    116      
    117     option_index    = 0; 
    118     files           = 0; 
    119     overwrite       = 0; 
    120     start_time      = swish_time_elapsed(); 
    121     s3              = swish_init_swish3( &handler, NULL ); 
    122  
    123     while ((ch = getopt_long(argc, argv, "c:d:f:h", longopts, &option_index)) != -1) 
    124     { 
    125         /* printf("switch is %c\n",   ch); */ 
    126         /* printf("optarg is %s\n", optarg); */ 
    127         /* printf("optind = %d\n",  optind); */ 
    128  
    129         switch (ch) 
    130         { 
    131         case 0:    /* If this option set a flag, do nothing else now. */ 
     113        swish_debug_nb(parser_data->properties, (xmlChar *)"Property"); 
     114        swish_debug_nb(parser_data->metanames, (xmlChar *)"MetaName"); 
     115    } 
     116
     117 
     118int 
     119main( 
     120    int argc, 
     121    char **argv 
     122
     123
     124    int i, ch; 
     125    extern char *optarg; 
     126    extern int optind; 
     127    int option_index; 
     128    int files; 
     129    int overwrite; 
     130    char *etime; 
     131    double start_time; 
     132    xmlChar *config_file = NULL; 
     133    swish_3 *s3; 
     134 
     135    option_index = 0; 
     136    files = 0; 
     137    overwrite = 0; 
     138    start_time = swish_time_elapsed(); 
     139    s3 = swish_init_swish3(&handler, NULL); 
     140 
     141    while ((ch = getopt_long(argc, argv, "c:d:f:h", longopts, &option_index)) != -1) { 
     142 
     143        switch (ch) { 
     144        case 0:                /* If this option set a flag, do nothing else now. */ 
    132145            if (longopts[option_index].flag != 0) 
    133146                break; 
     
    138151            break; 
    139152 
    140         case 'c':    /* should we set up default config first ? then override 
    141                  * here ? */ 
     153        case 'c':              /* should we set up default config first ? then override 
     154                                 * here ? */ 
    142155 
    143156            //printf("optarg = %s\n", optarg); 
    144             config_file = swish_xstrdup( (xmlChar*)optarg ); 
    145             break; 
    146              
     157            config_file = swish_xstrdup((xmlChar *)optarg); 
     158            break; 
    147159 
    148160        case 'd': 
     
    152164                err(1, "-d option requires a positive integer as argument\n"); 
    153165 
    154             SWISH_DEBUG = (int) strtol(optarg, (char **) NULL, 10); 
    155             break; 
    156  
     166            SWISH_DEBUG = (int)strtol(optarg, (char **)NULL, 10); 
     167            break; 
    157168 
    158169        case 'o': 
     
    168179 
    169180    } 
    170      
    171     if (config_file != NULL) 
    172     { 
     181 
     182    if (config_file != NULL) { 
    173183        s3->config = swish_add_config(config_file, s3->config); 
    174184    } 
    175185 
    176186    i = optind; 
    177      
    178     /* die with no args */ 
    179     if (!i || i >= argc) 
    180     { 
    181         swish_free_swish3( s3 ); 
     187 
     188    /* 
     189       die with no args  
     190     */ 
     191    if (!i || i >= argc) { 
     192        swish_free_swish3(s3); 
    182193        usage(); 
    183194 
    184195    } 
    185      
    186     if (SWISH_DEBUG == 20) 
    187     { 
    188         swish_debug_config(s3->config);    
    189     } 
    190              
    191     for (; i < argc; i++) 
    192     { 
    193  
    194         if (argv[i][0] != '-') 
    195         { 
     196 
     197    if (SWISH_DEBUG == 20) { 
     198        swish_debug_config(s3->config); 
     199    } 
     200 
     201    for (; i < argc; i++) { 
     202 
     203        if (argv[i][0] != '-') { 
    196204 
    197205            printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); 
    198206            printf("parse_file for %s\n", argv[i]); 
    199             if (! swish_parse_file(s3, (unsigned char *) argv[i])) 
     207            if (!swish_parse_file(s3, (unsigned char *)argv[i])) 
    200208                files++; 
    201209 
    202210        } 
    203         else if (argv[i][0] == '-' && !argv[i][1]) 
    204         { 
     211        else if (argv[i][0] == '-' && !argv[i][1]) { 
    205212 
    206213            printf("reading from stdin\n"); 
     
    217224    printf("%s total time\n\n", etime); 
    218225    swish_xfree(etime); 
    219      
    220     swish_free_swish3( s3 ); 
     226 
     227    swish_free_swish3(s3); 
    221228 
    222229    if (config_file != NULL) 
    223230        swish_xfree(config_file); 
    224          
    225      
     231 
    226232    return (0); 
    227233}