Code Duplication    Length = 59-59 lines in 2 locations

includes/parser/Preprocessor_DOM.php 1 location

@@ 268-326 (lines=59) @@
265
			if ( $fakeLineStart ) {
266
				$found = 'line-start';
267
				$curChar = '';
268
			} else {
269
				# Find next opening brace, closing brace or pipe
270
				$search = $searchBase;
271
				if ( $stack->top === false ) {
272
					$currentClosing = '';
273
				} else {
274
					$currentClosing = $stack->top->close;
275
					$search .= $currentClosing;
276
				}
277
				if ( $findPipe ) {
278
					$search .= '|';
279
				}
280
				if ( $findEquals ) {
281
					// First equals will be for the template
282
					$search .= '=';
283
				}
284
				$rule = null;
285
				# Output literal section, advance input counter
286
				$literalLength = strcspn( $text, $search, $i );
287
				if ( $literalLength > 0 ) {
288
					$accum .= htmlspecialchars( substr( $text, $i, $literalLength ) );
289
					$i += $literalLength;
290
				}
291
				if ( $i >= $lengthText ) {
292
					if ( $currentClosing == "\n" ) {
293
						// Do a past-the-end run to finish off the heading
294
						$curChar = '';
295
						$found = 'line-end';
296
					} else {
297
						# All done
298
						break;
299
					}
300
				} else {
301
					$curChar = $text[$i];
302
					if ( $curChar == '|' ) {
303
						$found = 'pipe';
304
					} elseif ( $curChar == '=' ) {
305
						$found = 'equals';
306
					} elseif ( $curChar == '<' ) {
307
						$found = 'angle';
308
					} elseif ( $curChar == "\n" ) {
309
						if ( $inHeading ) {
310
							$found = 'line-end';
311
						} else {
312
							$found = 'line-start';
313
						}
314
					} elseif ( $curChar == $currentClosing ) {
315
						$found = 'close';
316
					} elseif ( isset( $this->rules[$curChar] ) ) {
317
						$found = 'open';
318
						$rule = $this->rules[$curChar];
319
					} else {
320
						# Some versions of PHP have a strcspn which stops on null characters
321
						# Ignore and continue
322
						++$i;
323
						continue;
324
					}
325
				}
326
			}
327
328
			if ( $found == 'angle' ) {
329
				$matches = false;

includes/parser/Preprocessor_Hash.php 1 location

@@ 199-257 (lines=59) @@
196
			if ( $fakeLineStart ) {
197
				$found = 'line-start';
198
				$curChar = '';
199
			} else {
200
				# Find next opening brace, closing brace or pipe
201
				$search = $searchBase;
202
				if ( $stack->top === false ) {
203
					$currentClosing = '';
204
				} else {
205
					$currentClosing = $stack->top->close;
206
					$search .= $currentClosing;
207
				}
208
				if ( $findPipe ) {
209
					$search .= '|';
210
				}
211
				if ( $findEquals ) {
212
					// First equals will be for the template
213
					$search .= '=';
214
				}
215
				$rule = null;
216
				# Output literal section, advance input counter
217
				$literalLength = strcspn( $text, $search, $i );
218
				if ( $literalLength > 0 ) {
219
					self::addLiteral( $accum, substr( $text, $i, $literalLength ) );
220
					$i += $literalLength;
221
				}
222
				if ( $i >= $lengthText ) {
223
					if ( $currentClosing == "\n" ) {
224
						// Do a past-the-end run to finish off the heading
225
						$curChar = '';
226
						$found = 'line-end';
227
					} else {
228
						# All done
229
						break;
230
					}
231
				} else {
232
					$curChar = $text[$i];
233
					if ( $curChar == '|' ) {
234
						$found = 'pipe';
235
					} elseif ( $curChar == '=' ) {
236
						$found = 'equals';
237
					} elseif ( $curChar == '<' ) {
238
						$found = 'angle';
239
					} elseif ( $curChar == "\n" ) {
240
						if ( $inHeading ) {
241
							$found = 'line-end';
242
						} else {
243
							$found = 'line-start';
244
						}
245
					} elseif ( $curChar == $currentClosing ) {
246
						$found = 'close';
247
					} elseif ( isset( $this->rules[$curChar] ) ) {
248
						$found = 'open';
249
						$rule = $this->rules[$curChar];
250
					} else {
251
						# Some versions of PHP have a strcspn which stops on null characters
252
						# Ignore and continue
253
						++$i;
254
						continue;
255
					}
256
				}
257
			}
258
259
			if ( $found == 'angle' ) {
260
				$matches = false;