ed(1): Allow the omission of one address in (.,.) and (.;.) address ranges

With this patch, ",n" is an abbreviation for "1,n", ";n" abbreviates
".;n". The "n," and "n;" variants mean "n,n" and "n;n", respectively.
Also, piping to a shell command does not count as a save, so don't reset
the modified flag.

Obtained from:	OpenBSD (CVS Rev. 1.58, 1.59)
This commit is contained in:
Pedro F. Giffuni 2017-07-03 15:54:44 +00:00
parent 5567474c4a
commit be9e8bfaea

View File

@ -350,6 +350,7 @@ next_addr(void)
ibufp++;
addr_cnt++;
second_addr = (c == ';') ? current_addr : 1;
if ((addr = next_addr()) < 0)
addr = addr_last;
break;
}
@ -809,7 +810,7 @@ exec_command(void)
if ((addr = write_file(*fnp ? fnp : old_filename,
(c == 'W') ? "a" : "w", first_addr, second_addr)) < 0)
return ERR;
else if (addr == addr_last)
else if (addr == addr_last && *fnp != '!')
modified = 0;
else if (modified && !scripted && n == 'q')
gflag = EMOD;