groff-commit
[Top][All Lists]
Advanced

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

[groff] 06/11: [gpinyin]: Fix Savannah #60560.


From: G. Branden Robinson
Subject: [groff] 06/11: [gpinyin]: Fix Savannah #60560.
Date: Mon, 10 May 2021 08:49:01 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 7a2c2bb9e4ace900bf58697752858b5d4494b7ed
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sun May 9 16:52:56 2021 +1000

    [gpinyin]: Fix Savannah #60560.
    
    * contrib/gpinyin/subs.pl (%tones_glyphs, %tones4_glyphs): Fix hash keys
      to use the groff dotless i special character into
    
    * contrib/gpinyin/subs.pl (%tones_glyphs, %tones4_glyphs): Fix hash keys
      to use the groff dotless i special character into which a lowercase
      "i" has already been transforned instead of 'i' itself.
    
      (vowel_n, vowel_t): Rename variable so that tone-transformed vowel is
      stored separately.  Add "or warn" to test the result and cheaply
      assert that we got a string back from our hash lookup on the vowel.
    
    Fixes <https://savannah.gnu.org/bugs/?60560>.
---
 contrib/gpinyin/ChangeLog | 13 +++++++++++++
 contrib/gpinyin/subs.pl   | 26 ++++++++++++++------------
 2 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/contrib/gpinyin/ChangeLog b/contrib/gpinyin/ChangeLog
index 4f64188..46ba717 100644
--- a/contrib/gpinyin/ChangeLog
+++ b/contrib/gpinyin/ChangeLog
@@ -1,3 +1,16 @@
+2021-05-09  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * contrib/gpinyin/subs.pl (%tones_glyphs, %tones4_glyphs): Fix
+       hash keys to use the groff dotless i special character into
+       which a lowercase "i" has already been transforned instead of
+       'i' itself.
+       (vowel_n, vowel_t): Rename variable so that tone-transformed
+       vowel is stored separately.  Add "or warn" to test the result
+       and cheaply assert that we got a string back from our hash
+       lookup on the vowel.
+
+       Fixes <https://savannah.gnu.org/bugs/?60560>.
+
 2018-02-28  Werner LEMBERG  <wl@gnu.org>
 
        * gpinyin.am (gpinyin): Use $(AM_V_GEN) to silence file generation.
diff --git a/contrib/gpinyin/subs.pl b/contrib/gpinyin/subs.pl
index d1291c0..7a5734f 100755
--- a/contrib/gpinyin/subs.pl
+++ b/contrib/gpinyin/subs.pl
@@ -218,7 +218,7 @@ my %tones2_glyphs =
    'U' => q(\\['U]),
    'a' => q(\\['a]),
    'e' => q(\\['e]),
-   'i' => q(\\['i]),
+   '\\[.i]' => q(\\['i]),
    'o' => q(\\['o]),
    'u' => q(\\['u]),
   );
@@ -232,7 +232,7 @@ my %tones4_glyphs =
    'U' => q(\\[`U]),
    'a' => q(\\[`a]),
    'e' => q(\\[`e]),
-   'i' => q(\\[`i]),
+   '\\[.i]' => q(\\[`i]),
    'o' => q(\\[`o]),
    'u' => q(\\[`u]),
   );
@@ -502,15 +502,16 @@ sub vowel_n {     # Unicode for nroff
   return '' unless ( $vowel );
 
   if ( $tone == 1 ) {          # macron
-    $vowel = $tones1_Unicode{$vowel};
+    $vowel_with_tone = $tones1_Unicode{$vowel};
   } elsif ( $tone == 2 ) {     # acute
-    $vowel = $tones2_Unicode{$vowel};
+    $vowel_with_tone = $tones2_Unicode{$vowel};
   } elsif ( $tone == 3 ) {     # caron
-    $vowel = $tones3_Unicode{$vowel};
+    $vowel_with_tone = $tones3_Unicode{$vowel};
   } elsif ( $tone == 4 ) {     # grave
-    $vowel = $tones4_Unicode{$vowel};
+    $vowel_with_tone = $tones4_Unicode{$vowel};
   }
-  return $vowel;
+  $vowel_with_tone or warn "failed to apply tone $tone to vowel $vowel";
+  return $vowel_with_tone;
 } # vowel_nr()
 
 
@@ -533,15 +534,16 @@ sub vowel_t {     # named glyphs for troff
   $vowel = q(\\[.i]) if ( $vowel eq 'i' );
 
   if ( $tone == 1 ) {          # macron
-    $vowel = q(\\o') . $vowel . $accents[$tone] . q(');
+    $vowel_with_tone = q(\\o') . $vowel . $accents[$tone] . q(');
   } elsif ( $tone == 2 ) {     # acute
-    $vowel = $tones2_glyphs{$vowel};
+    $vowel_with_tone = $tones2_glyphs{$vowel};
   } elsif ( $tone == 3 ) {     # caron
-    $vowel = q(\\o') . $vowel . $accents[$tone] . q(');
+    $vowel_with_tone = q(\\o') . $vowel . $accents[$tone] . q(');
   } elsif ( $tone == 4 ) {     # grave
-    $vowel = $tones4_glyphs{$vowel};
+    $vowel_with_tone = $tones4_glyphs{$vowel};
   }
-  return $vowel;
+  $vowel_with_tone or warn "failed to apply tone $tone to vowel $vowel";
+  return $vowel_with_tone;
 } # vowel_t()
 
 



reply via email to

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