[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-ed] ed(1) doesn't support "^" address
From: |
Tim Chase |
Subject: |
[Bug-ed] ed(1) doesn't support "^" address |
Date: |
Sun, 18 Jan 2015 13:09:56 -0600 |
The original Unix™ ed(1) supported a "^" address which was a synonym
for "-". Supporting documentation can be seen at the top of page 4 in
the right-hand column:
http://webhome.csc.uvic.ca/~mcheng/360/xv6/unixv6/ed.pdf
"""
Try typing "ˆ" — it's equivalent to ".-1p"
"""
as well as item #10 here:
http://roguelife.org/~fujita/COOKIES/HISTORY/V6/ed.1.html
("To maintain compatibility with earlier version of the editor, the
character `^' in addresses is entirely equivalent to `-'.")
Based on my reading of the above two documents, I believe the diff
below should provide the functionality/backwards-compatibility. I
don't know how the testing scheme works so you might want to make up
a test for this.
-Tim
(in case you need some sort of contributor statement, as the author
of the diff, I hearby release this diff into the public domain, so do
what you want with it)
diff --git a/main_loop.c b/main_loop.c
index 2081b38..2d058d1 100644
--- a/main_loop.c
+++ b/main_loop.c
@@ -213,14 +213,15 @@ static int next_addr( const char ** const
ibufpp, int * const addr_cnt ) case '+':
case '\t':
case ' ':
+ case '^':
case '-': *ibufpp = skip_blanks( ++*ibufpp );
if( isdigit( (unsigned char)**ibufpp ) )
{
if( !parse_int( &n, *ibufpp, ibufpp ) ) return -2;
- addr += ( ( ch == '-' ) ? -n : n );
+ addr += ( ( ch == '-' || ch == '^' ) ? -n : n );
}
else if( ch == '+' ) ++addr;
- else if( ch == '-' ) --addr;
+ else if( ch == '-' || ch == '^' ) --addr;
break;
case '.':
case '$': if( !first ) { invalid_address(); return -2; };
.
- [Bug-ed] ed(1) doesn't support "^" address,
Tim Chase <=