Thomas Klausner [Fri, 19 May 2017 08:22:44 +0000 (10:22 +0200)]
scanner: Use reallocarr() when available.
NetBSD had a crash during build. Since the provided substitute for
reallocarray() wasn't working, use NetBSD's reallocarr(). Let
configure choose that function whenever it is available. Use
reallocarray if available. Still fallback if neither is available.
Jeff Smith [Sat, 1 Apr 2017 06:18:12 +0000 (01:18 -0500)]
filter: Output correct #line value for current file.
A #line pre-processor directive specifies the line number and source
file of the following lines. If the source file _is_ the current file,
the line number should be that of the line following the directive. So
the specified line number should be the current line number plus 1.
test: rename some files for non-case-sensitive filesystems.
-C*f and -C*F option-specific test files collide on case-insensitive
file systems, and cause tests to either not be run at all, or to
overwrite each other's files at build time. So rename -C*F ones to
-C*_F.
Explorer09 [Wed, 3 May 2017 03:48:06 +0000 (11:48 +0800)]
build: do not generate lib/Makefile.in.
Files in lib/ are picked up and built using makefile directives in
src/Makefile.am. Remove the need to generate lib/Makefile.in and the
stub lib/Makefile.am.
* Don't call isascii() here. It's deprecated in POSIX and not needed
for myesc's case.
* The check of the character class and range here should match what's
defined as {ESCSEQ} in scan.l, so for [[:xdigit:]] we use isxdigit();
for [0-7] we check '0' <= c <= '7' (not isdigit(c) because isdigit is
locale-dependant in standard's sense)
* Add missing length limit for "\x<hex>" (<hex> is at most 2 digits)
Simon Sobisch [Tue, 2 May 2017 15:26:07 +0000 (17:26 +0200)]
gettext: more recent makevars; new script to update po files.
Previously, "make dist" and similar commands would cause the po files
to be updated, which is incorrect. The more recent version now used
should not do this.
Replaced Rules-getpo by extra script to manually update and rebuild all po files.
Simon Sobisch [Tue, 2 May 2017 15:15:45 +0000 (17:15 +0200)]
gettext: list generated files instead of flex, bison sources in POTFILES.in.
Listing the flex and bison sources -- as the gettext manual suggests
-- causes warnings. Listing the generated C files for the lexer and
parser removes the warnings. Since both files contain line directives,
any translator who needs to refer back to those files should be able
to find the context in which strings are needed.
Simon Sobisch [Tue, 2 May 2017 10:04:00 +0000 (12:04 +0200)]
build: check for how to call libtoolize.
Previously, we would call libtoolize and if that failed, we would call
glibtoolize since some platforms have the libtoolize program under
that name.
Instead, we check to see if the environment variable LIBTOOLIZE is set
and use that if so. Otherwise, we try to find a program "libtoolize"
on the path and failing that glibtoolize. We alert the user if no
suitable program can be found.
Alastair Hughes [Fri, 6 Jan 2017 06:06:03 +0000 (19:06 +1300)]
build: support cross compiling.
Check for cross compiling. If cross compiling, build stage1flex using a
custom link command.
We also override LDADD since that adds the replacement implementations
that are cross compiled, and instead always use the replacement library
implementations.
We don't use BUILD_OBJEXT and BUILD_EXEEXT since it seems that automake
does not support these.
Explorer09 [Fri, 17 Feb 2017 15:19:10 +0000 (23:19 +0800)]
build: Include <strings.h>; add strcasecmp() check to configure.
strings.h (not string.h) is the standard-defined include header for
strcasecmp(). Include <strings.h> for portability (even though glibc
exposes strcasecmp() declaration also in <string.h> by default).
Explorer09 [Sun, 12 Feb 2017 11:59:52 +0000 (19:59 +0800)]
scanner: compute powers of two faster.
Replace the naive "for" loop in determining power of two with a clever
bitwise solution. This code is around the Internet already and is in
Public Domain.
Explorer09 [Tue, 7 Feb 2017 13:14:04 +0000 (21:14 +0800)]
test: skip pthread test when needed files missing.
"Unlisting" the pthread test when libpthread is not available is never
a good idea. Should let it compile into a stub program that returns
the "skip" status.
configure.ac and tests/Makefile.am are edited so that pthread test can
be built anyway, but only works (not as the stub) when both pthread.h
and libpthread are detected on the system.
Also fix a small typo in tests/pthread.l comments.
Will Estes [Thu, 16 Feb 2017 14:27:22 +0000 (09:27 -0500)]
build: mv scan.c when building dist.
Revert change to copy scan.c when building the distribution
archive. Move it instead. This satisfies automake's notions of what
should be clean and ensures that the distribution archive contains a
just-built copy of scan.c.
Explorer09 [Tue, 3 Jan 2017 12:44:17 +0000 (20:44 +0800)]
build: remove repeated bison detection from configure.
AC_PROG_YACC already detects the bison program. We can just use it,
and make notice if [ $YACC != 'bison -y' ]
Remove unused AC_SUBST([BISON], ...).
Add AM_CONDITIONAL([HAVE_BISON], ...) so that we can skip bison tests
in testsuite when bison is absent.
We don't make any attempt to detect other yacc implementations since
flex is developed with bison. While it would be possible, the need
isn't there right now. It would be possible to add a --with-parser
option that defaulted to bison if such a need cropped up.
Explorer09 [Sun, 1 Jan 2017 07:41:29 +0000 (15:41 +0800)]
build: fix Makefile parse.h dependency clauses.
The current clauses stating "main.c: parse.h" and "yylex.c: parse.h" do
not work as expected. Make did not try to build parse.h upon building
flex-main.o as it would think main.c exist already and ignore the
clause. Fix this by explicitly stating that the .o files depend on
parse.h instead.
This dependency bug only happens if user builds flex from a
checked-out repository.
Explorer09 [Tue, 3 Jan 2017 12:42:49 +0000 (20:42 +0800)]
test: Remake *_scanner.c if *_scanner.h is missing.
If a ${foo}_scanner.c exists but the respective ${foo}_scanner.h is
missing, then 'make' can halt. Fix this by deleting the
${foo}_scanner.c file and then remake it. This rule is the same as the
automake-generated rule for .c files that require LEX or YACC (except
automake will use ylwrap).
Without BUILT_SOURCES in Makefile, no test sources in tests/ will be
built when using the default "make all" target. This is desireable for
people who are just building flex but who do not want to run, and
therefore, build any part of the test suite.
Explorer09 [Thu, 19 Jan 2017 08:04:13 +0000 (16:04 +0800)]
build: detect overflow for [re]allocate_array.
Use reallocarray() when we have it (i.e. in OpenBSD system). When we
don't, use equivalent overflow detection for our allocate_array and
reallocate_array functions.
Remove lib/reallocarray.c from our LIBOBJS as we no longer need it.
Provide a fallback SIZE_MAX macro definition in flexint.h (not
preprocessor friendly, but enough for our reallocate_array use case).
Thomas Klausner [Mon, 23 Jan 2017 07:46:48 +0000 (08:46 +0100)]
build: more BSD make and vpath build fixes.
BSD make doesn't like $< with more than one source
specified. Additionally, make sure to specify srcdir when referring to
source files since vpath builds depend on this.
Explorer09 [Tue, 3 Jan 2017 13:00:15 +0000 (21:00 +0800)]
test: let testwrapper scripts be run by ${SHELL}.
This allows user to use a different shell if /bin/sh has problems.
The use of $SHELL (variable) to run scripts is already an Automake
convention. All shell scripts in build-aux are run by $SHELL.
Explorer09 [Sun, 1 Jan 2017 16:43:50 +0000 (00:43 +0800)]
test: exit on '-1' test non-zero status.
If a '-1' test program returns a non-zero status, don't go further and
compare it's (numeric) output values. This allows a '-1' test to
indicate a "skip" status or an otherwise error. (Currently no such '-1'
test would skip like this, though.)
Shell syntax note: `set -e` will not exit with the syntax like this
`test $(false) = $(false);`. The exit statuses of `false` in the
example will be ignored instead. But putting the output in a variable,
such as `VAR=$(false)`, DOES exit.
Explorer09 [Sun, 1 Jan 2017 16:38:37 +0000 (00:38 +0800)]
build: Fix 'make indent' target
This 'make indent' target has not been working since the directories
reorganization in flex 2.6.0. Now make it work again.
Note that the current indent profile breaks many styles of existing
code. The indent target should not be used until the .indent.pro
options are reviewed for desireability.
Tobias Klauser [Thu, 12 Jan 2017 09:49:32 +0000 (10:49 +0100)]
filter: Don't emit #line if %option noline set
One place emitting a #line directive to the generated header was
missed in commit 647a92b9f4 when resolving #55. Fix it to respect
gen_line_dirs as well.
Harald van Dijk [Tue, 10 Jan 2017 21:37:49 +0000 (22:37 +0100)]
c++: Fix yyrestart(NULL) SEGV.
Binding a reference to a dereferenced null pointer is invalid and
compilers optimise away the &file == 0 check. We need a real stream.
yyin is available already, and yyrestart(NULL) is only supported when
yyin will not be used, so there is no harm in just passing in that.
Since we now always have a valid stream, we can skip the null check
too.
Explorer09 [Sat, 26 Nov 2016 15:47:12 +0000 (23:47 +0800)]
build: New configure option '--disable-bootstrap'.
If configure is run with '--disable-bootstrap', then stage1flex won't
be built and stage1scan.c will be generated by sed'ing scan.c.
This option is intended to workaround bootstrap bugs rather than to
fix the bootstrapping issues which are proving subtler and harder to
fix than anyone would like.
Explorer09 [Sat, 26 Nov 2016 09:21:25 +0000 (17:21 +0800)]
build: allow building libfl even with --disable-libfl.
For various reasons, we may wish to build libfl explicitly even when
configure has been run with the --disable-libfl option. This is
possible, now, via 'make -C src libfl.la'.
Samuel Thibault [Thu, 29 Dec 2016 13:44:22 +0000 (08:44 -0500)]
scanner: allocate correct buffer size for m4 path.
Flex did not check the length of the m4 path which could lead to a
buffer overflow in some cases. Additionally, not all platforms believe
in PATH_MAX, so stop relying on it.
Explorer09 [Fri, 18 Nov 2016 18:37:04 +0000 (02:37 +0800)]
build: Link $(LIBOBJS) from src/ dir, remove libcompat.la.
The libcompat.la library was small and less friendly to bootstrapping
and cross compilation. Now, we will simply link individual object
files as needed, which is simpler.
Alastair Hughes [Thu, 27 Oct 2016 22:19:31 +0000 (11:19 +1300)]
build: fix false negatives for help2man and texi2dvi
HELP2MAN and TEXI2DVI (or the corresponding ac_prog variables) will
never be zero length as they fall back to the missing script; check for
the fall back and warn on that instead of always warning.