Update to 28 June snapshot from HEAD.

This commit is contained in:
Maxim Sobolev 2002-06-28 12:04:39 +00:00
parent f1bd7e4587
commit 3dfd43f219
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=62151
3 changed files with 20 additions and 15 deletions

View file

@ -6,7 +6,7 @@
#
PORTNAME= sed_inplace
PORTVERSION= 2002.06.17
PORTVERSION= 2002.06.28
CATEGORIES= textproc
MASTER_SITES= #
DISTFILES= #
@ -21,7 +21,7 @@ MAKE_ENV= PKGDIR="${PKGDIR}"
.include <bsd.port.pre.mk>
.if ${OSVERSION} > 500033
IGNORE= "is in the base system"
#IGNORE= "is in the base system"
.endif
do-install:

View file

@ -361,6 +361,8 @@ mf_fgets(sp, spflag)
p = fgetln(f, &len);
if (ferror(f))
errx(1, "%s: %s", fname, strerror(errno ? errno : EIO));
if (len != 0 && p[len - 1] == '\n')
len--;
cspace(sp, p, len, spflag);
linenum++;

View file

@ -85,7 +85,7 @@ static regex_t *defpreg;
size_t maxnsub;
regmatch_t *match;
#define OUT(s) { fwrite(s, sizeof(u_char), psl, stdout); }
#define OUT(s) { fwrite(s, sizeof(u_char), psl, stdout); putchar('\n'); }
void
process()
@ -148,14 +148,14 @@ redirect:
cspace(&PS, hs, hsl, REPLACE);
break;
case 'G':
if (hs == NULL)
cspace(&HS, "\n", 1, REPLACE);
cspace(&PS, "\n", 1, 0);
cspace(&PS, hs, hsl, 0);
break;
case 'h':
cspace(&HS, ps, psl, REPLACE);
break;
case 'H':
cspace(&HS, "\n", 1, 0);
cspace(&HS, ps, psl, 0);
break;
case 'i':
@ -174,6 +174,7 @@ redirect:
break;
case 'N':
flush_appends();
cspace(&PS, "\n", 1, 0);
if (!mf_fgets(&PS, 0)) {
if (!nflag && !pd)
OUT(ps)
@ -191,7 +192,7 @@ redirect:
if (psl != 0 &&
(p = memchr(ps, '\n', psl - 1)) != NULL) {
oldpsl = psl;
psl = (p + 1) - ps;
psl = p - ps;
}
OUT(ps)
if (p != NULL)
@ -230,12 +231,11 @@ redirect:
O_WRONLY|O_APPEND|O_CREAT|O_TRUNC,
DEFFILEMODE)) == -1)
err(1, "%s", cp->t);
if (write(cp->u.fd, ps, psl) != psl)
if (write(cp->u.fd, ps, psl) != psl ||
write(cp->u.fd, "\n", 1) != 1)
err(1, "%s", cp->t);
break;
case 'x':
if (hs == NULL)
cspace(&HS, "\n", 1, REPLACE);
tspace = PS;
PS = HS;
HS = tspace;
@ -243,7 +243,7 @@ redirect:
case 'y':
if (pd || psl == 0)
break;
for (p = ps, len = psl; --len; ++p)
for (p = ps, len = psl; len--; ++p)
*p = cp->u.y[(unsigned char)*p];
break;
case ':':
@ -418,7 +418,8 @@ substitute(cp)
if (cp->u.s->wfd == -1 && (cp->u.s->wfd = open(cp->u.s->wfile,
O_WRONLY|O_APPEND|O_CREAT|O_TRUNC, DEFFILEMODE)) == -1)
err(1, "%s", cp->u.s->wfile);
if (write(cp->u.s->wfd, ps, psl) != psl)
if (write(cp->u.s->wfd, ps, psl) != psl ||
write(cp->u.s->wfd, "\n", 1) != 1)
err(1, "%s", cp->u.s->wfile);
}
return (1);
@ -489,7 +490,11 @@ lputs(s)
if (isprint((unsigned char)*s) && *s != '\\') {
(void)putchar(*s);
count++;
} else if (*s != '\n') {
} else if (*s == '\n') {
(void)putchar('$');
(void)putchar('\n');
count = 0;
} else {
escapes = "\\\a\b\f\r\t\v";
(void)putchar('\\');
if ((p = strchr(escapes, *s))) {
@ -522,9 +527,7 @@ regexec_e(preg, string, eflags, nomatch, slen)
} else
defpreg = preg;
/* Set anchors, discounting trailing newline (if any). */
if (slen > 0 && string[slen - 1] == '\n')
slen--;
/* Set anchors */
match[0].rm_so = 0;
match[0].rm_eo = slen;