diff options
author | Hans Hagen <pragma@wxs.nl> | 2008-01-16 13:49:00 +0100 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2008-01-16 13:49:00 +0100 |
commit | 000a8c62f8ab88f17964644ce3dd3fc2720fb345 (patch) | |
tree | 427b505397a9433b7605ae762617c2b82fdfb562 /scripts | |
parent | 7c1a1b89fbaa2bfad94ca825c4b734e459993654 (diff) | |
download | context-000a8c62f8ab88f17964644ce3dd3fc2720fb345.tar.gz |
stable 2008.01.16 13:49
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/context/lua/mtx-context.lua | 8 | ||||
-rw-r--r-- | scripts/context/lua/mtxrun.lua | 32 | ||||
-rw-r--r-- | scripts/context/lua/x-ldx.lua | 10 | ||||
-rw-r--r-- | scripts/context/ruby/base/ctx.rb | 7 |
4 files changed, 31 insertions, 26 deletions
diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua index 6d01938ef..fbcad1111 100644 --- a/scripts/context/lua/mtx-context.lua +++ b/scripts/context/lua/mtx-context.lua @@ -74,7 +74,7 @@ do local attributes = e.at if str and attributes then if attributes['method'] then - str = ctsrunner.filtered(str,attributes['method']) + str = ctxrunner.filtered(str,attributes['method']) end if str == "" and attributes['default'] then str = attributes['default'] @@ -199,7 +199,7 @@ do local found = io.exists(usedname) if not found then - for _, path in (ctsrunner.locations) do + for _, path in pairs(ctxdata.locations) do local fullname = file.join(path,ctxdata.ctxname) if io.exists(fullname) then usedname, found = fullname, true @@ -429,7 +429,7 @@ function scripts.context.multipass.makeoptionfile(jobname,ctxdata) else local a = someflag(flag) if a and a ~= "" then - for _, v in a:gmatch("%s*([^,]+)") do + for v in a:gmatch("%s*([^,]+)") do f:write(format:format(v),"\n") end end @@ -539,7 +539,7 @@ function scripts.context.run(ctxdata) for _, filename in ipairs(files) do local basename, pathname = file.basename(filename), file.dirname(filename) local jobname = file.removesuffix(basename) - if pathname ~= "" and pathname ~= "." then + if pathname == "" then filename = "./" .. filename end -- also other stubs diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 96077d4f8..a52d3e882 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -7366,7 +7366,7 @@ function input.runners.launch_file(instance,filename) end end -function input.runners.execute_ctx_script(instance,filename) +function input.runners.execute_ctx_script(instance,filename,arguments) local function found(name) local path = file.dirname(name) if path and path ~= "" then @@ -7376,7 +7376,6 @@ function input.runners.execute_ctx_script(instance,filename) return io.exists(fullname) and fullname end end - local before, after = environment.split_arguments(filename) local suffix = "" if not filename:find("%.lua$") then suffix = ".lua" end local fullname = filename @@ -7406,25 +7405,26 @@ function input.runners.execute_ctx_script(instance,filename) elseif state == 'skip' then return true elseif state == "run" then - arg = { } for _,v in pairs(after) do arg[#arg+1] = v end + -- load and save ... kind of undocumented + arg = { } for _,v in pairs(arguments) do arg[#arg+1] = v end environment.initialize_arguments(arg) -local loadname = environment.arguments['load'] -if loadname then - if type(loadname) ~= "string" then loadname = file.basename(fullname) end - loadname = file.replacesuffix(loadname,"cfg") - input.runners.load_script_session(loadname) -end + local loadname = environment.arguments['load'] + if loadname then + if type(loadname) ~= "string" then loadname = file.basename(fullname) end + loadname = file.replacesuffix(loadname,"cfg") + input.runners.load_script_session(loadname) + end filename = environment.files[1] if input.verbose then input.report("using script: " .. fullname) end dofile(fullname) -local savename = environment.arguments['save'] -if savename and input.runners.save_list and not table.is_empty(input.runners.save_list or { }) then - if type(savename) ~= "string" then savename = file.basename(fullname) end - savename = file.replacesuffix(savename,"cfg") - input.runners.save_script_session(savename, input.runners.save_list) -end + local savename = environment.arguments['save'] + if savename and input.runners.save_list and not table.is_empty(input.runners.save_list or { }) then + if type(savename) ~= "string" then savename = file.basename(fullname) end + savename = file.replacesuffix(savename,"cfg") + input.runners.save_script_session(savename, input.runners.save_list) + end return true end else @@ -7473,7 +7473,7 @@ elseif environment.argument("ctxlua") or environment.argument("internal") then ok = input.runners.execute_script(instance,filename,true) elseif environment.argument("script") then -- run a script by loading it (using libs), pass args - ok = input.runners.execute_ctx_script(instance,filename) + ok = input.runners.execute_ctx_script(instance,filename,after) elseif environment.argument("execute") then -- execute script ok = input.runners.execute_script(instance,filename) diff --git a/scripts/context/lua/x-ldx.lua b/scripts/context/lua/x-ldx.lua index 780022e9a..d9d4e6a72 100644 --- a/scripts/context/lua/x-ldx.lua +++ b/scripts/context/lua/x-ldx.lua @@ -129,8 +129,8 @@ function ldx.enhance(data) -- i need to use lpeg and then we can properly autoin for _,v in pairs(data) do if v.code then local dqs, sqs, com, cmt, cod = { }, { }, { }, { }, e(v.code) -cod = cod:gsub('\\"', "##d##") -cod = cod:gsub("\\'", "##s##") + cod = cod:gsub('\\"', "##d##") + cod = cod:gsub("\\'", "##s##") cod = cod:gsub("%-%-%[%[.-%]%]%-%-", function(s) cmt[#cmt+1] = s return "[[[[".. #cmt .."]]]]" @@ -167,8 +167,8 @@ cod = cod:gsub("\\'", "##s##") cod = cod:gsub("%[%[(%d+)%]%]", function(s) return "<ldx:com>" .. com[tonumber(s)] .. "</ldx:com>" end) -cod = cod:gsub("##d##", "\\\"") -cod = cod:gsub("##s##", "\\\'") + cod = cod:gsub("##d##", "\\\"") + cod = cod:gsub("##s##", "\\\'") if ldx.make_index then local lines = cod:split("\n") local f = "(<ldx:key class='1'>function</ldx:key>)%s+([%w%.]+)%s*%(" @@ -279,7 +279,7 @@ it possible to change the indentation afterwards. function ldx.as_xml(data) local t, cmode = { }, false t[#t+1] = "<?xml version='1.0' standalone='yes'?>\n" - t[#t+1] = "\n<ldx:document>\n" + t[#t+1] = "\n<ldx:document xmlns:ldx='http://www.pragma-ade.com/schemas/ldx.rng'>\n" for _,v in pairs(data) do if v.code and not v.code:is_empty() then t[#t+1] = "\n<ldx:code>\n" diff --git a/scripts/context/ruby/base/ctx.rb b/scripts/context/ruby/base/ctx.rb index 2da60d0c7..a077297f2 100644 --- a/scripts/context/ruby/base/ctx.rb +++ b/scripts/context/ruby/base/ctx.rb @@ -110,7 +110,12 @@ class CtxRunner end end - @xmldata = IO.read(@ctxname) + if FileTest.file?(@ctxname) then + @xmldata = IO.read(@ctxname) + else + report('no ctx file found') + return false + end unless @xmldata =~ /^.*<\?xml.*?\?>/moi then report("ctx file #{@ctxname} is no xml file, skipping") |