Skip to content

Commit

Permalink
openclose.c: convert recorder filename to UTF-8 (texjporg#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
h20y6m committed Sep 14, 2023
1 parent 0d227bf commit c637098
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions source/texk/web2c/lib/openclose.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ void
recorder_change_filename (string new_name)
{
string temp = NULL;

#if defined(PTEX) && !defined(WIN32)
string fname0 = NULL;
#endif

if (!recorder_file)
return;

Expand All @@ -151,6 +154,13 @@ recorder_change_filename (string new_name)
fclose (recorder_file);
#endif /* _WIN32 */

#if defined(PTEX) && !defined(WIN32)
fname0 = ptenc_from_internal_enc_string_to_utf8(new_name);
if (fname0) {
new_name = fname0;
}
#endif

/* If an output directory was specified, use it. */
if (output_directory) {
temp = concat3(output_directory, DIR_SEP_STRING, new_name);
Expand All @@ -173,6 +183,10 @@ recorder_change_filename (string new_name)

if (temp)
free (temp);
#if defined(PTEX) && !defined(WIN32)
if (fname0)
free (fname0);
#endif
}

/* helper for recorder_record_* */
Expand Down Expand Up @@ -407,24 +421,25 @@ boolean
open_output (FILE **f_ptr, const_string fopen_mode)
{
string fname;
#if defined(PTEX) && !defined(WIN32)
string fname0;
#endif
boolean absolute = kpse_absolute_p(nameoffile+1, false);

/* If we have an explicit output directory, use it. */
if (output_directory && !absolute) {
fname = concat3(output_directory, DIR_SEP_STRING, nameoffile + 1);
} else {
fname = nameoffile + 1;
}
fname = nameoffile + 1;
#if defined(PTEX) && !defined(WIN32)
fname0 = ptenc_from_internal_enc_string_to_utf8(fname);
if (fname0) {
if (fname != nameoffile + 1) free(fname);
fname = fname0;
}
#endif
/* If we have an explicit output directory, use it. */
if (output_directory && !absolute) {
fname0 = concat3(output_directory, DIR_SEP_STRING, fname);
if (fname0) {
if (fname != nameoffile + 1) free(fname);
fname = fname0;
}
}

/* Is the filename openable as given? */
*f_ptr = fopen (fname, fopen_mode);
Expand Down

0 comments on commit c637098

Please sign in to comment.