A small lua lib, that performs char (1 byte char from 0 to 255) to value replacements, like string.gsub, but more faster and has some additional features (like functions and a metatable __tostring attr)
-- with lak
local lak = require "odielak";
local escape = lak.new({
['&'] = '&',
['<'] = '<',
['>'] = '>'
});
local escaped_str = escape("escape >th&is<");
-- escaped_str = "escape >th&is<"
-- same with gsub
local t = {
['&'] = '&',
['<'] = '<',
['>'] = '>'
}
local r = "[&<>]";
local escaped_str = string.gsub("escape >th&is<", r, t);
-- escaped_str = "escape >th&is<"
checkout example.lua for examples and more info
git clone https://github.com/Darvame/odielak.git
cd odielak
#by default sudo does not pass exported variables
#you may need to run everything bellow (from this point) with root
#in order to use '$ make install'
su -
#or call make with specified variables
make CC=clang
- with pgk-config
export LUAPKG=lua5.2 #or any ('luajit', 'lua5.1', 'lua5.3')
- without pgk-config
# this values are defaults (from luajit), do not set if have the same
export PREFIX=/usr/local #prefix
export LUA_LIBDIR=$PREFIX/lib/lua/5.1 #path to lua libs, used only for '$ make install'
export LUA_INCDIR=-I$PREFIX/include/luajit-2.0 #path to lua headers
export LUA=$PREFIX/bin/luajit #lua executable, used only for '$ make test'
- with clang
export CC=clang #if build on osx
make install