summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/perl/texexec.pl9
-rw-r--r--scripts/context/ruby/textools.rb103
-rw-r--r--scripts/context/ruby/xmltools.rb9
-rw-r--r--scripts/context/ruby/xmpl/switch.rb11
4 files changed, 113 insertions, 19 deletions
diff --git a/scripts/context/perl/texexec.pl b/scripts/context/perl/texexec.pl
index 05cd18358..1693094ea 100644
--- a/scripts/context/perl/texexec.pl
+++ b/scripts/context/perl/texexec.pl
@@ -1306,6 +1306,7 @@ sub ScanContent {
my ($ConTeXtInput) = @_;
open( TEX, $ConTeXtInput );
while (<TEX>) {
+ next if (/^\%/) ;
if (
/\\(starttekst|stoptekst|startonderdeel|startdocument|startoverzicht)/
)
@@ -1692,6 +1693,8 @@ if ($JobSuffix =~ /\_fo$/i) {
if ($class eq 'job') {
if ($key eq 'stylefile') {
print TMP "\\environment $value\n" ;
+ } elsif ($key eq 'module') {
+ print TMP "\\usemodule[$value]\n" ;
} elsif ($key eq 'interface') {
$ConTeXtInterface = $value ;
}
@@ -1834,9 +1837,9 @@ if ($JobSuffix =~ /\_fo$/i) {
}
if (($dosish) && (!$Problems) && ($PdfOpen)) {
if ($Result ne '') {
- system("pdfopen --file $Result.pdf")
+ system("pdfopen --file $Result.pdf") if -f "$Result.pdf"
} else {
- system("pdfopen --file $JobName.pdf")
+ system("pdfopen --file $JobName.pdf") if -f "$JobName.pdf"
}
}
}
@@ -2218,7 +2221,7 @@ sub RunOneFormat {
}
if ($Problems) {
$Problems = 0;
- if ( $TeXExecutable =~ /etex|eetex|pdfetex|pdfeetex|pdfxtex|xpdfetex|eomega|aleph/io ) {
+ if ( $TeXExecutable =~ /etex|eetex|pdfetex|pdfeetex|pdfxtex|xpdfetex|eomega|aleph|xetex/io ) {
$TeXPrefix = "*";
}
my $CurrentPath = cwd();
diff --git a/scripts/context/ruby/textools.rb b/scripts/context/ruby/textools.rb
index 1c7e4c926..d8928099c 100644
--- a/scripts/context/ruby/textools.rb
+++ b/scripts/context/ruby/textools.rb
@@ -121,13 +121,14 @@ class Commands
report
used = kpsefile(filename) || pathfile(filename)
if paths = texmfroots then
- found = false
+ found, prefered = false, false
paths.each do |p|
if files = texmffiles(p,filename) then
found = true
files.each do |f|
# unreadable: report("#{if f == used then '>' else '.' end} #{f}")
if f == used then
+ prefered = true
report("> #{f}")
else
report(". #{f}")
@@ -135,7 +136,11 @@ class Commands
end
end
end
- report("! #{used}") unless found
+ if prefered then
+ report("! #{used}") unless found
+ else
+ report("> #{used}")
+ end
elsif used then
report("? #{used}")
else
@@ -457,8 +462,79 @@ class Commands
return used
end
+ def touchcontextfile
+ maincontextfile = 'context.tex'
+ unless FileTest.file?(maincontextfile) then
+ begin
+ maincontextfile = `kpsewhich -progname=context #{maincontextfile}`.chomp
+ rescue
+ maincontextfile = ''
+ end
+ end
+ touchfile(maincontextfile) unless maincontextfile.empty?
+ end
+
+ def downcasefilenames
+ if @commandline.option('recurse') then
+ files = Dir.glob('**/*')
+ else
+ files = Dir.glob('*')
+ end
+ if files && files.length>0 then
+ files.each do |oldname|
+ if FileTest.file?(oldname) then
+ newname = oldname.downcase
+ if oldname != newname then
+ begin
+ File.rename(oldname,newname)
+ rescue
+ report("#{oldname} == #{oldname}\n")
+ else
+ report("#{oldname} => #{newname}\n")
+ end
+ end
+ end
+ end
+ end
+ end
+
private # specific
+ def touchfile(filename)
+
+ if FileTest.file?(filename) then
+ if data = IO.read(filename) then
+ timestamp = Time.now.strftime('%Y.%m.%d')
+ begin
+ data.gsub!(/\\contextversion\{(\d+)\.(\d+)\.(\d+)\}/) do
+ "\\contextversion{#{timestamp}}"
+ end
+ rescue
+ else
+ begin
+ File.delete(filename+'.old')
+ rescue
+ end
+ begin
+ File.copy(filename,filename+'.old')
+ rescue
+ end
+ begin
+ if f = File.open(filename,'w') then
+ f.puts(data)
+ f.close
+ end
+ rescue
+ end
+ end
+ report("#{filename} is touched as #{timestamp}")
+ end
+ else
+ report("#{filename} is not found")
+ end
+
+ end
+
def movefiles(from_path,to_path,suffix,&block)
obsolete = 'obsolete'
force = @commandline.option('force')
@@ -566,16 +642,19 @@ end
logger = EXA::ExaLogger.new(banner.shift)
commandline = CommandLine.new
-commandline.registeraction('removemapnames' , '[pattern] [--recurse]')
-commandline.registeraction('restoremapnames', '[pattern] [--recurse]')
-commandline.registeraction('hidemapnames' , '[pattern] [--recurse]')
-commandline.registeraction('videmapnames' , '[pattern] [--recurse]')
-commandline.registeraction('findfile' , 'filename [--recurse]')
-commandline.registeraction('unzipfiles' , '[pattern] [--recurse]')
-commandline.registeraction('fixafmfiles' , '[pattern] [--recurse]')
-commandline.registeraction('mactodos' , '[pattern] [--recurse]')
-commandline.registeraction('fixtexmftrees' , '[texmfroot] [--force]')
-commandline.registeraction('replace' , 'filename [--force]')
+commandline.registeraction('touchcontextfile', '') # private
+commandline.registeraction('downcasefilenames', '') # private
+
+commandline.registeraction('removemapnames' , '[pattern] [--recurse]')
+commandline.registeraction('restoremapnames' , '[pattern] [--recurse]')
+commandline.registeraction('hidemapnames' , '[pattern] [--recurse]')
+commandline.registeraction('videmapnames' , '[pattern] [--recurse]')
+commandline.registeraction('findfile' , 'filename [--recurse]')
+commandline.registeraction('unzipfiles' , '[pattern] [--recurse]')
+commandline.registeraction('fixafmfiles' , '[pattern] [--recurse]')
+commandline.registeraction('mactodos' , '[pattern] [--recurse]')
+commandline.registeraction('fixtexmftrees' , '[texmfroot] [--force]')
+commandline.registeraction('replace' , 'filename [--force]')
commandline.registeraction('help')
commandline.registeraction('version')
diff --git a/scripts/context/ruby/xmltools.rb b/scripts/context/ruby/xmltools.rb
index 05dd93ba3..b92f159e3 100644
--- a/scripts/context/ruby/xmltools.rb
+++ b/scripts/context/ruby/xmltools.rb
@@ -91,8 +91,13 @@ class Commands
output.xputs("<file name='#{bn}'>\n", 4)
end
output.xputs("<base>#{bn.sub(/\..*$/,'')}</base>\n", 6)
- output.xputs("<type>#{bn.sub(/^.*\./,'')}</type>\n", 6)
- output.xputs("<size>#{File.stat(f).size}</size>\n", 6)
+ if File.stat(f).file? then
+ bt = bn.sub(/^.*\./,'')
+ if bt != bn then
+ output.xputs("<type>#{bt}</type>\n", 6)
+ end
+ output.xputs("<size>#{File.stat(f).size}</size>\n", 6)
+ end
output.xputs("<date>#{File.stat(f).mtime.strftime("%Y-%m-%d %H:%M")}</date>\n", 6)
output.xputs("</file>\n", 4)
end
diff --git a/scripts/context/ruby/xmpl/switch.rb b/scripts/context/ruby/xmpl/switch.rb
index 9c38cdbdd..c0fd1d624 100644
--- a/scripts/context/ruby/xmpl/switch.rb
+++ b/scripts/context/ruby/xmpl/switch.rb
@@ -115,7 +115,14 @@ module CommandBase
files = Array.new
pattern.split(' ').each do |p|
- p = '**/' + p if recurse
+ if recurse then
+ if p =~ /^(.*)(\/.*?)$/i then
+ p = $1 + '/**' + $2
+ else
+ p = '**/' + p
+ end
+ p.gsub!(/[\\\/]+/, '/')
+ end
files.push(Dir.glob(p))
end
files.flatten.sort do |a,b|
@@ -463,4 +470,4 @@ end
# end
#
# c.showhelp("you can provide:\n\n")
-# c.showmandate("you also need to provide:\n\n") \ No newline at end of file
+# c.showmandate("you also need to provide:\n\n")