shell/match.c: shrink by dropping double bool inversion
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
This commit is contained in:
parent
acd5bc8f64
commit
2d8187c139
@ -27,8 +27,6 @@
|
|||||||
#include <fnmatch.h>
|
#include <fnmatch.h>
|
||||||
#include "match.h"
|
#include "match.h"
|
||||||
|
|
||||||
#define pmatch(a, b) !fnmatch((a), (b), 0)
|
|
||||||
|
|
||||||
char* FAST_FUNC scan_and_match(char *string, const char *pattern, unsigned flags)
|
char* FAST_FUNC scan_and_match(char *string, const char *pattern, unsigned flags)
|
||||||
{
|
{
|
||||||
char *loc;
|
char *loc;
|
||||||
@ -67,17 +65,17 @@ char* FAST_FUNC scan_and_match(char *string, const char *pattern, unsigned flags
|
|||||||
|
|
||||||
while (loc != end) {
|
while (loc != end) {
|
||||||
char c;
|
char c;
|
||||||
int match;
|
int r;
|
||||||
|
|
||||||
c = *loc;
|
c = *loc;
|
||||||
if (flags & SCAN_MATCH_LEFT_HALF) {
|
if (flags & SCAN_MATCH_LEFT_HALF) {
|
||||||
*loc = '\0';
|
*loc = '\0';
|
||||||
match = pmatch(pattern, string);
|
r = fnmatch(pattern, string, 0);
|
||||||
*loc = c;
|
*loc = c;
|
||||||
} else {
|
} else {
|
||||||
match = pmatch(pattern, loc);
|
r = fnmatch(pattern, loc, 0);
|
||||||
}
|
}
|
||||||
if (match)
|
if (r == 0) /* match found */
|
||||||
return loc;
|
return loc;
|
||||||
if (early_exit) {
|
if (early_exit) {
|
||||||
#ifdef STANDALONE
|
#ifdef STANDALONE
|
||||||
|
Loading…
Reference in New Issue
Block a user