]> granicus.if.org Git - flex/log
flex
9 years agowarning in generated code, with -Ca
rlar [Tue, 29 Mar 2016 17:27:54 +0000 (19:27 +0200)]
warning in generated code, with -Ca

warning: conversion to 'yy_state_type' from 'flex_uint32_t' may change the sign of the result [-Wsign-conversion]

9 years agosuppress `WARNINGFLAGS' for the almost obsolete `noansi' test cases
rlar [Tue, 29 Mar 2016 12:00:00 +0000 (14:00 +0200)]
suppress `WARNINGFLAGS' for the almost obsolete `noansi' test cases

9 years agoconfigure option `--enable-warnings' and `WARNINGFLAGS'
rlar [Tue, 29 Mar 2016 11:59:39 +0000 (13:59 +0200)]
configure option `--enable-warnings' and `WARNINGFLAGS'

`WARNINGFLAGS' can be passed when invoking `configure'
 and when invoking `make'

if configure switch `--enable-warnings' was given
  then default to something useful if we have `GCC'

`WARNINGFLAGS' is not used when compiling `stage1flex'
  to avoid unnecessary clutter

9 years agoFix potential buffer overflow in strncat()
Tobias Klauser [Thu, 31 Mar 2016 08:09:57 +0000 (10:09 +0200)]
Fix potential buffer overflow in strncat()

When using clang/llvm 3.8 to compile flex, the following warning is
emitted:

main.c:378:27: warning: the value of the size argument in 'strncat' is too large, might lead to a buffer overflow [-Wstrncat-size]
                                        strncat(m4_path, m4, sizeof(m4_path));
                                                             ^~~~~~~~~~~~~~~
main.c:378:27: note: change the argument to be the free space in the destination buffer minus the terminating null byte
                                        strncat(m4_path, m4, sizeof(m4_path));
                                                             ^~~~~~~~~~~~~~~
                                                             sizeof(m4_path) - strlen(m4_path) - 1

Fix it up by using the solution proposed by the warning message.

9 years agobuild: simplified dependency tracking so parallel make runs succeed
Robert.Larice Robert Larice [Tue, 29 Mar 2016 19:19:00 +0000 (15:19 -0400)]
build: simplified dependency tracking so parallel make runs succeed

9 years agoavoid warning in generated code, with -Cf
rlar [Sun, 20 Mar 2016 19:13:42 +0000 (20:13 +0100)]
avoid warning in generated code, with -Cf

warning: conversion to 'unsigned int' from 'int' may change the sign of the result [-Wsign-conversion]

9 years agomention v2.6.2; summarize changes since 2.6.1
Will Estes [Fri, 18 Mar 2016 19:25:10 +0000 (15:25 -0400)]
mention v2.6.2; summarize changes since 2.6.1

9 years agodoc: corrected example in manual, gh#67
Will Estes [Fri, 18 Mar 2016 19:09:44 +0000 (15:09 -0400)]
doc: corrected example in manual, gh#67

