Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changes between Version 2 and Version 3 of LinesOfCodeExample

Show
Ignore:
Author:
jcc7 (IP: 192.149.244.9)
Timestamp:
12/12/06 17:25:30 (17 years ago)
Comment:

added work-around for "&callback" issue and removed tabs

Legend:

Unmodified
Added
Removed
Modified
  • LinesOfCodeExample

    v2 v3  
    3232    char[] outputFileStr; 
    3333 
    34        if(args.length < 3) 
    35        
    36                writefln("Usage: " ~ pgmName ~ " pattern input_path output_file"); 
    37                return 0; 
    38        
    39        else 
    40        
    41                patternStr = args[1]; 
    42                pathStr = args[2]; 
    43                outputFileStr = args[3]; 
    44        
    45          
     34    if(args.length < 3) 
     35   
     36        writefln("Usage: " ~ pgmName ~ " pattern input_path output_file"); 
     37        return 0; 
     38   
     39    else 
     40   
     41        patternStr = args[1]; 
     42        pathStr = args[2]; 
     43        outputFileStr = args[3]; 
     44   
     45 
    4646    int n = listdirfn(pathStr, patternStr); 
    4747 
    5959    int n; 
    6060 
    61        File fl; 
     61    File fl; 
    6262 
    6363    bool callback(DirEntry* de) 
    6464    { 
    6565        if (de.isdir) 
    66             std.file.listdir(de.name, &callback); 
     66            std.file.listdir(de.name, & callback); 
    6767        else 
    6868        {   if (r.test(de.name)) 
    69                        
    70                                writefln("%s", de.name); 
     69           
     70                writefln("%s", de.name); 
    7171                n++; 
    7272 
    73                                fl = new File(de.name); 
    74                                int cntLn = 0; 
     73                fl = new File(de.name); 
     74                int cntLn = 0; 
    7575 
    76                                while (!fl.eof()) 
    77                                
    78                                        char[] line = strip(fl.readLine()); 
    79                                        if(line != "") /* don't count empty lines */ 
    80                                                 cntLn++;                                         
    81                                
    82                                 fl.close();                              
    83                                outputData ~= `"` ~ de.name ~ `","` ~ toString(cntLn) ~ `"` ~ \r\n; 
    84                        
    85                
     76                while (!fl.eof()) 
     77               
     78                    char[] line = strip(fl.readLine()); 
     79                    if(line != "") /* don't count empty lines */ 
     80                        cntLn++;                     
     81               
     82                fl.close();                  
     83                outputData ~= `"` ~ de.name ~ `","` ~ toString(cntLn) ~ `"` ~ \r\n; 
     84           
     85       
    8686        return true; // continue 
    8787    } 
    8888 
    89     std.file.listdir(pathname, &callback); 
     89    std.file.listdir(pathname, & callback); 
    9090    return n; 
    9191} 
    92  
    9392}}} 
    9493