Skip to content

Commit

Permalink
Converts non-Japanese non-ASCII bytes in name_of_file to "^^" format.
Browse files Browse the repository at this point in the history
  • Loading branch information
h20y6m committed Jan 22, 2022
1 parent 3ba7a49 commit 0af852a
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 6 deletions.
5 changes: 5 additions & 0 deletions source/texk/ptexenc/ptexenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ boolean is_internalUPTEX(void)
return (internal_enc == ENC_UPTEX);
}

boolean is_terminalUTF8(void)
{
return (terminal_enc == ENC_UTF8);
}


/* check char range */
boolean ismultichr (int length, int nth, int c)
Expand Down
3 changes: 3 additions & 0 deletions source/texk/ptexenc/ptexenc/ptexenc.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ extern PTENCDLL boolean is_internalUPTEX(void);
#define isinternalEUC is_internalEUC
#define isinternalUPTEX is_internalUPTEX

extern PTENCDLL boolean is_terminalUTF8(void);
#define isterminalUTF8 is_terminalUTF8

/* check char range */
extern PTENCDLL boolean ismultichr (int length, int nth, int c);
extern PTENCDLL boolean iskanji1(int c);
Expand Down
2 changes: 2 additions & 0 deletions source/texk/web2c/eptexdir/eptex.defines
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

@define function getencstring;
@define function setencstring ();
@define function isinternalUPTEX;
@define function isterminalUTF8;

@define function iskanji1 ();
@define function multistrlen ();
Expand Down
1 change: 1 addition & 0 deletions source/texk/web2c/euptexdir/euptex.defines
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@define function setencstring ();
@define procedure setpriorfileenc;
@define function isinternalUPTEX;
@define function isterminalUTF8;

@define function iskanji1 ();
@define function is1stchr ();
Expand Down
40 changes: 34 additions & 6 deletions source/texk/web2c/ptexdir/ptex-base.ch
Original file line number Diff line number Diff line change
Expand Up @@ -2857,11 +2857,39 @@ if #<>0 then
if k<=file_name_size then name_of_file[k]:=xchr[c];
end end
@y
@d append_to_name(#)==begin if (#)>=@"100 then c:=(#)-@"100 else c:=#;
{ Since the type of |c| is |ASCII_code|, above if-statement might not be needed }
if not (c="""") then begin incr(k);
if k<=file_name_size then name_of_file[k]:=xchr[c];
end end
@d append_to_name_char(#)==begin incr(k);
if k<=file_name_size then name_of_file[k]:=xchr[#];
end

@d append_to_name_hex(#)==if (#)<10 then append_to_name_char((#)+"0") else append_to_name_char((#)-10+"a")

@d append_to_name(#)==begin
if (#)>=@"100 then begin
c:=(#)-@"100;
append_to_name_char(c);
end else begin
c:=#;
if (c>=@"80) and (not isinternalUPTEX) and isterminalUTF8 then begin
append_to_name_char("^");
append_to_name_char("^");
append_to_name_hex(c div 16);
append_to_name_hex(c mod 16);
end else if not (c="""") then
append_to_name_char(c);
end
end
@z
@x l.10389
name_of_file:= xmalloc_array (ASCII_code, length(a)+length(n)+length(e)+1);
@y
name_of_file:= xmalloc_array (ASCII_code, (length(a)+length(n)+length(e))*4+1);
@z
@x l.10444
name_of_file := xmalloc_array (ASCII_code, n+(b-a+1)+format_ext_length+1);
@y
name_of_file := xmalloc_array (ASCII_code, (n+(b-a+1)+format_ext_length)*4+1);
@z
@x [29.526] l.10668 - pTeX: scan file name
Expand Down Expand Up @@ -6685,7 +6713,7 @@ end
str_pool[str_start[str_ptr]])));
@y
if name_of_file then libc_free(name_of_file);
name_of_file := xmalloc(cur_length * 3 + 2);
name_of_file := xmalloc(cur_length*4+1);
k := 0;
for d:=0 to cur_length-1 do
append_to_name(str_pool[str_start[str_ptr]+d]);
Expand Down
2 changes: 2 additions & 0 deletions source/texk/web2c/ptexdir/ptex.defines
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

@define function getencstring;
@define function setencstring ();
@define function isinternalUPTEX;
@define function isterminalUTF8;

@define function iskanji1 ();
@define function multistrlen ();
Expand Down
1 change: 1 addition & 0 deletions source/texk/web2c/uptexdir/uptex.defines
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@define procedure setpriorfileenc;
@define function isinternalUPTEX;
@define function isinternalEUC;
@define function isterminalUTF8;

@define function iskanji1 ();
@define function is1stchr ();
Expand Down

0 comments on commit 0af852a

Please sign in to comment.