changes to new pattern substitution replacement; documentation updates

This commit is contained in:
Chet Ramey
2021-10-18 10:57:20 -04:00
parent 304b1e938c
commit 1fff64acdc
18 changed files with 2528 additions and 2270 deletions
+11 -4
View File
@@ -178,17 +178,22 @@ strsub (string, pat, rep, global)
}
/* Replace all instances of C in STRING with TEXT. TEXT may be empty or
NULL. If DO_GLOB is non-zero, we quote the replacement text for
globbing. Backslash may be used to quote C. */
NULL. If (FLAGS & 1) is non-zero, we quote the replacement text for
globbing. Backslash may be used to quote C. If (FLAGS & 2) we allow
backslash to escape backslash as well. */
char *
strcreplace (string, c, text, do_glob)
strcreplace (string, c, text, flags)
char *string;
int c;
const char *text;
int do_glob;
int flags;
{
char *ret, *p, *r, *t;
int len, rlen, ind, tlen;
int do_glob, escape_backslash;
do_glob = flags & 1;
escape_backslash = flags & 2;
len = STRLEN (text);
rlen = len + strlen (string) + 2;
@@ -225,6 +230,8 @@ strcreplace (string, c, text, do_glob)
if (*p == '\\' && p[1] == c)
p++;
else if (escape_backslash && *p == '\\' && p[1] == '\\')
p++;
ind = r - ret;
RESIZE_MALLOCED_BUFFER (ret, ind, 2, rlen, rlen);