home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / misc / icalc.lzh / icalc / src / ufunc.c < prev   
C/C++ Source or Header  |  1991-09-29  |  857b  |  55 lines

  1. /*
  2. *    icalc - complex-expression parser
  3. *
  4. *    These are the routines to implement user-functions.
  5. *    Structure definition is in complex.h.
  6. *
  7. *    (C) Martin W Scott, 1991.
  8. */
  9. #include "complex.h"
  10. #include "memory.h"
  11.  
  12. Symbol *findsym(sl, s)
  13.     SymList *sl;
  14.     char *s;
  15. {
  16.     if (sl)
  17.         if (!strcmp(s,sl->sym->name))
  18.             return sl->sym;
  19.         else
  20.             return findsym(sl->next, s);
  21.     else
  22.         return NULL;
  23. }
  24.  
  25.  
  26. void clear_ufunc(func)
  27.     UserFunc *func;
  28. {
  29.     RemKey **oldkey = rem_setkey(&func->remkey);
  30.  
  31.     rem_freeall();
  32.     func->tree = NULL;
  33.     rem_setkey(oldkey);
  34. }
  35.  
  36.  
  37. void init_ufunc(func)        /* reset fields of user function */
  38.     UserFunc *func;
  39. {
  40.     func->remkey = NULL;
  41.     func->params = NULL;
  42. }
  43.  
  44. SymList *addparam(sl, s)    /* add symbol (parameter) to list */
  45.     SymList *sl;
  46.     Symbol *s;
  47. {
  48.     SymList *newsl;
  49.  
  50.     newsl = rem_malloc(sizeof(SymList));
  51.     newsl->sym = s;
  52.     newsl->next = sl;
  53.     return newsl;
  54. }
  55.