diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2011-12-19 14:33:12 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2011-12-19 14:33:12 +0000 |
commit | b900237b52142fc387930db473e26d901673a414 (patch) | |
tree | f7ddfff9ba923d55fee6a8af6e3142a9f48bec87 /Build/source/texk/web2c/ptexdir | |
parent | fbd50cdbd2c221a7f2a9f5bac3f4db0848763c64 (diff) |
(e-)(u)pTeX: Avoid Segmentation fault for japanese \catcode or \kcatcode
Patch from Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
git-svn-id: svn://tug.org/texlive/trunk@24874 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/ptexdir')
-rw-r--r-- | Build/source/texk/web2c/ptexdir/ChangeLog | 5 | ||||
-rw-r--r-- | Build/source/texk/web2c/ptexdir/kanji.c | 19 | ||||
-rw-r--r-- | Build/source/texk/web2c/ptexdir/kanji.h | 6 | ||||
-rw-r--r-- | Build/source/texk/web2c/ptexdir/ptex-base.ch | 52 | ||||
-rw-r--r-- | Build/source/texk/web2c/ptexdir/ptex.defines | 3 |
5 files changed, 58 insertions, 27 deletions
diff --git a/Build/source/texk/web2c/ptexdir/ChangeLog b/Build/source/texk/web2c/ptexdir/ChangeLog index d93aa045c0d..3eb1be48e42 100644 --- a/Build/source/texk/web2c/ptexdir/ChangeLog +++ b/Build/source/texk/web2c/ptexdir/ChangeLog @@ -1,3 +1,8 @@ +2011-12-19 Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp> + + * ptex-base.ch, ptex.defines, kanji.[ch]: Avoid Segmentation + fault for japanese \catcode or \kcatcode. + 2011-12-08 Peter Breitenlohner <peb@mppmu.mpg.de> * ptex-base.ch: Ensure that `hi(#)==#'. diff --git a/Build/source/texk/web2c/ptexdir/kanji.c b/Build/source/texk/web2c/ptexdir/kanji.c index d0a3766c25f..ac1769085e7 100644 --- a/Build/source/texk/web2c/ptexdir/kanji.c +++ b/Build/source/texk/web2c/ptexdir/kanji.c @@ -1,6 +1,6 @@ /* * KANJI Code conversion routines. - * (for ptex only) + * (for pTeX and e-pTeX) */ #include "kanji.h" @@ -9,17 +9,10 @@ int sjisterminal; #endif -int check_kanji(integer c) +/* TOKEN */ +boolean check_kanji(integer c) { - /* FIXME: why not 255 (0xff) */ - if (0 <= c && c <= 256) return -1; /* ascii without catcode */ - if (iskanji1(Hi(c)) && iskanji2(Lo(c))) return 1; - return 0; /* ascii with catcode */ -} - -boolean is_kanji(integer c) -{ - return (iskanji1(Hi(c)) && iskanji2(Lo(c))); + return is_char_kanji(c); } boolean is_char_ascii(integer c) @@ -27,9 +20,9 @@ boolean is_char_ascii(integer c) return (0 <= c && c < 0x100); } -boolean is_wchar_ascii(integer c) +boolean is_char_kanji(integer c) { - return (!is_char_ascii(c) && !is_kanji(c)); + return (iskanji1(Hi(c)) && iskanji2(Lo(c))); } boolean ismultiprn(integer c) diff --git a/Build/source/texk/web2c/ptexdir/kanji.h b/Build/source/texk/web2c/ptexdir/kanji.h index 5d33b97d9fa..1be8729cf3c 100644 --- a/Build/source/texk/web2c/ptexdir/kanji.h +++ b/Build/source/texk/web2c/ptexdir/kanji.h @@ -23,12 +23,10 @@ extern int sjisterminal; extern int check_kanji (integer c); #define checkkanji check_kanji -extern boolean is_kanji (integer c); -#define iskanji is_kanji extern boolean is_char_ascii (integer c); #define ischarascii is_char_ascii -extern boolean is_wchar_ascii (integer c); -#define iswcharascii is_wchar_ascii +extern boolean is_char_kanji (integer c); +#define ischarkanji is_char_kanji extern boolean ismultiprn (integer c); extern integer calc_pos (integer c); #define calcpos calc_pos diff --git a/Build/source/texk/web2c/ptexdir/ptex-base.ch b/Build/source/texk/web2c/ptexdir/ptex-base.ch index 569018c2946..759e4b5bbd0 100644 --- a/Build/source/texk/web2c/ptexdir/ptex-base.ch +++ b/Build/source/texk/web2c/ptexdir/ptex-base.ch @@ -1194,6 +1194,35 @@ for k:="A" to "Z" do { $\.{@@"20}+|k| = |kcatcodekey|(|fromKUTEN|(|HILO|(k,1))$ } @z +@x +@ @<Show the halfword code in |eqtb[n]|@>= +if n<math_code_base then + begin if n<lc_code_base then + begin print_esc("catcode"); print_int(n-cat_code_base); + end +@y +@ @<Show the halfword code in |eqtb[n]|@>= +if n<math_code_base then + begin if n<kcat_code_base then + begin print_esc("catcode"); print_int(n-cat_code_base); + end + else if n<auto_xsp_code_base then + begin print_esc("kcatcode"); print_int(n-kcat_code_base); + end + else if n<inhibit_xsp_code_base then + begin print_esc("xspcode"); print_int(n-auto_xsp_code_base); + end + else if n<kinsoku_base then + begin print("(inhibitxspcode table) "); print_int(n-inhibit_xsp_code_base); + end + else if n<kansuji_base then + begin print("(kinsoku table) "); print_int(n-kinsoku_base); + end + else if n<lc_code_base then + begin print_esc("kansujichar"); print_int(n-kansuji_base); + end +@z + @x [17.236] l.5092 - pTeX: cur_jfam_code, jchr_widow_penalty @d cur_fam_code=44 {current family} @d escape_char_code=45 {escape character for token output} @@ -1965,12 +1994,16 @@ else scanned_result(eqtb[m+cur_val].int)(int_val); @y if m=math_code_base then scanned_result(ho(math_code(cur_val)))(int_val) else if m=kcat_code_base then scanned_result(equiv(m+kcatcodekey(cur_val)))(int_val) -else if m<math_code_base then - begin if is_kanji(cur_val) then +else if m<math_code_base then { \.{\\lccode}, \.{\\uccode}, \.{\\sfcode}, \.{\\catcode} } + begin if not is_char_ascii(cur_val) then scanned_result(equiv(m+Hi(cur_val)))(int_val) else scanned_result(equiv(m+cur_val))(int_val) end -else scanned_result(eqtb[m+cur_val].int)(int_val); +else { \.{\\delcode} } + begin if not is_char_ascii(cur_val) then + scanned_result(eqtb[m+Hi(cur_val)].int)(int_val) + else scanned_result(eqtb[m+cur_val].int)(int_val) + end; @z @x [26.420] l.8474 - pTeX: Fetch a box dimension: dir_node @@ -2069,7 +2102,7 @@ end; @y procedure scan_char_num; begin scan_int; -if not is_char_ascii(cur_val)and not check_kanji(cur_val) then {|wchar_token|} +if not is_char_ascii(cur_val) and not is_char_kanji(cur_val) then begin print_err("Bad character code"); @.Bad character code@> help2("A character number must be between 0 and 255, or KANJI code.")@/ @@ -5626,7 +5659,10 @@ def_code: begin @<Let |m| be the minimal legal code value, based on |cur_chr|@>; @<Let |n| be the largest legal code value, based on |cur_chr|@>; p:=cur_chr; scan_char_num; - if p=kcat_code_base then p:=p+kcatcodekey(cur_val) else p:=p+cur_val; + if p=kcat_code_base then p:=p+kcatcodekey(cur_val) + else if not is_char_ascii(cur_val) then p:=p+Hi(cur_val) + { If |cur_val| is a KANJI code, we use its upper half, as the case of retrieving. } + else p:=p+cur_val; scan_optional_equals; scan_int; if ((cur_val<m)and(p<del_code_base))or(cur_val>n) then begin print_err("Invalid code ("); print_int(cur_val); @@ -5913,7 +5949,7 @@ set_kansuji_char: print_esc("kansujichar"); @ @<Assignments@>= set_kansuji_char: begin p:=cur_chr; scan_int; n:=cur_val; scan_optional_equals; scan_int; -if not check_kanji(cur_val) then +if not is_char_kanji(cur_val) then begin print_err("Invalid KANSUJI char ("); print_hex(cur_val); print_char(")"); @.Invalid KANSUJI char@> @@ -6049,7 +6085,7 @@ end; @ @<Assignments@>= assign_inhibit_xsp_code: begin p:=cur_chr; scan_int; n:=cur_val; scan_optional_equals; scan_int; -if check_kanji(n) then +if is_char_kanji(n) then begin j:=get_inhibit_pos(tokanji(n),new_pos); if j=no_entry then begin print_err("Inhibit table is full!!"); @@ -6123,7 +6159,7 @@ end; @ @<Assignments@>= assign_kinsoku: begin p:=cur_chr; scan_int; n:=cur_val; scan_optional_equals; scan_int; -if is_char_ascii(n) or check_kanji(n) then +if is_char_ascii(n) or is_char_kanji(n) then begin j:=get_kinsoku_pos(tokanji(n),new_pos); if j=no_entry then begin print_err("KINSOKU table is full!!"); diff --git a/Build/source/texk/web2c/ptexdir/ptex.defines b/Build/source/texk/web2c/ptexdir/ptex.defines index b7680c84c7c..b8729a1839b 100644 --- a/Build/source/texk/web2c/ptexdir/ptex.defines +++ b/Build/source/texk/web2c/ptexdir/ptex.defines @@ -21,9 +21,8 @@ @define function fromKUTEN (); @define function checkkanji (); -@define function iskanji (); @define function ischarascii (); -@define function iswcharascii (); +@define function ischarkanji (); @define function ismultiprn (); @define function calcpos (); @define function kcatcodekey (); |