scanner.c

changeset 22
4508da679ffb
parent 21
91e0890464b0
child 23
778388400f7b
--- a/scanner.c	Thu Oct 20 15:21:53 2011 +0200
+++ b/scanner.c	Thu Oct 20 17:29:23 2011 +0200
@@ -20,7 +20,7 @@
 
   while ((entry = readdir(dir)) != NULL) {
     if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) {
-      // Print occurence
+      /* Print occurence */
       char entryname[strlen(entry->d_name)+spaces];
       for (int t = 0 ; t < spaces ; t++) {
         entryname[t]=' ';
@@ -33,7 +33,7 @@
       strncat(filename, &settings->fileSeparator, 1);
       strcat(filename, entry->d_name);
 
-      // Check for subdirectory
+      /* Check for subdirectory */
       if ((subdir = opendir(filename)) != NULL) {
         printf("%-60s\n", entryname);
         if (settings->recursive) {
@@ -43,9 +43,10 @@
         continue;
       }
 
-      // Count lines
+      /* Count lines */
       lines = 0;
       bfile = false;
+      bfile_reset(settings->bfileHeuristics);
       if (testSuffix(filename, settings)) {
         FILE *file = fopen(filename, "r");
         if (file == NULL) {
@@ -64,16 +65,18 @@
         } while (!bfile && a != EOF);
         fclose(file);
 
-        // Print line count
+        /* Print and sum line count */
         if (bfile) {
-          printf("%-60s%19s\n", entryname, "binary");
+          if (!settings->matchesOnly) {
+            printf("%-60s%19s\n", entryname, "binary");
+          }
         } else {
+          lineSum += lines;
           printf("%-60s%13d lines\n", entryname, lines);
         }
-        lineSum += lines;
       } else {
         if (!settings->matchesOnly) {
-          // Print hint
+          /* Print hint */
           printf("%-60s%19s\n", entryname, "no match");
         }
       }

mercurial