Skip to contentSkip to conversation

build: doc: Only fix rendering of verbatim '\n"' when needed

PATCH New Duncan Roe 1 participant 2 messages Dec 21, 2024 netfilter

lore
Share & tools
lore

Duncan Roe

author
#0 lore raw

PATCH 1/2 build: doc: Only fix rendering of verbatim '\n"' when needed

commit 9f52afa60839 ("build: doc: Fix rendering of verbatim '\n"' in man pages") worked around a doxygen bug which was fixed at doxygen 1.9. Applying the workaround to output from a fixed doxygen version reintroduced the bug.
Update build_man.sh to record doxygen version and only apply workaround if that version is broken.

Fixes 9f52afa60839 ("build: doc: Fix rendering of verbatim '\n"' in man pages")
---
 doxygen/build_man.sh | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
doxygen/build_man.sh +8 -1
index 95c7569..a6531cb 100755
@@ -68,6 +68,13 @@ post_process(){
   #
   #keep_me=nfq_icmp_get_hdr.3
   #do_diagnostics
+
+  # Decide if we need to fix rendering of verbatim "\n"
+  i=$(doxygen --version)
+  doxymajor=$(echo $i|cut -f1 -d.)
+  doxyminor=$(echo $i|cut -f2 -d.)
+  [ $doxymajor -eq 1 -a $doxyminor -lt 9 ] &&
+    fix_newlines=true || fix_newlines=false
   #
   # Work through the "real" man pages
   for target in $(ls -S | head -n$page_count)
@@ -84,7 +91,7 @@ post_process(){
       [ $# -ne 2 ] || insert_see_also $@
 
       # Fix rendering of verbatim "\n" (in code snippets)
-      sed -i 's/\\n/\\\\n/' $target
+      $fix_newlines && sed -i 's/\\n/\\\\n/' $target
     }&
 
   done
Signature · 1 line
2.46.2
author
#1 lore raw

PATCH 2/2 build: doc: Fix `fprintf` in man pages from using single quotes

For example, man nfq_open shows
fprintf(stderr, 'error during nfq_open()\n');
where the single-quotes should be double-quotes (and are in the HTML). This doxygen bug appeared in doxygen 1.9.2.
It is fixed in doxygen 1.13.0 (not yet released).

Fixes 088c883bd1ca ("build: doc: Update build_man.sh for doxygen 1.9.2")
---
 doxygen/build_man.sh | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
doxygen/build_man.sh +15 -2
index a6531cb..8fda7ee 100755
@@ -69,13 +69,19 @@ post_process(){
   #keep_me=nfq_icmp_get_hdr.3
   #do_diagnostics
 
-  # Decide if we need to fix rendering of verbatim "\n"
+  # Record doxygen version
   i=$(doxygen --version)
   doxymajor=$(echo $i|cut -f1 -d.)
   doxyminor=$(echo $i|cut -f2 -d.)
+
+  # Decide if we need to fix rendering of verbatim "\n"
   [ $doxymajor -eq 1 -a $doxyminor -lt 9 ] &&
     fix_newlines=true || fix_newlines=false
-  #
+
+  # Decide if we need to fix double-to-single-quote conversion
+  [ $doxymajor -eq 1 -a $doxyminor -ge 9 -a $doxyminor < 13 ] &&
+    fix_quotes = true || fix_quotes=false
+
   # Work through the "real" man pages
   for target in $(ls -S | head -n$page_count)
   do grep -Eq "^\\.SH \"Function Documentation" $target || continue
@@ -90,6 +96,13 @@ post_process(){
       fix_double_blanks
       [ $# -ne 2 ] || insert_see_also $@
 
+      # Work around doxygen bugs (doxygen version-specific)
+
+      # Best effort: \" becomes \'
+      #              Only do lines with some kind of printf,
+      #              since other single quotes might be OK as-is.
+      $fix_quotes && sed -i '/printf/s/'\''/"/g' $target
+
       # Fix rendering of verbatim "\n" (in code snippets)
       $fix_newlines && sed -i 's/\\n/\\\\n/' $target
     }&
Signature · 1 line
2.46.2