Rebase to 2.6.4 (#1389575)

This patch rebases flex to upstream version 2.6.4 and thus drops all
backported upstream patches that the package has been carrying so far.

One exception is flex-2.6.0-yyless.patch which has no equivalent upstream.
I could not track the origin of this patch because flex development moved
from SourceForge to GitHub and in the process, sourceforge bug tracker
content has been lost. However, RHBZ #1281976 seems to suggest that this
patch was included in order to fix a libreswan build failure caused by a
flex integer comparison type mismatch bug. I dropped flex-2.6.0-yyless.patch
and confirmed that the Fedora libreswan package corresponding to
libreswan-3.25 builds successfully despite this patch being dropped.

Additionally, flex-2.6.4 FTBFS because it uses reallocarray but does not
define _GNU_SOURCE leading to a missing prototype for reallocarray. This
commit also includes the upstream patch that fixes this. The patch modifies
configure.ac, which necessitates executing autoreconf at build time and thus
a corresponding set of new build dependencies.
This commit is contained in:
Arjun Shankar 2018-09-03 18:20:44 +02:00
parent ffa5f9318b
commit c0c5e9ed4b
10 changed files with 55 additions and 170 deletions

1
.gitignore vendored
View File

@ -6,4 +6,5 @@ flex-2.5.35.tar.bz2
/flex-2.5.39.tar.bz2 /flex-2.5.39.tar.bz2
/flex-2.6.0.tar.bz2 /flex-2.6.0.tar.bz2
/flex-2.6.1.tar.xz /flex-2.6.1.tar.xz
/flex-2.6.4.tar.gz
series series

View File

@ -1,31 +0,0 @@
Index: b/src/flex.skl
===================================================================
--- a/src/flex.skl
+++ b/src/flex.skl
@@ -494,7 +494,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
*/
#define YY_LESS_LINENO(n) \
do { \
- int yyl;\
+ yy_size_t yyl;\
for ( yyl = n; yyl < yyleng; ++yyl )\
if ( yytext[yyl] == '\n' )\
--yylineno;\
@@ -520,7 +520,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
do \
{ \
/* Undo effects of setting up yytext. */ \
- int yyless_macro_arg = (n); \
+ yy_size_t yyless_macro_arg = (n); \
YY_LESS_LINENO(yyless_macro_arg);\
*yy_cp = YY_G(yy_hold_char); \
YY_RESTORE_YY_MORE_OFFSET \
@@ -2576,7 +2576,7 @@ void yyFlexLexer::LexerError( yyconst ch
do \
{ \
/* Undo effects of setting up yytext. */ \
- int yyless_macro_arg = (n); \
+ yy_size_t yyless_macro_arg = (n); \
YY_LESS_LINENO(yyless_macro_arg);\
yytext[yyleng] = YY_G(yy_hold_char); \
YY_G(yy_c_buf_p) = yytext + yyless_macro_arg; \

View File

@ -1,37 +0,0 @@
commit 3946924ed5e77420c453bf841603c7278766093a
Author: rlar <rlar>
Date: Sun Feb 28 15:20:31 2016 +0100
generated code, `max_size' seems to be of type `int', fix casts accordingly
Index: b/src/gen.c
===================================================================
--- a/src/gen.c
+++ b/src/gen.c
@@ -1875,7 +1875,7 @@ void make_tables (void)
if (!C_plus_plus) {
if (use_read) {
outn ("\terrno=0; \\");
- outn ("\twhile ( (result = (int) read( fileno(yyin), buf, max_size )) < 0 ) \\");
+ outn ("\twhile ( (result = (int) read( fileno(yyin), buf, (yy_size_t) max_size )) < 0 ) \\");
outn ("\t{ \\");
outn ("\t\tif( errno != EINTR) \\");
outn ("\t\t{ \\");
@@ -1891,7 +1891,7 @@ void make_tables (void)
outn ("\tif ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \\");
outn ("\t\t{ \\");
outn ("\t\tint c = '*'; \\");
- outn ("\t\tsize_t n; \\");
+ outn ("\t\tint n; \\");
outn ("\t\tfor ( n = 0; n < max_size && \\");
outn ("\t\t\t (c = getc( yyin )) != EOF && c != '\\n'; ++n ) \\");
outn ("\t\t\tbuf[n] = (char) c; \\");
@@ -1904,7 +1904,7 @@ void make_tables (void)
outn ("\telse \\");
outn ("\t\t{ \\");
outn ("\t\terrno=0; \\");
- outn ("\t\twhile ( (result = (int) fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \\");
+ outn ("\t\twhile ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \\");
outn ("\t\t\t{ \\");
outn ("\t\t\tif( errno != EINTR) \\");
outn ("\t\t\t\t{ \\");

View File

@ -1,19 +0,0 @@
commit 986bb5e29492a927a2ad157505c900f75c97016a
Author: rlar <rlar>
Date: Sun Feb 28 15:20:31 2016 +0100
generated code, here `new_size' is of type `int', fix casts accordingly
Index: b/src/flex.skl
===================================================================
--- a/src/flex.skl
+++ b/src/flex.skl
@@ -1782,7 +1782,7 @@ m4_ifdef( [[M4_YY_USES_REJECT]],
/* Extend the array by 50%, plus the number we really need. */
int new_size = YY_G(yy_n_chars) + number_to_move + (YY_G(yy_n_chars) >> 1);
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
- (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, new_size M4_YY_CALL_LAST_ARG );
+ (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()" );
}

39
flex-rh1389575.patch Normal file
View File

@ -0,0 +1,39 @@
This patch fixes a flex-2.6.4 build failure on x86_64 and possibly other
architectures where `size_t' is larger than `int'. The failure occurs as
follows:
A missing `reallocarray' prototype during compilation means that the
compiler assumes an `int' return type. When compiling with `-pie' (standard
for Fedora), addresses on the heap can be larger than `int' can store. Thus,
pointers returned from `reallocarray' are truncated and any read/write to
them leads to a SIGSEGV.
From 24fd0551333e7eded87b64dd36062da3df2f6380 Mon Sep 17 00:00:00 2001
From: Explorer09 <explorer09@gmail.com>
Date: Mon, 4 Sep 2017 10:47:33 +0800
Subject: [PATCH] build: AC_USE_SYSTEM_EXTENSIONS in configure.ac.
This would, e.g. define _GNU_SOURCE in config.h, enabling the
reallocarray() prototype in glibc 2.26+ on Linux systems with that
version of glibc.
Fixes #241.
---
configure.ac | 2 ++
1 file changed, 2 insertions(+)
Index: b/configure.ac
===================================================================
--- a/configure.ac
+++ b/configure.ac
@@ -25,8 +25,10 @@
# autoconf requirements and initialization
AC_INIT([the fast lexical analyser generator],[2.6.4],[flex-help@lists.sourceforge.net],[flex])
+AC_PREREQ([2.60])
AC_CONFIG_SRCDIR([src/scan.l])
AC_CONFIG_AUX_DIR([build-aux])
+AC_USE_SYSTEM_EXTENSIONS
LT_INIT
AM_INIT_AUTOMAKE([1.11.3 -Wno-portability foreign check-news std-options dist-lzip parallel-tests subdir-objects])
AC_CONFIG_HEADER([src/config.h])

View File

@ -1,43 +0,0 @@
commit 33dd868353ab98bc33363d43be5a8b0e7e049072
Author: rlar <rlar>
Date: Sun Feb 28 15:20:31 2016 +0100
generated code, `yy_buf_size' is of type `int', fix casts accordingly
Index: b/src/flex.skl
===================================================================
--- a/src/flex.skl
+++ b/src/flex.skl
@@ -1732,7 +1732,7 @@ m4_ifdef( [[M4_YY_USES_REJECT]],
b->yy_ch_buf = (char *)
/* Include room in for 2 EOB chars. */
yyrealloc( (void *) b->yy_ch_buf,
- b->yy_buf_size + 2 M4_YY_CALL_LAST_ARG );
+ (yy_size_t) (b->yy_buf_size + 2) M4_YY_CALL_LAST_ARG );
}
else
/* Can't grow it, we don't own it. */
@@ -2102,12 +2102,12 @@ static void yy_load_buffer_state YYFARG
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
- b->yy_buf_size = (yy_size_t)size;
+ b->yy_buf_size = size;
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
*/
- b->yy_ch_buf = (char *) yyalloc( b->yy_buf_size + 2 M4_YY_CALL_LAST_ARG );
+ b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) M4_YY_CALL_LAST_ARG );
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
@@ -2397,7 +2397,7 @@ YY_BUFFER_STATE yy_scan_buffer YYFARGS2
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
+ b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
b->yy_buf_pos = b->yy_ch_buf = base;
b->yy_is_our_buffer = 0;
b->yy_input_file = NULL;

View File

@ -1,24 +0,0 @@
commit cf4121fa97abac8aeaa5e08b8fc0b2380228494e
Author: rlar <rlar>
Date: Sat Feb 27 22:46:02 2016 +0100
generated code, `_yybytes_len' is of type `int', fix code accordingly
Index: b/src/flex.skl
===================================================================
--- a/src/flex.skl
+++ b/src/flex.skl
@@ -2451,11 +2451,11 @@ YY_BUFFER_STATE yy_scan_bytes YYFARGS2(
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
- yy_size_t i;
+ int i;
m4_dnl M4_YY_DECL_GUTS_VAR();
/* Get memory for full buffer, including space for trailing EOB's. */
- n = (yy_size_t) _yybytes_len + 2;
+ n = (yy_size_t) (_yybytes_len + 2);
buf = (char *) yyalloc( n M4_YY_CALL_LAST_ARG );
if ( ! buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );

View File

@ -2,8 +2,8 @@
Summary: A tool for creating scanners (text pattern recognizers) Summary: A tool for creating scanners (text pattern recognizers)
Name: flex Name: flex
Version: 2.6.1 Version: 2.6.4
Release: 10%{?dist} Release: 1%{?dist}
# parse.c and parse.h are under GPLv3+ with exception which allows # parse.c and parse.h are under GPLv3+ with exception which allows
# relicensing. Since flex is shipped under BDS-style license, # relicensing. Since flex is shipped under BDS-style license,
# let's assume that the relicensing was done. # let's assume that the relicensing was done.
@ -11,16 +11,12 @@ Release: 10%{?dist}
License: BSD and LGPLv2+ License: BSD and LGPLv2+
Group: Development/Tools Group: Development/Tools
URL: https://github.com/westes/flex URL: https://github.com/westes/flex
Source: https://github.com/westes/flex/releases/download/v%{version}/flex-%{version}.tar.xz Source: https://github.com/westes/flex/releases/download/v%{version}/flex-%{version}.tar.gz
Patch0: flex-2.6.0-yyless.patch Patch0: flex-rh1389575.patch
Patch1: flex-max_size.patch
Patch2: flex-new_size.patch
Patch3: flex-yy_buf_size.patch
Patch4: flex-yybytes_len.patch
Requires: m4 Requires: m4
BuildRequires: gettext bison m4 help2man gcc gcc-c++ BuildRequires: gettext gettext-devel bison m4 help2man gcc gcc-c++ automake libtool
Requires(post): /sbin/install-info Requires(post): /sbin/install-info
Requires(preun): /sbin/install-info Requires(preun): /sbin/install-info
@ -64,12 +60,9 @@ plain text and PDF formats.
%prep %prep
%setup -q %setup -q
%patch0 -p1 %patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%build %build
autoreconf -i
%configure --docdir=%{_pkgdocdir} CFLAGS="-fPIC $RPM_OPT_FLAGS" %configure --docdir=%{_pkgdocdir} CFLAGS="-fPIC $RPM_OPT_FLAGS"
make %{?_smp_mflags} make %{?_smp_mflags}
@ -119,7 +112,7 @@ echo ============END TESTING===========
%dir %{_pkgdocdir} %dir %{_pkgdocdir}
%license COPYING %license COPYING
%{_pkgdocdir}/NEWS %{_pkgdocdir}/NEWS
%{_pkgdocdir}/README %{_pkgdocdir}/README.md
%{_bindir}/* %{_bindir}/*
%{_mandir}/man1/* %{_mandir}/man1/*
%{_includedir}/FlexLexer.h %{_includedir}/FlexLexer.h
@ -134,6 +127,12 @@ echo ============END TESTING===========
%{_pkgdocdir} %{_pkgdocdir}
%changelog %changelog
* Mon Sep 03 2018 Arjun Shankar <arjun@redhat.com> - 2.6.4-1
- Rebase to 2.6.4
- Fix build failure due to missing include and `reallocarray' prototype
- Add gettext-devel, automake and libtool to build dependencies, and
execute `autoreconf -i' to regenerate files after patching configure.ac
* Mon Jul 23 2018 Arjun Shankar <arjun@redhat.com> - 2.6.1-10 * Mon Jul 23 2018 Arjun Shankar <arjun@redhat.com> - 2.6.1-10
- Add gcc-c++ as a build-time requirement - Add gcc-c++ as a build-time requirement

View File

@ -4,7 +4,7 @@ export QUILT_PATCHES=$PWD
# Extract source file name from sources file, # Extract source file name from sources file,
# and assume it's the same name as the directory. # and assume it's the same name as the directory.
source=`awk -F '[() ]+' '/^[A-Z0-9]+ /{print $2}; /^[0-9a-f]+ /{print $2}' sources` source=`awk -F '[() ]+' '/^[A-Z0-9]+ /{print $2}; /^[0-9a-f]+ /{print $2}' sources`
srcdir=${source%.tar.xz} srcdir=${source%.tar.gz}
if [ "$1" == "-f" ] && [ -d "$srcdir" ]; then if [ "$1" == "-f" ] && [ -d "$srcdir" ]; then
echo Cleaning up $srcdir echo Cleaning up $srcdir
rm -rf $srcdir rm -rf $srcdir

View File

@ -1 +1 @@
cd3c86290fc2676a641aefafeb10848a flex-2.6.1.tar.xz SHA512 (flex-2.6.4.tar.gz) = e9785f3d620a204b7d20222888917dc065c2036cae28667065bf7862dfa1b25235095a12fd04efdbd09bfd17d3452e6b9ef953a8c1137862ff671c97132a082e