home *** CD-ROM | disk | FTP | other *** search
/ pc.louisiana.edu/pub/unix/ / Louisiana_UNIX.tar / Louisiana_UNIX / sc621.eqs.bugfix < prev    next >
Internet Message Format  |  1994-05-13  |  3KB

  1. Received: from tabasco.ansa.co.uk by armagnac.ucs.usl.edu with SMTP id AA24337
  2.   (5.65c/IDA-1.4.4 for <jpd@usl.edu>); Fri, 13 May 1994 10:54:11 -0500
  3. Received: from crippen.ansa.co.uk by tabasco.ansa.co.uk; Fri, 13 May 94 16:53:25 +0100
  4. Received: by crippen.ansa.co.uk; Fri, 13 May 94 16:52:49 BST
  5. Date: Fri, 13 May 94 16:52:49 BST
  6. From: Andrew Watson <ajw@ansa.co.uk>
  7. Message-Id: <9405131552.AA26647@crippen.ansa.co.uk>
  8. To: comp.sources.bugs@newnews.demon.co.uk, James Dugal <jpd@usl.edu>
  9. Subject: SC 6.21 - Null string comparison patch
  10. Status: R
  11.  
  12. Greetings,
  13.  
  14. This is a small patch for the excellent sc 6.21 PD spreadsheet. I've been using
  15. sc for increasingly-complex applications over the years, and a month or so ago
  16. I bumped into a small problem with the @eqs string comparison function. While
  17. it's easily worked-around, it's also easily patched.
  18.  
  19. I'm not sure if SC is still actively maintained. The REAEDME names Jeff Buhrt of
  20. ProsLink, Inc as the maintainer, but I've failed to contact him (although I
  21. haven't tried very hard!). If you're reading this Jeff, I hope you don't mind
  22. me posting a patch without consulting you!
  23.  
  24.        .                           Regards,
  25.       / \^
  26.      / / \ \                           Andrew
  27.     / /   \ \
  28.    '=========`      Andrew Watson             Tel:      +44 223 323010
  29.   /| |\ | <  |\        APM Ltd, Poseidon House,  Fax:      +44 223 359779
  30.  / | | \| _> | \    Castle Park,              Internet: ajw@ansa.co.uk
  31.  ---------------    Cambridge CB3 0RD, UK
  32. ------------------------------------------------------------------------------
  33. Software and version:
  34.  
  35.     SC 6.21
  36.  
  37.  
  38. Problem description:
  39.  
  40.     A cell's initial string label, and the one that it is given after being
  41.     erased (for instance, using the 'x' command) appears to be the null string,
  42.     and assigning a null string label to a cell (for instance, using the '>'
  43.     command) leaves it in this state too. However, using the @eqs() operator
  44.     to compare such a cell to the string "" always yields 0 (false), whereas
  45.     comparing the cell to itself or another unlabelled cell yields 1 (true).
  46.  
  47.  
  48. Functional description of patch:
  49.  
  50.     Arrange that @eqs(<cell>, "") yields 1 (true) for an unlabelled cell, and
  51.     0 (false) otherwise.
  52.  
  53.  
  54. Internal description of patch:
  55.  
  56.     The string label of an empty cell is represented by a null pointer, while
  57.     the null string generated when the SC parser reads the empty string "" is a
  58.     pointer to a zero length string (i.e. a zero byte). The patch catches a
  59.     comparison of these two kinds of null string.
  60.  
  61. Patchfile:
  62.  
  63. *** interp.c.orig    Wed May 11 09:50:29 1994
  64. --- interp.c    Wed Apr 20 18:38:20 1994
  65. ***************
  66. *** 601,606 ****
  67. --- 601,608 ----
  68.       return(v);
  69.   }
  70.   
  71. + /* Mods by ajw@ansa.co.uk 20/4/94 */
  72.   double
  73.   doeqs(s1, s2)
  74.   char *s1, *s2;
  75. ***************
  76. *** 609,614 ****
  77. --- 611,628 ----
  78.   
  79.       if (!s1 && !s2)
  80.       return((double)1.0);
  81. + /* AJW start */
  82. +     if (!s1 && !strlen(s2))
  83. +       { scxfree(s2);
  84. +     return((double)1.0);
  85. +       }
  86. +     if (!s2 && !strlen(s1))
  87. +       { scxfree(s1);
  88. +     return((double)1.0);
  89. +       }
  90. + /* AJW end */
  91.   
  92.       if (!s1 || !s2)
  93.       v = 0.0;
  94.