texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * install-info/install-info.c (compare_entries_te


From: Gavin D. Smith
Subject: branch master updated: * install-info/install-info.c (compare_entries_text): If two strings compare identical, check which is longer. * install-info/tests/ii-0060-test: New test.
Date: Sun, 18 Feb 2024 14:05:00 -0500

This is an automated email from the git hooks/post-receive script.

gavin pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new 01b5a4b9c3 * install-info/install-info.c (compare_entries_text): If 
two strings compare identical, check which is longer. * 
install-info/tests/ii-0060-test: New test.
01b5a4b9c3 is described below

commit 01b5a4b9c33bef08feae041c221f820a1c76749f
Author: Roland Clobus <rclobus@rclobus.nl>
AuthorDate: Sun Feb 18 19:03:29 2024 +0000

    * install-info/install-info.c (compare_entries_text):
    If two strings compare identical, check which is longer.
    * install-info/tests/ii-0060-test: New test.
    
    This ensures reproducible results.
    See <https://reproducible-builds.org/>.
---
 ChangeLog                                    |  9 +++++++++
 install-info/install-info.c                  |  6 +++++-
 install-info/tests/Makefile.am               |  6 +++++-
 install-info/tests/README                    |  2 ++
 install-info/tests/ii-0060-expected-dir-file | 28 ++++++++++++++++++++++++++++
 install-info/tests/ii-0060-input-dir-file    | 23 +++++++++++++++++++++++
 install-info/tests/ii-0060-input-info-file   | 14 ++++++++++++++
 install-info/tests/ii-0060-test              | 28 ++++++++++++++++++++++++++++
 8 files changed, 114 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ea42c8d4d1..80cb3e3336 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-02-18  Roland Clobus <rclobus@rclobus.nl> (tiny change)
+
+       * install-info/install-info.c (compare_entries_text):
+       If two strings compare identical, check which is longer.
+       * install-info/tests/ii-0060-test: New test.
+
+       This ensures reproducible results.
+       See <https://reproducible-builds.org/>.
+
 2024-02-18  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/main/errors.c (message_list_line_formatted_message):
diff --git a/install-info/install-info.c b/install-info/install-info.c
index 0d59e27c33..1f42aef11d 100644
--- a/install-info/install-info.c
+++ b/install-info/install-info.c
@@ -2822,7 +2822,11 @@ compare_entries_text (const void *p1, const void *p2)
     len2 = strlen (text2);
   else
     len2 = colon2 - text2;
-  return mbsncasecmp (text1, text2, len1 <= len2 ? len1 : len2);
+  int result = mbsncasecmp (text1, text2, len1 <= len2 ? len1 : len2);
+  if (result == 0) /* Identical start, the longer goes last */
+    return len1 <= len2 ? -1 : +1;
+  else
+    return result;
 }
 
 /* Insert ENTRY into the ADD_ENTRIES_BEFORE vector for line number LINE_NUMBER 
diff --git a/install-info/tests/Makefile.am b/install-info/tests/Makefile.am
index 6b49b1397b..0548e176f9 100644
--- a/install-info/tests/Makefile.am
+++ b/install-info/tests/Makefile.am
@@ -21,7 +21,7 @@ ii-0036-test ii-0037-test ii-0038-test ii-0039-test 
ii-0040-test \
 ii-0041-test ii-0042-test ii-0043-test ii-0044-test ii-0045-test \
 ii-0046-test ii-0047-test ii-0048-test ii-0049-test ii-0050-test \
 ii-0051-test ii-0052-test ii-0053-test ii-0054-test ii-0055-test \
-ii-0056-test ii-0057-test ii-0058-test ii-0059-test
+ii-0056-test ii-0057-test ii-0058-test ii-0059-test ii-0060-test
 
 noinst_SCRIPTS=$(TESTS)
 
@@ -260,4 +260,8 @@ ii-0058-expected-dir-file \
 ii-0059-input-dir-file \
 ii-0059-input-info-file \
 ii-0059-expected-dir-file \
+\
+ii-0060-input-dir-file \
+ii-0060-input-info-file \
+ii-0060-expected-dir-file \
 README
diff --git a/install-info/tests/README b/install-info/tests/README
index 6785abf53e..7467da3cb9 100644
--- a/install-info/tests/README
+++ b/install-info/tests/README
@@ -180,3 +180,5 @@ This file describes each of the numbered install-info tests.
       extra blank lines.
 0059: Deletion of section between two other sections leaves one
       blank line between the remaining sections.
+0060: Installing an Info file.  The Info file contains entries with the same
+      start, the longest entry should be listed last (dictionary sort).
diff --git a/install-info/tests/ii-0060-expected-dir-file 
b/install-info/tests/ii-0060-expected-dir-file
new file mode 100644
index 0000000000..169ada4363
--- /dev/null
+++ b/install-info/tests/ii-0060-expected-dir-file
@@ -0,0 +1,28 @@
+This is the directory file `dir' a.k.a. `DIR', which contains the
+  topmost node of the Info hierarchy.
+
+
+File: dir,     Node: Top,      This is the top of the INFO tree.
+
+This is the Info main menu (aka directory node).
+A few useful Info commands:
+
+  `q' quits;
+  `?' lists all Info commands;
+  `h' starts the Info tutorial;
+  `mTexinfo RET' visits the Texinfo manual, etc.
+
+* Menu:
+
+Animals
+* Aardvark: (aardvark).         Medium-sized African mammal.
+* Baboon: (baboon).             A monkey from Africa.
+* Chameleon: (chameleon).       A lizard from Africa.
+* Deer: (deer).                 Ruminent antlered mammal.
+* Emu: (emu).                   A flightless bird from Australia.
+* Fisher: (fisher).             A marten from North America.
+
+Diff programs
+* diff: (diffutils).            Compare 2 files.
+* diff2: (diffutils).           Imaginary tool. Intentionally after 'diff'
+* diff3: (diffutils).           Compare 3 files. Intentionally before 'diff'
diff --git a/install-info/tests/ii-0060-input-dir-file 
b/install-info/tests/ii-0060-input-dir-file
new file mode 100644
index 0000000000..813b548648
--- /dev/null
+++ b/install-info/tests/ii-0060-input-dir-file
@@ -0,0 +1,23 @@
+This is the directory file `dir' a.k.a. `DIR', which contains the
+  topmost node of the Info hierarchy.
+
+
+File: dir,     Node: Top,      This is the top of the INFO tree.
+
+This is the Info main menu (aka directory node).
+A few useful Info commands:
+
+  `q' quits;
+  `?' lists all Info commands;
+  `h' starts the Info tutorial;
+  `mTexinfo RET' visits the Texinfo manual, etc.
+
+* Menu:
+
+Animals
+* Aardvark: (aardvark).         Medium-sized African mammal.
+* Baboon: (baboon).             A monkey from Africa.
+* Chameleon: (chameleon).       A lizard from Africa.
+* Deer: (deer).                 Ruminent antlered mammal.
+* Emu: (emu).                   A flightless bird from Australia.
+* Fisher: (fisher).             A marten from North America.
diff --git a/install-info/tests/ii-0060-input-info-file 
b/install-info/tests/ii-0060-input-info-file
new file mode 100644
index 0000000000..3a88f4631b
--- /dev/null
+++ b/install-info/tests/ii-0060-input-info-file
@@ -0,0 +1,14 @@
+INFO-DIR-SECTION Diff programs
+START-INFO-DIR-ENTRY
+* diff3: (diffutils).                  Compare 3 files. Intentionally before 
'diff'
+* diff: (diffutils).                   Compare 2 files.
+* diff2: (diffutils).                  Imaginary tool. Intentionally after 
'diff'
+END-INFO-DIR-ENTRY
+
+File: gnu,  Node: Top,  Next: Top,  Up: (dir)
+
+Diff programs
+*************
+
+See diffutils.
+
diff --git a/install-info/tests/ii-0060-test b/install-info/tests/ii-0060-test
new file mode 100755
index 0000000000..5f06aef0d8
--- /dev/null
+++ b/install-info/tests/ii-0060-test
@@ -0,0 +1,28 @@
+#!/bin/sh -x
+# This file is free software; as a special exception the author gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+. ./defs || exit 1
+
+outputdirfile=`mktemp ii60-XXXXXXXX`
+cp ${testdir}/ii-0060-input-dir-file $outputdirfile
+if [ "x$?" != "x0" ]; then
+  exit 1
+fi
+
+${install_info} ${testdir}/ii-0060-input-info-file $outputdirfile
+retval=$?
+if [ "x$retval" != "x0" ]; then
+  exit $retval
+fi
+
+${diff} ${testdir}/ii-0060-expected-dir-file $outputdirfile
+retval=$?
+
+rm -f $outputdirfile
+exit $retval



reply via email to

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