From news.coli.uni-sb.de!sbusol.rz.uni-sb.de!xlink.net!howland.reston.ans.net!pipex!demon!ansa.co.uk!ajw Sat May 21 17:56:35 1994
Path: news.coli.uni-sb.de!sbusol.rz.uni-sb.de!xlink.net!howland.reston.ans.net!pipex!demon!ansa.co.uk!ajw
Newsgroups: comp.sources.bugs
From: ajw@ansa.co.uk (Andrew Watson)
Subject: SC 6.21 - Null string comparison patch
Date: Fri, 13 May 1994 15:52:49 +0000
Message-ID: <9405131552.AA26647@crippen.ansa.co.uk>
Sender: usenet@demon.co.uk
Lines: 85

Greetings,

This is a small patch for the excellent sc 6.21 PD spreadsheet. I've been using
sc for increasingly-complex applications over the years, and a month or so ago
I bumped into a small problem with the @eqs string comparison function. While
it's easily worked-around, it's also easily patched.

I'm not sure if SC is still actively maintained. The REAEDME names Jeff Buhrt of
ProsLink, Inc as the maintainer, but I've failed to contact him (although I
haven't tried very hard!). If you're reading this Jeff, I hope you don't mind
me posting a patch without consulting you!

       .                           Regards,
      / \^
     / / \ \                           Andrew
    / /   \ \
   '=========`      Andrew Watson             Tel:      +44 223 323010
  /| |\ | <  |\	    APM Ltd, Poseidon House,  Fax:      +44 223 359779
 / | | \| _> | \    Castle Park,              Internet: ajw@ansa.co.uk
 ---------------    Cambridge CB3 0RD, UK
------------------------------------------------------------------------------
Software and version:

    SC 6.21


Problem description:

    A cell's initial string label, and the one that it is given after being
    erased (for instance, using the 'x' command) appears to be the null string,
    and assigning a null string label to a cell (for instance, using the '>'
    command) leaves it in this state too. However, using the @eqs() operator
    to compare such a cell to the string "" always yields 0 (false), whereas
    comparing the cell to itself or another unlabelled cell yields 1 (true).


Functional description of patch:

    Arrange that @eqs(<cell>, "") yields 1 (true) for an unlabelled cell, and
    0 (false) otherwise.


Internal description of patch:

    The string label of an empty cell is represented by a null pointer, while
    the null string generated when the SC parser reads the empty string "" is a
    pointer to a zero length string (i.e. a zero byte). The patch catches a
    comparison of these two kinds of null string.

Patchfile:

*** interp.c.orig	Wed May 11 09:50:29 1994
--- interp.c	Wed Apr 20 18:38:20 1994
***************
*** 601,606 ****
--- 601,608 ----
      return(v);
  }
  
+ /* Mods by ajw@ansa.co.uk 20/4/94 */
+ 
  double
  doeqs(s1, s2)
  char *s1, *s2;
***************
*** 609,614 ****
--- 611,628 ----
  
      if (!s1 && !s2)
  	return((double)1.0);
+ 
+ /* AJW start */
+     if (!s1 && !strlen(s2))
+       { scxfree(s2);
+ 	return((double)1.0);
+       }
+ 
+     if (!s2 && !strlen(s1))
+       { scxfree(s1);
+ 	return((double)1.0);
+       }
+ /* AJW end */
  
      if (!s1 || !s2)
  	v = 0.0;

