RPM Community Forums

Mailing List Message of <rpm-cvs>

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

From: Ralf S. Engelschall <rse@rpm5.org>
Date: Wed 02 Jan 2008 - 16:54:32 CET
Message-Id: <20080102155432.3628234845E@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: rpm lua                          Date:   02-Jan-2008 16:54:32
  Branch: HEAD                             Handle: 2008010215543101

  Modified files:
    lua/local               llocal.lua
    rpm                     CHANGES

  Log:
    Add RPM Lua function util.rsplit() for flexibly splitting strings into
    tokens based on regex.

  Summary:
    Revision    Changes     Path
    1.9         +23 -0      lua/local/llocal.lua
    1.2047      +1  -0      rpm/CHANGES
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: lua/local/llocal.lua
  ============================================================================
  $ cvs diff -u -r1.8 -r1.9 llocal.lua
  --- lua/local/llocal.lua	31 Dec 2007 20:28:29 -0000	1.8
  +++ lua/local/llocal.lua	2 Jan 2008 15:54:32 -0000	1.9
  @@ -94,6 +94,29 @@
       return result
   end
   
  +--  regular expression based string splitting
  +function util.rsplit(str, regex, count)
  +    local result = {}
  +    local re = rex.new(regex)
  +    while str ~= "" do
  +        if count ~= nil then
  +            if count <= 0 then
  +                break
  +            end
  +            count = count - 1
  +        end
  +        local s, e, m = re:match(str)
  +        if s ~= nil then
  +            table.insert(result, string.sub(str, 1, s -1))
  +            str = string.sub(str, e + 1)
  +        else
  +            break
  +        end
  +    end
  +    table.insert(result, str)
  +    return result
  +end
  +
   --  -----------------------------------------------------------------------  --
   --                           RECURSIVE DATA DUMPING
   --  -----------------------------------------------------------------------  --
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.2046 -r1.2047 CHANGES
  --- rpm/CHANGES	1 Jan 2008 20:27:52 -0000	1.2046
  +++ rpm/CHANGES	2 Jan 2008 15:54:31 -0000	1.2047
  @@ -1,4 +1,5 @@
   5.0b4 -> 5.0.0:
  +    - rse: add RPM Lua function util.rsplit() for flexibly splitting strings into tokens based on regex
       - rse: add rpmlogGetCallback() function to allow one to restore the complete rpmlog() callback information
       - rse: add rpmluaGetGlobalState() function to allow foreign code to further extend the RPM Lua environment
       - rse: add RPM Lua function rpm.verbose() to be able to check CLI option --verbose
  @@ .
Received on Wed Jan 2 16:54:32 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.