Modify ↓
Opened 12 years ago
Closed 12 years ago
#2841 closed Bug (Fixed)
_StringRepeat adds string once even if parsed count is zero
| Reported by: | RTFC | Owned by: | Melba23 |
|---|---|---|---|
| Milestone: | 3.3.13.17 | Component: | AutoIt |
| Version: | 3.3.12.0 | Severity: | None |
| Keywords: | stringrepeat | Cc: |
Description
Hi devs!
RTFC here. I use _StringRepeat with a variable count in file I/O for struct padding. This count can be zero, but one instance is always added. Id' like a count of zero to mean: "no padding."
Example
#include <String.au3>
MsgBox(0,"test",StringLen(_StringRepeat(" ",0))) ; << should be zero!!!
Annotation in <String.au3> explicitly states zero is valid input, but a final instance of string is added outside of the catenation loop, as marked below in original UDF in String.au3 (penultimate line):
Func _StringRepeat$sString, $iRepeatCount) ; Casting Int() takes care of String/Int, Numbers. $iRepeatCount = Int($iRepeatCount) ; Zero is a valid repeat integer. If StringLen($sString) < 1 Or $iRepeatCount < 0 Then Return SetError(1, 0, "") Local $sResult = "" While $iRepeatCount > 1 If BitAND($iRepeatCount, 1) Then $sResult &= $sString $sString &= $sString $iRepeatCount = BitShift($iRepeatCount, 1) WEnd Return $sString & $sResult ; <<<<<< FAILS HERE <<<< EndFunc ;==>_StringRepeat
Thanks for looking at this,
RTFC
Attachments (0)
Change History (1)
comment:1 by , 12 years ago
| Milestone: | → 3.3.13.17 |
|---|---|
| Owner: | set to |
| Resolution: | → Fixed |
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.

Fixed by revision [10898] in version: 3.3.13.17