From edc0e84d991ba2318388b1c416fd0b308c7043c2 Mon Sep 17 00:00:00 2001 From: Takuto Asakura Date: Sat, 10 Aug 2024 22:19:00 +0900 Subject: [PATCH] more w32_path for debug outputs --- script/texdoclib-config.tlu | 3 ++- script/texdoclib-search.tlu | 5 +++-- spec/search/texdocs_spec.rb | 20 +++++++++++++------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/script/texdoclib-config.tlu b/script/texdoclib-config.tlu index 881a556..44b42de 100644 --- a/script/texdoclib-config.tlu +++ b/script/texdoclib-config.tlu @@ -152,7 +152,8 @@ function M.set_config_element(key, value, context) -- special case: if we just set debug_list, print version info now if key == 'debug_list' then - dbg_print('version', '%s v%s', C.fullname, C.version) + local w32_path = import_function('util', 'w32_path') + dbg_print('version', '%s v%s', w32_path(C.fullname), C.version) end -- now tell what we have just done, for debugging diff --git a/script/texdoclib-search.tlu b/script/texdoclib-search.tlu index b560626..b0e8235 100644 --- a/script/texdoclib-search.tlu +++ b/script/texdoclib-search.tlu @@ -359,6 +359,7 @@ init_texdocs_database = function() doc_roots = {} local kpse_texdocs = kpse.expand_var('$TEXDOCS') + local w32_path = texdoc.util.w32_path -- expand the path and turn it into a lua list local raw_doc_roots = kpse.expand_braces(kpse_texdocs):explode(C.kpse_sep) @@ -376,13 +377,13 @@ init_texdocs_database = function() local index_mandatory = (n == 1) dbg_print('texdocs', 'texdocs[%d] = %s (index_mandatory=%s, recursion_allowed=%s)', - i, path, tostring(index_mandatory), tostring(recursion_allowed)) + i, w32_path(path), tostring(index_mandatory), tostring(recursion_allowed)) -- decide if we should use a ls-R index, the filesystem, or do nothing local root, shift = lsr_root(path) if root and shift and recursion_allowed then dbg_print('texdocs', - 'texdocs[%d] using index: %s (shift=%s)', i, root, shift) + 'texdocs[%d] using index: %s (shift=%s)', i, w32_path(root), w32_path(shift)) db = init_lsr_db(root, shift) elseif not index_mandatory and lfs.isdir(path) then dbg_print('texdocs', diff --git a/spec/search/texdocs_spec.rb b/spec/search/texdocs_spec.rb index 9d8ea11..8f514c3 100644 --- a/spec/search/texdocs_spec.rb +++ b/spec/search/texdocs_spec.rb @@ -11,19 +11,21 @@ } before(:each) { run_texdoc "-dtexdocs", "listings" } + let(:tree_prefix) { normalize_path("path/to/") } + it "should be properly interpreted" do expect(stderr).to include( debug_line "texdocs", - "texdocs[4] = path/to/tree4 (index_mandatory=false, recursion_allowed=false)") + "texdocs[4] = #{tree_prefix}tree4 (index_mandatory=false, recursion_allowed=false)") expect(stderr).to include( debug_line "texdocs", - "texdocs[3] = path/to/tree3 (index_mandatory=false, recursion_allowed=true)") + "texdocs[3] = #{tree_prefix}tree3 (index_mandatory=false, recursion_allowed=true)") expect(stderr).to include( debug_line "texdocs", - "texdocs[2] = path/to/tree2 (index_mandatory=true, recursion_allowed=false)") + "texdocs[2] = #{tree_prefix}tree2 (index_mandatory=true, recursion_allowed=false)") expect(stderr).to include( debug_line "texdocs", - "texdocs[1] = path/to/tree1 (index_mandatory=true, recursion_allowed=true)") + "texdocs[1] = #{tree_prefix}tree1 (index_mandatory=true, recursion_allowed=true)") end end @@ -33,15 +35,19 @@ let(:texmf_dist_regex) { Regexp.escape(normalize_path(`kpsewhich -var-value TEXMFDIST`.chomp)) } let(:texmf_home_regex) { Regexp.escape(normalize_path(texmf_home)) } + let(:path_doc_suffix_regex) { Regexp.escape(normalize_path("/doc")) } + let(:shift_doc_suffix_regex) { Regexp.escape(normalize_path("doc/")) } + let(:texdocs_n_dist) { - /texdocs\[(\d+?)\] = #{texmf_dist_regex}\/doc/.match(stderr).to_a.values_at(1)[0].to_i + /texdocs\[(\d+?)\] = #{texmf_dist_regex}#{path_doc_suffix_regex}/.match(stderr).to_a.values_at(1)[0].to_i } let(:texdocs_n_home) { - /texdocs\[(\d+?)\] = #{texmf_home_regex}\/doc/.match(stderr).to_a.values_at(1)[0].to_i + /texdocs\[(\d+?)\] = #{texmf_home_regex}#{path_doc_suffix_regex}/.match(stderr).to_a.values_at(1)[0].to_i } it "should search TEXMFDIST using index" do - expect(stderr).to match(/texdocs\[#{texdocs_n_dist}\] using index: #{texmf_dist_regex} \(shift=doc\/\)/) + expect(stderr).to match( + /texdocs\[#{texdocs_n_dist}\] using index: #{texmf_dist_regex} \(shift=#{shift_doc_suffix_regex}\)/) end it "should search TEXMFHOME using file system" do