Skip to content

Commit

Permalink
open_input (reencode nameoffile to utf8) and SyncTeX
Browse files Browse the repository at this point in the history
  • Loading branch information
h-kitagawa committed Oct 2, 2021
1 parent cbb903d commit 627b5d6
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 10 deletions.
7 changes: 7 additions & 0 deletions source/texk/web2c/lib/openclose.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,13 @@ open_input (FILE **f_ptr, int filefmt, const_string fopen_mode)
must_exist);
if (fname) {
fullnameoffile = xstrdup(fname);
#if defined(PTEX) && !defined(WIN32)
fname0 = ptenc_from_utf8_string_to_internal_enc(fullnameoffile);
if (fname0) {
free (fullnameoffile);
fullnameoffile = fname0;
}
#endif
/* If we found the file in the current directory, don't leave
the `./' at the beginning of `nameoffile', since it looks
dumb when `tex foo' says `(./foo.tex ... )'. On the other
Expand Down
10 changes: 5 additions & 5 deletions source/texk/web2c/ptexdir/ptex-base.ch
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,11 @@ var i,j,l:pool_pointer; p:integer;
begin if (s>=str_ptr) or (s<256) then print(s)
else begin i:=str_start[s]; l:=str_start[s+1];
while i<l do begin
p:=multistrlenfilename(str_pool, l, i);
p:=multistrlenshort(str_pool, l, i);
if p<>1 then
begin for j:=i to i+p-1 do print_char(so(str_pool[j]));
begin for j:=i to i+p-1 do print_char(@"100+(so(str_pool[j]) mod @"100));
i:=i+p; end
else begin print(so(str_pool[i])); incr(i); end;
else begin print(so(str_pool[i]) mod @"100); incr(i); end;
end;
end;
end;
Expand All @@ -401,10 +401,10 @@ begin if s<>0 then begin
while i<l do begin
p:=multistrlenshort(str_pool, l, i);
if p<>1 then begin
for j:=i to i+p-1 do print_char(@"100+so(str_pool[j]));
for j:=i to i+p-1 do print_char(@"100+(so(str_pool[j]) mod @"100));
i:=i+p; end
else begin
if so(str_pool[i])<>"""" then print(so(str_pool[i]));
if so(str_pool[i])<>"""" then print(so(str_pool[i]) mod @"100);
incr(i); end;
end;
end;
Expand Down
15 changes: 10 additions & 5 deletions source/texk/web2c/ptexdir/tests/filename_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,22 @@ cat <<'EOF' > filename_日本語.tex
EOF

ln -s filename_日本語.tex "filename_日本a.tex"
eptex "\input {filename_日本a}"
euptex "\input {filename_日本a}"
eptex -synctex=1 "\input {filename_日本a}"
ls *.synctex.gz; rm *.synctex.gz
euptex -synctex=1 "\input {filename_日本a}"
ls *.synctex.gz; rm *.synctex.gz
ls "filename_日本a".*
rm "filename_日本a".*
ln -s filename_日本語.tex filename_日本ßſa.tex
euptex filename_日本ßſa
euptex -synctex=1 filename_日本ßſa
ls *.synctex.gz; rm *.synctex.gz
ls filename_日本ßſa.*
rm filename_日本ßſa.*

eptex "-jobname=漢ßſa" filename_日本語
eptex -synctex=1 "-jobname=漢ßſa" filename_日本語
ls *.synctex.gz; rm *.synctex.gz
ls 漢*; rm 漢*
euptex "-jobname=漢ßſa" filename_日本語
euptex -synctex=1 "-jobname=漢ßſa" filename_日本語
ls *.synctex.gz; rm *.synctex.gz
ls 漢*; rm 漢*
rm filename_日本語.tex
21 changes: 21 additions & 0 deletions source/texk/web2c/synctexdir/synctex.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,34 @@ static int fsyscp_remove(char *name);
#endif /* pdfTeX ... */
#endif /* _WIN32 */

#if defined(pTeX) || defined(upTeX) || defined(epTeX) || defined(eupTeX)
#define IS_pTeX 1
#else
#define IS_pTeX 0
#endif

/* This macro layer was added to take luatex into account as suggested by T. Hoekwater. */
# if IS_pTeX && !defined(_WIN32)
char *SYNCTEX_GET_JOB_NAME()
{
char *tmp = gettexstring(jobname);
char *tmpa = ptenc_from_internal_enc_string_to_utf8(tmp);
if (tmpa) { SYNCTEX_FREE(tmp); return tmpa; } else return tmp;
}
char *SYNCTEX_GET_LOG_NAME()
{
char *tmp = gettexstring(texmflogname);
char *tmpa = ptenc_from_internal_enc_string_to_utf8(tmp);
if (tmpa) { SYNCTEX_FREE(tmp); return tmpa; } else return tmp;
}
# else
# if !defined(SYNCTEX_GET_JOB_NAME)
# define SYNCTEX_GET_JOB_NAME() (gettexstring(jobname))
# endif
# if !defined(SYNCTEX_GET_LOG_NAME)
# define SYNCTEX_GET_LOG_NAME() (gettexstring(texmflogname))
# endif
# endif
# if !defined(SYNCTEX_CURRENT_TAG)
# define SYNCTEX_CURRENT_TAG (curinput.synctextagfield)
# endif
Expand Down

0 comments on commit 627b5d6

Please sign in to comment.