summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorpixel <pixel>2007-07-23 14:00:05 +0000
committerpixel <pixel>2007-07-23 14:00:05 +0000
commitfc0f17c6e371dd13df72cea2e8ad67b062c630d9 (patch)
treed334d5dcefb6493102776f243b26b6603bd88207 /lib
parentdfb3bbb04d94823319ed33948543d57305b48efb (diff)
Adding support for the trim functions.
Diffstat (limited to 'lib')
-rw-r--r--lib/supportlib.lua27
1 files changed, 26 insertions, 1 deletions
diff --git a/lib/supportlib.lua b/lib/supportlib.lua
index 68c223c..6bb3149 100644
--- a/lib/supportlib.lua
+++ b/lib/supportlib.lua
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: supportlib.lua,v 1.7 2007-06-11 21:25:06 pixel Exp $ */
+/* $Id: supportlib.lua,v 1.8 2007-07-23 14:00:05 pixel Exp $ */
]]--
@@ -183,6 +183,31 @@ function generic_escape(str, replacements)
return str
end
+
+--
+-- Various, classique trim functions.
+--
+
function sql_escape(name)
return generic_escape(name, sql_replacements)
end
+
+function ltrim(str)
+ if string.sub(str, 1, 1) == " " then
+ return ltrim(string.sub(str, 2))
+ else
+ return str
+ end
+end
+
+function rtrim(str)
+ if string.sub(str, -1) == " " then
+ return rtrim(string.sub(str, 1, string.len(str) - 1))
+ else
+ return str
+ end
+end
+
+function trim(str)
+ return ltrim(rtrim(str))
+end