Thu, 01 Dec 2011 17:04:30 +0100
Added line buffer (and warning message - there is no regexp parser, though)
cline.c | file | annotate | diff | comparison | revisions | |
scanner.c | file | annotate | diff | comparison | revisions | |
settings.c | file | annotate | diff | comparison | revisions | |
settings.h | file | annotate | diff | comparison | revisions |
--- a/cline.c Fri Oct 21 15:09:26 2011 +0200 +++ b/cline.c Thu Dec 01 17:04:30 2011 +0100 @@ -163,6 +163,13 @@ } printf("\n%73d lines\n", lines); + if (settings->confusing_lnlen) { + /* TODO: display this only when the regexp parser is used */ + printf("\nSome files contain too long lines.\n" + "The regexp parser currently supports a maximum line length of 2048." + "\nThe result might be wrong.\n"); + } + if (!settings->verbose) { reopen_stdout(); printf("%d", lines);
--- a/scanner.c Fri Oct 21 15:09:26 2011 +0200 +++ b/scanner.c Thu Dec 01 17:04:30 2011 +0100 @@ -56,11 +56,14 @@ continue; } - /* Count lines */ - lines = 0; - bfile = false; - bfile_reset(settings->bfileHeuristics); if (testSuffix(filename, settings)) { + /* Count lines */ + lines = 0; + bfile = false; + bfile_reset(settings->bfileHeuristics); + char line_buffer[2048]; + int line_buffer_offset = 0; + FILE *file = fopen(filename, "r"); if (file == NULL) { printf(entryname); @@ -74,7 +77,19 @@ bfile = bfile_check(settings->bfileHeuristics, a); if (a == 10) { + line_buffer[line_buffer_offset] = 0; + /* TODO: do regex parsing */ + + line_buffer_offset = 0; lines++; + } else { + if (line_buffer_offset < 2048) { + line_buffer[line_buffer_offset] = a; + line_buffer_offset++; + } else { + line_buffer[line_buffer_offset-1] = 0; + settings->confusing_lnlen = true; + } } } while (!bfile && a != EOF); fclose(file);