Index: asterisk.c =================================================================== --- asterisk.c (revision 7717) +++ asterisk.c (working copy) @@ -271,7 +271,6 @@ struct file_version *iterator; regex_t regexbuf; int havepattern = 0; - int havename = 0; int count_files = 0; switch (argc) { @@ -284,7 +283,6 @@ return RESULT_SHOWUSAGE; break; case 4: - havename = 1; break; case 3: break; @@ -296,25 +294,26 @@ ast_cli(fd, FORMAT, "----", "--------"); AST_LIST_LOCK(&file_versions); AST_LIST_TRAVERSE(&file_versions, iterator, list) { - if (havename && strcasecmp(iterator->file, argv[3])) - continue; - - if (havepattern && regexec(®exbuf, iterator->file, 0, NULL, 0)) - continue; - - ast_cli(fd, FORMAT, iterator->file, iterator->version); - count_files++; - if (havename) - break; + if(havepattern) { + if (!regexec(®exbuf, iterator->file, 0, NULL, 0)) { + ast_cli(fd, FORMAT, iterator->file, iterator->version); + count_files++; + } + } else { + if (!strcasecmp(iterator->file, argv[3])) { + ast_cli(fd, FORMAT, iterator->file, iterator->version); + count_files++; + break; + } + } } AST_LIST_UNLOCK(&file_versions); - if (!havename) { - ast_cli(fd, "%d files listed.\n", count_files); + if (havepattern) { + if (count_files > 1) + ast_cli(fd, "%d files listed.\n", count_files); + regfree(®exbuf); } - if (havepattern) - regfree(®exbuf); - return RESULT_SUCCESS; #undef FORMAT }