1Received: from 128.140.1.1 by ee.lbl.gov for <vern@ee.lbl.gov> (8.6.9/1.43r) 2 id HAA01193; Thu, 29 Sep 1994 07:26:54 -0700 3Received: from larry-le0.cc.emory.edu by 4 emoryu1.cc.emory.edu (5.65/Emory_cc.4.0.1) via SMTP 5 id AA07292 ; Thu, 29 Sep 94 10:26:41 -0400 6From: tkane01@unix.cc.emory.edu (Terrence O Kane) 7Received: by larry.cc.emory.edu (5.0) id AA11757; Thu, 29 Sep 1994 10:26:43 +0500 8Message-Id: <9409291426.AA11757@larry.cc.emory.edu> 9Subject: patches and makefile for Borland C 4.02, flex 2.4.7 10To: vern@ee.lbl.gov 11Date: Thu, 29 Sep 1994 10:26:42 -0400 (EDT) 12X-Mailer: ELM [version 2.4 PL23] 13Mime-Version: 1.0 14Content-Type: text/plain; charset=US-ASCII 15Content-Transfer-Encoding: 7bit 16Content-Length: 9900 17 18Enclosed are unified diffs and a makefile for Borland 4.02 19 20The changes in the enclosed are 1) make the size parameters for memory 21allocation "size_t", 2) change an include file when the lexer is 22compiled within 'extern "C" {...}' in a C++ file, and 3) include pragmas 23in the header suitable for BCC 4.02 to hush on warnings. 24 25The latter is done because of the limit on command line size. A tradeoff 26exists between putting pragmas in the header, or #defines in the header - 27I put in the pragmas since they're suppoed to be ignored unless 28understood - *and* they're enclosed in BCC specific ifdefs, anyway. 29 30All changes are enclosed in "#ifdef __BORLANDC__". 31 32 33 34 35 36--- misc.c Tue Jan 04 14:33:10 1994 37+++ ../misc.c Wed Sep 28 18:44:32 1994 38@@ -55,15 +55,19 @@ 39 action_index += len; 40 } 41 42 43 /* allocate_array - allocate memory for an integer array of the given size */ 44 45 void *allocate_array( size, element_size ) 46+#ifndef __BORLANDC__ 47 int size, element_size; 48+#else /* __BORLANDC__ */ 49+size_t size, element_size; 50+#endif /* __BORLANDC__ */ 51 { 52 register void *mem; 53 54 /* On 16-bit int machines (e.g., 80286) we might be trying to 55 * allocate more than a signed int can hold, and that won't 56 * work. Cheap test: 57 */ 58@@ -634,15 +638,19 @@ 59 } 60 61 62 /* reallocate_array - increase the size of a dynamic array */ 63 64 void *reallocate_array( array, size, element_size ) 65 void *array; 66+#ifndef __BORLANDC__ 67 int size, element_size; 68+#else /* __BORLANDC__ */ 69+size_t size, element_size; 70+#endif /* __BORLANDC__ */ 71 { 72 register void *new_array; 73 74 /* Same worry as in allocate_array(): */ 75 if ( size * element_size <= 0 ) 76 flexfatal( 77 "attempt to increase array size by less than 1 byte" ); 78@@ -739,15 +747,19 @@ 79 } 80 81 82 /* The following is only needed when building flex's parser using certain 83 * broken versions of bison. 84 */ 85 void *yy_flex_xmalloc( size ) 86+#ifndef __BORLANDC__ 87 int size; 88+#else /* __BORLANDC__ */ 89+size_t size; 90+#endif /* __BORLANDC__ */ 91 { 92 void *result = flex_alloc( size ); 93 94 if ( ! result ) 95 flexfatal( "memory allocation failed in yy_flex_xmalloc()" ); 96 97 return result; 98 99 100 101 102 103--- skel.c Wed Aug 03 11:38:32 1994 104+++ ../skel.c Wed Sep 28 18:50:58 1994 105@@ -26,15 +26,19 @@ 106 "", 107 "#ifdef __cplusplus", 108 "", 109 "#include <stdlib.h>", 110 "%+", 111 "class istream;", 112 "%*", 113+ "#ifndef __BORLANDC__", 114 "#include <unistd.h>", 115+ "#else /* __BORLANDC__ */", 116+ "#include <io.h>", 117+ "#endif /* __BORLANDC__ */", 118 "", 119 "/* Use prototypes in function declarations. */", 120 "#define YY_USE_PROTOS", 121 "", 122 "/* The \"const\" storage-class-modifier is valid. */", 123 "#define YY_USE_CONST", 124 "", 125@@ -240,16 +244,21 @@ 126 "static int yy_start_stack_depth = 0;", 127 "static int *yy_start_stack = 0;", 128 "static void yy_push_state YY_PROTO(( int new_state ));", 129 "static void yy_pop_state YY_PROTO(( void ));", 130 "static int yy_top_state YY_PROTO(( void ));", 131 "%*", 132 "", 133+ "#ifndef __BORLANDC__", 134 "static void *yy_flex_alloc YY_PROTO(( unsigned int ));", 135 "static void *yy_flex_realloc YY_PROTO(( void *, unsigned int ));", 136+ "#else /* __BORLANDC__ */", 137+ "static void *yy_flex_alloc YY_PROTO(( size_t ));", 138+ "static void *yy_flex_realloc YY_PROTO(( void *, size_t ));", 139+ "#endif /* __BORLANDC__ */", 140 "static void yy_flex_free YY_PROTO(( void * ));", 141 "", 142 "#define yy_new_buffer yy_create_buffer", 143 "", 144 "%% yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here", 145 "", 146 "#ifndef yytext_ptr", 147 148 149 150 151 152--- initscan.c Wed Aug 03 11:42:46 1994 153+++ ../initscan.c Wed Sep 28 18:51:34 1994 154@@ -16,15 +16,19 @@ 155 #endif 156 #endif 157 158 159 #ifdef __cplusplus 160 161 #include <stdlib.h> 162+#ifndef __BORLANDC__ 163 #include <unistd.h> 164+#else /* __BORLANDC__ */ 165+#include <io.h> 166+#endif /* __BORLANDC__ */ 167 168 /* Use prototypes in function declarations. */ 169 #define YY_USE_PROTOS 170 171 /* The "const" storage-class-modifier is valid. */ 172 #define YY_USE_CONST 173 174@@ -220,16 +224,21 @@ 175 static int yy_start_stack_ptr = 0; 176 static int yy_start_stack_depth = 0; 177 static int *yy_start_stack = 0; 178 static void yy_push_state YY_PROTO(( int new_state )); 179 static void yy_pop_state YY_PROTO(( void )); 180 static int yy_top_state YY_PROTO(( void )); 181 182+#ifndef __BORLANDC__ 183 static void *yy_flex_alloc YY_PROTO(( unsigned int )); 184 static void *yy_flex_realloc YY_PROTO(( void *, unsigned int )); 185+#else /* __BORLANDC__ */ 186+static void *yy_flex_alloc YY_PROTO(( size_t )); 187+static void *yy_flex_realloc YY_PROTO(( void *, size_t )); 188+#endif /* __BORLANDC__ */ 189 static void yy_flex_free YY_PROTO(( void * )); 190 191 #define yy_new_buffer yy_create_buffer 192 193 #define INITIAL 0 194 #define SECT2 1 195 #define SECT2PROLOG 2 196 197 198 199 200 201--- flexdef.h Tue Jan 04 14:33:14 1994 202+++ ../flexdef.h Wed Sep 28 18:53:44 1994 203@@ -27,14 +27,25 @@ 204 */ 205 206 /* @(#) $Header: flexdef.h,v 1.2 94/01/04 14:33:14 vern Exp $ (LBL) */ 207 208 #include <stdio.h> 209 #include <ctype.h> 210 211+#ifdef __BORLANDC__ 212+#include <malloc.h> 213+ 214+#pragma warn -pro 215+#pragma warn -rch 216+#pragma warn -use 217+#pragma warn -aus 218+#pragma warn -par 219+#pragma warn -pia 220+ 221+#endif /* __BORLANDC__ */ 222 #if HAVE_STRING_H 223 #include <string.h> 224 #else 225 #include <strings.h> 226 #endif 227 228 #if __STDC__ 229@@ -607,19 +618,29 @@ 230 */ 231 232 extern char nmstr[MAXLINE]; 233 extern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs; 234 extern int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave; 235 extern int num_backing_up, bol_needed; 236 237+#ifndef __BORLANDC__ 238 void *allocate_array PROTO((int, int)); 239 void *reallocate_array PROTO((void*, int, int)); 240+#else /* __BORLANDC__ */ 241+void *allocate_array PROTO((size_t, size_t)); 242+void *reallocate_array PROTO((void*, size_t, size_t)); 243+#endif /* __BORLANDC__ */ 244 245+#ifndef __BORLANDC__ 246 void *flex_alloc PROTO((unsigned int)); 247 void *flex_realloc PROTO((void*, unsigned int)); 248+#else /* __BORLANDC__ */ 249+void *flex_alloc PROTO((size_t)); 250+void *flex_realloc PROTO((void*, size_t)); 251+#endif /* __BORLANDC__ */ 252 void flex_free PROTO((void*)); 253 254 #define allocate_integer_array(size) \ 255 (int *) allocate_array( size, sizeof( int ) ) 256 257 #define reallocate_integer_array(array,size) \ 258 (int *) reallocate_array( (void *) array, size, sizeof( int ) ) 259@@ -772,15 +793,19 @@ 260 /* Write out one section of the skeleton file. */ 261 extern void skelout PROTO((void)); 262 263 /* Output a yy_trans_info structure. */ 264 extern void transition_struct_out PROTO((int, int)); 265 266 /* Only needed when using certain broken versions of bison to build parse.c. */ 267+#ifndef __BORLANDC__ 268 extern void *yy_flex_xmalloc PROTO(( int )); 269+#else /* __BORLANDC__ */ 270+extern void *yy_flex_xmalloc PROTO(( size_t )); 271+#endif /* __BORLANDC__ */ 272 273 /* Set a region of memory to 0. */ 274 extern void zero_out PROTO((char *, int)); 275 276 277 /* from file nfa.c */ 278 279 280 281 282 283############################################################################### 284# Makefile for flex 2.4.7 with Borland C/C++ version 4.02 285# 286# This will probably need to be adjusted for your existing lexer/parser 287# generators. See definitions for FLEX and YACC near the bottom of the 288# makefile. 289# 290# Copy initscan.c to scan.c to make your first executable. After that, 291# you may choose to try alternate compression options for your everyday 292# flex executable. 293# 294# This will build flex with the large model. Don't use huge, but if you 295# feel like experimenting with other models, post your success stories to 296# comp.compilers, OK? 297# 298# This makefile does *not* implement the big testing found in "makefile.in". 299# 300# I also assume the availability of sed and the gnu file utilities on the 301# system - they're readily available, so if you don't have them, why not? 302# <grin> 303# 304# The resulting generated lexer (the real goal, right?) will compile 305# (and run nicely, too) as a .c file, as well as being included such as 306# extern "C" { #include "lexyyc" } in a .cplusplus file. 307# 308############################################################################### 309 310DEBUG = 1 311 312.autodepend 313 314all: flex.exe 315 316############################################################################### 317# 318# standard utilitities? ha. 319# 320 321CC = bcc 322CPP = bcc 323 324############################################################################### 325# 326 327MODEL = l 328 329!if $(DEBUG) == 1 330!message Building with debug. 331debugCompile = -v 332debugLink = /v 333!else 334!message Building without debug. 335debugCompile = 336debugLink = 337!endif 338 339LOADER = c0$(MODEL).obj 340LIBS = c$(MODEL).lib 341LINKFLAGS = $(debugLink) 342 343DATASEG = -dc -Ff 344SizeOPT = -Os -G- 345Defines = -DSHORT_FILE_NAMES=1 -DHAVE_STRING_H=1 346 347COMMON = -A -c -m$(MODEL) $(SizeOPT) $(DATASEG) $(Defines) $(debugCompile) 348CFLAGS = -o$@ $(COMMON) 349CCFLAGS = -o$@ $(COMMON) -Pcc 350 351############################################################################### 352 353.SUFFIXES: .cc 354 355.cc.obj: 356 $(CPP) $(CCFLAGS) $< 357 358.c.obj: 359 $(CPP) $(CFLAGS) $< 360 361############################################################################### 362# 363# source & object files 364# 365 366SRC = ccl.c dfa.c ecs.c gen.c main.c misc.c nfa.c parse.c \ 367 scan.c sym.c tblcmp.c yylex.c skel.c 368 369OBJS = $(SRC:.c=.obj) 370 371objects: $(OBJS) 372 @echo $(OBJS) 373 374############################################################################### 375# 376# Executable 377# 378 379flex.exe: $(OBJS) 380 tlink $(LINKFLAGS) @&&! 381$(LOADER) $** 382$&.exe 383$&.map 384$(LIBS) 385! 386 387# 388############################################################################### 389# 390# Lex files 391# 392 393FLEX = .\flex 394FLEX_FLAGS = -ist 395 396scan.c: scan.l 397 $(FLEX) $(FLEX_FLAGS) scan.l >scan.tmp 398 sed s,\"$(srcdir)/scan.l\",\"scan.l\", <scan.tmp >scan.c 399 @rm scan.tmp 400 401############################################################################### 402# 403# YACC files 404# 405 406YACC = .\bison 407YFLAGS = -vdyl 408 409parse.c: parse.y 410 $(YACC) -ydl parse.y 411 @sed "/extern char.*malloc/d" <y_tab.c >parse.c 412 @rm -f y_tab.c 413 @mv y_tab.h parse.h 414 415# 416# end Makefile 417# 418############################################################################### 419 420