summaryrefslogtreecommitdiff
path: root/regexp.c
diff options
context:
space:
mode:
authorEric Andersen1999-10-29 00:07:31 +0000
committerEric Andersen1999-10-29 00:07:31 +0000
commitc1525e84dd6a3ac8252ce10e6ae605bd37d60797 (patch)
treebef01229299c4ad89f2e353df0e88af292a8795c /regexp.c
parent6b6b3f6ef2f44898a8bddfaae93cc4ef3aa79661 (diff)
downloadbusybox-c1525e84dd6a3ac8252ce10e6ae605bd37d60797.zip
busybox-c1525e84dd6a3ac8252ce10e6ae605bd37d60797.tar.gz
Stuff
Diffstat (limited to 'regexp.c')
-rw-r--r--regexp.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/regexp.c b/regexp.c
index 6017d79..deee238 100644
--- a/regexp.c
+++ b/regexp.c
@@ -25,6 +25,28 @@ extern int find_match(char *haystack, char *needle, int ignoreCase)
return( status);
}
+/* This performs substitutions after a regexp match has been found.
+ * The new string is returned. It is malloc'ed, and do must be freed. */
+extern char* replace_match(char *haystack, char *needle, char *newNeedle, int ignoreCase)
+{
+ int status;
+ char* newHaystack;
+ struct regexp* re;
+ newHaystack = (char *)malloc((unsigned)(strlen(haystack) -
+ strlen(needle) + strlen(newNeedle));
+ re = regcomp( needle);
+ status = regexec(re, haystack, FALSE, ignoreCase);
+
+ return( newHaystack)
+}
+
+
+extern void regsub(regexp* re, char* src, char* dst)
+
+ free( re);
+ return( status);
+}
+
/* code swiped from elvis-tiny 1.4 (a clone of vi) and adjusted to
* suit the needs of busybox by Erik Andersen.