Previous Topic

Next Topic

Correct Conditional Index Results with Zero-Length String Literals

An index specified the conditional index expression:

 !strnicmp(myField, "", 6)

and the data file contains records having values of myField that match this condition (that is, myField is ""). However, for c-treeACE V9, the expression did not evaluate as true for these field values. The same conditional expression produced the expected results in c-tree Plus V8. The V9 conditional expression logic parses zero-length (empty) string literals differently than V8. A NULL pointer was placed into the expression tree rather than allocating space to hold an empty string and adding that value into the expression tree. The string comparison function returns a non-zero value when only one of its parameters (Source or Dest) is NULL, and caused the expression to return unexpected results in this situation.

The function that adds a string literal value to the expression tree was modified to allocate a one-byte buffer when the string length is zero. Similar logic was also reviewed for other cases where an empty string literal value is not properly handled and these other functions were modified accordingly.