summaryrefslogtreecommitdiff
path: root/bin/ed
diff options
context:
space:
mode:
authorMartijn van Duren <martijn@cvs.openbsd.org>2018-04-26 12:18:55 +0000
committerMartijn van Duren <martijn@cvs.openbsd.org>2018-04-26 12:18:55 +0000
commitb742e6cd3edacd6bf60c74c12ba9f6ab4a7faf2f (patch)
tree3530441660a986b3f60c0760374c8008340cbafa /bin/ed
parent3ed6884f09bda9a1273e85eeb23981507c9638d0 (diff)
Make ed's 'l' command end lines with a '$' and make sure that literal
'$' characters are escaped, so that we are POSIX compliant. The omission of trailing '$' was originally hidden behind a BACKWARDS flag. This flag was most likely introduced to be compatible with 4.4BSD. Thanks to naddy@ for pointing me to the 4.4BSD ed implementation. I tried to trace the origin and enabling of the BACKWARDS flag, since both FreeBSD and NetBSD have the flag, but only FreeBSD doesn't have it enabled. Both projects had an alm@ working on ed during 1993-1995 during which he added this flag to both projects and only enabled it on NetBSD, but I wasn't able to reach him on any known address. Thanks to Ed Schouten (ed@freebsd), and Michael W. Lucas of the ed Mastery book for helping me trying to locate Andrew Moore. Problem originally prodded by garzon.lucero@gmail.com and later independently re-requested by n.reusse@hxgn.net. OK tb@, guenther@, and mwl@mwl.io
Diffstat (limited to 'bin/ed')
-rw-r--r--bin/ed/ed.117
-rw-r--r--bin/ed/io.c10
2 files changed, 6 insertions, 21 deletions
diff --git a/bin/ed/ed.1 b/bin/ed/ed.1
index 8359cf292fa..aefb0d59d12 100644
--- a/bin/ed/ed.1
+++ b/bin/ed/ed.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ed.1,v 1.69 2017/07/05 12:23:46 schwarze Exp $
+.\" $OpenBSD: ed.1,v 1.70 2018/04/26 12:18:54 martijn Exp $
.\"
.\" Copyright (c) 1993 Andrew Moore, Talke Studio.
.\" All rights reserved.
@@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd $Mdocdate: July 5 2017 $
+.Dd $Mdocdate: April 26 2018 $
.Dt ED 1
.Os
.Sh NAME
@@ -807,19 +807,6 @@ additionally, it says behaviour for the
.Fl
option is
.Dq unspecified .
-.Pp
-The
-.St -p1003.1-2008
-specification says the
-.Ic l
-command should mark the ends of lines with a
-.Sq $
-character,
-and that
-.Sq $
-characters
-within the text should be output preceded by a backslash;
-this implementation does not support that.
.Sh HISTORY
An
.Nm
diff --git a/bin/ed/io.c b/bin/ed/io.c
index 13e2c583b8d..de2f2586b36 100644
--- a/bin/ed/io.c
+++ b/bin/ed/io.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: io.c,v 1.20 2017/04/26 21:25:43 naddy Exp $ */
+/* $OpenBSD: io.c,v 1.21 2018/04/26 12:18:54 martijn Exp $ */
/* $NetBSD: io.c,v 1.2 1995/03/21 09:04:43 cgd Exp $ */
/* io.c: This file contains the i/o routines for the ed line editor */
@@ -295,8 +295,8 @@ get_tty_line(void)
-#define ESCAPES "\a\b\f\n\r\t\v\\"
-#define ESCCHARS "abfnrtv\\"
+#define ESCAPES "\a\b\f\n\r\t\v\\$"
+#define ESCCHARS "abfnrtv\\$"
extern int rows;
extern int cols;
@@ -330,7 +330,7 @@ put_tty_line(char *s, int l, int n, int gflag)
#endif
}
if (gflag & GLS) {
- if (31 < *s && *s < 127 && *s != '\\')
+ if (31 < *s && *s < 127 && *s != '\\' && *s != '$')
putchar(*s);
else {
putchar('\\');
@@ -348,10 +348,8 @@ put_tty_line(char *s, int l, int n, int gflag)
} else
putchar(*s);
}
-#ifndef BACKWARDS
if (gflag & GLS)
putchar('$');
-#endif
putchar('\n');
return 0;
}