Skip to content

Commit

Permalink
#81 (epTeX only; \jobname does not work
Browse files Browse the repository at this point in the history
  • Loading branch information
h-kitagawa committed Jun 9, 2019
1 parent 4ac5ec0 commit 76536aa
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 31 deletions.
14 changes: 12 additions & 2 deletions source/texk/ptexenc/ptexenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,9 @@ int putc2(int c, FILE *fp)
static int num[NOFILE];
/* 0 : not in Kanji
1..4 : in JIS Kanji and num[] bytes are in store[][]
-1 : in JIS Kanji and store[][] is empty */
-1 : in JIS Kanji and store[][] is empty
-2 : next character will be printed with no conversion
*/
static unsigned char store[NOFILE][4];
const int fd = fileno(fp);
int ret = c, output_enc;
Expand All @@ -493,7 +495,15 @@ int putc2(int c, FILE *fp)
} else
output_enc = get_file_enc();
#endif
if (num[fd] > 0) { /* multi-byte char */
if (c==0xFF) { /* next character: no conversion */
if (num[fd] < 0 && output_enc == ENC_JIS) {
put_multibyte(KANJI_OUT, fp);
}
num[fd] = -2;
} else if (num[fd] == -2) {
ret = putc(c, fp);
num[fd] = 0;
} else if (num[fd] > 0) { /* multi-byte char */
if (is_internalUPTEX() && iskanji1(c)) { /* error */
ret = flush(store[fd], num[fd], fp);
num[fd] = 0;
Expand Down
12 changes: 6 additions & 6 deletions source/texk/web2c/eptexdir/pdfutils.ch
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@ random_seed_code: cur_val := random_seed;
procedure print_kanji(@!s:KANJI_code); {prints a single character}
begin
if s>255 then
begin print_char(Hi(s)); print_char(Lo(s));
begin print_char_raw(Hi(s)); print_char_raw(Lo(s));
end else print_char(s);
end;
@y
Expand All @@ -1307,12 +1307,12 @@ begin
if s>255 then begin
if isprint_utf8 then begin
s:=UCStoUTF8(toUCS(s));
if BYTE1(s)<>0 then print_char(BYTE1(s));
if BYTE2(s)<>0 then print_char(BYTE2(s));
if BYTE3(s)<>0 then print_char(BYTE3(s));
print_char(BYTE4(s));
if BYTE1(s)<>0 then print_char_raw(BYTE1(s));
if BYTE2(s)<>0 then print_char_raw(BYTE2(s));
if BYTE3(s)<>0 then print_char_raw(BYTE3(s));
print_char_raw(BYTE4(s));
end
else begin print_char(Hi(s)); print_char(Lo(s)); end;
else begin print_char_raw(Hi(s)); print_char_raw(Lo(s)); end;
end
else print_char(s);
end;
Expand Down
112 changes: 90 additions & 22 deletions source/texk/web2c/ptexdir/ptex-base.ch
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,55 @@ term_only: begin wterm(xchr[s]); incr(term_offset);
end;
no_print: do_nothing;
pseudo: if tally<trick_count then trick_buf[tally mod error_line]:=s;
new_string: begin if pool_ptr<pool_size then append_char(s);
end; {we drop characters if the string space is full}
othercases write(write_file[selector],xchr[s])
endcases;@/
incr(tally);
exit:end;
@y
procedure print_char(@!s:ASCII_code); {prints a single character}
label exit; {label is not used but nonetheless kept (for other changes?)}
begin if @<Character |s| is the current new-line character@> then
if selector<pseudo then
begin print_ln; return;
end;
kcode_pos:=0;
case selector of
term_and_log: begin
if xchr[s]>=@"80 then begin wterm(xchr[@"FF]); wlog(xchr[@"FF]); end;
wterm(xchr[s]); incr(term_offset);
if term_offset=max_print_line then
begin wterm_cr; term_offset:=0;
end;
wlog(xchr[s]); incr(file_offset);
if file_offset=max_print_line then
begin wlog_cr; file_offset:=0;
end;
end;
log_only: begin if xchr[s]>=@"80 then begin wlog(xchr[@"FF]); end;
wlog(xchr[s]); incr(file_offset);
if file_offset=max_print_line then print_ln;
end;
term_only: begin if xchr[s]>=@"80 then begin wterm(xchr[@"FF]); end;
wterm(xchr[s]); incr(term_offset);
if term_offset=max_print_line then print_ln;
end;
no_print: do_nothing;
pseudo: if tally<trick_count then
begin trick_buf[tally mod error_line]:=s;
trick_buf2[tally mod error_line]:=kcode_pos;
end;
new_string: begin
if xchr[s]>=@"80 then if pool_ptr<pool_size then append_char(@"FF);
if pool_ptr<pool_size then append_char(s);
end; {we drop characters if the string space is full}
othercases write(write_file[selector],xchr[s])
endcases;@/
incr(tally);
exit:end;
procedure print_char_raw(@!s:ASCII_code); {prints a single character}
label exit; {label is not used but nonetheless kept (for other changes?)}
begin if @<Character |s| is the current new-line character@> then
if selector<pseudo then
begin print_ln; return;
Expand Down Expand Up @@ -246,6 +292,12 @@ pseudo: if tally<trick_count then
begin trick_buf[tally mod error_line]:=s;
trick_buf2[tally mod error_line]:=kcode_pos;
end;
new_string: begin if pool_ptr<pool_size then append_char(s);
end; {we drop characters if the string space is full}
othercases write(write_file[selector],xchr[s])
endcases;@/
incr(tally);
exit:end;
@z
@x l.1603 - pTeX
Expand Down Expand Up @@ -324,20 +376,27 @@ var j:pool_pointer; {current character code position}
old_sel: integer;
begin if (s>=str_ptr) or (s<256) then print(s)
else begin j:=str_start[s];
old_sel:=selector; selector:=term_only;
{ old_sel:=selector; selector:=term_only;
print("SLOW_PRINT[[");
selector:=old_sel;
selector:=old_sel; }
while j<str_start[s+1] do
begin
old_sel:=selector; selector:=term_only;
print("("); print(so(str_pool[j])); print(")");
selector:=old_sel;
print(so(str_pool[j])); incr(j);
begin
if so(str_pool[j])=@"FF then
begin incr(j);
{ old_sel:=selector; selector:=term_only;
print("@@");
selector:=old_sel; }
if j<str_start[s+1] then print(so(str_pool[j]));
end
else begin
print(so(str_pool[j]));
end;
incr(j);
end;
end;
old_sel:=selector; selector:=term_only;
{ old_sel:=selector; selector:=term_only;
print("]]");
selector:=old_sel;
selector:=old_sel; }
end;
@z

