From c00656779e19523d32d1d563e37f48709e487ce3 Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Sun, 29 May 2022 03:00:41 +0000
Subject: CTAN sync 202205290300

---
 language/japanese/pxjahyper/pxjahyper.sty | 290 +++++++++++++++++++++++++-----
 1 file changed, 243 insertions(+), 47 deletions(-)

(limited to 'language/japanese/pxjahyper/pxjahyper.sty')

diff --git a/language/japanese/pxjahyper/pxjahyper.sty b/language/japanese/pxjahyper/pxjahyper.sty
index 772be814d4..f2ebcd4571 100644
--- a/language/japanese/pxjahyper/pxjahyper.sty
+++ b/language/japanese/pxjahyper/pxjahyper.sty
@@ -10,7 +10,7 @@
 
 %% package declaration
 \NeedsTeXFormat{pLaTeX2e}
-\ProvidesPackage{pxjahyper}[2022/05/10 v1.1]
+\ProvidesPackage{pxjahyper}[2022/05/27 v1.2]
 \def\pxhy@pkgname{pxjahyper}
 \providecommand{\bxDebug}[1]{}
 
@@ -24,6 +24,7 @@
 }
 
 %% packages
+\RequirePackage{keyval}\relax
 \RequirePackage{ltxcmds}[2011/08/22]% v1.21
 
 %% variables
@@ -53,6 +54,24 @@
 \let\pxhy@jsclasses@name\relax
 \newif\ifpxhy@jlreq@cls
 \newif\ifpxhy@fallback@geta
+\newif\ifpxhy@extjis@map
+\newif\ifpxhy@extjis@use
+\newif\ifpxhy@ajhankaku@chars
+
+%%<*> \pxjahypersetup{<key>=<value>,...}
+\newcommand*\pxjahypersetup{%
+  \setkeys{\pxhy@pkgname}%
+}
+%% \pxhy@handle@key{<key>}{<value>}{<name>}
+\def\pxhy@handle@key#1#2#3{%
+  \expandafter\let\expandafter\pxhy@tmpa\csname pxhy@#3\endcsname
+  \ifx\pxhy@tmpa\relax
+    \PackageError\pxhy@pkgname
+     {Invalid value for key '#1':\MessageBreak\@spaces#2}%
+     {\@eha}%
+  \else \pxhy@tmpa
+  \fi
+}
 
 %--------------------------------------- Package options
 
