groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Groff] Relocated Groff doesn't work


From: Eli Zaretskii
Subject: [Groff] Relocated Groff doesn't work
Date: Fri, 01 May 2015 17:47:59 +0300

Hi,

Someone reported to me that the MS-Windows binaries of Groff I made
available didn't work on their machine.  Looking into this issue, that
person found that setting GROFF_BIN_PATH in the environment to point
to the directory where the Groff executables lived solved the problem.

The root cause of that is this code in groff.cpp:main:

    // we save the original path in GROFF_PATH__ and put it into the
    // environment -- troff will pick it up later.
    char *path = getenv("PATH");
    string e = "GROFF_PATH__";
    e += '=';
    if (path && *path)
      e += path;
    e += '\0';
    if (putenv(strsave(e.contents())))
      fatal("putenv failed");
    char *binpath = getenv("GROFF_BIN_PATH");
    string f = "PATH";
    f += '=';
    if (binpath && *binpath)
      f += binpath;
    else
      f += BINPATH;

What this does is replace $PATH with a list that includes only the
value of BINPATH recorded at build time.  IOW, if Groff is relocated
to a different place, it will stop working.

This is not a Windows-specific problem, AFAIU, it's just that I
presume on Posix platforms people usually build Groff and install it
on the same platform, or use standard directories for which the binary
was built.

Would the following patch be okay?  It works for me.


--- src/roff/groff/groff.cpp~2  2015-05-01 16:43:02.571186000 +0300
+++ src/roff/groff/groff.cpp    2015-05-01 17:37:16.909571100 +0300
@@ -35,6 +35,7 @@ along with this program. If not, see <ht
 #include "pipeline.h"
 #include "nonposix.h"
 #include "defs.h"
+#include "relocate.h"
 
 #define GXDITVIEW "gxditview"
 
@@ -469,8 +470,10 @@ int main(int argc, char **argv)
     f += '=';
     if (binpath && *binpath)
       f += binpath;
-    else
-      f += BINPATH;
+    else {
+      binpath = relocatep(BINPATH);
+      f += binpath;
+    }
     if (path && *path) {
       f += PATH_SEP_CHAR;
       f += path;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]