src/scanner.c

changeset 101
0cb645809b1a
parent 100
e72410a58188
child 102
665b60727a89
equal deleted inserted replaced
100:e72410a58188 101:0cb645809b1a
288 60 - filelist->displayname_len - scnr.spaces, 288 60 - filelist->displayname_len - scnr.spaces,
289 "", "no match"); 289 "", "no match");
290 add_string(output, outbuf); 290 add_string(output, outbuf);
291 } 291 }
292 } else { 292 } else {
293 string_list *recoutput = settings->verbose ? new_string_list() : NULL; 293 string_list *recoutput = NULL;
294 scanresult recresult; 294 scanresult recresult = {0};
295 recresult.ext = result->ext; 295 recresult.ext = result->ext;
296 if (settings->verbose) {
297 recoutput = new_string_list();
298 }
296 scanDirectory( 299 scanDirectory(
297 (scanner) {filelist->filename, scnr.spaces+1}, 300 (scanner) {filelist->filename, scnr.spaces+1},
298 settings, recoutput, &recresult); 301 settings, recoutput, &recresult);
299 result->result += recresult.result; 302 result->result += recresult.result;
300 if (settings->verbose && (!settings->matchesOnly || recresult.result > 0)) { 303 if (settings->verbose &&
304 (!settings->matchesOnly || recresult.result > 0)) {
301 outbuf = malloc(81); 305 outbuf = malloc(81);
302 snprintf(outbuf, 81, "%*s/%*s%13u %s\n", 306 snprintf(outbuf, 81, "%*s/%*s%13u %s\n",
303 filelist->displayname_len+scnr.spaces, filelist->displayname, 307 filelist->displayname_len+scnr.spaces, filelist->displayname,
304 60-filelist->displayname_len-scnr.spaces-1, "", 308 60-filelist->displayname_len-scnr.spaces-1, "",
305 recresult.result, result_type); 309 recresult.result, result_type);
374 } while (!bfile && a != EOF); 378 } while (!bfile && a != EOF);
375 fclose(file); 379 fclose(file);
376 380
377 /* Print and sum line count */ 381 /* Print and sum line count */
378 if (bfile) { 382 if (bfile) {
379 if (!settings->matchesOnly && !settings->dirsOnly && settings->verbose) { 383 if (settings->verbose &&
384 !settings->matchesOnly && !settings->dirsOnly) {
380 outbuf = malloc(81); 385 outbuf = malloc(81);
381 snprintf(outbuf, 81, 386 snprintf(outbuf, 81,
382 "%*s%*s%19s\n", filelist->displayname_len+scnr.spaces, 387 "%*s%*s%19s\n", filelist->displayname_len+scnr.spaces,
383 filelist->displayname, 388 filelist->displayname,
384 60-filelist->displayname_len-scnr.spaces, "", "binary"); 389 60-filelist->displayname_len-scnr.spaces, "", "binary");
385 add_string(output, outbuf); 390 add_string(output, outbuf);
386 } 391 }
387 } else { 392 } else {
388 addResultPerExtension(result->ext, filelist->ext, res_value); 393 addResultPerExtension(result->ext, filelist->ext, res_value);
389 result->result += res_value; 394 result->result += res_value;
390 if (!settings->dirsOnly && settings->verbose) { 395 if (settings->verbose && !settings->dirsOnly) {
391 outbuf = malloc(81); 396 outbuf = malloc(81);
392 snprintf(outbuf, 81, "%*s%*s%13u %s\n", 397 snprintf(outbuf, 81, "%*s%*s%13u %s\n",
393 filelist->displayname_len+scnr.spaces, 398 filelist->displayname_len+scnr.spaces,
394 filelist->displayname, 399 filelist->displayname,
395 60-filelist->displayname_len-scnr.spaces, 400 60-filelist->displayname_len-scnr.spaces,
400 add_string(output, outbuf); 405 add_string(output, outbuf);
401 } 406 }
402 } 407 }
403 } 408 }
404 } else { 409 } else {
405 if (!settings->matchesOnly && !settings->dirsOnly && settings->verbose) { 410 if (settings->verbose &&
411 !settings->matchesOnly && !settings->dirsOnly) {
406 /* Print hint */ 412 /* Print hint */
407 outbuf = malloc(81); 413 outbuf = malloc(81);
408 snprintf(outbuf, 81, "%*s%*s%19s\n", 414 snprintf(outbuf, 81, "%*s%*s%19s\n",
409 filelist->displayname_len+scnr.spaces, filelist->displayname, 415 filelist->displayname_len+scnr.spaces, filelist->displayname,
410 60-filelist->displayname_len-scnr.spaces, "", "no match"); 416 60-filelist->displayname_len-scnr.spaces, "", "no match");

mercurial