summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/ruby/base/ctx.rb31
-rw-r--r--scripts/context/ruby/base/exa.rb6
-rw-r--r--scripts/context/ruby/base/merge.rb4
-rw-r--r--scripts/context/ruby/base/mp.rb2
-rw-r--r--scripts/context/ruby/base/tex.rb74
-rw-r--r--scripts/context/ruby/ctxtools.rb2
-rw-r--r--scripts/context/ruby/graphics/gs.rb4
-rw-r--r--scripts/context/ruby/pdftools.rb10
-rw-r--r--scripts/context/ruby/texexec.rb2
-rw-r--r--scripts/context/ruby/texmfstart.rb94
-rw-r--r--scripts/context/ruby/textools.rb2
-rw-r--r--scripts/context/ruby/www/exa.rb22
-rw-r--r--scripts/context/ruby/xmltools.rb14
13 files changed, 185 insertions, 82 deletions
diff --git a/scripts/context/ruby/base/ctx.rb b/scripts/context/ruby/base/ctx.rb
index d09be55d4..2da60d0c7 100644
--- a/scripts/context/ruby/base/ctx.rb
+++ b/scripts/context/ruby/base/ctx.rb
@@ -45,6 +45,11 @@ class CtxRunner
@flags = Array.new
@modes = Array.new
@local = false
+ @paths = Array.new
+ end
+
+ def register_path(str)
+ @paths << str
end
def manipulate(ctxname=nil,defaultname=nil)
@@ -61,6 +66,10 @@ class CtxRunner
return
end
+ if @ctxname !~ /\.[a-z]+$/ then
+ @ctxname += ".ctx"
+ end
+
# name can be kpse:res-make.ctx
if not FileTest.file?(@ctxname) then
fullname, done = '', false
@@ -84,6 +93,12 @@ class CtxRunner
end
break if done
end
+ if ! done then
+ fullname = Kpse.found(@ctxname)
+ if FileTest.file?(fullname) then
+ @ctxname, done = fullname, true
+ end
+ end
end
if ! done && defaultname && FileTest.file?(defaultname) then
report("using default ctxfile #{defaultname}")
@@ -211,12 +226,25 @@ class CtxRunner
end
pattern = justtext(pattern)
oldfiles = Dir.glob(pattern)
+ pluspath = false
if oldfiles.length == 0 then
report("no files match #{pattern}")
+ if @paths.length > 0 then
+ @paths.each do |p|
+ oldfiles = Dir.glob("#{p}/#{pattern}")
+ if oldfiles.length > 0 then
+ pluspath = true
+ break
+ end
+ end
+ if oldfiles.length == 0 then
+ report("no files match #{pattern} on path")
+ end
+ end
end
oldfiles.each do |oldfile|
newfile = "#{oldfile}.#{suffix}"
- newfile = File.basename(newfile) if @local
+ newfile = File.basename(newfile) if @local # or pluspath
if File.expand_path(oldfile) != File.expand_path(newfile) && File.needsupdate(oldfile,newfile) then
report("#{oldfile} needs preprocessing")
begin
@@ -413,6 +441,7 @@ class CtxRunner
when 'suffix' then if str =~ /^.*\.(.*?)$/o then $1 else '' end
when 'nosuffix' then if str =~ /^(.*)\..*?$/o then $1 else str end
when 'nopath' then if str =~ /^.*[\\\/](.*?)$/o then $1 else str end
+ when 'base' then if str =~ /^.*[\\\/](.*?)$/o then $1 else str end
when 'full' then str
when 'complete' then str
when 'expand' then File.expand_path(str).gsub(/\\/,"/")
diff --git a/scripts/context/ruby/base/exa.rb b/scripts/context/ruby/base/exa.rb
index fdc5b5093..5a094351e 100644
--- a/scripts/context/ruby/base/exa.rb
+++ b/scripts/context/ruby/base/exa.rb
@@ -45,7 +45,7 @@ module ExaEncrypt
"#{pre}#{password}#{post}"
end
else
- data.gsub!(/<exa:password([^>]*?)>(.*?)<\/exa:password>/mois) do
+ data.gsub!(/<exa:password([^>]*?)>(.*?)<\/exa:password>/moi) do
attributes, password = $1, $2
unless password =~ /^([0-9A-F][0-9A-F])+$/ then
done = true
@@ -238,11 +238,11 @@ module ExaModes
binln, einln = "<inlinetexmath>" , "</inlinetexmath>"
egraf = "<p/>"
end
- str.gsub!(/\n\s*\n+/mois, "\\ENDGRAF ")
+ str.gsub!(/\n\s*\n+/moi, "\\ENDGRAF ")
str.gsub!(/(\[\[)\s*(.*?)\s*(\]\])/mos) do
$1 + docalculatortexmath($2) + $3
end
- str.gsub!(/(\\ENDGRAF)+\s*(\[\[)\s*(.*?)\s*(\]\])/mois) do
+ str.gsub!(/(\\ENDGRAF)+\s*(\[\[)\s*(.*?)\s*(\]\])/moi) do
$1 + bdisp + $3 + edisp
end
str.gsub!(/(\[\[)\s*(.*?)\s*(\]\])/o) do
diff --git a/scripts/context/ruby/base/merge.rb b/scripts/context/ruby/base/merge.rb
index c6ea6c09e..ad4b9c9e6 100644
--- a/scripts/context/ruby/base/merge.rb
+++ b/scripts/context/ruby/base/merge.rb
@@ -65,7 +65,7 @@ module SelfMerge
end
inserts << "#{@@kpsemergestop}\n\n"
# no gsub! else we end up in SelfMerge
- rbfile.sub!(/#{@@kpsemergestart}\s*#{@@kpsemergestop}/mois) do
+ rbfile.sub!(/#{@@kpsemergestart}\s*#{@@kpsemergestop}/moi) do
inserts
end
rbfile.gsub!(/^(.*)(require [\"\'].*?#{@@modroot}.*)$/) do
@@ -99,7 +99,7 @@ module SelfMerge
begin
if rbfile = IO.read(@@filename) then
begin
- rbfile.sub!(/#{@@kpsemergestart}(.*)#{@@kpsemergestop}\s*/mois) do
+ rbfile.sub!(/#{@@kpsemergestart}(.*)#{@@kpsemergestop}\s*/moi) do
"#{@@kpsemergestart}\n\n#{@@kpsemergestop}\n\n"
end
rbfile.gsub!(/^(.*#{@@kpsemergedone}.*)$/) do
diff --git a/scripts/context/ruby/base/mp.rb b/scripts/context/ruby/base/mp.rb
index 5dd2948cf..d168bde1d 100644
--- a/scripts/context/ruby/base/mp.rb
+++ b/scripts/context/ruby/base/mp.rb
@@ -144,7 +144,7 @@ EOT
result.gsub!(/(.{80,})(\-\-\-|\-\-|\.\.\.|\.\.)/) do
"#{$1}#{$2}\n"
end
- result.gsub!(/\n[\s\n]+/mois) do
+ result.gsub!(/\n[\s\n]+/moi) do
"\n"
end
result.gsub!(/btex\((\d+)\)/) do
diff --git a/scripts/context/ruby/base/tex.rb b/scripts/context/ruby/base/tex.rb
index 5898d7aa5..bb961111c 100644
--- a/scripts/context/ruby/base/tex.rb
+++ b/scripts/context/ruby/base/tex.rb
@@ -783,12 +783,12 @@ class TEX
result = runtexexec([tempfilename], flags, 1)
if FileTest.file?("#{@@temprunfile}.log") then
logdata = IO.read("#{@@temprunfile}.log")
- if logdata =~ /^\s*This is (.*?)[\s\,]+(.*?)$/mois then
+ if logdata =~ /^\s*This is (.*?)[\s\,]+(.*?)$/moi then
if validtexengine($1.downcase) then
results.push("#{$1} #{$2.gsub(/\(format.*$/,'')}".strip)
end
end
- if logdata =~ /^\s*(ConTeXt)\s+(.*int:\s+[a-z]+.*?)\s*$/mois then
+ if logdata =~ /^\s*(ConTeXt)\s+(.*int:\s+[a-z]+.*?)\s*$/moi then
results.push("#{$1} #{$2}".gsub(/\s+/,' ').strip)
end
else
@@ -1184,7 +1184,7 @@ class TEX
begin
data = IO.read(File.suffixed(filename,'log'))
basename = filename.sub(/\.mp$/, '')
- if data =~ /output files* written\:\s*(.*)$/mois then
+ if data =~ /output files* written\:\s*(.*)$/moi then
files, number, range, list = $1.split(/\s+/), 0, false, []
files.each do |fname|
if fname =~ /^.*\.(\d+)$/ then
@@ -1270,7 +1270,7 @@ class TEX
File.open("texexec.tex",'w') do |f|
f << "\\setupoutput[pdftex]\n"
f << "\\setupcolors[state=start]\n"
- data.sub!(/^%mpenvironment\:\s*(.*?)$/mois) do
+ data.sub!(/^%mpenvironment\:\s*(.*?)$/moi) do
f << $1
"\n"
end
@@ -1488,7 +1488,14 @@ class TEX
[getvariable('runpath'),getvariable('path')].each do |pat|
unless pat.empty? then
if ENV.key?(res) then
- ENV[res] = if ENV[res].empty? then pat else pat + ":" + ENV[res] end
+ # ENV[res] = if ENV[res].empty? then pat else pat + ":" + ENV[res] end
+if ENV[res].empty? then
+ ENV[res] = pat
+elsif ENV[res] == pat || ENV[res] =~ /^#{pat}\:/ || ENV[res] =~ /\:#{pat}\:/ then
+ # skip
+else
+ ENV[res] = pat + ":" + ENV[res]
+end
else
ENV[res] = pat
end
@@ -1731,14 +1738,9 @@ class TEX
takeprecautions
report("using search method '#{Kpse.searchmethod}'") if getvariable('verbose')
+
rawname = getvariable('filename')
jobname = getvariable('filename')
- suffix = getvariable('suffix')
- result = getvariable('result')
- forcexml = getvariable('forcexml')
- runonce = getvariable('once')
- finalrun = getvariable('final') || (getvariable('arrange') && ! getvariable('noarrange'))
- globalfile = getvariable('globalfile')
if getvariable('autopath') then
jobname = File.basename(jobname)
@@ -1751,18 +1753,11 @@ class TEX
jobname = File.unixfied(jobname)
inppath = File.unixfied(inppath)
- result = File.unixfied(result)
orisuffix = jobsuffix # still needed ?
- setvariable('nomprun',true) if orisuffix == 'mpx' # else cylic run
-
- PDFview.setmethod('xpdf') if getvariable('xpdf')
-
- PDFview.closeall if getvariable('autopdf')
-
if jobsuffix =~ /^(htm|html|xhtml|xml|fo|fox|rlg|exa)$/io then
- forcexml = true
+ setvariable('forcexml',true)
end
dummyfile = false
@@ -1779,7 +1774,6 @@ class TEX
# we can have funny names, like 2005.10.10 (given without suffix)
rawname = jobname + '.' + jobsuffix
-
rawpath = File.dirname(rawname)
rawbase = File.basename(rawname)
@@ -1789,16 +1783,22 @@ class TEX
end
end
- if dummyfile || forcexml then
- jobsuffix = makestubfile(rawname,rawbase,forcexml)
- checkxmlfile(rawname)
- end
+ forcexml = getvariable('forcexml')
+ # if dummyfile || forcexml then # after ctx?
+ # jobsuffix = makestubfile(rawname,rawbase,forcexml)
+ # checkxmlfile(rawname)
+ # end
# preprocess files
unless getvariable('noctx') then
ctx = CtxRunner.new(rawname,@logger)
+ if pth = getvariable('path') then
+ pth.split(',').each do |p|
+ ctx.register_path(p)
+ end
+ end
if getvariable('ctxfile').empty? then
if rawname == rawbase then
ctx.manipulate(File.suffixed(rawname,'ctx'),'jobname.ctx')
@@ -1829,7 +1829,7 @@ class TEX
# merge environment and module specs
envs << getvariable('environments') unless getvariable('environments').empty?
- mods << getvariable('modules') unless getvariable('modules') .empty?
+ mods << getvariable('usemodules') unless getvariable('usemodules') .empty?
mdes << getvariable('modes') unless getvariable('modes') .empty?
envs = envs.uniq.join(',')
@@ -1843,12 +1843,30 @@ class TEX
report("using modes #{mdes}") if mdes.length > 0
setvariable('environments', envs)
- setvariable('modules', mods)
+ setvariable('usemodules', mods)
setvariable('modes', mdes)
end
# end of preprocessing and merging
+ setvariable('nomprun',true) if orisuffix == 'mpx' # else cylic run
+ PDFview.setmethod('xpdf') if getvariable('xpdf')
+ PDFview.closeall if getvariable('autopdf')
+
+ runonce = getvariable('once')
+ finalrun = getvariable('final') || (getvariable('arrange') && ! getvariable('noarrange'))
+ suffix = getvariable('suffix')
+ result = getvariable('result')
+ globalfile = getvariable('globalfile')
+ forcexml = getvariable('forcexml') # can be set in ctx file
+
+ if dummyfile || forcexml then # after ctx?
+ jobsuffix = makestubfile(rawname,rawbase,forcexml)
+ checkxmlfile(rawname)
+ end
+
+ result = File.unixfied(result)
+
if globalfile || FileTest.file?(rawname) then
if not dummyfile and not globalfile then
@@ -1960,7 +1978,7 @@ class TEX
# next line is empty
ok = 2
when 2 then
- if line =~ /^\%\s+\>\s+(.*?)\s+(\d+)/mois then
+ if line =~ /^\%\s+\>\s+(.*?)\s+(\d+)/moi then
filename, n = $1, $2
done = File.delete(filename) rescue false
if done && getvariable('verbose') then
@@ -1970,7 +1988,7 @@ class TEX
break
end
else
- if line =~ /^\%\s+temporary files\:\s+(\d+)/mois then
+ if line =~ /^\%\s+temporary files\:\s+(\d+)/moi then
if $1.to_i == 0 then
break
else
diff --git a/scripts/context/ruby/ctxtools.rb b/scripts/context/ruby/ctxtools.rb
index d8d38e84b..a70501cd5 100644
--- a/scripts/context/ruby/ctxtools.rb
+++ b/scripts/context/ruby/ctxtools.rb
@@ -908,7 +908,7 @@ class Language
@data += data.gsub(/\%.*$/, '').gsub(/\\message\{.*?\}/, '')
data.gsub!(/(\\patterns|\\hyphenation)\s*\{.*/mo) do '' end
@read += "\n% preamble of file #{fname}\n\n#{data}\n"
- @data.gsub!(/^[\s\n]+$/mois, '')
+ @data.gsub!(/^[\s\n]+$/moi, '')
report("file #{fname} is loaded")
found = true
break # next fileset
diff --git a/scripts/context/ruby/graphics/gs.rb b/scripts/context/ruby/graphics/gs.rb
index 51175efa3..a73400ba2 100644
--- a/scripts/context/ruby/graphics/gs.rb
+++ b/scripts/context/ruby/graphics/gs.rb
@@ -452,10 +452,10 @@ class GhostScript
debug('bbox spec', bbox)
- if bbox =~ /(Exact|HiRes)BoundingBox:#{@@bboxspec}/mois then
+ if bbox =~ /(Exact|HiRes)BoundingBox:#{@@bboxspec}/moi then
debug("high res bbox #{$2} #{$3} #{$4} #{$5}")
setdimensions($2,$3,$4,$5)
- elsif bbox =~ /BoundingBox:#{@@bboxspec}/mois
+ elsif bbox =~ /BoundingBox:#{@@bboxspec}/moi
debug("low res bbox #{$1} #{$2} #{$3} #{$4}")
setdimensions($1,$2,$3,$4)
end
diff --git a/scripts/context/ruby/pdftools.rb b/scripts/context/ruby/pdftools.rb
index 25e7250b6..23edfeca2 100644
--- a/scripts/context/ruby/pdftools.rb
+++ b/scripts/context/ruby/pdftools.rb
@@ -397,20 +397,20 @@ class SpotColorImage
if data =~ /(\d+)\s+0\s+obj\s+\[\/Separation\s+\/#{@colorname}/mos then
@command.report("replacing separation color")
object = $1
- data.gsub!(/(\/Type\s+\/XObject.*?)(\/ColorSpace\s*(\/DeviceGray|\/DeviceCMYK|\/DeviceRGB|\d+\s+\d+\s+R))/mois) do
+ data.gsub!(/(\/Type\s+\/XObject.*?)(\/ColorSpace\s*(\/DeviceGray|\/DeviceCMYK|\/DeviceRGB|\d+\s+\d+\s+R))/moi) do
$1 + "/ColorSpace #{object} 0 R".ljust($2.length)
end
elsif data =~ /(\d+)\s+0\s+obj\s+\[\/Indexed\s*\[/mos then
@command.report("replacing indexed color")
# todo: more precise check on color
object = $1
- data.gsub!(/(\/Type\s+\/XObject.*?)(\/ColorSpace\s*(\/DeviceGray|\/DeviceCMYK|\/DeviceRGB|\d+\s+\d+\s+R))/mois) do
+ data.gsub!(/(\/Type\s+\/XObject.*?)(\/ColorSpace\s*(\/DeviceGray|\/DeviceCMYK|\/DeviceRGB|\d+\s+\d+\s+R))/moi) do
$1 + "/ColorSpace #{object} 0 R".ljust($2.length)
end
elsif data =~ /(\d+)\s+0\s+obj\s+\[\/Separation/mos then
@command.report("replacing separation color")
object = $1
- data.gsub!(/(\/Type\s+\/XObject.*?)(\/ColorSpace\s*(\/DeviceGray|\/DeviceCMYK|\/DeviceRGB|\d+\s+\d+\s+R))/mois) do
+ data.gsub!(/(\/Type\s+\/XObject.*?)(\/ColorSpace\s*(\/DeviceGray|\/DeviceCMYK|\/DeviceRGB|\d+\s+\d+\s+R))/moi) do
$1 + "/ColorSpace #{object} 0 R".ljust($2.length)
end
end
@@ -663,7 +663,7 @@ class Commands
pairs = Hash.new
data.each do |d|
- if (d =~ /^\s*(.*?)\s*\:\s*(.*?)\s*$/mois) then
+ if (d =~ /^\s*(.*?)\s*\:\s*(.*?)\s*$/moi) then
key, val = $1, $2
pairs[key.downcase.sub(/ /,'')] = val
end
@@ -780,7 +780,7 @@ class Commands
end
threshold = @commandline.option('threshold').to_i rescue 0
filenames.each do |filename|
- if `pdfinfo #{filename}`.chomp =~ /^pages\s*\:\s*(\d+)/mois then
+ if `pdfinfo #{filename}`.chomp =~ /^pages\s*\:\s*(\d+)/moi then
p = $1
m = p.to_i rescue 0
if threshold == 0 or m > threshold then
diff --git a/scripts/context/ruby/texexec.rb b/scripts/context/ruby/texexec.rb
index f37cfd8c2..9b79369d8 100644
--- a/scripts/context/ruby/texexec.rb
+++ b/scripts/context/ruby/texexec.rb
@@ -242,7 +242,7 @@ class Commands
mod << "\\stoptext\n"
mod.close
job.setvariable('interface','english') # redundant
- job.setvariable('simplerun',true)
+ # job.setvariable('simplerun',true)
# job.setvariable('nooptionfile',true)
job.setvariable('files',[job.tempfilename])
result = File.unsuffixed(File.basename(ffname))
diff --git a/scripts/context/ruby/texmfstart.rb b/scripts/context/ruby/texmfstart.rb
index 17d4b5042..f60011d1d 100644
--- a/scripts/context/ruby/texmfstart.rb
+++ b/scripts/context/ruby/texmfstart.rb
@@ -1349,7 +1349,7 @@ module SelfMerge
end
inserts << "#{@@kpsemergestop}\n\n"
# no gsub! else we end up in SelfMerge
- rbfile.sub!(/#{@@kpsemergestart}\s*#{@@kpsemergestop}/mois) do
+ rbfile.sub!(/#{@@kpsemergestart}\s*#{@@kpsemergestop}/moi) do
inserts
end
rbfile.gsub!(/^(.*)(require [\"\'].*?#{@@modroot}.*)$/) do
@@ -1383,7 +1383,7 @@ module SelfMerge
begin
if rbfile = IO.read(@@filename) then
begin
- rbfile.sub!(/#{@@kpsemergestart}(.*)#{@@kpsemergestop}\s*/mois) do
+ rbfile.sub!(/#{@@kpsemergestart}(.*)#{@@kpsemergestop}\s*/moi) do
"#{@@kpsemergestart}\n\n#{@@kpsemergestop}\n\n"
end
rbfile.gsub!(/^(.*#{@@kpsemergedone}.*)$/) do
@@ -1445,6 +1445,7 @@ $stderr.sync = true
$applications = Hash.new
$suffixinputs = Hash.new
$predefined = Hash.new
+$runners = Hash.new
$suffixinputs['pl'] = 'PERLINPUTS'
$suffixinputs['rb'] = 'RUBYINPUTS'
@@ -1517,10 +1518,10 @@ $kpse = nil
def set_applications(page=1)
$applications['unknown'] = ''
- $applications['perl'] = $applications['pl'] = 'perl'
$applications['ruby'] = $applications['rb'] = 'ruby'
+ $applications['lua'] = $applications['lua'] = 'lua'
+ $applications['perl'] = $applications['pl'] = 'perl'
$applications['python'] = $applications['py'] = 'python'
- $applications['lua'] = $applications['lua'] = 'luatex --luaonly'
$applications['java'] = $applications['jar'] = 'java'
if $mswindows then
@@ -1536,6 +1537,8 @@ def set_applications(page=1)
$applications['htm'] = $applications['html']
$applications['eps'] = $applications['ps']
+ $runners['lua'] = "luatex --luaonly"
+
end
set_applications()
@@ -1675,6 +1678,33 @@ class File
end
+# def hashed (arr=[])
+ # arg = if arr.class == String then arr.split(' ') else arr.dup end
+ # hsh = Hash.new
+ # if arg.length > 0
+ # hsh['arguments'] = ''
+ # done = false
+ # arg.each do |s|
+ # if done then
+ # if s =~ / / then
+ # hsh['arguments'] += " \"#{s}\"" # maybe split on =
+ # else
+ # hsh['arguments'] += " #{s}"
+ # end
+ # else
+ # kvl = s.split('=')
+ # if kvl[0].sub!(/^\-+/,'') then
+ # hsh[kvl[0]] = if kvl.length > 1 then kvl[1] else true end
+ # else
+ # hsh['file'] = s
+ # done = true
+ # end
+ # end
+ # end
+ # end
+ # return hsh
+# end
+
def hashed (arr=[])
arg = if arr.class == String then arr.split(' ') else arr.dup end
hsh = Hash.new
@@ -1683,7 +1713,18 @@ def hashed (arr=[])
done = false
arg.each do |s|
if done then
- hsh['arguments'] += ' ' + s
+ if s =~ /\s/ then
+ kvl = s.split('=')
+ if kvl[1] and kvl[1] !~ /^[\"\']/ then
+ hsh['arguments'] += ' ' + kvl[0] + "=" + '"' + kvl[1] + '"'
+ elsif s =~ /\s/ then
+ hsh['arguments'] += ' "' + s + '"'
+ else
+ hsh['arguments'] += ' ' + s
+ end
+ else
+ hsh['arguments'] += ' ' + s
+ end
else
kvl = s.split('=')
if kvl[0].sub!(/^\-+/,'') then
@@ -1698,6 +1739,7 @@ def hashed (arr=[])
return hsh
end
+
def launch(filename)
if $browser && $mswindows then
filename = filename.gsub(/\.[\/\\]/) do
@@ -1717,15 +1759,25 @@ end
# rel|relative
# loc|locate|kpse|path|file
+def quoted(str)
+ if str =~ /^\"/ then
+ return str
+ elsif str =~ / / then
+ return "\"#{str}\""
+ else
+ return str
+ end
+end
+
def expanded(arg) # no "other text files", too restricted
arg.gsub(/(env|environment)\:([a-zA-Z\-\_\.0-9]+)/o) do
method, original, resolved = $1, $2, ''
if resolved = ENV[original] then
report("environment variable #{original} expands to #{resolved}") unless $report
- resolved
+ quoted(resolved)
else
report("environment variable #{original} cannot be resolved") unless $report
- original
+ quoted(original)
end
end . gsub(/(rel|relative)\:([a-zA-Z\-\_\.0-9]+)/o) do
method, original, resolved = $1, $2, ''
@@ -1736,9 +1788,9 @@ def expanded(arg) # no "other text files", too restricted
end
end
if resolved.empty? then
- original
+ quoted(original)
else
- resolved
+ quoted(resolved)
end
end . gsub(/(kpse|loc|locate|file|path)\:([a-zA-Z\-\_\.0-9]+)/o) do
method, original, resolved = $1, $2, ''
@@ -1753,7 +1805,7 @@ def expanded(arg) # no "other text files", too restricted
if ENV["_CTX_K_V_#{original}_"] then
resolved = ENV["_CTX_K_V_#{original}_"]
report("environment provides #{original} as #{resolved}") unless $report
- resolved
+ quoted(resolved)
else
check_kpse
pstrings.each do |pstr|
@@ -1789,12 +1841,12 @@ def expanded(arg) # no "other text files", too restricted
original = File.dirname(original) if method =~ /path/
report("#{original} is not resolved") unless $report
ENV["_CTX_K_V_#{original}_"] = original if $crossover
- original
+ quoted(original)
else
resolved = File.dirname(resolved) if method =~ /path/
report("#{original} is resolved to #{resolved}") unless $report
ENV["_CTX_K_V_#{original}_"] = resolved if $crossover
- resolved
+ quoted(resolved)
end
end
end
@@ -1839,6 +1891,11 @@ def runcommand(command)
end
end
+def join_command(args)
+ args[0] = $runners[args[0]] || args[0]
+ [args].join(' ')
+end
+
def runoneof(application,fullname,browserpermitted)
if browserpermitted && launch(fullname) then
return true
@@ -1851,26 +1908,26 @@ def runoneof(application,fullname,browserpermitted)
return true
elsif applications.class == Array then
if $report then
- output([fullname,expanded($arguments)].join(' '))
+ output(join_command([fullname,expanded($arguments)]))
return true
else
applications.each do |a|
- return true if runcommand([a,fullname,expanded($arguments)].join(' '))
+ return true if runcommand(join_command([a,fullname,expanded($arguments)]))
end
end
elsif applications.empty? then
if $report then
- output([fullname,expanded($arguments)].join(' '))
+ output(join_command([fullname,expanded($arguments)]))
return true
else
- return runcommand([fullname,expanded($arguments)].join(' '))
+ return runcommand(join_command([fullname,expanded($arguments)]))
end
else
if $report then
- output([applications,fullname,expanded($arguments)].join(' '))
+ output(join_command([applications,fullname,expanded($arguments)]))
return true
else
- return runcommand([applications,fullname,expanded($arguments)].join(' '))
+ return runcommand(join_command([applications,fullname,expanded($arguments)]))
end
end
return false
@@ -2414,7 +2471,6 @@ end
def execute(arguments)
arguments = arguments.split(/\s+/) if arguments.class == String
-
$directives = hashed(arguments)
$help = $directives['help'] || false
diff --git a/scripts/context/ruby/textools.rb b/scripts/context/ruby/textools.rb
index 56b018e2a..442dc1924 100644
--- a/scripts/context/ruby/textools.rb
+++ b/scripts/context/ruby/textools.rb
@@ -713,7 +713,7 @@ class Commands
f << "\n"
f << "/#{encoding.gsub(/[^a-zA-Z]/,'')}encoding [\n"
256.times do |i|
- f << " /#{chars[i] || '.notdef'}\n"
+ f << " /#{chars[i] || '.notdef'} % #{i}\n"
end
f << "] def\n"
f.close
diff --git a/scripts/context/ruby/www/exa.rb b/scripts/context/ruby/www/exa.rb
index 5e9b3fd82..997eab67d 100644
--- a/scripts/context/ruby/www/exa.rb
+++ b/scripts/context/ruby/www/exa.rb
@@ -156,32 +156,32 @@ class WWW
req << "</exa:request>\n"
else
# better use rexml but slower
- if req =~ /<exa:request[^>]*>.*?\s*<exa:threshold>\s*(.*?)\s*<\/exa:threshold>\s*.*?<\/exa:request>/mois then
+ if req =~ /<exa:request[^>]*>.*?\s*<exa:threshold>\s*(.*?)\s*<\/exa:threshold>\s*.*?<\/exa:request>/moi then
threshold = $1
unless threshold.empty? then
@interface.set('process:threshold', threshold)
@session.set('threshold', threshold)
end
end
- req.sub!(/(<exa:request[^>]*>.*?)\s*<exa:option>\s*\-\-action\=(.*?)\s*<\/exa:option>\s*(.*?<\/exa:request>)/mois) do
+ req.sub!(/(<exa:request[^>]*>.*?)\s*<exa:option>\s*\-\-action\=(.*?)\s*<\/exa:option>\s*(.*?<\/exa:request>)/moi) do
pre, act, pos = $1, $2, $3
action = act.sub(/\.exa$/,'') if action.empty?
str = "#{pre}<exa:action>#{action}</exa:action>#{pos}"
- str.sub(/\s*<exa:command>.*?<\/exa:command>\s*/mois ,'')
+ str.sub(/\s*<exa:command>.*?<\/exa:command>\s*/moi ,'')
end
- req.sub!(/(<exa:request[^>]*>.*?)<exa:action>\s*(.*?)\s*<\/exa:action>(.*?<\/exa:request>)/mois) do
+ req.sub!(/(<exa:request[^>]*>.*?)<exa:action>\s*(.*?)\s*<\/exa:action>(.*?<\/exa:request>)/moi) do
pre, act, pos = $1, $2, $3
action = act.sub(/\.exa$/,'') if action.empty?
str = "#{pre}<exa:action>#{action}</exa:action>#{pos}"
- str.sub(/\s*<exa:command>.*?<\/exa:command>\s*/mois ,'')
+ str.sub(/\s*<exa:command>.*?<\/exa:command>\s*/moi ,'')
end
- unless req =~ /<exa:data>(.*?)<\/exa:data>/mois then
+ unless req =~ /<exa:data>(.*?)<\/exa:data>/moi then
req.sub!(/(<\/exa:request>)/) do dat + $1 end
end
end
- req.sub!(/<exa:filename>.*?<\/exa:filename>/mois, '')
+ req.sub!(/<exa:filename>.*?<\/exa:filename>/moi, '')
unless @variables.empty?('exa:filename') then
- req.sub!(/(<\/exa:application>)/mois) do
+ req.sub!(/(<\/exa:application>)/moi) do
"<exa:filename>#{@variables.get('exa:filename')}<\/exa:filename>" + $1
end
end
@@ -312,13 +312,13 @@ class WWW
end
unless req.empty? then
# better use rexml but slower / reuse these : command = filter_from_request('exa:command')
- if req =~ /<exa:request[^>]*>.*?\s*<exa:command>\s*(.*?)\s*<\/exa:command>\s*.*?<\/exa:request>/mois then
+ if req =~ /<exa:request[^>]*>.*?\s*<exa:command>\s*(.*?)\s*<\/exa:command>\s*.*?<\/exa:request>/moi then
command = $1
end
- if req =~ /<exa:request[^>]*>.*?\s*<exa:url>\s*(.*?)\s*<\/exa:url>\s*.*?<\/exa:request>/mois then
+ if req =~ /<exa:request[^>]*>.*?\s*<exa:url>\s*(.*?)\s*<\/exa:url>\s*.*?<\/exa:request>/moi then
url = $1
end
- if req =~ /<exa:request[^>]*>.*?\s*<exa:threshold>\s*(.*?)\s*<\/exa:threshold>\s*.*?<\/exa:request>/mois then
+ if req =~ /<exa:request[^>]*>.*?\s*<exa:threshold>\s*(.*?)\s*<\/exa:threshold>\s*.*?<\/exa:request>/moi then
threshold = $1
unless threshold.empty? then
@interface.set('process:threshold', threshold)
diff --git a/scripts/context/ruby/xmltools.rb b/scripts/context/ruby/xmltools.rb
index 0c828e9d3..e0ff3c0f7 100644
--- a/scripts/context/ruby/xmltools.rb
+++ b/scripts/context/ruby/xmltools.rb
@@ -15,7 +15,7 @@
# This script will harbor some handy manipulations on tex
# related files.
-banner = ['XMLTools', 'version 1.2.1', '2002/2006', 'PRAGMA ADE/POD']
+banner = ['XMLTools', 'version 1.2.2', '2002/2007', 'PRAGMA ADE/POD']
$: << File.expand_path(File.dirname($0)) ; $: << File.join($:.last,'lib') ; $:.uniq!
@@ -466,35 +466,35 @@ class Commands
elements = Array.new
preamble = ""
done = false
- data.sub!(/^(.*?)\s*(<[a-z])/mois) do
+ data.sub!(/^(.*?)\s*(<[a-z])/moi) do
preamble = $1
$2
end
# hide elements
- data.gsub!(/<(.*?)>/mois) do
+ data.gsub!(/<([^>]*?)>/moi) do
elements << $1
"<#{elements.length}>"
end
# abc[-/]def
- data.gsub!(/([a-z]{3,})([\/\-\(\)])([a-z]{3,})/mois) do
+ data.gsub!(/([a-z]{3,})([\/\-\(\)])([a-z]{3,})/moi) do
done = true
report("compound: #{$1}#{$2}#{$3}") if verbose
"#{$1}<compound token='#{$2}'/>#{$3}"
end
# (abcd
- # data.gsub!(/(\()([a-z]{4,})/mois) do
+ # data.gsub!(/(\()([a-z]{4,})/moi) do
# done = true
# report("compound: #{$1}#{$2}") if verbose
# "<compound token='#{$1}'/>#{$2}"
# end
# abcd)
- # data.gsub!(/(\()([a-z]{4,})/mois) do
+ # data.gsub!(/(\()([a-z]{4,})/moi) do
# done = true
# report("compound: #{$1}#{$2}") if verbose
# "#{$2}<compound token='#{$2}'/>"
# end
# roll back elements
- data.gsub!(/<(\d+)>/mois) do
+ data.gsub!(/<(\d+)>/moi) do
"<#{elements.shift}>"
end
File.open(newname,'wb') do |f|