r87346 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87345‎ | r87346 | r87347 >
Date:19:48, 3 May 2011
Author:platonides
Status:ok
Tags:
Comment:
We can't check if it's a parentNode->type == name_node so early, since
it may be just a single } and end up being a literal.
Modified paths:
  • /trunk/extensions/NativePreprocessor/preprocesstoobj.c (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/parser/PreprocessorTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/parser/PreprocessorTest.php
@@ -56,6 +56,7 @@
5757 array( "{{Foo|=bar}}", "<root><template lineStart=\"1\"><title>Foo</title><part><name></name>=<value>bar</value></part></template></root>" ),
5858 array( "{{Foo|bar=baz}}", "<root><template lineStart=\"1\"><title>Foo</title><part><name>bar</name>=<value>baz</value></part></template></root>" ),
5959 array( "{{Foo|1=bar|baz}}", "<root><template lineStart=\"1\"><title>Foo</title><part><name>1</name>=<value>bar</value></part><part><name index=\"1\" /><value>baz</value></part></template></root>" ),
 60+ array( "{{Foo|1=bar|2=baz}}", "<root><template lineStart=\"1\"><title>Foo</title><part><name>1</name>=<value>bar</value></part><part><name>2</name>=<value>baz</value></part></template></root>" ),
6061 array( "{{Foo|bar|foo=baz}}", "<root><template lineStart=\"1\"><title>Foo</title><part><name index=\"1\" /><value>bar</value></part><part><name>foo</name>=<value>baz</value></part></template></root>" ),
6162 array( "{{{1}}}", "<root><tplarg lineStart=\"1\"><title>1</title></tplarg></root>" ),
6263 array( "{{{1|}}}", "<root><tplarg lineStart=\"1\"><title>1</title><part><name index=\"1\" /><value></value></part></tplarg></root>" ),
@@ -96,6 +97,8 @@
9798 array( "{{foo|}", "<root>{{foo|}</root>"),
9899 array( "{{foo|} }}", "<root><template lineStart=\"1\"><title>foo</title><part><name index=\"1\" /><value>} </value></part></template></root>"),
99100 array( "{{foo|bar=|}", "<root>{{foo|bar=|}</root>"),
 101+ array( "{{Foo|} Bar=", "<root>{{Foo|} Bar=</root>"),
 102+ array( "{{Foo|} Bar=}}", "<root><template lineStart=\"1\"><title>Foo</title><part><name>} Bar</name>=<value></value></part></template></root>"),
100103 /* array( file_get_contents( dirname( __FILE__ ) . '/QuoteQuran.txt' ), file_get_contents( dirname( __FILE__ ) . '/QuoteQuranExpanded.txt' ) ), */
101104 );
102105 }
Index: trunk/extensions/NativePreprocessor/preprocesstoobj.c
@@ -589,22 +589,18 @@
590590 } else if ( found == closeBrace || found == closeBracket ) {
591591 // lets check if there are enough characters for closing brace
592592
593 - if ( parentNode->type == name_node ) {
594 - /* Go to close it */
595 - fakePipeFound = true;
596 - continue;
597 - }
598593 assert( ( parentNode->type == found - 2 ) ||
599594 ( parentNode->parent &&
600 - ( ( parentNode->parent->type == found - 2 ) || ( parentNode->type == value_node &&
 595+ ( ( parentNode->parent->type == found - 2 ) ||
 596+ ( ( parentNode->type == value_node || parentNode->type == name_node ) &&
601597 parentNode->parent->parent && ( parentNode->parent->parent->type == found - 2 ) ) ) ) );
602598
603599 int maxCount;
604600 if ( found == closeBracket ) {
605601 maxCount = parentNode->count;
606602 } else {
607 - if ( parentNode->type == value_node ) {
608 - /* template\part\value */
 603+ if ( parentNode->type == value_node || parentNode->type == name_node ) {
 604+ /* template\part\value or template\part\name */
609605 maxCount = parentNode->parent->parent->count;
610606 assert( parentNode->parent->parent->type == brace_node );
611607 } else {
@@ -637,7 +633,7 @@
638634 matchingCount = count;
639635 }
640636 }
641 -
 637+
642638 if ( matchingCount <= 0 ) {
643639 // No matching element found in callback array
644640 // Output a literal closing brace and continue
@@ -646,6 +642,13 @@
647643 i += count;
648644 continue;
649645 }
 646+
 647+ if ( parentNode->type == name_node ) {
 648+ /* Go to close it */
 649+ fakePipeFound = true;
 650+ continue;
 651+ }
 652+
650653 if ( parentNode->type == value_node ) {
651654 printf("%c in parent %c. Closing\n", found, parentNode->type);
652655 closeNode( parentNode->type );

Follow-up revisions

RevisionCommit summaryAuthorDate
r96887Reverted r86072, r86419 per CR. Lots of conflicts resolved here. Removes line...aaron19:16, 12 September 2011

Status & tagging log