summaryrefslogtreecommitdiff
path: root/source3/lib/util_str.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/util_str.c')
-rw-r--r--source3/lib/util_str.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index 6b91a0d625..1401d6d853 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -909,14 +909,15 @@ BOOL string_set(char **dest,const char *src)
enough room!
This routine looks for pattern in s and replaces it with
- insert. It may do multiple replacements.
+ insert. It may do multiple replacements or just one.
Any of " ; ' $ or ` in the insert string are replaced with _
if len==0 then the string cannot be extended. This is different from the old
use of len==0 which was for no length checks to be done.
**/
-void string_sub2(char *s,const char *pattern, const char *insert, size_t len, BOOL remove_unsafe_characters)
+void string_sub2(char *s,const char *pattern, const char *insert, size_t len,
+ BOOL remove_unsafe_characters, BOOL replace_once)
{
char *p;
ssize_t ls,lp,li, i;
@@ -963,12 +964,20 @@ void string_sub2(char *s,const char *pattern, const char *insert, size_t len, BO
}
s = p + li;
ls += (li-lp);
+
+ if (replace_once)
+ break;
}
}
+void string_sub_once(char *s, const char *pattern, const char *insert, size_t len)
+{
+ string_sub2( s, pattern, insert, len, True, True );
+}
+
void string_sub(char *s,const char *pattern, const char *insert, size_t len)
{
- string_sub2( s, pattern, insert, len, True );
+ string_sub2( s, pattern, insert, len, True, False );
}
void fstring_sub(char *s,const char *pattern,const char *insert)