9 years agowarning: conversion to 'size_t' from 'int' may change the sign of the result [-Wsign...
rlar [Wed, 16 Mar 2016 18:47:44 +0000 (19:47 +0100)]
warning: conversion to 'size_t' from 'int' may change the sign of the result [-Wsign-conversion]

9 years agowarning: conversion to 'long unsigned int' from 'int' may change the sign of the...
rlar [Wed, 16 Mar 2016 18:46:14 +0000 (19:46 +0100)]
warning: conversion to 'long unsigned int' from 'int' may change the sign of the result [-Wsign-conversion]

9 years agowarning: conversion to 'flex_uint32_t' from 'long unsigned int' may alter its value...
rlar [Wed, 16 Mar 2016 18:45:56 +0000 (19:45 +0100)]
warning: conversion to 'flex_uint32_t' from 'long unsigned int' may alter its value [-Wconversion]

struct yytbl_reader, member bread is of type flex_uint32_t

9 years agowarning: redundant redeclaration of '...' [-Wredundant-decls]
rlar [Wed, 16 Mar 2016 18:45:41 +0000 (19:45 +0100)]
warning: redundant redeclaration of '...' [-Wredundant-decls]

9 years agowarning: no previous prototype for '...' [-Wmissing-prototypes]
rlar [Wed, 16 Mar 2016 18:45:37 +0000 (19:45 +0100)]
warning: no previous prototype for '...' [-Wmissing-prototypes]

9 years agowarning: unused variable 'fp' [-Wunused-variable]
rlar [Wed, 16 Mar 2016 18:45:22 +0000 (19:45 +0100)]
warning: unused variable 'fp' [-Wunused-variable]

9 years agomain(), warning: redundant redeclaration of 'main' [-Wredundant-decls]
rlar [Wed, 16 Mar 2016 18:45:10 +0000 (19:45 +0100)]
main(), warning: redundant redeclaration of 'main' [-Wredundant-decls]

9 years agomain(), warning: old-style function definition [-Wold-style-definition]
rlar [Wed, 16 Mar 2016 18:44:53 +0000 (19:44 +0100)]
main(), warning: old-style function definition [-Wold-style-definition]

9 years agomain(), warning: old-style function definition [-Wold-style-definition]
rlar [Wed, 16 Mar 2016 18:44:46 +0000 (19:44 +0100)]
main(), warning: old-style function definition [-Wold-style-definition]

9 years agoFix two more casts
rlar [Tue, 1 Mar 2016 19:10:29 +0000 (20:10 +0100)]
Fix two more casts

9 years agoFixes yyl compare with unsigned warning
Bastian Köcher [Mon, 14 Mar 2016 15:48:15 +0000 (16:48 +0100)]
Fixes yyl compare with unsigned warning

9 years agoSuppress portability warnings in Makefile generation
Robert Larice [Sun, 13 Mar 2016 14:55:57 +0000 (10:55 -0400)]
Suppress portability warnings in Makefile generation

9 years agogenerated code, in yyensure_buffer_stack(), change type of local `num_to_alloc'
rlar [Sat, 27 Feb 2016 22:00:14 +0000 (23:00 +0100)]
generated code, in yyensure_buffer_stack(), change type of local `num_to_alloc'

which is exclusively used in yy_size_t context

9 years agogenerated code, in yy_get_next_buffer(), change type of local `number_to_move'
rlar [Tue, 1 Mar 2016 18:36:08 +0000 (19:36 +0100)]
generated code, in yy_get_next_buffer(), change type of local `number_to_move'

suits better, because `yy_n_chars' and `yy_buf_size' are of type `int'

9 years agogenerated code, `_yybytes_len' is of type `int', fix code accordingly
rlar [Sat, 27 Feb 2016 21:46:02 +0000 (22:46 +0100)]
generated code, `_yybytes_len' is of type `int', fix code accordingly

9 years agogenerated code, `max_size' seems to be of type `int', fix casts accordingly
rlar [Sun, 28 Feb 2016 14:20:31 +0000 (15:20 +0100)]
generated code, `max_size' seems to be of type `int', fix casts accordingly

9 years agogenerated code, here `new_size' is of type `int', fix casts accordingly
rlar [Sun, 28 Feb 2016 14:20:31 +0000 (15:20 +0100)]
generated code, here `new_size' is of type `int', fix casts accordingly

9 years agogenerated code, `yy_buf_size' is of type `int', fix casts accordingly
rlar [Sun, 28 Feb 2016 14:20:31 +0000 (15:20 +0100)]
generated code, `yy_buf_size' is of type `int', fix casts accordingly

9 years agogenerated code, `offset' is of type `int'
rlar [Sun, 28 Feb 2016 14:20:31 +0000 (15:20 +0100)]
generated code, `offset' is of type `int'

9 years agogenerated code, `yy_more_len' is of type `int'
rlar [Sun, 28 Feb 2016 14:19:11 +0000 (15:19 +0100)]
generated code, `yy_more_len' is of type `int'

9 years agoscan.l, rewrite two loops to avoid unneccesairy casting
rlar [Sun, 28 Feb 2016 09:36:06 +0000 (10:36 +0100)]
scan.l, rewrite two loops to avoid unneccesairy casting

9 years agoimprove readability
rlar [Tue, 1 Mar 2016 17:22:25 +0000 (18:22 +0100)]
improve readability

9 years agoanother cast in tblcmp.c to avoid warning
rlar [Sun, 28 Feb 2016 13:48:51 +0000 (14:48 +0100)]
another cast in tblcmp.c to avoid warning

9 years agocasts in buf_append() to get rid of warnings
rlar [Sun, 28 Feb 2016 15:23:22 +0000 (16:23 +0100)]
casts in buf_append() to get rid of warnings

9 years agocast to suite type of flex_uint32_t td_lolen
rlar [Sun, 28 Feb 2016 14:58:10 +0000 (15:58 +0100)]
cast to suite type of flex_uint32_t td_lolen

9 years agocast to get rid of warnings
rlar [Sun, 28 Feb 2016 20:12:45 +0000 (21:12 +0100)]
cast to get rid of warnings

9 years agocast and fix usage of log10(), ceil to prevent buffer overflow
rlar [Tue, 1 Mar 2016 16:59:09 +0000 (17:59 +0100)]
cast and fix usage of log10(), ceil to prevent buffer overflow

9 years agotables.c, sprinkle casts to get rid of warnings
rlar [Tue, 1 Mar 2016 16:49:52 +0000 (17:49 +0100)]
tables.c, sprinkle casts to get rid of warnings

9 years agoyytbl_data_compress(), change type of local newsz to get rid of warnings
rlar [Tue, 1 Mar 2016 16:43:44 +0000 (17:43 +0100)]
yytbl_data_compress(), change type of local newsz to get rid of warnings

9 years agochange type of struct yytbl_writer.total_written to get rid of warnings
rlar [Tue, 1 Mar 2016 16:38:16 +0000 (17:38 +0100)]
change type of struct yytbl_writer.total_written to get rid of warnings

9 years agochange argument type of yytbl_writen() to get rid of warnings
rlar [Sun, 28 Feb 2016 19:57:29 +0000 (20:57 +0100)]
change argument type of yytbl_writen() to get rid of warnings

9 years agoyytbl_write8/16/32(), change type of local variables to get rid of warnings
rlar [Tue, 1 Mar 2016 16:31:13 +0000 (17:31 +0100)]
yytbl_write8/16/32(), change type of local variables to get rid of warnings

9 years agochange return type and rename int htoi()/otoi() --> unsigned int htoui()/otoui()
rlar [Sun, 28 Feb 2016 15:49:53 +0000 (16:49 +0100)]
change return type and rename int htoi()/otoi() --> unsigned int htoui()/otoui()

9 years agoMention 2.6.1 release date v2.6.1
Will Estes [Wed, 2 Mar 2016 00:24:24 +0000 (19:24 -0500)]
Mention 2.6.1 release date

9 years agoavoid warning, add (int) cast to the read() return value
rlar [Sun, 28 Feb 2016 18:38:21 +0000 (19:38 +0100)]
avoid warning, add (int) cast to the read() return value

For similiarity with the fread() case.

9 years agoavoid warning, POSIX says yyless() has an `int' argument
rlar [Sun, 28 Feb 2016 09:41:23 +0000 (10:41 +0100)]
avoid warning, POSIX says yyless() has an `int' argument

9 years agouse type size_t in filter_tee_header() to avoid warnings
rlar [Mon, 29 Feb 2016 19:26:18 +0000 (20:26 +0100)]
use type size_t in filter_tee_header() to avoid warnings

9 years agoadd (size_t) casts to malloc invocations to prevent warnings
rlar [Mon, 29 Feb 2016 19:15:29 +0000 (20:15 +0100)]
add (size_t) casts to malloc invocations to prevent warnings

9 years agoadd (int) casts to some strlen() invocations to prevent warnings
rlar [Mon, 29 Feb 2016 18:41:04 +0000 (19:41 +0100)]
add (int) casts to some strlen() invocations to prevent warnings

9 years agondlookup(), char *, to get rid of casts and warnings
rlar [Mon, 29 Feb 2016 17:43:05 +0000 (18:43 +0100)]
ndlookup(), char *, to get rid of casts and warnings

9 years agondinstal(), char *, to get rid of casts and warnings
rlar [Sun, 28 Feb 2016 19:11:49 +0000 (20:11 +0100)]
ndinstal(), char *, to get rid of casts and warnings

9 years agocclinstal() and ccllookup(), char *, to get rid of casts and warnings
rlar [Sun, 28 Feb 2016 19:08:24 +0000 (20:08 +0100)]
cclinstal() and ccllookup(), char *, to get rid of casts and warnings

9 years agowarning: redundant redeclaration of ‘gen_next_state’ [-Wredundant-decls]
rlar [Sun, 28 Feb 2016 14:50:24 +0000 (15:50 +0100)]
warning: redundant redeclaration of ‘gen_next_state’ [-Wredundant-decls]

9 years agowarning: no previous prototype for ‘mkecstbl’ [-Wmissing-prototypes]
rlar [Sun, 28 Feb 2016 14:50:46 +0000 (15:50 +0100)]
warning: no previous prototype for ‘mkecstbl’ [-Wmissing-prototypes]

9 years agowarning: suggest parentheses around assignment used as truth value [-Wparentheses]
rlar [Sun, 28 Feb 2016 15:32:59 +0000 (16:32 +0100)]
warning: suggest parentheses around assignment used as truth value [-Wparentheses]

9 years agowarning: redundant redeclaration of ‘yywrap’ [-Wredundant-decls]
rlar [Sun, 28 Feb 2016 13:21:49 +0000 (14:21 +0100)]
warning: redundant redeclaration of ‘yywrap’ [-Wredundant-decls]

9 years agowarning: redundant redeclaration of ‘yylval’ [-Wredundant-decls]
rlar [Sun, 28 Feb 2016 12:52:26 +0000 (13:52 +0100)]
warning: redundant redeclaration of ‘yylval’ [-Wredundant-decls]

9 years agowarning: redundant redeclaration of ‘yyin’ [-Wredundant-decls]
rlar [Sun, 28 Feb 2016 12:49:44 +0000 (13:49 +0100)]
warning: redundant redeclaration of ‘yyin’ [-Wredundant-decls]

9 years agowarning: redundant redeclaration of ‘yyparse’ [-Wredundant-decls]
rlar [Sun, 28 Feb 2016 13:20:14 +0000 (14:20 +0100)]
warning: redundant redeclaration of ‘yyparse’ [-Wredundant-decls]

9 years agounification, rename some more
rlar [Sun, 28 Feb 2016 13:19:04 +0000 (14:19 +0100)]
unification, rename some more

rename these too for improved similiarity:
  OPTION_OP OPT_HEADER OPT_EXTRA_TYPE OPT_TABLES

9 years agofix name clash, OPT_OUTFILE from parse.y and from options.h
rlar [Sun, 28 Feb 2016 13:17:36 +0000 (14:17 +0100)]
fix name clash, OPT_OUTFILE from parse.y and from options.h

these collide:
  OPT_OUTFILE OPT_PREFIX OPT_YYCLASS
rename them TOK_... in the parser

9 years agoPrototyped reallocarray implementation
Will Estes [Sun, 28 Feb 2016 21:23:19 +0000 (16:23 -0500)]
Prototyped reallocarray implementation

9 years agoRemoved custom strcasecmp() function
Will Estes [Sun, 28 Feb 2016 20:51:57 +0000 (15:51 -0500)]
Removed custom strcasecmp() function

9 years agofwrite wants a size_t, yyleng is int per posix
rlar [Sun, 28 Feb 2016 09:46:37 +0000 (10:46 +0100)]
fwrite wants a size_t, yyleng is int per posix

9 years agoRemove some unneeded casts
rlar [Sun, 28 Feb 2016 10:54:00 +0000 (11:54 +0100)]
Remove some unneeded casts

9 years agowarning: negative integer implicitly converted to unsigned type [-Wsign-conversion]
rlar [Sun, 28 Feb 2016 10:42:41 +0000 (11:42 +0100)]
warning: negative integer implicitly converted to unsigned type [-Wsign-conversion]

9 years agodfa.c:157:24: warning: conversion to 'size_t' from 'int' may change the sign of the...
rlar [Sat, 27 Feb 2016 18:10:48 +0000 (19:10 +0100)]
dfa.c:157:24: warning: conversion to 'size_t' from 'int' may change the sign of the result [-Wsign-conversion]

most certainly safe cast

9 years agoccl.c:86:19: warning: conversion to 'unsigned char' from 'int' may alter its value...
rlar [Sat, 27 Feb 2016 18:08:04 +0000 (19:08 +0100)]
ccl.c:86:19: warning: conversion to 'unsigned char' from 'int' may alter its value [-Wconversion]

ch seems to have been checked for proper range some lines above

9 years agowarning: deprecated directive, use '%pure-parser' [-Wdeprecated]
rlar [Sat, 27 Feb 2016 16:42:52 +0000 (17:42 +0100)]
warning: deprecated directive, use '%pure-parser' [-Wdeprecated]

9 years agowarning: no previous prototype for 'do_nothing' [-Wmissing-prototypes]
rlar [Sat, 27 Feb 2016 16:27:11 +0000 (17:27 +0100)]
warning: no previous prototype for 'do_nothing' [-Wmissing-prototypes]

9 years agoincluded stdlib.h header
rlar [Sat, 27 Feb 2016 15:18:29 +0000 (16:18 +0100)]
included stdlib.h header

9 years agoDescribed more post v2.6.0 changes
Will Estes [Sat, 27 Feb 2016 21:23:11 +0000 (16:23 -0500)]
Described more post v2.6.0 changes

9 years agobuild: Removed bzip2 distribiution archive
Will Estes [Sat, 27 Feb 2016 20:45:34 +0000 (15:45 -0500)]
build: Removed bzip2 distribiution archive

9 years agoremoved obsolete program check
Will Estes [Sat, 27 Feb 2016 20:41:59 +0000 (15:41 -0500)]
removed obsolete program check

9 years agoMade some program checks more robust
Will Estes [Sat, 27 Feb 2016 20:35:33 +0000 (15:35 -0500)]
Made some program checks more robust

9 years agoRemove unneeded cast to int
rlar [Sat, 27 Feb 2016 17:31:33 +0000 (18:31 +0100)]
Remove unneeded cast to int

9 years agoFixed incorrect integer type
Will Estes [Sat, 27 Feb 2016 16:56:05 +0000 (11:56 -0500)]
Fixed incorrect integer type

9 years agoFix more integer types, resolves sf 184, 187
Will Estes [Sat, 27 Feb 2016 14:43:00 +0000 (09:43 -0500)]
Fix more integer types, resolves sf 184, 187

9 years agoRemoved some type conversion warnings
Robert Larice [Sat, 27 Feb 2016 01:23:05 +0000 (20:23 -0500)]
Removed some type conversion warnings

9 years agoChanged another buffer size to int; resolves gh#61
Will Estes [Fri, 26 Feb 2016 19:23:33 +0000 (14:23 -0500)]
Changed another buffer size to int; resolves gh#61

9 years agoChanged type of yy_n_chars to int; gh#53, sf#160.
Will Estes [Thu, 25 Feb 2016 01:11:24 +0000 (20:11 -0500)]
Changed type of yy_n_chars to int; gh#53, sf#160.

The variable yy_n_chars had been of type yy_size_t which is incorrect
given its use in read(). While it might be adviseable to look at
defining a yy_ssize_t, there might be some issues doing this and so, for
now, at least, we'll punt back to int.

9 years agoFixed size of bufferallocation, resolved gh#54.
Will Estes [Wed, 24 Feb 2016 22:50:00 +0000 (17:50 -0500)]
Fixed size of bufferallocation, resolved gh#54.

The value of n_alloc was a count, not a size. Multiplying the value by the element size was incorrect. That multiplication was already being done and having it done twice was incorrect.

9 years agoAllow '%option noline' in flex input file, resolves gh#56.
Tobias Klauser [Tue, 23 Feb 2016 14:39:24 +0000 (15:39 +0100)]
Allow '%option noline' in flex input file, resolves gh#56.

Allow specifying '%option noline' in the input file, leading to the same
effect as calling flex with the command line option --noline.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
9 years agoEmit no #line directives if gen_line_dirs is false, resolves igh#55.
Tobias Klauser [Tue, 23 Feb 2016 14:59:42 +0000 (15:59 +0100)]
Emit no #line directives if gen_line_dirs is false, resolves igh#55.

There are two instances in the code which will print a #line directive
to the resulting lexer, regardless of the value of gen_line_dirs. Fix
them, so they also respect gen_line_dirs.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
9 years agoConverted K&R style function definitions to ANSI C style
Tobias Klauser [Tue, 16 Feb 2016 13:35:34 +0000 (14:35 +0100)]
Converted K&R style function definitions to ANSI C style

Consistently make use of the ANSI C function definition style instead of
the K&R style.

9 years agoUsed NULL constant instead of plain integer for NULL pointer.
Tobias Klauser [Fri, 29 Jan 2016 13:31:54 +0000 (14:31 +0100)]
Used NULL constant instead of plain integer for NULL pointer.

The sparse static checker warns about using plain integer 0 as NULL
pointers in the generated lexer code. Fix this by using NULL
consistently for pointers.

9 years agoMarked declaration and definition of yy_fatal_error as noreturn.
Tobias Klauser [Fri, 29 Jan 2016 13:26:23 +0000 (14:26 +0100)]
Marked declaration and definition of yy_fatal_error as noreturn.

Only the declaration of yy_fatal_error is marked with
__attribute__((__noreturn__)) in case GCC >= 3 is used, but not the
definition. This leads to the sparse static checker to complain about
function declaration mismatch.

Fix it by defining a macro yynoreturn and using it for both the
declaration and the definition of yy_fatal_error.

9 years agoFixed declaration mismatch in yy_fatal_error.
Tobias Klauser [Wed, 27 Jan 2016 12:58:08 +0000 (13:58 +0100)]
Fixed declaration mismatch in yy_fatal_error.

The prototype declares yy_fatal_error parameter as "const char msg[]"
while the definition uses "const char* msg" (introduced by commit
e9d5fc713f61b) which causes the sparse static checkers to produce an
error.

Fix this by adjusting the definition to use "const char* msg" as well.
Also change the C++ version accordingly so it matches the declaration in
FlexLexer.hpp.

9 years agoflex is for flex #NCoC
Will Estes [Sat, 23 Jan 2016 16:43:07 +0000 (11:43 -0500)]
flex is for flex #NCoC

9 years agoReferred to github for issue tracking, no longer sf
Will Estes [Mon, 18 Jan 2016 21:00:04 +0000 (16:00 -0500)]
Referred to github for issue tracking, no longer sf

9 years agoOpened files in binary mode explicitly
Egor Pugin [Sun, 10 Jan 2016 20:43:47 +0000 (15:43 -0500)]
Opened files in binary mode explicitly

9 years agoLinked flex binary against libintl, not libfl.
OBATA Akio [Fri, 8 Jan 2016 20:23:18 +0000 (15:23 -0500)]
Linked flex binary against libintl, not libfl.

Signed-off-by: Thomas Klausner <wiz@NetBSD.org>
9 years agoImproved pipe-stdin hack behavior; resolves sf#198.
Michael van Elst [Fri, 8 Jan 2016 20:07:57 +0000 (15:07 -0500)]
Improved pipe-stdin hack behavior; resolves sf#198.

Signed-off-by: Thomas <Klausner wiz@NetBSD.org>
9 years agoRemoved no longer needed header checks
Will Estes [Sun, 27 Dec 2015 19:05:51 +0000 (14:05 -0500)]
Removed no longer needed header checks

9 years agoChecked for reallocarray() with AC_REPLACE_FUNCS
Will Estes [Sun, 27 Dec 2015 18:57:13 +0000 (13:57 -0500)]
Checked for reallocarray() with AC_REPLACE_FUNCS

9 years agoinclude libgen.h from flexdef.h, not main.c
Will Estes [Sun, 27 Dec 2015 18:46:37 +0000 (13:46 -0500)]
include libgen.h from flexdef.h, not main.c

9 years agoReplace basename2() with basename(3).
Michael Reed [Fri, 25 Dec 2015 19:49:33 +0000 (14:49 -0500)]
Replace basename2() with basename(3).

Given the following program:

\#include <libgen.h>
\#include <stdio.h>

/* extracts basename from path, optionally stripping the extension "\.*"
 * (same concept as /bin/sh `basename`, but different handling of extension). */
static char *basename2 (char *path)
{
char   *b;

for (b = path; *path; path++)
if (*path == '/')
b = path + 1;
return b;
}

static void basename_compare(char *path)
{
printf("basename: %s\n", basename(path));
printf("basename2: %s\n\n", basename2(path));
}

int main (int argc, char *argv[])
{
// From http://pubs.opengroup.org/onlinepubs/9699919799/
// ``Sample Input and Output Strings''
basename_compare("/usr/lib");
basename_compare("/usr/");
basename_compare("/");
basename_compare("///");
basename_compare("//usr//lib//");
return 0;
}

... and the program's output:

basename: lib
basename2: lib

basename: usr
basename2:

basename: /
basename2:

basename: /
basename2:

basename: lib
basename2:

... we can see that basename2() behaves the same as basename(3) in the
average use case, but messes up pretty severely in others.  Besides
that, basename(3) is mandated by POSIX so should be present on modern
Unix-like systems, so we shouldn't define it ourselves.

Some notes:
- it doesn't appear to be mentioned in POSIX, but OpenBSD's basename(3)
  returns NULL if the returned path componenet is > PATH_MAX, so add a
  check for that
- basename(3) shouldn't return an empty string, so remove the
  program_name[0] != '\0' check

9 years agoSimplify basename2().
Michael Reed [Fri, 25 Dec 2015 19:39:18 +0000 (14:39 -0500)]
Simplify basename2().

It's only call site does not activate the `strip_ext` code path, so the
function can be simplified a lot.  While here, remove a double
assignment.

9 years agoCleaned up __STDC__ #ifdefs.
Michael Reed [Fri, 25 Dec 2015 19:15:15 +0000 (14:15 -0500)]
Cleaned up __STDC__ #ifdefs.

Assuming a compiler conforming to the ISO C standard is used, i.e.,
__STDC__ is defined to 1, YY_USE_CONST is always defined and can be
eliminated.

9 years agoRemove remaining use of PROTO
Michael Reed [Fri, 25 Dec 2015 19:01:24 +0000 (14:01 -0500)]
Remove remaining use of PROTO

9 years agobuf.c: use snprintf
Serguey Parkhomovsky [Mon, 21 Dec 2015 22:40:24 +0000 (14:40 -0800)]
buf.c: use snprintf

9 years agobuild: reformatted AC_CHECK_FUNCS for readability
Will Estes [Sat, 19 Dec 2015 21:17:31 +0000 (16:17 -0500)]
build: reformatted AC_CHECK_FUNCS for readability