• Announcement: Lua.org now officially recommends this forum as a meeting place for the Lua community

Recent content by awsdert

  1. awsdert

    patsubst mimic didn't work correctly, tried fixing but hit infinite loop

    Never mind, fixed it but also found encountered another infinite loop elsewhere, haven't identified the location of it yet though. -- internal replacement function local function rpatsubst( match, subst, arg ) local i, e, tmp -- lua modifies the source by default, try to indicate a...
  2. awsdert

    patsubst mimic didn't work correctly, tried fixing but hit infinite loop

    Since I know the rest of the functions work as intended (including the public patsubst function which calls this internally) I can only view this new version of the replacement loop as the culprit for the infinite loop, any ideas where I'm going wrong? -- internal replacement function local...
  3. awsdert

    Want to do something similar to GNUmake's patsubst function

    Welp I got it working despite the lack of help here, for the benefit of others who wanted the same thing, this is what I got in a dedicated file: local function patsubst_str2vec( pattern ) local i, j, a, c, list = 1, 1, '', '', {} for j = 1, #pattern, 1 do c = pattern:sub(j,j)...
  4. awsdert

    Want to do something similar to GNUmake's patsubst function

    Few more fixes to indexing issues, now I'm way closer to the intended result: function patsubst_str2vec( pattern ) local i, j, a, c, list = 1, 1, '', '', {} for j = 1, #pattern, 1 do c = pattern:sub(j,j) if c == '%' then if pattern:sub(j,j+1) == '%%' then...
  5. awsdert

    Want to do something similar to GNUmake's patsubst function

    simplified the code a bit, managed to lose the effect I had almost achieved though, can't see why either: function patsubst_str2vec( pattern ) local i, j, a, c, list = 1, 1, '', '', {} for j = 1, #pattern, 1 do c = pattern:sub(j,j) if c == '%' then if...
  6. awsdert

    Want to do something similar to GNUmake's patsubst function

    Well I got a step closer to my goal: function __patsubst( subst, arg ) local i for i = 1, #subst, 1 do m = subst:sub(i,i) if m == '%' then if subst:sub(i,i+1) == '%%' then i = i + 1 else return subst:sub(1,i) .. arg...
  7. awsdert

    Want to do something similar to GNUmake's patsubst function

    Didn't realise the developers of lua decided to be stupid about index declarations, requiring an equals operation where none is appropriate leaving us with daft declarations like for i = i,..., if there was a more commonplace scripting language that did things more sensibly than lua then I...
  8. awsdert

    Want to do something similar to GNUmake's patsubst function

    As an alternative I tried re-creating the function in lua directly, not quite finished but for some reason lua is complaining about the #arg near the bottom: function patsubst( match, subst, ... ) local args = {...} local list = {} -- optimises memory allocation list[#args] =...
  9. awsdert

    Want to do something similar to GNUmake's patsubst function

    I got as far as this: function values(prefix,text) return text:gsub('@"%"','$$(' .. prefix .. '%)') end Which didn't work as intended, am I using the wrong function or have I simply written the pattern wrong?
  10. awsdert

    Need help tweaking a regexp to accept only *.c files

    Never mind, finally found the info I needed, just needed to replace the \\ with another . to escape the .
  11. awsdert

    Need help tweaking a regexp to accept only *.c files

    This is where I'm at: for _,prj in ipairs(projects) do cfg[prj] = { src_files = allsubents ( { ignore = function(ud) if ud.mode == "directory" then return false end...
Top