[comp.sources.bugs] Official patch #3 for popi v2.1 - part 1 of 2.

richb@sunaus.oz (Rich Burridge) (12/27/89)

popi is a program for manipulating digital images. It was posted to
comp.sources.misc earlier this month.

**Note that popi was released to comp.sources.misc at patchlevel #2**

Patch #3 is included in the shar file below along with two new files:

        popi.man - this is a plain text version of the popi manual
                   page (popi.1) for those people who do not have
                   the ability to format popi.1.

        hp.c     - a graphics driver for an HP display from Eric
                   Haines - 3D/Eye Inc, Ithaca, NY.

Use Larry Walls patch program to apply these changes and then recompile.

    Rich Burridge & Stephen Frede.

Rich Burridge,          DOMAIN: richb@sunaus.oz.au
PHONE: +61 2 413 2666   UUCP:   {uunet,mcvax,ukc}!munnari!sunaus.oz!richb

Stephen Frede,          DOMAIN: stephenf@softway.oz.au
PHONE: +61 2 698 2322   UUCP:   {uunet,mcvax,ukc}!munnari!softway.oz!stephenf

---- Cut Here and unpack ----
#!/bin/sh
# shar:	Shell Archiver  (v1.22)
#	Packed Wed Dec 27 12:21:28 EST 1989 by stard!richb
#	from directory /usr/richb/popi
#
# This is part 1 of a multipart archive                                    
# do not concatenate these parts, unpack them in order with /bin/sh        
#
#	Run the following text with /bin/sh to create:
#	  patch.3
#	  hp.c
#	  popi.man
#
if test -r s2_seq_.tmp
then echo "Must unpack archives in sequence!"
     next=`cat s2_seq_.tmp`; echo "Please unpack part $next next"
     exit 1; fi
