r87227 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87226‎ | r87227 | r87228 >
Date:22:20, 1 May 2011
Author:platonides
Status:deferred
Tags:
Comment:
Fix a bug in strpos() and another searching backwards where it used i was used as index instead of searchStart
Added cosmetical space before closing bracket.
Modified paths:
  • /trunk/extensions/NativePreprocessor/preprocesstoobj.c (modified) (history)

Diff [purge]

Index: trunk/extensions/NativePreprocessor/preprocesstoobj.c
@@ -15,7 +15,7 @@
1616 static int strpos(const char* haystack, int haystack_len, const char* needle, int needle_len, int offset) {
1717 int i;
1818
19 - for ( i = offset; i < haystack_len - needle_len; i++ ) {
 19+ for ( i = offset; i <= haystack_len - needle_len; i++ ) {
2020 if ( !memcmp( haystack + i, needle, needle_len ) ) {
2121 return i;
2222 }
@@ -316,7 +316,7 @@
317317
318318 int wsStart;
319319 for (wsStart = i - 1; wsStart > 0; wsStart--) {
320 - if ( text[wsStart] != ' ') { /* It can't go over wikitext_len because the php string has a \0 terminator, too */
 320+ if ( text[wsStart] != ' ' ) { /* It can't go over wikitext_len because the php string has a \0 terminator, too */
321321 wsStart++;
322322 break;
323323 }
@@ -515,7 +515,7 @@
516516 // Comment found at line end
517517 // Search for equals signs before the comment
518518 for (searchStart = parentNode->visualEnd; searchStart > 0; --searchStart) {
519 - if (text[i] != ' ' && text[i] != '\t')
 519+ if (text[searchStart] != ' ' && text[searchStart] != '\t')
520520 break;
521521 }
522522 }

Status & tagging log