bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Warn user when 2 files conflict on a case insensitive fs


From: Torbjörn SVENSSON
Subject: [PATCH] Warn user when 2 files conflict on a case insensitive fs
Date: Fri, 6 Jan 2023 13:28:04 +0100

Hi,

I can't find where to send patches, so pardon me if this is the wrong
channel.

I recently noticed a problem doing a building GDB for Windows on a
GNU/Linux host. The documentation contains 'qMemTags' and 'QMemTags'
and as GDB is using the --split-size argument, the --node-files is
automatically activated and a bunch of redirect files are generated,
including qMemTags.html and QMemTags.html. As these 2 files have the
"same" filename on Windows, the content of one of them will be used,
but it's unpredictable witch one. So, to make the developers aware
of this situation, I added a simple warning to makeinfo about the
potential problem for case insensitive file systems.

Kind regards,
Torbjörn

---

* tp/Texinfo/Common.pm (output_files_initialize, output_files_open_out):
Add warning when paths conflicts on a case insensitive file system.

* tp/tests/formatting/list-of-tests (unique_filenames): New test.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
---
 ChangeLog                                     |  7 +++
 tp/Texinfo/Common.pm                          |  7 ++-
 tp/tests/formatting/list-of-tests             |  1 +
 .../res_parser/unique_filenames/Foo.html      | 23 ++++++++
 .../res_parser/unique_filenames/foo.html      | 23 ++++++++
 .../res_parser/unique_filenames/index.html    | 52 +++++++++++++++++++
 .../unique_filenames/unique_filenames.1       |  0
 .../unique_filenames/unique_filenames.2       |  1 +
 tp/tests/formatting/unique_filenames.texi     | 27 ++++++++++
 .../formatting_unique_filenames.sh            | 19 +++++++
 10 files changed, 159 insertions(+), 1 deletion(-)
 create mode 100644 tp/tests/formatting/res_parser/unique_filenames/Foo.html
 create mode 100644 tp/tests/formatting/res_parser/unique_filenames/foo.html
 create mode 100644 tp/tests/formatting/res_parser/unique_filenames/index.html
 create mode 100644 
tp/tests/formatting/res_parser/unique_filenames/unique_filenames.1
 create mode 100644 
tp/tests/formatting/res_parser/unique_filenames/unique_filenames.2
 create mode 100644 tp/tests/formatting/unique_filenames.texi
 create mode 100755 tp/tests/test_scripts/formatting_unique_filenames.sh

diff --git a/ChangeLog b/ChangeLog
index d416b25a45..5821561f47 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2023-01-06  Torbjörn Svensson <torbjorn.svensson@foss.st.com>
+
+       * tp/Texinfo/Common.pm (output_files_initialize, output_files_open_out):
+       Add warning when paths conflicts on a case insensitive file system.
+
+       * tp/tests/formatting/list-of-tests (unique_filenames): New test.
+
 2023-01-05  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/ParserNonXS.pm (%parser_state_initialization, _next_text)
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 9a8f1d2f9e..060de25394 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -754,7 +754,7 @@ sub locate_init_file($$$)
 # both in POD and in HTML Customization API.
 sub output_files_initialize
 {
-  return {'unclosed_files' => {}, 'opened_files' => []};
+  return {'unclosed_files' => {}, 'opened_files' => [], 'unique_files' => {}};
 }
 #
 # All the opened files are registered, except for stdout,
@@ -811,6 +811,11 @@ sub output_files_open_out($$$;$$)
   if ($self) {
     push @{$self->{'opened_files'}}, $file_path;
     $self->{'unclosed_files'}->{$file_path} = $filehandle;
+    if (exists $self->{'unique_files'}{lc $file_path}) {
+      print STDERR "warning: $file_path is in conflict with another file on a 
".
+        "case insensitive file system.\n";
+    }
+    $self->{'unique_files'}{lc $file_path} = ();
   }
   return $filehandle, undef;
 }
diff --git a/tp/tests/formatting/list-of-tests 
b/tp/tests/formatting/list-of-tests
index 8a6d40cbd4..bd39fcf77c 100644
--- a/tp/tests/formatting/list-of-tests
+++ b/tp/tests/formatting/list-of-tests
@@ -33,3 +33,4 @@ index_entries_relate_to_item 
index_entries_relate_to_item.texi --html --no-split
 
 info_extension_warning foo.info
 
