Skip to content

Commit

Permalink
added --wincompat option to win_flex (that changes <unistd.h> to <io.…
Browse files Browse the repository at this point in the history
…h> and isatty/fileno to _isatty/_fileno functions). Fixed 2 warnings in output flex file.

git-svn-id: svn://svn.code.sf.net/p/winflexbison/code/trunk@37 da3578c4-ce5d-4d2c-aa0c-bbd0a991affc
  • Loading branch information
lexxmark committed Jan 18, 2013
1 parent 84fa6a6 commit daca9ca
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 5 deletions.
6 changes: 6 additions & 0 deletions bin/Release/README.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
version 2.2
--------------
added --wincompat option to win_flex (this option changes <unistd.h> unix include with <io.h> windows analog
also isatty/fileno functions changed to _isatty/_fileno)
fixed two "'<' : signed/unsigned mismatch" warnings in win_flex generated file

version 2.1
--------------
fixed crash when execute win_bison.exe under WindowsXP (argv[0] don't have full application path)
Expand Down
4 changes: 4 additions & 0 deletions bin/Release/UNISTD_ERROR.readme
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
In case compile errors like "cannot include <unistd.h>" in win_flex generated file try add --wincompat invoke option.
This new option changes <unistd.h> unix header with windows analog <io.h> and replaces isatty/fileno functions to
"safe" windows analogs _isatty/_fileno as well. If you have compile issues with it afterwards please open ticket
at http://sourceforge.net/p/winflexbison/tickets .
Binary file modified bin/Release/win_bison.exe
Binary file not shown.
Binary file modified bin/Release/win_flex.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion flex/src/gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1972,7 +1972,7 @@ void make_tables ()
("if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )");
indent_up ();
indent_puts ("{");
indent_puts ("int yyl;");
indent_puts ("yy_size_t yyl;");
do_indent ();
out_str ("for ( yyl = %s; yyl < yyleng; ++yyl )\n",
yymore_used ? (yytext_is_array ? "YY_G(yy_prev_more_offset)" :
Expand Down
5 changes: 5 additions & 0 deletions flex/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,10 @@ void flexinit (argc, argv)
buf_m4_define( &m4defs_buf, "M4_YY_NO_UNISTD_H",0);
break;

case OPT_WIN_COMPAT:
buf_m4_define( &m4defs_buf, "M4_YY_WIN_COMPAT",0);
break;

case OPT_TABLES_FILE:
tablesext = true;
tablesfilename = arg;
Expand Down Expand Up @@ -1711,6 +1715,7 @@ void usage ()
" --noansi-definitions old-style function definitions\n"
" --noansi-prototypes empty parameter list in prototypes\n"
" --nounistd do not include <unistd.h>\n"
" --wincompat windows compatibility (uses <io.h> instead of <unistd.h> and _isatty, _fileno functions)\n"
" --noFUNCTION do not generate a particular FUNCTION\n"
"\n" "Miscellaneous:\n"
" -c do-nothing POSIX option\n"
Expand Down
6 changes: 4 additions & 2 deletions flex/src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,12 @@ optspec_t flexopts[] = {
, /* Flex should run in trace mode. */
{"--tables-file[=FILE]", OPT_TABLES_FILE, 0}
, /* Save tables to FILE */
{"--tables-verify", OPT_TABLES_VERIFY, 0}
, /* Tables integrity check */
{"--tables-verify", OPT_TABLES_VERIFY, 0}
, /* Tables integrity check */
{"--nounistd", OPT_NO_UNISTD_H, 0}
, /* Do not include unistd.h */
{"--wincompat", OPT_WIN_COMPAT, 0}
, /* windows compatibility */
{"-v", OPT_VERBOSE, 0}
,
{"--verbose", OPT_VERBOSE, 0}
Expand Down
3 changes: 2 additions & 1 deletion flex/src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ enum flexopt_flag_t {
OPT_YYCLASS,
OPT_YYLINENO,
OPT_YYMORE,
OPT_YYWRAP
OPT_YYWRAP,
OPT_WIN_COMPAT
};

#endif
Expand Down
11 changes: 10 additions & 1 deletion flex/src/skel.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,14 @@ const char *skel[] = {
"",
"m4_ifdef( [[M4_YY_NO_UNISTD_H]],,",
"[[",
" m4_ifdef( [[M4_YY_WIN_COMPAT]],",
" [[",
"/*windows compatibility case*/",
"#include <io.h>",
"#define isatty _isatty",
"#define fileno _fileno",
" ]],",
" [[",
"#ifndef YY_NO_UNISTD_H",
"/* Special case for \"unistd.h\", since it is non-ANSI. We include it way",
" * down here because we want the user's section 1 to have been scanned first.",
Expand All @@ -843,6 +851,7 @@ const char *skel[] = {
"#include <unistd.h>",
"%endif",
"#endif",
" ]])",
"]])",
"",
"m4_ifdef( [[M4_EXTRA_TYPE_DEFS]],",
Expand Down Expand Up @@ -2571,7 +2580,7 @@ const char *skel[] = {
" YY_BUFFER_STATE b;",
" char *buf;",
" yy_size_t n;",
" int i;",
" yy_size_t i;",
" m4_dnl M4_YY_DECL_GUTS_VAR();",
"",
" /* Get memory for full buffer, including space for trailing EOB's. */",
Expand Down

0 comments on commit daca9ca

Please sign in to comment.