# HG changeset patch # User Mike Becker # Date 1322755470 -3600 # Node ID 802c5382f499d0e73d2383e9b24c644c99341218 # Parent 778388400f7b0e87b9465261b15bd8305a965ede Added line buffer (and warning message - there is no regexp parser, though) diff -r 778388400f7b -r 802c5382f499 cline.c --- 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); diff -r 778388400f7b -r 802c5382f499 scanner.c --- 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); diff -r 778388400f7b -r 802c5382f499 settings.c --- a/settings.c Fri Oct 21 15:09:26 2011 +0200 +++ b/settings.c Thu Dec 01 17:04:30 2011 +0100 @@ -21,6 +21,7 @@ settings->suffixList = new_string_list_t(); settings->verbose = true; settings->bfileHeuristics = new_bfile_heuristics_t(); + settings->confusing_lnlen = false; } return settings; diff -r 778388400f7b -r 802c5382f499 settings.h --- a/settings.h Fri Oct 21 15:09:26 2011 +0200 +++ b/settings.h Thu Dec 01 17:04:30 2011 +0100 @@ -20,6 +20,7 @@ bool includeSuffixes; bool matchesOnly; bool verbose; + bool confusing_lnlen; /* this flag is set by the scanner */ } settings_t; #ifdef _cplusplus