@@ -153,10 +172,10 @@
   \pxhy@otfmacrosfalse
 }
 \DeclareOption{fallback-geta}{%
-  \pxhy@fallback@getatrue
+  \pxjahypersetup{fallback=geta}%
 }
 \DeclareOption{fallback-delete}{%
-  \pxhy@fallback@getafalse
+  \pxjahypersetup{fallback=delete}%
 }
 \DeclareOption{force-unicode}{%
   \let\pxhy@force@unicode=t
@@ -164,10 +183,30 @@
 \DeclareOption{disable-Ux}{% for debug
   \let\pxhy@disable@Ux=t
 }
+%% key-value options
+\DeclareOption*{%
+  \expandafter\pxjahypersetup\expandafter{\CurrentOption}%
+}
+% 'fallback=geta|delete'
+\pxhy@fallback@getatrue
+\define@key{\pxhy@pkgname}{fallback}{%
+  \pxhy@handle@key{fallback}{#1}{kv@fallback@@#1}%
+}
+\let\pxhy@kv@fallback@@geta\pxhy@fallback@getatrue
+\let\pxhy@kv@fallback@@delete\pxhy@fallback@getafalse
+% 'extjis=<bool>'
+\pxhy@extjis@usetrue
+\define@key{\pxhy@pkgname}{extjis}[true]{%
+  \pxhy@handle@key{extjis}{#1}{extjis@use#1}%
+}
+% 'ajhankaku-chars=<bool>'
+\define@key{\pxhy@pkgname}{ajhankaku-chars}[true]{%
+  \pxhy@handle@key{ajhankaku-chars}{#1}{ajhankaku@chars#1}%
+}
 %% dispatch
 \ExecuteOptions{%
   resetdvidriver,tounicode,papersize,charcmds,jacommentline,%
-  disablecmds,otfutf,otfcid,fallback-geta%
+  disablecmds,otfutf,otfcid%
 }
 \ProcessOptions*
 
@@ -251,6 +290,12 @@
 %% pxhy@ucs@avail switch
 \pxhy@check\ucs{\pxhy@ucs@availtrue}
 
+%% pxhy@extjis@map switch
+% Note that 'tounicode' is necessary.
+\ifpxhy@etex \ifpxhy@uptex\else \ifpxhy@tounicode
+  \pxhy@extjis@maptrue
+\fi\fi\fi
+
 %% Check the document class.
 % jlreq
 \ifpxhy@etex
@@ -388,11 +433,9 @@ pxhy@fallback@geta = \ifpxhy@fallback@geta true\else false\fi^^J%
 \let\pxhy@geta\pxhy@jchar
 
 %% \pxhy@print@geta
-\ifpxhy@fallback@geta
-  \def\pxhy@print@geta{\pxhy@geta}
-\else
-  \let\pxhy@print@geta\@empty
-\fi
+\def\pxhy@print@geta{%
+  \ifpxhy@fallback@geta \pxhy@geta \fi
+}
 
 %% \pxhy@hook@after@package{<package-name>}{<code>}
 \@onlypreamble\pxhy@hook@after@package
@@ -417,6 +460,11 @@ pxhy@fallback@geta = \ifpxhy@fallback@geta true\else false\fi^^J%
   \expandafter\expandafter\expandafter
 }
 
+%% \pxhy@csletcs{<csname1>}{<csname2>}
+\def\pxhy@csletcs#1#2{%
+  \expandafter\let\csname#1\expandafter\endcsname\csname#2\endcsname
+}
+
 %% \pxhy@cond\ifXXX<arg>\fi{<true>}{<false>}
 % Does the test "\ifXXX<arg>", with immediate exit from the
 % induced if-level.
@@ -730,11 +778,25 @@ pxhy@fallback@geta = \ifpxhy@fallback@geta true\else false\fi^^J%
     \def\pxhy@uchex@out#1{%
       \expandafter\pxhy@uchex@out@a\ucs"#1\pxhy@mk{#1}%
     }
+    \chardef\pxhy@max@asc="7F
     \def\pxhy@uchex@out@a#1\pxhy@mk#2{%
       \ifnum#1<\z@
+        \ifnum"#2>\pxhy@max@asc
+          \ifpxhy@extjis@use
+            \expandafter\pxhy@uchex@out@b\csname
+                pxhy@uc/\number"#2\endcsname{#2}%
+          \else \pxhy@uchex@out@b\relax{#2}%
+          \fi
+        \else \Uchar"#2
+        \fi
+      \else \Uchar#1
+      \fi
+    }
+    \def\pxhy@uchex@out@b#1#2{%
+      \ifx#1\relax
         \@nameuse{U+#2}%
         \pxhy@print@geta
-      \else \Uchar#1
+      \else #1%
       \fi
     }
 
@@ -845,6 +907,45 @@ pxhy@fallback@geta = \ifpxhy@fallback@geta true\else false\fi^^J%
   }
 \fi
 