Expand Down Expand Up @@ -1553,7 +1612,7 @@ left_brace,right_brace,math_shift,tab_mark,sup_mark,sub_mark,spacer,
@<Display the token ...@>=
case m of
kanji,kana,other_kchar:
begin print("("); print_kanji(KANJI(c)); print(")"); end;
begin print_kanji(KANJI(c)); end;
left_brace,right_brace,math_shift,tab_mark,sup_mark,sub_mark,spacer,
letter,other_char: print(c);
@z
Expand Down Expand Up @@ -2369,25 +2428,20 @@ while k<pool_ptr do
incr(k);
end;
@y
print("STR_TOKS[[");
while k<pool_ptr do
begin t:=so(str_pool[k]);
if t<@"80 then begin
print("("); print_char(t); print(")");
if t=@"FF then begin
incr(k); if k<pool_ptr then t:=other_token+so(str_pool[k]);
end
else begin
print("("); print_hex(t); print(")");
end;
if multistrlen(ustringcast(str_pool), pool_ptr, k)=2 then
else if multistrlen(ustringcast(str_pool), pool_ptr, k)=2 then
begin t:=fromBUFF(ustringcast(str_pool), pool_ptr, k); incr(k);
print("["); print_hex(so(str_pool[k])); print("]");
end
else if t=" " then t:=space_token
else t:=other_token+t;
else begin
if t=" " then t:=space_token else t:=other_token+t;
end;
fast_store_new_token(t);
incr(k);
end;
print("]]");
@z
@x [27.468] l.9531 - pTeX: convert KANJI code
Expand Down Expand Up @@ -2641,6 +2695,20 @@ else begin str_room(1); append_char(c); {contribute |c| to the current string}
end;
@z

@x [29] pTeX: print file name
@d print_quoted(#) == {print string |#|, omitting quotes}
if #<>0 then
for j:=str_start[#] to str_start[#+1]-1 do
if so(str_pool[j])<>"""" then
print(so(str_pool[j]))
@y
@d print_quoted(#) == {print string |#|, omitting quotes}
if #<>0 then
for j:=str_start[#] to str_start[#+1]-1 do
if so(str_pool[j])<>"""" then
if so(str_pool[j])>=@"80 then print_char_raw(so(str_pool[j])) else print(so(str_pool[j]))
@z
@x [29.526] l.10668 - pTeX: scan file name
loop@+begin if (cur_cmd>other_char)or(cur_chr>255) then {not a character}
begin back_input; goto done;
Expand Down Expand Up @@ -7414,7 +7482,7 @@ skip_loop: do_nothing;
procedure print_kanji(@!s:KANJI_code); {prints a single character}
begin
if s>255 then
begin print_char(Hi(s)); print_char(Lo(s));
begin print_char_raw(Hi(s)); print_char_raw(Lo(s));
end else print_char(s);
end;
Expand Down
10 changes: 9 additions & 1 deletion source/texk/web2c/ptexdir/tests/printkanji.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
\scrollmode
%\scrollmode
\tracingstats=1000
\newlinechar=`\^^J
\font\x=ec-lmtt10 \x
\message{^^J}
Expand All @@ -19,4 +20,11 @@

\message{^^J}
\message{\meaning\A}

\jobname
\message{^^J}
\message{*\jobname *}

\detokenize\expandafter{\meaning\A}

\end

0 comments on commit 76536aa

Please sign in to comment.