Since string compares are now, apparently by default, done by uppercasing both strings before comparing, how do you now go about comparing strings on a case sensitive basis as was the norm in BCX 732? After looking a a number of codes written in the 732 era, I have found that the major problem in each case of trying to recompile and run correctly under 761 is due to this change in comparing strings.
Hi Don,
Comparing strings
in C has traditionally been done using the standard library functions
strcmp and
stricmp.
strcmp is used to perform case-sensitive comparisons
str
icmp is used to perform non-case-sensitive comparisons (
by comparing lower case versions of the strings )
For all case-sensitive string comparisons, BCX uses the compiler's standard library
implementation of the
strcmp function.
For many years, BCX used its own version of strcmp ( str_cmp) which was a little faster than some compiler
library implementations. Eventually, hardware and compiler improvements rendered the custom version
pointless and BCX
7.4.8 went back to using the standard library version of strcmp.
It's worth noting that throughout 2020, dozens, possibly hundreds, of
single-character string comparisons
in the BCX translator were changed to pointer comparisons, in order to eliminate the overhead of those function
calls and, in return, provide the translator with a performance bump. Perhaps your encryption work is triggering
a "corner case" in one or more of those comparisons.
In October 2020, I implemented the "
??" operator which initially used the standard str
icmp C function.
Eventually, stricmp was replaced with a new BCX function:
bcx_stricmp.
Hours of testing were performed before the string changes were rolled out in version
757 but it's possible
you have a "corner case" that we need to look at. We would need you to provide a short, easy to understand
example that clearly demonstrates the failure.
Robert Wishlaw collaborated with me on the creation and testing of the locale-specific bcx_stricmp function,
in response to this eye-popping Microsoft article:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/stricmp-wcsicmp-mbsicmp-stricmp-l-wcsicmp-l-mbsicmp-l?view=msvc-160From which the following extract is noteworthy:
Because _stricmp does lowercase comparisons, it may result in unexpected behavior.
To illustrate when case conversion by _stricmp affects the outcome of a comparison, assume that you have the two strings JOHNSTON and JOHN_HENRY. The string JOHN_HENRY will be considered less than JOHNSTON because the "_" has a lower ASCII value than a lowercase S. In fact, any character that has an ASCII value between 91 and 96 will be considered less than any letter.
If the strcmp function is used instead of _stricmp, JOHN_HENRY will be greater than JOHNSTON.