aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-14 20:27:49 +1000
committerDavid Walter Seikel2014-05-14 20:27:49 +1000
commit2cb3b86a8260a01d87bd88f4c20de1c107616d8a (patch)
tree302c352886f163e39443b0d7cc7d93cd15b0a324
parentFake llGetFreeMemory(). (diff)
downloadSledjHamr-2cb3b86a8260a01d87bd88f4c20de1c107616d8a.zip
SledjHamr-2cb3b86a8260a01d87bd88f4c20de1c107616d8a.tar.gz
SledjHamr-2cb3b86a8260a01d87bd88f4c20de1c107616d8a.tar.bz2
SledjHamr-2cb3b86a8260a01d87bd88f4c20de1c107616d8a.tar.xz
REal llStrimTrim(), and sanity check inputs to llSubStringIndex().
-rw-r--r--lib/LSL.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/LSL.lua b/lib/LSL.lua
index 571ecf1..09f6ba8 100644
--- a/lib/LSL.lua
+++ b/lib/LSL.lua
@@ -722,11 +722,24 @@ function --[[string]] LSL.llGetSubString(--[[string]] text, --[[integer]] start,
722end 722end
723 723
724function --[[integer]] LSL.llSubStringIndex(--[[string]] text, --[[string]] sub) 724function --[[integer]] LSL.llSubStringIndex(--[[string]] text, --[[string]] sub)
725 if nil == text then return -1 end
726 if nil == sub then return -1 end
725 local start, End = string.find(text, sub, 1, true) 727 local start, End = string.find(text, sub, 1, true)
726 728
727 if nil == start then return -1 else return start - 1 end 729 if nil == start then return -1 else return start - 1 end
728end 730end
729 731
732function LSL.llStringTrim(--[[string]] text, --[[integer]] Type)
733 -- Trims spaces (ASCII 32), tabs (ASCII 9) '\t', and new lines (ASCII 10) '\n'
734 -- Lua doesn't document what it considers to be "space characters"
735 if (Type == LSL.STRING_TRIM_HEAD) or (Type == LSL.STRING_TRIM) then
736 text = string.gsub(text, '^%s*(.*)', '%1')
737 end
738 if (Type == LSL.STRING_TRIM_TAIL) or (Type == LSL.STRING_TRIM) then
739 text = string.gsub(text, '(.-)%s*$', '%1')
740 end
741 return text
742end
730 743
731-- Crements stuff. 744-- Crements stuff.
732 745