bug-bison
[Top][All Lists]
Advanced

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

Building and testing Bison 3.0.2 with MinGW [4/5]


From: Eli Zaretskii
Subject: Building and testing Bison 3.0.2 with MinGW [4/5]
Date: Tue, 07 Oct 2014 21:17:09 +0300

Users on MS-Windows expect programs that come with data files to be
"relocatable", i.e. continue working if the entire tree with the built
Bison was moved to some directory other than the one for which the
package was configured with --prefix.  Here's a patch to do that:

--- src/output.c~0      2013-12-04 17:53:01 +0200
+++ src/output.c        2014-10-06 13:49:31 +0300
@@ -712,9 +719,43 @@ output (void)
   obstack_free (&format_obstack, NULL);
 }
 
+#ifdef __MINGW32__
+#define WIN32_LEAN_AND_MEAN
+/* These two get in the way because parse-gram.h defines them to be
+   numbers, but windows.h uses them in typedefs.  */
+#undef INT
+#define INT INTEGER
+#undef CHAR
+#define CHAR CHARACTER
+#include <windows.h>
+#endif
+
+
 char const *
 pkgdatadir (void)
 {
   char const *cp = getenv ("BISON_PKGDATADIR");
+
+#ifdef __MINGW32__
+  /* Cater to those who install Bison in a place different from what
+     it was configured for.  */
+  if (!cp)
+    {
+      char dir_name[MAX_PATH], *p;
+      struct stat sb;
+
+      if (GetModuleFileName (NULL, dir_name, MAX_PATH)
+          && (p = strrchr (dir_name, '\\')) != NULL)
+       {
+          p[1] = '\0';
+         for (p = dir_name; *p; p++)
+           if (*p == '\\')
+             *p = '/';
+          strcat (dir_name, "../share/bison");
+         if (stat (dir_name, &sb) == 0)
+           cp = strdup (dir_name);
+       }
+    }
+#endif
   return cp ? cp : PKGDATADIR;
 }





reply via email to

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