diff options
author | Hans Hagen <pragma@wxs.nl> | 2006-06-07 23:34:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2006-06-07 23:34:00 +0200 |
commit | 6e2bc6fac8b9a5b4d29155b13d40c08c5868cd13 (patch) | |
tree | f036819fa39766a8b2b9f13fe21fa3be87de5b00 /scripts | |
parent | b961771c7114a8181029ad495bded7872687307e (diff) | |
download | context-6e2bc6fac8b9a5b4d29155b13d40c08c5868cd13.tar.gz |
stable 2006.06.07 23:34
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/context/ruby/base/tex.rb | 9 | ||||
-rw-r--r-- | scripts/context/ruby/base/texutil.rb | 72 | ||||
-rw-r--r-- | scripts/context/ruby/ctxtools.rb | 1 | ||||
-rw-r--r-- | scripts/context/ruby/texexec.rb | 6 | ||||
-rw-r--r-- | scripts/context/ruby/texmfstart.rb | 35 | ||||
-rw-r--r-- | scripts/context/ruby/textools.rb | 1 | ||||
-rwxr-xr-x | scripts/context/stubs/mswin/rlxtools.bat | 2 | ||||
-rwxr-xr-x | scripts/context/stubs/unix/rlxtools | 2 |
8 files changed, 96 insertions, 32 deletions
diff --git a/scripts/context/ruby/base/tex.rb b/scripts/context/ruby/base/tex.rb index 61d857d19..16544c420 100644 --- a/scripts/context/ruby/base/tex.rb +++ b/scripts/context/ruby/base/tex.rb @@ -139,10 +139,11 @@ class TEX ['cont-en','cont-nl','cont-de','cont-it', 'cont-fr','cont-cz','cont-ro','cont-uk'] .each do |f| @@texprocstr[f] = "\\emergencyend" end - # @@runoptions['xetex'] = ['--output-driver \\\"-d 4 -V 5\\\"'] # we need the pos pass - @@runoptions['xetex'] = ['--no-pdf'] # from now on we assume (x)dvipdfmx to be used - - # @@runoptions['luatex'] = ['--progname=pdftex'] + # @@runoptions['xetex'] = ['--output-driver \\\"-d 4 -V 5\\\"'] # we need the pos pass + @@runoptions['xetex'] = ['--8bit --no-pdf'] # from now on we assume (x)dvipdfmx to be used + @@runoptions['pdfetex'] = ['--8bit'] + @@runoptions['luatex'] = ['--8bit'] + @@runoptions['aleph'] = ['--8bit'] @@booleanvars = [ 'batchmode', 'nonstopmode', 'fast', 'fastdisabled', 'silentmode', 'final', diff --git a/scripts/context/ruby/base/texutil.rb b/scripts/context/ruby/base/texutil.rb index 89f5e5385..7b3e957e3 100644 --- a/scripts/context/ruby/base/texutil.rb +++ b/scripts/context/ruby/base/texutil.rb @@ -230,7 +230,8 @@ class TeXUtil end def normalize(str) - replace(str).gsub(/ +/,' ') + # replace(str).gsub(/ +/,' ') + replace(str).gsub(/\s\s+/," \\space") end def tokenize(str) @@ -267,16 +268,16 @@ class TeXUtil s end - def preset(shortcuts=[],expansions=[],reductions=[],divisions=[]) + def preset(shortcuts=[],expansions=[],reductions=[],divisions=[],language='') 'a'.upto('z') do |c| expander(c) ; division(c) 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('-','-') ; - 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 - divisions.each do |d| division(d[0],d[1]) end + shortcuts.each do |s| shortcut(s[1],s[2]) if s[0] == '' || s[0] == language end + expansions.each do |e| expander(e[1],e[2]) if e[0] == '' || e[0] == language end + reductions.each do |r| reducer(r[1],r[2]) if r[0] == '' || r[0] == language end + divisions.each do |d| division(d[1],d[2]) if d[0] == '' || d[0] == language end end def simplify(str) @@ -490,16 +491,23 @@ class TeXUtil end - @@synonyms = Hash.new + @@synonyms = Hash.new + @@sorter = Hash.new + @@languages = Hash.new def MySynonyms::reset(logger) - @@synonyms = Hash.new + @@synonyms = Hash.new + @@sorter = Hash.new + @@languages = Hash.new end def MySynonyms::reader(logger,data) - if data[0] == 'e' then - @@synonyms[data[1]] = Array.new unless @@synonyms.key?(data[1]) - @@synonyms[data[1]].push(Synonym.new(data[1],data[2],data[3],data[4])) + case data[0] + when 'e' then + @@synonyms[data[1]] = Array.new unless @@synonyms.key?(data[1]) + @@synonyms[data[1]].push(Synonym.new(data[1],data[2],data[3],data[4])) + when 'l' then + @@languages[data[1]] = data[2] || '' end end @@ -513,12 +521,17 @@ class TeXUtil end def MySynonyms::processor(logger) - sorter = Sorter.new - sorter.preset(eval("MyKeys").shortcuts,eval("MyKeys").expansions,eval("MyKeys").reductions,eval("MyKeys").divisions) - sorter.prepare @@synonyms.keys.each do |s| + @@sorter[s] = Sorter.new + @@sorter[s].preset( + eval("MyKeys").shortcuts, + eval("MyKeys").expansions, + eval("MyKeys").reductions, + eval("MyKeys").divisions, + @@languages[s] || '') + @@sorter[s].prepare @@synonyms[s].each_index do |i| - @@synonyms[s][i].build(sorter) + @@synonyms[s][i].build(@@sorter[s]) end @@synonyms[s] = @@synonyms[s].sort end @@ -550,6 +563,7 @@ class TeXUtil @key = @entry.dup if @key.empty? @sortkey = @key.dup @nofentries, @nofpages = 0, 0 + @normalizeentry = false end attr_reader :state, :type, :location, :key, :entry, :seetoo, :page, :realpage, :texthowto, :pagehowto @@ -557,7 +571,9 @@ class TeXUtil 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)) + @entry = sorter.normalize(sorter.tokenize(@entry)) if @normalizeentry + @key = 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 @@ -738,11 +754,13 @@ end end @@registers = Hash.new - @@sorter = Sorter.new + @@sorter = Hash.new + @@languages = Hash.new def MyRegisters::reset(logger) @@registers = Hash.new - @@sorter = Sorter.new + @@sorter = Hash.new + @@languages = Hash.new end def MyRegisters::reader(logger,data) @@ -759,6 +777,8 @@ end when 's' then @@registers[data[1]] = Array.new unless @@registers.key?(data[1]) @@registers[data[1]].push(Register.new(4,data[1],data[2],data[3],data[4],data[5],data[6],nil)) + when 'l' then + @@languages[data[1]] = data[2] || '' end end @@ -766,18 +786,24 @@ end if @@registers.size > 0 then @@registers.keys.sort.each do |s| handle << logger.banner("registers: #{s} #{@@registers[s].size}") - Register.flush(@@registers[s],handle,@@sorter) + Register.flush(@@registers[s],handle,@@sorter[s]) # report("register #{@@registers[s].class}: #{@@registers[s].@nofentries} entries and #{@@registers[s].@nofpages} pages") end end end def MyRegisters::processor(logger) - @@sorter.preset(eval("MyKeys").shortcuts,eval("MyKeys").expansions,eval("MyKeys").reductions,eval("MyKeys").divisions) - @@sorter.prepare @@registers.keys.each do |s| + @@sorter[s] = Sorter.new + @@sorter[s].preset( + eval("MyKeys").shortcuts, + eval("MyKeys").expansions, + eval("MyKeys").reductions, + eval("MyKeys").divisions, + @@languages[s] || '') + @@sorter[s].prepare @@registers[s].each_index do |i| - @@registers[s][i].build(@@sorter) + @@registers[s][i].build(@@sorter[s]) end @@registers[s] = @@registers[s].sort end @@ -861,7 +887,7 @@ end def MyKeys::reader(logger,data) key = data.shift - grp = data.shift # language code, todo + # grp = data.shift # language code, todo case key when 's' then @@shortcuts.push(data) when 'e' then @@expansions.push(data) diff --git a/scripts/context/ruby/ctxtools.rb b/scripts/context/ruby/ctxtools.rb index 69c6885b4..5686468f1 100644 --- a/scripts/context/ruby/ctxtools.rb +++ b/scripts/context/ruby/ctxtools.rb @@ -529,6 +529,7 @@ class Commands "tui", "tup", "ted", "tes", "top", "log", "tmp", "run", "bck", "rlg", "mpt", "mpx", "mpd", "mpo", "ctl", + "tmp.md5", "tmp.out" ] $texonlysuffixes = [ "dvi", "ps", "pdf" diff --git a/scripts/context/ruby/texexec.rb b/scripts/context/ruby/texexec.rb index b74b6c793..3dab3e9ce 100644 --- a/scripts/context/ruby/texexec.rb +++ b/scripts/context/ruby/texexec.rb @@ -137,7 +137,8 @@ class Commands files = @commandline.arguments.sort if files.length > 0 then if f = File.open(job.tempfilename('tex'),'w') then - job.runtexutil(files,"--figures", true) + # will be replaced + Kpse.runscript('texutil',files.join(' '),'--figures') figures = @commandline.checkedoption('method', 'a').downcase paperoffset = @commandline.checkedoption('paperoffset', '0pt') backspace = @commandline.checkedoption('backspace', '1.5cm') @@ -194,8 +195,7 @@ class Commands fnames.each do |ffname| if msuffixes.include?(File.splitname(ffname)[1]) && FileTest.file?(ffname) then if mod = File.open(job.tempfilename('tex'),'w') then - # will become a call to ctxtools - job.runtexutil(ffname,"--documents", true) + Kpse.runscript('ctxtools',ffname,'--document') if ted = File.silentopen(File.suffixed(ffname,'ted')) then firstline = ted.gets if firstline =~ /interface=/o then diff --git a/scripts/context/ruby/texmfstart.rb b/scripts/context/ruby/texmfstart.rb index e1d688f67..66bab6261 100644 --- a/scripts/context/ruby/texmfstart.rb +++ b/scripts/context/ruby/texmfstart.rb @@ -23,6 +23,7 @@ # --locate => provides location # --exec => exec instead of system # --iftouched=a,b => only if timestamp a<>b +# --ifchanged=a,b => only if checksum changed # # file: path: bin: @@ -35,6 +36,7 @@ $ownpath = File.expand_path(File.dirname($0)) unless defined? $ownpath $: << $ownpath require "rbconfig" +require "md5" # kpse_merge_done: require 'base/kpseremote' # kpse_merge_done: require 'base/kpsedirect' @@ -1494,6 +1496,7 @@ $makelist = [ 'tmftools', 'exatools', 'runtools', + 'rlxtools', # # no, 'texmfstart' ] @@ -2107,7 +2110,7 @@ end def run(fullname) if ! fullname || fullname.empty? then - report("the file '#{$filename}' is not found") + output("the file '#{$filename}' is not found") elsif FileTest.file?(fullname) then begin case fullname @@ -2222,6 +2225,35 @@ def process(&block) else report("file #{oldname} is untouched") end + elsif $ifchanged then + filename = $directives['ifchanged'] + checkname = filename + ".md5" + oldchecksum, newchecksum = "old", "new" + begin + newchecksum = MD5.new(IO.read(filename)).hexdigest.upcase + rescue + newchecksum = "new" + else + begin + oldchecksum = IO.read(checkname).chomp + rescue + oldchecksum = "old" + end + end + if oldchecksum != newchecksum then + report("old checksum #{filename}: #{oldchecksum}") + report("new checksum #{filename}: #{newchecksum}") + report("file is changed, processing started") + begin + File.open(checkname,'w') do |f| + f << newchecksum + end + rescue + end + yield + else + report("file #{filename} is unchanged") + end else yield end @@ -2370,6 +2402,7 @@ def execute(arguments) $after = $directives['after'] || '' $iftouched = $directives['iftouched'] || false + $ifchanged = $directives['ifchanged'] || false $openoffice = $directives['oo'] || false diff --git a/scripts/context/ruby/textools.rb b/scripts/context/ruby/textools.rb index 3c257b7db..993388347 100644 --- a/scripts/context/ruby/textools.rb +++ b/scripts/context/ruby/textools.rb @@ -98,7 +98,6 @@ class Commands end end - end class Commands diff --git a/scripts/context/stubs/mswin/rlxtools.bat b/scripts/context/stubs/mswin/rlxtools.bat new file mode 100755 index 000000000..b78dec13b --- /dev/null +++ b/scripts/context/stubs/mswin/rlxtools.bat @@ -0,0 +1,2 @@ +@echo off +texmfstart rlxtools.rb %* diff --git a/scripts/context/stubs/unix/rlxtools b/scripts/context/stubs/unix/rlxtools new file mode 100755 index 000000000..6cd5db89f --- /dev/null +++ b/scripts/context/stubs/unix/rlxtools @@ -0,0 +1,2 @@ +#!/bin/sh +texmfstart rlxtools.rb $@ |