summaryrefslogtreecommitdiff
path: root/src/main.c
Commit message (Collapse)AuthorAge
* build: fix ENABLE_NLS preprocessor check.Explorer092017-11-28
| | | | | | | | | Because ENABLE_NLS may be defined to 0 (manually, not through autoconf) and it's semantically incorrect to only check whether it's defined. This is a correction to commit 661d603b65385f62f372acd2017e5af2e0f0cd50.
* build: use #ifdef for ENABLE_NLS check.Alex Richardson2017-11-03
| | | | | | config.h will have either define ENABLE_NLS or not define it. If it is not defined we get a -Wundef warning due to using #if with an undefined macro
* Hardcode flex name in --help textExplorer092017-08-24
| | | | | | | | | | | Don't use program_name in the description of -T/--trace or -V/--version option. It's ugly when user invokes flex with a long path like "/home/username/tools/bin/my-custom-built-flex". This solution is not long term. If possible, the help text should be modified so that the "flex" name is no longer needed below the first "Usage:" line. All translations of help text will need to be updated as well.
* Remove an unneeded gettext() in --version outputExplorer092017-08-24
| | | | "%s %s\n" is not translatable
* scanner: remove BASENAME(); don't strip path from program_nameExplorer092017-08-24
| | | | | | | | | | | | | | | There's no technical need of stripping path from program_name. I think the users should be fine if they see the path they use to invoke flex is diagnostic messages and help texts. Yes, users will see "Usage: ../flex [OPTIONS]..." now if they invoke flex with the path "../flex". The --version output has been changed so that the name field will be always "flex" or "flex++". If the flex program has been renamed to "lex" (for compatibility or other reason) this will allow identifying the implementation name ("flex"). (And it's a recommended practice in GNU Coding Standards)
* scanner: #define BASENAME, remove #include libgen.hJannick2017-07-17
|
* scanner: add optionn to specify backup filename.EricSharkey2017-07-03
| | | | | | In a directory containing multiple scanners, we want to allow specifying the name of the backup file else the backup files will be overwritten.
* scanner: finish support for noyy{get,set}_column.Will Estes2017-05-13
| | | | Unattributed patch carried over from sourceforge bug tracker.
* Don't leak macro definitions into header filesDemi Obenour2017-05-03
| | | | | | | This allowed unnamespaced definitions to leak into header files, breaking client code. Fixes #142
* scanner: manage path to m4 better.Christos Zoulas2017-01-23
| | | | | Avoid alloca() for SSP; it is better anyway; since we don't need to strdup the path.
* scanner: Use prefix when defining yywrap to avoid redefinition.Christos Zoulas2017-01-23
| | | | Fixes regression introduced in v2.6.3.
* scanner: Rename warn to lwarn.Christos Zoulas2017-01-23
| | | | This avoids a naming conflict in NetBSD's libc.
* scanner: Disallow, overquote '[' and ']' in prefixDemi Obenour2016-12-29
|
* scanner: allocate correct buffer size for m4 path.Samuel Thibault2016-12-29
| | | | | | | | 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. Fixes #138
* Improved M4 quotationDemi Obenour2016-10-19
| | | | | | | | | | | This fixes M4 quotation of certain strings beginning with `yy` (in section 3 of the input file only) and character literals. The new quotation method is also less brittle and faster. Tests that relied on the old behavior were fixed. Also, `yyconst` is no longer defined; use `const` (which it unconditionally was defined to) instead.
* Fix M4 quoting of section 3.Demi Obenour2016-10-05
| | | | | | | | | | This fixes M4 quoting of section 3 of the input file, including escape sequences and character constants. Tests were added to verify the behavior in section 3 with respect to quoting. Both escaping of quotes and quoting of potential macro-start characters are tested. Existing tests were also fixed to account for the new -- and now correct -- behavior. Many tests relied on the old behavior of expanding M4 macros in section 3. They needed to be updated for the new behavior.
* no longer generate K&R C scannersDemi Obenour2016-09-25
|
* Fix potential buffer overflow in strncat()Tobias Klauser2016-03-31
| | | | | | | | | | | | | | | 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.
* avoid warning in generated code, with -Cfrlar2016-03-28
| | | | warning: conversion to 'unsigned int' from 'int' may change the sign of the result [-Wsign-conversion]
* cast to get rid of warningsrlar2016-03-08
|
* cast and fix usage of log10(), ceil to prevent buffer overflowrlar2016-03-08
|
* warning: suggest parentheses around assignment used as truth value ↵rlar2016-02-29
| | | | [-Wparentheses]
* warning: redundant redeclaration of ‘yyparse’ [-Wredundant-decls]rlar2016-02-28
|
* Emit no #line directives if gen_line_dirs is false, resolves igh#55.Tobias Klauser2016-02-24
| | | | | | | | 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>
* include libgen.h from flexdef.h, not main.cWill Estes2015-12-27
|
* Replace basename2() with basename(3).Michael Reed2015-12-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Simplify basename2().Michael Reed2015-12-27
| | | | | | 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.
* Remove remaining use of PROTOMichael Reed2015-12-25
|
* Remove more instances of PROTOMichael Reed2015-12-15
|
* Removed prototype for main().Michael Reed2015-12-15
| | | | | | | It's not called anywhere else so the prototype is not needed. See the C99 standard [1], section 5.1.2.2.1 for more info. [1]: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf
* Removed SHORT_FILE_NAMES preprocessor symbol.Michael Reed2015-12-12
| | | | | | | | As a relic of MS-DOS, we don't need this. It's never defined; see 13b5b214f53d1c3354a7ab910bd160c126df1331. Removed additional MSDOS ifdef.
* Made search for m4 more explicit.Will Estes2015-12-12
|
* Removed NULL-checks before free()Michael McConville2015-12-09
|
* Removed flex_alloc; cleaned up style.Michael McConville2015-12-09
| | | | | | | | | | | The function flex_alloc() was just a wrapper around malloc(). Since this only added unclarity, and the flex_alloc() function is likely a legacy of olden times, remove it in favor of calls to malloc() directly. Style elements cleaned up: * superfluous spacing around parentheses * non-constant initialization in variable declarations * needless casts * almost all uses of assignments as subexpressions
* Remove allocation castsMichael McConville2015-12-07
|
* Use NULL rather than (type *) 0.Michael McConville2015-12-05
|
* Replaced FLEX_STD macro with std::.Akim Demaille2015-12-05
| | | | | The std:: construct exists as of C++98, so we can simply assume it is supported.
* Replaced CHAR macro with unsigned char type.Mightyjo2015-11-29
| | | | | | | | Thanks to Michael McConville for pointing out that the old Char macro causes problems with static analysis. The macro has been removed and replaced with 'unsigned char' throughout the flex sources. The macro is not needed at best and was confusing at worst. It was not used in any of the example files nor was it mentioned in the manual at all.
* Switch function definitions from mixed K&R to consistent ANSI C.Stefan Reinauer2015-11-19
| | | | | | | | flex was using K&R function definitions for some functions and ANSI C style in others, sometimes even in the same file. Change the code to consistently use ANSI C. Signed-off-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
* Fix warning about redefined macro when multiple scanners are used.Mariusz Pluciński2014-11-23
|
* NetBSD downstream patches.Christos Zoulas2014-11-11
| | | | | | | | | | | | | | | | const fixes. -Wconversion fixes for the skeleton files. param namespace protection (add _ to inline function parameters). unused variable/code removal. rename warn to lwarn to avoid conflict with <err.h>. ctype.h function argument correction. merged the error functions lerrif and lerrsf -> lerr.
* Add disambiguation braces in main.cMariusz Pluciński2014-07-25
|
* Change output formats from octal to hexadecimalMariusz Pluciński2014-06-26
|
* move flex program sources into src/ directoryWill Estes2014-02-16
The *.[chly] sources are now in the src directory. This implies a bunch of changes in Makefile.am and friends to account for the new location. The .gitignore files are now more local to places where various object files and generated source files occur.