home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / PROG / MISC / XLSP21TC.ZIP / XL-005.BUG / text0000.txt < prev   
Encoding:
Text File  |  1991-04-14  |  2.6 KB  |  137 lines

  1. These problems were pointed out to me by Paul van Niekerk 
  2. (nikkie@duteca2.tudelft.nl). They are applicable to XLISP versions 2.0 or 2.1.
  3.  
  4. PROBLEM: (last '(a b . c)) returns c rather than (b . c)
  5. SOLUTION: in xllist.c, replace xlast with:
  6.  
  7. /* xlast - return the last cons of a list */
  8. LVAL xlast()
  9. {
  10.     LVAL list;
  11.  
  12.     /* get the list */
  13.     list = xlgalist();
  14.     xllastarg();
  15.  
  16.     /* find the last cons */
  17.     if (consp(list))
  18.         while (consp(cdr(list))) list = cdr(list);
  19.  
  20.     /* return the last element */
  21.     return (list);
  22. }
  23.  
  24. PROBLEM: functions boundp, fboundp, symbol-name, symbol-value, and 
  25. symbol-plist fail on NIL (which *is* a symbol), and symbol-function fails 
  26. improperly (wrong error message).
  27.  
  28. SOLUTION:
  29.  
  30. In xlisp.h, add:
  31.  
  32. #define xlgasymornil()    (*xlargv==NIL || symbolp(*xlargv) ? nextarg() : xlbadtype(*xlargv))
  33.  
  34. In xlbfun.c, change functions to the following:
  35.  
  36. /* xboundp - is this a value bound to this symbol? */
  37. LVAL xboundp()
  38. {
  39.     LVAL sym;
  40.     sym = xlgasymornil();
  41.     xllastarg();
  42.     return (sym == NIL || boundp(sym) ? true : NIL);
  43. }
  44.  
  45. /* xfboundp - is this a functional value bound to this symbol? */
  46. LVAL xfboundp()
  47. {
  48.     LVAL sym;
  49.     sym = xlgasymornil();
  50.     xllastarg();
  51.     return (sym != NIL && fboundp(sym) ? true : NIL);
  52. }
  53.  
  54. /* xsymname - get the print name of a symbol */
  55. LVAL xsymname()
  56. {
  57.     LVAL sym;
  58.  
  59.     /* get the symbol */
  60.     sym = xlgasymornil();
  61.     xllastarg();
  62.  
  63.     /* handle NIL, which is not internally represented as a symbol */
  64.     if (sym == NIL) {
  65.         sym = newstring(4);
  66.         strcpy(getstring(sym), "NIL");
  67.         return sym;
  68.     }
  69.  
  70.     /* return the print name */
  71.     return (getpname(sym));
  72. }
  73.  
  74. /* xsymvalue - get the value of a symbol */
  75. LVAL xsymvalue()
  76. {
  77.     LVAL sym,val;
  78.  
  79.     /* get the symbol */
  80.     sym = xlgasymornil();
  81.     xllastarg();
  82.  
  83.     /* handle NIL */
  84.     if (sym == NIL) return (NIL);
  85.  
  86.     /* get the global value */
  87.     while ((val = getvalue(sym)) == s_unbound)
  88.         xlunbound(sym);
  89.  
  90.     /* return its value */
  91.     return (val);
  92. }
  93.  
  94. /* xsymfunction - get the functional value of a symbol */
  95. LVAL xsymfunction()
  96. {
  97.     LVAL sym,val;
  98.  
  99.     /* get the symbol */
  100.     sym = xlgasymornil();
  101.     xllastarg();
  102.  
  103.     /* handle NIL */
  104.     if (sym == NIL) {
  105.         while (1)
  106.             xlfunbound(sym);
  107.     }
  108.  
  109.  
  110.     /* get the global value */
  111.     while ((val = getfunction(sym)) == s_unbound)
  112.         xlfunbound(sym);
  113.  
  114.     /* return its value */
  115.     return (val);
  116. }
  117.  
  118. /* xsymplist - get the property list of a symbol */
  119. LVAL xsymplist()
  120. {
  121.     LVAL sym;
  122.  
  123.     /* get the symbol */
  124.     sym = xlgasymornil();
  125.     xllastarg();
  126.  
  127.     /* return the property list */
  128.     return (sym == NIL ? NIL : getplist(sym));
  129. }
  130.  
  131.  
  132. Tom Almy
  133. toma@tekgvs.labs.tek.com
  134. Standard Disclaimers Apply
  135.  
  136.  
  137.