+%--------------------------------------- Fix for high-byte protection
+\ifpxhy@etex
+\begingroup
+% Check for high-byte protection.
+\catcode"EF=\active \catcode`\^=7
+\global\let\pxhy@std@EF=^^ef
+\def\pxhy@next#1 #2\pxhy@end{%
+  \@tempswafalse
+  \def\pxhy@tmpa{#1}\edef\pxhy@tmpb{\string\protected}%
+  \ifx\pxhy@tmpa\pxhy@tmpb \@tempswatrue \fi
+}\expandafter\pxhy@next\meaning\pxhy@std@EF. \pxhy@end
+% Add a hook if protected.
+\if@tempswa
+
+  %% \pxhy@unprotect@high@bytes
+  \let\pxhy@unprotect@high@bytes\@empty
+  \def\pxhy@next#1#2{%
+    \expandafter\gdef\expandafter#1\expandafter{#2}%
+    \edef\pxhy@unprotect@high@bytes{%
+      \unexpanded\expandafter{\pxhy@unprotect@high@bytes}%
+      \unexpanded{\let#2#1}}%
+    \advance\@tempcnta\@ne
+  }
+  \@tempcnta="C2
+  \@whilenum{\@tempcnta<"F5}\do{%
+    \lccode"EF=\@tempcnta
+    \lowercase{\expandafter\pxhy@next\csname
+        pxhy@uhb/\string^^ef\endcsname^^ef}%
+  }
+  \xdef\pxhy@unprotect@high@bytes{%
+    \unexpanded{\ifx^^ef\pxhy@std@EF}%
+      \unexpanded\expandafter{\pxhy@unprotect@high@bytes}%
+    \unexpanded{\fi}%
+  }
+  \ltx@GlobalPrependToMacro\pdfstringdefPreHook{\pxhy@unprotect@high@bytes}
+
+\fi
+\endgroup
+\fi
 %--------------------------------------- Support for 'otfutf'
 \ifpxhy@otfutf
 
@@ -961,15 +1062,98 @@ pxhy@fallback@geta = \ifpxhy@fallback@geta true\else false\fi^^J%
 \fi
 
 \fi
+%--------------------------------------- Extended JIS mapping
+\ifpxhy@extjis@map             %<*extjis-map>
+\begingroup
+
+\def\pxhy@next#1#2#3#4{%
+  \@tempcnta"#1\relax\@tempcntb#3\relax
+  \chardef\pxhy@tmpa\numexpr#4+1\relax
+  \@whilenum{\@tempcntb<\pxhy@tmpa}\do{%
+    \expandafter\xdef\csname pxhy@uc/\the\@tempcnta\endcsname{%
+      \unexpanded{#2}\the\@tempcntb}%
+    \advance\@tempcnta\@ne \advance\@tempcntb\@ne}%
+}
+
+%% add special mapping
+\ifnum \jis"2121="8140 % sjis
+  \pxhy@next{2460}{\207\10}{0}{7}
+  \pxhy@next{2468}{\207\11}{0}{7}
+  \pxhy@next{2470}{\207\12}{0}{3}
+  \pxhy@next{2160}{\207\12}{4}{7}
+  \pxhy@next{2164}{\207\13}{0}{5}
+  \pxhy@next{3349}{\207\13}{7}{7}
+  \pxhy@next{3314}{\207\14}{0}{0}
+  \pxhy@next{3322}{\207\14}{1}{1}
+  \pxhy@next{334D}{\207\14}{2}{2}
+  \pxhy@next{3318}{\207\14}{3}{3}
+  \pxhy@next{3327}{\207\14}{4}{4}
+  \pxhy@next{3303}{\207\14}{5}{5}
+  \pxhy@next{3336}{\207\14}{6}{6}
+  \pxhy@next{3351}{\207\14}{7}{7}
+  \pxhy@next{3357}{\207\15}{0}{0}
+  \pxhy@next{330D}{\207\15}{1}{1}
+  \pxhy@next{3326}{\207\15}{2}{2}
+  \pxhy@next{3323}{\207\15}{3}{3}
+  \pxhy@next{332B}{\207\15}{4}{4}
+  \pxhy@next{334A}{\207\15}{5}{5}
+  \pxhy@next{333B}{\207\15}{6}{6}
+  \pxhy@next{339C}{\207\15}{7}{7}
+  \pxhy@next{339D}{\207\16}{0}{1}
+  \pxhy@next{338E}{\207\16}{2}{3}
+  \pxhy@next{33C4}{\207\16}{4}{4}
+  \pxhy@next{33A1}{\207\16}{5}{5}
+  \pxhy@next{337B}{\207\17}{6}{6}
+  \pxhy@next{301D}{\207\20}{0}{0}
+  \pxhy@next{301F}{\207\20}{1}{1}
+  \pxhy@next{2116}{\207\20}{2}{2}
+  \pxhy@next{33CD}{\207\20}{3}{3}
+  \pxhy@next{2121}{\207\20}{4}{4}
+  \pxhy@next{32A4}{\207\20}{5}{7}
+  \pxhy@next{32A7}{\207\21}{0}{1}
+  \pxhy@next{3231}{\207\21}{2}{3}
+  \pxhy@next{3239}{\207\21}{4}{4}
+  \pxhy@next{337E}{\207\21}{5}{5}
+  \pxhy@next{337D}{\207\21}{6}{6}
+  \pxhy@next{337C}{\207\21}{7}{7}
+  \pxhy@next{222E}{\207\22}{3}{3}
+  \pxhy@next{2211}{\207\22}{4}{4}
+  \pxhy@next{221F}{\207\23}{0}{0}
+  \pxhy@next{22BF}{\207\23}{1}{1}
+  \pxhy@next{FF61}{\24}{1}{7}
+  \pxhy@next{FF68}{\25}{0}{7}
+  \pxhy@next{FF70}{\26}{0}{7}
+  \pxhy@next{FF78}{\27}{0}{7}
+  \pxhy@next{FF80}{\30}{0}{7}
+  \pxhy@next{FF88}{\31}{0}{7}
+  \pxhy@next{FF90}{\32}{0}{7}
+  \pxhy@next{FF98}{\33}{0}{7}
+\else\ifnum\jis"2121="A1A1 % euc
+  \pxhy@next{FF61}{\216\24}{1}{7}
+  \pxhy@next{FF68}{\216\25}{0}{7}
+  \pxhy@next{FF70}{\216\26}{0}{7}
+  \pxhy@next{FF78}{\216\27}{0}{7}
+  \pxhy@next{FF80}{\216\30}{0}{7}
+  \pxhy@next{FF88}{\216\31}{0}{7}
+  \pxhy@next{FF90}{\216\32}{0}{7}
+  \pxhy@next{FF98}{\216\33}{0}{7}
+\fi\fi
+
+%% \pxhy@hkcdot
+\global\pxhy@csletcs{pxhy@hkcdot}{pxhy@uc/\number"FF65}
+
+\endgroup
+\fi                             %</extjis-map>
 %--------------------------------------- Redefine text commands for PD1
+\ifpxhy@charcmds                %<*charcmds>
 
+%% \pxhy@cc@jis@only
+\chardef\pxhy@cc@jis@only=0
 %% \pxhy@pdfenc
 \edef\pxhy@pdfenc{%
   \ifpxhy@hy@unicode PU\else PD1\fi
 }
 
-\ifpxhy@charcmds                %<*charcmds>
-
 %%<+> \pxDeclarePdfTextCommand{\CS}{<jis>}{<ucs>}
 \@onlypreamble\pxDeclarePdfTextCommand
 \newcommand*\pxDeclarePdfTextCommand[3]{%
@@ -986,15 +1170,6 @@ pxhy@fallback@geta = \ifpxhy@fallback@geta true\else false\fi^^J%
    {\pxhy@revoke@pdf@tcc{#1}{#2}}%
 }
 
-\else                           %<*!textcmd>
-
-\@onlypreamble\pxDeclarePdfTextCommand
-\newcommand*\pxDeclarePdfTextCommand[3]{}
-\@onlypreamble\pxDeclarePdfTextComposite
-\newcommand*\pxDeclarePdfTextComposite[4]{}
-
-\fi                             %</textcmd>
-
 %% \pxhy@revoke@pdf@tc
 \@onlypreamble\pxhy@revoke@pdf@tc
 \def\pxhy@revoke@pdf@tc#1{%
@@ -1022,7 +1197,8 @@ pxhy@fallback@geta = \ifpxhy@fallback@geta true\else false\fi^^J%
 %% \pxhy@decl@pdf@tc
 \@onlypreamble\pxhy@decl@pdf@tc
 \def\pxhy@decl@pdf@tc#1#2{%
-  \pxhy@get@body{#1}{#2}%
+  \edef\pxhy@next{{#1}{\ifx\pxhy@mt#2\pxhy@mt FFFD\else#2\fi}}%
+  \expandafter\pxhy@get@body\pxhy@next
   \ifx\pxhy@body\@undefined
     \let\pxhy@next\@secondoftwo
   \else
@@ -1043,30 +1219,47 @@ pxhy@fallback@geta = \ifpxhy@fallback@geta true\else false\fi^^J%
     \pxhy@get@jchar{\ucs"#2}%
     \let\pxhy@body\pxhy@jchar
   }%
-\else                           %<*!upTeX>
-  \ifpxhy@uniescape
+\else\ifpxhy@hy@unicode         %<*unicode>
+  \def\pxhy@get@body#1#2{%
+    \def\pxhy@body{\unichar{"#2}}%
+  }%
+\else\ifpxhy@uniescape          %<*uniescape>
     \def\pxhy@get@body#1#2{%
-      \ifx\pxhy@end#1\pxhy@end
+      \ifx\pxhy@mt#1\pxhy@mt
         \def\pxhy@body{\0x#2}%
       \else
         \pxhy@get@jchar{\jis"#1}%
         \let\pxhy@body\pxhy@jchar
       \fi
     }%
-  \else
+\else                           %<*!>
+  \chardef\pxhy@cc@jis@only=1
     \def\pxhy@get@body#1#2{%
-      \ifx\pxhy@end#1\pxhy@end
+      \ifx\pxhy@mt#1\pxhy@mt
         \let\pxhy@body\@undefined
       \else
         \pxhy@get@jchar{\jis"#1}%
         \let\pxhy@body\pxhy@jchar
       \fi
     }%
-  \fi
-\fi                             %</upTeX>
+\fi\fi\fi                       %</>
 
 %%%%%%%%%%%%%%%%%%%% the definitions
-\ifpxhy@hy@unicode\else         %<!*unicode>
+\ifpxhy@hy@unicode              %<*unicode>
+
+% The PU encoding has already done the job.
+% I supplement some definitions.
+\def\pxhy@next#1#2{%
+  \expandafter\ifx\csname PU\string#1\endcsname\relax
+    \DeclareTextCommand{#1}{PU}{#2}\fi}
+\pxhy@next{\guillemetleft}{\80\253}%00AB
+\pxhy@next{\guillemetright}{\80\273}%00BB
+\pxhy@next{\textborn}{\9046\005}%2605
+\pxhy@next{\textfinalsigma}{\83\302}%03C2
+\pxhy@next{\textxgeq}{\9042\145}%2265
+\pxhy@next{\textxleq}{\9042\144}%2264
+
+\else                           %<!*unicode>
 
 % JIS X 0213 does not distinguish the following pairs:
 %  - circumflex(U+02C6) and asciicircum(U+005E)
@@ -1084,6 +1277,9 @@ pxhy@fallback@geta = \ifpxhy@fallback@geta true\else false\fi^^J%
 \DeclareTextCommand{\ij}{PD1}{ij}% needed?
 \DeclareTextCommand{\textspace}{PD1}{\040}
 \DeclareTextCommand{\textquotesingle}{PD1}{\047}
+\DeclareTextCommand{\textasteriskcentered}{PD1}{*}
+\DeclareTextCommand{\textanoteleia}{PD1}{\textperiodcentered}
+\DeclareTextCommand{\texterotimatiko}{PD1}{;}
 
 %% Some adjustments on accents.
 \DeclareTextAccent{\H}{PD1}{\texthungarumlaut}
@@ -1092,6 +1288,9 @@ pxhy@fallback@geta = \ifpxhy@fallback@geta true\else false\fi^^J%
 \DeclareTextAccent{\u}{PD1}{\textasciibreve}
 \DeclareTextCompositeCommand{\u}{PD1}{\@empty}{\textasciibreve}
 \DeclareTextCompositeCommand{\u}{PD1}{\ }{\textasciibreve}
+\DeclareTextAccent{\U}{PD1}{\textasciibreve}
+\DeclareTextCompositeCommand{\U}{PD1}{\@empty}{\textasciibreve}
+\DeclareTextCompositeCommand{\U}{PD1}{\ }{\textasciibreve}
 \DeclareTextAccent{\k}{PD1}{\textogonek}
 \DeclareTextCompositeCommand{\k}{PD1}{\@empty}{\textogonek}
 \DeclareTextCompositeCommand{\k}{PD1}{\ }{\textogonek}
@@ -1335,10 +1534,12 @@ pxhy@fallback@geta = \ifpxhy@fallback@geta true\else false\fi^^J%
 \pxDeclarePdfTextCommand{\CYRD}{2725}{0414}
 \pxDeclarePdfTextCommand{\CYRE}{2726}{0415}
 \pxDeclarePdfTextCommand{\CYRYO}{2727}{0401}
+\pxDeclarePdfTextComposite{\"}{\CYRE}{2727}{0401}
 \pxDeclarePdfTextCommand{\CYRZH}{2728}{0416}
 \pxDeclarePdfTextCommand{\CYRZ}{2729}{0417}
 \pxDeclarePdfTextCommand{\CYRI}{272A}{0418}
 \pxDeclarePdfTextCommand{\CYRISHRT}{272B}{0419}
+\pxDeclarePdfTextComposite{\U}{\CYRI}{272B}{0419}
 \pxDeclarePdfTextCommand{\CYRK}{272C}{041A}
 \pxDeclarePdfTextCommand{\CYRL}{272D}{041B}
 \pxDeclarePdfTextCommand{\CYRM}{272E}{041C}
@@ -1368,10 +1569,12 @@ pxhy@fallback@geta = \ifpxhy@fallback@geta true\else false\fi^^J%
 \pxDeclarePdfTextCommand{\cyrd}{2755}{0434}
 \pxDeclarePdfTextCommand{\cyre}{2756}{0435}
 \pxDeclarePdfTextCommand{\cyryo}{2757}{0451}
+\pxDeclarePdfTextComposite{\"}{\cyre}{2757}{0451}
 \pxDeclarePdfTextCommand{\cyrzh}{2758}{0436}
 \pxDeclarePdfTextCommand{\cyrz}{2759}{0437}
 \pxDeclarePdfTextCommand{\cyri}{275A}{0438}
 \pxDeclarePdfTextCommand{\cyrishrt}{275B}{0439}
+\pxDeclarePdfTextComposite{\U}{\cyri}{275B}{0439}
 \pxDeclarePdfTextCommand{\cyrk}{275C}{043A}
 \pxDeclarePdfTextCommand{\cyrl}{275D}{043B}
 \pxDeclarePdfTextCommand{\cyrm}{275E}{043C}
@@ -1458,19 +1661,20 @@ pxhy@fallback@geta = \ifpxhy@fallback@geta true\else false\fi^^J%
 % Give a substitute definition to characters that appear as
 % ligatures, since otherwise hyperref leaves some garbage in
 % output pdf-strings when such ligatures appear.
-\ifpxhy@uptex\else
-  \ifpxhy@uniescape\else
+\ifnum\pxhy@cc@jis@only>\z@
     \DeclareTextCommand{\textendash}{PD1}{--}
     \DeclareTextCommand{\textquestiondown}{PD1}{}% empty
     \DeclareTextCommand{\textexclamdown}{PD1}{}% empty
+\fi
+\ifnum\pxhy@cc@jis@only>\z@
+  \ifx\pxhy@hkcdot\@undefined\else
+    \DeclareTextCommand{\textperiodcentered}{PD1}{\pxhy@hkcdot}
   \fi
 \fi
 
 \fi                             %</unicode>
 %%%%%%%%%%%%%%%%%%%% done
 
-\ifpxhy@charcmds                %<*charcmds>
-
   %% \pxhy@disable@tc@commands
   \def\pxhy@disable@tc@commands{%
     \let\yen\textyen
@@ -1486,22 +1690,14 @@ pxhy@fallback@geta = \ifpxhy@fallback@geta true\else false\fi^^J%
   %% register to 'disable' list
   \ltx@GlobalPrependToMacro\pdfstringdefPreHook{\pxhy@disable@tc@commands}
 
-  \ifpxhy@hy@unicode            %<*unicode>
+\else                           %<*!textcmd>
 
-    %% supplementary definitions
-    \def\pxhy@next#1#2{%
-      \expandafter\ifx\csname PU\string#1\endcsname\relax
-        \DeclareTextCommand{#1}{PU}{#2}\fi}
-    \pxhy@next{\guillemetleft}{\80\253}%00AB
-    \pxhy@next{\guillemetright}{\80\273}%00BB
-    \pxhy@next{\textborn}{\9046\005}%2605
-    \pxhy@next{\textfinalsigma}{\83\302}%03C2
-    \pxhy@next{\textxgeq}{\9042\145}%2265
-    \pxhy@next{\textxleq}{\9042\144}%2264
+\@onlypreamble\pxDeclarePdfTextCommand
+\newcommand*\pxDeclarePdfTextCommand[3]{}
+\@onlypreamble\pxDeclarePdfTextComposite
+\newcommand*\pxDeclarePdfTextComposite[4]{}
 
-  \fi                           %</unicode>
 \fi                             %</textcmd>
-
 %--------------------------------------- Enable hyperref unicode
 \ifpxhy@hy@unicode
 
-- 
cgit v1.2.3

