[metapost] Using -recorder with -output-directory

Karl Berry karl at freefriends.org
Tue May 19 02:09:10 CEST 2009

Hi Nicola,

    Date: Sat, 16 May 2009 13:41:36 +0200
    From: Nicola <nvitacolonna at gmail.com>
    To: metapost at tug.org

    mpost -recorder -output-directory ./mydir ./mydir/foo.mp

    the file foo.fls is written into the current directory and not into 
    ./mydir. I consider this as a bug.  [...]

I do too.  And independent of mpost, the same behavior was in the other
binaries (tex, mf, etc.).  I have checked in a patch which fixes it, to
my tests anyway.


--- openclose.c (revision 13213)
+++ openclose.c (working copy)
@@ -39,10 +39,20 @@
     /* Alas, while we might want to use mkstemp it is not portable.
        So we have to be content with using a default name... */
     string cwd;
     recorder_name = (string)xmalloc(strlen(kpse_program_name)+5);
     strcpy(recorder_name, kpse_program_name);
     strcat(recorder_name, ".fls");
+    /* If an output directory was specified, use it instead of cwd.  */
+    if (output_directory) {
+      string temp = concat3(output_directory, DIR_SEP_STRING, recorder_name);
+      free(recorder_name);
+      recorder_name = temp;
+    }
     recorder_file = xfopen(recorder_name, FOPEN_W_MODE);
     cwd = xgetcwd();
     fprintf(recorder_file, "PWD %s\n", cwd);

More information about the metapost mailing list