Changeset 1955
- Timestamp:
- 11/13/07 23:31:51 (6 months ago)
- Files:
-
- libswish3/trunk/doc/libswish3.3.pod.in (modified) (1 diff)
- libswish3/trunk/perl/docmaker.pl (modified) (4 diffs)
- libswish3/trunk/src/Makefile.am (modified) (1 diff)
- libswish3/trunk/src/libswish3/config.c (modified) (4 diffs)
- libswish3/trunk/src/libswish3/libswish3.h (modified) (2 diffs)
- libswish3/trunk/src/swish_lint.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libswish3/trunk/doc/libswish3.3.pod.in
r1934 r1955 354 354 <Meta name="bar" bias="-5" /> 355 355 <Meta name="swishtitle" bias="+50" alias="title" /> 356 <Meta name="other">color size weight</ meta>356 <Meta name="other">color size weight</Meta> 357 357 358 358 <Prop name="foo" type="text" ignorecase="1" /> libswish3/trunk/perl/docmaker.pl
r1948 r1955 5 5 use SWISH::Prog::Headers; 6 6 use Search::Tools::XML; 7 use Term::ProgressBar; 7 8 8 9 my $usage = "$0 [max_files] [utf_factor]\n"; … … 26 27 my $utf_factor = shift @ARGV; 27 28 $utf_factor = 10 28 unless29 defined $utf_factor;# every Nth word gets converted to random UTF string29 unless 30 defined $utf_factor; # every Nth word gets converted to random UTF string 30 31 31 my $counter = 0; 32 33 my ($num_words, @words, $i, $j); 32 my ( $num_words, @words ); 34 33 35 34 binmode STDOUT, ":utf8"; … … 38 37 open DICT, "<$dict" or die "can't open $dict: $!\n"; 39 38 40 for ($num_words = 0 ; $words[$num_words] = <DICT> ; $num_words++) 41 { 39 for ( $num_words = 0; $words[$num_words] = <DICT>; $num_words++ ) { 42 40 chomp $words[$num_words]; 43 41 44 42 # utf hack: convert every Nth word up a factor of $num_words > 1 45 if ($utf_factor > 0 && !$num_words % $utf_factor) 46 { 43 if ( $utf_factor > 0 && !$num_words % $utf_factor ) { 47 44 no bytes; # so ord() and chr() work as expected 48 45 #warn ">> $num_words: $words[$num_words]\n"; 49 46 my $utf_word = ''; 50 for my $c (split(//, $words[$num_words])) 51 { 52 my $u = 53 chr(ord($c) + 30000); # 30000 puts it in Chinese range, I think... 47 for my $c ( split( //, $words[$num_words] ) ) { 48 my $u = chr( ord($c) + 30000 ) 49 ; # 30000 puts it in Chinese range, I think... 54 50 $utf_word .= $u; 55 51 } … … 64 60 srand; 65 61 66 for ($i = 0 ; $i < $max_files ; $i++) 67 { 68 my $this_file_words = 69 int(rand($max_words_per_file - $min_words_per_file + 1)) + 70 $min_words_per_file; 71 my $doc = ""; 72 for ($j = 0 ; $j < $this_file_words ; $j++) 73 { 74 $doc .= $words[int(rand($num_words - 1))] . " "; 62 my $i = 0; 63 my $progress 64 = Term::ProgressBar->new( { term_width => 80, count => $max_files } ); 65 66 # preallocate memory (doesn't really matter after all...) 67 my $doc = ' ' x ( $max_words_per_file * 10 ); 68 my $xml = $doc; 69 while ( $i++ < $max_files ) { 70 my $this_file_words 71 = int( rand( $max_words_per_file - $min_words_per_file + 1 ) ) 72 + $min_words_per_file; 73 $doc = ''; 74 my $word_cnt = 0; 75 while ( $word_cnt++ < $this_file_words ) { 76 $doc .= $words[ int( rand( $num_words - 1 ) ) ] . ' '; 75 77 } 76 78 Search::Tools::XML->escape($doc); 77 $doc = <<EOF 78 <?xml version="1.0" encoding="utf-8"?> 79 $xml = qq(<?xml version="1.0" encoding="utf-8"?> 79 80 <doc> 80 81 $doc 81 82 </doc> 82 EOF 83 ; 83 ); 84 84 85 #print SWISH::Prog::Headers->head( $doc, { url=>$counter++, mtime=>time(), mime=>'text/xml' } ) . $doc; 86 print SWISH::Prog::Headers->head( 87 $doc, 88 { 89 url => $counter++, 90 mtime => time(), 91 mime => 'text/xml' 92 } 93 ) 94 . $doc; 85 my $header = SWISH::Prog::Headers->head( 86 $xml, 87 { url => $i, 88 mtime => time(), 89 mime => 'text/xml' 90 } 91 ); 92 93 print $header, $xml; 94 95 $progress->update($i); 95 96 96 97 } libswish3/trunk/src/Makefile.am
r1913 r1955 9 9 # -pg is for profiling -- don't use in production 10 10 11 bin_PROGRAMS = swish_lint swish_words swish_isw 11 bin_PROGRAMS = swish_lint swish_words swish_isw utf8test 12 12 check_PROGRAMS = swish_lint 13 13 swish_lint_SOURCES = swish_lint.c $(myheaders) 14 14 swish_words_SOURCES = swish_words.c $(myheaders) 15 15 swish_isw_SOURCES = swish_isw.c 16 utf8test_SOURCES = utf8test.c $(myheaders) 16 17 17 18 TESTS = $(check_PROGRAMS) test.pl libswish3/trunk/src/libswish3/config.c
r1952 r1955 97 97 98 98 xmlHashFree(config->conf, (xmlHashDeallocator) free_config1); 99 swish_xfree(config->flags); 99 100 100 101 if (config->stash != NULL) … … 116 117 /* declare all our vars */ 117 118 swish_Config *config; 119 swish_ConfigFlags *flags; 118 120 xmlHashTablePtr c, metas, parsers, index, prop, alias, parsewords; 119 121 … … 124 126 125 127 config = swish_xmalloc(sizeof(swish_Config)); 128 flags = swish_xmalloc(sizeof(swish_ConfigFlags)); 126 129 127 130 /* init all config hashes */ … … 216 219 config->ref_cnt = 0; 217 220 config->stash = NULL; 221 config->flags = flags; 218 222 219 223 libswish3/trunk/src/libswish3/libswish3.h
r1952 r1955 148 148 typedef struct swish_StringList swish_StringList; 149 149 typedef struct swish_Config swish_Config; 150 typedef struct swish_ConfigFlags swish_ConfigFlags; 150 151 typedef struct swish_ConfigValue swish_ConfigValue; 151 152 typedef struct swish_DocInfo swish_DocInfo; … … 175 176 struct swish_Config 176 177 { 177 int ref_cnt; /* for scripting languages */ 178 void *stash; /* for scripting languages */ 179 xmlHashTablePtr conf; /* the meat */ 178 int ref_cnt; /* for scripting languages */ 179 void *stash; /* for scripting languages */ 180 xmlHashTablePtr conf; /* the meat */ 181 struct swish_ConfigFlags *flags; /* shortcuts for parsing */ 182 }; 183 184 struct swish_ConfigFlags 185 { 186 187 180 188 }; 181 189 libswish3/trunk/src/swish_lint.c
r1934 r1955 91 91 swish_debug_docinfo(parse_data->docinfo); 92 92 swish_debug_wordlist(parse_data->wordlist); 93 swish_debug_nb(parse_data->properties, "Property");94 swish_debug_nb(parse_data->metanames, "MetaName");93 swish_debug_nb(parse_data->properties, (xmlChar*)"Property"); 94 swish_debug_nb(parse_data->metanames, (xmlChar*)"MetaName"); 95 95 } 96 96 } … … 137 137 138 138 //printf("optarg = %s\n", optarg); 139 config_file = swish_xstrdup( optarg );139 config_file = swish_xstrdup( (xmlChar*)optarg ); 140 140 break; 141 141
