diff options
Diffstat (limited to 'Master/texmf-dist/scripts/context/ruby/base/switch.rb')
-rw-r--r-- | Master/texmf-dist/scripts/context/ruby/base/switch.rb | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/Master/texmf-dist/scripts/context/ruby/base/switch.rb b/Master/texmf-dist/scripts/context/ruby/base/switch.rb index 64d518bd42f..5187a795f03 100644 --- a/Master/texmf-dist/scripts/context/ruby/base/switch.rb +++ b/Master/texmf-dist/scripts/context/ruby/base/switch.rb @@ -33,12 +33,18 @@ end class File + @@update_eps = 1 + def File.needsupdate(oldname,newname) begin - if $mswindows then - return File.stat(oldname).mtime > File.stat(newname).mtime + oldtime = File.stat(oldname).mtime.to_i + newtime = File.stat(newname).mtime.to_i + if newtime >= oldtime then + return false + elsif oldtime-newtime < @@update_eps then + return false else - return File.stat(oldname).mtime != File.stat(newname).mtime + return true end rescue return true @@ -46,11 +52,12 @@ class File end def File.syncmtimes(oldname,newname) + return begin if $mswindows then - # does not work (yet) - t = File.mtime(oldname) # i'm not sure if the time is frozen, so we do it here - File.utime(0,t,oldname,newname) + # does not work (yet) / gives future timestamp + # t = File.mtime(oldname) # i'm not sure if the time is frozen, so we do it here + # File.utime(0,t,oldname,newname) else t = File.mtime(oldname) # i'm not sure if the time is frozen, so we do it here File.utime(0,t,oldname,newname) @@ -493,15 +500,21 @@ class CommandLine unless foundkey then @registered.each do |option, shortcut, kind| n = 0 - if option =~ /^#{key}/i then - case n - when 0 - foundkey, foundkind = option, kind - n = 1 - when 1 - # ambiguous matches, like --fix => --fixme --fixyou - foundkey, foundkind = nil, nil - break + begin + re = /^#{key}/i + rescue + key = key.inspect.sub(/^\"(.*)\"$/) do $1 end + re = /^#{key}/i + ensure + if option =~ re then + case n + when 0 + foundkey, foundkind, n = option, kind, 1 + when 1 + # ambiguous matches, like --fix => --fixme --fixyou + foundkey, foundkind = nil, nil + break + end end end end |