[comp.os.minix] More sed

housel@en.ecn.purdue.edu (Peter S. Housel) (08/04/89)

	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-**

TAR@MAINE.BITNET (Thom Rounds) (08/09/89)

    The ultimate irony!! Here (prev. letter) we have sed patches. And what do
they use to unshar themselves?? You guessed it, sed!!
-------
                          |            Thom Rounds (after 6 P.M.)
Phone:  (207) 437-2475    |  INTERNET: tar@maine.bitnet
Mail:   PO Box 245        |    BITNET: TAR@MAINE
        Albion, ME 04910  +-----------+------------------------------
        U.S. of A.        | This space|"..thinking that we're getting
                          |intention- | older and wiser, when we're
                          |ally left  | just getting old."
                          |blank  :-> | --David Gilmour

ncoverby@plains.NoDak.edu (Glen Overby) (08/11/89)

In article <1695TAR@MAINE> TAR@MAINE.BITNET (Thom Rounds) writes:
>    The ultimate irony!! Here (prev. letter) we have sed patches. And what do
>they use to unshar themselves?? You guessed it, sed!!

And how do you apply them?  With patch, of course (unless your a machoist).
Patch is smart enough to find the diffs inside of a shar/sed file without
un-sharing them.

So you don't NEED sed to apply the patches.
-- 
		Glen Overby	<ncoverby@plains.nodak.edu>
	uunet!ndsuvax!ncoverby (UUCP)	ncoverby@ndsuvax (Bitnet)

TAR@MAINE.BITNET (Thom Rounds) (08/12/89)

In article <1989Aug11.055037.1847@plains.NoDak.edu>, ncoverby@plains.NoDak.edu (Glen Overby) says:
>
>In article <1695TAR@MAINE> TAR@MAINE.BITNET (Thom Rounds) writes:
>>    The ultimate irony!! Here (prev. letter) we have sed patches. And what do
>>they use to unshar themselves?? You guessed it, sed!!
>
>And how do you apply them?  With patch, of course (unless your a machoist).
>Patch is smart enough to find the diffs inside of a shar/sed file without
>un-sharing them.
>
>So you don't NEED sed to apply the patches.
>--
>                Glen Overby        <ncoverby@plains.nodak.edu>
>        uunet!ndsuvax!ncoverby (UUCP)        ncoverby@ndsuvax (Bitnet)

    Some people run MINIX on SMALL computers and don't have such marvelous
tools. If only IBM would market PC-AIX!!!

rmtodd@uokmax.UUCP (Richard Michael Todd) (08/13/89)

In article <1705TAR@MAINE> TAR@MAINE.BITNET (Thom Rounds) writes:
>In article <1989Aug11.055037.1847@plains.NoDak.edu>, ncoverby@plains.NoDak.edu (Glen Overby) says:
>>And how do you apply them?  With patch, of course (unless your a machoist).

>    Some people run MINIX on SMALL computers and don't have such marvelous
>tools. If only IBM would market PC-AIX!!!

  Said "marvelous tool" is a freeware Unix program written by Larry Wall
and available at any friendly comp.sources.unix archive site.  Patch will
compile and run just fine under Minix, even on your IBM PC.  You will need
to fiddle about with the config.h file, as Larry Wall's auto-configure
shell script may not work under Minix (it didn't under 1.1, I haven't 
tried it under a more recent version).  Still, you can have Patch on your
system.  For free, yet.  So pick yourself up a copy of the source and
have at it.  And mellow out a little, will you?
  P.S. I somehow doubt PC/AIX would have come with Patch, either.  I'm
not sure any Unix distribution comes with Patch, except maybe BSD4.3.  
-- 
Richard Todd   rmtodd@chinet.chi.il.us  or  rmtodd@uokmax.ecn.uoknor.edu  
                                    aka     ...!sun!texsun!uokmax!rmtodd
"Never re-invent the wheel unnecessarily; yours may have corners."-henry@utzoo

hjg@amms4.UUCP (Harry Gross) (08/14/89)

In article <3613@uokmax.UUCP> rmtodd@uokmax.UUCP (Richard Michael Todd) writes:
>In article <1705TAR@MAINE> TAR@MAINE.BITNET (Thom Rounds) writes:
>  Said "marvelous tool" is a freeware Unix program written by Larry Wall
>and available at any friendly comp.sources.unix archive site.  Patch will
>compile and run just fine under Minix, even on your IBM PC.  You will need
>to fiddle about with the config.h file, as Larry Wall's auto-configure
>shell script may not work under Minix (it didn't under 1.1, I haven't 
>tried it under a more recent version).

The auto-configure script doesn't work under 1.3, either.  Also, it requires
awk to finish.  I have been fiddling with the script to take into consideration
various MINIX quirks (like no .o files - which the vanilla configure script
looks for when extracting names from the library), but in order to make it
fully functional, I will need a MINIX version of awk.  Does one exist?  If so,
where can I get a copy from?  (Via annonymous uucp or by e-mail only - I am not
on Internet and can't use ftp - sigh :-)

Thanks - I'll post my changes to patch once I get it working - and I will mail
a copy of them to Larry for inclusion in the 'master copy', if he wants to add
the stuff.

Cheers,
-- 
		Harry Gross				 |  reserved for
							 |  something really
Internet: hjg@amms4.UUCP   (we're working on registering)|  clever - any
UUCP: {jyacc, rna, bklyncis}!amms4!hjg			 |  suggestions?