[comp.binaries.ibm.pc] v01i146: flex.fix, patches to Flex for PC

seg@uunet.UU.NET (Scott Garfinkle) (02/17/89)

Posting-number: Volume 01 Issue 146
Originally-from: smsdpg!seg@uunet.UU.NET (Scott Garfinkle)
Submitted-by: smsdpg!seg@uunet.UU.NET (Scott Garfinkle)
Archive-name: flex/flex.fix

Following is a short shell script that patches flex (the version from
Nov 88) for compilation/execution on the PC.  Since the patches are
short, and are meant to be applied on a Unix box *before* shipping the
sources to the PC, The (Bourne) shell script to do the patching is not
arc'ed.  Thanks to kwok@iris.ucdavis.edu (Conrad Kwok) for testing.
Note: these patches were only tested using the Microsoft C 5.1
compiler.

Flex is part of comp.sources.unix, volume 14, and is also available by
ftp from the Free Software Foundation.

[
I'm not sure exactly what flex does.  I think it is a lexical
analyzer.

Cut at the BEGIN--cut and END--cut lines before feeding to /bin/sh.
This is not a shar posting.  Feed this to sh with the flex sources
nearby to perform the patching.

Checksum obtained with the 4.3BSD "sum" or System V "sum -r" command.

checksum     size (bytes)  file (between BEGIN--cut and END--cut lines)
   36748         6633      this text posting

-- R.D.
]

BEGIN--cut here--cut here
#!/bin/sh
# this is a Bourne shell script that shows the mods I did to go from flex
# MSC5/DOS -scott garfinkle
mv fastskeldef.h  fastskel.h
mv flex.fastskel  fastskel.flx
mv flex.skel  skel.flx
mv flexskelcom.h  fskelcom.h
mv flexskeldef.h  flexskel.h
mv scan.c.dist  scan-c.dst
patch2 << 'DONE-WITH-PATCHES'
*** fastskel.flx	Fri Nov 18 13:21:13 1988
--- pc/fastskel.flx	Sat Dec 31 09:49:17 1988
***************
*** 2,8 ****
  
  #define FLEX_FAST_SKEL
  
! #include "fastskeldef.h"
  
  %% section 1 code and the definition of YY_TRANS_OFFSET_TYPE, if needed, go here
  
--- 2,8 ----
  
  #define FLEX_FAST_SKEL
  
! #include "fastskel.h"
  
  %% section 1 code and the definition of YY_TRANS_OFFSET_TYPE, if needed, go here
  
*** fastskel.h	Fri Nov 18 13:21:03 1988
--- pc/fastskel.h	Sat Dec 31 09:49:18 1988
***************
*** 1,6 ****
  /*  macro definitions for fast/full-table  C/FTL programs generated by flex */
  
! #include "flexskelcom.h"
  
  #define YY_END_OF_BUFFER_CHAR 0
  
--- 1,6 ----
  /*  macro definitions for fast/full-table  C/FTL programs generated by flex */
  
! #include "fskelcom.h"
  
  #define YY_END_OF_BUFFER_CHAR 0
  
*** flex.1	Fri Nov 18 13:21:09 1988
--- pc/flex.1	Sat Dec 31 09:49:19 1988
***************
*** 427,445 ****
  without requiring a separate library to link to.
  .SH FILES
  .TP
! .I flex.skel
  skeleton scanner
  .TP
! .I flex.fastskel
  skeleton scanner for -f and -F
  .TP
! .I flexskelcom.h
  common definitions for skeleton files
  .TP
! .I flexskeldef.h
  definitions for compressed skeleton file
  .TP
! .I fastskeldef.h
  definitions for -f, -F skeleton file
  .SH "SEE ALSO"
  .LP
--- 427,445 ----
  without requiring a separate library to link to.
  .SH FILES
  .TP
! .I flexskel.flx
  skeleton scanner
  .TP
! .I fastskel.flx
  skeleton scanner for -f and -F
  .TP
! .I fskelcom.h
  common definitions for skeleton files
  .TP
! .I flexskel.h
  definitions for compressed skeleton file
  .TP
! .I fastskel.h
  definitions for -f, -F skeleton file
  .SH "SEE ALSO"
  .LP
*** flexdef.h	Fri Nov 18 13:21:23 1988
--- pc/flexdef.h	Sat Dec 31 09:49:24 1988
***************
*** 21,34 ****
  
  #include <stdio.h>
  
  #ifdef SV
  #include <string.h>
  #define bzero(s, n) memset((char *)(s), '\000', (unsigned)(n))
  #else
  #include <strings.h>
  #endif
  
- char *sprintf(); /* keep lint happy */
  
  
  /* maximum line length we'll have to deal with */
--- 21,38 ----
  
  #include <stdio.h>
  
+ #ifdef MSC5
+ # define SV
+ #endif
+ 
  #ifdef SV
  #include <string.h>
  #define bzero(s, n) memset((char *)(s), '\000', (unsigned)(n))
  #else
  #include <strings.h>
+ char *sprintf(); /* keep lint happy */
  #endif
  
  
  
  /* maximum line length we'll have to deal with */
