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 |
1.1 --- a/cline.c Fri Oct 21 15:09:26 2011 +0200 1.2 +++ b/cline.c Thu Dec 01 17:04:30 2011 +0100 1.3 @@ -163,6 +163,13 @@ 1.4 } 1.5 printf("\n%73d lines\n", lines); 1.6 1.7 + if (settings->confusing_lnlen) { 1.8 + /* TODO: display this only when the regexp parser is used */ 1.9 + printf("\nSome files contain too long lines.\n" 1.10 + "The regexp parser currently supports a maximum line length of 2048." 1.11 + "\nThe result might be wrong.\n"); 1.12 + } 1.13 + 1.14 if (!settings->verbose) { 1.15 reopen_stdout(); 1.16 printf("%d", lines);
2.1 --- a/scanner.c Fri Oct 21 15:09:26 2011 +0200 2.2 +++ b/scanner.c Thu Dec 01 17:04:30 2011 +0100 2.3 @@ -56,11 +56,14 @@ 2.4 continue; 2.5 } 2.6 2.7 - /* Count lines */ 2.8 - lines = 0; 2.9 - bfile = false; 2.10 - bfile_reset(settings->bfileHeuristics); 2.11 if (testSuffix(filename, settings)) { 2.12 + /* Count lines */ 2.13 + lines = 0; 2.14 + bfile = false; 2.15 + bfile_reset(settings->bfileHeuristics); 2.16 + char line_buffer[2048]; 2.17 + int line_buffer_offset = 0; 2.18 + 2.19 FILE *file = fopen(filename, "r"); 2.20 if (file == NULL) { 2.21 printf(entryname); 2.22 @@ -74,7 +77,19 @@ 2.23 bfile = bfile_check(settings->bfileHeuristics, a); 2.24 2.25 if (a == 10) { 2.26 + line_buffer[line_buffer_offset] = 0; 2.27 + /* TODO: do regex parsing */ 2.28 + 2.29 + line_buffer_offset = 0; 2.30 lines++; 2.31 + } else { 2.32 + if (line_buffer_offset < 2048) { 2.33 + line_buffer[line_buffer_offset] = a; 2.34 + line_buffer_offset++; 2.35 + } else { 2.36 + line_buffer[line_buffer_offset-1] = 0; 2.37 + settings->confusing_lnlen = true; 2.38 + } 2.39 } 2.40 } while (!bfile && a != EOF); 2.41 fclose(file);
3.1 --- a/settings.c Fri Oct 21 15:09:26 2011 +0200 3.2 +++ b/settings.c Thu Dec 01 17:04:30 2011 +0100 3.3 @@ -21,6 +21,7 @@ 3.4 settings->suffixList = new_string_list_t(); 3.5 settings->verbose = true; 3.6 settings->bfileHeuristics = new_bfile_heuristics_t(); 3.7 + settings->confusing_lnlen = false; 3.8 } 3.9 3.10 return settings;
4.1 --- a/settings.h Fri Oct 21 15:09:26 2011 +0200 4.2 +++ b/settings.h Thu Dec 01 17:04:30 2011 +0100 4.3 @@ -20,6 +20,7 @@ 4.4 bool includeSuffixes; 4.5 bool matchesOnly; 4.6 bool verbose; 4.7 + bool confusing_lnlen; /* this flag is set by the scanner */ 4.8 } settings_t; 4.9 4.10 #ifdef _cplusplus