Skip to content

Commit

Permalink
ptex-base.ch: wrap print_hex for negative value
Browse files Browse the repository at this point in the history
  • Loading branch information
aminophen committed Jun 28, 2021
1 parent 3d8183b commit 81ad436
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions source/texk/web2c/ptexdir/ptex-base.ch
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,17 @@ else
wterm(')');
@z

@x pTeX: print_hex for "Invalid KANJI code" or "Invalid KANSUJI char" errors
@ Old versions of \TeX\ needed a procedure called |print_ASCII| whose function
@y
@ Hexadecimal printing.

@p procedure print_hex_safe(@!n:integer);
begin if n<0 then print_int(n) else print_hex(n); end;

@ Old versions of \TeX\ needed a procedure called |print_ASCII| whose function
@z

@x
@d max_halfword==@"FFFFFFF {largest allowable value in a |halfword|}
@y
Expand Down Expand Up @@ -6468,7 +6479,7 @@ set_kansuji_char:
begin p:=cur_chr; scan_int; n:=cur_val; scan_optional_equals; scan_int;
if not is_char_kanji(cur_val) then
begin print_err("Invalid KANSUJI char (");
print_hex(cur_val); print_char(")");
print_hex_safe(cur_val); print_char(")");
@.Invalid KANSUJI char@>
help1("I'm skipping this control sequences.");@/
error; return;
Expand Down Expand Up @@ -6626,7 +6637,7 @@ if is_char_kanji(n) then
define(inhibit_xsp_code_base+j,cur_val,n);
end
else
begin print_err("Invalid KANJI code ("); print_hex(n); print_char(")");
begin print_err("Invalid KANJI code ("); print_hex_safe(n); print_char(")");
@.Invalid KANJI code@>
help1("I'm skipping this control sequences.");@/
error; return;
Expand Down Expand Up @@ -6714,7 +6725,7 @@ else
if p=pre_break_penalty_code then print("pre")
else if p=post_break_penalty_code then print("post")
else print_char("?");
print("breakpenalty ("); print_hex(n); print_char(")");
print("breakpenalty ("); print_hex_safe(n); print_char(")");
@.Invalid KANJI code@>
help1("I'm skipping this control sequences.");@/
error; return;
Expand Down

2 comments on commit 81ad436

@h-kitagawa
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

先に書かれてしまったので,ac4c860 として master に cherry-pick しました.個人的にはいちいち procedure として切り出さなくても

procedure print_delimiter(@!p:pointer); {prints a delimiter as 24-bit hex value}
var a:integer; {accumulator}
begin a:=small_fam(p)*256+qo(small_char(p));
a:=a*@"1000+large_fam(p)*256+qo(large_char(p));
if a<0 then print_int(a) {this should never happen}
else print_hex(a);
end;
のようにそのつど if で判定する(か,マクロを使う)のを好みますが.

@aminophen
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tex.web のそこは見に行きましたが,3か所あったので都度判定はあれかなぁと思ってしまいました…。

Please sign in to comment.