FreeBSD Bugzilla – Attachment 144761 Details for
Bug 191933
[exp-run] Test patch to usr.bin/sed, to fix PR 160745
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to sed(1) to fix PR 160745
sed-appends-newline-pr160745.4.patch (text/plain), 2.71 KB, created by
Jean-Sébastien Pédron
on 2014-07-17 21:19:21 UTC
(
hide
)
Description:
Patch to sed(1) to fix PR 160745
Filename:
MIME Type:
Creator:
Jean-Sébastien Pédron
Created:
2014-07-17 21:19:21 UTC
Size:
2.71 KB
patch
obsolete
>diff --git a/usr.bin/sed/defs.h b/usr.bin/sed/defs.h >index d4f434e..fb33676 100644 >--- a/usr.bin/sed/defs.h >+++ b/usr.bin/sed/defs.h >@@ -143,6 +143,7 @@ typedef struct { > char *space; /* Current space pointer. */ > size_t len; /* Current length. */ > int deleted; /* If deleted. */ >+ int append_newline; /* If originally terminated by \n. */ > char *back; /* Backing memory. */ > size_t blen; /* Backing memory length. */ > } SPACE; >diff --git a/usr.bin/sed/main.c b/usr.bin/sed/main.c >index 6cdfcda..9ddb2e2 100644 >--- a/usr.bin/sed/main.c >+++ b/usr.bin/sed/main.c >@@ -439,8 +439,12 @@ mf_fgets(SPACE *sp, enum e_spflag spflag) > len = getline(&p, &plen, infile); > if (len == -1) > err(1, "%s", fname); >- if (len != 0 && p[len - 1] == '\n') >+ if (len != 0 && p[len - 1] == '\n') { >+ sp->append_newline = 1; > len--; >+ } else { >+ sp->append_newline = 0; >+ } > cspace(sp, p, len, spflag); > > linenum++; >diff --git a/usr.bin/sed/process.c b/usr.bin/sed/process.c >index 5e2618a..85bc8f0 100644 >--- a/usr.bin/sed/process.c >+++ b/usr.bin/sed/process.c >@@ -63,6 +63,7 @@ static SPACE HS, PS, SS, YS; > #define pd PS.deleted > #define ps PS.space > #define psl PS.len >+#define psanl PS.append_newline > #define hs HS.space > #define hsl HS.len > >@@ -85,7 +86,10 @@ static regex_t *defpreg; > size_t maxnsub; > regmatch_t *match; > >-#define OUT() do {fwrite(ps, 1, psl, outfile); fputc('\n', outfile);} while (0) >+#define OUT() do { \ >+ fwrite(ps, 1, psl, outfile); \ >+ if (psanl) fputc('\n', outfile); \ >+} while (0) > > void > process(void) >@@ -94,6 +98,7 @@ process(void) > SPACE tspace; > size_t oldpsl = 0; > char *p; >+ int oldpsanl; > > p = NULL; > >@@ -190,11 +195,15 @@ redirect: > break; > if ((p = memchr(ps, '\n', psl)) != NULL) { > oldpsl = psl; >+ oldpsanl = psanl; > psl = p - ps; >+ psanl = 0; > } > OUT(); >- if (p != NULL) >+ if (p != NULL) { > psl = oldpsl; >+ psanl = oldpsanl; >+ } > break; > case 'q': > if (!nflag && !pd) >@@ -244,6 +253,7 @@ redirect: > cspace(&HS, "", 0, REPLACE); > tspace = PS; > PS = HS; >+ psanl = tspace.append_newline; > HS = tspace; > break; > case 'y': >@@ -444,6 +454,7 @@ substitute(struct s_command *cp) > */ > tspace = PS; > PS = SS; >+ psanl = tspace.append_newline; > SS = tspace; > SS.space = SS.back; > >@@ -513,6 +524,7 @@ do_tr(struct s_tr *y) > /* Swap the translation space and the pattern space. */ > tmp = PS; > PS = YS; >+ psanl = tmp.append_newline; > YS = tmp; > YS.space = YS.back; > } >diff --git a/usr.bin/sed/tests/regress.y.out b/usr.bin/sed/tests/regress.y.out >index 829a681..22f4f05 100644 >--- a/usr.bin/sed/tests/regress.y.out >+++ b/usr.bin/sed/tests/regress.y.out >@@ -1 +1 @@ >-fOO >+fOO >\ No newline at end of file
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 191933
:
144761
|
145336