[net.bugs.usg] Another GPS ptog bug...

dan@rna.UUCP (Dan Ts'o) (02/11/85)

x
	Well here is another bug in GPS's ptog (plot(5) to GPS converter).
Two character variables were defined as CHAR instead of INT. Yet the
character from the plot(5) was occassionally 0377. Ptog() uses ungetc() alot
which barfs on trying to backup an EOF, but 0377 and EOF look the same to
a CHAR so ungetc() failed and ptog() got out of sync.
	I have also included a new get2b() for ptog just in case you missed
my last bug report. The symptoms of that one was total garbage on a VAX, while
good output on a PDP-11.

					Cheers,
					Dan Ts'o
					Dept. Neurobiology
					Rockefeller Univ.
					1230 York Ave.
					NY, NY 10021
					212-570-7671
					...cmcl2!rna!dan

*** ptog.c.old	Sun Feb 10 22:40:40 1985
--- ptog.c	Sun Feb 10 22:40:21 1985
***************
*** 92,98
  ptog(fpi,fpo)
  FILE *fpi,*fpo; {
  	int x=0,y=0,x1,y1,x2,y2,xc,yc,r;
! 	char c, c1, string[TEXLEN],*ptr;
  	gsl.fp=fpo;
  	newparm(&gsl);
  	gplinit(gsl.fp);

--- 92,99 -----
  ptog(fpi,fpo)
  FILE *fpi,*fpo; {
  	int x=0,y=0,x1,y1,x2,y2,xc,yc,r;
! 	int c, c1;
! 	char string[TEXLEN],*ptr;
  	gsl.fp=fpo;
  	newparm(&gsl);
  	gplinit(gsl.fp);
***************

Here is a new get2b:
***************
get2b(fptr)		/* get an integer stored in 2 ascii bytes. */
FILE *fptr;
{
	short a, b;
	if((b = getc(fptr)) == EOF) {
		ERRPR0(Format error);
		return(EOF);
	}
	if((a = getc(fptr)) == EOF) {
		ERRPR0(Format error);
		return(EOF);
	}
	a <<= 8;
	return((int)a|b);
}