/***********************************************
 (C) Copyright 1992-1993; dit/upm
   Distributed under the conditions stated in the
   EPS General Public License (see file LICENSE)
 ***********************************************
 $Log: astgoto.c,v $
 * Revision 2.3  1993/01/12  16:33:54  eps
 * portability issues
 *
 * Revision 2.2  1992/01/14  15:42:38  eps
 * distribution issues
 *
 * Revision 2.1  90/10/30  08:31:53  eps
 * hardwired colours added
 * new colours I2, IAT, AT
 * ! is no longer used as colour delimiter
 * still some bugs are known w.r.t. colour deallocation
 * 
 * Revision 1.3  90/03/16  15:38:48  eps
 * minor beautifying
 * 
 * Revision 1.2  90/01/29  14:51:15  eps
 * fixing license details
 * 
 * Revision 1.1  90/01/25  17:58:25  eps
 * Initial revision
 * 
 **********************************************/

#ifndef lint
static char rcsid[]= "$Id: astgoto.c,v 2.3 1993/01/12 16:33:54 eps Exp $";
#endif

/***********************************************************************
        Tomas P. de Miguel Moro
	Jose A. Manas
        dpt. Ingenieria Telematica
        E.T.S.I. Telecomunicacion
        Ciudad Universitaria
        E-28040  MADRID
 **********************************************************************/

/* LINTLIBRARY */

# define cast_IMP
# include "cast.hh"

# include <stdio.h>

PUBLIC TNODE*
gt_ls (nodep)
        TNODE*  nodep;
{
  if (nodep = gt_fs(nodep))
  {
     while(nodep->brothers != NULL) nodep = gt_rb(nodep);
     return nodep;
  }
  else return NULL;

} /* end of gt_ls */

PUBLIC TNODE*
gt_lb (nodep)
        TNODE*  nodep;
{
        TNODE* auxp;

   if (nodep == NULL) return NULL;
   auxp = nodep->father;
   if (auxp == NULL) return NULL;
   if (auxp->sons == NULL) return NULL;
   if (auxp->sons == nodep) return NULL;
   for (auxp = auxp->sons;
	auxp->brothers != NULL && auxp->brothers != nodep;
	auxp= auxp->brothers)
       ;
   return auxp;

} /* end of gt_lb */

PUBLIC TNODE*
gt_rt (nodep)
        TNODE*  nodep;
{
  TNODE* auxp;
  
  if (nodep == NULL)
    return NULL;
  for (auxp= nodep; auxp->father != NULL; auxp= auxp->father)
    ;
  return auxp;
}
