NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bin/59050: Discrepancy between ed behaviour and man page and POSIX
>Number: 59050
>Category: bin
>Synopsis: Discrepancy between ed behaviour and man page and POSIX
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Feb 06 22:50:00 +0000 2025
>Originator: Carsten Reith
>Release: 10.1-STABLE
>Organization:
>Environment:
NetBSD mogli.creith.de 10.1_STABLE NetBSD 10.1_STABLE (MOGLI) #0: Thu Feb 6 17:48:39 CET 2025 creith%mogli.creith.de@localhost:/home/creith/netbsd/obj/sys/arch/amd64/compile/MOGLI amd64
>Description:
According to the man page and POSIX, a missing trailing delimiter in a substitution should be equivalent to <delimter>p (f.ex. /p). This doesn't work with % (repeat last substitution.)
>How-To-Repeat:
mogli$ printf "a\nb\nc\n" > test
mogli$ ed test
6
1s/a/hello
hello
2s/b/%
%
,n
1 hello
2 %
3 c
>Fix:
After applying the following diff, ed works as expected.
Index: sub.c
===================================================================
RCS file: /cvsroot/src/bin/ed/sub.c,v
retrieving revision 1.7
diff -u -r1.7 sub.c
--- sub.c 23 Mar 2014 05:06:42 -0000 1.7
+++ sub.c 6 Feb 2025 22:18:46 -0000
@@ -84,7 +84,8 @@
char c;
char delimiter = *ibufp++;
- if (*ibufp == '%' && *(ibufp + 1) == delimiter) {
+ if (*ibufp == '%' &&
+ (*(ibufp + 1) == delimiter || *(ibufp + 1) == '\n')) {
ibufp++;
if (!rhbuf) {
seterrmsg("no previous substitution");
Ed session after diff:
mogli$ printf "a\nb\nc\n" > test
mogli$ ed test
6
,n
1 a
2 b
3 c
1s/a/hello
hello
2s/b/%
hello
.n
2 hello
,n
1 hello
2 hello
3 c
Home |
Main Index |
Thread Index |
Old Index