[comp.windows.news] Did anyone get my program "treeedit" to work?

callahan@gondor.cs.psu.edu (Paul B. Callahan) (03/15/89)

I posted a program called treeedit last October or so (maybe Nov.).  
It consisted of two files: treeedit.c and treeedit.cps.  The program was 
an interactive graphical binary tree "editor," which allowed the user to 
perform insertions, deletions, and rotations on a binary search tree.
Needless to say, it runs under NeWS.

The only response I have had to date is from a person who was unable
to get the source to compile for some unknown reason.  We have been
trying to determine why the program works for me and not for him,
but have so far been unsuccessful.

I would appreciate a response from anyone who tried out the program,
whether successful or not.  I would especially appreciate some explanation
as to why it may not be portable to other systems running NeWS.
I will mail the source to anyone who would like to troubleshoot.

montnaro@sprite.steinmetz.ge.com (Skip Montanaro) (03/17/89)

    The only response I have had to date is from a person who was unable
    to get the source to compile for some unknown reason.  We have been
    trying to determine why the program works for me and not for him,
    but have so far been unsuccessful.

There are three places in the code where you neglected to place space around
either "=*" or "=&". This results in an ambiguity detected by Sun's C
compiler. It can't tell if you are using an assignment operator followed by
* or &, or the old-fashioned versions of *= and &=. I suspect you weren't
using a Sun for treeedit development.

My diffs follow. I have not tested them yet.

diff -rc2 treeedit.c~ treeedit.c
*** treeedit.c~	Mon Mar 13 22:11:03 1989
--- treeedit.c	Thu Mar 16 22:35:32 1989
***************
*** 76,80 ****
        if (depth>*maxdepth) *maxdepth=depth;
        findxy(root->left,rank,depth+1,maxdepth);
!       root->rank=*rank;
        root->depth=depth; 
        (*rank)++;
--- 76,80 ----
        if (depth>*maxdepth) *maxdepth=depth;
        findxy(root->left,rank,depth+1,maxdepth);
!       root->rank = *rank;
        root->depth=depth; 
        (*rank)++;
***************
*** 169,177 ****
            }
            else if (cps_rightbutton(&id,&geomx)) {
!              insplace=&root; 
               while ((*insplace)!=NULL) { 
                  if ((float) ((*insplace)->rank) > geomx)
!                      insplace=&((*insplace)->left);
!                 else insplace=&((*insplace)->right);
               }
               *insplace=(struct bst *) malloc(sizeof(struct bst));
--- 169,177 ----
            }
            else if (cps_rightbutton(&id,&geomx)) {
!              insplace = &root; 
               while ((*insplace)!=NULL) { 
                  if ((float) ((*insplace)->rank) > geomx)
! 		  insplace = &((*insplace)->left);
!                 else insplace = &((*insplace)->right);
               }
               *insplace=(struct bst *) malloc(sizeof(struct bst));

--
Skip Montanaro (montanaro@sprite.crd.ge.com)