Skip to content

Commit

Permalink
further windows path handling
Browse files Browse the repository at this point in the history
  • Loading branch information
wtsnjp committed Aug 11, 2024
1 parent 853b8ba commit aca8b4d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
5 changes: 3 additions & 2 deletions script/texdoclib-search.tlu
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,12 @@ function Doclist:add(df)
-- if no realpath information, unable to add
-- (useful if vanilla == false)
if not df.realpath then return end
local w32_path = texdoc.util.w32_path
local df_hash = md5.sumhexa(df.normname:lower()):sub(1, 7) -- same as debug-score

-- check the existence of the file
if not lfs.isfile(df.realpath) then
dbg_print('search', '(%d) File %s not found. Skipping.', df_hash, df.realpath)
dbg_print('search', '(%d) File %s not found. Skipping.', df_hash, w32_path(df.realpath))
return
end

Expand All @@ -139,7 +140,7 @@ function Doclist:add(df)
if index then
self[index]:mergein(df)
else
dbg_print('search', '(%s) File %s found.', df_hash, df.realpath)
dbg_print('search', '(%s) File %s found.', df_hash, w32_path(df.realpath))
dbg_print_docfile(df, df_hash)

local newindex = #self + 1
Expand Down
6 changes: 1 addition & 5 deletions spec/config/buitin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
context "if no other sources of config is set" do
before(:each) { run_texdoc "-D", "texlive-en" }

it "config items should be set to the default values" do
it "should be set to the default values" do
defaults = [
"badext_list=txt, dat, ",
"mode=view",
Expand All @@ -29,9 +29,5 @@
debug_line "config", "Setting \"#{config}\" from built-in defaults.")
end
end

if not OS.windows?
# nothing: just to prevent a bug on windows
end
end
end
5 changes: 3 additions & 2 deletions spec/search/alias_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
EOF
}
before(:each) { File.write(texdoc_cnf, config_content) }
let(:realpath) { Regexp.escape(normalize_path("texlive/texlive-en/texlive-en.pdf")) }

context "and query the exact alias" do
before(:each) { run_texdoc "-ddocfile", "testalias" }

it "should find aliased documents" do
expect(stderr).to include(debug_line "search", 'Searching documents for pattern "testalias"')
expect(stderr).to match(/texdoc debug-search: \(0da8ec4\) File \S*texlive\/texlive-en\/texlive-en.pdf found/)
expect(stderr).to match(/texdoc debug-search: \(0da8ec4\) File \S*#{realpath} found/)
expect(stderr).to include(debug_line "docfile", "(0da8ec4) name: texlive/texlive-en/texlive-en.pdf")
expect(stderr).to include(debug_line "docfile", "(0da8ec4) matches: texlive (alias)")
expect(last_command_started).to be_successfully_executed
Expand All @@ -31,7 +32,7 @@

it "should not find aliased documents" do
expect(stderr).to include(debug_line "search", 'Searching documents for pattern "testaliases"')
expect(stderr).not_to match(/texdoc debug-search: \(0da8ec4\) File \S*texlive\/texlive-en\/texlive-en.pdf found/)
expect(stderr).not_to match(/texdoc debug-search: \(0da8ec4\) File \S*#{realpath} found/)
expect(stderr).not_to include(debug_line "docfile", "(0da8ec4) name: texlive/texlive-en/texlive-en.pdf")
expect(stderr).not_to include(debug_line "docfile", "(0da8ec4) matches: texlive (alias)")
end
Expand Down

0 comments on commit aca8b4d

Please sign in to comment.