summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/uptexdir
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2011-12-19 14:33:12 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2011-12-19 14:33:12 +0000
commitb900237b52142fc387930db473e26d901673a414 (patch)
treef7ddfff9ba923d55fee6a8af6e3142a9f48bec87 /Build/source/texk/web2c/uptexdir
parentfbd50cdbd2c221a7f2a9f5bac3f4db0848763c64 (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/uptexdir')
-rw-r--r--Build/source/texk/web2c/uptexdir/ChangeLog10
-rw-r--r--Build/source/texk/web2c/uptexdir/kanji.c36
-rw-r--r--Build/source/texk/web2c/uptexdir/kanji.h8
-rw-r--r--Build/source/texk/web2c/uptexdir/uppltotf.ch2
-rw-r--r--Build/source/texk/web2c/uptexdir/uptex-m.ch50
-rw-r--r--Build/source/texk/web2c/uptexdir/uptex.defines3
-rw-r--r--Build/source/texk/web2c/uptexdir/uptftopl.ch2
7 files changed, 32 insertions, 79 deletions
diff --git a/Build/source/texk/web2c/uptexdir/ChangeLog b/Build/source/texk/web2c/uptexdir/ChangeLog
index 99b5ffb9fc8..b8cbfe38918 100644
--- a/Build/source/texk/web2c/uptexdir/ChangeLog
+++ b/Build/source/texk/web2c/uptexdir/ChangeLog
@@ -1,3 +1,13 @@
+2011-12-19 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * uptex-m.ch, kanji.[ch]: Drop unused param2 of check_kanji().
+
+2011-12-19 Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
+
+ * uptex-m.ch, uptex.defines, kanji.[ch], uppltotf.ch,
+ uppltotf.ch: Avoid Segmentation fault for japanese \catcode
+ or \kcatcode.
+
2011-12-04 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
* uptex-m.ch: change min_halfword because the ConTeXt with
diff --git a/Build/source/texk/web2c/uptexdir/kanji.c b/Build/source/texk/web2c/uptexdir/kanji.c
index 36ffdc22db5..62ea30f1805 100644
--- a/Build/source/texk/web2c/uptexdir/kanji.c
+++ b/Build/source/texk/web2c/uptexdir/kanji.c
@@ -1,6 +1,6 @@
/*
* KANJI Code conversion routines.
- * (for ptex only)
+ * (for upTeX and e-upTeX)
*/
#include "kanji.h"
@@ -15,29 +15,12 @@
int sjisterminal;
#endif
-/* m: for debug */
-integer check_kanji (integer c,integer m)
+/* TOKEN */
+boolean check_kanji (integer c)
{
- if (c > CS_TOKEN_FLAG) return 0;
- if (is_internalUPTEX()) {
- if ((c & CJK_TOKEN_FLAG) < CJK_CHAR_LIMIT) {
- if (XXHi(c)==0) return 1;
- else if (XXHi(c)>=KCAT_KANJI && XXHi(c)<=KCAT_HANGUL) return 2;
- }
- } else {
- if ((XHi(c)==0) &&
- iskanji1(Hi(c)) && iskanji2(Lo(c))) {
- if (XXHi(c)==0) return 1;
- else if (XXHi(c)>=KCAT_KANJI && XXHi(c)<=KCAT_HANGUL) return 2;
- }
- }
- if (0 <= c && c <= 255) return -1; /* ascii without catcode */
- return 0; /* ascii with catcode */
-}
-
-boolean is_kanji(integer c)
-{
- return (iskanji1(Hi(c)) && iskanji2(Lo(c)));
+ if (c > CS_TOKEN_FLAG) return false;
+ else if (!(XXHi(c)>=KCAT_KANJI && XXHi(c)<=KCAT_HANGUL)) return false;
+ else return is_char_kanji(c);
}
boolean is_char_ascii(integer c)
@@ -45,9 +28,12 @@ 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));
+ if (is_internalUPTEX())
+ return (c>=0&&(c & CJK_TOKEN_FLAG) < CJK_CHAR_LIMIT);
+ else
+ return iskanji1(Hi(c)) && iskanji2(Lo(c));
}
boolean ismultiprn(integer c)
diff --git a/Build/source/texk/web2c/uptexdir/kanji.h b/Build/source/texk/web2c/uptexdir/kanji.h
index 76e577bdd0a..a6e92c40760 100644
--- a/Build/source/texk/web2c/uptexdir/kanji.h
+++ b/Build/source/texk/web2c/uptexdir/kanji.h
@@ -23,14 +23,12 @@ extern int sjisterminal;
#define Hi(x) BYTE3(x)
#define Lo(x) BYTE4(x)
-extern integer check_kanji (integer c, integer m);
+extern boolean 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/uptexdir/uppltotf.ch b/Build/source/texk/web2c/uptexdir/uppltotf.ch
index 61326987d0a..acaf3d45475 100644
--- a/Build/source/texk/web2c/uptexdir/uppltotf.ch
+++ b/Build/source/texk/web2c/uptexdir/uppltotf.ch
@@ -46,7 +46,7 @@ if (first_byte<@"21)
if (second_byte<@"21)or(second_byte>@"7E) then valid_jis_code:=false;
@y
begin valid_jis_code:=true;
-if (cx>@"FFFF)or(check_kanji(fromDVI(cx),0)<>1)
+if (cx>@"FFFF)or(not is_char_kanji(fromDVI(cx)))
or(toDVI(fromDVI(cx))<>cx) then valid_jis_code:=false;
@z
diff --git a/Build/source/texk/web2c/uptexdir/uptex-m.ch b/Build/source/texk/web2c/uptexdir/uptex-m.ch
index ce5f134d455..71c57cffec4 100644
--- a/Build/source/texk/web2c/uptexdir/uptex-m.ch
+++ b/Build/source/texk/web2c/uptexdir/uptex-m.ch
@@ -306,7 +306,7 @@ token that stands for a control sequence; is a multiple of~256, less~1}
end
else begin m:=Hi(info(p)); c:=Lo(info(p));
@y
- if check_kanji(info(p),1)=2 then {|wchar_token|}
+ if check_kanji(info(p)) then {|wchar_token|}
begin m:=info(p) div max_cjk_val; c:=info(p) mod max_cjk_val; end
else begin m:=info(p) div max_char_val; c:=info(p) mod max_char_val;
@z
@@ -354,7 +354,7 @@ if ((kcp mod @'10)>0)and(nrestmultichr(kcp)>0) then p:=p-(kcp mod @'10);
begin cur_input:=input_stack[base_ptr-1];
s:=get_avail; info(s):=Lo(buffer[loc]);
@y
- begin if (link(start)=null)and(check_kanji(info(start),2)=2) then {|wchar_token|}
+ begin if (link(start)=null)and(check_kanji(info(start))) then {|wchar_token|}
begin cur_input:=input_stack[base_ptr-1];
s:=get_avail; info(s):=(buffer[loc] mod max_char_val);
@z
@@ -470,7 +470,7 @@ if cat=other_kchar then k:=k-multilenbuffchar(cur_chr)+1; {now |k| points to fir
else
begin cur_cmd:=Hi(t); cur_chr:=Lo(t);
@y
- else if check_kanji(t,3)=2 then {|wchar_token|}
+ else if check_kanji(t) then {|wchar_token|}
begin cur_cmd:=t div max_cjk_val; cur_chr:=t mod max_cjk_val; end
else
begin cur_cmd:=t div max_char_val; cur_chr:=t mod max_char_val;
@@ -492,7 +492,7 @@ if cat=other_kchar then k:=k-multilenbuffchar(cur_chr)+1; {now |k| points to fir
end;
buffer[j]:=Lo(info(p)); incr(j); p:=link(p);
@y
- if check_kanji(info(p),4)=2 then {|wchar_token|}
+ if check_kanji(info(p)) then {|wchar_token|}
begin t:=toBUFF(info(p) mod max_cjk_val);
if BYTE1(t)<>0 then begin buffer[j]:=BYTE1(t); incr(j); end;
if BYTE2(t)<>0 then begin buffer[j]:=BYTE2(t); incr(j); end;
@@ -533,18 +533,6 @@ char_given,math_given: scanned_result(cur_chr)(int_val);
@z
@x
- begin if is_kanji(cur_val) then
-@y
- begin if (cur_val<0)or(cur_val>255) then
-@z
-
-@x
-if not is_char_ascii(cur_val)and not check_kanji(cur_val) then {|wchar_token|}
-@y
-if ((cur_val<0)or(cur_val>255))and(check_kanji(cur_val,6)<>1) then {|wchar_token|}
-@z
-
-@x
if (cur_cmd=kanji)or(cur_cmd=kana)or(cur_cmd=other_kchar) then {|wchar_token|}
@y
if (cur_cmd>=kanji)and(cur_cmd<=hangul) then {|wchar_token|}
@@ -1000,7 +988,7 @@ if (t<cs_token_flag+single_base)and(not check_kanji(t)) then
@y
@<Change the case of the token in |p|, if a change is appropriate@>=
t:=info(p);
-if (t<cs_token_flag+single_base)and(check_kanji(t,7)<2) then
+if (t<cs_token_flag+single_base)and(not check_kanji(t)) then
begin c:=t mod max_char_val;
@z
@@ -1019,14 +1007,6 @@ undump_kanji(fmt_file);
@z
@x
-begin p:=cur_chr; scan_int; n:=cur_val; scan_optional_equals; scan_int;
-if not check_kanji(cur_val) then
-@y
-begin p:=cur_chr; scan_int; n:=cur_val; scan_optional_equals; scan_int;
-if check_kanji(cur_val,8)<>1 then
-@z
-
-@x
@d set_auto_xspacing_code=3
@y
@d set_auto_xspacing_code=3
@@ -1074,26 +1054,6 @@ set_enable_cjk_token: define(enable_cjk_token_code,data,cur_chr);
@z
@x
-assign_inhibit_xsp_code:
-begin p:=cur_chr; scan_int; n:=cur_val; scan_optional_equals; scan_int;
-if check_kanji(n) then
-@y
-assign_inhibit_xsp_code:
-begin p:=cur_chr; scan_int; n:=cur_val; scan_optional_equals; scan_int;
-if check_kanji(n,9)=1 then
-@z
-
-@x
-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
-@y
-assign_kinsoku:
-begin p:=cur_chr; scan_int; n:=cur_val; scan_optional_equals; scan_int;
-if abs(check_kanji(n,10))=1 then
-@z
-
-@x
@ @<Insert a space around the character |p|@>=
if font_dir[font(p)]<>dir_default then
begin KANJI(cx):=info(link(p));
diff --git a/Build/source/texk/web2c/uptexdir/uptex.defines b/Build/source/texk/web2c/uptexdir/uptex.defines
index 9871d4a15e0..28b644e35ff 100644
--- a/Build/source/texk/web2c/uptexdir/uptex.defines
+++ b/Build/source/texk/web2c/uptexdir/uptex.defines
@@ -33,9 +33,8 @@
@define function fromUCS ();
@define function checkkanji ();
-@define function iskanji ();
@define function ischarascii ();
-@define function iswcharascii ();
+@define function ischarkanji ();
@define function ismultiprn ();
@define function calcpos ();
@define function kcatcodekey ();
diff --git a/Build/source/texk/web2c/uptexdir/uptftopl.ch b/Build/source/texk/web2c/uptexdir/uptftopl.ch
index 00ad96fe5f5..25fda2700b1 100644
--- a/Build/source/texk/web2c/uptexdir/uptftopl.ch
+++ b/Build/source/texk/web2c/uptexdir/uptftopl.ch
@@ -57,7 +57,7 @@ if (first_byte<@"21)
if (second_byte<@"21)or(second_byte>@"7E) then valid_jis_code:=false;
@y
begin valid_jis_code:=true;
-if (cx>@"FFFF)or(check_kanji(fromDVI(cx),0)<>1)
+if (cx>@"FFFF)or(not is_char_kanji(fromDVI(cx)))
or(toDVI(fromDVI(cx))<>cx) then valid_jis_code:=false;
@z