gbranden pushed a commit to branch master
in repository groff.

commit 6d970eeed411493dd7dbb2439495a19aaed4bd6e
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Aug 30 15:46:48 2024 -0500

    [groff]: Revise `\X` spec char test expectations.
    
    * src/roff/groff/tests/device-control-special-character-handling.sh:
    * src/roff/groff/tests/device_control_escapes_express_basic_latin.sh:
      Revise test expectations.
    
    Continues fixing Savannah #63074.
---
 ChangeLog                                          | 10 ++++
 .../device-control-special-character-handling.sh   | 54 ++++++++++++++++------
 .../device_control_escapes_express_basic_latin.sh  |  1 -
 src/roff/troff/input.cpp                           | 30 +++++++++---
 4 files changed, 74 insertions(+), 21 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b326172a2..8f8f8dd12 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-08-30  G. Branden Robinson <[email protected]>
+
+       * src/roff/groff/tests/\
+       device-control-special-character-handling.sh:
+       * src/roff/groff/tests/\
+       device_control_escapes_express_basic_latin.sh: Revise test
+       expectations.
+
+       Continues fixing Savannah #63074.
+
 2024-08-30  G. Branden Robinson <[email protected]>
 
        [groff]: Add test of diagnostics for attempts to write invalid
diff --git a/src/roff/groff/tests/device-control-special-character-handling.sh 
b/src/roff/groff/tests/device-control-special-character-handling.sh
index e1f4651ff..1a755846a 100755
--- a/src/roff/groff/tests/device-control-special-character-handling.sh
+++ b/src/roff/groff/tests/device-control-special-character-handling.sh
@@ -29,11 +29,11 @@ wail () {
 
 input='.
 .nf
-\X#bogus1: esc \%to-do\[u1F63C]\\[u1F00] -\[aq]\[dq]\[ga]\[ha]\[rs]\[ti]\[`a]#
-.device bogus1: req \%to-do\[u1F63C]\\[u1F00] 
-\[aq]\[dq]\[ga]\[ha]\[rs]\[ti]\[`a]
+\X#bogus1: esc \%to-do\[u1F63C]\\[u1F00]\-\[`a]#
+.device bogus1: req \%to-do\[u1F63C]\\[u1F00]\-\[`a]
 .ec @
-@X#bogus2: esc @%to-do@[u1F63C]@@[u1F00] -@[aq]@[dq]@[ga]@[ha]@[rs]@[ti]@[`a]#
-.device bogus2: req @%to-do@[u1F63C]@@[u1F00] 
-@[aq]@[dq]@[ga]@[ha]@[rs]@[ti]@[`a]
+@X#bogus2: esc @%to-do@[u1F63C]@@[u1F00]@-@[`a]#
+.device bogus2: req @%to-do@[u1F63C]@@[u1F00]@-@[`a]
 .'
 
 output=$(printf '%s\n' "$input" | "$groff" -T ps -Z 2> /dev/null \
@@ -44,16 +44,15 @@ echo "$output"
 echo "$error"
 
 # Expected:
-# x X bogus1: esc to-do\[u1F63C]\[u1F00] -'"`^\~\[u00E0]
-# x X bogus1: req @%to-do\[u1F63C]\[u1F00] 
-\[aq]\[dq]\[ga]\[ha]\[rs]\[ti]\[`a]#
-# x X bogus2: esc to-do\[u1F63C]\[u1F00] -'"`^\~\[u00E0]
-# x X bogus2: req @%to-do@[u1F63C]@[u1F00] 
-@[aq]@[dq]@[ga]@[ha]@[rs]@[ti]@[`a]#
+#
+# x X bogus1: esc to-do\[u1F63C]\[u1F00]-\[u00E0]
+# x X bogus1: req @%to-do\[u1F63C]\[u1F00]@-\[`a]
+# x X bogus2: esc to-do\[u1F63C]\[u1F00]-\[u00E0]
+# x X bogus2: req @%to-do@[u1F63C]@[u1F00]@-@[`a]
 
 echo "checking X escape sequence, default escape character" >&2
 echo "$output" \
-  | grep -Fqx \
-  'x X bogus1: esc to-do\[u1F63C]\[u1F00] -'"'"'"`^\~\[u00E0]' \
-  || wail
+  | grep -Fqx 'x X bogus1: esc to-do\[u1F63C]\[u1F00]-\[u00E0]' || wail
 
 #echo "checking device request, default escape character" >&2
 #echo "$output" \
@@ -62,15 +61,42 @@ echo "$output" \
 
 echo "checking X escape sequence, alternate escape character" >&2
 echo "$output" \
-  | grep -Fqx \
-  'x X bogus1: esc to-do\[u1F63C]\[u1F00] -'"'"'"`^\~\[u00E0]' \
-  || wail
+  | grep -Fqx 'x X bogus2: esc to-do\[u1F63C]\[u1F00]-\[u00E0]' || wail
 
 #echo "checking device request, alternate escape character" >&2
 #echo "$output" \
 #  | grep -qx 'x X bogus2: req to-do\\\[u1F00\] -'"'"'"`^\\~' \
 #  || wail
 
+input='.
+.nf
+\X#bogus3: \[dq]\[sh]\[Do]\[aq]\[sl]\[at]#
+\X#bogus4: \[lB]\[rs]\[rB]\[ha]#
+\X#bogus5: \[lC]\[ba]\[or]\[rC]\[ti]#
+.\"device bogus3: \[dq]\[sh]\[Do]\[aq]\[sl]\[at]
+.\"device bogus4: \[lB]\[rs]\[rB]\[ha]
+.\"device bogus5: \[lC]\[ba]\[or]\[rC]\[ti]
+.'
+
+# Expected:
+#
+# x X bogus3: "#$'/@
+# x X bogus4: [\]^
+# x X bogus5: {||}~
+
+output=$(printf '%s\n' "$input" | "$groff" -T ps -Z 2> /dev/null \
+  | grep '^x X')
+echo "$output"
+
+echo "checking X escape sequence, conversions to basic Latin (1/3)" >&2
+echo "$output" | grep -Fqx 'x X bogus3: "#$'"'"'/@' || wail
+
+echo "checking X escape sequence, conversions to basic Latin (2/3)" >&2
+echo "$output" | grep -Fqx 'x X bogus4: [\]^' || wail
+
+echo "checking X escape sequence, conversions to basic Latin (3/3)" >&2
+echo "$output" | grep -Fqx 'x X bogus5: {||}~' || wail
+
 test -z "$fail"
 
 # vim:set autoindent expandtab shiftwidth=2 tabstop=2 textwidth=72:
diff --git a/src/roff/groff/tests/device_control_escapes_express_basic_latin.sh 
b/src/roff/groff/tests/device_control_escapes_express_basic_latin.sh
index 64189138f..b0fd63afb 100755
--- a/src/roff/groff/tests/device_control_escapes_express_basic_latin.sh
+++ b/src/roff/groff/tests/device_control_escapes_express_basic_latin.sh
@@ -49,7 +49,6 @@ do
   check_char - - "minus sign" $device
   check_char '[aq]' "'" "neutral apostrophe" $device
   check_char '[dq]' '"' "double quote" $device
-  check_char '[ga]' '`' "grave accent" $device
   check_char '[ha]' ^ "caret/hat" $device
   check_char '[rs]' '\' "reverse solidus/backslash" $device
   check_char '[ti]' '~' "tilde" $device
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 6a31aac01..75a157a33 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -5706,16 +5706,34 @@ static void 
encode_special_character_for_device_output(macro *mac)
     sc = tok.get_char(true /* required */)->get_symbol()->contents();
   if (strcmp("-", sc) == 0)
     mac->append('-');
-  else if (strcmp("aq", sc) == 0)
-    mac->append('\'');
   else if (strcmp("dq", sc) == 0)
     mac->append('"');
-  else if (strcmp("ga", sc) == 0)
-    mac->append('`');
-  else if (strcmp("ha", sc) == 0)
-    mac->append('^');
+  else if (strcmp("sh", sc) == 0)
+    mac->append('#');
+  else if (strcmp("Do", sc) == 0)
+    mac->append('$');
+  else if (strcmp("aq", sc) == 0)
+    mac->append('\'');
+  else if (strcmp("sl", sc) == 0)
+    mac->append('/');
+  else if (strcmp("at", sc) == 0)
+    mac->append('@');
+  else if (strcmp("lB", sc) == 0)
+    mac->append('[');
   else if (strcmp("rs", sc) == 0)
     mac->append('\\');
+  else if (strcmp("rB", sc) == 0)
+    mac->append(']');
+  else if (strcmp("ha", sc) == 0)
+    mac->append('^');
+  else if (strcmp("lC", sc) == 0)
+    mac->append('{');
+  else if (strcmp("ba", sc) == 0)
+    mac->append('|');
+  else if (strcmp("or", sc) == 0)
+    mac->append('|');
+  else if (strcmp("rC", sc) == 0)
+    mac->append('}');
   else if (strcmp("ti", sc) == 0)
     mac->append('~');
   else {

_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to