On Sun, Sep 20, 2026 at 01:36:04AM +0200, Pavel Sanda wrote:
On Fri, Sep 18, 2026 at 10:39:34PM +0200, Enrico Forestieri wrote:
I was speaking about *native* Windows. I compiled LyX using MinGW to test
your patch, so Cygwin doesn't come into play in this case. You were probably
misled by the fact that the string "cygwin" appeared in the error message,
but that is simply because I use the Cygwin `/tmp` directory as the
temporary directory for the native LyX. That's all.
I think I understood your test correctly.
Let me explain less briefly, because there are more issues here.
1) The CAS problem on Windows proper. The one you tested and reported
.bat problem. Fails with my patch and would need
#ifdef for windows.
2) Cygwin problem which I originally wanted to report only in the next step.
The issue is that cygwin runs in init
runCommand(mount + " --show-cygdrive-prefix");
As with CAS this is safe, and the only reason I touch it is that without
these two I can get rid of shell-based runCommand out of our API.
Before I new about the .bat problem in 1 I thought that I'll just #ifdef
runCommand to stay cornered only for cygwin to solve 2.
Now with 1 it means I need to starting #ifdef for windows in CAS
code as well and became hesitant and I asked whether is it still good
idea to get rid of runCommand altogether...
It seems I was the one who didn't understand, then! Sorry, looks like
I'm getting old ;)
Regarding the issue with .bat files on windows, some time ago we were
using QProcess, which was was also unable to launch batch files. At the
time, I wrote a wrapper that made it possible to do so simply by giving
the resulting executable the same name. I am attaching it here. This
single executable, when renamed appropriately, can launch any .bat file.
We could therefore distribute a maxima.exe file in LyX's bin folder on
Windows to resolve the issue. I tested it with your patch and it works.
Regarding point 2), We could simply replace the runCommand line with a
few lines that execute the command to obtain the cygdrive prefix using
just popen, along the lines of the attached wrapper.
--
Enrico
/* Wrapper executable for starting a batch file with same name.
* Using _popen instead of CreateProcess allows to execute .bat files, too.
*
* Compile this source with following options set:
*
* x86_64-w64-mingw32-gcc bat-executer.c -O2 -o bat-executer -static -Wall \
* -Wno-format -Wstrict-prototypes -Wmissing-prototypes -mwindows
*
* Enrico Forestieri, 2010-01-14
*/
#include <stdio.h> /* standard io library */
#include <stdlib.h> /* standard library */
#include <string.h> /* standard string library */
int main(int argc, char *argv[])
{
FILE *inf;
char *s;
char cmd[4096] = "";
int c;
int i;
int ret;
strncat(cmd, argv[0], sizeof(cmd) - 1);
if ((s = strstr(cmd, ".exe")) != NULL)
*s = '\0';
strncat(cmd, ".bat", sizeof(cmd) - strlen(cmd) - 1);
for (i = 1; i < argc; ++i) {
strncat(cmd, " \"", sizeof(cmd) - strlen(cmd) - 1) ;
strncat(cmd, argv[i], sizeof(cmd) - strlen(cmd) - 1) ;
strncat (cmd, "\"", sizeof(cmd) - strlen(cmd) - 1) ;
}
inf = _popen(cmd, "r");
if (!inf) {
fprintf(stderr, "Could not start command\n");
exit(1);
}
c = fgetc(inf);
while (c != EOF) {
putchar(c);
c = fgetc(inf);
}
ret = _pclose(inf);
if (ret == -1)
fprintf(stderr, "Could not terminate command\n");
return(0);
}
--
lyx-devel mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-devel