diff options
author | Eric Andersen | 1999-10-29 00:07:31 +0000 |
---|---|---|
committer | Eric Andersen | 1999-10-29 00:07:31 +0000 |
commit | c1525e84dd6a3ac8252ce10e6ae605bd37d60797 (patch) | |
tree | bef01229299c4ad89f2e353df0e88af292a8795c /regexp.c | |
parent | 6b6b3f6ef2f44898a8bddfaae93cc4ef3aa79661 (diff) | |
download | busybox-c1525e84dd6a3ac8252ce10e6ae605bd37d60797.zip busybox-c1525e84dd6a3ac8252ce10e6ae605bd37d60797.tar.gz |
Stuff
Diffstat (limited to 'regexp.c')
-rw-r--r-- | regexp.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -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. |