***************
*** 44,55 ****
  #define false 0
  
  
! #ifndef DEFAULT_SKELETON_FILE
! #define DEFAULT_SKELETON_FILE "flex.skel"
  #endif
  
! #ifndef FAST_SKELETON_FILE
! #define FAST_SKELETON_FILE "flex.fastskel"
  #endif
  
  /* special nxt[] action number for the "at the end of the input buffer" state */
--- 48,63 ----
  #define false 0
  
  
! #ifndef FLEXFILE
! #define FLEXFILE "lex.yy.c"
  #endif
  
! #ifndef DEFAULT_SKEL
! #define DEFAULT_SKEL "flex.skel"
! #endif
! 
! #ifndef FAST_SKEL
! #define FAST_SKEL "flex.fastskel"
  #endif
  
  /* special nxt[] action number for the "at the end of the input buffer" state */
*** flexskel.h	Fri Nov 18 13:21:28 1988
--- pc/flexskel.h	Sat Dec 31 09:49:25 1988
***************
*** 1,6 ****
  /* macro definitions for compressed-table C/FTL programs generated by flex */
  
! #include "flexskelcom.h"
  
  /* reinitializes everything except the current start condition.  The last
   * input character is set to a newline so an initial beginning-of-line
--- 1,6 ----
  /* macro definitions for compressed-table C/FTL programs generated by flex */
  
! #include "fskelcom.h"
  
  /* reinitializes everything except the current start condition.  The last
   * input character is set to a newline so an initial beginning-of-line
*** main.c	Fri Nov 18 13:21:33 1988
--- pc/main.c	Sat Dec 31 09:49:26 1988
***************
*** 347,363 ****
  	skelname = skeleton_name_storage;
  
  	if ( fullspd || fulltbl )
! 	    (void) strcpy( skelname, FAST_SKELETON_FILE );
  	else
! 	    (void) strcpy( skelname, DEFAULT_SKELETON_FILE );
  	}
  
      if ( ! use_stdout )
  	{
! 	FILE *prev_stdout = freopen( "lex.yy.c", "w", stdout );
  
  	if ( prev_stdout == NULL )
! 	    flexerror( "could not create lex.yy.c" );
  	}
  
      if ( argc )
--- 347,363 ----
  	skelname = skeleton_name_storage;
  
  	if ( fullspd || fulltbl )
! 	    (void) strcpy( skelname, FAST_SKEL );
  	else
! 	    (void) strcpy( skelname, DEFAULT_SKEL );
  	}
  
      if ( ! use_stdout )
  	{
! 	FILE *prev_stdout = freopen( FLEXFILE, "w", stdout );
  
  	if ( prev_stdout == NULL )
! 	    flexerror( "could not create " FLEXFILE );
  	}
  
      if ( argc )
***************
*** 380,386 ****
      /* initialize the statistics */
      starttime = gettime();
  
!     if ( (skelfile = fopen( skelname, "r" )) == NULL )
  	lerrsf( "can't open skeleton file %s", skelname );
  
      (void) mktemp( action_file_name );
--- 380,401 ----
      /* initialize the statistics */
      starttime = gettime();
  
!     if ( (skelfile = fopen( skelname, "r" )) == NULL ) {
!     	char *getenv(), *ptr;
! 
! 	if((ptr = getenv("FLEXPATH")) || (ptr = getenv("INIT"))) {
! 		char *malloc();
! 	    char *newname = malloc(strlen(ptr)+strlen(skelname)+2);
! 
! 	    strcpy(newname,ptr);
! 	    ptr = newname+strlen(ptr);
! 	    *ptr++ = '/';	/* works even in DOS */
! 	    strcpy(ptr,skelname);
! 	    skelfile = fopen( newname, "r" );
! 	    free(newname);
!     	}
!     }
!     if(!skelfile)
  	lerrsf( "can't open skeleton file %s", skelname );
  
      (void) mktemp( action_file_name );
*** scan-c.dst	Fri Nov 18 13:25:22 1988
--- pc/scan-c.dst	Sat Dec 31 09:49:34 1988
***************
*** 3,9 ****
  #define FLEX_USE_MECS
  /* A lexical scanner generated by flex */
  
! #include "flexskeldef.h"
  
  # line 1 "scan.l"
  #define INITIAL 0
--- 3,9 ----
  #define FLEX_USE_MECS
  /* A lexical scanner generated by flex */
  
! #include "fskeldef.h"
  
  # line 1 "scan.l"
  #define INITIAL 0
*** skel.flx	Fri Nov 18 13:21:17 1988
--- pc/skel.flx	Sat Dec 31 09:49:38 1988
***************
*** 1,6 ****
  /* A lexical scanner generated by flex */
  
! #include "flexskeldef.h"
  
  %% section 1 code and data tables for DFA go here
  
--- 1,6 ----
  /* A lexical scanner generated by flex */
  
! #include "flexskel.h"
  
  %% section 1 code and data tables for DFA go here
  
DONE-WITH-PATCHES'
END--cut here--cut here