scanner.c

changeset 14
ee9333c91dda
parent 10
ecf787666f44
child 16
bc9a0fefd892
     1.1 --- a/scanner.c	Fri Sep 16 09:59:20 2011 +0200
     1.2 +++ b/scanner.c	Fri Sep 16 10:36:45 2011 +0200
     1.3 @@ -27,15 +27,16 @@
     1.4        entryname[spaces] = 0;
     1.5        strcat(entryname, entry->d_name);
     1.6    
     1.7 +      char filename[(1+strlen(currdir)+strlen(entry->d_name))];
     1.8 +      strcpy(filename, currdir);
     1.9 +      strncat(filename, &settings->fileSeparator, 1);
    1.10 +      strcat(filename, entry->d_name);
    1.11 +
    1.12        // Check for subdirectory
    1.13 -      char subdirname[(1+strlen(currdir)+strlen(entry->d_name))];
    1.14 -      strcpy(subdirname, currdir);
    1.15 -      strncat(subdirname, &settings->fileSeparator, 1);
    1.16 -      strcat(subdirname, entry->d_name);
    1.17 -      if ((subdir = opendir(subdirname)) != NULL) {
    1.18 +      if ((subdir = opendir(filename)) != NULL) {
    1.19          printf("%-60s\n", entryname);
    1.20          if (settings->recursive) {
    1.21 -          lineSum += scanDirectory(subdir, spaces+1, subdirname, settings);
    1.22 +          lineSum += scanDirectory(subdir, spaces+1, filename, settings);
    1.23          }
    1.24          closedir(subdir);
    1.25          continue;
    1.26 @@ -43,10 +44,10 @@
    1.27  
    1.28        // Count lines
    1.29        lines = 0;
    1.30 -      char filename[(1+strlen(currdir)+strlen(entry->d_name))];
    1.31 +      /* char filename[(1+strlen(currdir)+strlen(entry->d_name))];
    1.32        strcpy(filename, currdir);
    1.33        strncat(filename, &settings->fileSeparator, 1);
    1.34 -      strcat(filename, entry->d_name);
    1.35 +      strcat(filename, entry->d_name); */
    1.36        if (testSuffix(filename, settings)) {
    1.37          FILE *file = fopen(filename, "r");
    1.38          if (file == NULL) {

mercurial