[m-rev.] for review: fix generation of debugger documentation on Windows

Julien Fischer jfischer at opturion.com
Sat May 13 14:20:23 AEST 2023


For review by anyone.

(Cygwin is apparently unaffected by any of this, although I haven't 
checked yet.)

-----------------------------------

Fix generation of the debugger documentation on Windows.

We generate the debugger documentation files, e.g. the command list, by
processing the output of the info tool and running through a series of sh and
awk scripts. This is breaking for MSYS based systems on Windows because the
port of awk there does not handle non-ASCII characters and info will sometimes
output those. Using the C locale on affected systems causes the output of info
to be ASCII.

doc/generate_mdb_doc:
     Force the use of the C locale on MSYS / MinGW systems in order to avoid
     problems with awk.

     Shut up some warnings form shellcheck.

Julien.

diff --git a/doc/generate_mdb_doc b/doc/generate_mdb_doc
index b1b0047..4cb65c8 100755
--- a/doc/generate_mdb_doc
+++ b/doc/generate_mdb_doc
@@ -2,10 +2,25 @@
  # vim: sw=4 ts=4 et
  #---------------------------------------------------------------------------#
  # Copyright (C) 1998-1999,2002, 2004-2006 The University of Melbourne.
+# Copyright (C) 2014, 2020, 2023 The Mercury team.
  # This file may only be copied under the terms of the GNU General
  # Public License - see the file COPYING in the Mercury distribution.
  #---------------------------------------------------------------------------#

+# Some versions of the info tool will emit single quotes as directional
+# quotation marks (i.e. U+2018 and U+2019). This causes problems because awk
+# on MSYS* / MinGW* systems does not handle UTF-8 encoded input properly.
+# (Apparently, it's some weird Windows code page thing.)
+# Using the C locale makes info emit the apostrophe character for single quotes.
+# Since that is ASCII, affected versions of awk do not have a problem with it.
+# None of this is an issue on non-Windows systems since their versions of
+# awk are not affected.
+#
+platform=$(uname -a)
+case "$platform" in
+    MINGW*|MSYS*) export LC_ALL=C ;;
+esac
+
  # The info menu items that get us to the chapter on debugger commands.
  cat mdb_categories > mdb_doc

@@ -25,7 +40,7 @@ echo                                                             >> mdb_doc
  info -f ./mercury_user_guide.info -o ${tmp} \
      -n "Declarative debugging commands"
  echo "The following commands are available from within the" \
-    "declarative debugger:" `./commands ${tmp}` | \
+    "declarative debugger:" "$(./commands ${tmp})" | \
      fold -w72 -s | sed "s/^/     /"                              >> mdb_doc
  echo end                                                         >> mdb_doc
  ../util/info_to_mdb decl ${tmp} >> mdb_doc


More information about the reviews mailing list