From 444d7120aa867d5d620cb7ec8ede194f1c7a1a0e Mon Sep 17 00:00:00 2001 From: khaled Date: Wed, 9 May 2012 12:40:45 +0000 Subject: [PATCH] Fix \the\mathcode when used with \Umathcode http://tug.org/pipermail/luatex/2012-May/003611.html git-svn-id: https://foundry.supelec.fr/svn/luatex/trunk@4410 0b2b3880-5936-4365-a048-eb17d2e5a6bf --- source/texk/web2c/luatexdir/tex/mathcodes.h | 4 +-- source/texk/web2c/luatexdir/tex/mathcodes.w | 38 ++++++++++++++++++++--------- source/texk/web2c/luatexdir/tex/scanning.w | 6 ++--- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/source/texk/web2c/luatexdir/tex/mathcodes.h b/source/texk/web2c/luatexdir/tex/mathcodes.h index 145a3f9e6..b65a741e5 100644 --- a/source/texk/web2c/luatexdir/tex/mathcodes.h +++ b/source/texk/web2c/luatexdir/tex/mathcodes.h @@ -1,6 +1,6 @@ /* mathcodes.h - Copyright 2009 Taco Hoekwater + Copyright 2009-2012 Taco Hoekwater This file is part of LuaTeX. @@ -43,7 +43,7 @@ void set_math_code(int n, int mathfamily, int mathcharacter, quarterword gl); mathcodeval get_math_code(int n); -int get_math_code_num(int n); +int get_math_code_num(int n, boolean compat); int get_del_code_num(int n); mathcodeval scan_mathchar(int extcode); mathcodeval scan_delimiter_as_mathchar(int extcode); diff --git a/source/texk/web2c/luatexdir/tex/mathcodes.w b/source/texk/web2c/luatexdir/tex/mathcodes.w index dd27face6..2b7b9e12a 100644 --- a/source/texk/web2c/luatexdir/tex/mathcodes.w +++ b/source/texk/web2c/luatexdir/tex/mathcodes.w @@ -1,6 +1,7 @@ % mathnodes.w % -% Copyright 2006-2010 Taco Hoekwater +% Copyright 2006-2012 Taco Hoekwater +% Copyright 2012 Khaled Hosny % This file is part of LuaTeX. @@ -207,20 +208,33 @@ mathcodeval get_math_code(int n) @ @c -int get_math_code_num(int n) +int get_math_code_num(int n, boolean compat) { mathcodeval mval; mval = get_math_code(n); - if (mval.origin_value == tex_mathcode) { - return (mval.class_value * 16 + mval.family_value) * 256 + - mval.character_value; - } else if (mval.origin_value == aleph_mathcode) { - return (mval.class_value * 256 + mval.family_value) * 65536 + - mval.character_value; - } else if (mval.origin_value == xetexnum_mathcode - || mval.origin_value == xetex_mathcode) { - return (mval.class_value + (mval.family_value * 8)) * (65536 * 32) + - mval.character_value; + if (compat) { /* \.{\\the\\mathcode} */ + if (mval.class_value > 7 + || mval.family_value > 15 + || mval.character_value > 255) { + print_err("Extended mathchar used as mathchar"); + help2("A mathchar number must be between 0 and 32767.", + "I changed this one to zero."); + int_error(mval.character_value); + mval = get_math_code(0); + } + return mval.class_value * 4096 + mval.family_value * 256 + mval.character_value; + } else { /* \.{\\the\\Umathcodenum} */ + if (mval.origin_value == tex_mathcode) { + return (mval.class_value * 16 + mval.family_value) * 256 + + mval.character_value; + } else if (mval.origin_value == aleph_mathcode) { + return (mval.class_value * 256 + mval.family_value) * 65536 + + mval.character_value; + } else if (mval.origin_value == xetexnum_mathcode + || mval.origin_value == xetex_mathcode) { + return (mval.class_value + (mval.family_value * 8)) * (65536 * 32) + + mval.character_value; + } } return 0; } diff --git a/source/texk/web2c/luatexdir/tex/scanning.w b/source/texk/web2c/luatexdir/tex/scanning.w index d8e8a0c14..c154e0c91 100644 --- a/source/texk/web2c/luatexdir/tex/scanning.w +++ b/source/texk/web2c/luatexdir/tex/scanning.w @@ -1,6 +1,6 @@ % scanning.w % -% Copyright 2009-2010 Taco Hoekwater +% Copyright 2009-2012 Taco Hoekwater % This file is part of LuaTeX. @@ -646,7 +646,7 @@ void scan_something_internal(int level, boolean negative) /* Fetch a character code from some table */ scan_char_num(); if (m == math_code_base) { - cur_val1 = get_math_code_num(cur_val); + cur_val1 = get_math_code_num(cur_val, true); scanned_result(cur_val1, int_val_level); } else if (m == lc_code_base) { cur_val1 = get_lc_code(cur_val); @@ -673,7 +673,7 @@ void scan_something_internal(int level, boolean negative) case extdef_math_code_cmd: /* Fetch an extended math code table value */ scan_char_num(); - cur_val1 = get_math_code_num(cur_val); + cur_val1 = get_math_code_num(cur_val, false); scanned_result(cur_val1, int_val_level); break; case toks_register_cmd: -- 2.11.4.GIT