scanner.c

changeset 27
95a958e3de88
parent 25
802c5382f499
child 28
72a98cbcb9f1
equal deleted inserted replaced
26:853a1181884b 27:95a958e3de88
7 7
8 8
9 #include "scanner.h" 9 #include "scanner.h"
10 #include "suffix_fnc.h" 10 #include "suffix_fnc.h"
11 #include "bfile_heuristics.h" 11 #include "bfile_heuristics.h"
12 #include "regex_parser.h"
12 #include <sys/stat.h> 13 #include <sys/stat.h>
13 14
14 int scanDirectory(scanner_t scanner, settings_t* settings) { 15 int scanDirectory(scanner_t scanner, settings_t* settings) {
15 16
16 DIR *dirf; 17 DIR *dirf;
59 if (testSuffix(filename, settings)) { 60 if (testSuffix(filename, settings)) {
60 /* Count lines */ 61 /* Count lines */
61 lines = 0; 62 lines = 0;
62 bfile = false; 63 bfile = false;
63 bfile_reset(settings->bfileHeuristics); 64 bfile_reset(settings->bfileHeuristics);
64 char line_buffer[2048]; 65 char line_buffer[REGEX_MAX_LINELENGTH];
65 int line_buffer_offset = 0; 66 int line_buffer_offset = 0;
66 67
67 FILE *file = fopen(filename, "r"); 68 FILE *file = fopen(filename, "r");
68 if (file == NULL) { 69 if (file == NULL) {
69 printf(entryname); 70 printf(entryname);
81 /* TODO: do regex parsing */ 82 /* TODO: do regex parsing */
82 83
83 line_buffer_offset = 0; 84 line_buffer_offset = 0;
84 lines++; 85 lines++;
85 } else { 86 } else {
86 if (line_buffer_offset < 2048) { 87 if (line_buffer_offset < REGEX_MAX_LINELENGTH) {
87 line_buffer[line_buffer_offset] = a; 88 line_buffer[line_buffer_offset] = a;
88 line_buffer_offset++; 89 line_buffer_offset++;
89 } else { 90 } else {
90 line_buffer[line_buffer_offset-1] = 0; 91 line_buffer[line_buffer_offset-1] = 0;
91 settings->confusing_lnlen = true; 92 settings->confusing_lnlen = true;

mercurial