Skip to content

Commit

Permalink
Fix :x($n) in subst where $n is greater than the number of matches we…
Browse files Browse the repository at this point in the history
… can do. Resolves RT#61204.
  • Loading branch information
jnthn committed Feb 13, 2009
1 parent 9a5c690 commit 01811bf
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/builtins/any-str.pir
Expand Up @@ -1071,13 +1071,17 @@ Partial implementation. The :g modifier on regexps doesn't work, for example.
startpos = pos + replacelen
goto subst_loop
subst_done:
if null x_opt goto x_check_done
if n_cnt >= times goto x_check_done
.return (self)
x_check_done:
.return (result)
nth_fail:
die "Must pass a non-negative integer to :nth()"
'die'("Must pass a non-negative integer to :nth()")
x_fail:
die "Must pass a non-negative integer to :x()"
'die'("Must pass a non-negative integer to :x()")
.end
Expand Down Expand Up @@ -1181,6 +1185,10 @@ Partial implementation. The :g modifier on regexps doesn't work, for example.
offset += $I3
goto subst_loop
subst_done:
if null x_opt goto x_check_done
if n_cnt >= times goto x_check_done
.return (self)
x_check_done:
.return (result)

nth_fail:
Expand Down

0 comments on commit 01811bf

Please sign in to comment.