[net.micro.att] fix to "mongo" graphing program

richmon@astrovax.UUCP (Michael Richmond) (04/12/86)

About a week or so ago I posted the sources to a simple graphing package
called "mongo" to net.sources. Since then, I have discovered that on the
7300, whenever you resize or move a window, the escape sequence generated
by the mouse gets passed to the input stream of the program (!), causing
the command-hashing routine to yield a non-sense pointer, causing the
program to bomb as soon as you type <return>. Here's the fix:

file: hash.c  function: lookup()

lookup(s)
char *s;
{
    struct nlist *np;
    int i;                    /* first line of fix */

    if ((i = hash(s)) < 0) 	  /* second line */
       return(NULL);          /* third */

    for (np = hashtab[i]; np != NULL; np = np->next)   /* last line of fix */
       .
       .
 

As you can see, I've added a check to make sure that the hashing function
does not return a negative value. What happened was that the mouse escape
sequence somehow gave negative character values, AND the mod function
inside the hashing procedure returned negative values for negative arguments.
Hmmm.


-- 
Michael Richmond			Princeton University, Astrophysics

{allegra,akgua,burl,cbosgd,decvax,ihnp4,noao,princeton,vax135}!astrovax!richmon