On Wed, May 17, 2006 at 10:41:28PM +0200, Edwin Leuven wrote: > Enrico Forestieri wrote: > > On Wed, May 17, 2006 at 09:47:21PM +0200, Edwin Leuven wrote: > >> does anyone know whether dvipost runs under windows? > >> > >> (i did some searching but could not find anything) > >> > >> if not, then i guess that this functionality is not complete under > >> windows. maybe we should say so somewhere... > > > > It cannot be compiled with mingw because it relies on fork(), > > but I think that it can be hacked to work without because > > it simply waitpid() after the fork call. > > maybe someone knowledgable could do this so that we can distribute it > with the windows lyx installer?
Please, attached find a patch for dvipost 1.1 which allows compiling it with mingw. It seems to work for me ;-) It should be a matter of: configure make make install -- Enrico
diff -uNr dvipost-1.1.orig/dvi.c dvipost-1.1/dvi.c --- dvipost-1.1.orig/dvi.c 2006-03-22 14:59:58.000000000 +0100 +++ dvipost-1.1/dvi.c 2006-05-03 19:49:02.000000000 +0200 @@ -502,8 +502,12 @@ for (i = 0; i < pos_changed.dim; i++) { POS *p = pos_changed.tab + i; + if (!p->type) + dout_special(out, osstart); cmd_goto(out, p->end, cbcol); dout_putrule(out, p->end - p->beg, cbrule); + if (!p->type) + dout_special(out, osend); } dout_special(out, cbend); @@ -625,10 +629,9 @@ mv_right(w); text_cnt++; - if (!cbmode[page_stat]) return; - + if (!cbmode[page_stat] && !osmode[page_stat]) return; pos_add(&pos_changed, dvi_stat.v - text_height - cbexp, - dvi_stat.v + text_depth + cbexp); + dvi_stat.v + text_depth + cbexp, cbmode[page_stat]); if (cbframe) { diff -uNr dvipost-1.1.orig/dvipost.h dvipost-1.1/dvipost.h --- dvipost-1.1.orig/dvipost.h 2002-11-04 08:44:46.000000000 +0100 +++ dvipost-1.1/dvipost.h 2006-05-07 20:19:06.000000000 +0200 @@ -33,7 +33,12 @@ #define STAT 2 #define DBG 3 +#ifdef _WIN32 +#include <limits.h> +extern char pname[PATH_MAX]; +#else extern char *pname; +#endif extern int verboselevel; extern void message (int level, const char *fmt, ...); @@ -44,6 +49,7 @@ typedef struct { int beg; int end; + int type; } POS; typedef struct { @@ -53,7 +59,7 @@ } PosTab; void pos_init (PosTab *pos); -void pos_add (PosTab *pos, int beg, int end); +void pos_add (PosTab *pos, int beg, int end, int type); extern int process_dvi (const char *id, FILE *in, FILE *out); extern int dvipost (const char *iname, const char *oname); diff -uNr dvipost-1.1.orig/main.c dvipost-1.1/main.c --- dvipost-1.1.orig/main.c 2002-11-27 15:19:14.000000000 +0100 +++ dvipost-1.1/main.c 2006-05-18 04:30:12.000000000 +0200 @@ -32,7 +32,9 @@ #include <unistd.h> #include <string.h> #include <sys/types.h> +#ifndef _WIN32 #include <sys/wait.h> +#endif char **tex_argv = NULL; int tex_argc = 0; @@ -236,7 +238,7 @@ static char *get_dvi_name (const char *arg) { char *p, *dvi; - + p = strrchr(arg, '/'); if (p && p[1]) @@ -267,18 +269,34 @@ char *dviname; int flag; int i, n; +#ifdef _WIN32 + char *cmd; +#else int status; pid_t pid; +#endif time_t stamp; tex_argv = xalloc((1 + argc) * sizeof(char*)); tex_argv[0] = argv[0]; tex_argc = 1; +#ifdef _WIN32 + if ((cmd = strrchr(argv[0], '/')) || + (cmd = strrchr(argv[0], '\\')) || + (cmd = strrchr(argv[0], ':'))) + cmd++; + else + cmd = argv[0]; + strncpy(pname, cmd, PATH_MAX-1); + if ((cmd = strstr(pname, ".exe")) != NULL) + *cmd = '\0'; +#else pname = strrchr(argv[0], '/'); if (pname == NULL) pname = argv[0]; else pname++; +#endif if (strcmp(pname, "pplatex") == 0) { @@ -356,6 +374,22 @@ fflush(stdout); time(&stamp); +#ifdef _WIN32 + for (i=0, n=0; i < tex_argc; ++i) + n += strlen(tex_argv[i]); + + cmd = xalloc(1 + n + 3*(tex_argc-1)); + strcpy(cmd, tex_argv[0]); + + for (i=1; i < tex_argc; ++i) + { + strcat(cmd, " \""); + strcat(cmd, tex_argv[i]); + strcat(cmd, "\""); + } + system(cmd); + xfree(cmd); +#else pid = fork(); if (pid == -1) @@ -368,6 +402,7 @@ execvp(tex_argv[0], tex_argv); waitpid(pid, &status, 0); +#endif if (dviname) return dvipost(dviname, dviname); diff -uNr dvipost-1.1.orig/message.c dvipost-1.1/message.c --- dvipost-1.1.orig/message.c 2002-10-29 12:54:02.000000000 +0100 +++ dvipost-1.1/message.c 2006-05-07 20:05:40.000000000 +0200 @@ -21,7 +21,11 @@ #include "dvipost.h" #include <stdarg.h> +#ifdef _WIN32 +char pname[PATH_MAX] = "LaTeXPost"; +#else char *pname = "LaTeXPost"; +#endif int verboselevel = NOTE; void message (int level, const char *fmt, ...) diff -uNr dvipost-1.1.orig/pos.c dvipost-1.1/pos.c --- dvipost-1.1.orig/pos.c 2002-10-29 12:54:02.000000000 +0100 +++ dvipost-1.1/pos.c 2004-04-02 15:49:52.000000000 +0200 @@ -39,7 +39,7 @@ pos->dim = 0; } -void pos_add (PosTab *pos, int beg, int end) +void pos_add (PosTab *pos, int beg, int end, int type) { if (beg > end) { @@ -56,7 +56,7 @@ { if (last->end < end) last->end = end; if (last->beg > beg) last->beg = beg; - + if (last->type < type) last->type = type; return; } } @@ -64,5 +64,6 @@ pos_expand(pos); pos->tab[pos->dim].beg = beg; pos->tab[pos->dim].end = end; + pos->tab[pos->dim].type = type; pos->dim++; } diff -uNr dvipost-1.1.orig/tfm.c dvipost-1.1/tfm.c --- dvipost-1.1.orig/tfm.c 2002-11-03 09:52:04.000000000 +0100 +++ dvipost-1.1/tfm.c 2006-03-22 11:48:16.000000000 +0100 @@ -112,6 +112,8 @@ { if (tfm_buf[n] == '\n') { + if (n && tfm_buf[n-1] == '\r') + n--; tfm_buf[n] = 0; break; }