FreeBSD Bugzilla – Attachment 170127 Details for
Bug 209387
[exp-run] sed fix.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Fix for sed issue
sed-fix.diff (text/plain), 3.53 KB, created by
Pedro F. Giffuni
on 2016-05-09 00:41:08 UTC
(
hide
)
Description:
Fix for sed issue
Filename:
MIME Type:
Creator:
Pedro F. Giffuni
Created:
2016-05-09 00:41:08 UTC
Size:
3.53 KB
patch
obsolete
>Index: lib/libc/regex/engine.c >=================================================================== >--- lib/libc/regex/engine.c (revision 299241) >+++ lib/libc/regex/engine.c (working copy) >@@ -789,7 +789,7 @@ > ASSIGN(fresh, st); > SP("start", st, *p); > coldp = NULL; >- if (start == m->beginp) >+ if (start == m->offp) > c = OUT; > else { > /* >@@ -894,7 +894,7 @@ > SP("sstart", st, *p); > st = step(m->g, startst, stopst, st, NOTHING, st); > matchp = NULL; >- if (start == m->beginp) >+ if (start == m->offp) > c = OUT; > else { > /* >Index: usr.bin/sed/process.c >=================================================================== >--- usr.bin/sed/process.c (revision 299241) >+++ usr.bin/sed/process.c (working copy) >@@ -71,7 +71,8 @@ > static void do_tr(struct s_tr *); > static void flush_appends(void); > static void lputs(char *, size_t); >-static int regexec_e(regex_t *, const char *, int, int, size_t); >+static int regexec_e(regex_t *, const char *, int, int, size_t, >+ size_t); > static void regsub(SPACE *, char *, char *); > static int substitute(struct s_command *); > >@@ -281,7 +282,7 @@ > * (lastline, linenumber, ps). > */ > #define MATCH(a) \ >- ((a)->type == AT_RE ? regexec_e((a)->u.r, ps, 0, 1, psl) : \ >+ ((a)->type == AT_RE ? regexec_e((a)->u.r, ps, 0, 1, 0, psl) : \ > (a)->type == AT_LINE ? linenum == (a)->u.l : lastline()) > > /* >@@ -381,6 +382,7 @@ > regex_t *re; > regoff_t slen; > int lastempty, n; >+ size_t le = 0; > char *s; > > s = ps; >@@ -392,7 +394,7 @@ > linenum, fname, cp->u.s->maxbref); > } > } >- if (!regexec_e(re, s, 0, 0, psl)) >+ if (!regexec_e(re, s, 0, 0, 0, psl)) > return (0); > > SS.len = 0; /* Clean substitute space. */ >@@ -402,28 +404,30 @@ > > do { > /* Copy the leading retained string. */ >- if (n <= 1 && match[0].rm_so) >- cspace(&SS, s, match[0].rm_so, APPEND); >+ if (n <= 1 && match[0].rm_so - le) >+ cspace(&SS, s, match[0].rm_so - le, APPEND); > > /* Skip zero-length matches right after other matches. */ >- if (lastempty || match[0].rm_so || >+ if (lastempty || (match[0].rm_so - le) || > match[0].rm_so != match[0].rm_eo) { > if (n <= 1) { > /* Want this match: append replacement. */ >- regsub(&SS, s, cp->u.s->new); >+ regsub(&SS, ps, cp->u.s->new); > if (n == 1) > n = -1; > } else { > /* Want a later match: append original. */ >- if (match[0].rm_eo) >- cspace(&SS, s, match[0].rm_eo, APPEND); >+ if (match[0].rm_eo - le) >+ cspace(&SS, s, match[0].rm_eo - le, >+ APPEND); > n--; > } > } > > /* Move past this match. */ >- s += match[0].rm_eo; >- slen -= match[0].rm_eo; >+ s += (match[0].rm_eo - le); >+ slen -= (match[0].rm_eo - le); >+ le = match[0].rm_eo; > > /* > * After a zero-length match, advance one byte, >@@ -434,13 +438,15 @@ > slen = -1; > else > slen--; >- if (*s != '\0') >+ if (*s != '\0') { > cspace(&SS, s++, 1, APPEND); >+ le++; >+ } > lastempty = 1; > } else > lastempty = 0; > >- } while (n >= 0 && slen >= 0 && regexec_e(re, s, REG_NOTBOL, 0, slen)); >+ } while (n >= 0 && slen >= 0 && regexec_e(re, ps, 0, 0, le, psl)); > > /* Did not find the requested number of matches. */ > if (n > 1) >@@ -652,7 +658,7 @@ > > static int > regexec_e(regex_t *preg, const char *string, int eflags, int nomatch, >- size_t slen) >+ size_t start, size_t stop) > { > int eval; > >@@ -663,8 +669,8 @@ > defpreg = preg; > > /* Set anchors */ >- match[0].rm_so = 0; >- match[0].rm_eo = slen; >+ match[0].rm_so = start; >+ match[0].rm_eo = stop; > > eval = regexec(defpreg, string, > nomatch ? 0 : maxnsub + 1, match, eflags | REG_STARTEND);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 209387
: 170127