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: 12-Jan-2008 14:25:52
Branch: HEAD Handle: 2008011213255200
Modified files:
lua/local llocal.lua
rpm CHANGES
Log:
Implement RPM Lua function util.textwrap() for auto-wrapping junks of
larger text messages.
Summary:
Revision Changes Path
1.14 +29 -0 lua/local/llocal.lua
1.2063 +1 -0 rpm/CHANGES
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: lua/local/llocal.lua
============================================================================
$ cvs diff -u -r1.13 -r1.14 llocal.lua
--- lua/local/llocal.lua 12 Jan 2008 13:13:33 -0000 1.13
+++ lua/local/llocal.lua 12 Jan 2008 13:25:52 -0000 1.14
@@ -165,6 +165,35 @@
end
-- ----------------------------------------------------------------------- --
+-- TEXT FORMATTING
+-- ----------------------------------------------------------------------- --
+
+function util.textwrap(prefix, text, col_min, col_max)
+ if col_min == nil then col_min = 78 end
+ if col_max == nil then col_max = col_min end
+ text = text .. " "
+ text = util.rsubst(text, "(?s)\\r?\\n[ \\t]*", " ")
+ text = util.rsubst(text,
+ "(?s)(" ..
+ ".{" .. col_min .. "," .. col_max .. "}?([ \\t])" ..
+ "|" ..
+ ".{" .. col_max .. "}" ..
+ ")",
+ function (s, ws)
+ if ws then
+ return s .. "\n"
+ else
+ return s .. "-\n"
+ end
+ end
+ )
+ text = util.rsubst(text, "(?s)([ \\t]*)$", "")
+ text = util.rsubst(text, "(?s)([^\\n])$", "%1\n")
+ text = util.rsubst(text, "(?m)^", prefix)
+ return text
+end
+
+-- ----------------------------------------------------------------------- --
-- I/O UTILITIES
-- ----------------------------------------------------------------------- --
@@ .
patch -p0 <<'@@ .'
Index: rpm/CHANGES
============================================================================
$ cvs diff -u -r1.2062 -r1.2063 CHANGES
--- rpm/CHANGES 12 Jan 2008 13:13:33 -0000 1.2062
+++ rpm/CHANGES 12 Jan 2008 13:25:52 -0000 1.2063
@@ -1,4 +1,5 @@
5.0.0 -> 5.1a1:
+ - rse: implement RPM Lua function util.textwrap() for auto-wrapping junks of larger text messages
- rse: upgrade RPM Lua functions util.rmatch(), util.rsubst() and util.rsplit() to new lrexlib 2.2
- rse: upgrade the RPM Lua extension lrexlib from ancient version 1.1x to latest version 2.2
- jbj: permit opt-in network access using %_rpmgio macro.
@@ .
Received on Sat Jan 12 14:25:52 2008