1 Received: 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
3 Received: 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
6 From: tkane01@unix.cc.emory.edu (Terrence O Kane)
7 Received: by larry.cc.emory.edu (5.0) id AA11757; Thu, 29 Sep 1994 10:26:43 +0500
8 Message-Id: <9409291426.AA11757@larry.cc.emory.edu>
9 Subject: patches and makefile for Borland C 4.02, flex 2.4.7
11 Date: Thu, 29 Sep 1994 10:26:42 -0400 (EDT)
12 X-Mailer: ELM [version 2.4 PL23]
14 Content-Type: text/plain; charset=US-ASCII
15 Content-Transfer-Encoding: 7bit
18 Enclosed are unified diffs and a makefile for Borland 4.02
20 The changes in the enclosed are 1) make the size parameters for memory
21 allocation "size_t", 2) change an include file when the lexer is
22 compiled within 'extern "C" {...}' in a C++ file, and 3) include pragmas
23 in the header suitable for BCC 4.02 to hush on warnings.
25 The latter is done because of the limit on command line size. A tradeoff
26 exists between putting pragmas in the header, or #defines in the header -
27 I put in the pragmas since they're suppoed to be ignored unless
28 understood - *and* they're enclosed in BCC specific ifdefs, anyway.
30 All changes are enclosed in "#ifdef __BORLANDC__".
36 --- misc.c Tue Jan 04 14:33:10 1994
37 +++ ../misc.c Wed Sep 28 18:44:32 1994
43 /* allocate_array - allocate memory for an integer array of the given size */
45 void *allocate_array( size, element_size )
47 int size, element_size;
48 +#else /* __BORLANDC__ */
49 +size_t size, element_size;
50 +#endif /* __BORLANDC__ */
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
62 /* reallocate_array - increase the size of a dynamic array */
64 void *reallocate_array( array, size, element_size )
67 int size, element_size;
68 +#else /* __BORLANDC__ */
69 +size_t size, element_size;
70 +#endif /* __BORLANDC__ */
72 register void *new_array;
74 /* Same worry as in allocate_array(): */
75 if ( size * element_size <= 0 )
77 "attempt to increase array size by less than 1 byte" );
82 /* The following is only needed when building flex's parser using certain
83 * broken versions of bison.
85 void *yy_flex_xmalloc( size )
88 +#else /* __BORLANDC__ */
90 +#endif /* __BORLANDC__ */
92 void *result = flex_alloc( size );
95 flexfatal( "memory allocation failed in yy_flex_xmalloc()" );
103 --- skel.c Wed Aug 03 11:38:32 1994
104 +++ ../skel.c Wed Sep 28 18:50:58 1994
107 "#ifdef __cplusplus",
109 "#include <stdlib.h>",
113 + "#ifndef __BORLANDC__",
114 "#include <unistd.h>",
115 + "#else /* __BORLANDC__ */",
117 + "#endif /* __BORLANDC__ */",
119 "/* Use prototypes in function declarations. */",
120 "#define YY_USE_PROTOS",
122 "/* The \"const\" storage-class-modifier is valid. */",
123 "#define YY_USE_CONST",
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 ));",
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 * ));",
142 "#define yy_new_buffer yy_create_buffer",
144 "%% yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here",
146 "#ifndef yytext_ptr",
152 --- initscan.c Wed Aug 03 11:42:46 1994
153 +++ ../initscan.c Wed Sep 28 18:51:34 1994
162 +#ifndef __BORLANDC__
164 +#else /* __BORLANDC__ */
166 +#endif /* __BORLANDC__ */
168 /* Use prototypes in function declarations. */
169 #define YY_USE_PROTOS
171 /* The "const" storage-class-modifier is valid. */
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 ));
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 * ));
191 #define yy_new_buffer yy_create_buffer
195 #define SECT2PROLOG 2
201 --- flexdef.h Tue Jan 04 14:33:14 1994
202 +++ ../flexdef.h Wed Sep 28 18:53:44 1994
206 /* @(#) $Header$ (LBL) */
221 +#endif /* __BORLANDC__ */
229 @@ -607,19 +618,29 @@
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;
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__ */
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*));
254 #define allocate_integer_array(size) \
255 (int *) allocate_array( size, sizeof( int ) )
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));
263 /* Output a yy_trans_info structure. */
264 extern void transition_struct_out PROTO((int, int));
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__ */
273 /* Set a region of memory to 0. */
274 extern void zero_out PROTO((char *, int));
277 /* from file nfa.c */
283 ###############################################################################
284 # Makefile for flex 2.4.7 with Borland C/C++ version 4.02
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
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
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?
298 # This makefile does *not* implement the big testing found in "makefile.in".
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?
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.
308 ###############################################################################
316 ###############################################################################
318 # standard utilitities? ha.
324 ###############################################################################
330 !message Building with debug.
334 !message Building without debug.
339 LOADER = c0$(MODEL).obj
341 LINKFLAGS = $(debugLink)
345 Defines = -DSHORT_FILE_NAMES=1 -DHAVE_STRING_H=1
347 COMMON = -A -c -m$(MODEL) $(SizeOPT) $(DATASEG) $(Defines) $(debugCompile)
348 CFLAGS = -o$@ $(COMMON)
349 CCFLAGS = -o$@ $(COMMON) -Pcc
351 ###############################################################################
361 ###############################################################################
363 # source & object files
366 SRC = 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
369 OBJS = $(SRC:.c=.obj)
374 ###############################################################################
380 tlink $(LINKFLAGS) @&&!
388 ###############################################################################
397 $(FLEX) $(FLEX_FLAGS) scan.l >scan.tmp
398 sed s,\"$(srcdir)/scan.l\",\"scan.l\", <scan.tmp >scan.c
401 ###############################################################################
411 @sed "/extern char.*malloc/d" <y_tab.c >parse.c
418 ###############################################################################