ref: ba783aceb08b55a8535a793a382f9765168a94d9
parent: 1aa852987a045bf5de5eb52bb9fcb975b147e0eb
author: aiju <devnull@localhost>
date: Mon Nov 5 15:17:48 EST 2018
sed: only dollars as first address are a problem for -u
--- a/sys/src/cmd/sed.c
+++ b/sys/src/cmd/sed.c
@@ -96,7 +96,7 @@
SedCom *pend = pspace+MAXCMDS; /* End of command storage */
SedCom *rep = pspace; /* Current fill point */
-int dollars; /* Number of dollar addresses */
+int dollars; /* Number of dollar (first) addresses */
Reprog *lastre; /* Last regular expression */
Resub subexp[MAXSUB]; /* sub-patterns of pattern match*/
@@ -290,6 +290,8 @@
address(&rep->ad1);
if (rep->ad1.type != A_NONE) {+ if (rep->ad1.type == A_DOL)
+ dollars++;
if (rep->ad1.type == A_LAST) {if (!lastre)
quit("First RE may not be null");@@ -765,10 +767,9 @@
int c;
long lno;
- if((c = *cp++) == '$'){+ if((c = *cp++) == '$')
ap->type = A_DOL;
- dollars++;
- }else if(c == '/') {+ else if(c == '/') {seof = c;
if (ap->rp = compile())
ap->type = A_RE;
--
⑨