summaryrefslogtreecommitdiff
path: root/src/main.c
Commit message (Collapse)AuthorAge
* 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.