# HG changeset patch # User Mike Becker # Date 1322755587 -3600 # Node ID 853a1181884baa4bfddcb3da4b9b6a0820824231 # Parent 802c5382f499d0e73d2383e9b24c644c99341218# Parent 3963e8800a1268be93d938c709e2d4be4d0b2d39 Merge with 3963e8800a1268be93d938c709e2d4be4d0b2d39 diff -r 3963e8800a12 -r 853a1181884b cline.c --- a/cline.c Sun Nov 06 20:12:55 2011 +0100 +++ b/cline.c Thu Dec 01 17:06:27 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 3963e8800a12 -r 853a1181884b scanner.c --- a/scanner.c Sun Nov 06 20:12:55 2011 +0100 +++ b/scanner.c Thu Dec 01 17:06:27 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 3963e8800a12 -r 853a1181884b settings.c --- a/settings.c Sun Nov 06 20:12:55 2011 +0100 +++ b/settings.c Thu Dec 01 17:06:27 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 3963e8800a12 -r 853a1181884b settings.h --- a/settings.h Sun Nov 06 20:12:55 2011 +0100 +++ b/settings.h Thu Dec 01 17:06:27 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