[metapost] using MPXMAINCMD fails when it contains space
Martin Budaj
m.budaj at gmail.com
Thu May 21 18:53:51 CEST 2009
Hi all,
there is a problem when trying to use metapost btex...etex labels in
the Windows environment where 1) tex binary is not in a path and 2)
its installation directory contains space.
Older metapost version (0.641) had no problems using
MPXCOMMAND = "$SELFAUTOLOC/makempx.exe"
in texmf.cnf to generate labels. For latest version (1.200) I changed it to
MPXMAINCMD = "$SELFAUTOLOC/tex.exe"
but metapost fails (producing no mpxerr.log as advised)
fatal: Command failed: "C:/Program Files/Therion/bin/win32/tex.exe"
--parse-first-line --interaction=nonstopmode mpa02804.tex; see
mpxerr.log
The old way of running external makempx binary doesn't work either,
giving the message
makempx: Command failed: mpto -tex ./data.mp
After some experiments it seems that the function spawnvp(P_WAIT, cmd,
options) requires that cmd MUST NOT be enclosed in quotes but
options[0] MUST be enclosed in quotes if the path contains a space.
After deleting the quotation marks in cmd (patch attached below) the
label generation works fine using the new method (without external
makempx).
I am not sure if all windows version require this modification (tested
just on XP).
Best regards,
Martin
--- mpxout.w.old 2009-05-21 18:41:39 +0200
+++ mpxout.w 2009-05-21 18:00:54 +0200
@@ -3952,7 +3952,15 @@
return retcode;
#else
(void)mpx;
- return spawnvp(P_WAIT, cmd, (const char **)options);
+
+ char * tmps = xmalloc(strlen(cmd)+1,1);
+ if (cmd[0] != '"') strcpy(tmps,cmd);
+ else {
+ strncpy(tmps,cmd+1,strlen(cmd)-2);
+ tmps[strlen(cmd)-2] = 0;
+ }
+
+ return spawnvp(P_WAIT, tmps, (const char **)options);
#endif
}
More information about the metapost
mailing list