bug-bison
[Top][All Lists]
Advanced

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

Bison 1.35 is complied for Win32 with MSVC 6.0


From: Yury Lebedev
Subject: Bison 1.35 is complied for Win32 with MSVC 6.0
Date: Fri, 20 Sep 2002 11:55:04 +0400

Hello all Bison users

Here is a patch to compile Bison v1.35 for Win32 platforms and use it as
standalone application. Latest Bison already searches for bison.simple and
bison.hairy datafiles in bison.exe startup directory and can be conveniently
used separately but nevertheless some small fixes are required.

To compile bison.exe with MSVC 6.0 you should to do following:
- Download and extract bison 1.35 source distribution
- Apply 2 patches to src/main.c and src/output.c files:
main.c was added by GetModuleFileName() call to get full startup path of
bison.exe:
*** main.c.orig Tue Dec 18 07:53:36 2001
--- main.c Fri Sep 20 06:32:04 2002
***************
*** 37,50 ****
  #include "symtab.h"
  #include "lex.h"

! /* The name this program was run with, for messages.  */
  char *program_name;


  int
  main (int argc, char *argv[])
  {
    program_name = argv[0];
    setlocale (LC_ALL, "");
    bindtextdomain (PACKAGE, LOCALEDIR);
    textdomain (PACKAGE);
--- 37,62 ----
  #include "symtab.h"
  #include "lex.h"

! /* The name this program was run with, for messages and datafiles
searching.  */
  char *program_name;

+ #ifdef _WIN32
+ /* Program name buffer to store real full filename via GetModuleFileName()
call. */
+ # define WIN32_LEAN_AND_MEAN 1
+ # include <windows.h>
+ char program_name_buf[1024];
+ #endif /* _WIN32 */

  int
  main (int argc, char *argv[])
  {
    program_name = argv[0];
+
+ #ifdef _WIN32
+   if (GetModuleFileName (0, program_name_buf, sizeof(program_name_buf)) >
0)
+     program_name = program_name_buf;
+ #endif
+
    setlocale (LC_ALL, "");
    bindtextdomain (PACKAGE, LOCALEDIR);
    textdomain (PACKAGE);
***************
Also output.c was patched to replace alloca() call with malloc() one - MSVC
provides its own alloca() implementation but I could not find its definition
in libc.lib and other libraries! :(
*** output.c.orig Mon Mar 04 16:48:38 2002
--- output.c Fri Sep 20 06:23:56 2002
***************
*** 354,366 ****
--- 354,373 ----
  output_stos (void)
  {
    int i;
+ #if HAVE_ALLOCA || C_ALLOCA
    short *values = (short *) alloca (sizeof (short) * nstates);
+ #else
+   short *values = XMALLOC (short, nstates);
+ #endif
    for (i = 0; i < nstates; ++i)
      values[i] = state_table[i].accessing_symbol;
    output_short_table (&table_obstack,
          "YYSTOS[STATE] -- Accessing symbol to the STATE",
          "yystos", values,
          0, 1, nstates);
+ #if !HAVE_ALLOCA && !C_ALLOCA
+   XFREE (values);
+ #endif
  }
***************
- Create some subdirectory in bison source tree (with 'win32' name by
example) and put there config.h and msvc60.mak files attached to this
message. Start 'Command Prompt' window and make this directory current one.
Build bison.exe by 'nmake -f msvc60.mak' command (there are some warnings
during build - seems they may be ignored). Copy compiled bison.exe and
bison.simple & bison.hairy from 'src' subdirectory into your target path
(listed in PATH environment advisable).

Short README about this also attached.
Please replace '=3D' strings in attached msvc60.mak to '=' char if you will
create this file from this message snapshot.

Regards,
Yury Lebedev

Attachment: config.h
Description: Text document

Attachment: msvc60.mak
Description: Text document

Attachment: INSTALL-WIN32.txt
Description: Text document


reply via email to

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