RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: lua/local/ llocal.lua

From: Ralf S. Engelschall <rse@rpm5.org>
Date: Sun 30 Dec 2007 - 22:09:39 CET
Message-Id: <20071230210939.59EBA34845C@rpm5.org>
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Ralf S. Engelschall
  Root:   /v/rpm/cvs                       Email:  rse@rpm5.org
  Module: lua                              Date:   30-Dec-2007 22:09:39
  Branch: HEAD                             Handle: 2007123021093900

  Modified files:
    lua/local               llocal.lua

  Log:
    bugfix the util.subst() function again: correct $n expansion and
    endless looping detection

  Summary:
    Revision    Changes     Path
    1.6         +7  -2      lua/local/llocal.lua
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: lua/local/llocal.lua
  ============================================================================
  $ cvs diff -u -r1.5 -r1.6 llocal.lua
  --- lua/local/llocal.lua	30 Dec 2007 11:27:01 -0000	1.5
  +++ lua/local/llocal.lua	30 Dec 2007 21:09:39 -0000	1.6
  @@ -69,7 +69,9 @@
   function util.rsubst(str, regex, subst)
       local result = str
       local re = rex.new(regex)
  -    while true do
  +    local result_last = ""
  +    while result ~= result_last do
  +        result_last = result
           local s, e, m = re:match(result)
           if s ~= nil then
               local prolog = string.sub(result, 1, s - 1)
  @@ -79,7 +81,10 @@
               elseif type(subst) == "table" then
                   result = subst[m[1]]
               else
  -                result = string.gsub(subst, "%$(%n)", function (n) return m[n] end)
  +                result = string.gsub(subst, "%$([0-9])", function (n) return m[tonumber(n)] end)
  +            end
  +            if result == nil then
  +                result = ""
               end
               result = prolog .. result .. epilog
           else
  @@ .
Received on Sun Dec 30 22:09:39 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.