| 197 |
197 |
| 198 while (filelist != NULL) { |
198 while (filelist != NULL) { |
| 199 |
199 |
| 200 /* Scan subdirectories */ |
200 /* Scan subdirectories */ |
| 201 if (!S_ISREG(filelist->st_mode)) { |
201 if (!S_ISREG(filelist->st_mode)) { |
| 202 if (settings->recursive && S_ISDIR(filelist->st_mode)) { |
202 if (S_ISDIR(filelist->st_mode)) { |
| 203 string_list_t *recoutput = new_string_list_t(); |
203 if (settings->recursive) { |
| 204 scanresult_t recresult; |
204 string_list_t *recoutput = new_string_list_t(); |
| 205 recresult.ext = result->ext; |
205 scanresult_t recresult; |
| 206 scanDirectory( |
206 recresult.ext = result->ext; |
| 207 (scanner_t) {filelist->filename, scanner.spaces+1}, |
207 scanDirectory( |
| 208 settings, recoutput, &recresult); |
208 (scanner_t) {filelist->filename, scanner.spaces+1}, |
| 209 result->result += recresult.result; |
209 settings, recoutput, &recresult); |
| 210 if (!settings->matchesOnly || recoutput->count > 0) { |
210 result->result += recresult.result; |
| 211 outbuf = (char*) malloc(81); |
211 if (!settings->matchesOnly || recresult.result > 0) { |
| 212 snprintf(outbuf, 81, "%*s/%*s%13u %s\n", |
212 outbuf = (char*) malloc(81); |
| 213 filelist->displayname_len+scanner.spaces, filelist->displayname, |
213 snprintf(outbuf, 81, "%*s/%*s%13u %s\n", |
| 214 60-filelist->displayname_len-scanner.spaces-1, "", |
214 filelist->displayname_len+scanner.spaces, filelist->displayname, |
| 215 recresult.result, result_type); |
215 60-filelist->displayname_len-scanner.spaces-1, "", |
| 216 add_string(output, outbuf); |
216 recresult.result, result_type); |
| 217 for (unsigned i = 0 ; i < recoutput->count ; i++) { |
217 add_string(output, outbuf); |
| 218 add_string(output, recoutput->items[i]); |
218 for (unsigned i = 0 ; i < recoutput->count ; i++) { |
| |
219 add_string(output, recoutput->items[i]); |
| |
220 } |
| 219 } |
221 } |
| |
222 destroy_string_list_t(recoutput); |
| 220 } |
223 } |
| 221 destroy_string_list_t(recoutput); |
224 } else if (!settings->matchesOnly) { |
| 222 } else { |
|
| 223 outbuf = (char*) malloc(81); |
225 outbuf = (char*) malloc(81); |
| 224 snprintf(outbuf, 81, "%*s\n", |
226 snprintf(outbuf, 81, "%*s\n", |
| 225 filelist->displayname_len+scanner.spaces, |
227 filelist->displayname_len+scanner.spaces, |
| 226 filelist->displayname); |
228 filelist->displayname); |
| 227 add_string(output, outbuf); |
229 add_string(output, outbuf); |
| 286 } while (!bfile && a != EOF); |
288 } while (!bfile && a != EOF); |
| 287 fclose(file); |
289 fclose(file); |
| 288 |
290 |
| 289 /* Print and sum line count */ |
291 /* Print and sum line count */ |
| 290 if (bfile) { |
292 if (bfile) { |
| 291 if (!settings->matchesOnly) { |
293 if (!settings->matchesOnly && !settings->dirsOnly) { |
| 292 outbuf = (char*) malloc(81); |
294 outbuf = (char*) malloc(81); |
| 293 snprintf(outbuf, 81, |
295 snprintf(outbuf, 81, |
| 294 "%*s%*s%19s\n", filelist->displayname_len+scanner.spaces, |
296 "%*s%*s%19s\n", filelist->displayname_len+scanner.spaces, |
| 295 filelist->displayname, |
297 filelist->displayname, |
| 296 60-filelist->displayname_len-scanner.spaces, "", "binary"); |
298 60-filelist->displayname_len-scanner.spaces, "", "binary"); |
| 297 add_string(output, outbuf); |
299 add_string(output, outbuf); |
| 298 } |
300 } |
| 299 } else { |
301 } else { |
| 300 addResultPerExtension(result->ext, filelist->ext, res_value); |
302 addResultPerExtension(result->ext, filelist->ext, res_value); |
| 301 result->result += res_value; |
303 result->result += res_value; |
| 302 outbuf = (char*) malloc(81); |
304 if (!settings->dirsOnly) { |
| 303 snprintf(outbuf, 81, "%*s%*s%13u %s\n", |
305 outbuf = (char*) malloc(81); |
| 304 filelist->displayname_len+scanner.spaces, |
306 snprintf(outbuf, 81, "%*s%*s%13u %s\n", |
| 305 filelist->displayname, |
307 filelist->displayname_len+scanner.spaces, |
| 306 60-filelist->displayname_len-scanner.spaces, |
308 filelist->displayname, |
| 307 "", |
309 60-filelist->displayname_len-scanner.spaces, |
| 308 res_value, |
310 "", |
| 309 result_type |
311 res_value, |
| 310 ); |
312 result_type |
| 311 add_string(output, outbuf); |
313 ); |
| |
314 add_string(output, outbuf); |
| |
315 } |
| 312 } |
316 } |
| 313 } |
317 } |
| 314 } else { |
318 } else { |
| 315 if (!settings->matchesOnly) { |
319 if (!settings->matchesOnly && !settings->dirsOnly) { |
| 316 /* Print hint */ |
320 /* Print hint */ |
| 317 outbuf = (char*) malloc(81); |
321 outbuf = (char*) malloc(81); |
| 318 snprintf(outbuf, 81, "%*s%*s%19s\n", |
322 snprintf(outbuf, 81, "%*s%*s%19s\n", |
| 319 filelist->displayname_len+scanner.spaces, filelist->displayname, |
323 filelist->displayname_len+scanner.spaces, filelist->displayname, |
| 320 60-filelist->displayname_len-scanner.spaces, "", "no match"); |
324 60-filelist->displayname_len-scanner.spaces, "", "no match"); |