Skip to content

Commit

Permalink
upgrade win_flex to version 2.6.4
Browse files Browse the repository at this point in the history
  • Loading branch information
lexxmark committed Nov 15, 2017
1 parent 6bd0085 commit 2607575
Show file tree
Hide file tree
Showing 17 changed files with 1,002 additions and 650 deletions.
10 changes: 10 additions & 0 deletions bin/Release/README.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
NOTE:
2.4.x versions include bison version 2.7
2.5.x versions include bison version 3.0.x

=======
versions 2.4.10/2.5.11
--------------
upgrade win_flex to version 2.6.4
fixed compilation warnings

=======
versions 2.4.9/2.5.10
--------------
Expand Down
Binary file modified bin/Release/win_flex.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion flex/src/buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ struct Buf *buf_append (struct Buf *buf, const void *ptr, int n_elem)
buf->nmax = n_alloc;
}

memcpy ((char*)buf->elts + (size_t) buf->nelts * buf->elt_size, ptr,
memcpy ((char *) buf->elts + (size_t) buf->nelts * buf->elt_size, ptr,
(size_t) n_elem * buf->elt_size);
buf->nelts += n_elem;

Expand Down
11 changes: 3 additions & 8 deletions flex/src/dfa.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,14 +463,9 @@ void ntod (void)
/* We still may want to use the table if numecs
* is a power of 2.
*/
int power_of_two;

for (power_of_two = 1; power_of_two <= csize;
power_of_two *= 2)
if (numecs == power_of_two) {
use_NUL_table = true;
break;
}
if (numecs <= csize && is_power_of_2(numecs)) {
use_NUL_table = true;
}
}

if (use_NUL_table)
Expand Down
9 changes: 5 additions & 4 deletions flex/src/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ clearerr(stdin);

if ((r = chain->filter_func (chain)) == -1)
flexfatal (_("filter_func failed"));
exit (0);
FLEX_EXIT (0);
}
else {
execvp (chain->argv[0],
Expand All @@ -384,7 +384,7 @@ clearerr(stdin);
chain->argv[0]);
}

exit (1);
FLEX_EXIT (1);
}

/* Parent */
Expand Down Expand Up @@ -513,7 +513,8 @@ int filter_tee_header (struct filter *chain)
fprintf (to_h, "\n");

/* write a fake line number. It will get fixed by the linedir filter. */
fprintf (to_h, "#line 4000 \"M4_YY_OUTFILE_NAME\"\n");
if (gen_line_dirs)
fprintf (to_h, "#line 4000 \"M4_YY_OUTFILE_NAME\"\n");

