Removed dead regular expression code.
This commit is contained in:
parent
88cc3057fd
commit
ab60f6987a
@ -139,12 +139,6 @@
|
||||
// at the same time...
|
||||
#define BB_FEATURE_USE_PROCFS
|
||||
//
|
||||
// Enable full regular expressions. This adds about
|
||||
// 4k. When this is off, things that would normally
|
||||
// use regualr expressions (like grep) will just use
|
||||
// normal strings.
|
||||
#define BB_FEATURE_FULL_REGULAR_EXPRESSIONS
|
||||
//
|
||||
// This compiles out everything but the most
|
||||
// trivial --help usage information (i.e. reduces binary size)
|
||||
//#define BB_FEATURE_TRIVIAL_HELP
|
||||
@ -281,10 +275,6 @@
|
||||
#define BB_MTAB
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_FULL_REGULAR_EXPRESSIONS && (defined BB_SED || defined BB_GREP )
|
||||
#define BB_REGEXP
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_SH_COMMAND_EDITING && defined BB_SH
|
||||
#define BB_CMDEDIT
|
||||
#endif
|
||||
|
76
utility.c
76
utility.c
@ -1033,82 +1033,6 @@ int get_console_fd(char *tty_name)
|
||||
#endif /* BB_CHVT || BB_DEALLOCVT || BB_SETKEYCODES */
|
||||
|
||||
|
||||
#if !defined BB_REGEXP && (defined BB_GREP || defined BB_SED)
|
||||
|
||||
/* Do a case insensitive strstr() */
|
||||
char *stristr(char *haystack, const char *needle)
|
||||
{
|
||||
int len = strlen(needle);
|
||||
|
||||
while (*haystack) {
|
||||
if (!strncasecmp(haystack, needle, len))
|
||||
break;
|
||||
haystack++;
|
||||
}
|
||||
|
||||
if (!(*haystack))
|
||||
haystack = NULL;
|
||||
|
||||
return haystack;
|
||||
}
|
||||
|
||||
/* This tries to find a needle in a haystack, but does so by
|
||||
* only trying to match literal strings (look 'ma, no regexps!)
|
||||
* This is short, sweet, and carries _very_ little baggage,
|
||||
* unlike its beefier cousin in regexp.c
|
||||
* -Erik Andersen
|
||||
*/
|
||||
extern int find_match(char *haystack, char *needle, int ignoreCase)
|
||||
{
|
||||
|
||||
if (ignoreCase == FALSE)
|
||||
haystack = strstr(haystack, needle);
|
||||
else
|
||||
haystack = stristr(haystack, needle);
|
||||
if (haystack == NULL)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* This performs substitutions after a string match has been found. */
|
||||
extern int replace_match(char *haystack, char *needle, char *newNeedle,
|
||||
int ignoreCase)
|
||||
{
|
||||
int foundOne = 0;
|
||||
char *where, *slider, *slider1, *oldhayStack;
|
||||
|
||||
if (ignoreCase == FALSE)
|
||||
where = strstr(haystack, needle);
|
||||
else
|
||||
where = stristr(haystack, needle);
|
||||
|
||||
if (strcmp(needle, newNeedle) == 0)
|
||||
return FALSE;
|
||||
|
||||
oldhayStack = (char *) xmalloc((unsigned) (strlen(haystack)));
|
||||
while (where != NULL) {
|
||||
foundOne++;
|
||||
strcpy(oldhayStack, haystack);
|
||||
for (slider = haystack, slider1 = oldhayStack; slider != where;
|
||||
slider++, slider1++);
|
||||
*slider = 0;
|
||||
haystack = strcat(haystack, newNeedle);
|
||||
slider1 += strlen(needle);
|
||||
haystack = strcat(haystack, slider1);
|
||||
where = strstr(slider, needle);
|
||||
}
|
||||
free(oldhayStack);
|
||||
|
||||
if (foundOne > 0)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#endif /* ! BB_REGEXP && (BB_GREP || BB_SED) */
|
||||
|
||||
|
||||
#if defined BB_FIND || defined BB_INSMOD
|
||||
/*
|
||||
* Routine to see if a text string is matched by a wildcard pattern.
|
||||
|
Loading…
Reference in New Issue
Block a user