~reviczky/context/mirror

« back to all changes in this revision

Viewing changes to scripts/context/stubs/win64/mtxrun.lua

  • Committer: Context Git Mirror Bot
  • Author(s): Hans Hagen
  • Date: 2019-11-25 22:15:50 UTC
  • Revision ID: git-v1:7ecbcaaf68d152851591dbb5931a6eb15d155019
2019-11-25 17:37:00

Show diffs side-by-side

added added

removed removed

Lines of Context:
324
324
 
325
325
package.loaded["l-macro"] = package.loaded["l-macro"] or true
326
326
 
 
327
-- original size: 10130, stripped down to: 5990
327
328
 
328
329
if not modules then modules={} end modules ['l-macros']={
329
330
 version=1.001,
549
549
macros.loaded=loaded
550
550
function required(name,trace)
551
551
 local filename=file.addsuffix(name,"lua")
552
 
 local fullname=resolvers and resolvers.find_file(filename) or filename
 
552
 local fullname=resolvers and resolvers.findfile(filename) or filename
553
553
 if not fullname or fullname=="" then
554
554
  return false
555
555
 end
12608
12608
 
12609
12609
package.loaded["trac-set"] = package.loaded["trac-set"] or true
12610
12610
 
 
12611
-- original size: 13394, stripped down to: 8882
12611
12612
 
12612
12613
if not modules then modules={} end modules ['trac-set']={ 
12613
12614
 version=1.001,
12618
12618
 license="see context related readme files"
12619
12619
}
12620
12620
local type,next,tostring,tonumber=type,next,tostring,tonumber
 
12621
local print=print
12621
12622
local concat,sortedhash=table.concat,table.sortedhash
12622
 
local format,find,lower,gsub,topattern=string.format,string.find,string.lower,string.gsub,string.topattern
 
12623
local formatters,find,lower,gsub,topattern=string.formatters,string.find,string.lower,string.gsub,string.topattern
12623
12624
local is_boolean=string.is_boolean
12624
12625
local settings_to_hash=utilities.parsers.settings_to_hash
12625
12626
local allocate=utilities.storage.allocate
12826
12827
 end
12827
12828
end
12828
12829
local enable,disable,register,list,show=setters.enable,setters.disable,setters.register,setters.list,setters.show
12829
 
function setters.report(setter,...)
12830
 
 print(format("%-15s : %s\n",setter.name,format(...)))
 
12830
function setters.report(setter,fmt,...)
 
12831
 print(formatters["%-15s : %s\n"](setter.name,formatters[fmt](...)))
12831
12832
end
12832
12833
local function default(setter,name)
12833
12834
 local d=setter.data[name]
12950
12951
 
12951
12952
package.loaded["trac-log"] = package.loaded["trac-log"] or true
12952
12953
 
 
12954
-- original size: 32997, stripped down to: 21715
12953
12955
 
12954
12956
if not modules then modules={} end modules ['trac-log']={
12955
12957
 version=1.001,
13613
13614
local nesting=0
13614
13615
local verbose=false
13615
13616
local hasscheme=url.hasscheme
13616
 
function logs.show_open(name)
13617
 
end
13618
 
function logs.show_close(name)
13619
 
end
13620
 
function logs.show_load(name)
13621
 
end
13622
13617
local simple=logs.reporter("comment")
13623
13618
logs.simple=simple
13624
13619
logs.simpleline=simple
20686
20681
 
20687
20682
package.loaded["data-ini"] = package.loaded["data-ini"] or true
20688
20683
 
 
20684
-- original size: 11019, stripped down to: 7086
20689
20685
 
20690
20686
if not modules then modules={} end modules ['data-ini']={
20691
20687
 version=1.001,
20699
20694
local gsub,find,gmatch,char=string.gsub,string.find,string.gmatch,string.char
20700
20695
local filedirname,filebasename,filejoin=file.dirname,file.basename,file.join
20701
20696
local ostype,osname,osuname,ossetenv,osgetenv=os.type,os.name,os.uname,os.setenv,os.getenv
 
20697
local sortedpairs=table.sortedpairs
20702
20698
local P,S,R,C,Cs,Cc,lpegmatch=lpeg.P,lpeg.S,lpeg.R,lpeg.C,lpeg.Cs,lpeg.Cc,lpeg.match
20703
20699
local trace_locating=false  trackers.register("resolvers.locating",function(v) trace_locating=v end)
20704
20700
local trace_expansions=false  trackers.register("resolvers.expansions",function(v) trace_expansions=v end)
20909
20905
   rawset(t,k,v)
20910
20906
  end
20911
20907
  local colon=P(":")
20912
 
  for k,v in table.sortedpairs(prefixes) do
 
20908
  for k,v in sortedpairs(prefixes) do
20913
20909
   if p then
20914
20910
    p=P(k)+p
20915
20911
   else
20936
20932
 
20937
20933
package.loaded["data-exp"] = package.loaded["data-exp"] or true
20938
20934
 
 
20935
-- original size: 18173, stripped down to: 10432
20939
20936
 
20940
20937
if not modules then modules={} end modules ['data-exp']={
20941
20938
 version=1.001,
21220
21216
 scancache[sub(full,1,-2)]=files
21221
21217
 return files,remap,n,m,r
21222
21218
end
21223
 
function resolvers.scanfiles(path,branch,usecache,onlyonce,tolerant)
 
21219
local function scanfiles(path,branch,usecache,onlyonce,tolerant)
21224
21220
 local realpath=resolveprefix(path)
21225
21221
 if usecache then
21226
21222
  local content=fullcache[realpath]
21275
21271
 statistics.stoptiming(timer)
21276
21272
 return content
21277
21273
end
 
21274
resolvers.scanfiles=scanfiles
21278
21275
function resolvers.simplescanfiles(path,branch,usecache)
21279
 
 return resolvers.scanfiles(path,branch,usecache,true,true) 
 
21276
 return scanfiles(path,branch,usecache,true,true) 
21280
21277
end
21281
21278
function resolvers.scandata()
21282
21279
 table.sort(scanned)
21343
21340
 
21344
21341
package.loaded["data-env"] = package.loaded["data-env"] or true
21345
21342
 
 
21343
-- original size: 9400, stripped down to: 6347
21346
21344
 
21347
21345
if not modules then modules={} end modules ['data-env']={
21348
21346
 version=1.001,
21353
21350
 license="see context related readme files",
21354
21351
}
21355
21352
local lower,gsub=string.lower,string.gsub
21356
 
local next=next
 
21353
local next,rawget=next,rawget
21357
21354
local resolvers=resolvers
21358
21355
local allocate=utilities.storage.allocate
21359
21356
local setmetatableindex=table.setmetatableindex
21628
21625
 
21629
21626
package.loaded["data-tmp"] = package.loaded["data-tmp"] or true
21630
21627
 
 
21628
-- original size: 16070, stripped down to: 11353
21631
21629
 
21632
21630
if not modules then modules={} end modules ['data-tmp']={
21633
21631
 version=1.100,
21637
21634
 copyright="PRAGMA ADE / ConTeXt Development Team",
21638
21635
 license="see context related readme files"
21639
21636
}
21640
 
local format,lower,gsub,concat=string.format,string.lower,string.gsub,table.concat
21641
 
local concat=table.concat
21642
 
local mkdirs,isdir,isfile=dir.mkdirs,lfs.isdir,lfs.isfile
21643
 
local addsuffix,is_writable,is_readable=file.addsuffix,file.is_writable,file.is_readable
 
21637
local next,type=next,type
 
21638
local pcall,loadfile,collectgarbage=pcall,loadfile,collectgarbage
 
21639
local format,lower,gsub=string.format,string.lower,string.gsub
 
21640
local concat,serialize,fastserialize,serializetofile=table.concat,table.serialize,table.fastserialize,table.tofile
 
21641
local mkdirs,expanddirname,isdir,isfile=dir.mkdirs,dir.expandname,lfs.isdir,lfs.isfile
 
21642
local is_writable,is_readable=file.is_writable,file.is_readable
 
21643
local collapsepath,joinfile,addsuffix,dirname=file.collapsepath,file.join,file.addsuffix,file.dirname
 
21644
local savedata=file.savedata
21644
21645
local formatters=string.formatters
21645
 
local next,type=next,type
 
21646
local osexit,osdate,osuuid=os.exit,os.date,os.uuid
 
21647
local removefile=os.remove
 
21648
local md5hex=md5.hex
21646
21649
local trace_locating=false  trackers.register("resolvers.locating",function(v) trace_locating=v end)
21647
21650
local trace_cache=false  trackers.register("resolvers.cache",function(v) trace_cache=v end)
21648
21651
local report_caches=logs.reporter("resolvers","caches")
21649
21652
local report_resolvers=logs.reporter("resolvers","caching")
21650
21653
local resolvers=resolvers
21651
21654
local cleanpath=resolvers.cleanpath
21652
 
local directive_cleanup=false  directives.register("system.compile.cleanup",function(v) directive_cleanup=v end)
21653
 
local directive_strip=false  directives.register("system.compile.strip",function(v) directive_strip=v end)
21654
 
local compile=utilities.lua.compile
21655
 
function utilities.lua.compile(luafile,lucfile,cleanup,strip)
21656
 
 if cleanup==nil then cleanup=directive_cleanup end
21657
 
 if strip==nil then strip=directive_strip   end
21658
 
 return compile(luafile,lucfile,cleanup,strip)
 
21655
local resolvepath=resolvers.resolve
 
21656
local luautilities=utilities.lua
 
21657
do
 
21658
 local directive_cleanup=false  directives.register("system.compile.cleanup",function(v) directive_cleanup=v end)
 
21659
 local directive_strip=false  directives.register("system.compile.strip",function(v) directive_strip=v end)
 
21660
 local compilelua=luautilities.compile
 
21661
 function luautilities.compile(luafile,lucfile,cleanup,strip)
 
21662
  if cleanup==nil then cleanup=directive_cleanup end
 
21663
  if strip==nil then strip=directive_strip   end
 
21664
  return compilelua(luafile,lucfile,cleanup,strip)
 
21665
 end
21659
21666
end
21660
21667
caches=caches or {}
21661
21668
local caches=caches
21662
 
local luasuffixes=utilities.lua.suffixes
21663
 
caches.base=caches.base or "luatex-cache"
21664
 
caches.more=caches.more or "context"
21665
 
caches.direct=false 
21666
 
caches.tree=false
21667
 
caches.force=true
21668
 
caches.ask=false
21669
 
caches.relocate=false
 
21669
local writable=nil
 
21670
local readables={}
 
21671
local usedreadables={}
 
21672
local compilelua=luautilities.compile
 
21673
local luasuffixes=luautilities.suffixes
 
21674
caches.base=caches.base or "luatex-cache"  
 
21675
caches.more=caches.more or "context"    
21670
21676
caches.defaults={ "TMPDIR","TEMPDIR","TMP","TEMP","HOME","HOMEPATH" }
21671
 
directives.register("system.caches.fast",function(v) caches.fast=true end)
21672
 
directives.register("system.caches.direct",function(v) caches.direct=true end)
21673
 
local writable,readables,usedreadables=nil,{},{}
 
21677
local direct_cache=false 
 
21678
local fast_cache=false
 
21679
local cache_tree=false
 
21680
directives.register("system.caches.direct",function(v) direct_cache=true end)
 
21681
directives.register("system.caches.fast",function(v) fast_cache=true end)
 
21682
local function configfiles()
 
21683
 return concat(resolvers.configurationfiles(),";")
 
21684
end
 
21685
local function hashed(tree)
 
21686
 tree=gsub(tree,"[\\/]+$","")
 
21687
 tree=lower(tree)
 
21688
 local hash=md5hex(tree)
 
21689
 if trace_cache or trace_locating then
 
21690
  report_caches("hashing tree %a, hash %a",tree,hash)
 
21691
 end
 
21692
 return hash
 
21693
end
 
21694
local function treehash()
 
21695
 local tree=configfiles()
 
21696
 if not tree or tree=="" then
 
21697
  return false
 
21698
 else
 
21699
  return hashed(tree)
 
21700
 end
 
21701
end
 
21702
caches.hashed=hashed
 
21703
caches.treehash=treehash
 
21704
caches.configfiles=configfiles
21674
21705
local function identify()
21675
21706
 local texmfcaches=resolvers.cleanpathlist("TEXMFCACHE") 
21676
21707
 if texmfcaches then
21677
21708
  for k=1,#texmfcaches do
21678
21709
   local cachepath=texmfcaches[k]
21679
21710
   if cachepath~="" then
21680
 
    cachepath=resolvers.resolve(cachepath)
21681
 
    cachepath=resolvers.cleanpath(cachepath)
21682
 
    cachepath=file.collapsepath(cachepath)
 
21711
    cachepath=resolvepath(cachepath)
 
21712
    cachepath=cleanpath(cachepath)
 
21713
    cachepath=collapsepath(cachepath)
21683
21714
    local valid=isdir(cachepath)
21684
21715
    if valid then
21685
21716
     if is_readable(cachepath) then
21688
21719
       writable=cachepath
21689
21720
      end
21690
21721
     end
21691
 
    elseif not writable and caches.force then
21692
 
     local cacheparent=file.dirname(cachepath)
21693
 
     if is_writable(cacheparent) and true then 
21694
 
      if not caches.ask or io.ask(format("\nShould I create the cache path %s?",cachepath),"no",{ "yes","no" })=="yes" then
21695
 
       mkdirs(cachepath)
21696
 
       if isdir(cachepath) and is_writable(cachepath) then
21697
 
        report_caches("path %a created",cachepath)
21698
 
        writable=cachepath
21699
 
        readables[#readables+1]=cachepath
21700
 
       end
 
21722
    elseif not writable then
 
21723
     local cacheparent=dirname(cachepath)
 
21724
     if is_writable(cacheparent) then 
 
21725
      mkdirs(cachepath)
 
21726
      if isdir(cachepath) and is_writable(cachepath) then
 
21727
       report_caches("path %a created",cachepath)
 
21728
       writable=cachepath
 
21729
       readables[#readables+1]=cachepath
21701
21730
      end
21702
21731
     end
21703
21732
    end
21710
21739
   local cachepath=texmfcaches[k]
21711
21740
   cachepath=resolvers.expansion(cachepath) 
21712
21741
   if cachepath~="" then
21713
 
    cachepath=resolvers.resolve(cachepath)
21714
 
    cachepath=resolvers.cleanpath(cachepath)
 
21742
    cachepath=resolvepath(cachepath)
 
21743
    cachepath=cleanpath(cachepath)
21715
21744
    local valid=isdir(cachepath)
21716
21745
    if valid and is_readable(cachepath) then
21717
21746
     if not writable and is_writable(cachepath) then
21725
21754
 end
21726
21755
 if not writable then
21727
21756
  report_caches("fatal error: there is no valid writable cache path defined")
21728
 
  os.exit()
 
21757
  osexit()
21729
21758
 elseif #readables==0 then
21730
21759
  report_caches("fatal error: there is no valid readable cache path defined")
21731
 
  os.exit()
 
21760
  osexit()
21732
21761
 end
21733
 
 writable=dir.expandname(resolvers.cleanpath(writable))
21734
 
 local base,more,tree=caches.base,caches.more,caches.tree or caches.treehash() 
 
21762
 writable=expanddirname(cleanpath(writable))
 
21763
 local base=caches.base
 
21764
 local more=caches.more
 
21765
 local tree=cache_tree or treehash() 
21735
21766
 if tree then
21736
 
  caches.tree=tree
 
21767
  cache_tree=tree
21737
21768
  writable=mkdirs(writable,base,more,tree)
21738
21769
  for i=1,#readables do
21739
 
   readables[i]=file.join(readables[i],base,more,tree)
 
21770
   readables[i]=joinfile(readables[i],base,more,tree)
21740
21771
  end
21741
21772
 else
21742
21773
  writable=mkdirs(writable,base,more)
21743
21774
  for i=1,#readables do
21744
 
   readables[i]=file.join(readables[i],base,more)
 
21775
   readables[i]=joinfile(readables[i],base,more)
21745
21776
  end
21746
21777
 end
21747
21778
 if trace_cache then
21778
21809
  return writable or "?"
21779
21810
 end
21780
21811
end
21781
 
function caches.configfiles()
21782
 
 return concat(resolvers.configurationfiles(),";")
21783
 
end
21784
 
function caches.hashed(tree)
21785
 
 tree=gsub(tree,"[\\/]+$","")
21786
 
 tree=lower(tree)
21787
 
 local hash=md5.hex(tree)
21788
 
 if trace_cache or trace_locating then
21789
 
  report_caches("hashing tree %a, hash %a",tree,hash)
21790
 
 end
21791
 
 return hash
21792
 
end
21793
 
function caches.treehash()
21794
 
 local tree=caches.configfiles()
21795
 
 if not tree or tree=="" then
21796
 
  return false
21797
 
 else
21798
 
  return caches.hashed(tree)
21799
 
 end
21800
 
end
21801
 
local r_cache,w_cache={},{} 
 
21812
local r_cache={}
 
21813
local w_cache={}
21802
21814
local function getreadablepaths(...)
21803
21815
 local tags={... }
21804
21816
 local hash=concat(tags,"/")
21808
21820
  if #tags>0 then
21809
21821
   done={}
21810
21822
   for i=1,#readables do
21811
 
    done[i]=file.join(readables[i],...)
 
21823
    done[i]=joinfile(readables[i],...)
21812
21824
   end
21813
21825
  else
21814
21826
   done=readables
21832
21844
 end
21833
21845
 return done
21834
21846
end
21835
 
caches.getreadablepaths=getreadablepaths
21836
 
caches.getwritablepath=getwritablepath
21837
 
function caches.getfirstreadablefile(filename,...)
21838
 
 local fullname,path=caches.setfirstwritablefile(filename,...)
 
21847
local function setfirstwritablefile(filename,...)
 
21848
 local wr=getwritablepath(...)
 
21849
 local fullname=joinfile(wr,filename)
 
21850
 return fullname,wr
 
21851
end
 
21852
local function setluanames(path,name)
 
21853
 return
 
21854
  format("%s/%s.%s",path,name,luasuffixes.tma),
 
21855
  format("%s/%s.%s",path,name,luasuffixes.tmc)
 
21856
end
 
21857
local function getfirstreadablefile(filename,...)
 
21858
 local fullname,path=setfirstwritablefile(filename,...)
21839
21859
 if is_readable(fullname) then
21840
21860
  return fullname,path 
21841
21861
 end
21842
21862
 local rd=getreadablepaths(...)
21843
21863
 for i=1,#rd do
21844
21864
  local path=rd[i]
21845
 
  local fullname=file.join(path,filename)
 
21865
  local fullname=joinfile(path,filename)
21846
21866
  if is_readable(fullname) then
21847
21867
   usedreadables[i]=true
21848
21868
   return fullname,path 
21850
21870
 end
21851
21871
 return fullname,path 
21852
21872
end
21853
 
function caches.setfirstwritablefile(filename,...)
21854
 
 local wr=getwritablepath(...)
21855
 
 local fullname=file.join(wr,filename)
21856
 
 return fullname,wr
21857
 
end
21858
 
function caches.define(category,subcategory) 
21859
 
 return function()
21860
 
  return getwritablepath(category,subcategory)
21861
 
 end
21862
 
end
21863
 
function caches.setluanames(path,name)
21864
 
 return format("%s/%s.%s",path,name,luasuffixes.tma),format("%s/%s.%s",path,name,luasuffixes.tmc)
21865
 
end
 
21873
caches.getreadablepaths=getreadablepaths
 
21874
caches.getwritablepath=getwritablepath
 
21875
caches.setfirstwritablefile=setfirstwritablefile
 
21876
caches.getfirstreadablefile=getfirstreadablefile
 
21877
caches.setluanames=setluanames
21866
21878
function caches.loaddata(readables,name,writable)
21867
21879
 if type(readables)=="string" then
21868
21880
  readables={ readables }
21871
21883
  local path=readables[i]
21872
21884
  local loader=false
21873
21885
  local state=false
21874
 
  local tmaname,tmcname=caches.setluanames(path,name)
 
21886
  local tmaname,tmcname=setluanames(path,name)
21875
21887
  if isfile(tmcname) then
21876
21888
   state,loader=pcall(loadfile,tmcname)
21877
21889
  end
21878
21890
  if not loader and isfile(tmaname) then
21879
 
   local tmacrap,tmcname=caches.setluanames(writable,name)
 
21891
   local tmacrap,tmcname=setluanames(writable,name)
21880
21892
   if isfile(tmcname) then
21881
21893
    state,loader=pcall(loadfile,tmcname)
21882
21894
   end
21883
 
   utilities.lua.compile(tmaname,tmcname)
 
21895
   compilelua(tmaname,tmcname)
21884
21896
   if isfile(tmcname) then
21885
21897
    state,loader=pcall(loadfile,tmcname)
21886
21898
   end
21897
21909
 return false
21898
21910
end
21899
21911
function caches.is_writable(filepath,filename)
21900
 
 local tmaname,tmcname=caches.setluanames(filepath,filename)
 
21912
 local tmaname,tmcname=setluanames(filepath,filename)
21901
21913
 return is_writable(tmaname)
21902
21914
end
21903
21915
local saveoptions={ compact=true }
21904
 
function caches.savedata(filepath,filename,data)
21905
 
 local tmaname,tmcname=caches.setluanames(filepath,filename)
21906
 
 data.cache_uuid=os.uuid()
21907
 
 if caches.fast then
21908
 
  file.savedata(tmaname,table.fastserialize(data,true))
21909
 
 elseif caches.direct then
21910
 
  file.savedata(tmaname,table.serialize(data,true,saveoptions))
 
21916
function caches.savedata(filepath,filename,data,fast)
 
21917
 local tmaname,tmcname=setluanames(filepath,filename)
 
21918
 data.cache_uuid=osuuid()
 
21919
 if fast or fast_cache then
 
21920
  savedata(tmaname,fastserialize(data,true))
 
21921
 elseif direct_cache then
 
21922
  savedata(tmaname,serialize(data,true,saveoptions))
21911
21923
 else
21912
 
  table.tofile(tmaname,data,true,saveoptions)
 
21924
  serializetofile(tmaname,data,true,saveoptions)
21913
21925
 end
21914
 
 utilities.lua.compile(tmaname,tmcname)
 
21926
 compilelua(tmaname,tmcname)
21915
21927
end
21916
21928
local content_state={}
21917
21929
function caches.contentstate()
21919
21931
end
21920
21932
function caches.loadcontent(cachename,dataname,filename)
21921
21933
 if not filename then
21922
 
  local name=caches.hashed(cachename)
21923
 
  local full,path=caches.getfirstreadablefile(addsuffix(name,luasuffixes.lua),"trees")
21924
 
  filename=file.join(path,name)
 
21934
  local name=hashed(cachename)
 
21935
  local full,path=getfirstreadablefile(addsuffix(name,luasuffixes.lua),"trees")
 
21936
  filename=joinfile(path,name)
21925
21937
 end
21926
21938
 local state,blob=pcall(loadfile,addsuffix(filename,luasuffixes.luc))
21927
21939
 if not blob then
21959
21971
end
21960
21972
function caches.savecontent(cachename,dataname,content,filename)
21961
21973
 if not filename then
21962
 
  local name=caches.hashed(cachename)
21963
 
  local full,path=caches.setfirstwritablefile(addsuffix(name,luasuffixes.lua),"trees")
21964
 
  filename=file.join(path,name) 
 
21974
  local name=hashed(cachename)
 
21975
  local full,path=setfirstwritablefile(addsuffix(name,luasuffixes.lua),"trees")
 
21976
  filename=joinfile(path,name) 
21965
21977
 end
21966
21978
 local luaname=addsuffix(filename,luasuffixes.lua)
21967
21979
 local lucname=addsuffix(filename,luasuffixes.luc)
21972
21984
  type=dataname,
21973
21985
  root=cachename,
21974
21986
  version=resolvers.cacheversion,
21975
 
  date=os.date("%Y-%m-%d"),
21976
 
  time=os.date("%H:%M:%S"),
 
21987
  date=osdate("%Y-%m-%d"),
 
21988
  time=osdate("%H:%M:%S"),
21977
21989
  content=content,
21978
 
  uuid=os.uuid(),
 
21990
  uuid=osuuid(),
21979
21991
 }
21980
 
 local ok=io.savedata(luaname,table.serialize(data,true))
 
21992
 local ok=savedata(luaname,serialize(data,true))
21981
21993
 if ok then
21982
21994
  if trace_locating then
21983
21995
   report_resolvers("category %a, cachename %a saved in %a",dataname,cachename,luaname)
21984
21996
  end
21985
 
  if utilities.lua.compile(luaname,lucname) then
 
21997
  if compilelua(luaname,lucname) then
21986
21998
   if trace_locating then
21987
21999
    report_resolvers("%a compiled to %a",dataname,lucname)
21988
22000
   end
21991
22003
   if trace_locating then
21992
22004
    report_resolvers("compiling failed for %a, deleting file %a",dataname,lucname)
21993
22005
   end
21994
 
   os.remove(lucname)
 
22006
   removefile(lucname)
21995
22007
  end
21996
22008
 elseif trace_locating then
21997
22009
  report_resolvers("unable to save %a in %a (access error)",dataname,luaname)
22005
22017
 
22006
22018
package.loaded["data-met"] = package.loaded["data-met"] or true
22007
22019
 
 
22020
-- original size: 5518, stripped down to: 3854
22008
22021
 
22009
22022
if not modules then modules={} end modules ['data-met']={
22010
22023
 version=1.100,
22014
22026
 copyright="PRAGMA ADE / ConTeXt Development Team",
22015
22027
 license="see context related readme files"
22016
22028
}
22017
 
local find,format=string.find,string.format
22018
 
local sequenced=table.sequenced
 
22029
local type=type
 
22030
local find=string.find
22019
22031
local addurlscheme,urlhashed=url.addscheme,url.hashed
 
22032
local collapsepath,joinfile=file.collapsepath,file.join
 
22033
local report_methods=logs.reporter("resolvers","methods")
22020
22034
local trace_locating=false
22021
22035
local trace_methods=false
22022
22036
trackers.register("resolvers.locating",function(v) trace_methods=v end)
22023
22037
trackers.register("resolvers.methods",function(v) trace_methods=v end)
22024
 
local report_methods=logs.reporter("resolvers","methods")
22025
22038
local allocate=utilities.storage.allocate
22026
22039
local resolvers=resolvers
22027
22040
local registered={}
22028
22041
local function splitmethod(filename) 
22029
22042
 if not filename then
22030
 
  return { scheme="unknown",original=filename }
 
22043
  return {
 
22044
   scheme="unknown",
 
22045
   original=filename,
 
22046
  }
22031
22047
 end
22032
22048
 if type(filename)=="table" then
22033
22049
  return filename 
22034
22050
 end
22035
 
 filename=file.collapsepath(filename,".") 
 
22051
 filename=collapsepath(filename,".") 
22036
22052
 if not find(filename,"://",1,true) then
22037
 
  return { scheme="file",path=filename,original=filename,filename=filename }
 
22053
  return {
 
22054
   scheme="file",
 
22055
   path=filename,
 
22056
   original=filename,
 
22057
   filename=filename,
 
22058
  }
22038
22059
 end
22039
 
 local specification=url.hashed(filename)
 
22060
 local specification=urlhashed(filename)
22040
22061
 if not specification.scheme or specification.scheme=="" then
22041
 
  return { scheme="file",path=filename,original=filename,filename=filename }
 
22062
  return {
 
22063
   scheme="file",
 
22064
   path=filename,
 
22065
   original=filename,
 
22066
   filename=filename,
 
22067
  }
22042
22068
 else
22043
22069
  return specification
22044
22070
 end
22047
22073
local function methodhandler(what,first,...) 
22048
22074
 local method=registered[what]
22049
22075
 if method then
22050
 
  local how,namespace=method.how,method.namespace
 
22076
  local how=method.how
 
22077
  local namespace=method.namespace
22051
22078
  if how=="uri" or how=="url" then
22052
22079
   local specification=splitmethod(first)
22053
22080
   local scheme=specification.scheme
22093
22120
end
22094
22121
resolvers.methodhandler=methodhandler
22095
22122
function resolvers.registermethod(name,namespace,how)
22096
 
 registered[name]={ how=how or "tag",namespace=namespace }
 
22123
 registered[name]={
 
22124
  how=how or "tag",
 
22125
  namespace=namespace
 
22126
 }
22097
22127
 namespace["byscheme"]=function(scheme,filename,...)
22098
22128
  if scheme=="file" then
22099
22129
   return methodhandler(name,filename,...)
22102
22132
  end
22103
22133
 end
22104
22134
end
22105
 
local concatinators=allocate { notfound=file.join    }  
 
22135
local concatinators=allocate { notfound=joinfile  }  
22106
22136
local locators=allocate { notfound=function() end  }  
22107
22137
local hashers=allocate { notfound=function() end  }  
22108
22138
local generators=allocate { notfound=function() end  }  
22123
22153
 
22124
22154
package.loaded["data-res"] = package.loaded["data-res"] or true
22125
22155
 
 
22156
-- original size: 69574, stripped down to: 44470
22126
22157
 
22127
22158
if not modules then modules={} end modules ['data-res']={
22128
22159
 version=1.001,
22134
22164
}
22135
22165
local gsub,find,lower,upper,match,gmatch=string.gsub,string.find,string.lower,string.upper,string.match,string.gmatch
22136
22166
local concat,insert,remove=table.concat,table.insert,table.remove
22137
 
local next,type,rawget=next,type,rawget
 
22167
local next,type,rawget,loadfile=next,type,rawget,loadfile
 
22168
local mergedtable=table.merged
22138
22169
local os=os
22139
22170
local P,S,R,C,Cc,Cs,Ct,Carg=lpeg.P,lpeg.S,lpeg.R,lpeg.C,lpeg.Cc,lpeg.Cs,lpeg.Ct,lpeg.Carg
22140
22171
local lpegmatch,lpegpatterns=lpeg.match,lpeg.patterns
22150
22181
local is_qualified_path=file.is_qualified_path
22151
22182
local allocate=utilities.storage.allocate
22152
22183
local settings_to_array=utilities.parsers.settings_to_array
 
22184
local urlhasscheme=url.hasscheme
22153
22185
local getcurrentdir=lfs.currentdir
22154
22186
local isfile=lfs.isfile
22155
22187
local isdir=lfs.isdir
22175
22207
resolvers.cacheversion="1.100"
22176
22208
resolvers.configbanner=""
22177
22209
resolvers.homedir=environment.homedir
22178
 
resolvers.criticalvars=allocate { "SELFAUTOLOC","SELFAUTODIR","SELFAUTOPARENT","TEXMFCNF","TEXMF","TEXOS" }
22179
22210
resolvers.luacnfname="texmfcnf.lua"
22180
22211
resolvers.luacnffallback="contextcnf.lua"
22181
22212
resolvers.luacnfstate="unknown"
 
22213
local criticalvars={
 
22214
 "SELFAUTOLOC",
 
22215
 "SELFAUTODIR",
 
22216
 "SELFAUTOPARENT",
 
22217
 "TEXMFCNF",
 
22218
 "TEXMF",
 
22219
 "TEXOS",
 
22220
}
22182
22221
if environment.default_texmfcnf then
22183
22222
 resolvers.luacnfspec="home:texmf/web2c;"..environment.default_texmfcnf 
22184
22223
else
22198
22237
local suffixmap=resolvers.suffixmap
22199
22238
resolvers.defaultsuffixes={ "tex" } 
22200
22239
local instance=nil
22201
 
function resolvers.setenv(key,value,raw)
 
22240
local variable
 
22241
local expansion
 
22242
local setenv
 
22243
local getenv
 
22244
local formatofsuffix=resolvers.formatofsuffix
 
22245
local splitpath=resolvers.splitpath
 
22246
local splitmethod=resolvers.splitmethod
 
22247
setenv=function(key,value,raw)
22202
22248
 if instance then
22203
22249
  instance.environment[key]=value
22204
22250
  ossetenv(key,raw and value or resolveprefix(value))
22205
22251
 end
22206
22252
end
22207
 
local function getenv(key)
 
22253
getenv=function(key)
22208
22254
 local value=rawget(instance.environment,key)
22209
22255
 if value and value~="" then
22210
22256
  return value
22214
22260
 end
22215
22261
end
22216
22262
resolvers.getenv=getenv
22217
 
resolvers.env=getenv
22218
 
local function resolvevariable(k)
22219
 
 return instance.expansions[k]
22220
 
end
 
22263
resolvers.setenv=setenv
22221
22264
local dollarstripper=lpeg.stripper("$")
22222
22265
local inhibitstripper=P("!")^0*Cs(P(1)^0)
22223
 
local somevariable=P("$")/""
22224
 
local somekey=C(R("az","AZ","09","__","--")^1)
22225
 
local somethingelse=P(";")*((1-S("!{}/\\"))^1*P(";")/"")+P(";")*(P(";")/"")+P(1)
22226
 
local variableexpander=Cs((somevariable*(somekey/resolvevariable)+somethingelse)^1 )
22227
 
local cleaner=P("\\")/"/"+P(";")*S("!{}/\\")^0*P(";")^1/";"
22228
 
local variablecleaner=Cs((cleaner+P(1))^0)
22229
 
local somevariable=R("az","AZ","09","__","--")^1/resolvevariable
22230
 
local variable=(P("$")/"")*(somevariable+(P("{")/"")*somevariable*(P("}")/""))
22231
 
local variableresolver=Cs((variable+P(1))^0)
22232
 
local function expandedvariable(var)
22233
 
 return lpegmatch(variableexpander,var) or var
22234
 
end
22235
 
function resolvers.reset()
22236
 
 if trace_locating then
22237
 
  report_resolving("creating instance")
22238
 
 end
22239
 
 local environment={}
22240
 
 local variables={}
22241
 
 local expansions={}
22242
 
 local order={}
22243
 
 instance={
22244
 
  environment=environment,
22245
 
  variables=variables,
22246
 
  expansions=expansions,
22247
 
  order=order,
22248
 
  files={},
22249
 
  setups={},
22250
 
  found={},
22251
 
  foundintrees={},
22252
 
  hashes={},
22253
 
  hashed={},
22254
 
  pathlists=false,
22255
 
  specification={},
22256
 
  lists={},
22257
 
  data={},
22258
 
  fakepaths={},
22259
 
  remember=true,
22260
 
  diskcache=true,
22261
 
  renewcache=false,
22262
 
  renewtree=false,
22263
 
  loaderror=false,
22264
 
  savelists=true,
22265
 
  pattern=nil,
22266
 
  force_suffixes=true,
22267
 
  pathstack={},
22268
 
 }
22269
 
 setmetatableindex(variables,function(t,k)
22270
 
  local v
22271
 
  for i=1,#order do
22272
 
   v=order[i][k]
 
22266
local expandedvariable,resolvedvariable  do
 
22267
 local function resolveinstancevariable(k)
 
22268
  return instance.expansions[k]
 
22269
 end
 
22270
 local p_variable=P("$")/""
 
22271
 local p_key=C(R("az","AZ","09","__","--")^1)
 
22272
 local p_whatever=P(";")*((1-S("!{}/\\"))^1*P(";")/"")+P(";")*(P(";")/"")+P(1)
 
22273
 local variableexpander=Cs((p_variable*(p_key/resolveinstancevariable)+p_whatever)^1 )
 
22274
 local p_cleaner=P("\\")/"/"+P(";")*S("!{}/\\")^0*P(";")^1/";"
 
22275
 local variablecleaner=Cs((p_cleaner+P(1))^0)
 
22276
 local p_variable=R("az","AZ","09","__","--")^1/resolveinstancevariable
 
22277
 local p_variable=(P("$")/"")*(p_variable+(P("{")/"")*p_variable*(P("}")/""))
 
22278
 local variableresolver=Cs((p_variable+P(1))^0)
 
22279
 expandedvariable=function(var)
 
22280
  return lpegmatch(variableexpander,var) or var
 
22281
 end
 
22282
 function resolvers.reset()
 
22283
  if trace_locating then
 
22284
   report_resolving("creating instance")
 
22285
  end
 
22286
  local environment={}
 
22287
  local variables={}
 
22288
  local expansions={}
 
22289
  local order={}
 
22290
  instance={
 
22291
   environment=environment,
 
22292
   variables=variables,
 
22293
   expansions=expansions,
 
22294
   order=order,
 
22295
   files={},
 
22296
   setups={},
 
22297
   found={},
 
22298
   foundintrees={},
 
22299
   hashes={},
 
22300
   hashed={},
 
22301
   pathlists=false,
 
22302
   specification={},
 
22303
   lists={},
 
22304
   data={},
 
22305
   fakepaths={},
 
22306
   remember=true,
 
22307
   diskcache=true,
 
22308
   renewcache=false,
 
22309
   renewtree=false,
 
22310
   loaderror=false,
 
22311
   savelists=true,
 
22312
   pattern=nil,
 
22313
   force_suffixes=true,
 
22314
   pathstack={},
 
22315
  }
 
22316
  setmetatableindex(variables,function(t,k)
 
22317
   local v
 
22318
   for i=1,#order do
 
22319
    v=order[i][k]
 
22320
    if v~=nil then
 
22321
     t[k]=v
 
22322
     return v
 
22323
    end
 
22324
   end
 
22325
   if v==nil then
 
22326
    v=""
 
22327
   end
 
22328
   t[k]=v
 
22329
   return v
 
22330
  end)
 
22331
  local repath=resolvers.repath
 
22332
  setmetatableindex(environment,function(t,k)
 
22333
   local v=osgetenv(k)
 
22334
   if v==nil then
 
22335
    v=variables[k]
 
22336
   end
22273
22337
   if v~=nil then
22274
 
    t[k]=v
22275
 
    return v
22276
 
   end
22277
 
  end
22278
 
  if v==nil then
22279
 
   v=""
22280
 
  end
22281
 
  t[k]=v
22282
 
  return v
22283
 
 end)
22284
 
 setmetatableindex(environment,function(t,k)
22285
 
  local v=osgetenv(k)
22286
 
  if v==nil then
22287
 
   v=variables[k]
22288
 
  end
22289
 
  if v~=nil then
22290
 
   v=checkedvariable(v) or ""
22291
 
  end
22292
 
  v=resolvers.repath(v) 
22293
 
  t[k]=v
22294
 
  return v
22295
 
 end)
22296
 
 setmetatableindex(expansions,function(t,k)
22297
 
  local v=environment[k]
22298
 
  if type(v)=="string" then
22299
 
   v=lpegmatch(variableresolver,v)
22300
 
   v=lpegmatch(variablecleaner,v)
22301
 
  end
22302
 
  t[k]=v
22303
 
  return v
22304
 
 end)
 
22338
    v=checkedvariable(v) or ""
 
22339
   end
 
22340
   v=repath(v) 
 
22341
   t[k]=v
 
22342
   return v
 
22343
  end)
 
22344
  setmetatableindex(expansions,function(t,k)
 
22345
   local v=environment[k]
 
22346
   if type(v)=="string" then
 
22347
    v=lpegmatch(variableresolver,v)
 
22348
    v=lpegmatch(variablecleaner,v)
 
22349
   end
 
22350
   t[k]=v
 
22351
   return v
 
22352
  end)
 
22353
 end
22305
22354
end
22306
22355
function resolvers.initialized()
22307
22356
 return instance~=nil
22315
22364
 instance.lists={}
22316
22365
 instance.pathlists=false
22317
22366
end
22318
 
local slash=P("/")
22319
 
local pathexpressionpattern=Cs (
22320
 
 Cc("^")*(
22321
 
  Cc("%")*S(".-")+slash^2*P(-1)/"/.*"
 
22367
local makepathexpression  do
 
22368
 local slash=P("/")
 
22369
 local pathexpressionpattern=Cs (
 
22370
  Cc("^")*(
 
22371
   Cc("%")*S(".-")+slash^2*P(-1)/"/.*"
22322
22372
+slash^2/"/"+(1-slash)*P(-1)*Cc("/")+P(1)
22323
 
 )^1*Cc("$") 
22324
 
)
22325
 
local cache={}
22326
 
local function makepathexpression(str)
22327
 
 if str=="." then
22328
 
  return "^%./$"
22329
 
 else
22330
 
  local c=cache[str]
22331
 
  if not c then
22332
 
   c=lpegmatch(pathexpressionpattern,str)
22333
 
   cache[str]=c
 
22373
  )^1*Cc("$") 
 
22374
 )
 
22375
 local cache={}
 
22376
 makepathexpression=function(str)
 
22377
  if str=="." then
 
22378
   return "^%./$"
 
22379
  else
 
22380
   local c=cache[str]
 
22381
   if not c then
 
22382
    c=lpegmatch(pathexpressionpattern,str)
 
22383
    cache[str]=c
 
22384
   end
 
22385
   return c
22334
22386
  end
22335
 
  return c
22336
22387
 end
22337
22388
end
22338
22389
local function reportcriticalvariables(cnfspec)
22339
22390
 if trace_locating then
22340
 
  for i=1,#resolvers.criticalvars do
22341
 
   local k=resolvers.criticalvars[i]
22342
 
   local v=resolvers.getenv(k) or "unknown" 
 
22391
  for i=1,#criticalvars do
 
22392
   local k=criticalvars[i]
 
22393
   local v=getenv(k) or "unknown" 
22343
22394
   report_resolving("variable %a set to %a",k,v)
22344
22395
  end
22345
22396
  report_resolving()
22361
22412
   resolvers.luacnfstate="environment"
22362
22413
  end
22363
22414
  reportcriticalvariables(cnfspec)
22364
 
  local cnfpaths=expandedpathfromlist(resolvers.splitpath(cnfspec))
 
22415
  local cnfpaths=expandedpathfromlist(splitpath(cnfspec))
22365
22416
  local function locatecnf(luacnfname,kind)
22366
22417
   for i=1,#cnfpaths do
22367
22418
    local filepath=cnfpaths[i]
22394
22445
end
22395
22446
local function load_configuration_files()
22396
22447
 local specification=instance.specification
 
22448
 local setups=instance.setups
 
22449
 local order=instance.order
22397
22450
 if #specification>0 then
22398
22451
  local luacnfname=resolvers.luacnfname
22399
22452
  for i=1,#specification do
22403
22456
   local realname=resolveprefix(filename) 
22404
22457
   local blob=loadfile(realname)
22405
22458
   if blob then
22406
 
    local setups=instance.setups
22407
22459
    local data=blob()
22408
22460
    local parent=data and data.parent
22409
22461
    if parent then
22414
22466
      local parentdata=blob()
22415
22467
      if parentdata then
22416
22468
       report_resolving("loading configuration file %a",filename)
22417
 
       data=table.merged(parentdata,data)
 
22469
       data=mergedtable(parentdata,data)
22418
22470
      end
22419
22471
     end
22420
22472
    end
22446
22498
       if trace_locating then
22447
22499
        report_resolving("reloading configuration due to TEXMF redefinition")
22448
22500
       end
22449
 
       resolvers.setenv("TEXMFCNF",cnfspec)
 
22501
       setenv("TEXMFCNF",cnfspec)
22450
22502
       instance.specification={}
22451
22503
       identify_configuration_files()
22452
22504
       load_configuration_files()
22464
22516
   elseif trace_locating then
22465
22517
    report_resolving("skipping configuration file %a (no valid format)",filename)
22466
22518
   end
22467
 
   instance.order[#instance.order+1]=instance.setups[pathname]
 
22519
   order[#order+1]=setups[pathname]
22468
22520
   if instance.loaderror then
22469
22521
    break
22470
22522
   end
22473
22525
  report_resolving("warning: no lua configuration files found")
22474
22526
 end
22475
22527
end
 
22528
local expandedpathlist
 
22529
local unexpandedpathlist
22476
22530
function resolvers.configurationfiles()
22477
22531
 return instance.specification or {}
22478
22532
end
22489
22543
 end
22490
22544
end
22491
22545
local function locate_file_databases()
22492
 
 local texmfpaths=resolvers.expandedpathlist("TEXMF")
 
22546
 local texmfpaths=expandedpathlist("TEXMF")
22493
22547
 if #texmfpaths>0 then
22494
22548
  for i=1,#texmfpaths do
22495
22549
   local path=collapsepath(texmfpaths[i])
22498
22552
   if stripped~="" then
22499
22553
    local runtime=stripped==path
22500
22554
    path=cleanpath(path)
22501
 
    local spec=resolvers.splitmethod(stripped)
 
22555
    local spec=splitmethod(stripped)
22502
22556
    if runtime and (spec.noscheme or spec.scheme=="file") then
22503
22557
     stripped="tree:///"..stripped
22504
22558
    elseif spec.scheme=="cache" or spec.scheme=="file" then
22532
22586
 end
22533
22587
end
22534
22588
local function save_file_databases() 
22535
 
 for i=1,#instance.hashes do
22536
 
  local hash=instance.hashes[i]
 
22589
 local hashes=instance.hashes
 
22590
 local files=instance.files
 
22591
 for i=1,#hashes do
 
22592
  local hash=hashes[i]
22537
22593
  local cachename=hash.name
22538
22594
  if hash.cache then
22539
 
   local content=instance.files[cachename]
 
22595
   local content=files[cachename]
22540
22596
   caches.collapsecontent(content)
22541
22597
   if trace_locating then
22542
22598
    report_resolving("saving tree %a",cachename)
22548
22604
 end
22549
22605
end
22550
22606
function resolvers.renew(hashname)
 
22607
 local files=instance.files
22551
22608
 if hashname and hashname~="" then
22552
 
  local expanded=resolvers.expansion(hashname) or ""
 
22609
  local expanded=expansion(hashname) or ""
22553
22610
  if expanded~="" then
22554
22611
   if trace_locating then
22555
22612
    report_resolving("identifying tree %a from %a",expanded,hashname)
22566
22623
    report_resolving("using path %a",realpath)
22567
22624
   end
22568
22625
   methodhandler('generators',hashname)
22569
 
   local content=instance.files[hashname]
 
22626
   local content=files[hashname]
22570
22627
   caches.collapsecontent(content)
22571
22628
   if trace_locating then
22572
22629
    report_resolving("saving tree %a",hashname)
22593
22650
 end
22594
22651
end
22595
22652
function resolvers.appendhash(type,name,cache)
22596
 
 if not instance.hashed[name] then
 
22653
 local hashed=instance.hashed
 
22654
 local hashes=instance.hashes
 
22655
 if hashed[name] then
 
22656
 else
22597
22657
  if trace_locating then
22598
22658
   report_resolving("hash %a appended",name)
22599
22659
  end
22600
 
  insert(instance.hashes,{ type=type,name=name,cache=cache } )
22601
 
  instance.hashed[name]=cache
 
22660
  insert(hashes,{ type=type,name=name,cache=cache } )
 
22661
  hashed[name]=cache
22602
22662
 end
22603
22663
end
22604
22664
function resolvers.prependhash(type,name,cache)
22605
 
 if not instance.hashed[name] then
 
22665
 local hashed=instance.hashed
 
22666
 local hashes=instance.hashes
 
22667
 if hashed[name] then
 
22668
 else
22606
22669
  if trace_locating then
22607
22670
   report_resolving("hash %a prepended",name)
22608
22671
  end
22609
 
  insert(instance.hashes,1,{ type=type,name=name,cache=cache } )
22610
 
  instance.hashed[name]=cache
 
22672
  insert(hashes,1,{ type=type,name=name,cache=cache } )
 
22673
  hashed[name]=cache
22611
22674
 end
22612
22675
end
22613
22676
function resolvers.extendtexmfvariable(specification) 
22614
 
 local t=resolvers.splitpath(getenv("TEXMF")) 
22615
 
 insert(t,1,specification)
22616
 
 local newspec=concat(t,",") 
22617
 
 if instance.environment["TEXMF"] then
22618
 
  instance.environment["TEXMF"]=newspec
22619
 
 elseif instance.variables["TEXMF"] then
22620
 
  instance.variables["TEXMF"]=newspec
 
22677
 local environment=instance.environment
 
22678
 local variables=instance.variables
 
22679
 local texmftrees=splitpath(getenv("TEXMF")) 
 
22680
 insert(texmftrees,1,specification)
 
22681
 texmftrees=concat(texmftrees,",") 
 
22682
 if environment["TEXMF"] then
 
22683
  environment["TEXMF"]=texmftrees
 
22684
 elseif variables["TEXMF"] then
 
22685
  variables["TEXMF"]=texmftrees
22621
22686
 else
22622
22687
 end
22623
22688
 reset_hashes()
22624
22689
end
22625
22690
function resolvers.splitexpansions()
22626
 
 local ie=instance.expansions
22627
 
 for k,v in next,ie do
 
22691
 local expansions=instance.expansions
 
22692
 for k,v in next,expansions do
22628
22693
  local t,tn,h,p={},0,{},splitconfigurationpath(v)
22629
22694
  for kk=1,#p do
22630
22695
   local vv=p[kk]
22634
22699
    h[vv]=true
22635
22700
   end
22636
22701
  end
22637
 
  if #t>1 then
22638
 
   ie[k]=t
 
22702
  if tn>1 then
 
22703
   expansions[k]=t
22639
22704
  else
22640
 
   ie[k]=t[1]
 
22705
   expansions[k]=t[1]
22641
22706
  end
22642
22707
 end
22643
22708
end
22644
22709
function resolvers.datastate()
22645
22710
 return caches.contentstate()
22646
22711
end
22647
 
function resolvers.variable(name)
22648
 
 local name=name and lpegmatch(dollarstripper,name)
22649
 
 local result=name and instance.variables[name]
22650
 
 return result~=nil and result or ""
22651
 
end
22652
 
function resolvers.expansion(name)
22653
 
 local name=name and lpegmatch(dollarstripper,name)
22654
 
 local result=name and instance.expansions[name]
22655
 
 return result~=nil and result or ""
22656
 
end
22657
 
function resolvers.unexpandedpathlist(str)
22658
 
 local pth=resolvers.variable(str)
22659
 
 local lst=resolvers.splitpath(pth)
 
22712
variable=function(name)
 
22713
 local variables=instance.variables
 
22714
 local name=name and lpegmatch(dollarstripper,name)
 
22715
 local result=name and variables[name]
 
22716
 return result~=nil and result or ""
 
22717
end
 
22718
expansion=function(name)
 
22719
 local expansions=instance.expansions
 
22720
 local name=name and lpegmatch(dollarstripper,name)
 
22721
 local result=name and expansions[name]
 
22722
 return result~=nil and result or ""
 
22723
end
 
22724
resolvers.variable=variable
 
22725
resolvers.expansion=expansion
 
22726
unexpandedpathlist=function(str)
 
22727
 local pth=variable(str)
 
22728
 local lst=splitpath(pth)
22660
22729
 return expandedpathfromlist(lst)
22661
22730
end
22662
22731
function resolvers.unexpandedpath(str)
22663
 
 return joinpath(resolvers.unexpandedpathlist(str))
 
22732
 return joinpath(unexpandedpathlist(str))
22664
22733
end
22665
22734
function resolvers.pushpath(name)
22666
22735
 local pathstack=instance.pathstack
22690
22759
end
22691
22760
local done={}
22692
22761
function resolvers.resetextrapaths()
22693
 
 local ep=instance.extra_paths
22694
 
 if not ep then
 
22762
 local extra_paths=instance.extra_paths
 
22763
 if not extra_paths then
22695
22764
  done={}
22696
22765
  instance.extra_paths={}
22697
22766
 elseif #ep>0 then
22712
22781
 end
22713
22782
 local paths=settings_to_array(paths)
22714
22783
 local subpaths=settings_to_array(subpaths)
22715
 
 local ep=instance.extra_paths or {}
22716
 
 local oldn=#ep
 
22784
 local extra_paths=instance.extra_paths or {}
 
22785
 local oldn=#extra_paths
22717
22786
 local newn=oldn
22718
22787
 local nofpaths=#paths
22719
22788
 local nofsubpaths=#subpaths
22726
22795
     local ps=p.."/"..s
22727
22796
     if not done[ps] then
22728
22797
      newn=newn+1
22729
 
      ep[newn]=cleanpath(ps)
 
22798
      extra_paths[newn]=cleanpath(ps)
22730
22799
      done[ps]=true
22731
22800
     end
22732
22801
    end
22736
22805
    local p=paths[i]
22737
22806
    if not done[p] then
22738
22807
     newn=newn+1
22739
 
     ep[newn]=cleanpath(p)
 
22808
     extra_paths[newn]=cleanpath(p)
22740
22809
     done[p]=true
22741
22810
    end
22742
22811
   end
22745
22814
  for i=1,oldn do
22746
22815
   for j=1,nofsubpaths do
22747
22816
    local s=subpaths[j]
22748
 
    local ps=ep[i].."/"..s
 
22817
    local ps=extra_paths[i].."/"..s
22749
22818
    if not done[ps] then
22750
22819
     newn=newn+1
22751
 
     ep[newn]=cleanpath(ps)
 
22820
     extra_paths[newn]=cleanpath(ps)
22752
22821
     done[ps]=true
22753
22822
    end
22754
22823
   end
22755
22824
  end
22756
22825
 end
22757
22826
 if newn>0 then
22758
 
  instance.extra_paths=ep 
 
22827
  instance.extra_paths=extra_paths 
22759
22828
 end
22760
22829
 if newn~=oldn then
22761
22830
  reset_caches()
22763
22832
end
22764
22833
function resolvers.pushextrapath(path)
22765
22834
 local paths=settings_to_array(path)
22766
 
 if instance.extra_stack then
22767
 
  insert(instance.extra_stack,1,paths)
 
22835
 local extra_stack=instance.extra_stack
 
22836
 if extra_stack then
 
22837
  insert(extra_stack,1,paths)
22768
22838
 else
22769
22839
  instance.extra_stack={ paths }
22770
22840
 end
22771
22841
 reset_caches()
22772
22842
end
22773
22843
function resolvers.popextrapath()
22774
 
 if instance.extra_stack then
 
22844
 local extra_stack=instance.extra_stack
 
22845
 if extra_stack then
22775
22846
  reset_caches()
22776
 
  return remove(instance.extra_stack,1)
 
22847
  return remove(extra_stack,1)
22777
22848
 end
22778
22849
end
22779
22850
local function made_list(instance,list,extra_too)
22802
22873
  end
22803
22874
 end
22804
22875
 if extra_too then
22805
 
  local es=instance.extra_stack
22806
 
  if es and #es>0 then
22807
 
   for k=1,#es do
22808
 
    add(es[k])
 
22876
  local extra_stack=instance.extra_stack
 
22877
  local extra_paths=instance.extra_paths
 
22878
  if extra_stack and #extra_stack>0 then
 
22879
   for k=1,#extra_stack do
 
22880
    add(extra_stack[k])
22809
22881
   end
22810
22882
  end
22811
 
  local ep=instance.extra_paths
22812
 
  if ep and #ep>0 then
22813
 
   add(ep)
 
22883
  if extra_paths and #extra_paths>0 then
 
22884
   add(extra_paths)
22814
22885
  end
22815
22886
 end
22816
22887
 add(list)
22817
22888
 return new
22818
22889
end
22819
 
function resolvers.cleanpathlist(str)
22820
 
 local t=resolvers.expandedpathlist(str)
22821
 
 if t then
22822
 
  for i=1,#t do
22823
 
   t[i]=collapsepath(cleanpath(t[i]))
22824
 
  end
22825
 
 end
22826
 
 return t
22827
 
end
22828
 
function resolvers.expandpath(str)
22829
 
 return joinpath(resolvers.expandedpathlist(str))
22830
 
end
22831
 
function resolvers.expandedpathlist(str,extra_too)
 
22890
expandedpathlist=function(str,extra_too)
22832
22891
 if not str then
22833
22892
  return {}
22834
22893
 elseif instance.savelists then 
22836
22895
  local lists=instance.lists
22837
22896
  local lst=lists[str]
22838
22897
  if not lst then
22839
 
   local l=made_list(instance,resolvers.splitpath(resolvers.expansion(str)),extra_too)
 
22898
   local l=made_list(instance,splitpath(expansion(str)),extra_too)
22840
22899
   lst=expandedpathfromlist(l)
22841
22900
   lists[str]=lst
22842
22901
  end
22843
22902
  return lst
22844
22903
 else
22845
 
  local lst=resolvers.splitpath(resolvers.expansion(str))
 
22904
  local lst=splitpath(expansion(str))
22846
22905
  return made_list(instance,expandedpathfromlist(lst),extra_too)
22847
22906
 end
22848
22907
end
22849
 
function resolvers.expandedpathlistfromvariable(str) 
 
22908
resolvers.expandedpathlist=expandedpathlist
 
22909
resolvers.unexpandedpathlist=unexpandedpathlist
 
22910
function resolvers.cleanpathlist(str)
 
22911
 local t=expandedpathlist(str)
 
22912
 if t then
 
22913
  for i=1,#t do
 
22914
   t[i]=collapsepath(cleanpath(t[i]))
 
22915
  end
 
22916
 end
 
22917
 return t
 
22918
end
 
22919
function resolvers.expandpath(str)
 
22920
 return joinpath(expandedpathlist(str))
 
22921
end
 
22922
local function expandedpathlistfromvariable(str) 
22850
22923
 str=lpegmatch(dollarstripper,str)
22851
22924
 local tmp=resolvers.variableofformatorsuffix(str)
22852
 
 return resolvers.expandedpathlist(tmp~="" and tmp or str)
 
22925
 return expandedpathlist(tmp~="" and tmp or str)
22853
22926
end
22854
22927
function resolvers.expandpathfromvariable(str)
22855
 
 return joinpath(resolvers.expandedpathlistfromvariable(str))
 
22928
 return joinpath(expandedpathlistfromvariable(str))
22856
22929
end
 
22930
resolvers.expandedpathlistfromvariable=expandedpathlistfromvariable
22857
22931
function resolvers.cleanedpathlist(v) 
22858
 
 local t=resolvers.expandedpathlist(v)
 
22932
 local t=expandedpathlist(v)
22859
22933
 for i=1,#t do
22860
 
  t[i]=resolvers.resolve(resolvers.cleanpath(t[i]))
 
22934
  t[i]=resolveprefix(cleanpath(t[i]))
22861
22935
 end
22862
22936
 return t
22863
22937
end
22864
22938
function resolvers.expandbraces(str) 
22865
 
 local pth=expandedpathfromlist(resolvers.splitpath(str))
 
22939
 local pth=expandedpathfromlist(splitpath(str))
22866
22940
 return joinpath(pth)
22867
22941
end
22868
22942
function resolvers.registerfilehash(name,content,someerror)
 
22943
 local files=instance.files
22869
22944
 if content then
22870
 
  instance.files[name]=content
 
22945
  files[name]=content
22871
22946
 else
22872
 
  instance.files[name]={}
 
22947
  files[name]={}
22873
22948
  if somerror==true then 
22874
22949
   instance.loaderror=someerror
22875
22950
  end
22926
23001
   pathname="/"..pathname.."$"
22927
23002
  end
22928
23003
  local hashes=instance.hashes
 
23004
  local files=instance.files
22929
23005
  for h=1,#hashes do
22930
23006
   local hash=hashes[h]
22931
23007
   local hashname=hash.name
22932
 
   local content=hashname and instance.files[hashname]
 
23008
   local content=hashname and files[hashname]
22933
23009
   if content then
22934
23010
    if trace_details then
22935
23011
     report_resolving("deep checking %a, base %a, pattern %a",hashname,basename,pathname)
22999
23075
 if askedformat=="" then
23000
23076
  if filesuffix=="" or not suffixmap[filesuffix] then
23001
23077
   local defaultsuffixes=resolvers.defaultsuffixes
23002
 
   local formatofsuffix=resolvers.formatofsuffix
23003
23078
   for i=1,#defaultsuffixes do
23004
23079
    local forcedname=filename..'.'..defaultsuffixes[i]
23005
23080
    wantedfiles[#wantedfiles+1]=forcedname
23009
23084
    end
23010
23085
   end
23011
23086
  else
23012
 
   filetype=resolvers.formatofsuffix(filename)
 
23087
   filetype=formatofsuffix(filename)
23013
23088
   if trace_locating then
23014
23089
    report_resolving("using suffix based filetype %a",filetype)
23015
23090
   end
23070
23145
  local format_suffixes=askedformat=="" and resolvers.defaultsuffixes or suffixes[askedformat]
23071
23146
  if format_suffixes then
23072
23147
   for i=1,#format_suffixes do
23073
 
    local s=format_suffixes[i]
23074
 
    forcedname=filename.."."..s
 
23148
    local suffix=format_suffixes[i]
 
23149
    forcedname=filename.."."..suffix
23075
23150
    if isreadable(forcedname) then
23076
23151
     if trace_locating then
23077
 
      report_resolving("no suffix, forcing format filetype %a",s)
 
23152
      report_resolving("no suffix, forcing format filetype %a",suffix)
23078
23153
     end
23079
23154
     return "qualified",{ forcedname }
23080
23155
    end
23087
23162
  local savedformat=askedformat
23088
23163
  local format=savedformat or ""
23089
23164
  if format=="" then
23090
 
   askedformat=resolvers.formatofsuffix(suffix)
 
23165
   askedformat=formatofsuffix(suffix)
23091
23166
  end
23092
23167
  if not format then
23093
23168
   askedformat="othertextfiles" 
23126
23201
end
23127
23202
local function makepathlist(list,filetype)
23128
23203
 local typespec=resolvers.variableofformat(filetype)
23129
 
 local pathlist=resolvers.expandedpathlist(typespec,filetype and usertypes[filetype]) 
 
23204
 local pathlist=expandedpathlist(typespec,filetype and usertypes[filetype]) 
23130
23205
 local entry={}
23131
23206
 if pathlist and #pathlist>0 then
23132
23207
  for k=1,#pathlist do
23137
23212
   local expression=makepathexpression(pathname)
23138
23213
   local barename=gsub(pathname,"/+$","")
23139
23214
   barename=resolveprefix(barename)
23140
 
   local scheme=url.hasscheme(barename)
 
23215
   local scheme=urlhasscheme(barename)
23141
23216
   local schemename=gsub(barename,"%.%*$",'')
23142
23217
   entry[k]={
23143
23218
    path=path,
23342
23417
   { find_onpath   (filename,filetype,wantedfiles,true) },
23343
23418
   { find_otherwise(filename,filetype,wantedfiles,true) },
23344
23419
  }
23345
 
  local result,status,done={},{},{}
 
23420
  local result={}
 
23421
  local status={}
 
23422
  local done={}
23346
23423
  for k,r in next,results do
23347
23424
   local method,list=r[1],r[2]
23348
23425
   if method and list then
23413
23490
 if not filename or filename=="" then
23414
23491
  return {}
23415
23492
 end
 
23493
 if allresults==nil then
 
23494
  allresults=true
 
23495
 end
23416
23496
 local result,status=collect_instance_files(filename,filetype or "",allresults)
23417
23497
 if not result or #result==0 then
23418
23498
  local lowered=lower(filename)
23422
23502
 end
23423
23503
 return result or {},status
23424
23504
end
23425
 
function resolvers.findfiles(filename,filetype)
23426
 
 if not filename or filename=="" then
23427
 
  return ""
23428
 
 else
23429
 
  return findfiles(filename,filetype,true)
23430
 
 end
23431
 
end
23432
 
function resolvers.findfile(filename,filetype)
 
23505
local function findfile(filename,filetype)
23433
23506
 if not filename or filename=="" then
23434
23507
  return ""
23435
23508
 else
23436
23509
  return findfiles(filename,filetype,false)[1] or ""
23437
23510
 end
23438
23511
end
 
23512
resolvers.findfiles=findfiles
 
23513
resolvers.findfile=findfile
 
23514
resolvers.find_file=findfile  
 
23515
resolvers.find_files=findfiles 
23439
23516
function resolvers.findpath(filename,filetype)
23440
23517
 return filedirname(findfiles(filename,filetype,false)[1] or "")
23441
23518
end
23442
23519
local function findgivenfiles(filename,allresults)
 
23520
 local hashes=instance.hashes
 
23521
 local files=instance.files
23443
23522
 local base=filebasename(filename)
23444
23523
 local result={}
23445
 
 local hashes=instance.hashes
23446
23524
 local function okay(hash,path,name)
23447
23525
  local found=methodhandler('concatinators',hash.type,hash.name,path,name)
23448
23526
  if found and found~="" then
23452
23530
 end
23453
23531
 for k=1,#hashes do
23454
23532
  local hash=hashes[k]
23455
 
  local content=instance.files[hash.name]
 
23533
  local content=files[hash.name]
23456
23534
  if content then
23457
23535
   local path,name=lookup(content,base)
23458
23536
   if not path then
23484
23562
 return lpegmatch(makewildcard,pattern) or pattern
23485
23563
end
23486
23564
local function findwildcardfiles(filename,allresults,result)
 
23565
 local files=instance.files
 
23566
 local hashes=instance.hashes
23487
23567
 local result=result or {}
23488
23568
 local base=filebasename(filename)
23489
23569
 local dirn=filedirname(filename)
23490
23570
 local path=lower(lpegmatch(makewildcard,dirn) or dirn)
23491
23571
 local name=lower(lpegmatch(makewildcard,base) or base)
23492
 
 local files=instance.files
23493
23572
 if find(name,"*",1,true) then
23494
 
  local hashes=instance.hashes
23495
23573
  local function okay(found,path,base,hashname,hashtype)
23496
23574
   if find(found,path) then
23497
23575
    local full=methodhandler('concatinators',hashtype,hashname,found,base)
23531
23609
    end
23532
23610
   end
23533
23611
  end
23534
 
  local hashes=instance.hashes
23535
23612
  for k=1,#hashes do
23536
23613
   local hash=hashes[k]
23537
23614
   local hashname=hash.name
23561
23638
function resolvers.findwildcardfile(filename)
23562
23639
 return findwildcardfiles(filename,false)[1] or ""
23563
23640
end
 
23641
do
 
23642
 local starttiming=statistics.starttiming
 
23643
 local stoptiming=statistics.stoptiming
 
23644
 local elapsedtime=statistics.elapsedtime
 
23645
 function resolvers.starttiming()
 
23646
  starttiming(instance)
 
23647
 end
 
23648
 function resolvers.stoptiming()
 
23649
  stoptiming(instance)
 
23650
 end
 
23651
 function resolvers.loadtime()
 
23652
  return elapsedtime(instance)
 
23653
 end
 
23654
end
23564
23655
function resolvers.automount()
23565
23656
end
23566
 
function resolvers.starttiming()
23567
 
 statistics.starttiming(instance)
23568
 
end
23569
 
function resolvers.stoptiming()
23570
 
 statistics.stoptiming(instance)
23571
 
end
23572
23657
function resolvers.load(option)
23573
23658
 resolvers.starttiming()
23574
23659
 identify_configuration_files()
23581
23666
 local files=instance.files
23582
23667
 return files and next(files) and true
23583
23668
end
23584
 
function resolvers.loadtime()
23585
 
 return statistics.elapsedtime(instance)
23586
 
end
23587
23669
local function report(str)
23588
23670
 if trace_locating then
23589
23671
  report_resolving(str) 
23613
23695
 end
23614
23696
end
23615
23697
function resolvers.showpath(str)  
23616
 
 return joinpath(resolvers.expandedpathlist(resolvers.formatofvariable(str)))
 
23698
 return joinpath(expandedpathlist(resolvers.formatofvariable(str)))
23617
23699
end
23618
23700
function resolvers.registerfile(files,name,path)
23619
23701
 if files[name] then
23627
23709
 end
23628
23710
end
23629
23711
function resolvers.dowithpath(name,func)
23630
 
 local pathlist=resolvers.expandedpathlist(name)
 
23712
 local pathlist=expandedpathlist(name)
23631
23713
 for i=1,#pathlist do
23632
23714
  func("^"..cleanpath(pathlist[i]))
23633
23715
 end
23641
23723
 local fullname=addsuffix(barename,"fmt")
23642
23724
 local fmtname=caches.getfirstreadablefile(fullname,"formats",engine) or ""
23643
23725
 if fmtname=="" then
23644
 
  fmtname=resolvers.findfile(fullname)
 
23726
  fmtname=findfile(fullname)
23645
23727
  fmtname=cleanpath(fmtname)
23646
23728
 end
23647
23729
 if fmtname~="" then
23660
23742
 return nil,nil
23661
23743
end
23662
23744
function resolvers.booleanvariable(str,default)
23663
 
 local b=resolvers.expansion(str)
 
23745
 local b=expansion(str)
23664
23746
 if b=="" then
23665
23747
  return default
23666
23748
 else
23670
23752
end
23671
23753
function resolvers.dowithfilesintree(pattern,handle,before,after) 
23672
23754
 local hashes=instance.hashes
 
23755
 local files=instance.files
23673
23756
 for i=1,#hashes do
23674
23757
  local hash=hashes[i]
23675
23758
  local blobtype=hash.type
23681
23764
   if before then
23682
23765
    before(blobtype,blobpath,pattern)
23683
23766
   end
23684
 
   for path,name in filtered(instance.files[blobpath],pattern) do
 
23767
   for path,name in filtered(files[blobpath],pattern) do
23685
23768
    if type(path)=="string" then
23686
23769
     checked=checked+1
23687
23770
     if handle(blobtype,blobpath,path,name) then
23702
23785
  end
23703
23786
 end
23704
23787
end
23705
 
local obsolete=resolvers.obsolete or {}
23706
 
resolvers.obsolete=obsolete
23707
 
resolvers.find_file=resolvers.findfile obsolete.find_file=resolvers.findfile
23708
 
resolvers.find_files=resolvers.findfiles   obsolete.find_files=resolvers.findfiles
23709
23788
function resolvers.knownvariables(pattern)
23710
23789
 if instance then
23711
23790
  local environment=instance.environment
23739
23818
 
23740
23819
package.loaded["data-pre"] = package.loaded["data-pre"] or true
23741
23820
 
 
23821
-- original size: 5088, stripped down to: 3144
23742
23822
 
23743
23823
if not modules then modules={} end modules ['data-pre']={
23744
23824
 version=1.001,
23748
23827
 copyright="PRAGMA ADE / ConTeXt Development Team",
23749
23828
 license="see context related readme files"
23750
23829
}
 
23830
local insert,remove=table.insert,table.remove
23751
23831
local resolvers=resolvers
23752
23832
local prefixes=resolvers.prefixes
23753
23833
local cleanpath=resolvers.cleanpath
23825
23905
prefixes.full=prefixes.locate
23826
23906
prefixes.file=prefixes.filename
23827
23907
prefixes.path=prefixes.pathname
 
23908
local inputstack={}
 
23909
local stackpath=resolvers.stackpath
23828
23910
local function toppath()
23829
 
 local inputstack=resolvers.inputstack 
23830
23911
 if not inputstack then      
23831
23912
  return "."
23832
23913
 end
23838
23919
 end
23839
23920
end
23840
23921
local function jobpath()
23841
 
 local path=resolvers.stackpath()
 
23922
 local path=stackpath()
23842
23923
 if not path or path=="" then
23843
23924
  return "."
23844
23925
 else
23845
23926
  return path
23846
23927
 end
23847
23928
end
 
23929
local function pushinputname(name)
 
23930
 insert(inputstack,name)
 
23931
end
 
23932
local function popinputname(name)
 
23933
 return remove(inputstack)
 
23934
end
23848
23935
resolvers.toppath=toppath
23849
23936
resolvers.jobpath=jobpath
 
23937
resolvers.pushinputname=pushinputname
 
23938
resolvers.popinputname=popinputname
23850
23939
prefixes.toppath=function(str) return cleanpath(joinpath(toppath(),str)) end 
23851
23940
prefixes.jobpath=function(str) return cleanpath(joinpath(jobpath(),str)) end 
23852
23941
resolvers.setdynamic("toppath")
23889
23978
 
23890
23979
package.loaded["data-out"] = package.loaded["data-out"] or true
23891
23980
 
 
23981
-- original size: 551, stripped down to: 470
23892
23982
 
23893
23983
if not modules then modules={} end modules ['data-out']={
23894
23984
 version=1.001,
23912
24001
 
23913
24002
package.loaded["data-fil"] = package.loaded["data-fil"] or true
23914
24003
 
 
24004
-- original size: 4365, stripped down to: 3588
23915
24005
 
23916
24006
if not modules then modules={} end modules ['data-fil']={
23917
24007
 version=1.001,
23921
24010
 copyright="PRAGMA ADE / ConTeXt Development Team",
23922
24011
 license="see context related readme files"
23923
24012
}
 
24013
local ioopen=io.open
 
24014
local isdir=lfs.isdir
23924
24015
local trace_locating=false  trackers.register("resolvers.locating",function(v) trace_locating=v end)
23925
24016
local report_files=logs.reporter("resolvers","files")
23926
24017
local resolvers=resolvers
23927
24018
local resolveprefix=resolvers.resolve
23928
 
local finders,openers,loaders,savers=resolvers.finders,resolvers.openers,resolvers.loaders,resolvers.savers
23929
 
local locators,hashers,generators,concatinators=resolvers.locators,resolvers.hashers,resolvers.generators,resolvers.concatinators
 
24019
local findfile=resolvers.findfile
 
24020
local scanfiles=resolvers.scanfiles
 
24021
local registerfilehash=resolvers.registerfilehash
 
24022
local appendhash=resolvers.appendhash
 
24023
local loadcachecontent=caches.loadcontent
23930
24024
local checkgarbage=utilities.garbagecollector and utilities.garbagecollector.check
23931
 
function locators.file(specification)
 
24025
function resolvers.locators.file(specification)
23932
24026
 local filename=specification.filename
23933
24027
 local realname=resolveprefix(filename) 
23934
 
 if realname and realname~='' and lfs.isdir(realname) then
 
24028
 if realname and realname~='' and isdir(realname) then
23935
24029
  if trace_locating then
23936
24030
   report_files("file locator %a found as %a",filename,realname)
23937
24031
  end
23938
 
  resolvers.appendhash('file',filename,true) 
 
24032
  appendhash('file',filename,true) 
23939
24033
 elseif trace_locating then
23940
24034
  report_files("file locator %a not found",filename)
23941
24035
 end
23942
24036
end
23943
 
function hashers.file(specification)
23944
 
 local pathname=specification.filename
23945
 
 local content=caches.loadcontent(pathname,'files')
23946
 
 resolvers.registerfilehash(pathname,content,content==nil)
23947
 
end
23948
 
function generators.file(specification)
23949
 
 local pathname=specification.filename
23950
 
 local content=resolvers.scanfiles(pathname,false,true) 
23951
 
 resolvers.registerfilehash(pathname,content,true)
23952
 
end
23953
 
concatinators.file=file.join
 
24037
function resolvers.hashers.file(specification)
 
24038
 local pathname=specification.filename
 
24039
 local content=loadcachecontent(pathname,'files')
 
24040
 registerfilehash(pathname,content,content==nil)
 
24041
end
 
24042
function resolvers.generators.file(specification)
 
24043
 local pathname=specification.filename
 
24044
 local content=scanfiles(pathname,false,true) 
 
24045
 registerfilehash(pathname,content,true)
 
24046
end
 
24047
resolvers.concatinators.file=file.join
 
24048
local finders=resolvers.finders
 
24049
local notfound=finders.notfound
23954
24050
function finders.file(specification,filetype)
23955
24051
 local filename=specification.filename
23956
 
 local foundname=resolvers.findfile(filename,filetype)
 
24052
 local foundname=findfile(filename,filetype)
23957
24053
 if foundname and foundname~="" then
23958
24054
  if trace_locating then
23959
24055
   report_files("file finder: %a found",filename)
23963
24059
  if trace_locating then
23964
24060
   report_files("file finder: %a not found",filename)
23965
24061
  end
23966
 
  return finders.notfound()
 
24062
  return notfound()
23967
24063
 end
23968
24064
end
23969
 
function openers.helpers.textopener(tag,filename,f)
 
24065
local openers=resolvers.openers
 
24066
local notfound=openers.notfound
 
24067
local overloaded=false
 
24068
local function textopener(tag,filename,f)
23970
24069
 return {
23971
 
  reader=function()         return f:read () end,
23972
 
  close=function() logs.show_close(filename) return f:close() end,
 
24070
  reader=function() return f:read () end,
 
24071
  close=function() return f:close() end,
23973
24072
 }
23974
24073
end
 
24074
function openers.helpers.textopener(...)
 
24075
 return textopener(...)
 
24076
end
 
24077
function openers.helpers.settextopener(opener)
 
24078
 if overloaded then
 
24079
  report_files("file opener: %s overloaded","already")
 
24080
 else
 
24081
  if trace_locating then
 
24082
   report_files("file opener: %s overloaded","once")
 
24083
  end
 
24084
  overloaded=true
 
24085
  textopener=opener
 
24086
 end
 
24087
end
23975
24088
function openers.file(specification,filetype)
23976
24089
 local filename=specification.filename
23977
24090
 if filename and filename~="" then
23978
 
  local f=io.open(filename,"r")
 
24091
  local f=ioopen(filename,"r")
23979
24092
  if f then
23980
24093
   if trace_locating then
23981
24094
    report_files("file opener: %a opened",filename)
23982
24095
   end
23983
 
   return openers.helpers.textopener("file",filename,f)
 
24096
   return textopener("file",filename,f)
23984
24097
  end
23985
24098
 end
23986
24099
 if trace_locating then
23987
24100
  report_files("file opener: %a not found",filename)
23988
24101
 end
23989
 
 return openers.notfound()
 
24102
 return notfound()
23990
24103
end
 
24104
local loaders=resolvers.loaders
 
24105
local notfound=loaders.notfound
23991
24106
function loaders.file(specification,filetype)
23992
24107
 local filename=specification.filename
23993
24108
 if filename and filename~="" then
23994
 
  local f=io.open(filename,"rb")
 
24109
  local f=ioopen(filename,"rb")
23995
24110
  if f then
23996
 
   logs.show_load(filename)
23997
24111
   if trace_locating then
23998
24112
    report_files("file loader: %a loaded",filename)
23999
24113
   end
24010
24124
 if trace_locating then
24011
24125
  report_files("file loader: %a not found",filename)
24012
24126
 end
24013
 
 return loaders.notfound()
 
24127
 return notfound()
24014
24128
end
24015
24129
 
24016
24130
 
24020
24134
 
24021
24135
package.loaded["data-con"] = package.loaded["data-con"] or true
24022
24136
 
 
24137
-- original size: 5388, stripped down to: 3685
24023
24138
 
24024
24139
if not modules then modules={} end modules ['data-con']={
24025
24140
 version=1.100,
24029
24143
 copyright="PRAGMA ADE / ConTeXt Development Team",
24030
24144
 license="see context related readme files"
24031
24145
}
 
24146
local setmetatable=setmetatable
24032
24147
local format,lower,gsub=string.format,string.lower,string.gsub
24033
24148
local trace_cache=false  trackers.register("resolvers.cache",function(v) trace_cache=v end)
24034
24149
local trace_containers=false  trackers.register("resolvers.containers",function(v) trace_containers=v end)
24036
24151
containers=containers or {}
24037
24152
local containers=containers
24038
24153
containers.usecache=true
 
24154
local getwritablepath=caches.getwritablepath
 
24155
local getreadablepaths=caches.getreadablepaths
 
24156
local cacheiswritable=caches.is_writable
 
24157
local loaddatafromcache=caches.loaddata
 
24158
local savedataincache=caches.savedata
24039
24159
local report_containers=logs.reporter("resolvers","containers")
24040
24160
local allocated={}
24041
24161
local mt={
24042
24162
 __index=function(t,k)
24043
24163
  if k=="writable" then
24044
 
   local writable=caches.getwritablepath(t.category,t.subcategory) or { "." }
 
24164
   local writable=getwritablepath(t.category,t.subcategory) or { "." }
24045
24165
   t.writable=writable
24046
24166
   return writable
24047
24167
  elseif k=="readables" then
24048
 
   local readables=caches.getreadablepaths(t.category,t.subcategory) or { "." }
 
24168
   local readables=getreadablepaths(t.category,t.subcategory) or { "." }
24049
24169
   t.readables=readables
24050
24170
   return readables
24051
24171
  end
24076
24196
 end
24077
24197
end
24078
24198
function containers.is_usable(container,name)
24079
 
 return container.enabled and caches and caches.is_writable(container.writable,name)
 
24199
 return container.enabled and caches and cacheiswritable(container.writable,name)
24080
24200
end
24081
24201
function containers.is_valid(container,name)
24082
24202
 if name and name~="" then
24090
24210
 local storage=container.storage
24091
24211
 local stored=storage[name]
24092
24212
 if not stored and container.enabled and caches and containers.usecache then
24093
 
  stored=caches.loaddata(container.readables,name,container.writable)
 
24213
  stored=loaddatafromcache(container.readables,name,container.writable)
24094
24214
  if stored and stored.cache_version==container.version then
24095
24215
   if trace_cache or trace_containers then
24096
24216
    report_containers("action %a, category %a, name %a","load",container.subcategory,name)
24106
24226
 end
24107
24227
 return stored
24108
24228
end
24109
 
function containers.write(container,name,data)
 
24229
function containers.write(container,name,data,fast)
24110
24230
 if data then
24111
24231
  data.cache_version=container.version
24112
24232
  if container.enabled and caches then
24113
 
   local unique,shared=data.unique,data.shared
24114
 
   data.unique,data.shared=nil,nil
24115
 
   caches.savedata(container.writable,name,data)
 
24233
   local unique=data.unique
 
24234
   local shared=data.shared
 
24235
   data.unique=nil
 
24236
   data.shared=nil
 
24237
   savedataincache(container.writable,name,data,fast)
24116
24238
   if trace_cache or trace_containers then
24117
24239
    report_containers("action %a, category %a, name %a","save",container.subcategory,name)
24118
24240
   end
24119
 
   data.unique,data.shared=unique,shared
 
24241
   data.unique=unique
 
24242
   data.shared=shared
24120
24243
  end
24121
24244
  if trace_cache or trace_containers then
24122
24245
   report_containers("action %a, category %a, name %a","store",container.subcategory,name)
24139
24262
 
24140
24263
package.loaded["data-use"] = package.loaded["data-use"] or true
24141
24264
 
 
24265
-- original size: 5790, stripped down to: 2910
24142
24266
 
24143
24267
if not modules then modules={} end modules ['data-use']={
24144
24268
 version=1.001,
24148
24271
 copyright="PRAGMA ADE / ConTeXt Development Team",
24149
24272
 license="see context related readme files"
24150
24273
}
24151
 
local format,lower,gsub,find=string.format,string.lower,string.gsub,string.find
 
24274
local format=string.format
24152
24275
local trace_locating=false  trackers.register("resolvers.locating",function(v) trace_locating=v end)
24153
24276
local report_mounts=logs.reporter("resolvers","mounts")
24154
24277
local resolvers=resolvers
24155
 
resolvers.automounted=resolvers.automounted or {}
24156
 
function resolvers.automount(usecache)
24157
 
 local mountpaths=resolvers.cleanpathlist(resolvers.expansion('TEXMFMOUNT'))
24158
 
 if (not mountpaths or #mountpaths==0) and usecache then
24159
 
  mountpaths=caches.getreadablepaths("mount")
24160
 
 end
24161
 
 if mountpaths and #mountpaths>0 then
24162
 
  resolvers.starttiming()
24163
 
  for k=1,#mountpaths do
24164
 
   local root=mountpaths[k]
24165
 
   local f=io.open(root.."/url.tmi")
24166
 
   if f then
24167
 
    for line in f:lines() do
24168
 
     if line then
24169
 
      if find(line,"^[%%#%-]") then
24170
 
      elseif find(line,"^zip://") then
24171
 
       if trace_locating then
24172
 
        report_mounts("mounting %a",line)
24173
 
       end
24174
 
       table.insert(resolvers.automounted,line)
24175
 
       resolvers.usezipfile(line)
24176
 
      end
24177
 
     end
24178
 
    end
24179
 
    f:close()
24180
 
   end
24181
 
  end
24182
 
  resolvers.stoptiming()
24183
 
 end
24184
 
end
 
24278
local findfile=resolvers.findfile
24185
24279
statistics.register("used config file",function() return caches.configfiles() end)
24186
24280
statistics.register("used cache path",function() return caches.usedpaths() end)
24187
24281
function statistics.savefmtstatus(texname,formatbanner,sourcefile,kind,banner) 
24191
24285
  local luvdata={
24192
24286
   enginebanner=enginebanner,
24193
24287
   formatbanner=formatbanner,
24194
 
   sourcehash=md5.hex(io.loaddata(resolvers.findfile(sourcefile)) or "unknown"),
 
24288
   sourcehash=md5.hex(io.loaddata(findfile(sourcefile)) or "unknown"),
24195
24289
   sourcefile=sourcefile,
24196
24290
   luaversion=LUAVERSION,
24197
24291
   formatid=LUATEXFORMATID,
24215
24309
  if lfs.isfile(luvname) then
24216
24310
   local luv=dofile(luvname)
24217
24311
   if luv and luv.sourcefile then
24218
 
    local sourcehash=md5.hex(io.loaddata(resolvers.findfile(luv.sourcefile)) or "unknown")
 
24312
    local sourcehash=md5.hex(io.loaddata(findfile(luv.sourcefile)) or "unknown")
24219
24313
    local luvbanner=luv.enginebanner or "?"
24220
24314
    if luvbanner~=enginebanner then
24221
24315
     return format("engine mismatch (luv: %s <> bin: %s)",luvbanner,enginebanner)
24256
24350
 
24257
24351
package.loaded["data-zip"] = package.loaded["data-zip"] or true
24258
24352
 
 
24353
-- original size: 10725, stripped down to: 7949
24259
24354
 
24260
24355
if not modules then modules={} end modules ['data-zip']={
24261
24356
 version=1.001,
24269
24363
local trace_locating=false  trackers.register("resolvers.locating",function(v) trace_locating=v end)
24270
24364
local report_zip=logs.reporter("resolvers","zip")
24271
24365
local resolvers=resolvers
 
24366
local findfile=resolvers.findfile
 
24367
local registerfile=resolvers.registerfile
 
24368
local splitmethod=resolvers.splitmethod
 
24369
local prependhash=resolvers.prependhash
 
24370
local starttiming=resolvers.starttiming
 
24371
local extendtexmf=resolvers.extendtexmfvariable
 
24372
local stoptiming=resolvers.stoptiming
 
24373
local urlquery=url.query
24272
24374
zip=zip or {}
24273
24375
local zip=zip
24274
24376
local archives=zip.archives or {}
24283
24385
 closezip=zipfiles.close
24284
24386
 validfile=zipfiles.found
24285
24387
 wholefile=zipfiles.unzip
 
24388
 local listzip=zipfiles.list
24286
24389
 traversezip=function(zfile)
24287
 
  return ipairs(zipfiles.list(zfile))
 
24390
  return ipairs(listzip(zfile))
24288
24391
 end
24289
24392
 local streams=utilities.streams
24290
24393
 local openstream=streams.open
24341
24444
  return str
24342
24445
 end
24343
24446
end
24344
 
function zip.openarchive(name)
 
24447
local function openarchive(name)
24345
24448
 if not name or name=="" then
24346
24449
  return nil
24347
24450
 else
24348
24451
  local arch=archives[name]
24349
24452
  if not arch then
24350
 
     local full=resolvers.findfile(name) or ""
 
24453
     local full=findfile(name) or ""
24351
24454
     arch=full~="" and openzip(full) or false
24352
24455
     archives[name]=arch
24353
24456
  end
24354
24457
    return arch
24355
24458
 end
24356
24459
end
24357
 
function zip.closearchive(name)
 
24460
local function closearchive(name)
24358
24461
 if not name or (name=="" and archives[name]) then
24359
24462
  closezip(archives[name])
24360
24463
  archives[name]=nil
24361
24464
 end
24362
24465
end
 
24466
zip.openarchive=openarchive
 
24467
zip.closearchive=closearchive
24363
24468
function resolvers.locators.zip(specification)
24364
24469
 local archive=specification.filename
24365
 
 local zipfile=archive and archive~="" and zip.openarchive(archive) 
 
24470
 local zipfile=archive and archive~="" and openarchive(archive) 
24366
24471
 if trace_locating then
24367
24472
  if zipfile then
24368
24473
   report_zip("locator: archive %a found",archive)
24371
24476
  end
24372
24477
 end
24373
24478
end
24374
 
function resolvers.hashers.zip(specification)
24375
 
 local archive=specification.filename
24376
 
 if trace_locating then
24377
 
  report_zip("loading file %a",archive)
24378
 
 end
24379
 
 resolvers.usezipfile(specification.original)
24380
 
end
24381
24479
function resolvers.concatinators.zip(zipfile,path,name) 
24382
24480
 if not path or path=="" then
24383
24481
  return format('%s?name=%s',zipfile,name)
24385
24483
  return format('%s?name=%s/%s',zipfile,path,name)
24386
24484
 end
24387
24485
end
24388
 
function resolvers.finders.zip(specification)
 
24486
local finders=resolvers.finders
 
24487
local notfound=finders.notfound
 
24488
function finders.zip(specification)
24389
24489
 local original=specification.original
24390
24490
 local archive=specification.filename
24391
24491
 if archive then
24392
 
  local query=url.query(specification.query)
 
24492
  local query=urlquery(specification.query)
24393
24493
  local queryname=query.name
24394
24494
  if queryname then
24395
 
   local zfile=zip.openarchive(archive)
 
24495
   local zfile=openarchive(archive)
24396
24496
   if zfile then
24397
24497
    if trace_locating then
24398
24498
     report_zip("finder: archive %a found",archive)
24413
24513
 if trace_locating then
24414
24514
  report_zip("finder: %a not found",original)
24415
24515
 end
24416
 
 return resolvers.finders.notfound()
 
24516
 return notfound()
24417
24517
end
24418
 
function resolvers.openers.zip(specification)
 
24518
local openers=resolvers.openers
 
24519
local notfound=openers.notfound
 
24520
local textopener=openers.helpers.textopener
 
24521
function openers.zip(specification)
24419
24522
 local original=specification.original
24420
24523
 local archive=specification.filename
24421
24524
 if archive then
24422
 
  local query=url.query(specification.query)
 
24525
  local query=urlquery(specification.query)
24423
24526
  local queryname=query.name
24424
24527
  if queryname then
24425
 
   local zfile=zip.openarchive(archive)
 
24528
   local zfile=openarchive(archive)
24426
24529
   if zfile then
24427
24530
    if trace_locating then
24428
24531
     report_zip("opener; archive %a opened",archive)
24432
24535
     if trace_locating then
24433
24536
      report_zip("opener: file %a found",queryname)
24434
24537
     end
24435
 
     return resolvers.openers.helpers.textopener('zip',original,handle)
 
24538
     return textopener('zip',original,handle)
24436
24539
    elseif trace_locating then
24437
24540
     report_zip("opener: file %a not found",queryname)
24438
24541
    end
24444
24547
 if trace_locating then
24445
24548
  report_zip("opener: %a not found",original)
24446
24549
 end
24447
 
 return resolvers.openers.notfound()
 
24550
 return notfound()
24448
24551
end
24449
 
function resolvers.loaders.zip(specification)
 
24552
local loaders=resolvers.loaders
 
24553
local notfound=loaders.notfound
 
24554
function loaders.zip(specification)
24450
24555
 local original=specification.original
24451
24556
 local archive=specification.filename
24452
24557
 if archive then
24453
 
  local query=url.query(specification.query)
 
24558
  local query=urlquery(specification.query)
24454
24559
  local queryname=query.name
24455
24560
  if queryname then
24456
 
   local zfile=zip.openarchive(archive)
 
24561
   local zfile=openarchive(archive)
24457
24562
   if zfile then
24458
24563
    if trace_locating then
24459
24564
     report_zip("loader: archive %a opened",archive)
24460
24565
    end
24461
24566
    local data=wholefile(zfile,queryname)
24462
24567
    if data then
24463
 
     logs.show_load(original)
24464
24568
     if trace_locating then
24465
24569
      report_zip("loader; file %a loaded",original)
24466
24570
     end
24476
24580
 if trace_locating then
24477
24581
  report_zip("loader: %a not found",original)
24478
24582
 end
24479
 
 return resolvers.openers.notfound()
24480
 
end
24481
 
function resolvers.usezipfile(archive)
24482
 
 local specification=resolvers.splitmethod(archive) 
24483
 
 local archive=specification.filename
24484
 
 if archive and not registeredfiles[archive] then
24485
 
  local z=zip.openarchive(archive)
24486
 
  if z then
24487
 
   local tree=url.query(specification.query).tree or ""
24488
 
   if trace_locating then
24489
 
    report_zip("registering: archive %a",archive)
24490
 
   end
24491
 
   resolvers.starttiming()
24492
 
   resolvers.prependhash('zip',archive)
24493
 
   resolvers.extendtexmfvariable(archive) 
24494
 
   registeredfiles[archive]=z
24495
 
   resolvers.registerfilehash(archive,resolvers.registerzipfile(z,tree))
24496
 
   resolvers.stoptiming()
24497
 
  elseif trace_locating then
24498
 
   report_zip("registering: unknown archive %a",archive)
24499
 
  end
24500
 
 elseif trace_locating then
24501
 
  report_zip("registering: archive %a not found",archive)
24502
 
 end
24503
 
end
24504
 
function resolvers.registerzipfile(z,tree)
 
24583
 return notfound()
 
24584
end
 
24585
local function registerzipfile(z,tree)
24505
24586
 local names={}
24506
24587
 local files={} 
24507
24588
 local remap={} 
24508
24589
 local n=0
24509
24590
 local filter=tree=="" and "^(.+)/(.-)$" or format("^%s/(.+)/(.-)$",tree)
24510
 
 local register=resolvers.registerfile
24511
24591
 if trace_locating then
24512
24592
  report_zip("registering: using filter %a",filter)
24513
24593
 end
 
24594
 starttiming()
24514
24595
 for i in traversezip(z) do
24515
24596
  local filename=i.filename
24516
24597
  local path,name=match(filename,filter)
24517
24598
  if not path then
24518
24599
   n=n+1
24519
 
   register(names,filename,"")
 
24600
   registerfile(names,filename,"")
24520
24601
   local usedname=lower(filename)
24521
24602
   files[usedname]=""
24522
24603
   if usedname~=filename then
24533
24614
  else
24534
24615
  end
24535
24616
 end
 
24617
 stoptiming()
24536
24618
 report_zip("registering: %s files registered",n)
24537
24619
 return {
24538
24620
  files=files,
24539
24621
  remap=remap,
24540
24622
 }
24541
24623
end
 
24624
local function usezipfile(archive)
 
24625
 local specification=splitmethod(archive) 
 
24626
 local archive=specification.filename
 
24627
 if archive and not registeredfiles[archive] then
 
24628
  local z=openarchive(archive)
 
24629
  if z then
 
24630
   local tree=urlquery(specification.query).tree or ""
 
24631
   if trace_locating then
 
24632
    report_zip("registering: archive %a",archive)
 
24633
   end
 
24634
   prependhash('zip',archive)
 
24635
   extendtexmf(archive) 
 
24636
   registeredfiles[archive]=z
 
24637
   registerfilehash(archive,registerzipfile(z,tree))
 
24638
  elseif trace_locating then
 
24639
   report_zip("registering: unknown archive %a",archive)
 
24640
  end
 
24641
 elseif trace_locating then
 
24642
  report_zip("registering: archive %a not found",archive)
 
24643
 end
 
24644
end
 
24645
resolvers.usezipfile=usezipfile
 
24646
resolvers.registerzipfile=registerzipfile
 
24647
function resolvers.hashers.zip(specification)
 
24648
 local archive=specification.filename
 
24649
 if trace_locating then
 
24650
  report_zip("loading file %a",archive)
 
24651
 end
 
24652
 usezipfile(specification.original)
 
24653
end
24542
24654
 
24543
24655
 
24544
24656
end -- of closure
24547
24659
 
24548
24660
package.loaded["data-tre"] = package.loaded["data-tre"] or true
24549
24661
 
 
24662
-- original size: 9444, stripped down to: 5650
24550
24663
 
24551
24664
if not modules then modules={} end modules ['data-tre']={
24552
24665
 version=1.001,
24563
24675
local trace_locating=false  trackers.register("resolvers.locating",function(v) trace_locating=v end)
24564
24676
local report_trees=logs.reporter("resolvers","trees")
24565
24677
local resolvers=resolvers
24566
 
local resolveprefix=resolvers.resolve
24567
 
local notfound=resolvers.finders.notfound
24568
 
local lookup=resolvers.get_from_content
24569
 
local collectors={}
24570
 
local found={}
24571
 
function resolvers.finders.tree(specification) 
24572
 
 local spec=specification.filename
24573
 
 local okay=found[spec]
24574
 
 if okay==nil then
24575
 
  if spec~="" then
24576
 
   local path=dirname(spec)
24577
 
   local name=basename(spec)
24578
 
   if path=="" then
24579
 
    path="."
24580
 
   end
24581
 
   local names=collectors[path]
24582
 
   if not names then
24583
 
    local pattern=find(path,"/%*+$") and path or (path.."/*")
24584
 
    names=globdir(pattern)
24585
 
    collectors[path]=names
24586
 
   end
24587
 
   local pattern="/"..gsub(name,"([%.%-%+])","%%%1").."$"
24588
 
   for i=1,#names do
24589
 
    local fullname=names[i]
24590
 
    if find(fullname,pattern) then
24591
 
     found[spec]=fullname
24592
 
     return fullname
24593
 
    end
24594
 
   end
24595
 
   local pattern=lower(pattern)
24596
 
   for i=1,#names do
24597
 
    local fullname=lower(names[i])
24598
 
    if find(fullname,pattern) then
24599
 
     if isfile(fullname) then
 
24678
local finders=resolvers.finders
 
24679
local openers=resolvers.openers
 
24680
local loaders=resolvers.loaders
 
24681
local locators=resolvers.locators
 
24682
local hashers=resolvers.hashers
 
24683
local generators=resolvers.generators
 
24684
do
 
24685
 local collectors={}
 
24686
 local found={}
 
24687
 local notfound=finders.notfound
 
24688
 function finders.tree(specification) 
 
24689
  local spec=specification.filename
 
24690
  local okay=found[spec]
 
24691
  if okay==nil then
 
24692
   if spec~="" then
 
24693
    local path=dirname(spec)
 
24694
    local name=basename(spec)
 
24695
    if path=="" then
 
24696
     path="."
 
24697
    end
 
24698
    local names=collectors[path]
 
24699
    if not names then
 
24700
     local pattern=find(path,"/%*+$") and path or (path.."/*")
 
24701
     names=globdir(pattern)
 
24702
     collectors[path]=names
 
24703
    end
 
24704
    local pattern="/"..gsub(name,"([%.%-%+])","%%%1").."$"
 
24705
    for i=1,#names do
 
24706
     local fullname=names[i]
 
24707
     if find(fullname,pattern) then
24600
24708
      found[spec]=fullname
24601
24709
      return fullname
24602
 
     else
24603
 
      break
24604
 
     end
24605
 
    end
24606
 
   end
24607
 
  end
24608
 
  okay=notfound() 
24609
 
  found[spec]=okay
24610
 
 end
24611
 
 return okay
24612
 
end
24613
 
function resolvers.locators.tree(specification)
24614
 
 local name=specification.filename
24615
 
 local realname=resolveprefix(name) 
24616
 
 if realname and realname~='' and isdir(realname) then
 
24710
     end
 
24711
    end
 
24712
    local pattern=lower(pattern)
 
24713
    for i=1,#names do
 
24714
     local fullname=lower(names[i])
 
24715
     if find(fullname,pattern) then
 
24716
      if isfile(fullname) then
 
24717
       found[spec]=fullname
 
24718
       return fullname
 
24719
      else
 
24720
       break
 
24721
      end
 
24722
     end
 
24723
    end
 
24724
   end
 
24725
   okay=notfound() 
 
24726
   found[spec]=okay
 
24727
  end
 
24728
  return okay
 
24729
 end
 
24730
end
 
24731
do
 
24732
 local resolveprefix=resolvers.resolve
 
24733
 local appendhash=resolvers.appendhash
 
24734
 local function dolocate(specification)
 
24735
  local name=specification.filename
 
24736
  local realname=resolveprefix(name) 
 
24737
  if realname and realname~='' and isdir(realname) then
 
24738
   if trace_locating then
 
24739
    report_trees("locator %a found",realname)
 
24740
   end
 
24741
   appendhash('tree',name,false) 
 
24742
  elseif trace_locating then
 
24743
   report_trees("locator %a not found",name)
 
24744
  end
 
24745
 end
 
24746
 locators.tree=dolocate
 
24747
 locators.dirlist=dolocate
 
24748
 locators.dirfile=dolocate
 
24749
end
 
24750
do
 
24751
 local filegenerator=generators.file
 
24752
 generators.dirlist=filegenerator
 
24753
 generators.dirfile=filegenerator
 
24754
end
 
24755
do
 
24756
 local filegenerator=generators.file
 
24757
 local methodhandler=resolvers.methodhandler
 
24758
 local function dohash(specification)
 
24759
  local name=specification.filename
24617
24760
  if trace_locating then
24618
 
   report_trees("locator %a found",realname)
24619
 
  end
24620
 
  resolvers.appendhash('tree',name,false) 
24621
 
 elseif trace_locating then
24622
 
  report_trees("locator %a not found",name)
24623
 
 end
24624
 
end
24625
 
function resolvers.hashers.tree(specification)
24626
 
 local name=specification.filename
24627
 
 if trace_locating then
24628
 
  report_trees("analyzing %a",name)
24629
 
 end
24630
 
 resolvers.methodhandler("hashers",name)
24631
 
 resolvers.generators.file(specification)
24632
 
end
24633
 
local collectors={}
24634
 
local splitter=lpeg.splitat("/**/")
24635
 
local stripper=lpeg.replacer { [P("/")*P("*")^1*P(-1)]="" }
24636
 
table.setmetatableindex(collectors,function(t,k)
24637
 
 local rootname=lpegmatch(stripper,k)
24638
 
 local dataname=joinname(rootname,"dirlist")
24639
 
 local content=caches.loadcontent(dataname,"files",dataname)
24640
 
 if not content then
24641
 
  content=resolvers.scanfiles(rootname,nil,nil,false,true) 
24642
 
  caches.savecontent(dataname,"files",content,dataname)
24643
 
 end
24644
 
 t[k]=content
24645
 
 return content
24646
 
end)
24647
 
local function checked(root,p,n)
24648
 
 if p then
24649
 
  if type(p)=="table" then
24650
 
   for i=1,#p do
24651
 
    local fullname=joinname(root,p[i],n)
 
24761
   report_trees("analyzing %a",name)
 
24762
  end
 
24763
  methodhandler("hashers",name)
 
24764
  filegenerator(specification)
 
24765
 end
 
24766
 hashers.tree=dohash
 
24767
 hashers.dirlist=dohash
 
24768
 hashers.dirfile=dohash
 
24769
end
 
24770
local resolve  do
 
24771
 local collectors={}
 
24772
 local splitter=lpeg.splitat("/**/")
 
24773
 local stripper=lpeg.replacer { [P("/")*P("*")^1*P(-1)]="" }
 
24774
 local loadcontent=caches.loadcontent
 
24775
 local savecontent=caches.savecontent
 
24776
 local notfound=finders.notfound
 
24777
 local scanfiles=resolvers.scanfiles
 
24778
 local lookup=resolvers.get_from_content
 
24779
 table.setmetatableindex(collectors,function(t,k)
 
24780
  local rootname=lpegmatch(stripper,k)
 
24781
  local dataname=joinname(rootname,"dirlist")
 
24782
  local content=loadcontent(dataname,"files",dataname)
 
24783
  if not content then
 
24784
   content=scanfiles(rootname,nil,nil,false,true) 
 
24785
   savecontent(dataname,"files",content,dataname)
 
24786
  end
 
24787
  t[k]=content
 
24788
  return content
 
24789
 end)
 
24790
 local function checked(root,p,n)
 
24791
  if p then
 
24792
   if type(p)=="table" then
 
24793
    for i=1,#p do
 
24794
     local fullname=joinname(root,p[i],n)
 
24795
     if isfile(fullname) then 
 
24796
      return fullname
 
24797
     end
 
24798
    end
 
24799
   else
 
24800
    local fullname=joinname(root,p,n)
24652
24801
    if isfile(fullname) then 
24653
24802
     return fullname
24654
24803
    end
24655
24804
   end
 
24805
  end
 
24806
  return notfound()
 
24807
 end
 
24808
 resolve=function(specification) 
 
24809
  local filename=specification.filename
 
24810
  if filename~="" then
 
24811
   local root,rest=lpegmatch(splitter,filename)
 
24812
   if root and rest then
 
24813
    local path,name=dirname(rest),basename(rest)
 
24814
    if name~=rest then
 
24815
     local content=collectors[root]
 
24816
     local p,n=lookup(content,name)
 
24817
     if not p then
 
24818
      return notfound()
 
24819
     end
 
24820
     local pattern=".*/"..path.."$"
 
24821
     local istable=type(p)=="table"
 
24822
     if istable then
 
24823
      for i=1,#p do
 
24824
       local pi=p[i]
 
24825
       if pi==path or find(pi,pattern) then
 
24826
        local fullname=joinname(root,pi,n)
 
24827
        if isfile(fullname) then 
 
24828
         return fullname
 
24829
        end
 
24830
       end
 
24831
      end
 
24832
     elseif p==path or find(p,pattern) then
 
24833
      local fullname=joinname(root,p,n)
 
24834
      if isfile(fullname) then 
 
24835
       return fullname
 
24836
      end
 
24837
     end
 
24838
     local queries=specification.queries
 
24839
     if queries and queries.option=="fileonly" then
 
24840
      return checked(root,p,n)
 
24841
     else
 
24842
      return notfound()
 
24843
     end
 
24844
    end
 
24845
   end
 
24846
   local path=dirname(filename)
 
24847
   local name=basename(filename)
 
24848
   local root=lpegmatch(stripper,path)
 
24849
   local content=collectors[path]
 
24850
   local p,n=lookup(content,name)
 
24851
   if p then
 
24852
    return checked(root,p,n)
 
24853
   end
 
24854
  end
 
24855
  return notfound()
 
24856
 end
 
24857
 finders.dirlist=resolve
 
24858
 function finders.dirfile(specification)
 
24859
  local queries=specification.queries
 
24860
  if queries then
 
24861
   queries.option="fileonly"
24656
24862
  else
24657
 
   local fullname=joinname(root,p,n)
24658
 
   if isfile(fullname) then 
24659
 
    return fullname
24660
 
   end
24661
 
  end
24662
 
 end
24663
 
 return notfound()
24664
 
end
24665
 
local function resolve(specification) 
24666
 
 local filename=specification.filename
24667
 
 if filename~="" then
24668
 
  local root,rest=lpegmatch(splitter,filename)
24669
 
  if root and rest then
24670
 
   local path,name=dirname(rest),basename(rest)
24671
 
   if name~=rest then
24672
 
    local content=collectors[root]
24673
 
    local p,n=lookup(content,name)
24674
 
    if not p then
24675
 
     return notfound()
24676
 
    end
24677
 
    local pattern=".*/"..path.."$"
24678
 
    local istable=type(p)=="table"
24679
 
    if istable then
24680
 
     for i=1,#p do
24681
 
      local pi=p[i]
24682
 
      if pi==path or find(pi,pattern) then
24683
 
       local fullname=joinname(root,pi,n)
24684
 
       if isfile(fullname) then 
24685
 
        return fullname
24686
 
       end
24687
 
      end
24688
 
     end
24689
 
    elseif p==path or find(p,pattern) then
24690
 
     local fullname=joinname(root,p,n)
24691
 
     if isfile(fullname) then 
24692
 
      return fullname
24693
 
     end
24694
 
    end
24695
 
    local queries=specification.queries
24696
 
    if queries and queries.option=="fileonly" then
24697
 
     return checked(root,p,n)
24698
 
    else
24699
 
     return notfound()
24700
 
    end
24701
 
   end
24702
 
  end
24703
 
  local path,name=dirname(filename),basename(filename)
24704
 
  local root=lpegmatch(stripper,path)
24705
 
  local content=collectors[path]
24706
 
  local p,n=lookup(content,name)
24707
 
  if p then
24708
 
   return checked(root,p,n)
24709
 
  end
24710
 
 end
24711
 
 return notfound()
24712
 
end
24713
 
resolvers.finders   .dirlist=resolve
24714
 
resolvers.locators  .dirlist=resolvers.locators  .tree
24715
 
resolvers.hashers   .dirlist=resolvers.hashers   .tree
24716
 
resolvers.generators.dirlist=resolvers.generators.file
24717
 
resolvers.openers   .dirlist=resolvers.openers   .file
24718
 
resolvers.loaders   .dirlist=resolvers.loaders   .file
24719
 
function resolvers.finders.dirfile(specification)
24720
 
 local queries=specification.queries
24721
 
 if queries then
24722
 
  queries.option="fileonly"
24723
 
 else
24724
 
  specification.queries={ option="fileonly" }
24725
 
 end
24726
 
 return resolve(specification)
24727
 
end
24728
 
resolvers.locators  .dirfile=resolvers.locators  .dirlist
24729
 
resolvers.hashers   .dirfile=resolvers.hashers   .dirlist
24730
 
resolvers.generators.dirfile=resolvers.generators.dirlist
24731
 
resolvers.openers   .dirfile=resolvers.openers   .dirlist
24732
 
resolvers.loaders   .dirfile=resolvers.loaders   .dirlist
 
24863
   specification.queries={ option="fileonly" }
 
24864
  end
 
24865
  return resolve(specification)
 
24866
 end
 
24867
end
 
24868
do
 
24869
 local fileopener=openers.file
 
24870
 local fileloader=loaders.file
 
24871
 openers.dirlist=fileopener
 
24872
 loaders.dirlist=fileloader
 
24873
 openers.dirfile=fileopener
 
24874
 loaders.dirfile=fileloader
 
24875
end
24733
24876
 
24734
24877
 
24735
24878
end -- of closure
24738
24881
 
24739
24882
package.loaded["data-sch"] = package.loaded["data-sch"] or true
24740
24883
 
 
24884
-- original size: 6945, stripped down to: 5408
24741
24885
 
24742
24886
if not modules then modules={} end modules ['data-sch']={
24743
24887
 version=1.001,
24748
24891
 license="see context related readme files"
24749
24892
}
24750
24893
local load,tonumber=load,tonumber
24751
 
local gsub,concat,format=string.gsub,table.concat,string.format
 
24894
local gsub,format=string.gsub,string.format
 
24895
local sortedhash,concat=table.sortedhash,table.concat
24752
24896
local finders,openers,loaders=resolvers.finders,resolvers.openers,resolvers.loaders
 
24897
local addsuffix,suffix,splitbase=file.addsuffix,file.suffix,file.splitbase
 
24898
local md5hex=md5.hex
24753
24899
local trace_schemes=false  trackers.register("resolvers.schemes",function(v) trace_schemes=v end)
24754
24900
local report_schemes=logs.reporter("resolvers","schemes")
24755
24901
local http=require("socket.http")
24766
24912
 return specification.original
24767
24913
end
24768
24914
function cleaners.strip(specification) 
24769
 
 local path,name=file.splitbase(specification.original)
 
24915
 local path,name=splitbase(specification.original)
24770
24916
 if path=="" then
24771
24917
  return (gsub(name,"[^%a%d%.]+","-"))
24772
24918
 else
24774
24920
 end
24775
24921
end
24776
24922
function cleaners.md5(specification)
24777
 
 return file.addsuffix(md5.hex(specification.original),file.suffix(specification.path))
 
24923
 return addsuffix(md5hex(specification.original),suffix(specification.path))
24778
24924
end
24779
24925
local cleaner=cleaners.strip
24780
24926
directives.register("schemes.cleanmethod",function(v) cleaner=cleaners[v] or cleaners.strip end)
24865
25011
schemes.install=install
24866
25012
local function http_handler(specification,cachename)
24867
25013
 local tempname=cachename..".tmp"
24868
 
 local f=io.open(tempname,"wb")
 
25014
 local handle=io.open(tempname,"wb")
24869
25015
 local status,message=http.request {
24870
25016
  url=specification.original,
24871
 
  sink=ltn12.sink.file(f)
 
25017
  sink=ltn12.sink.file(handle)
24872
25018
 }
24873
25019
 if not status then
24874
25020
  os.remove(tempname)
24883
25029
install('ftp')
24884
25030
statistics.register("scheme handling time",function()
24885
25031
 local l,r,nl,nr={},{},0,0
24886
 
 for k,v in table.sortedhash(loaded) do
 
25032
 for k,v in sortedhash(loaded) do
24887
25033
  if v>0 then
24888
25034
   nl=nl+1
24889
25035
   l[nl]=k..":"..v
24890
25036
  end
24891
25037
 end
24892
 
 for k,v in table.sortedhash(reused) do
 
25038
 for k,v in sortedhash(reused) do
24893
25039
  if v>0 then
24894
25040
   nr=nr+1
24895
25041
   r[nr]=k..":"..v
24897
25043
 end
24898
25044
 local n=nl+nr
24899
25045
 if n>0 then
24900
 
  l=nl>0 and concat(l) or "none"
24901
 
  r=nr>0 and concat(r) or "none"
 
25046
  if nl==0 then l={ "none" } end
 
25047
  if nr==0 then r={ "none" } end
24902
25048
  return format("%s seconds, %s processed, threshold %s seconds, loaded: %s, reused: %s",
24903
 
   statistics.elapsedtime(schemes),n,threshold,l,r)
 
25049
   statistics.elapsedtime(schemes),n,threshold,concat(l," "),concat(l," "))
24904
25050
 else
24905
25051
  return nil
24906
25052
 end
24933
25079
 
24934
25080
package.loaded["data-lua"] = package.loaded["data-lua"] or true
24935
25081
 
 
25082
-- original size: 4227, stripped down to: 3049
24936
25083
 
24937
25084
if not modules then modules={} end modules ['data-lua']={
24938
25085
 version=1.001,
24943
25089
 license="see context related readme files"
24944
25090
}
24945
25091
local package,lpeg=package,lpeg
24946
 
local gsub=string.gsub
24947
 
local concat=table.concat
 
25092
local loadfile=loadfile
24948
25093
local addsuffix=file.addsuffix
24949
25094
local P,S,Cs,lpegmatch=lpeg.P,lpeg.S,lpeg.Cs,lpeg.match
24950
25095
local luasuffixes={ 'tex','lua' }
24955
25100
local methods=helpers.methods or {}
24956
25101
local resolvers=resolvers
24957
25102
local resolveprefix=resolvers.resolve
 
25103
local expandedpaths=resolvers.expandedpathlistfromvariable
 
25104
local findfile=resolvers.findfile
24958
25105
helpers.report=logs.reporter("resolvers","libraries")
24959
25106
trackers.register("resolvers.libraries",function(v) helpers.trace=v end)
24960
25107
trackers.register("resolvers.locating",function(v) helpers.trace=v end)
24983
25130
 if not luaformatpaths then
24984
25131
  luaformatpaths={}
24985
25132
  for i=1,#luaformats do
24986
 
   registerpath("lua format","lua",luaformatpaths,resolvers.expandedpathlistfromvariable(luaformats[i]))
 
25133
   registerpath("lua format","lua",luaformatpaths,expandedpaths(luaformats[i]))
24987
25134
  end
24988
25135
 end
24989
25136
 return luaformatpaths
24992
25139
 if not libformatpaths then
24993
25140
  libformatpaths={}
24994
25141
  for i=1,#libformats do
24995
 
   registerpath("lib format","lib",libformatpaths,resolvers.expandedpathlistfromvariable(libformats[i]))
 
25142
   registerpath("lib format","lib",libformatpaths,expandedpaths(libformats[i]))
24996
25143
  end
24997
25144
 end
24998
25145
 return libformatpaths
25002
25149
 local report=helpers.report
25003
25150
 for i=1,#suffixes do 
25004
25151
  local format=suffixes[i]
25005
 
  local resolved=resolvers.findfile(name,format) or ""
 
25152
  local resolved=findfile(name,format) or ""
25006
25153
  if trace then
25007
25154
   report("%s format, identifying %a using format %a",what,name,format)
25008
25155
  end
25040
25187
 
25041
25188
package.loaded["data-aux"] = package.loaded["data-aux"] or true
25042
25189
 
 
25190
-- original size: 2610, stripped down to: 2019
25043
25191
 
25044
25192
if not modules then modules={} end modules ['data-aux']={
25045
25193
 version=1.001,
25051
25198
}
25052
25199
local find=string.find
25053
25200
local type,next=type,next
 
25201
local addsuffix,removesuffix=file.addsuffix,file.removesuffix
 
25202
local loaddata,savedata=io.loaddata,io.savedata
25054
25203
local trace_locating=false  trackers.register("resolvers.locating",function(v) trace_locating=v end)
25055
25204
local resolvers=resolvers
 
25205
local cleanpath=resolvers.cleanpath
 
25206
local findfiles=resolvers.findfiles
25056
25207
local report_scripts=logs.reporter("resolvers","scripts")
25057
25208
function resolvers.updatescript(oldname,newname)
25058
25209
 local scriptpath="context/lua"
25059
 
 newname=file.addsuffix(newname,"lua")
25060
 
 local oldscript=resolvers.cleanpath(oldname)
 
25210
 local oldscript=cleanpath(oldname)
 
25211
 local newname=addsuffix(newname,"lua")
 
25212
 local newscripts=findfiles(newname) or {}
25061
25213
 if trace_locating then
25062
25214
  report_scripts("to be replaced old script %a",oldscript)
25063
25215
 end
25064
 
 local newscripts=resolvers.findfiles(newname) or {}
25065
25216
 if #newscripts==0 then
25066
25217
  if trace_locating then
25067
25218
   report_scripts("unable to locate new script")
25068
25219
  end
25069
25220
 else
25070
25221
  for i=1,#newscripts do
25071
 
   local newscript=resolvers.cleanpath(newscripts[i])
 
25222
   local newscript=cleanpath(newscripts[i])
25072
25223
   if trace_locating then
25073
25224
    report_scripts("checking new script %a",newscript)
25074
25225
   end
25080
25231
    if trace_locating then
25081
25232
     report_scripts("new script should come from %a",scriptpath)
25082
25233
    end
25083
 
   elseif not (find(oldscript,file.removesuffix(newname).."$") or find(oldscript,newname.."$")) then
 
25234
   elseif not (find(oldscript,removesuffix(newname).."$") or find(oldscript,newname.."$")) then
25084
25235
    if trace_locating then
25085
25236
     report_scripts("invalid new script name")
25086
25237
    end
25087
25238
   else
25088
 
    local newdata=io.loaddata(newscript)
 
25239
    local newdata=loaddata(newscript)
25089
25240
    if newdata then
25090
25241
     if trace_locating then
25091
25242
      report_scripts("old script content replaced by new content: %s",oldscript)
25092
25243
     end
25093
 
     io.savedata(oldscript,newdata)
 
25244
     savedata(oldscript,newdata)
25094
25245
     break
25095
25246
    elseif trace_locating then
25096
25247
     report_scripts("unable to load new script")
25163
25314
 
25164
25315
package.loaded["data-lst"] = package.loaded["data-lst"] or true
25165
25316
 
 
25317
-- original size: 1912, stripped down to: 1591
25166
25318
 
25167
25319
if not modules then modules={} end modules ['data-lst']={
25168
25320
 version=1.001,
25173
25324
 license="see context related readme files"
25174
25325
}
25175
25326
local type=type
25176
 
local concat,sortedhash=table.concat,table.sortedhash
 
25327
local sortedhash=table.sortedhash
 
25328
local isdir=lfs.isdir
25177
25329
local resolvers=resolvers
25178
25330
local listers=resolvers.listers or {}
25179
25331
resolvers.listers=listers
25180
25332
local resolveprefix=resolvers.resolve
 
25333
local configurationfiles=resolvers.configurationfiles
 
25334
local expandedpathfromlist=resolvers.expandedpathfromlist
 
25335
local splitpath=resolvers.splitpath
 
25336
local knownvariables=resolvers.knownvariables
25181
25337
local report_lists=logs.reporter("resolvers","lists")
25182
25338
local report_resolved=logs.reporter("system","resolved")
25183
 
local function tabstr(str)
25184
 
 if type(str)=='table' then
25185
 
  return concat(str," | ")
25186
 
 else
25187
 
  return str
25188
 
 end
25189
 
end
25190
25339
function listers.variables(pattern)
25191
25340
 local result=resolvers.knownvariables(pattern)
 
25341
 local unset={ "unset" }
25192
25342
 for key,value in sortedhash(result) do
25193
25343
  report_lists(key)
25194
 
  report_lists("  env: %s",tabstr(value.environment or "unset"))
25195
 
  report_lists("  var: %s",tabstr(value.variable or "unset"))
25196
 
  report_lists("  exp: %s",tabstr(value.expansion   or "unset"))
25197
 
  report_lists("  res: %s",tabstr(value.resolved or "unset"))
 
25344
  report_lists("  env: % | t",value.environment or unset)
 
25345
  report_lists("  var: % | t",value.variable or unset)
 
25346
  report_lists("  exp: % | t",value.expansion   or unset)
 
25347
  report_lists("  res: % | t",value.resolved or unset)
25198
25348
 end
25199
25349
end
25200
25350
function listers.configurations()
25201
 
 local configurations=resolvers.configurationfiles()
 
25351
 local configurations=configurationfiles()
25202
25352
 for i=1,#configurations do
25203
25353
  report_resolved("file : %s",resolveprefix(configurations[i]))
25204
25354
 end
25205
25355
 report_resolved("")
25206
 
 local list=resolvers.expandedpathfromlist(resolvers.splitpath(resolvers.luacnfspec))
 
25356
 local list=expandedpathfromlist(splitpath(resolvers.luacnfspec))
25207
25357
 for i=1,#list do
25208
25358
  local li=resolveprefix(list[i])
25209
 
  if lfs.isdir(li) then
 
25359
  if isdir(li) then
25210
25360
   report_resolved("path - %s",li)
25211
25361
  else
25212
25362
   report_resolved("path + %s",li)
25978
26128
 
25979
26129
-- used libraries    : l-bit32.lua l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua util-zip.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua
25980
26130
-- skipped libraries : -
 
26131
-- original bytes    : 1040817
 
26132
-- stripped bytes    : 412122
25981
26133
 
25982
26134
-- end library merge
25983
26135