summaryrefslogtreecommitdiffhomepage
path: root/libs/core
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2008-11-16 22:45:10 +0000
committerJo-Philipp Wich <jow@openwrt.org>2008-11-16 22:45:10 +0000
commitcbed72fb47c8c0eda6322574c678389b795cd23c (patch)
treed6c2798764c258017c14e5ef375f62bba49a7e45 /libs/core
parent8b8d9030357e739eb1ae1a6b52a723c8fee8c4a6 (diff)
* luci/themes: fix log pages
* luci/modules/admin-full: add dmesg page * luci/i18n: add "dmesg" translations * luci/libs/util: add cmatch(), register string functions in string class * luci/libs/sys: add dmesg()
Diffstat (limited to 'libs/core')
-rw-r--r--libs/core/luasrc/util.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/libs/core/luasrc/util.lua b/libs/core/luasrc/util.lua
index 109ccab286..ea1fccbc1c 100644
--- a/libs/core/luasrc/util.lua
+++ b/libs/core/luasrc/util.lua
@@ -261,6 +261,16 @@ function trim(str)
return (str:gsub("^%s*(.-)%s*$", "%1"))
end
+--- Count the occurences of given substring in given string.
+-- @param str String to search in
+-- @param pattern String containing pattern to find
+-- @return Number of found occurences
+function cmatch(str, pat)
+ local count = 0
+ for _ in str:gmatch(pat) do count = count + 1 end
+ return count
+end
+
--- Parse certain units from the given string and return the canonical integer
-- value or 0 if the unit is unknown. Upper- or lower case is irrelevant.
-- Recognized units are:
@@ -320,6 +330,16 @@ function parse_units(ustr)
return val
end
+-- also register functions above in the central string class for convenience
+string.escape = escape
+string.pcdata = pcdata
+string.striptags = striptags
+string.split = split
+string.trim = trim
+string.cmatch = cmatch
+string.parse_units = parse_units
+
+
--- Appends numerically indexed tables or single objects to a given table.
-- @param src Target table
-- @param ... Objects to insert