summaryrefslogtreecommitdiff
path: root/lib/supportlib.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lib/supportlib.lua')
-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