Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!purdue!mentor.cc.purdue.edu!pur-ee!ea.ecn.purdue.edu!housel From: housel@en.ecn.purdue.edu (Peter S. Housel) Newsgroups: comp.os.minix Subject: More sed(1) fixes Message-ID: <14048@ea.ecn.purdue.edu> Date: 4 Aug 89 13:23:22 GMT Sender: housel@ea.ecn.purdue.edu Organization: Purdue University Engineering Computer Network Lines: 122 Here is a patch which fixes a couple of longstanding bugs in the Minix sed(1) program. The first fixes the handling of multiple ';'-separated commands in a single line. The rest is an incorporation of fixes by Klamer Schutte (n62@nikhefh.hep.nl) which clear up some null pointer problems and keep "." in regular expressions from being treated as ".*". -Peter S. Housel- housel@ecn.purdue.edu ...!pur-ee!housel echo 'x - sed.c.cdif' sed 's/^X//' <<'**-sed.c.cdif-EOF-**' >sed.c.cdif X*** sed.c.orig Thu Aug 3 19:39:23 1989 X--- /usr/src/commands/sed.c Thu Aug 3 19:56:25 1989 X*************** X*** 294,305 **** X X for(;;) /* main compilation loop */ X { X! if (*cp != ';') /* get a new command line */ X if (cmdline(cp = linebuf) < 0) X break; X SKIPWS(cp); X! if (*cp=='\0' || *cp=='#') /* a comment */ X! continue; X if (*cp == ';') /* ; separates cmds */ X { X cp++; X--- 294,311 ---- X X for(;;) /* main compilation loop */ X { X! if (*cp == '\0') /* get a new command line */ X if (cmdline(cp = linebuf) < 0) X break; X SKIPWS(cp); X! if (*cp=='\0') /* empty */ X! continue; X! if (*cp == '#') /* comment */ X! { X! while(*cp) X! ++cp; X! continue; X! } X if (*cp == ';') /* ; separates cmds */ X { X cp++; X*************** X*** 360,370 **** X if (++cmdp >= cmds + MAXCMDS) ABORT(TMCDS); X X SKIPWS(cp); /* look for trailing stuff */ X! if (*cp != '\0') X! if (*++cp == ';') X! continue; X! else if (cp[-1] != '#') X! ABORT(TRAIL); X } X } X X--- 366,373 ---- X if (++cmdp >= cmds + MAXCMDS) ABORT(TMCDS); X X SKIPWS(cp); /* look for trailing stuff */ X! if (*cp != '\0' && *cp != ';' && *cp != '#') X! ABORT(TRAIL); X } X } X X*************** X*** 500,506 **** X if (nwfiles >= WFILES) ABORT(TMWFI); X fp=gettext(fname[nwfiles]=fp); /* filename will be in pool */ X for(i = nwfiles-1; i >= 0; i--) /* match it in table */ X! if (strcmp(fname[nwfiles], fname[i]) == 0) X { X cmdp->fout = fout[i]; X return(0); X--- 503,510 ---- X if (nwfiles >= WFILES) ABORT(TMWFI); X fp=gettext(fname[nwfiles]=fp); /* filename will be in pool */ X for(i = nwfiles-1; i >= 0; i--) /* match it in table */ X! if ((fname[i] != NULL) && X! (strcmp(fname[nwfiles], fname[i]) == 0)) X { X cmdp->fout = fout[i]; X return(0); X*************** X*** 639,645 **** X X case '.': /* match any char except newline */ X *ep++ = CDOT; X! X case '*': /* 0..n repeats of previous pattern */ X if (lastep == NULL) /* if * isn't first on line */ X goto defchar; /* match a literal * */ X--- 643,649 ---- X X case '.': /* match any char except newline */ X *ep++ = CDOT; X! continue; X case '*': /* 0..n repeats of previous pattern */ X if (lastep == NULL) /* if * isn't first on line */ X goto defchar; /* match a literal * */ X*************** X*** 832,838 **** X { X register label *rp; X for(rp = lablst; rp < ptr; rp++) X! if (strcmp(rp->name, ptr->name) == 0) X return(rp); X return(NULL); X } X--- 836,842 ---- X { X register label *rp; X for(rp = lablst; rp < ptr; rp++) X! if ((rp->name != NULL) && (strcmp(rp->name, ptr->name) == 0)) X return(rp); X return(NULL); X } **-sed.c.cdif-EOF-**