| 1 |
%% suppresserrors.ch: support ``suppressing errors'' primitives in LuaTeX |
| 2 |
%% |
| 3 |
%% \suppresslongerror done |
| 4 |
%% \suppressoutererror done |
| 5 |
%% \suppressmathparerror done |
| 6 |
%% The followings are not implemented to e-(u)pTeX: |
| 7 |
%% % \suppressifcsnameerror |
| 8 |
%% % \suppressfontnotfounderror -> we have an error from mktextfm etc. anyway |
| 9 |
%% % \suppressprimitiveerror -> e-(u)pTeX does not produce errors in \pdfprimitive |
| 10 |
%% |
| 11 |
%% \ignoreprimitiveerror (from pdfTeX and XeTeX) |
| 12 |
%% |
| 13 |
%% This change file should be applied after unbalanced-braces.ch. |
| 14 |
|
| 15 |
@x |
| 16 |
@d print_err(#)==begin if interaction=error_stop_mode then wake_up_terminal; |
| 17 |
if file_line_error_style_p then print_file_line |
| 18 |
else print_nl("! "); |
| 19 |
print(#); |
| 20 |
end |
| 21 |
@y |
| 22 |
@d print_err(#)==begin if interaction=error_stop_mode then wake_up_terminal; |
| 23 |
if file_line_error_style_p then print_file_line |
| 24 |
else print_nl("! "); |
| 25 |
print(#); |
| 26 |
end |
| 27 |
@d print_ignored_err(#)==begin |
| 28 |
{An error in original \TeX, but we want to send it only to the log in |
| 29 |
other engines, and without the word |"error"|, which humans and |
| 30 |
software look for.} |
| 31 |
old_selector_ignored_err := selector; |
| 32 |
selector := log_only; |
| 33 |
wlog_cr; wlog('ignored: '); print(#); |
| 34 |
selector := old_selector_ignored_err; |
| 35 |
end |
| 36 |
@z |
| 37 |
|
| 38 |
@x |
| 39 |
else begin xn_over_d:=-u; remainder:=-(v mod d); |
| 40 |
end; |
| 41 |
end; |
| 42 |
@y |
| 43 |
else begin xn_over_d:=-u; remainder:=-(v mod d); |
| 44 |
end; |
| 45 |
end; |
| 46 |
|
| 47 |
function is_bit_set(n: integer; s: small_number): boolean; |
| 48 |
{check if $s$-th bit (one-based) of $n$ is set} |
| 49 |
var m, i: integer; |
| 50 |
begin |
| 51 |
m := 1; |
| 52 |
for i := 1 to s - 1 do |
| 53 |
m := m * 2; |
| 54 |
is_bit_set := (n div m) mod 2; |
| 55 |
end; |
| 56 |
@z |
| 57 |
|
| 58 |
@x |
| 59 |
@d eTeX_state_code=etex_int_base+10 {\eTeX\ state variables} |
| 60 |
@y |
| 61 |
@d suppress_long_error_code=etex_int_base+10 |
| 62 |
@d suppress_outer_error_code=etex_int_base+11 |
| 63 |
@d suppress_mathpar_error_code=etex_int_base+12 |
| 64 |
@d ignore_primitive_error_code=etex_int_base+13 {ignore some primitive/engine errors} |
| 65 |
@d eTeX_state_code=etex_int_base+14 {\eTeX\ state variables} |
| 66 |
@z |
| 67 |
|
| 68 |
@x |
| 69 |
@d read_papersize_special==int_par(read_papersize_special_code) |
| 70 |
@y |
| 71 |
@d read_papersize_special==int_par(read_papersize_special_code) |
| 72 |
@d suppress_long_error==int_par(suppress_long_error_code) |
| 73 |
@d suppress_outer_error==int_par(suppress_outer_error_code) |
| 74 |
@d suppress_mathpar_error==int_par(suppress_mathpar_error_code) |
| 75 |
@d ignore_primitive_error==int_par(ignore_primitive_error_code) |
| 76 |
@z |
| 77 |
|
| 78 |
@x |
| 79 |
@<Glob...@>= |
| 80 |
@!old_setting:0..max_selector; |
| 81 |
@y |
| 82 |
@<Glob...@>= |
| 83 |
@!old_setting:0..max_selector; |
| 84 |
@!old_selector_ignored_err:0..max_selector; { for |print_ignored_err|} |
| 85 |
@z |
| 86 |
|
| 87 |
@x @<Finish line, emit a \.{\\par}@> |
| 88 |
if cur_cmd>=outer_call then check_outer_validity; |
| 89 |
@y |
| 90 |
if (suppress_outer_error=0)and(cur_cmd>=outer_call) then check_outer_validity; |
| 91 |
@z |
| 92 |
|
| 93 |
@x @<Process an active-character...@> |
| 94 |
if cur_cmd>=outer_call then check_outer_validity; |
| 95 |
@y |
| 96 |
if (suppress_outer_error=0)and(cur_cmd>=outer_call) then check_outer_validity; |
| 97 |
@z |
| 98 |
|
| 99 |
@x @<Scan a control...@> |
| 100 |
if cur_cmd>=outer_call then check_outer_validity; |
| 101 |
@y |
| 102 |
if (suppress_outer_error=0)and(cur_cmd>=outer_call) then check_outer_validity; |
| 103 |
@z |
| 104 |
|
| 105 |
@x @<Input from token list, |goto restart| ...@> |
| 106 |
if cur_cmd=dont_expand then |
| 107 |
@<Get the next token, suppressing expansion@> |
| 108 |
else |
| 109 |
begin |
| 110 |
if (cur_cs=end_write)and(mode=0) then |
| 111 |
fatal_error("Unbalanced write command"); |
| 112 |
check_outer_validity; |
| 113 |
end; |
| 114 |
@y |
| 115 |
if cur_cmd=dont_expand then |
| 116 |
@<Get the next token, suppressing expansion@> |
| 117 |
else |
| 118 |
begin |
| 119 |
if (cur_cs=end_write)and(mode=0) then |
| 120 |
fatal_error("Unbalanced write command"); |
| 121 |
if suppress_outer_error=0 then check_outer_validity; |
| 122 |
end; |
| 123 |
@z |
| 124 |
|
| 125 |
@x @<Read next line of file into |buffer|, ...> |
| 126 |
end_file_reading; {resume previous level} |
| 127 |
check_outer_validity; goto restart; |
| 128 |
@y |
| 129 |
end_file_reading; {resume previous level} |
| 130 |
if suppress_outer_error=0 then check_outer_validity; goto restart; |
| 131 |
@z |
| 132 |
|
| 133 |
@x |
| 134 |
if cur_tok=par_token then if long_state<>long_call then |
| 135 |
@<Report a runaway argument and abort@>; |
| 136 |
@y |
| 137 |
if cur_tok=par_token then if long_state<>long_call then |
| 138 |
if suppress_long_error=0 then @<Report a runaway argument and abort@>; |
| 139 |
@z |
| 140 |
|
| 141 |
@x |
| 142 |
if cur_tok=par_token then if long_state<>long_call then |
| 143 |
@<Report a runaway argument and abort@>; |
| 144 |
@y |
| 145 |
if cur_tok=par_token then if long_state<>long_call then |
| 146 |
if suppress_long_error=0 then @<Report a runaway argument and abort@>; |
| 147 |
@z |
| 148 |
|
| 149 |
@x |
| 150 |
print_err("Infinite glue shrinkage found in box being split");@/ |
| 151 |
@.Infinite glue shrinkage...@> |
| 152 |
help4("The box you are \vsplitting contains some infinitely")@/ |
| 153 |
("shrinkable glue, e.g., `\vss' or `\vskip 0pt minus 1fil'.")@/ |
| 154 |
("Such glue doesn't belong there; but you can safely proceed,")@/ |
| 155 |
("since the offensive shrinkability has been made finite."); |
| 156 |
error; r:=new_spec(q); shrink_order(r):=normal; delete_glue_ref(q); |
| 157 |
@y |
| 158 |
if is_bit_set(ignore_primitive_error, 1) then |
| 159 |
print_ignored_err("Infinite glue shrinkage found in box being split") |
| 160 |
else begin |
| 161 |
print_err("Infinite glue shrinkage found in box being split");@/ |
| 162 |
@.Infinite glue shrinkage...@> |
| 163 |
help4("The box you are \vsplitting contains some infinitely")@/ |
| 164 |
("shrinkable glue, e.g., `\vss' or `\vskip 0pt minus 1fil'.")@/ |
| 165 |
("Such glue doesn't belong there; but you can safely proceed,")@/ |
| 166 |
("since the offensive shrinkability has been made finite."); |
| 167 |
error; |
| 168 |
end; |
| 169 |
r:=new_spec(q); shrink_order(r):=normal; delete_glue_ref(q); |
| 170 |
@z |
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
@x |
| 175 |
@<Math-only cases in non-math modes, or vice versa@>: insert_dollar_sign; |
| 176 |
@y |
| 177 |
@<Math-only cases in non-math modes, or vice versa@>: insert_dollar_sign; |
| 178 |
mmode+par_end: if suppress_mathpar_error=0 then insert_dollar_sign; |
| 179 |
@z |
| 180 |
|
| 181 |
@x |
| 182 |
mmode+endv, mmode+par_end, mmode+stop, mmode+vskip, mmode+un_vbox, |
| 183 |
mmode+valign, mmode+hrule |
| 184 |
@y |
| 185 |
mmode+endv, mmode+stop, mmode+vskip, mmode+un_vbox, |
| 186 |
mmode+valign, mmode+hrule |
| 187 |
@z |
| 188 |
|
| 189 |
@x after_math |
| 190 |
@<Check that another \.\$ follows@>= |
| 191 |
begin get_x_token; |
| 192 |
@y |
| 193 |
@<Check that another \.\$ follows@>= |
| 194 |
begin repeat get_x_token; |
| 195 |
until (suppress_mathpar_error=0)or(cur_cmd<>par_end); |
| 196 |
@z |
| 197 |
|
| 198 |
@x |
| 199 |
primitive("readpapersizespecial",assign_int,int_base+read_papersize_special_code);@/ |
| 200 |
@!@:read_papersize_special_}{\.{\\readpapersizespecial} primitive@> |
| 201 |
@y |
| 202 |
primitive("readpapersizespecial",assign_int,int_base+read_papersize_special_code);@/ |
| 203 |
@!@:read_papersize_special_}{\.{\\readpapersizespecial} primitive@> |
| 204 |
primitive("suppresslongerror",assign_int,int_base+suppress_long_error_code);@/ |
| 205 |
@!@:suppress_long_error_}{\.{\\suppresslongerror} primitive@> |
| 206 |
primitive("suppressoutererror",assign_int,int_base+suppress_outer_error_code);@/ |
| 207 |
@!@:suppress_outer_error_}{\.{\\suppressoutererror} primitive@> |
| 208 |
primitive("suppressmathparerror",assign_int,int_base+suppress_mathpar_error_code);@/ |
| 209 |
@!@:suppress_mathpar_error_}{\.{\\suppressmathparerror} primitive@> |
| 210 |
primitive("ignoreprimitiveerror",assign_int,int_base+ignore_primitive_error_code);@/ |
| 211 |
@!@:ignore_primitive_error_}{\.{\\ignoreprimitiveerror} primitive@> |
| 212 |
@z |
| 213 |
|
| 214 |
@x |
| 215 |
read_papersize_special_code:print_esc("readpapersizespecial"); |
| 216 |
@y |
| 217 |
read_papersize_special_code:print_esc("readpapersizespecial"); |
| 218 |
suppress_long_error_code: print_esc("suppresslongerror"); |
| 219 |
suppress_outer_error_code: print_esc("suppressoutererror"); |
| 220 |
suppress_mathpar_error_code: print_esc("suppressmathparerror"); |
| 221 |
ignore_primitive_error_code:print_esc("ignoreprimitiveerror"); |
| 222 |
@z |