fprintf (to_h, "#undef %sIN_HEADER\n", prefix);
fprintf (to_h, "#endif /* %sHEADER_H */\n", prefix);
Expand Down Expand Up @@ -557,7 +558,7 @@ int filter_tee_header (struct filter *chain)
while (wait (0) > 0) ;
exit (0);
FLEX_EXIT (0);
return 0;
*/
return 0;
Expand Down
44 changes: 35 additions & 9 deletions flex/src/flex.skl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
%# pre-compilation stage of flex. Only macros starting
%# with `m4preproc_' are processed, and quoting is normal.
%#
%# 2. The preprocessed skeleton is translated verbatim into a
%# C array, saved as "skel.c" and compiled into the flex binary.
%# 2. The preprocessed skeleton is translated into a C array, saved
%# as "skel.c" and compiled into the flex binary. The %# comment
%# lines are removed.
%#
%# 3. At runtime, the skeleton is generated and filtered (again)
%# through m4. Macros beginning with `m4_' will be processed.
Expand Down Expand Up @@ -61,11 +62,17 @@ m4_changequote([[, ]])
m4_ifelse(M4_YY_PREFIX,yy,,
#define yy_create_buffer M4_YY_PREFIX[[_create_buffer]]
#define yy_delete_buffer M4_YY_PREFIX[[_delete_buffer]]
#define yy_flex_debug M4_YY_PREFIX[[_flex_debug]]
#define yy_scan_buffer M4_YY_PREFIX[[_scan_buffer]]
#define yy_scan_string M4_YY_PREFIX[[_scan_string]]
#define yy_scan_bytes M4_YY_PREFIX[[_scan_bytes]]
#define yy_init_buffer M4_YY_PREFIX[[_init_buffer]]
#define yy_flush_buffer M4_YY_PREFIX[[_flush_buffer]]
#define yy_load_buffer_state M4_YY_PREFIX[[_load_buffer_state]]
#define yy_switch_to_buffer M4_YY_PREFIX[[_switch_to_buffer]]
#define yypush_buffer_state M4_YY_PREFIX[[push_buffer_state]]
#define yypop_buffer_state M4_YY_PREFIX[[pop_buffer_state]]
#define yyensure_buffer_stack M4_YY_PREFIX[[ensure_buffer_stack]]
#define yy_flex_debug M4_YY_PREFIX[[_flex_debug]]
#define yyin M4_YY_PREFIX[[in]]
#define yyleng M4_YY_PREFIX[[leng]]
#define yylex M4_YY_PREFIX[[lex]]
Expand Down Expand Up @@ -105,9 +112,16 @@ m4_ifdef( [[M4_YY_REENTRANT]], [[m4_define([[M4_YY_HAS_START_STACK_VARS]])]])

m4_ifdef( [[M4_YY_PREFIX]],, [[m4_define([[M4_YY_PREFIX]], [[yy]])]])

m4preproc_define(`M4_GEN_PREFIX',
``[[#define yy$1 ]]M4_YY_PREFIX[[$1]]
m4_define([[yy$1]], [[M4_YY_PREFIX[[$1]]m4_ifelse($'`#,0,,[[($'`@)]])]])'')
m4preproc_define(`M4_GEN_PREFIX',``
[[#ifdef yy$1
#define ]]M4_YY_PREFIX[[$1_ALREADY_DEFINED
#else
#define yy$1 ]]M4_YY_PREFIX[[$1
#endif]]
'm4preproc_divert(1)`
[[#ifndef ]]M4_YY_PREFIX[[$1_ALREADY_DEFINED
#undef yy$1
#endif]]'m4preproc_divert(0)')
%if-c++-only
/* The c++ scanner is a mess. The FlexLexer.h header file relies on the
Expand All @@ -120,6 +134,7 @@ m4_define([[yy$1]], [[M4_YY_PREFIX[[$1]]m4_ifelse($'`#,0,,[[($'`@)]])]])'')
%endif

%if-c-only
m4_ifelse(M4_YY_PREFIX,yy,,
M4_GEN_PREFIX(`_create_buffer')
M4_GEN_PREFIX(`_delete_buffer')
M4_GEN_PREFIX(`_scan_buffer')
Expand Down Expand Up @@ -155,6 +170,7 @@ m4_define([[yy$1]], [[M4_YY_PREFIX[[$1]]m4_ifelse($'`#,0,,[[($'`@)]])]])'')
M4_GEN_PREFIX(`set_column')
]])
M4_GEN_PREFIX(`wrap')
)
%endif

m4_ifdef( [[M4_YY_BISON_LVAL]],
Expand All @@ -170,11 +186,14 @@ m4_ifdef( [[<M4_YY_BISON_LLOC>]],
]])


m4_ifelse(M4_YY_PREFIX,yy,,
M4_GEN_PREFIX(`alloc')
M4_GEN_PREFIX(`realloc')
M4_GEN_PREFIX(`free')
)

%if-c-only
m4_ifelse(M4_YY_PREFIX,yy,,
m4_ifdef( [[M4_YY_NOT_REENTRANT]],
[[
M4_GEN_PREFIX(`text')
Expand All @@ -184,6 +203,7 @@ m4_ifdef( [[M4_YY_NOT_REENTRANT]],
M4_GEN_PREFIX(`_flex_debug')
M4_GEN_PREFIX(`lineno')
]])
)
%endif


Expand Down Expand Up @@ -214,8 +234,8 @@ m4_ifdef( [[M4_YY_TABLES_EXTERNAL]],
m4preproc_include(`flexint.h')
%endif

%if-c++-only
/* begin standard C++ headers. */
%if-c++-only
#include <iostream>
#include <errno.h>
#include <cstdlib>
Expand Down Expand Up @@ -1664,6 +1684,8 @@ m4_ifdef( [[M4_YY_USES_REJECT]],
(void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size M4_YY_CALL_LAST_ARG );
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
/* "- 2" to take care of EOB's */
YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
}

YY_G(yy_n_chars) += number_to_move;
Expand Down Expand Up @@ -1896,6 +1918,9 @@ m4_ifdef( [[M4_YY_USE_LINENO]],
*/
void yyFlexLexer::yyrestart( std::istream* input_file )
{
if( ! input_file ) {
input_file = &yyin;
}
yyrestart( *input_file );
}
%endif
Expand Down Expand Up @@ -2057,7 +2082,7 @@ static void yy_load_buffer_state (M4_YY_DEF_ONLY_ARG)
b->yy_input_file = file;
%endif
%if-c++-only
b->yy_input_file = (&file == 0) ? NULL : file.rdbuf();
b->yy_input_file = file.rdbuf();
%endif
b->yy_fill_buffer = 1;

Expand Down Expand Up @@ -2435,7 +2460,7 @@ static void yynoreturn yy_fatal_error YYFARGS1(const char*, msg)
{
M4_YY_DECL_GUTS_VAR();
M4_YY_NOOP_GUTS_VAR();
(void) fprintf( stderr, "%s\n", msg );
fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE );
}
%endif
Expand Down Expand Up @@ -3398,4 +3423,5 @@ m4_ifdef( [[M4_YY_IN_HEADER]],
#undef YY_DECL_IS_OURS
#undef YY_DECL
#endif
m4preproc_undivert(1)
]])
36 changes: 16 additions & 20 deletions flex/src/flexdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,24 @@
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
/* Required: dup() and dup2() in <unistd.h> */
//#include <unistd.h>
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_SYS_PARAMS_H
#include <sys/params.h>
#endif
#ifdef HAVE_SYS_STAT_H
/* Required: stat() in <sys/stat.h> */
#include <sys/stat.h>
#endif
/* Required: wait() in <sys/wait.h> */
//#include <sys/wait.h>
#include <stdbool.h>
#define HAVE_REGEX_H
#ifdef HAVE_REGEX_H
#include <stdarg.h>
/* Required: regcomp(), regexec() and regerror() in <regex.h> */
#include <regex.h>
#endif
/* Required: strcasecmp() in <strings.h> */
//#include <strings.h>
#include "flexint.h"

/* We use gettext. So, when we write strings which should be translated, we mark them with _() */
Expand Down Expand Up @@ -109,6 +109,8 @@
#define ABS(x) ((x) < 0 ? -(x) : (x))
#endif

/* Whether an integer is a power of two */
#define is_power_of_2(n) ((n) > 0 && ((n) & ((n) - 1)) == 0)

#define unspecified -1

Expand Down Expand Up @@ -843,9 +845,6 @@ extern void flexfatal(const char *);
}while(0)
#endif /* ! HAVE_DECL___func__ */

/* Convert a hexadecimal digit string to an integer value. */
extern unsigned int htoui(unsigned char[]);

/* Report an error message formatted */
extern void lerr(const char *, ...)
#if defined(__GNUC__) && __GNUC__ >= 3
Expand Down Expand Up @@ -882,9 +881,6 @@ extern int myctoi(const char *);
/* Return character corresponding to escape sequence. */
extern unsigned char myesc(unsigned char[]);

/* Convert an octal digit string to an integer value. */
extern unsigned int otoui(unsigned char[]);

/* Output a (possibly-formatted) string to the generated scanner. */
extern void out(const char *);
extern void out_dec(const char *, int);
Expand Down Expand Up @@ -975,8 +971,9 @@ extern void line_pinpoint(const char *, int);
extern void format_synerr(const char *, const char *);
extern void synerr(const char *); /* report a syntax error */
extern void format_warn(const char *, const char *);
extern void warn(const char *); /* report a warning */
extern void lwarn(const char *); /* report a warning */
extern void yyerror(const char *); /* report a parse error */
extern int yyparse(void); /* the YACC parser */


/* from file scan.l */
Expand Down Expand Up @@ -1118,7 +1115,7 @@ struct filter {
const char ** argv; /**< arg vector, \0-terminated */
FILE* in_file;
FILE* out_file;
struct filter * next; /**< next filter or NULL */
struct filter * next; /**< next filter or NULL */
};

/* output filter chain */
Expand All @@ -1131,10 +1128,10 @@ extern bool filter_apply_chain(struct filter * chain, FILE* in_file, FILE* out_f
extern int filter_truncate(struct filter * chain, int max_len);
extern int filter_tee_header(struct filter *chain);
extern int filter_fix_linedirs(struct filter *chain);
extern int filter_m4_p (struct filter *chain);
extern int filter_m4_p(struct filter *chain);

extern char* add_tmp_dir (const char* tmp_file_name);
extern FILE* mkstempFILE (char *tmpl, const char *mode);
extern char* add_tmp_dir(const char* tmp_file_name);
extern FILE* mkstempFILE(char *tmpl, const char *mode);
extern void unlinktemp();


Expand Down Expand Up @@ -1169,6 +1166,5 @@ extern void sf_init(void);
extern void sf_push(void);
extern void sf_pop(void);

extern int snprintf(char* str, size_t size, const char* format, ...);

#endif /* not defined FLEXDEF_H */
4 changes: 4 additions & 0 deletions flex/src/flexint.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U)
#endif

#ifndef SIZE_MAX
#define SIZE_MAX (~(size_t)0)
#endif

#endif /* ! C99 */

#endif /* ! FLEXINT_H */
4 changes: 4 additions & 0 deletions flex/src/gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,12 @@ void gen_find_action (void)
indent_puts ("yy_current_state = *--YY_G(yy_state_ptr);");
indent_puts ("YY_G(yy_lp) = yy_accept[yy_current_state];");

if (!variable_trailing_context_rules)
outn ("m4_ifdef( [[M4_YY_USES_REJECT]],\n[[");
if(reject_really_used)
outn ("find_rule: /* we branch to this label when backing up */");
if (!variable_trailing_context_rules)
outn ("]])\n");

indent_puts
("for ( ; ; ) /* until we find what rule we matched */");
Expand Down
13 changes: 7 additions & 6 deletions flex/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include "parse.h"
#include <io.h>

static char flex_version[] = "2.6.3";//FLEX_VERSION;
static char flex_version[] = "2.6.4";//FLEX_VERSION;

/* declare functions that have forward references */

Expand Down Expand Up @@ -283,7 +283,7 @@ void check_options (void)
flexerror (_("Can't use -+ with -CF option"));

if (C_plus_plus && yytext_is_array) {
warn (_("%array incompatible with -+ option"));
lwarn (_("%array incompatible with -+ option"));
yytext_is_array = false;
}

Expand Down Expand Up @@ -369,16 +369,17 @@ void check_options (void)
endOfDir = path+length;

{
char m4_path[endOfDir-path + 1 + m4_length + 1];
char *m4_path = calloc(endOfDir-path + 1 + m4_length + 1, 1);

memcpy(m4_path, path, endOfDir-path);
m4_path[endOfDir-path] = '/';
memcpy(m4_path + (endOfDir-path) + 1, m4, m4_length + 1);
if (stat(m4_path, &sbuf) == 0 &&
(S_ISREG(sbuf.st_mode)) && sbuf.st_mode & S_IXUSR) {
m4 = strdup(m4_path);
m4 = m4_path;
break;
}
free(m4_path);
}
path = endOfDir+1;
} while (path[0]);
Expand Down Expand Up @@ -1685,9 +1686,9 @@ void readin (void)
if (!do_yywrap) {
if (!C_plus_plus) {
if (reentrant)
outn ("\n#define yywrap(yyscanner) (/*CONSTCOND*/1)");
out_str ("\n#define %swrap(yyscanner) (/*CONSTCOND*/1)\n", prefix);
else
outn ("\n#define yywrap() (/*CONSTCOND*/1)");
out_str ("\n#define %swrap() (/*CONSTCOND*/1)\n", prefix);
}
outn ("#define YY_SKIP_YYWRAP");
}
Expand Down
Loading

0 comments on commit 2607575

Please sign in to comment.