﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
1810	Crash, StringRegExpReplace, recursion.	mvg		"Crash, StringRegExpReplace, recursion.

crashes when a recursion patter is given more than N characters to store(?).

- note: Not sure, but the number N might differ in differant situations. (final script, OS, ...)
- not really tested with StringRegExp, other than a quick 

''v3.3.6.1 on Win.Xp.Pro.32.Sp3''

{{{
;; Crash, StringRegExpReplace, recursion.
;; crashes when a recursion patter is given more than N characters to store(?).
;; - note: Not sure, but the number N might differ in differant situations. (final script, OS, ...)
;; - not really tested with StringRegExp, other than a quick StringRegExp test with same pattern and data. witch did not fail ...

bug()
Func bug()
	Local $iFill = 0, $aText1, $aText2, $sPattern, $result

	$sPattern = '(?x)  X  (?:  (?>  [^XZ]  )  |  (?R)  )*  Z' ;; pat A
	$iFill = 5931 ;; pat A

;~ 	$sPattern = '(?x)  X  (?:  (?>  [^XZ]  )  |  (?R)  )+ Z' ;; pat B
;~ 	$iFill = 5932 ;; pat B

	$aText1 = 'aXX' & StringRepeat($iFill, 'o') & 'ZZb'
	$aText2 = 'aXX' & StringRepeat($iFill + 1, 'o') & 'ZZb'

	$result = StringRegExpReplace($aText1, $sPattern, '[$0]')
	ConsoleWrite('1) ' & CompressFiller($result) & ', err: ' & @error & ', ext: ' & @extended & @CRLF)
	$result = StringRegExpReplace($aText2, $sPattern, '[$0]')
	ConsoleWrite('2) ' & CompressFiller($result) & ', err: ' & @error & ', ext: ' & @extended & @CRLF)
EndFunc

;; support functions.
Func StringRepeat($iRep, $sRep = ' ')
	Local $sOut = ''
	For $i = 1 To $iRep
		$sOut &= $sRep
	Next
	Return $sOut
EndFunc
Func CompressFiller(ByRef $sText, $sChar = 'o', $err = @error, $ext = @extended)
	If Not IsString($sChar) Or _
			StringLen($sChar) > 1 Or _
			StringUpper($sChar) == StringLower($sChar) _
			Then Exit 961 ;; Return SetError(1, 0, 0)
	$sChar = StringLower($sChar)
	Local $ipos2, $iPos1 = StringInStr($sText, 'o', 1) ;; find first.
	While $iPos1 ;; any left.
		$ipos2 = $iPos1 + 1
		While StringMid($sText, $ipos2, 1) == $sChar ;; count repeats.
			$ipos2 += 1
		WEnd
		$sText = StringMid($sText, 1, $iPos1 - 1) & '(' & StringUpper($sChar) & ':' & String($ipos2 - $iPos1) & ')' & StringMid($sText, $ipos2, -1) ;; adjust string.
		$iPos1 = StringInStr($sText, 'o', 1) ;; find next, if any.
	WEnd
	$sText = StringReplace($sText, '(' & StringUpper($sChar) & ':', '(' & $sChar & ':') ;; finalize.
	Return SetError($err, $ext, $sText)
EndFunc
}}}"	Bug	closed		AutoIt	3.3.6.1	None	Wont Fix	crash StringRegExpReplace recurstion	
