diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2018-11-02 14:38:24 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2018-11-02 14:39:23 -0700 |
| commit | 307dea18815ba4a06a3098edb170d7ad90708815 (patch) | |
| tree | bce78eb28fa03c9939a92e08e47564afc984c988 /string2.lua | |
| parent | d0c3c57f7b25c8d912c426e48cb5ab09cd738f65 (diff) | |
Changed stub convention to (foo 1 baz 2) -> foo_1_baz instead of
foo_1_baz_2, removed "smext", made some cleanup changes.
Diffstat (limited to 'string2.lua')
| -rw-r--r-- | string2.lua | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/string2.lua b/string2.lua index 8e13171..cf86026 100644 --- a/string2.lua +++ b/string2.lua @@ -78,6 +78,9 @@ local string2 = { end return _accum_0 end, + starts_with = function(self, s) + return sub(self, 1, #s) == s + end, lines = function(self) local _accum_0 = { } local _len_0 = 1 @@ -114,10 +117,10 @@ local string2 = { for _index_0 = 1, #_list_0 do local line = _list_0[_index_0] while #line > maxlen do - local chunk = line:sub(1, maxlen) - local split = chunk:find(' ', maxlen - buffer, true) or maxlen - chunk = line:sub(1, split) - line = line:sub(split + 1, -1) + local chunk = sub(line, 1, maxlen) + local split = find(chunk, ' ', maxlen - buffer, true) or maxlen + chunk = sub(line, 1, split) + line = sub(line, split + 1, -1) lines[#lines + 1] = chunk end lines[#lines + 1] = line @@ -151,14 +154,14 @@ local string2 = { return format("x%02X", byte(c)) end end) - if not (is_lua_id(str:match("^_*(.*)$"))) then + if not (is_lua_id(match(str, "^_*(.*)$"))) then str = "_" .. str end return str end, from_lua_id = function(str) - if not (is_lua_id(str:match("^_*(.*)$"))) then - str = str:sub(2, -1) + if not (is_lua_id(match(str, "^_*(.*)$"))) then + str = sub(str, 2, -1) end str = gsub(str, "_", " ") str = gsub(str, "x([0-9A-F][0-9A-F])", function(hex) |
