Merge remote-tracking branch 'GateGuru/bugfix/do-not-strip-positionals'

This commit is contained in:
Sebastian Celis 2013-10-01 09:06:56 -05:00
commit bb6f2b656f
2 changed files with 2 additions and 36 deletions

View file

@ -1,2 +1,2 @@
source :rubygems
source "https://rubygems.org"
gemspec

View file

@ -14,42 +14,8 @@ module Twine
end
def iosify_substitutions(str)
# 1) use "@" instead of "s" for substituting strings
# use "@" instead of "s" for substituting strings
str.gsub!(/%([0-9\$]*)s/, '%\1@')
# 2) if substitutions are numbered, see if we can remove the numbering safely
expectedSub = 1
startFound = false
foundSub = 0
str.each_char do |c|
if startFound
if c == "%"
# this is a literal %, keep moving
startFound = false
elsif c.match(/\d/)
foundSub *= 10
foundSub += Integer(c)
elsif c == "$"
if expectedSub == foundSub
# okay to keep going
startFound = false
expectedSub += 1
else
# the numbering appears to be important (or non-existent), leave it alone
return str
end
end
elsif c == "%"
startFound = true
foundSub = 0
end
end
# if we got this far, then the numbering (if any) is in order left-to-right and safe to remove
if expectedSub > 1
str.gsub!(/%\d+\$(.)/, '%\1')
end
return str
end