summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/ruby/base/kpse.rb12
-rw-r--r--scripts/context/ruby/base/kpse/soap.rb3
-rw-r--r--scripts/context/ruby/base/kpsefast.rb36
-rw-r--r--scripts/context/ruby/base/switch.rb2
-rw-r--r--scripts/context/ruby/base/tex.rb29
-rw-r--r--scripts/context/ruby/base/texutil.rb23
6 files changed, 71 insertions, 34 deletions
diff --git a/scripts/context/ruby/base/kpse.rb b/scripts/context/ruby/base/kpse.rb
index 0e3292d00..8eb261724 100644
--- a/scripts/context/ruby/base/kpse.rb
+++ b/scripts/context/ruby/base/kpse.rb
@@ -21,11 +21,19 @@ require 'rbconfig'
class String
def split_path
- self.split(/\:\;/)
+ if self =~ /\;/ then
+ self.split(";")
+ else
+ self.split(":")
+ end
end
+end
+
+class Array
+
def join_path
- self.join(FILE::PATH_SEPARATOR)
+ self.join(File::PATH_SEPARATOR)
end
end
diff --git a/scripts/context/ruby/base/kpse/soap.rb b/scripts/context/ruby/base/kpse/soap.rb
index 5ec45e954..c9ed75c44 100644
--- a/scripts/context/ruby/base/kpse/soap.rb
+++ b/scripts/context/ruby/base/kpse/soap.rb
@@ -77,6 +77,3 @@ class KpseClient
end
end
-
-
-
diff --git a/scripts/context/ruby/base/kpsefast.rb b/scripts/context/ruby/base/kpsefast.rb
index dbc9f55e8..724c90921 100644
--- a/scripts/context/ruby/base/kpsefast.rb
+++ b/scripts/context/ruby/base/kpsefast.rb
@@ -10,6 +10,26 @@
# todo: multiple cnf files
+class String
+
+ def split_path
+ if self =~ /\;/ then
+ self.split(";")
+ else
+ self.split(":")
+ end
+ end
+
+end
+
+class Array
+
+ def join_path
+ self.join(File::PATH_SEPARATOR)
+ end
+
+end
+
class File
def File.locate_file(path,name)
@@ -50,7 +70,7 @@ module KpseUtil
end
filenames = Array.new
if ENV['TEXMFCNF'] and not ENV['TEXMFCNF'].empty? then
- ENV['TEXMFCNF'].split_path.each do |path|
+ ENV['TEXMFCNF'].to_s.split_path.each do |path|
filenames << File.join(path,@@texmfcnf)
end
elsif ENV['SELFAUTOPARENT'] == '.' then
@@ -79,18 +99,6 @@ module KpseUtil
end
-class String
-
- def split_path
- self.split(/\:\;/)
- end
-
- def join_path
- self.join(FILE::PATH_SEPARATOR)
- end
-
-end
-
class KpseFast
# formats are an incredible inconsistent mess
@@ -293,7 +301,7 @@ class KpseFast
end
filenames = Array.new
if @environment['TEXMFCNF'] and not @environment['TEXMFCNF'].empty? then
- @environment['TEXMFCNF'].split_path.each do |path|
+ @environment['TEXMFCNF'].to_s.split_path.each do |path|
filenames << File.join(path,@@texmfcnf)
end
elsif @environment['SELFAUTOPARENT'] == '.' then
diff --git a/scripts/context/ruby/base/switch.rb b/scripts/context/ruby/base/switch.rb
index 3113ad4d6..97575cdaa 100644
--- a/scripts/context/ruby/base/switch.rb
+++ b/scripts/context/ruby/base/switch.rb
@@ -52,7 +52,7 @@ class File
oldtime = File.stat(oldname).mtime.to_i
newtime = File.stat(newname).mtime.to_i
delta = newtime - oldtime
- (delta > @@update_eps) || (-delta > @@update_eps)
+ delta < @@update_eps
rescue
return true
end
diff --git a/scripts/context/ruby/base/tex.rb b/scripts/context/ruby/base/tex.rb
index 5e9a9566f..9cb891009 100644
--- a/scripts/context/ruby/base/tex.rb
+++ b/scripts/context/ruby/base/tex.rb
@@ -125,7 +125,7 @@ class TEX
'nomapfiles', 'local',
'arrange', 'noarrange',
'forcexml', 'foxet',
-'alpha', 'beta',
+ 'alpha', 'beta',
'mpyforce', 'forcempy',
'forcetexutil', 'texutil',
'globalfile', 'autopath',
@@ -136,7 +136,8 @@ class TEX
'modefile', 'result', 'suffix', 'response', 'path',
'filters', 'usemodules', 'environments', 'separation', 'setuppath',
'arguments', 'input', 'output', 'randomseed', 'modes', 'mode', 'filename',
- 'ctxfile', 'printformat', 'paperformat'
+ 'ctxfile', 'printformat', 'paperformat',
+ 'timeout'
]
@@standardvars = [
'mainlanguage', 'bodyfont', 'language'
@@ -858,12 +859,34 @@ end
class TEX
+ def timedrun(delay, &block)
+ delay = delay.to_i rescue 0
+ if delay > 0 then
+ begin
+ report("job started with timeout '#{delay}'")
+ timeout(delay) do
+ yield block
+ end
+ rescue TimeoutError
+ report("job aborted due to timeout '#{delay}'")
+ rescue
+ report("job aborted due to error")
+ else
+ report("job finished within timeout '#{delay}'")
+ end
+ else
+ yield block
+ end
+ end
+
def processtex # much to do: mp, xml, runs etc
setvariable('texformats',[getvariable('interface')]) unless getvariable('interface').empty?
getarrayvariable('files').each do |filename|
setvariable('filename',filename)
report("processing document '#{filename}'")
- processfile
+ timedrun(getvariable('timeout')) do
+ processfile
+ end
end
reportruntime
end
diff --git a/scripts/context/ruby/base/texutil.rb b/scripts/context/ruby/base/texutil.rb
index 86de0ee91..5e935501b 100644
--- a/scripts/context/ruby/base/texutil.rb
+++ b/scripts/context/ruby/base/texutil.rb
@@ -226,9 +226,11 @@ class TeXUtil
def remap(str)
s = str.dup
- s.gsub!(/(\d+)/o) do
- $1.rjust(10,'a') # rest is b .. k
- end
+if true then # numbers are treated special
+ s.gsub!(/(\d+)/o) do
+ $1.rjust(10,'a') # rest is b .. k
+ end
+end
if @rexa then
s.gsub!(@rexa) do
@rep[$1.escaped]
@@ -237,9 +239,9 @@ class TeXUtil
if @rexb then
s.gsub!(@rexb) do
token = $1.sub(/\\/o, '')
-if @@downcase then
- token.downcase!
-end
+ if @@downcase then
+ token.downcase!
+ end
if @exp.key?(token) then
@exp[token].ljust(@max,' ')
elsif @map.key?(token) then
@@ -257,8 +259,7 @@ end
'A'.upto('Z') do |c| expander(c) ; division(c) end
expander('1','b') ; expander('2','c') ; expander('3','e') ; expander('4','f')
expander('5','g') ; expander('6','h') ; expander('7','i') ; expander('8','i')
- expander('9','j') ; expander('0','a') ; expander('-',"-") ;
- # end potential move
+ expander('9','j') ; expander('0','a') ; expander('-','-') ;
shortcuts.each do |s| shortcut(s[0],s[1]) end
expansions.each do |e| expander(e[0],e[1]) end
reductions.each do |r| reducer(r[0],r[1]) end
@@ -452,7 +453,7 @@ end
attr_writer :sortkey
def build(sorter)
-@sortkey = sorter.normalize(sorter.tokenize(@sortkey))
+ @sortkey = sorter.normalize(sorter.tokenize(@sortkey))
@sortkey = sorter.remap(sorter.simplify(@key.downcase))
if @sortkey.empty? then
@sortkey = sorter.remap(@command.downcase)
@@ -543,7 +544,7 @@ end
attr_writer :sortkey
def build(sorter)
-@entry, @key = sorter.normalize(@entry), sorter.normalize(sorter.tokenize(@key))
+ @entry, @key = sorter.normalize(@entry), sorter.normalize(sorter.tokenize(@key))
if false then
@entry, @key = [@entry, @key].collect do |target|
# +a+b+c &a&b&c a+b+c a&b&c
@@ -560,7 +561,7 @@ if false then
# end
end
else
- @entry, @key = cleanupsplit(@entry), cleanupsplit(@key)
+ @entry, @key = cleanupsplit(@entry), cleanupsplit(@key)
end
@sortkey = sorter.simplify(@key)
@sortkey = @sortkey.split(@@split).collect do |c| sorter.remap(c) end.join(@@split)