tree-sitter/functions.lua
Björn Bidar c23cd3b70c - update to 0.23.0:
* test: modernize scanner files
  * fix: always reset to the first language when iterating over language
  * feat(zig): update outdated path syntax
  * feat(bindings): add query constants to python
  * style(bindings): fix indent & line endings
  * feat(dsl)!: support other JS runtimes
  * feat(bindings): add node, python, swift tests 
  * introduce tree-sitter-language crate for grammar crates to depend on
  * refactor: remove ansi_term dependency
  * refactor: remove difference dependency
  * feat: add fuzz subcommand
  * fix(wasm): update test
  * feat(lib): add ts_query_end_byte_for_pattern
  * fix(rust): fix new clippy warnings
  * feat(lib): support no_std
  * Reset language when resetting wasm store
  * docs: clean up binding & parser lists
  * clone wasm store engine
  * fix(cli): dedup preceding_auxiliary_symbols
- use of ldconfig_scriptlets, and removal of the duplicate setting of buildflags

OBS-URL: https://build.opensuse.org/package/show/editors/tree-sitter?expand=0&rev=29
2024-09-16 08:18:59 +00:00

61 lines
1.2 KiB
Lua

--[[
SPDX-License-Identifier: GPL-2.0
SPDX-FileCopyrightText: 2024 Björn Bidar
partly based of functions.lua from python-rpm-macros
--]]
-- declare common functions
function string.startswith(str, prefix)
return str:sub(1, prefix:len()) == prefix
end
function string.endswith(str, suffix)
return str:sub(-suffix:len()) == suffix
end
function string.dirname(str)
if str:match("(.*)/") == "" then
return nil
else
return str:match("(.*)/")
end
end
function string.basename(str)
while true do
local idx = str:find("/")
if not idx then return str end
str = str:sub(idx + 1)
end
end
function string.split(str, sep)
if sep == nil then
sep = '%s'
end
local res = {}
local func = function(w)
table.insert(res, w)
end
string.gsub(str, '[^'..sep..']+', func)
return res
end
function arg_compat()
--[[
Compat macro as workaround for older rpm not having function
arguments available as table arg(uments)
--]]
local arg_count = rpm.expand("%#")
local arg = {}
for arg_num = 1,arg_count do
arg[arg_num] = rpm.expand(("%" .. arg_num))
end
return arg
end