Revert "[backport] fix #15064, strscans.scanf edge case for '$+' (#15223)"

This reverts commit f713c54166.
This commit is contained in:
narimiran
2020-09-12 08:42:43 +02:00
parent dc5e8fc39d
commit 8ec5dc1969
2 changed files with 2 additions and 16 deletions

View File

@@ -396,7 +396,7 @@ macro scanf*(input: string; pattern: static[string]; results: varargs[typed]): b
var resLen = genSym(nskLet, "resLen")
conds.add newLetStmt(resLen, newCall(bindSym"parseUntil", inp,
results[i], newLit(token), idx))
conds.add newCall(bindSym">=", resLen, newLit min)
conds.add newCall(bindSym"!=", resLen, newLit min)
conds.add resLen
else:
matchError

View File

@@ -79,22 +79,8 @@ block EmptyTuple:
block Arrow:
let text = "foo;bar;baz;"
var idx = 0
var res = ""
doAssert scanp(text, idx, +(~{';','\0'} -> (discard $_)), ';')
doAssert scanp(text, idx, +(~{';','\0'} -> (discard $_)), ';')
doAssert scanp(text, idx, +(~{';','\0'} -> (discard $_)), ';')
doAssert scanp(text, idx, +(~{';','\0'} -> (discard $_)), ';') == false
block issue15064:
var nick1, msg1: string
doAssert scanf("<abcd> a", "<$+> $+", nick1, msg1)
doAssert nick1 == "abcd"
doAssert msg1 == "a"
var nick2, msg2: string
doAssert(not scanf("<abcd> ", "<$+> $+", nick2, msg2))
var nick3, msg3: string
doAssert scanf("<abcd> ", "<$+> $*", nick3, msg3)
doAssert nick3 == "abcd"
doAssert msg3 == ""