aboutsummaryrefslogtreecommitdiff
path: root/utility.c
diff options
context:
space:
mode:
authorkraai <kraai@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-08-28 03:12:30 +0000
committerkraai <kraai@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-08-28 03:12:30 +0000
commitf4255d0d131c792ed7c361cc2ac51690d4ccc151 (patch)
treef3df79cd432fd69d4d4d92833062c6b069a6194c /utility.c
parentd9a3078f9b7a626ca5a379e5ea25a38cefdf39b2 (diff)
downloadbusybox-w32-f4255d0d131c792ed7c361cc2ac51690d4ccc151.tar.gz
busybox-w32-f4255d0d131c792ed7c361cc2ac51690d4ccc151.tar.bz2
busybox-w32-f4255d0d131c792ed7c361cc2ac51690d4ccc151.zip
Removed dead regular expression code.
git-svn-id: svn://busybox.net/trunk/busybox@985 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to '')
-rw-r--r--utility.c76
1 files changed, 0 insertions, 76 deletions
diff --git a/utility.c b/utility.c
index aa8bef6b3..911d84eaf 100644
--- a/utility.c
+++ b/utility.c
@@ -1033,82 +1033,6 @@ int get_console_fd(char *tty_name)
1033#endif /* BB_CHVT || BB_DEALLOCVT || BB_SETKEYCODES */ 1033#endif /* BB_CHVT || BB_DEALLOCVT || BB_SETKEYCODES */
1034 1034
1035 1035
1036#if !defined BB_REGEXP && (defined BB_GREP || defined BB_SED)
1037
1038/* Do a case insensitive strstr() */
1039char *stristr(char *haystack, const char *needle)
1040{
1041 int len = strlen(needle);
1042
1043 while (*haystack) {
1044 if (!strncasecmp(haystack, needle, len))
1045 break;
1046 haystack++;
1047 }
1048
1049 if (!(*haystack))
1050 haystack = NULL;
1051
1052 return haystack;
1053}
1054
1055/* This tries to find a needle in a haystack, but does so by
1056 * only trying to match literal strings (look 'ma, no regexps!)
1057 * This is short, sweet, and carries _very_ little baggage,
1058 * unlike its beefier cousin in regexp.c
1059 * -Erik Andersen
1060 */
1061extern int find_match(char *haystack, char *needle, int ignoreCase)
1062{
1063
1064 if (ignoreCase == FALSE)
1065 haystack = strstr(haystack, needle);
1066 else
1067 haystack = stristr(haystack, needle);
1068 if (haystack == NULL)
1069 return FALSE;
1070 return TRUE;
1071}
1072
1073
1074/* This performs substitutions after a string match has been found. */
1075extern int replace_match(char *haystack, char *needle, char *newNeedle,
1076 int ignoreCase)
1077{
1078 int foundOne = 0;
1079 char *where, *slider, *slider1, *oldhayStack;
1080
1081 if (ignoreCase == FALSE)
1082 where = strstr(haystack, needle);
1083 else
1084 where = stristr(haystack, needle);
1085
1086 if (strcmp(needle, newNeedle) == 0)
1087 return FALSE;
1088
1089 oldhayStack = (char *) xmalloc((unsigned) (strlen(haystack)));
1090 while (where != NULL) {
1091 foundOne++;
1092 strcpy(oldhayStack, haystack);
1093 for (slider = haystack, slider1 = oldhayStack; slider != where;
1094 slider++, slider1++);
1095 *slider = 0;
1096 haystack = strcat(haystack, newNeedle);
1097 slider1 += strlen(needle);
1098 haystack = strcat(haystack, slider1);
1099 where = strstr(slider, needle);
1100 }
1101 free(oldhayStack);
1102
1103 if (foundOne > 0)
1104 return TRUE;
1105 else
1106 return FALSE;
1107}
1108
1109#endif /* ! BB_REGEXP && (BB_GREP || BB_SED) */
1110
1111
1112#if defined BB_FIND || defined BB_INSMOD 1036#if defined BB_FIND || defined BB_INSMOD
1113/* 1037/*
1114 * Routine to see if a text string is matched by a wildcard pattern. 1038 * Routine to see if a text string is matched by a wildcard pattern.