Changeset 2188
- Timestamp:
- 11/03/08 21:44:48 (2 months ago)
- Files:
-
- libswish3/trunk/src/libswish3/libswish3.h (modified) (2 diffs)
- libswish3/trunk/src/libswish3/namedbuffer.c (modified) (3 diffs)
- libswish3/trunk/src/libswish3/parser.c (modified) (8 diffs)
- libswish3/trunk/src/t/001-wordcount.t (modified) (2 diffs)
- libswish3/trunk/src/t/003-properties.t (modified) (2 diffs)
- libswish3/trunk/src/test_configs/dom.conf (added)
- libswish3/trunk/src/test_docs/dom.xml (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libswish3/trunk/src/libswish3/libswish3.h
r2187 r2188 600 600 xmlBufferPtr buf, 601 601 xmlChar * joiner, 602 intcleanwsp,602 boolean cleanwsp, 603 603 int autovivify); 604 604 void swish_add_str_to_nb( swish_NamedBuffer * nb, … … 607 607 unsigned int len, 608 608 xmlChar * joiner, 609 intcleanwsp,609 boolean cleanwsp, 610 610 int autovivify); 611 611 void swish_append_buffer( xmlBufferPtr buf, xmlChar * txt, int len ); libswish3/trunk/src/libswish3/namedbuffer.c
r2178 r2188 149 149 xmlBufferPtr buf, 150 150 xmlChar *joiner, 151 intcleanwsp,151 boolean cleanwsp, 152 152 int autovivify 153 153 ) … … 164 164 unsigned int len, 165 165 xmlChar *joiner, 166 intcleanwsp,166 boolean cleanwsp, 167 167 int autovivify 168 168 ) … … 197 197 198 198 if (cleanwsp) { 199 /* SWISH_DEBUG_MSG("before cleanwsp: '%s'", str); */ 199 //SWISH_DEBUG_MSG("before cleanwsp: '%s'", str); 200 200 nowhitesp = swish_str_skip_ws(str); 201 201 swish_str_trim_ws(nowhitesp); 202 /* SWISH_DEBUG_MSG("after cleanwsp: adding '%s' to buffer '%s'", nowhitesp, name); */ 202 //SWISH_DEBUG_MSG("after cleanwsp: adding '%s' to buffer '%s'", nowhitesp, name); 203 203 swish_append_buffer(buf, nowhitesp, xmlStrlen(nowhitesp)); 204 204 } libswish3/trunk/src/libswish3/parser.c
r2187 r2188 684 684 { 685 685 swish_ParserData *parser_data; 686 xmlChar *baked; 687 686 688 parser_data = (swish_ParserData *)data; 687 689 … … 705 707 push_tag_stack(parser_data->domstack, (xmlChar *)tag, parser_data->tag, SWISH_DOT); 706 708 } 707 709 708 710 /* 709 711 * set property if this tag is configured for it 710 712 */ 711 if (swish_hash_exists(parser_data->s3->config->properties, parser_data->tag)) { 713 if (swish_hash_exists(parser_data->s3->config->properties, parser_data->tag) 714 || 715 swish_hash_exists(parser_data->s3->config->properties, parser_data->domstack->head->context) 716 ) { 712 717 if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 713 718 SWISH_DEBUG_MSG(" %s = new property", parser_data->tag); … … 715 720 add_stack_to_prop_buf(NULL, parser_data); /* NULL means all properties in the stack are added */ 716 721 xmlBufferEmpty(parser_data->prop_buf); 717 718 push_tag_stack(parser_data->propstack, (xmlChar *)tag, parser_data->tag, SWISH_SPACE); 722 723 if (swish_hash_exists(parser_data->s3->config->properties, parser_data->domstack->head->context)) 724 baked = parser_data->domstack->head->context; 725 else 726 baked = parser_data->tag; 727 728 push_tag_stack(parser_data->propstack, (xmlChar *)tag, baked, SWISH_SPACE); 719 729 720 730 if (SWISH_DEBUG & SWISH_DEBUG_PARSER) … … 725 735 * likewise for metastack 726 736 */ 727 if (swish_hash_exists(parser_data->s3->config->metanames, parser_data->tag)) { 737 if (swish_hash_exists(parser_data->s3->config->metanames, parser_data->tag) 738 || 739 swish_hash_exists(parser_data->s3->config->metanames, parser_data->domstack->head->context) 740 ) { 728 741 if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 729 742 SWISH_DEBUG_MSG(" %s = new metaname", parser_data->tag); … … 731 744 flush_buffer(parser_data, parser_data->metastack->head->baked, 732 745 parser_data->metastack->head->context); 733 734 push_tag_stack(parser_data->metastack, (xmlChar *)tag, parser_data->tag, SWISH_SPACE); 746 747 if (swish_hash_exists(parser_data->s3->config->properties, parser_data->domstack->head->context)) 748 baked = parser_data->domstack->head->context; 749 else 750 baked = parser_data->tag; 751 752 push_tag_stack(parser_data->metastack, (xmlChar *)tag, baked, SWISH_SPACE); 735 753 } 736 754 … … 1083 1101 ptr->domstack->temp = NULL; 1084 1102 ptr->domstack->count = 0; 1085 push_tag_stack(ptr->domstack, (xmlChar *)".", (xmlChar *)".", SWISH_DOT);1086 1087 /*1088 * no such property just to seed stack1089 */1090 1103 1091 1104 /* … … 2155 2168 tmp = swish_xmalloc(size); 2156 2169 2157 if (snprintf((char *)tmp, size, "%s%c%s", (char *)flat, flatten_join, (char *)stack->temp->baked) 2158 > 0) { 2170 if (snprintf((char *)tmp, size, "%s%c%s", 2171 (char *)stack->temp->baked, flatten_join, (char *)flat) 2172 > 0 2173 ) { 2159 2174 if (flat != NULL) 2160 2175 swish_xfree(flat); … … 2178 2193 { 2179 2194 swish_TagStack *stack; 2180 intcleanwsp;2195 boolean cleanwsp; 2181 2196 swish_Property *prop; 2182 2197 libswish3/trunk/src/t/001-wordcount.t
r2158 r2188 3 3 use strict; 4 4 use warnings; 5 use Test::More tests => 2 5;5 use Test::More tests => 26; 6 6 use SwishTestUtils; 7 7 … … 30 30 'inline.xml' => 12, 31 31 'inline.html' => 9, 32 'dom.xml' => 3, 32 33 33 34 ); libswish3/trunk/src/t/003-properties.t
r2142 r2188 2 2 use strict; 3 3 use warnings; 4 use Test::More tests => 2;4 use Test::More tests => 3; 5 5 use SwishTestUtils; 6 6 … … 18 18 ); 19 19 20 $buf = SwishTestUtils::run_lint_stderr( 'dom.xml', 'dom.conf' ); 21 22 # the dot . is the TOKENPOS_BUMPER delimiter 23 like( $buf, qr!<doc\.one\.two>green.yellow</doc\.one\.two>!, "dom" ); 24 20 25 #diag($buf);
