Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/grep/grep.c
Show First 20 Lines • Show All 718 Lines • ▼ Show 20 Lines | #endif | ||||
switch (grepbehave) { | switch (grepbehave) { | ||||
case GREP_BASIC: | case GREP_BASIC: | ||||
break; | break; | ||||
case GREP_FIXED: | case GREP_FIXED: | ||||
#if defined(REG_NOSPEC) | #if defined(REG_NOSPEC) | ||||
cflags |= REG_NOSPEC; | cflags |= REG_NOSPEC; | ||||
#elif defined(REG_LITERAL) | #elif defined(REG_LITERAL) | ||||
cflags |= REG_LITERAL; | cflags |= REG_LITERAL; | ||||
#else | |||||
ngie: Could you please add a comment as to why this is the case? | |||||
errx(2, "literal expressions not supported at compile time"); | |||||
#endif | #endif | ||||
break; | break; | ||||
case GREP_EXTENDED: | case GREP_EXTENDED: | ||||
cflags |= REG_EXTENDED; | cflags |= REG_EXTENDED; | ||||
break; | break; | ||||
default: | default: | ||||
/* NOTREACHED */ | /* NOTREACHED */ | ||||
usage(); | usage(); | ||||
} | } | ||||
#ifndef WITHOUT_FASTMATCH | #ifndef WITHOUT_FASTMATCH | ||||
fg_pattern = grep_calloc(patterns, sizeof(*fg_pattern)); | fg_pattern = grep_calloc(patterns, sizeof(*fg_pattern)); | ||||
#endif | #endif | ||||
r_pattern = grep_calloc(patterns, sizeof(*r_pattern)); | r_pattern = grep_calloc(patterns, sizeof(*r_pattern)); | ||||
/* Don't process any patterns if we have a blank one */ | /* Don't process any patterns if we have a blank one */ | ||||
#ifdef WITH_INTERNAL_NOSPEC | |||||
if (!matchall && grepbehave != GREP_FIXED) { | |||||
#else | |||||
if (!matchall) { | if (!matchall) { | ||||
#endif | |||||
Done Inline ActionsI'd generally have a slight preference for #ifdef WITH_INTERNAL_NOSPEC if (!matchall && grepbehave != GREP_FIXED) { #else if (!matchall) { #endif emaste: I'd generally have a slight preference for
```
#ifdef WITH_INTERNAL_NOSPEC
if (! | |||||
/* Check if cheating is allowed (always is for fgrep). */ | /* Check if cheating is allowed (always is for fgrep). */ | ||||
for (i = 0; i < patterns; ++i) { | for (i = 0; i < patterns; ++i) { | ||||
#ifndef WITHOUT_FASTMATCH | #ifndef WITHOUT_FASTMATCH | ||||
/* | /* | ||||
* Attempt compilation with fastmatch regex and | * Attempt compilation with fastmatch regex and | ||||
* fallback to regex(3) if it fails. | * fallback to regex(3) if it fails. | ||||
*/ | */ | ||||
if (fastncomp(&fg_pattern[i], pattern[i].pat, | if (fastncomp(&fg_pattern[i], pattern[i].pat, | ||||
Show All 38 Lines |
Could you please add a comment as to why this is the case?