aboutsummaryrefslogtreecommitdiff
path: root/regexp.c
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>1999-10-29 00:07:31 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>1999-10-29 00:07:31 +0000
commit2f8c4fd21e700eb3a87b36dc405bcd2360c99eba (patch)
treebef01229299c4ad89f2e353df0e88af292a8795c /regexp.c
parent2e723b93d635572788b1afbe0bb55870305669db (diff)
downloadbusybox-w32-2f8c4fd21e700eb3a87b36dc405bcd2360c99eba.tar.gz
busybox-w32-2f8c4fd21e700eb3a87b36dc405bcd2360c99eba.tar.bz2
busybox-w32-2f8c4fd21e700eb3a87b36dc405bcd2360c99eba.zip
Stuff
git-svn-id: svn://busybox.net/trunk/busybox@65 69ca8d6d-28ef-0310-b511-8ec308f3f277
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 6017d79b4..deee238ec 100644
--- a/regexp.c
+++ b/regexp.c
@@ -25,6 +25,28 @@ extern int find_match(char *haystack, char *needle, int ignoreCase)
25 return( status); 25 return( status);
26} 26}
27 27
28/* This performs substitutions after a regexp match has been found.
29 * The new string is returned. It is malloc'ed, and do must be freed. */
30extern char* replace_match(char *haystack, char *needle, char *newNeedle, int ignoreCase)
31{
32 int status;
33 char* newHaystack;
34 struct regexp* re;
35 newHaystack = (char *)malloc((unsigned)(strlen(haystack) -
36 strlen(needle) + strlen(newNeedle));
37 re = regcomp( needle);
38 status = regexec(re, haystack, FALSE, ignoreCase);
39
40 return( newHaystack)
41}
42
43
44extern void regsub(regexp* re, char* src, char* dst)
45
46 free( re);
47 return( status);
48}
49
28 50
29/* code swiped from elvis-tiny 1.4 (a clone of vi) and adjusted to 51/* code swiped from elvis-tiny 1.4 (a clone of vi) and adjusted to
30 * suit the needs of busybox by Erik Andersen. 52 * suit the needs of busybox by Erik Andersen.