+unique_filenames unique_filenames.texi --html --node-files
diff --git a/tp/tests/formatting/res_parser/unique_filenames/Foo.html 
b/tp/tests/formatting/res_parser/unique_filenames/Foo.html
new file mode 100644
index 0000000000..30cce03d42
--- /dev/null
+++ b/tp/tests/formatting/res_parser/unique_filenames/Foo.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<!-- Created by texinfo, http://www.gnu.org/software/texinfo/ -->
+<!-- This file redirects to the location of a node or anchor -->
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>Foo (top section)</title>
+
+<meta name="description" content="Foo (top section)">
+<meta name="keywords" content="Foo (top section)">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="Generator" content="texi2any">
+
+<meta http-equiv="Refresh" content="0; url=index.html#Foo">
+<meta name="viewport" content="width=device-width,initial-scale=1">
+
+</head>
+
+<body lang="en">
+
+<p>The node you are looking for is at <a href="index.html#Foo">Foo</a>.</p>
+</body>
diff --git a/tp/tests/formatting/res_parser/unique_filenames/foo.html 
b/tp/tests/formatting/res_parser/unique_filenames/foo.html
new file mode 100644
index 0000000000..7b0603002d
--- /dev/null
+++ b/tp/tests/formatting/res_parser/unique_filenames/foo.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<!-- Created by texinfo, http://www.gnu.org/software/texinfo/ -->
+<!-- This file redirects to the location of a node or anchor -->
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>foo (top section)</title>
+
+<meta name="description" content="foo (top section)">
+<meta name="keywords" content="foo (top section)">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="Generator" content="texi2any">
+
+<meta http-equiv="Refresh" content="0; url=index.html#foo">
+<meta name="viewport" content="width=device-width,initial-scale=1">
+
+</head>
+
+<body lang="en">
+
+<p>The node you are looking for is at <a href="index.html#foo">foo</a>.</p>
+</body>
diff --git a/tp/tests/formatting/res_parser/unique_filenames/index.html 
b/tp/tests/formatting/res_parser/unique_filenames/index.html
new file mode 100644
index 0000000000..29a735be57
--- /dev/null
+++ b/tp/tests/formatting/res_parser/unique_filenames/index.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<!-- Created by texinfo, http://www.gnu.org/software/texinfo/ -->
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>Top (top section)</title>
+
+<meta name="description" content="Top (top section)">
+<meta name="keywords" content="Top (top section)">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="Generator" content="texi2any">
+<meta name="viewport" content="width=device-width,initial-scale=1">
+
+<link href="#Top" rel="start" title="Top">
+
+
+</head>
+
+<body lang="en">
+
+<div class="top-level-extent" id="Top">
+<h1 class="top" id="top-section">top section</h1>
+
+<ul class="mini-toc">
+<li><a href="#Chapter" accesskey="1">Chapter</a></li>
+</ul>
+<div class="chapter-level-extent" id="Chapter">
+<h2 class="chapter">1 Chapter</h2>
+
+<dl class="table">
+<dt>&lsquo;<samp class="samp">foo</samp>&rsquo;</dt>
+<dd><a class="anchor" id="foo"></a><p>Some text about &lsquo;<samp 
class="samp">foo</samp>&rsquo;
+</p>
+</dd>
+<dt>&lsquo;<samp class="samp">Foo</samp>&rsquo;</dt>
+<dd><a class="anchor" id="Foo"></a><p>Some text about &lsquo;<samp 
class="samp">Foo</samp>&rsquo;
+</p>
+</dd>
+</dl>
+
+<p>See <a class="xref" href="#foo">foo</a>
+</p>
+<p>See <a class="xref" href="#Foo">Foo</a>
+</p>
+</div>
+</div>
+
+
+
+</body>
+</html>
diff --git a/tp/tests/formatting/res_parser/unique_filenames/unique_filenames.1 
b/tp/tests/formatting/res_parser/unique_filenames/unique_filenames.1
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tp/tests/formatting/res_parser/unique_filenames/unique_filenames.2 
b/tp/tests/formatting/res_parser/unique_filenames/unique_filenames.2
new file mode 100644
index 0000000000..792c88f2f9
--- /dev/null
+++ b/tp/tests/formatting/res_parser/unique_filenames/unique_filenames.2
@@ -0,0 +1 @@
+warning: formatting/out_parser/unique_filenames/foo.html is in conflict with 
another file on a case insensitive file system.
diff --git a/tp/tests/formatting/unique_filenames.texi 
b/tp/tests/formatting/unique_filenames.texi
new file mode 100644
index 0000000000..4fe491b751
--- /dev/null
+++ b/tp/tests/formatting/unique_filenames.texi
@@ -0,0 +1,27 @@
+\input texinfo @c -*-texinfo-*-
+
+@setfilename unique_filenames.info
+
+@node Top
+@top top section
+
+@chapter Chapter
+
+@table @samp
+
+@item foo
+@anchor{foo}
+Some text about @samp{foo}
+
+@item Foo
+@anchor{Foo}
+Some text about @samp{Foo}
+
+@end table
+
+@xref{foo}
+
+@xref{Foo}
+
+@bye
+
diff --git a/tp/tests/test_scripts/formatting_unique_filenames.sh 
b/tp/tests/test_scripts/formatting_unique_filenames.sh
new file mode 100755
index 0000000000..e722a4a78e
--- /dev/null
+++ b/tp/tests/test_scripts/formatting_unique_filenames.sh
@@ -0,0 +1,19 @@
+#! /bin/sh
+# This file generated by maintain/regenerate_cmd_tests.sh
+
+if test z"$srcdir" = "z"; then
+  srcdir=.
+fi
+
+one_test_logs_dir=test_log
+
+
+dir=formatting
+name='unique_filenames'
+mkdir -p $dir
+
+"$srcdir"/run_parser_all.sh -dir $dir $name
+exit_status=$?
+cat $dir/$one_test_logs_dir/$name.log
+exit $exit_status
+
-- 
2.25.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]