Changeset 1931
- Timestamp:
- 05/01/07 23:53:25 (1 year ago)
- Files:
-
- libswish3/trunk/bindings/perl/3.xs (modified) (7 diffs)
- libswish3/trunk/bindings/perl/t/20metanames.t (added)
- libswish3/trunk/bindings/perl/t/test.html (modified) (1 diff)
- libswish3/trunk/src/libswish3/libswish3.h (modified) (1 diff)
- libswish3/trunk/src/libswish3/parser.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libswish3/trunk/bindings/perl/3.xs
r1930 r1931 300 300 301 301 302 static void _store_xml2_pair_in_perl_hash(xmlChar * val, HV * perl_hash, xmlChar * key)302 static void sp_store_xml2_pair_in_perl_hash(xmlChar * val, HV * perl_hash, xmlChar * key) 303 303 { 304 304 dTHX; … … 306 306 } 307 307 308 static HV * _xml2_hash_to_perl_hash( xmlHashTablePtr xml2_hash ) 308 static HV * 309 sp_xml2_hash_to_perl_hash( xmlHashTablePtr xml2_hash ) 309 310 { 310 311 dTHX; 311 312 HV * perl_hash = newHV(); 312 313 /* perl bug means we must increm ref count manually */ 313 sv_2mortal((SV*)perl_hash);314 xmlHashScan(xml2_hash, (xmlHashScanner) _store_xml2_pair_in_perl_hash, perl_hash);314 SvREFCNT_inc((SV*)perl_hash); 315 xmlHashScan(xml2_hash, (xmlHashScanner)sp_store_xml2_pair_in_perl_hash, perl_hash); 315 316 return perl_hash; 316 317 } 317 318 318 static void _add_key_to_array(xmlChar * val, AV * mykeys, xmlChar * key) 319 static void 320 sp_add_key_to_array(xmlChar * val, AV * mykeys, xmlChar * key) 319 321 { 320 322 dTHX; … … 322 324 } 323 325 324 static AV * _get_xml2_hash_keys( xmlHashTablePtr xml2_hash ) 326 static AV * 327 sp_get_xml2_hash_keys( xmlHashTablePtr xml2_hash ) 325 328 { 326 329 dTHX; 327 330 AV * mykeys = newAV(); 328 sv_2mortal((SV*)mykeys); /* needed?? */329 xmlHashScan(xml2_hash, (xmlHashScanner) _add_key_to_array, mykeys);331 SvREFCNT_inc((SV*)mykeys); /* needed?? */ 332 xmlHashScan(xml2_hash, (xmlHashScanner)sp_add_key_to_array, mykeys); 330 333 return mykeys; 331 334 } 332 335 333 334 335 336 void sp_test_handler( swish_ParseData * parse_data ) 336 static void 337 sp_nb_hash_to_phash(xmlBufferPtr buf, HV *phash, xmlChar *key) 338 { 339 340 /* TODO: it'd be nice to split on \003 here and make each hash val an AV ref */ 341 dTHX; 342 hv_store(phash, key, strlen(key), 343 newSVpvn((char*)xmlBufferContent(buf), xmlBufferLength(buf)), 344 0); 345 } 346 347 static HV * 348 sp_nb_to_hash( swish_NamedBuffer * nb ) 349 { 350 dTHX; 351 HV * perl_hash = newHV(); 352 SvREFCNT_inc((SV*)perl_hash); 353 xmlHashScan(nb->hash, (xmlHashScanner)sp_nb_hash_to_phash, perl_hash); 354 return perl_hash; 355 } 356 357 358 void 359 sp_test_handler( swish_ParseData * parse_data ) 337 360 { 338 361 dTHX; … … 1059 1082 1060 1083 SV* 1061 property(self, p)1084 property(self, p) 1062 1085 swish_ParseData * self; 1063 1086 xmlChar * p; … … 1073 1096 RETVAL 1074 1097 1098 HV* 1099 properties(self) 1100 swish_ParseData * self 1101 1102 CODE: 1103 RETVAL = sp_nb_to_hash( self->properties ); 1104 1105 OUTPUT: 1106 RETVAL 1107 1108 1109 HV* 1110 metanames(self) 1111 swish_ParseData * self 1112 1113 CODE: 1114 RETVAL = sp_nb_to_hash( self->metanames ); 1115 1116 OUTPUT: 1117 RETVAL 1118 1119 1075 1120 1076 1121 swish_DocInfo * … … 1133 1178 1134 1179 CODE: 1135 RETVAL = _get_xml2_hash_keys(self->conf);1180 RETVAL = sp_get_xml2_hash_keys(self->conf); 1136 1181 1137 1182 OUTPUT: … … 1151 1196 CODE: 1152 1197 sc = swish_subconfig_hash(self, (xmlChar*)key); 1153 RETVAL = _xml2_hash_to_perl_hash(sc);1198 RETVAL = sp_xml2_hash_to_perl_hash(sc); 1154 1199 1155 1200 OUTPUT: libswish3/trunk/bindings/perl/t/test.html
r1914 r1931 1 1 <html> 2 <head> 3 <title>This is the title of the test.html doc</title> 4 <meta name="foo" content="metaname bar" /> 5 </head> 2 6 <body> 3 7 <p>some words</p> libswish3/trunk/src/libswish3/libswish3.h
r1930 r1931 102 102 #define SWISH_PROP_MTIME "swishlastmodified" 103 103 #define SWISH_PROP_DESCRIPTION "swishdescription" 104 #define SWISH_PROP_CONNECTOR " | " 104 #define SWISH_PROP_CONNECTOR " \3" 105 #define SWISH_META_CONNECTOR " \3" 105 106 106 107 /* utils */ libswish3/trunk/src/libswish3/parser.c
r1930 r1931 107 107 const xmlChar * URI); 108 108 109 static void chars_to_words(swish_ParseData * parse_data, const xmlChar * ch, int len);109 static void buffer_characters(swish_ParseData * parse_data, const xmlChar * ch, int len); 110 110 static void mycharacters(void *parse_data, const xmlChar * ch, int len); 111 111 static void mycomments(void *parse_data, const xmlChar * ch); … … 251 251 if (metaname != NULL && metacontent != NULL) 252 252 { 253 if (SWISH_DEBUG > 3)253 if (SWISH_DEBUG == SWISH_DEBUG_PARSER) 254 254 swish_debug_msg("found HTML meta: %s => %s", metaname, metacontent); 255 255 … … 257 257 parse_data->bump_word = 1; 258 258 open_tag(parse_data, metaname, NULL); 259 chars_to_words(parse_data, metacontent, xmlStrlen(metacontent));259 buffer_characters(parse_data, metacontent, xmlStrlen(metacontent)); 260 260 close_tag(parse_data, metaname); 261 261 swish_xfree(swishtag); … … 314 314 swish_TagStack *s = parse_data->metastack; 315 315 316 if (SWISH_DEBUG > 10)316 if (SWISH_DEBUG == SWISH_DEBUG_PARSER) 317 317 swish_debug_msg("buffer is >>%s<< before flush, word_pos = %d", 318 318 xmlBufferContent(parse_data->buf_ptr), parse_data->word_pos); … … 330 330 swish_add_buf_to_nb( parse_data->metanames, 331 331 metaname, 332 parse_data->buf_ptr, '\0', 0, 1);332 parse_data->buf_ptr, (xmlChar*)SWISH_META_CONNECTOR, 0, 1); 333 333 334 334 if (parse_data->context_as_meta) … … 341 341 swish_add_buf_to_nb(parse_data->metanames, 342 342 s->temp->name, 343 parse_data->buf_ptr, '\0', 0, 1);343 parse_data->buf_ptr, (xmlChar*)SWISH_META_CONNECTOR, 0, 1); 344 344 } 345 345 } … … 513 513 /* handle all characters in doc */ 514 514 static void 515 chars_to_words(swish_ParseData * parse_data, const xmlChar * ch, int len)515 buffer_characters(swish_ParseData * parse_data, const xmlChar * ch, int len) 516 516 { 517 517 int i; … … 539 539 540 540 if (parse_data->bump_word && xmlBufferLength(buf)) 541 swish_append_buffer(buf, (xmlChar *)" ", 1);541 swish_append_buffer(buf, (xmlChar*)" ", 1); 542 542 543 543 swish_append_buffer(buf, output, len); … … 546 546 { 547 547 //swish_debug_msg(" appending ' ' to prop_buf"); 548 swish_append_buffer(parse_data->prop_buf, (xmlChar *)" ", 1);548 swish_append_buffer(parse_data->prop_buf, (xmlChar*)" ", 1); 549 549 } 550 550 … … 563 563 swish_debug_msg(" >> mycharacters()"); 564 564 565 chars_to_words(parse_data, ch, len);565 buffer_characters(parse_data, ch, len); 566 566 } 567 567 … … 577 577 return; 578 578 579 chars_to_words(parse_data, ch, len);579 buffer_characters(parse_data, ch, len); 580 580 } 581 581 … … 1659 1659 (xmlChar*)SWISH_DEFAULT_METANAME); 1660 1660 1661 if (SWISH_DEBUG > 2)1661 if (SWISH_DEBUG == SWISH_DEBUG_PARSER) 1662 1662 swish_debug_msg("stack pushed for %s", parse_data->metastack->flat); 1663 1663 1664 chars_to_words(parse_data, buffer, size);1664 buffer_characters(parse_data, buffer, size); 1665 1665 flush_buffer(parse_data, (xmlChar*)SWISH_DEFAULT_METANAME, (xmlChar*)SWISH_DEFAULT_METANAME); 1666 1666 1667 1667 if (out != NULL) 1668 1668 { 1669 if (SWISH_DEBUG > 3)1669 if (SWISH_DEBUG == SWISH_DEBUG_PARSER) 1670 1670 swish_debug_msg("tmp text buffer being freed"); 1671 1671
