Skip to content

Commit

Permalink
Add options nounistd & never-interactive to seclang-scanner.ll
Browse files Browse the repository at this point in the history
- The parser is not used interactively so we can avoid including
  unistd.h, which is not available on Windows MSVC C++ compiler.
- The #ifdef WIN32 introduced in PR owasp-modsecurity#3132 would probably be overwritten
  when the parser is updated.
  • Loading branch information
eduar-hte committed May 19, 2024
1 parent 124a434 commit 2c48838
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions src/parser/seclang-scanner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4900,13 +4900,14 @@ static std::stack<int> YY_PREVIOUS_STATE;
// The location of the current token.
#line 4902 "seclang-scanner.cc"
#define YY_NO_INPUT 1
#define YY_NO_UNISTD_H 1

#line 494 "seclang-scanner.ll"
// Code run each time a pattern is matched.
# define YY_USER_ACTION driver.loc.back()->columns (yyleng);

#line 4909 "seclang-scanner.cc"
#line 4910 "seclang-scanner.cc"
#line 4911 "seclang-scanner.cc"

#define INITIAL 0
#define EXPECTING_ACTION_PREDICATE_VARIABLE 1
Expand Down Expand Up @@ -4952,11 +4953,7 @@ static std::stack<int> YY_PREVIOUS_STATE;
* The user has a chance to override it with an option.
*/
/* %if-c-only */
#ifndef WIN32
#include <unistd.h>
#else
#include <io.h>
#endif
/* %endif */
/* %if-c++-only */
/* %endif */
Expand Down Expand Up @@ -5232,7 +5229,7 @@ YY_DECL
// Code run each time yylex is called.
driver.loc.back()->step();

#line 5232 "seclang-scanner.cc"
#line 5233 "seclang-scanner.cc"

while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{
Expand Down Expand Up @@ -8338,7 +8335,7 @@ YY_RULE_SETUP
#line 1340 "seclang-scanner.ll"
ECHO;
YY_BREAK
#line 8338 "seclang-scanner.cc"
#line 8339 "seclang-scanner.cc"

case YY_END_OF_BUFFER:
{
Expand Down Expand Up @@ -8960,7 +8957,7 @@ static void yy_load_buffer_state (void)

/* %if-c-only */

b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
b->yy_is_interactive = 0;

/* %endif */
/* %if-c++-only */
Expand Down
2 changes: 1 addition & 1 deletion src/parser/seclang-scanner.ll
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static std::stack<int> YY_PREVIOUS_STATE;

// The location of the current token.
%}
%option noyywrap nounput batch debug noinput
%option noyywrap nounput batch debug noinput nounistd never-interactive



Expand Down

0 comments on commit 2c48838

Please sign in to comment.