echo "x - extracting patch.3 (Text)"
sed 's/^X//' << 'SHAR_EOF' > patch.3 &&
XThis is official patch #3 for popi v2.1; please apply it.
X
X**Note that popi was released to comp.sources.misc at patchlevel #2**
X
XIt makes the following changes:
X
X	Checking has been added to prevent constructs such as:
X        dmr[x+1,y+1]=.... causing a segmentation fault.
X
X        The X11 driver has been fixed to correctly display on
X        monochrome screens where the black pixel isn't 1.
X
X        New commands #create and #run have been added.
X
X        ungetc is now handled in the main popi code, so the graphics
X        routine disp_ungetc is no longer needed.
X
X        Fixed a few typos in the manual page.
X
X        Adjusted a few inefficiencies found in expr.c, io.c and main.c
X
X        Several changes to allow a potential change in the image data
X        structure.
X
X
XIt adds the following two files:
X
X        popi.man - this is a plain text version of the popi manual
X                   page (popi.1) for those people who do not have
X                   the ability to format popi.1.
X
X        hp.c     - a graphics driver for an HP display from Eric
X                   Haines - 3D/Eye Inc, Ithaca, NY.
X
X
XKnown problems still to be fixed:
X
X        popi won't compile on an Apollo DN3000 running Domain/OS SR10.1
X        under the bsd4.3 environment. This should be fixed in the next
X        patch.
X
X
XUse Larry Walls patch program to apply these changes and then recompile.
X
X------CUT HERE------patch.3------CUT HERE------
X
X------- x11.c -------
X*** /tmp/da1936	Wed Dec 27 12:13:37 1989
X--- x11.c	Wed Dec 27 11:10:33 1989
X***************
X*** 25,31 ****
X--- 25,36 ----
X  #include <X11/cursorfont.h>
X  #include <X11/keysym.h>
X  
X+ #ifdef   X11R2FONTS
X+ #define  BOLD_FONT    "helvb14"
X+ #else
X  #define  BOLD_FONT    "helvetica-bold-14"
X+ #endif /*X11R2FONTS*/
X+ 
X  #define  DEFFONT      "fixed"
X  #define  NORMAL_FONT  "8x13"
X  
X***************
X*** 136,141 ****
X--- 141,148 ----
X        mpr = XCreatePixmapFromBitmapData(dpy, RootWindow(dpy, screen), mptr,
X                                          Xsize, 1, foregnd, backgnd, scr_depth) ;      free(mptr) ;
X      }
X+   gc_val.function = GXcopy ;
X+   XChangeGC(dpy, gc, GCFunction, &gc_val) ;
X    XCopyArea(dpy, mpr, frame, gc, 0, 0, Xsize, 1, 0, y+100) ;
X    XFreePixmap(dpy, mpr) ;
X  }
X***************
X*** 168,179 ****
X  int x, y ;
X  char *str ;
X  {
X!        if (fontno == NFONT) font = nfont ;
X    else if (fontno == BFONT) font = bfont ;
X    gc_val.font = font->fid ;
X!   gc_val.function = GXcopy ;
X    XChangeGC(dpy, gc, GCFont | GCFunction, &gc_val) ;
X!   XDrawString(dpy, frame, gc, x, y, str, strlen(str)) ;
X  }
X  
X  
X--- 175,190 ----
X  int x, y ;
X  char *str ;
X  {
X!   int len = strlen(str) ;
X! 
X!   if (str[len-1] == '\n') len-- ;
X! 
X!      if (fontno == NFONT) font = nfont ;
X    else if (fontno == BFONT) font = bfont ;
X    gc_val.font = font->fid ;
X!   gc_val.function = GXset ;
X    XChangeGC(dpy, gc, GCFont | GCFunction, &gc_val) ;
X!   XDrawString(dpy, frame, gc, x, y, str, len) ;
X  }
X  
X  
X
X------- popi.h -------
X*** /tmp/da1939	Wed Dec 27 12:13:38 1989
X--- popi.h	Wed Dec 27 10:50:16 1989
X***************
X*** 38,43 ****
X--- 38,52 ----
X  # define STDC	1
X  #endif	/* __STDC__ || __TURBOC__ || __MSC__ */
X  
X+ /*
X+  *	For all function declarations, if ANSI then use a prototype.
X+  */
X+ #if	defined(STDC)
X+ # define P(args)	args
X+ #else	/* ! STDC */
X+ # define P(args)	()
X+ #endif	/* STDC */
X+ 
X  #if defined(STDC) && ! defined(apollo)
X  
X  # include <stdlib.h>
X***************
X*** 50,58 ****
X   * we can't #define away) as part of the type.
X   */
X  extern char
X! 	    *malloc(),
X! 	    *getenv(),
X  # ifdef	   BSD
X  	    *sprintf();
X  # endif  /* BSD */
X  #endif	/* STDC && !apollo */
X--- 59,68 ----
X   * we can't #define away) as part of the type.
X   */
X  extern char
X! 	    *malloc P((unsigned int)),
X! 	    *getenv P((char *));
X  # ifdef	   BSD
X+ extern char
X  	    *sprintf();
X  # endif  /* BSD */
X  #endif	/* STDC && !apollo */
X***************
X*** 63,77 ****
X  # include <strings.h>
X  #endif	/* STDC || ! BSD */
X  
X- /*
X-  *	For all function declarations, if ANSI then use a prototype.
X-  */
X- #if	defined(STDC)
X- # define P(args)	args
X- #else	/* ! STDC */
X- # define P(args)	()
X- #endif	/* STDC */
X- 
X  #ifndef	FILE
X  # include	<stdio.h>
X  #endif	/* FILE */
X--- 73,78 ----
X***************
X*** 101,106 ****
X--- 102,111 ----
X  	log P((double)),
X  	sqrt P((double));
X  
X+ #ifndef	MAXPATHLEN
X+ # define MAXPATHLEN	1024
X+ #endif /* MAXPATHLEN */
X+ 
X  #define NELS(arr)	(sizeof (arr) / sizeof (*(arr)))
X  
X  #define DtoR(degrees)	((degrees) * M_PI * 2.0 / 360.0)
X***************
X*** 127,133 ****
X  
X  typedef long		stack_t;
X  typedef long		parse_t;
X! typedef unsigned char	pixel_t;
X  typedef int		bool;
X  
X  #ifndef	FALSE
X--- 132,140 ----
X  
X  typedef long		stack_t;
X  typedef long		parse_t;
X! typedef unsigned char	pixel_t;	/* A pixel value */
X! typedef pixel_t		*line_t;	/* A scanline (array of pixels) */
X! typedef line_t		*image_t;	/* An image (array of scanlines) */
X  typedef int		bool;
X  
X  #ifndef	FALSE
X***************
X*** 144,150 ****
X  #define FPUTS		(void) fputs
X  #define FREAD    	(void) fread
X  #define FWRITE   	(void) fwrite
X- #define IOCTL           (void) ioctl
X  #define PCLOSE		(void) pclose
X  #define PRINTF   	(void) printf
X  #define PUTC            (void) putc
X--- 151,156 ----
X***************
X*** 156,162 ****
X  #define STRNCAT		(void) strncat
X  #define STRNCPY		(void) strncpy
X  #define UNGETC   	(void) ungetc
X- #define WRITE           (void) write
X  
X  #ifndef LINT_CAST
X  #ifdef lint
X--- 162,167 ----
X***************
X*** 282,287 ****
X--- 287,293 ----
X  extern char	*Emalloc P((unsigned int));
X  extern void	PrStrs P((char **));
X  extern void	version P((void));
X+ extern void	Quit P((void));
X  
X  /* io.c */
X  extern pixel_t	**ImgAlloc P((void));
X***************
X*** 300,306 ****
X  extern void	pushback P((int));
X  
X  /* expr.c */
X! extern void	transform P((void));
X  
X  /* special.c */
X  extern void	help P((void));
X--- 306,312 ----
X  extern void	pushback P((int));
X  
X  /* expr.c */
X! extern void	parse P((FILE *));
X  
X  /* special.c */
X  extern void	help P((void));
X***************
X*** 336,347 ****
X  
X  extern FILE *Debug ;           /* Debugging stream */
X  extern FILE *LogStr ;          /* command logging stream */
X  
X  extern double lexfract ;
X  
X- extern short CUROLD ;
X- extern short CURNEW ;
X- 
X  extern long parsed[] ;
X  
X  extern int CharPos ;           /* Position in input line. */
X--- 342,351 ----
X  
X  extern FILE *Debug ;           /* Debugging stream */
X  extern FILE *LogStr ;          /* command logging stream */
X+ extern FILE *InputStream ;	/* Current input stream. */
X  
X  extern double lexfract ;
X  
X  extern long parsed[] ;
X  
X  extern int CharPos ;           /* Position in input line. */
X***************
X*** 355,361 ****
X  extern int lat ;          /* Lookahead token. */
X  extern int lexval ;
X  extern int noerr ;        /* Indicates if an error has occured. */
X! extern int nsrc ;
X  extern int prs ;
X  extern short *rvals ;
X  extern int Verbose ;
X--- 359,365 ----
X  extern int lat ;          /* Lookahead token. */
X  extern int lexval ;
X  extern int noerr ;        /* Indicates if an error has occured. */
X! extern int nimages ;
X  extern int prs ;
X  extern short *rvals ;
X  extern int Verbose ;
X***************
X*** 362,368 ****
X  extern void Skip() ;
X  extern int Truncate ;
X  
X! extern struct SRC src[MAXIMG] ;
X  
X  extern int disp_active ;       /* Display results after each operation. */
X  
X--- 366,375 ----
X  extern void Skip() ;
X  extern int Truncate ;
X  
X! extern struct SRC
X! 		Images[MAXIMG],
X! 		*CurOld,
X! 		*CurNew;
X  
X  extern int disp_active ;       /* Display results after each operation. */
X  
X
X------- Makefile -------
X*** /tmp/da1942	Wed Dec 27 12:13:39 1989
X--- Makefile	Wed Dec 27 11:21:54 1989
X***************
X*** 24,29 ****
X--- 24,30 ----
X  #  different systems. These have been isolated here, and should
X  #  be uncommented if needed.
X  #
X+ #-------------------------------------------------------------------
X  #  If you are running under BSD unix, uncomment the two lines:
X  #
X  SYS		= -DBSD
X***************
X*** 38,43 ****
X--- 39,45 ----
X  #
X  #SYS		= -DSYSV
X  #
X+ #---------------------------------------------------------------------
X  #  If you not running under a BSD4.[12] derived system, the parameters
X  #  to the select call are different, and this definition should be
X  #  uncommented. You need to uncomment this for SunOS v3.x.
X***************
X*** 44,49 ****
X--- 46,52 ----
X  #
X  #SELTYPE	= -DNO_4_3SELECT
X  #
X+ #---------------------------------------------------------------------
X  #  Most existing versions of unix use a pointer to a function
X  #  returning an integer as the return type of signal(). Newer systems
X  #  use pointer to function returning void. If this is the case,
X***************
X*** 51,56 ****
X--- 54,65 ----
X  #
X  #SIGRET         = -DSIGRET=void
X  #
X+ #---------------------------------------------------------------------
X+ #  If you are running X11R2 then you need to uncomment the following
X+ #  definition to get the correct bold font.
X+ #
X+ #X11R2FONTS     = -DX11R2FONTS
X+ #
X  #  If you are running X11R2 on a Sun4, then the popi executable
X  #  needs to be statically linked to work correctly, so the following
X  #  line should be uncommented.
X***************
X*** 57,79 ****
X  #
X  #LDX11FLAGS     = -Bstatic
X  #
X  #  The X11 include directory should be specified here if required
X  #
X! #X11HOME		= /home/openwin
X! #X11INCDIR	= -I$(X11HOME)/include
X  #
X  #  If you are compiling the MGR version, then the following
X  #  definitions should be uncommented.
X  #
X! #MGRHOME        = /usr/mgr
X  #MGRPARAM        = -DMGRHOME=\"$(MGRHOME)\"
X  #MGRINCDIR       = -I$(MGRHOME)/include
X  #
X  #  If you are compiling the NeWS version, then you need to uncomment
X  #  the following line.
X  #
X  #NEWSFILE        = -DNEWSGIVEN -DNEWSFILE=\"$(LIBDIR)/popi.ps\"
X  #
X  #  If you are compiling the XView version, then the following two lines
X  #  should be uncommented.
X  #
X--- 66,92 ----
X  #
X  #LDX11FLAGS     = -Bstatic
X  #
X+ #---------------------------------------------------------------------
X  #  The X11 include directory should be specified here if required
X  #
X! #X11HOME         = /home/openwin
X! #X11INCDIR       = -I$(X11HOME)/include
X  #
X+ #---------------------------------------------------------------------
X  #  If you are compiling the MGR version, then the following
X  #  definitions should be uncommented.
X  #
X! #MGRHOME         = /usr/mgr
X  #MGRPARAM        = -DMGRHOME=\"$(MGRHOME)\"
X  #MGRINCDIR       = -I$(MGRHOME)/include
X  #
X+ #---------------------------------------------------------------------
X  #  If you are compiling the NeWS version, then you need to uncomment
X  #  the following line.
X  #
X  #NEWSFILE        = -DNEWSGIVEN -DNEWSFILE=\"$(LIBDIR)/popi.ps\"
X  #
X+ #----------------------------------------------------------------------
X  #  If you are compiling the XView version, then the following two lines
X  #  should be uncommented.
X  #
X***************
X*** 80,90 ****
X--- 93,105 ----
X  #XVIEWINCDIR      = -I$(XVIEWHOME)/include
X  #XVIEWLIBDIR      = -L$(XVIEWHOME)/lib
X  #
X+ #----------------------------------------------------------------------
X  #  If you are running on a Sun and you have some kind of floating
X  #  point co-processor, then uncomment this line, and set accordingly.
X  #
X  #SUNFLOAT             = -fswitch
X  #
X+ #----------------------------------------------------------------------
X  #  If you are running Dynix (sequent) compatible parallel make,
X  #  uncomment the following line.
X  #
X***************
X*** 96,103 ****
X  #PLIB		= -lpps
X  #PFLAGS		= -Y -DSEQPAR
X  #
X! #
X  #  Name of your favourite C compiler
X  #	Standard unix
X  CC		= cc
X  #	Gnu C
X--- 111,121 ----
X  #PLIB		= -lpps
X  #PFLAGS		= -Y -DSEQPAR
X  #
X! #----------------------------------------------------------------------
X  #  Name of your favourite C compiler
X+ #  But note that if you are using a microsoft product, their
X+ #  version of make won't work with this makefile. Use another
X+ #  version of make, or use "popi.mak" with microsoft make.
X  #	Standard unix
X  CC		= cc
X  #	Gnu C
X***************
X*** 113,118 ****
X--- 131,137 ----
X  #	Lattice C for Amiga or DOS
X  #CC		= lc
X  #
X+ #---------------------------------------------------------------------
X  #  Suffix used for object files
X  #	Normal
X  O		= o
X***************
X*** 121,126 ****
X--- 140,146 ----
X  #	Mix Power C
X  #O		= mix
X  #
X+ #---------------------------------------------------------------------
X  #  Suffix (including the `.') for executable files
X  #	Normal
X  E		=
X***************
X*** 133,138 ****
X--- 153,159 ----
X  #	Turbo C (must not have a trailing space)
X  #EXE		= -e
X  #
X+ #---------------------------------------------------------------------
X  #  Your system remove command
X  #	Standard unix
X  RM		= rm -f
X***************
X*** 141,146 ****
X--- 162,168 ----
X  #	Amiga
X  #RM		= delete
X  #
X+ #---------------------------------------------------------------------
X  #  Your system copy command
X  #	Standard unix
X  CP		= cp
X***************
X*** 147,156 ****
X  #	DOS and Amiga
X  #CP		= copy
X  #
X! #
X  #  Specify any flags to be used with your C compiler.
X  #	Standard unix
X  OCFLAGS		= -g
X  #	Turbo C (also set BGIPATH to the location of your .bgi files)
X  #OCFLAGS		= -DBGIPATH=c:\\util\\tc\\bgi -G -O -Z -d -v -w
X  #	Microsoft Quick C
X--- 169,180 ----
X  #	DOS and Amiga
X  #CP		= copy
X  #
X! #---------------------------------------------------------------------
X  #  Specify any flags to be used with your C compiler.
X  #	Standard unix
X  OCFLAGS		= -g
X+ #	HP/UX
X+ #OCFLAGS		= +bfpa
X  #	Turbo C (also set BGIPATH to the location of your .bgi files)
X  #OCFLAGS		= -DBGIPATH=c:\\util\\tc\\bgi -G -O -Z -d -v -w
X  #	Microsoft Quick C
X***************
X*** 160,178 ****
X  #	Lattice C for Amiga (ansi compliance, winge, fast FP).
X  #OCFLAGS		= -caf -ff
X  #
X  #  Specify any extra flags to be passed to the linker
X  OLDFLAGS	=
X  #
X  #-------------------------------------------------------------------
X  
X! BINARIES	= apollo_popi atari_popi mgr_popi null_popi ps_popi sv_popi \
X! 		  x11_popi xv_popi
X  BINDIR          = /usr/local/bin
X  LIBDIR          = /usr/local/lib
X  MANDIR          = /usr/man/man$(MANSECT)
X  MANSECT         = l
X  CFLAGS		= $(OCFLAGS) $(SYS) $(SELTYPE) $(SIGRET) $(X11INCDIR) \
X! 		    $(NEWSFILE) $(MGRPARAM) $(MGRINCDIR) \
X  		    $(XVIEWINCDIR) $(PFLAGS)
X  LDFLAGS         = $(OLDFLAGS) $(LDX11FLAGS)
X  HDRS		= popi.h graphics.h
X--- 184,203 ----
X  #	Lattice C for Amiga (ansi compliance, winge, fast FP).
X  #OCFLAGS		= -caf -ff
X  #
X+ #--------------------------------------------------------------------
X  #  Specify any extra flags to be passed to the linker
X  OLDFLAGS	=
X  #
X  #-------------------------------------------------------------------
X  
X! BINARIES	= apollo_popi atari_popi hp_popi mgr_popi null_popi \
X! 		  ps_popi sv_popi x11_popi xv_popi
X  BINDIR          = /usr/local/bin
X  LIBDIR          = /usr/local/lib
X  MANDIR          = /usr/man/man$(MANSECT)
X  MANSECT         = l
X  CFLAGS		= $(OCFLAGS) $(SYS) $(SELTYPE) $(SIGRET) $(X11INCDIR) \
X! 		    $(X11R2FONTS) $(NEWSFILE) $(MGRPARAM) $(MGRINCDIR) \
X  		    $(XVIEWINCDIR) $(PFLAGS)
X  LDFLAGS         = $(OLDFLAGS) $(LDX11FLAGS)
X  HDRS		= popi.h graphics.h
X***************
X*** 181,187 ****
X  		  special.$(O)
X  LIBS		= -lm $(PLIB)
X  STDSRCS		= expr.c io.c lex.c main.c polar.c run.c special.c
X! OTHERSRCS1	= amiga.c apollo.c atariterm.c graphics.c kerterm.c mgr.c
X  OTHERSRCS2	= news.c nulldev.c ibmpc.c sunview.c x11.c xview.c popi.ps
X  
X  OTHERSRCS       = $(OTHERSRCS1) $(OTHERSRCS2)
X--- 206,212 ----
X  		  special.$(O)
X  LIBS		= -lm $(PLIB)
X  STDSRCS		= expr.c io.c lex.c main.c polar.c run.c special.c
X! OTHERSRCS1	= amiga.c apollo.c atariterm.c graphics.c hp.c kerterm.c mgr.c
X  OTHERSRCS2	= news.c nulldev.c ibmpc.c sunview.c x11.c xview.c popi.ps
X  
X  OTHERSRCS       = $(OTHERSRCS1) $(OTHERSRCS2)
X***************
X*** 199,204 ****
X--- 224,233 ----
X  ATARIOBJS       = $(STDOBJS) atariterm.$(O)
X  ATARISRCS       = $(STDSRCS) atariterm.c
X  
X+ HPLIBS		= $(LIBS) -ldd98731 -ldd98730 -lsb1 -lsb2 -lm -lmalloc
X+ HPOBJS		= $(STDOBJS) hp.$(O)
X+ HPSRCS		= $(STDSRCS) hp.c
X+ 
X  IBMPCLIBS	= $(LIBS)
X  IBMPCOBJS	= $(STDOBJS) ibmpc.$(O)
X  IBMPCSRCS	= $(STDSRCS) ibmpc.c
X***************
X*** 243,248 ****
X--- 272,278 ----
X  		@echo make amiga      - to make the Amiga version.
X  		@echo make apollo     - to make the Apollo version.
X  		@echo make atari      - to make the Atari version.
X+ 		@echo make hp         - to make the HP version.
X  		@echo make ibmpc      - to make the PC version.
X  		@echo make kermit     - to make the Kermit version.
X  		@echo make mgr        - to make the MGR version.
X***************
X*** 265,270 ****
X--- 295,303 ----
X  atari:          atari_popi$(E)
X  		$(CP) atari_popi$(E) $(TARGET)
X  
X+ hp:		hp_popi$(E)
X+ 		$(CP) hp_popi$(E) $(TARGET)
X+ 
X  ibmpc:		ibmpc_popi$(E)
X  		$(CP) ibmpc_popi$(E) $(TARGET)
X  
X***************
X*** 298,303 ****
X--- 331,339 ----
X  atari_popi$(E):$(P)   $(ATARIOBJS)
X  		$(CC) $(EXE)atari_popi $(LDFLAGS) $(ATARIOBJS) $(ATARILIBS)
X  
X+ hp_popi$(E):	$(HPOBJS)
X+ 		$(CC) $(EXE)hp_popi $(LDFLAGS) $(HPOBJS) $(HPLIBS)
X+ 
X  ibmpc_popi$(E):	$(IBMPCOBJS)
X  		$(CC) $(EXE)ibmpc_popi $(LDFLAGS) $(IBMPCOBJS) $(IBMPCLIBS)
X  
X***************
X*** 382,387 ****
X--- 418,424 ----
X  atariterm.$(O):	atariterm.c $(HDRS)
X  expr.$(O):	expr.c $(HDRS)
X  graphics.$(O):	graphics.c $(HDRS)
X+ hp.$(O):	hp.c $(HDRS)
X  io.$(O):	io.c $(HDRS)
X  kerterm.$(O):	kerterm.c $(HDRS)
X  lex.$(O):	lex.c $(HDRS)
X
X------- README -------
X*** /tmp/da1945	Wed Dec 27 12:13:41 1989
X--- README	Wed Dec 27 11:51:20 1989
X***************
X*** 21,26 ****
X--- 21,27 ----
X  	    images.
X  	Apollo
X  	Atari terminal
X+ 	Hewlett Packard
X  	Kermit terminal
X  	MGR
X  	NeWS
X***************
X*** 83,89 ****
X  	Tim Lambert for the Apollo driver;
X  	Mark Andrews and Andrew Nicholson for help with the NeWS driver;
X  	Frank Crawford for the kermit terminal driver;
X! 	Peter Chubb for the Amiga work.
X  
X  Please pass suggestions for further improvement, comments, bugs and
X  flames back to me (Rich), at the address below, and I'll forward the
X--- 84,96 ----
X  	Tim Lambert for the Apollo driver;
X  	Mark Andrews and Andrew Nicholson for help with the NeWS driver;
X  	Frank Crawford for the kermit terminal driver;
X! 	Peter Chubb for the Amiga work;
X! 	Eric Haines for the HP driver.
X! 
X! Also thanks to Tor Lillqvist for fixing up the X11 driver to work with an
X! HP9000 Series 300 workstation (which incidentally fixes it to work on NCD
X! terminals), to Eric Haines for spotting several minor inefficiencies in
X! the popi code, and to Tim Born and Ed Falk for bug reports and/or fixes.
X  
X  Please pass suggestions for further improvement, comments, bugs and
X  flames back to me (Rich), at the address below, and I'll forward the
X
X------- popi.1 -------
X*** /tmp/da1948	Wed Dec 27 12:13:42 1989
X--- popi.1	Wed Dec 27 11:46:37 1989
X***************
X*** 1,6 ****
X  .\" %Z%%M% %I% %E%
X  .\"OPTIONS man
X! .TH POPI 1L "12 December 1989"
X  .tr @"
X  .\"These macros always explicitly return to font 1, rather than the
X  .\"previous font, because previous may have been altered.
X--- 1,6 ----
X  .\" %Z%%M% %I% %E%
X  .\"OPTIONS man
X! .TH POPI 1L "20 December 1989"
X  .tr @"
X  .\"These macros always explicitly return to font 1, rather than the
X  .\"previous font, because previous may have been altered.
X***************
X*** 488,493 ****
X--- 488,496 ----
X  .CW "(Z+1)" .
X  This is the default.
X  .TP
X+ .CW "#truncate"
X+ Report whether truncation is currently in effect or not.
X+ .TP
X  .CW "#verbose +"
X  Turn on verbose mode.
X  Equivalent to the
X***************
X*** 496,504 ****
X  This turns on the "percent done" feature of some drivers (on
X  others it is always active).
X  .TP
X- .CW "#truncate"
X- Report whether truncation is currently in effect or not.
X- .TP
X  .CW "#verbose \-"
X  Turn off verbose mode.
X  Equivalent to the
X--- 499,504 ----
X***************
X*** 524,529 ****
X--- 524,537 ----
X  All user input is logged, along with error messages and some
X  program responses.
X  .TP
X+ .CW "#create \f2imagename\fP"
X+ Memory is allocated for a new image. This image is then
X+ swapped with the current image (the result of the last
X+ transformation).
X+ .TP
X+ .CW "#run @\f2filename\fP@"
X+ Commands are read and executed from the given filename.
X+ .TP
X  .CW "#free \f2imagename\fP"
X  The memory associated with the named image is freed.
X  Any further access to this image becomes impossible.
X***************
X*** 764,770 ****
X  when viewed up close, but from a distance of a few metres it
X  will resolve into the original.
X  .C
X! new[x,y] = old{r, a + old{r,a)/8}  ; page 68
X  .E
X  This image is a swirl, but with the skew dependant on the
X  brightness of the current point.
X--- 772,778 ----
X  when viewed up close, but from a distance of a few metres it
X  will resolve into the original.
X  .C
X! new[x,y] = old{r, a + old{r,a}/8}  ; page 68
X  .E
X  This image is a swirl, but with the skew dependant on the
X  brightness of the current point.
X***************
X*** 857,862 ****
X--- 865,872 ----
X  .br
X  Apollo driver by
X  Tim Lambert, University of New South Wales.
X+ .br
X+ HP driver by Eric Haines, 3D/Eye Inc, Ithaca, NY.
X  .SH BUGS
X  Functions which require popen() (ie auto reading of compressed
X  files and writing to pipes) don't work in the sequent
X
X------- patchlevel.h -------
X*** /tmp/da1951	Wed Dec 27 12:13:43 1989
X--- patchlevel.h	Wed Dec 27 10:35:53 1989
X***************
X*** 16,19 ****
X   *  (see README file) then an attempt will be made to fix them.
X   */
X  
X! #define  PATCHLEVEL  2
X--- 16,19 ----
X   *  (see README file) then an attempt will be made to fix them.
X   */
X  
X! #define  PATCHLEVEL  3
X
X------- expr.c -------
X*** /tmp/da1954	Wed Dec 27 12:13:44 1989
X--- expr.c	Wed Dec 27 10:42:38 1989
X***************
X*** 30,36 ****
X  	factor P((void)),
X  	fileref P((int, int)),
X  	expect P((int)),
X! 	emit P((int));
X  
X  #define	MAX_SAME_PREC	5	/* max length row of op[], +1 */
X  
X--- 30,37 ----
X  	factor P((void)),
X  	fileref P((int, int)),
X  	expect P((int)),
X! 	emit P((int)),
X! 	transform P((void));
X  
X  #define	MAX_SAME_PREC	5	/* max length row of op[], +1 */
X  
X***************
X*** 87,98 ****
X  {
X      DEBUG((Debug, "fileref(val=%d, tok=%d)\n", val, tok));
X  
X!     if (val < 0 || val >= nsrc || src[val].str == (char *) 0)
X      {
X  	SPRINTF(ErrBuf, "bad file number: %d", val - 1);
X  	error(ERR_PARSE);
X      }
X  
X      emit(VALUE);
X      emit(val);
X      if (lat == '[')
X--- 88,101 ----
X  {
X      DEBUG((Debug, "fileref(val=%d, tok=%d)\n", val, tok));
X  
X!     if (val < 0 || val >= nimages || Images[val].str == (char *) 0)
X      {
X  	SPRINTF(ErrBuf, "bad file number: %d", val - 1);
X  	error(ERR_PARSE);
X      }
X  
X+     DEBUG((Debug, "fileref name='%s'\n", Images[val].str));
X+ 
X      emit(VALUE);
X      emit(val);
X      if (lat == '[')
X***************
X*** 146,152 ****
X  static void
X  factor()
X  {
X-     int n;
X      int	token;
X  
X      DEBUG((Debug, "factor() lat='%c'\n", lat));
X--- 149,154 ----
X***************
X*** 187,201 ****
X  	    break;
X  
X  	case INAME:
X- 	    n = lexval;
X  	    lex();
X! 	    fileref(n+1, CRVAL);
X  	    break;
X  
X  	case '$':
X  	    lex();
X  	    expect(VALUE);
X! 	    fileref(lexval+1, CRVAL);
X  	    break;
X  
X  	case VALUE:
X--- 189,203 ----
X  	    break;
X  
X  	case INAME:
X  	    lex();
X! 	    fileref(lexval, CRVAL);
X  	    break;
X  
X  	case '$':
X  	    lex();
X  	    expect(VALUE);
X! 	    /* $1 refers to Images[2] */
X! 	    fileref(lexval-1+2, CRVAL);
X  	    break;
X  
X  	case VALUE:
X***************
X*** 477,483 ****
X   *		|	NEW '=' expr
X   *		|	expr
X   */
X! void
X  transform()
X  {
X      extern int prs;
X--- 479,485 ----
X   *		|	NEW '=' expr
X   *		|	expr
X   */
X! static void
X  transform()
X  {
X      extern int prs;
X***************
X*** 485,490 ****
X--- 487,493 ----
X      DEBUG((Debug, "transform() lat='%c'\n", lat));
X  
X      prs = 0 ;     /* initial length of parse string */
X+     DEBUG((Debug, "lat=%d, NEW=%d, lat!=NEW = %d\n", lat, NEW, lat != NEW));
X      if (lat != NEW)
X      {
X  	expr();
X***************
X*** 495,501 ****
X  	lex();
X  	if (lat == '[')
X  	{
X! 	    fileref(CURNEW, CLVAL);
X  	    expect('=');
X  	    expr();
X  	    emit('=');
X--- 498,504 ----
X  	lex();
X  	if (lat == '[')
X  	{
X! 	    fileref(CurNew - Images, CLVAL);
X  	    expect('=');
X  	    expr();
X  	    emit('=');
X***************
X*** 514,517 ****
X--- 517,589 ----
X  	error(ERR_PARSE);
X      }
X      assert(lat == '\n');
X+ }
X+ 
X+ 
X+ /*
X+  * Parse	= # special
X+  *		| '?'				help
X+  *		| 'q'				quit
X+  *		| transform			transformation expression
X+  */
X+ void
X+ parse(istr)
X+ FILE	*istr;
X+ {
X+     extern int	lat;     	/* look ahead token */
X+     FILE	*SaveInput;	/* Saved previous input stream. */
X+ 
X+     DEBUG((Debug, "parse()\n"));
X+ 
X+     /* Save and then reset current input stream. */
X+     SaveInput = InputStream;
X+     InputStream = istr;
X+ 
X+     do
X+     {
X+ 	DEBUG((Debug, "parse() - top of loop\n"));
X+ 	noerr = TRUE;
X+ 	/* Display popi prompt and clear input line.
X+ 	 * Returns length of popi prompt.
X+ 	 */
X+ 	CharPos = istr ? 0 : disp_prompt();
X+ 
X+ 	if (LogStr)
X+ 	{
X+ 	    FPRINTF(LogStr, "-> ");
X+ 	    FFLUSH(LogStr);
X+ 	}
X+ 
X+ 	lex();
X+ 
X+ 	switch (lat)
X+ 	{
X+ 	    case '#':
X+ 	        special();
X+ 	        break;
X+ 
X+ 	    case '?':
X+ 	        help();
X+ 	        Skip();
X+ 	        break;
X+ 
X+ 	    case 'q':
X+ 	        Quit();
X+ 	        /* NOTREACHED */
X+ 
X+ 	    case EOF:
X+ 	    case '\n':
X+ 	        break;
X+ 
X+ 	    default:
X+ 	        transform();
X+ 	        if (noerr)
X+ 		    run();
X+ 	        break;
X+ 	}
X+ 	assert(lat == '\n' || lat == EOF);
X+     } while (lat != EOF);
X+ 
X+     /* Restore saved previous input stream. */
X+     InputStream = SaveInput;
X  }
X
X------- io.c -------
X*** /tmp/da1957	Wed Dec 27 12:13:45 1989
X--- io.c	Wed Dec 27 12:01:23 1989
X***************
X*** 29,62 ****
X  #define WMODE	"wb"
X  #endif	/* unix || AMIGA */
X  
X! int		nsrc = 2;
X! static int	IsPopen = 0;
X  
X  pixel_t **
X  ImgAlloc()
X  {
X!     int			y;
X!     pixel_t		**p;
X  
X!     noerr = 1;
X!     if ((p = (pixel_t **) LINT_CAST(Emalloc((unsigned)Xsize * sizeof(pixel_t *)))) == 0)
X  	return (pixel_t **) 0;
X  
X!     for (y = 0; y < Ysize; ++y)
X! 	p[y] = (pixel_t *) Emalloc((unsigned)Xsize * sizeof (pixel_t));
X  
X!     if (noerr == 0)
X      {
X  	/* Run out of memory; free what we have allocated */
X! 	for (y = 0; y < Ysize; ++y)
X  	{
X! 	    if (p[y])
X! 		free((char *) p[y]);
X  	}
X  	return (pixel_t **) 0;
X      }
X  
X!     return p;
X  }
X  
X  void
X--- 29,66 ----
X  #define WMODE	"wb"
X  #endif	/* unix || AMIGA */
X  
X! #if	defined(unix)
X! static bool	IsPopen = FALSE;
X! #endif	/* unix */
X! int		nimages = 2;
X  
X  pixel_t **
X  ImgAlloc()
X  {
X!     pixel_t		**img,
X!     			**linep,
X! 			**imgend;
X  
X!     noerr = TRUE;
X!     if ((img = (pixel_t **) LINT_CAST(Emalloc((unsigned)Xsize * sizeof(pixel_t *)))) == 0)
X  	return (pixel_t **) 0;
X  
X!     imgend = &img[Ysize];
X!     for (linep = img; linep != imgend; ++linep)
X! 	*linep = (pixel_t *) Emalloc((unsigned)Xsize * sizeof (pixel_t));
X  
X!     if (!noerr)
X      {
X  	/* Run out of memory; free what we have allocated */
X! 	for (linep = img; linep != imgend; ++linep)
X  	{
X! 	    if (*linep)
X! 		free((char *) *linep);
X  	}
X  	return (pixel_t **) 0;
X      }
X  
X!     return img;
X  }
X  
X  void
X***************
X*** 82,90 ****
X  Efclose(stream)
X  FILE	*stream;
X  {
X! #if	unix
X      if (IsPopen)
X  	PCLOSE(stream);
X      else
X  #endif	/* unix */
X  	FCLOSE(stream);
X--- 86,97 ----
X  Efclose(stream)
X  FILE	*stream;
X  {
X! #ifdef	unix
X      if (IsPopen)
X+     {
X  	PCLOSE(stream);
X+ 	IsPopen = FALSE;
X+     }
X      else
X  #endif	/* unix */
X  	FCLOSE(stream);
X***************
X*** 100,106 ****
X  #endif /* unix */
X  
X      DEBUG((Debug, "EfopenR(%s)\n", filename));
X-     IsPopen = 0;
X      if ((istr = fopen(filename, RMODE)) != NULL)
X  	return istr;
X  
X--- 107,112 ----
X***************
X*** 107,113 ****
X  #if	unix
X      if (errno == ENOENT)
X      {
X! 	char buf[512];
X  
X  	/* first see if the compressed file exists and is readable */
X  	SPRINTF(buf, "%s.Z", filename);
X--- 113,119 ----
X  #if	unix
X      if (errno == ENOENT)
X      {
X! 	char buf[MAXPATHLEN];
X  
X  	/* first see if the compressed file exists and is readable */
X  	SPRINTF(buf, "%s.Z", filename);
X***************
X*** 119,125 ****
X  	    DEBUG((Debug, "popen(%s)\n", buf));
X  	    if ((istr = popen(buf, "r")) != NULL)
X  	    {
X! 		IsPopen = 1;
X  		return istr;
X  	    }
X  	}
X--- 125,131 ----
X  	    DEBUG((Debug, "popen(%s)\n", buf));
X  	    if ((istr = popen(buf, "r")) != NULL)
X  	    {
X! 		IsPopen = TRUE;
X  		return istr;
X  	    }
X  	}
X***************
X*** 136,147 ****
X  char	*filename;
X  {
X      FILE	*ostr;
X      FILE	*popen();
X  
X      DEBUG((Debug, "EfopenW(%s)\n", filename));
X-     IsPopen = 0;
X  
X! #if	unix
X      if (*filename == '|')
X      {
X  	++filename;
X--- 142,154 ----
X  char	*filename;
X  {
X      FILE	*ostr;
X+ #ifdef	unix
X      FILE	*popen();
X+ #endif	/* unix */
X  
X      DEBUG((Debug, "EfopenW(%s)\n", filename));
X  
X! #ifdef	unix
X      if (*filename == '|')
X      {
X  	++filename;
X***************
X*** 151,156 ****
X--- 158,164 ----
X  	    SPRINTF(ErrBuf, "Can't run command '%s'", filename);
X  	    error(ERR_SYS);
X  	}
X+ 	IsPopen = TRUE;
X  	return ostr;
X      }
X  #endif	/* unix */
X***************
X*** 170,180 ****
X  char	*imgname;			/* image name */
X  {
X      FILE	*fd;
X!     int		y,
X! 		c;
X!     struct SRC	*img = (struct SRC *) 0;	/* work buffer */
X      char	*p,
X  		*rem;
X  
X      if ((fd = EfopenR(filename)) == NULL)
X          return;
X--- 178,189 ----
X  char	*imgname;			/* image name */
X  {
X      FILE	*fd;
X!     struct SRC	*img,				/* Pointer into Images */
X!     		*unused = (struct SRC *) 0;	/* first unused slot */
X      char	*p,
X  		*rem;
X+     pixel_t	**linep,
X+     		**imgend;
X  
X      if ((fd = EfopenR(filename)) == NULL)
X          return;
X***************
X*** 199,215 ****
X      }
X  
X      /* See if the named image already exists */
X!     for (c = 0; c < nsrc; c++)
X! 	if (src[c].str && strcmp(src[c].str, imgname) == 0)
X! 	{
X! 	    img = &src[c];
X  	    break;
X- 	}
X  
X!     if (img == (struct SRC *) 0)
X      {
X! 	/* Allocate a new image */
X!         img = &src[nsrc++];
X  
X  	if
X  	(
X--- 208,230 ----
X      }
X  
X      /* See if the named image already exists */
X!     for (img = Images; img != &Images[nimages]; ++img)
X!     {
X! 	if (img->str && strcmp(img->str, imgname) == 0)
X  	    break;
X  
X! 	if (img->pix == (pixel_t **) 0 && unused == (struct SRC *) 0)
X! 	    unused = img;
X!     }
X! 
X!     if (img == &Images[nimages])
X      {
X! 	/* Named image doesn't exist. */
X! 	/* Allocate a new image. */
X! 	if (unused == (struct SRC *) 0)
X! 	    img = &Images[nimages++];
X! 	else
X! 	    img = unused;
X  
X  	if
X  	(
X***************
X*** 223,234 ****
X      }
X  
X      /* Read in the image */
X!     for (y = 0; y < Ysize; y++)
X      {
X- 	long	total = 0;
X  	int	count;
X  
X! 	if ((count = fread((char *) img->pix[y], 1, Xsize, fd)) <= 0)
X  	{
X  	    if (ferror(fd))
X  	    {
X--- 238,253 ----
X      }
X  
X      /* Read in the image */
X!     long	total = 0;
X!     for (
X! 	linep = img->pix, imgend = &img->pix[Ysize];
X! 	linep != imgend;
X! 	++linep
X! 	)
X      {
X  	int	count;
X  
X! 	if ((count = fread((char *) *linep, 1, Xsize, fd)) <= 0)
X  	{
X  	    if (ferror(fd))
X  	    {
X***************
X*** 255,272 ****
X  }
X  
X  void
X! putpix(into, str)
X! struct SRC *into ;       /* work buffer */
X! char *str ;              /* file name */
X  {
X!     FILE *fd;
X!     int i;
X  
X!     if ((fd = EfopenW(str)) == NULL)
X  	return;
X  
X!     for (i = 0; i < Ysize; i++)
X! 	FWRITE((char *) into->pix[i], 1, Xsize, fd);
X  
X      Efclose(fd);
X  }
X--- 274,296 ----
X  }
X  
X  void
X! putpix(into, filename)
X! struct SRC *into;		/* work buffer */
X! char *filename;			/* file name */
X  {
X!     FILE	*fd;
X!     pixel_t	**linep,	/* pointer to a scanline */
X!     		**imgend;	/* pointer to just after end of image */
X  
X!     if ((fd = EfopenW(filename)) == NULL)
X  	return;
X  
X!     for (
X!     	linep = into->pix, imgend = &into->pix[Ysize];
X! 	linep != imgend;
X! 	++linep
X! 	)
X! 	FWRITE((char *) *linep, 1, Xsize, fd);
X  
X      Efclose(fd);
X  }
X***************
X*** 275,287 ****
X  void
X  showfiles()
X  {
X!     int n;
X  
X!     for (n = 2; n < nsrc; n++)
X! 	if(src[n].str)
X  	{
X! 	    PRINTF("$%d = %s\n", n - 1, src[n].str);
X  	    if (LogStr)
X! 		FPRINTF(LogStr, "$%d = %s\n", n - 1, src[n].str);
X  	}
X  }
X--- 299,318 ----
X  void
X  showfiles()
X  {
X!     struct SRC	*img,
X!     		*endimages;
X  
X!     for (
X! 	img = &Images[2], endimages = &Images[nimages];
X! 	img != endimages;
X! 	++img
X! 	)
X!     {
X! 	if(img->str)
X  	{
X! 	    PRINTF("$%d = %s\n", img - Images - 1, img->str);
X  	    if (LogStr)
X! 		FPRINTF(LogStr, "$%d = %s\n", img - Images + 1, img->str);
X  	}
X+     }
X  }
X
X------- lex.c -------
X*** /tmp/da1960	Wed Dec 27 12:13:46 1989
X--- lex.c	Wed Dec 27 10:46:34 1989
X***************
X*** 31,37 ****
X  	TokPos = 0;	/* position of the beginning of the current token */
X  char	ErrBuf[256];
X  double	lexfract;
X! double	hypot();
X  
X  static int
X  Getch()
X--- 31,39 ----
X  	TokPos = 0;	/* position of the beginning of the current token */
X  char	ErrBuf[256];
X  double	lexfract;
X! FILE	*InputStream = (FILE *) 0;
X! /* One level of character pushback on stdin to avoid disp_ungetc() */
X! char	SaveChar = '\0';
X  
X  static int
X  Getch()
X***************
X*** 38,44 ****
X  {
X      int	c;
X  
X!     c = disp_getchar();
X  
X      OldPos = CharPos;
X  
X--- 40,57 ----
X  {
X      int	c;
X  
X!     if (InputStream == (FILE *) 0)
X!     {
X! 	if (SaveChar == '\0')
X! 	    c = disp_getchar();
X! 	else
X! 	{
X! 	    c = SaveChar;
X! 	    SaveChar = '\0';
X! 	}
X!     }
X!     else
X! 	c = getc(InputStream);
X  
X      OldPos = CharPos;
X  
X***************
X*** 113,118 ****
X--- 126,133 ----
X  {
X      int		c = first;
X      char	*str = text;
X+     struct SRC	*img,
X+     		*endimages;
X  
X      do
X      {
X***************
X*** 133,144 ****
X      else if (strcmp(text, "sqrt") == 0)		return SQRT;
X      else if (strcmp(text, "rand") == 0)		return RAND;
X  
X!     for (c = 0; c < nsrc; c++)
X! 	if (src[c].str && strcmp(src[c].str, text) == 0)
X  	{
X! 	    lexval = c - 1;
X  	    return INAME;
X  	}
X  
X      if (strlen(text) > 1)
X  	return NAME;
X--- 148,165 ----
X      else if (strcmp(text, "sqrt") == 0)		return SQRT;
X      else if (strcmp(text, "rand") == 0)		return RAND;
X  
X!     for (
X! 	img = Images, endimages = &Images[nimages];
X! 	img != endimages;
X! 	++img
X! 	)
X!     {
X! 	if (img->str && strcmp(img->str, text) == 0)
X  	{
X! 	    lexval = img - Images;
X  	    return INAME;
X  	}
X+     }
X  
X      if (strlen(text) > 1)
X  	return NAME;
X***************
X*** 178,187 ****
X  
X      switch (lat)
X      {
X- 	case EOF:
X- 	    lat = 'q';
X- 	    break;
X- 
X  	case '*':
X  	    lat = follow('*', POW, lat);
X  	    break;
X--- 199,204 ----
X***************
X*** 260,265 ****
X--- 277,293 ----
X  	    lat = '\n';
X  	    break;
X  
X+ 	case '\\':	/* Special meaning to next character */
X+ 	    switch (lat = Getch())
X+ 	    {
X+ 	        case '\n':
X+ 		    lex();	/* ignore newline - get next token */
X+ 		    break;
X+ 
X+ 		/* May be other cases here later. */
X+ 	    }
X+ 	    break;
X+ 
X          default:
X  	    break;
X      }
X***************
X*** 278,283 ****
X  int c;
X  {
X      DEBUG((Debug, "pushback('%c')\n", c));
X!     disp_ungetc(c);
X      CharPos = OldPos;
X  }
X--- 306,314 ----
X  int c;
X  {
X      DEBUG((Debug, "pushback('%c')\n", c));
X!     if (InputStream == (FILE *) 0)
X! 	SaveChar = c;
X!     else
X! 	ungetc(c, InputStream);
X      CharPos = OldPos;
X  }
X
X------- main.c -------
X*** /tmp/da1963	Wed Dec 27 12:13:47 1989
X--- main.c	Wed Dec 27 12:01:48 1989
X***************
X*** 23,38 ****
X  
X  /* prototypes for local functions */
X  
X- bool	do_parse P((void));
X  void	get_options P((char **));
X  void	Usage P((int));
X  int	main P((int, char **));
X  
X  struct SRC
X! 	src[MAXIMG];		/* array of images */
X! short	CUROLD = 0;		/* index of "old" image */
X! short	CURNEW = 1;		/* index of "new" image */
X! int	noerr = 1;
X  int	lexval;			/* value of numerical token */
X  int	Xsize = DEF_X,		/* image width */
X  	Ysize = DEF_Y,		/* image height */
X--- 23,37 ----
X  
X  /* prototypes for local functions */
X  
X  void	get_options P((char **));
X  void	Usage P((int));
X  int	main P((int, char **));
X  
X  struct SRC
X! 	Images[MAXIMG],		/* array of images */
X! 	*CurOld,		/* pointer to "old" image */
X! 	*CurNew;		/* pointer to "new" image */
X! int	noerr = TRUE;
X  int	lexval;			/* value of numerical token */
X  int	Xsize = DEF_X,		/* image width */
X  	Ysize = DEF_Y,		/* image height */
X***************
X*** 70,76 ****
X  {
X      char	**p;
X  
X-     p = msg;
X      for (p = msg; *p; ++p)
X  	FPRINTF(stderr, "%s\n", *p);
X  }
X--- 69,74 ----
X***************
X*** 207,216 ****
X          }
X      }
X  
X!     src[CUROLD].pix = ImgAlloc();
X!     src[CUROLD].str = "old";
X!     src[CURNEW].pix = ImgAlloc();
X!     src[CURNEW].str = "new";
X  
X      for (; *argv; ++argv)
X          getpix(*argv, (char *) 0);
X--- 205,216 ----
X          }
X      }
X  
X!     CurOld = &Images[0];
X!     CurNew = &Images[1];
X!     CurOld->pix = ImgAlloc();
X!     CurOld->str = "old";
X!     CurNew->pix = ImgAlloc();
X!     CurNew->str = "new";
X  
X      for (; *argv; ++argv)
X          getpix(*argv, (char *) 0);
X***************
X*** 218,272 ****
X  
X  
X  /*
X-  * Parse	= # special
X-  *		| '?'				help
X-  *		| 'q'				quit
X-  */
X- static bool
X- do_parse()
X- {
X-     extern int lat ;     /* look ahead token */
X- 
X-     /* display popi prompt and clear input line. Returns length of popi prompt. */
X-     CharPos = disp_prompt();
X- 
X-     if (LogStr)
X-     {
X- 	FPRINTF(LogStr, "-> ");
X- 	FFLUSH(LogStr);
X-     }
X- 
X-     lex();
X- 
X-     switch (lat)
X-     {
X- 	case '#':
X- 	    special();
X- 	    break;
X- 
X- 	case '?':
X- 	    help();
X- 	    Skip();
X- 	    break;
X- 
X- 	case 'q':
X- 	    return FALSE;
X- 
X- 	case '\n':
X- 	    break;
X- 
X- 	default:
X- 	    transform();
X- 	    if (noerr)
X- 		run();
X- 	    break;
X-     }
X-     assert(lat == '\n');
X-     return TRUE;
X- }
X- 
X- 
X- /*
X   *	We deliberately don't exit on error here.
X   *	The user may have some picture that has taken ages to develop.
X   *	If we run out of memory, they have a chance to save the
X--- 218,223 ----
X***************
X*** 293,298 ****
X--- 244,257 ----
X      return try;
X  }
X  
X+ void
X+ Quit()
X+ {
X+     disp_finish();
X+ 
X+     exit(0);
X+ }
X+ 
X  main(argc,argv)
X  int argc;
X  char **argv;
X***************
X*** 304,318 ****
X      m_set_procs(ncpus);
X  #endif /* SEQPAR */
X  
X!     do
X! 	noerr = TRUE;
X!     while (do_parse());
X  
X!     disp_finish();
X  
X- 	/* Some compilers don't get the exit status right when
X- 	 * you return from main()
X- 	 */
X-     exit(0);
X      return 0;	/* shut up warning messages from some compilers */
X  }
X--- 263,271 ----
X      m_set_procs(ncpus);
X  #endif /* SEQPAR */
X  
X!     parse((FILE *) 0);
X  
X!     Quit();
X  
X      return 0;	/* shut up warning messages from some compilers */
X  }
X
X------- run.c -------
X*** /tmp/da1966	Wed Dec 27 12:13:48 1989
X--- run.c	Wed Dec 27 10:51:09 1989
X***************
X*** 31,38 ****
X  void
X  SwapOldNew()
X  {
X!     CUROLD = CURNEW;
X!     CURNEW = 1 - CUROLD;
X  }
X  
X  static void
X--- 31,41 ----
X  void
X  SwapOldNew()
X  {
X!     struct SRC	*tmp;
X! 
X!     tmp = CurOld;
X!     CurOld = CurNew;
X!     CurNew = tmp;
X  }
X  
X  static void
X***************
X*** 68,82 ****
X  	short	*ap,		/* precalculated polar angles */
X  		*rp;		/* precalculated polar radius */
X  	register pixel_t
X! 		*p;		/* default destination */
X  
X  	ap = &avals[y * Xsize];
X  	rp = &rvals[y * Xsize];
X  
X! 	p = src[CURNEW].pix[y];
X  
X  	DEBUG((Debug, "y = %d\n", y));
X! 	for (x = 0; x < Xsize; ++x, ++p)
X  	{
X  	    stack_t
X  		Stack[STACKSIZE];	/* the stack */
X--- 71,85 ----
X  	short	*ap,		/* precalculated polar angles */
X  		*rp;		/* precalculated polar radius */
X  	register pixel_t
X! 		*pixp;		/* default destination */
X  
X  	ap = &avals[y * Xsize];
X  	rp = &rvals[y * Xsize];
X  
X! 	pixp = CurNew->pix[y];
X  
X  	DEBUG((Debug, "y = %d\n", y));
X! 	for (x = 0; x < Xsize; ++x, ++pixp)
X  	{
X  	    stack_t
X  		Stack[STACKSIZE];	/* the stack */
X***************
X*** 93,99 ****
X  	    register long
X  		*CurrParse;	/* pointer to current item in parse string */
X  
X! 	    for (CurrParse = parsed, sp = Stack; CurrParse != ParseEnd; ++CurrParse)
X  	    {
X  	        if (*CurrParse == VALUE)
X  		{
X--- 96,106 ----
X  	    register long
X  		*CurrParse;	/* pointer to current item in parse string */
X  
X! 	    for (
X! 	        CurrParse = parsed, sp = Stack;
X! 		CurrParse != ParseEnd;
X! 		++CurrParse
X! 		)
X  	    {
X  	        if (*CurrParse == VALUE)
X  		{
X***************
X*** 110,116 ****
X  			else if (*sp < 0)
X  			    *sp = 0;
X  		    }
X! 		    *p = (pixel_t) *sp;
X  		    continue;
X  		}
X  	        switch ((int) *CurrParse)
X--- 117,123 ----
X  			else if (*sp < 0)
X  			    *sp = 0;
X  		    }
X! 		    *pixp = (pixel_t) *sp;
X  		    continue;
X  		}
X  	        switch ((int) *CurrParse)
X***************
X*** 204,210 ****
X  			b = *--sp;		/* x */
X  			tp = sp-1;
X  			c = (int) *tp;
X! 			*tp = (stack_t) src[c].pix[a][b];
X  			break;
X  		    case CLVAL:
X  			a = *--sp;		/* y */
X--- 211,217 ----
X  			b = *--sp;		/* x */
X  			tp = sp-1;
X  			c = (int) *tp;
X! 			*tp = (stack_t) Images[c].pix[a][b];
X  			break;
X  		    case CLVAL:
X  			a = *--sp;		/* y */
X***************
X*** 224,230 ****
X  			    if (nrange++ == 0)
X  				FPRINTF(stderr,
X  				    "Range err at (%d,%d) => %s[%d, %d]\n",
X! 				    x, y, src[c].str, b, a);
X  			}
X  			if (a >= Ysize)
X  			    a = Ysize - 1;
X--- 231,237 ----
X  			    if (nrange++ == 0)
X  				FPRINTF(stderr,
X  				    "Range err at (%d,%d) => %s[%d, %d]\n",
X! 				    x, y, Images[c].str, b, a);
X  			}
X  			if (a >= Ysize)
X  			    a = Ysize - 1;
X***************
X*** 234,240 ****
X  			    b = Xsize - 1;
X  			if (b < 0)
X  			    b = 0;
X! 			*tp = (stack_t) &(src[c].pix[a][b]);
X  			break;
X  		    case PRVAL:
X  			{
X--- 241,247 ----
X  			    b = Xsize - 1;
X  			if (b < 0)
X  			    b = 0;
X! 			*tp = (stack_t) &(Images[c].pix[a][b]);
X  			break;
X  		    case PRVAL:
X  			{
X***************
X*** 257,263 ****
X  				if (nrange++ == 0)
X  				    FPRINTF(stderr,
X  					"Range err at (%d,%d) => %s{%d,%d} [%d,%d]\n",
X! 					x, y, src[c].str, b, a, xval, yval);
X  			    }
X  
X  			    if (xval < 0)
X--- 264,270 ----
X  				if (nrange++ == 0)
X  				    FPRINTF(stderr,
X  					"Range err at (%d,%d) => %s{%d,%d} [%d,%d]\n",
X! 					x, y, Images[c].str, b, a, xval, yval);
X  			    }
X  
X  			    if (xval < 0)
X***************
X*** 269,275 ****
X  			    if (yval >= Ysize)
X  				yval = Ysize - 1;
X  
X! 			    *tp = (stack_t) src[c].pix[yval][xval];
X  			}
X  			break;
X  
X--- 276,282 ----
X  			    if (yval >= Ysize)
X  				yval = Ysize - 1;
X  
X! 			    *tp = (stack_t) Images[c].pix[yval][xval];
X  			}
X  			break;
X  
X***************
X*** 294,300 ****
X  				if (nrange++ == 0)
X  				    FPRINTF(stderr,
X  					"Range err at (%d,%d) => %s{%d,%d} [%d,%d]\n",
X! 					x, y, src[c].str, b, a, xval, yval);
X  			    }
X  
X  			    if (xval < 0)
X--- 301,307 ----
X  				if (nrange++ == 0)
X  				    FPRINTF(stderr,
X  					"Range err at (%d,%d) => %s{%d,%d} [%d,%d]\n",
X! 					x, y, Images[c].str, b, a, xval, yval);
X  			    }
X  
X  			    if (xval < 0)
X***************
X*** 306,312 ****
X  			    if (yval >= Ysize)
X  				yval = Ysize - 1;
X  
X! 			    *tp = (stack_t) &(src[c].pix[yval][xval]);
X  			}
X  			break;
X  
X--- 313,319 ----
X  			    if (yval >= Ysize)
X  				yval = Ysize - 1;
X  
X! 			    *tp = (stack_t) &(Images[c].pix[yval][xval]);
X  			}
X  			break;
X  
X***************
X*** 411,417 ****
X  void
X  run()
X  {
X!     int	y;
X  #if	SEQPAR
X      static int	parked = 0;
X  
X--- 418,426 ----
X  void
X  run()
X  {
X!     int		y;
X!     pixel_t	**linep;
X! 
X  #if	SEQPAR
X      static int	parked = 0;
X  
X***************
X*** 430,437 ****
X      if (disp_active)
X      {
X  	disp_imgstart();
X! 	for (y = 0; y < Ysize; ++y)
X! 	    disp_putline(src[CURNEW].pix[y], y);
X  	disp_imgend();
X      }
X  
X--- 439,450 ----
X      if (disp_active)
X      {
X  	disp_imgstart();
X! 	for (
X! 	    linep = CurNew->pix, y = 0;
X! 	    y != Ysize;
X! 	    ++linep, ++y
X! 	    )
X! 	    disp_putline(*linep, y);
X  	disp_imgend();
X      }
X  
X
X------- special.c -------
X*** /tmp/da1969	Wed Dec 27 12:13:49 1989
X--- special.c	Wed Dec 27 10:51:56 1989
X***************
X*** 22,43 ****
X   *		but it does work.
X   */
X  
X! #ifndef AMIGA
X! # include <sys/types.h>
X! #endif /* AMIGA */
X  #include <ctype.h>
X  #include <time.h>
X  
X  #ifdef      BSD
X! # include <sys/timeb.h>
X  #endif   /* BSD */
X  #include "popi.h"
X  
X  #define	GAMMA		7.5	/* default gamma for matte() */
X  #define	TILESIZE	25	/* default tile size for tile() */
X! #define N    		3
X! #define New  		src[CURNEW].pix
X  
X  /* prototypes for local functions */
X  struct SRC *	parseimg P((void));
X  bool		parsefname P((void));
X--- 22,42 ----
X   *		but it does work.
X   */
X  
X! #include <sys/types.h>
X  #include <ctype.h>
X  #include <time.h>
X  
X  #ifdef      BSD
X! #include <sys/timeb.h>
X  #endif   /* BSD */
X  #include "popi.h"
X  
X  #define	GAMMA		7.5	/* default gamma for matte() */
X  #define	TILESIZE	25	/* default tile size for tile() */
X! #define N    		3	/* default blur size for oil() */
X  
X+ #define New  		(CurNew->pix)
X+ 
X  /* prototypes for local functions */
X  struct SRC *	parseimg P((void));
X  bool		parsefname P((void));
X***************
X*** 60,65 ****
X--- 59,65 ----
X  void		undo P((void));
X  void		verbose P((void));
X  void		trunc P((void));
X+ void		doparse P((void));
X  
X  /*
X   * convenience function, since most of these routines have
X***************
X*** 73,79 ****
X      if (lat == '\n' || lat == ')')
X      {
X  	pushback(lat);
X! 	return &src[CUROLD];
X      }
X  
X      if (lat != INAME)
X--- 73,79 ----
X      if (lat == '\n' || lat == ')')
X      {
X  	pushback(lat);
X! 	return CurOld;
X      }
X  
X      if (lat != INAME)
X***************
X*** 83,89 ****
X  	return (struct SRC *) 0;
X      }
X  
X!     return &src[lexval + 1];
X  }
X  
X  static bool
X--- 83,89 ----
X  	return (struct SRC *) 0;
X      }
X  
X!     return &Images[lexval];
X  }
X  
X  static bool
X***************
X*** 548,555 ****
X      img	= srcp->pix;
X  
X      /* printer specific	*/
X!     xPinsPerPixel = 4;
X!     yPinsPerPixel = 4;
X      BytesPerColumn = 24	/ BITSINBYTE;
X  
X      PinsPerPixel = xPinsPerPixel * yPinsPerPixel;
X--- 548,555 ----
X      img	= srcp->pix;
X  
X      /* printer specific	*/
X!     xPinsPerPixel = 2;
X!     yPinsPerPixel = 2;
X      BytesPerColumn = 24	/ BITSINBYTE;
X  
X      PinsPerPixel = xPinsPerPixel * yPinsPerPixel;
X***************
X*** 722,738 ****
X  }
X  
X  static void
X  writeimg()
X  {
X!     struct SRC	*srcp;
X  
X      if (parsefname() == 0)
X  	return;
X  
X!     if ((srcp = parseimg()) == (struct SRC *) 0)
X  	return;
X  
X!     putpix(srcp, text);
X  }
X  
X  static void
X--- 722,790 ----
X  }
X  
X  static void
X+ newimg()
X+ {
X+     struct SRC	*img;
X+ 
X+     lex();
X+ 
X+     if (lat == INAME)
X+     {
X+ 	SPRINTF(ErrBuf, "Image named '%s' already exists", text);
X+ 	error(ERR_PARSE);
X+ 	return;
X+     }
X+ 
X+     if (lat != NAME)
X+     {
X+ 	SPRINTF(ErrBuf, "Expected name of new image");
X+ 	error(ERR_PARSE);
X+ 	return;
X+     }
X+ 
X+     /* Find an empty slot in the image array */
X+     for (img = Images; img->pix != (pixel_t **) 0; ++img)
X+ 	;
X+ 
X+     if (img == &Images[nimages])
X+ 	++nimages;
X+ 
X+     if
X+     (
X+ 	(img->pix = ImgAlloc()) == (pixel_t **) 0
X+ 	||
X+ 	(img->str = (char *) Emalloc((unsigned int) (strlen(text)+1)))
X+ 		== (char *) 0
X+     )
X+     {
X+ 	img->pix = (pixel_t **) 0;
X+ 	return;
X+     }
X+ 
X+     STRCPY(img->str, text);
X+ 
X+     /* Swap newly created image with old */
X+     {
X+ 	pixel_t		**tmp;
SHAR_EOF
echo "End of part 1"
echo "File patch.3 is continued in part 2"
echo "2" > s2_seq_.tmp
exit 0

conway@hpdtl.HP.COM (Daniel F. Conway) (01/04/90)

/ hpdtl:comp.sources.bugs / richb@sunaus.oz (Rich Burridge) /  5:34 pm  Dec 26, 1989 /
| popi is a program for manipulating digital images. It was posted to
| comp.sources.misc earlier this month.
| 
| **Note that popi was released to comp.sources.misc at patchlevel #2**
| 
| Patch #3 is included in the shar file below along with two new files:
| 

  [deleted]

Were patches 1 & 2 posted?  We never got them here.  If they were posted, is
there an archive that I can get them from?

Dan Conway
dan_conway@hplabs.hp.com

icsu6000@caesar (Jaye Mathisen) (01/07/90)

In article <12920001@hpdtl.HP.COM> conway@hpdtl.HP.COM (Daniel F. Conway) writes:
:/ hpdtl:comp.sources.bugs / richb@sunaus.oz (Rich Burridge) /  5:34 pm  Dec 26, 1989 /
:| **Note that popi was released to comp.sources.misc at patchlevel #2**
:| 
:
:  [deleted]
:
:Were patches 1 & 2 posted?  We never got them here.  If they were posted, is

If you were to peruse the line that starts with '**', you would note that
popi was sent out at patchlevel 2, so you can justuse patch 3 on the posted
source, and be off and gone...
--
+-----------------------------------------------------------------------------+
| Jaye Mathisen,systems manager       Internet: icsu6000@caesar.cs.montana.edu|
| 410 Roberts Hall                      BITNET: icsu6000@mtsunix1.bitnet      |
| Dept. of Computer Science	                                              |