Skip to content

Commit 5b135dd

Browse files
committed
Fix compile error with flex >= 2.5.36
Newer flex declares yyleng to be yy_size_t (== size_t), contrary to SuS.
1 parent 6fe1c6f commit 5b135dd

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

configure.in

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,23 @@ if test "${LEX}" = "flex"; then
135135
AC_DEFINE(HAVE_FLEX,1,[using flex, rather than lex])
136136
fi
137137

138+
# flex >= 2.5.36 uses a nonstandard type for yyleng
139+
AC_MSG_CHECKING([whether yyleng is yy_size_t])
140+
cat > conftest.l <<EOF
141+
%%
142+
%%
143+
yy_size_t yyleng;
144+
EOF
145+
$LEX conftest.l
146+
AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED [`cat $LEX_OUTPUT_ROOT.c`]], [
147+
AC_MSG_RESULT(yes)
148+
AC_DEFINE(YYLENG_IS_YY_SIZE_T,1,
149+
[Define to 1 if lex declares yyleng to be yy_size_t.])
150+
], [
151+
AC_MSG_RESULT(no)
152+
])
153+
rm -f conftest.l $LEX_OUTPUT_ROOT.c
154+
138155
# get packages we need
139156
# gtk before 2.4.9 crashes with the way we use combobox :-(
140157
PKG_CHECK_MODULES(REQUIRED_PACKAGES,

src/parser.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@ extern InputState input_state;
5555
void nip2yyerror( const char *sub, ... )
5656
__attribute__((format(printf, 1, 2)));
5757
void yyerror( const char *msg );
58+
#ifdef YYLENG_IS_YY_SIZE_T
59+
/* Assume yy_size_t is size_t.
60+
*/
61+
extern size_t yyleng;
62+
#else
5863
extern int yyleng; /* lex stuff */
64+
#endif
5965

6066
/* Lex gathers tokens here for workspace.c
6167
*/

0 commit comments

Comments
 (0)