From 9dd2a8fc59988cb3b9a55a7d56d15d4429f2c7c7 Mon Sep 17 00:00:00 2001 From: Shy Date: Thu, 29 Aug 2024 10:01:42 +0200 Subject: [PATCH] Use ":"-notation for strings manipulation --- c4mate | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/c4mate b/c4mate index d05fdcf..e827fb4 100755 --- a/c4mate +++ b/c4mate @@ -12,16 +12,16 @@ HOST = "http://mate.labor.koeln.ccc.de" local function utf8_decode(str) -- Replace JSON Unicode escape sequences with chars. if str == nil then return "" end - str = string.gsub(str, "\\\"", "\"") + str = str:gsub("\\\"", "\"") if utf8 == nil then return str end -- Only available in Lua >= 5.3. - return string.gsub(str, "\\u(%x%x%x%x)", + return str:gsub("\\u(%x%x%x%x)", function (s) return utf8.char(tonumber(s, 16)) end) end local function url_encode(str) -- URL-encode string. Used only for usernames. -- Todo: make this more sophisticated. - return string.gsub(str, " ", "%%20") + return str:gsub(" ", "%%20") end MatePad = { @@ -421,12 +421,12 @@ else -- Find and buy item. local roster, query, input, ok roster = pad:get_roster() - query = string.lower(table.concat(arg, " ")) + query = table.concat(arg, " "):lower() local menu = {} for i = 1, #roster do local item = roster[i] - if string.match(string.lower(item.name), query) then + if item.name:lower():match(query) then table.insert(menu, item) end end