r80712 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80711‎ | r80712 | r80713 >
Date:22:00, 21 January 2011
Author:platonides
Status:deferred
Tags:
Comment:
The << operator (level 7) has greater priority than bitwise or (level 12),
which makes getNextSibling() function wrong for values >= 256.
Modified paths:
  • /trunk/extensions/NativePreprocessor/nodes.h (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/parser/PreprocessorTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/parser/PreprocessorTest.php
@@ -80,6 +80,8 @@
8181 array( "{{#if: {{{1|}}} | Foo | [[Bar]] }}", "<root><template><title>#if: <tplarg><title>1</title><part><name index=\"1\" /><value></value></part></tplarg> </title><part><name index=\"1\" /><value> Foo </value></part><part><name index=\"2\" /><value> [[Bar]] </value></part></template></root>"),
8282 array( "{{#if: {{{1|}}} | [[Foo]] | Bar }}", "<root><template><title>#if: <tplarg><title>1</title><part><name index=\"1\" /><value></value></part></tplarg> </title><part><name index=\"1\" /><value> [[Foo]] </value></part><part><name index=\"2\" /><value> Bar </value></part></template></root>"),
8383 array( "{{#if: {{{1|}}} | 1 | {{#if: {{{1|}}} | 2 | 3 }} }}", "<root><template><title>#if: <tplarg><title>1</title><part><name index=\"1\" /><value></value></part></tplarg> </title><part><name index=\"1\" /><value> 1 </value></part><part><name index=\"2\" /><value> <template><title>#if: <tplarg><title>1</title><part><name index=\"1\" /><value></value></part></tplarg> </title><part><name index=\"1\" /><value> 2 </value></part><part><name index=\"2\" /><value> 3 </value></part></template> </value></part></template></root>"),
 84+ array( "{{ {{Foo}}", "<root>{{ <template><title>Foo</title></template></root>"),
 85+ array( "{{Foobar {{Foo}} {{Bar}} {{Baz}} ", "<root>{{Foobar <template><title>Foo</title></template> <template><title>Bar</title></template> <template><title>Baz</title></template> </root>"),
8486 /* array( file_get_contents( dirname( __FILE__ ) . '/QuoteQuran.txt' ), file_get_contents( dirname( __FILE__ ) . '/QuoteQuranExpanded.txt' ) ), */
8587 );
8688 }
Index: trunk/extensions/NativePreprocessor/nodes.h
@@ -214,10 +214,12 @@
215215
216216 /**
217217 * Get the nextSibling value from a node serialized at pointer.
 218+ * The nextSibling is a hexadecimal value in bytes 2-7, forming a
 219+ * value from 0 to 0x01000000.
218220 */
219221 static inline int getNextSibling(const char* pointer) {
220222 assert( pointer[2] != '?' );
221 - return ( ( ( ( ( hex2dec(pointer[2]) << 4 ) | hex2dec(pointer[3]) << 4 ) | hex2dec(pointer[4]) << 4 ) | hex2dec(pointer[5]) << 4 ) | hex2dec(pointer[6]) << 4 ) | hex2dec(pointer[7]);
 223+ return ( ( ( ( ( hex2dec(pointer[2]) << 4 ) | hex2dec(pointer[3]) ) << 4 | hex2dec(pointer[4]) ) << 4 | hex2dec(pointer[5]) ) << 4 | hex2dec(pointer[6]) ) << 4 | hex2dec(pointer[7]);
222224 }
223225
224226 /**

Status & tagging log