]> granicus.if.org Git - graphviz/commitdiff
support GVBINDIR env var on all platforms - per request and patch from:
authorellson <devnull@localhost>
Mon, 14 Apr 2008 16:35:16 +0000 (16:35 +0000)
committerellson <devnull@localhost>
Mon, 14 Apr 2008 16:35:16 +0000 (16:35 +0000)
Marcel Partap <mpartap@gmx.net>

lib/gvc/gvconfig.c

index 350ee7caf2aaba7b3c92a5d2305a4d6006dd8af1..e6ce944b92d3edd711e7e4ce7a683c2c9bc1d4aa 100644 (file)
@@ -273,9 +273,9 @@ char * gvconfig_libdir(void)
     FILE *f;
 
     if (!libdir) {
-#ifdef WIN32
         libdir=getenv("GVBINDIR");
        if (!libdir) {
+#ifdef WIN32
            int r;
            char* s;
            HMODULE hm = GetModuleHandle (NULL);
@@ -295,35 +295,35 @@ char * gvconfig_libdir(void)
            }
            *s = '\0';
            libdir = line;
-       }
 #else
-        /* this only works on linux, other systems will get GVLIBDIR only */
-       libdir = GVLIBDIR;
-        f = fopen ("/proc/self/maps", "r");
-        if (f) {
-            while (!feof (f)) {
-               if (!fgets (line, sizeof (line), f))
-                   continue;
-               if (!strstr (line, " r-xp "))
-                   continue;
-               path = strchr (line, '/');
-               if (!path)
-                   continue;
-               tmp = strstr (path, "/libgvc.");
-               if (tmp) {
-                   *tmp = 0;
-                   /* Check for real /lib dir. Don't accept pre-install /.libs */
-                   if (strcmp(strrchr(path,'/'), "/.libs") == 0)
+           /* this only works on linux, other systems will get GVLIBDIR only */
+           libdir = GVLIBDIR;
+           f = fopen ("/proc/self/maps", "r");
+           if (f) {
+               while (!feof (f)) {
+                   if (!fgets (line, sizeof (line), f))
                        continue;
-                   strcpy(line, path);  /* use line buffer for result */
-                   strcat(line, "/graphviz");  /* plugins are in "graphviz" subdirectory */
-                   libdir = line;
-                   break;
-               }
-            }
-            fclose (f);
-        }
+                   if (!strstr (line, " r-xp "))
+                       continue;
+                   path = strchr (line, '/');
+                   if (!path)
+                       continue;
+                   tmp = strstr (path, "/libgvc.");
+                   if (tmp) {
+                       *tmp = 0;
+                       /* Check for real /lib dir. Don't accept pre-install /.libs */
+                       if (strcmp(strrchr(path,'/'), "/.libs") == 0)
+                           continue;
+                       strcpy(line, path);  /* use line buffer for result */
+                       strcat(line, "/graphviz");  /* plugins are in "graphviz" subdirectory */
+                       libdir = line;
+                       break;
+                   }
+               }
+               fclose (f);
+           }
 #endif
+       }
     }
     return libdir;
 }