Found this when trying to build Tcl 8.5.1 on an ancient Unix (AIX 4.1):
Tcl 8.5.1 calls strcasecmp() in a few places, and it really should not. strcasecmp is nonportable (it's not part of C89 -- with good reason).
FTBFS errors on AIX 4.1 attached.
Logged In: YES
There is a fallback implementation of strcasecmp and strncasecmp in compat/strncasecmp.c; however the autoconf logic to enable it is not being triggered on this platform.
AIX 4.1 has strcasecmp; it's defined in libc.a, and declared in <strings.h> along with a few other BSDisms like bcmp/bcopy/bzero, index, and rindex.
# include <strings.h>
to unix/tclUnixPort.h fixes the compile-time errors, and there are no subsequent link-time errors.
<strings.h> is in neither C89 nor POSIX, but it is specified in the Open Group Single Unix Specification.
strcasecmp is called in the following places in Tcl 8.5.1
+ In the implementation of [lsort -nocase], [switch -nocase], [lsearch -nocase], and [lsearch -sorted -nocase]
All of these uses were introduced by TIP#241. The TIP does not specify whether "case-insensitive" means "ASCII-only", "locale-dependent", "UTF-aware but still ASCII-only", "according to one of the standardized Unicode normalization forms", or "what Tcl does elsewhere". Presumably "what Tcl does elsewhere" (e.g., Tcl_StringCaseMatch, Tcl_UniCharToLower) is the most sensible. strcasecmp() will typically be locale-dependent (or ASCII-only, which amounts to the same thing). In any event, strcasecmp() is incorrect here, and causes portability problems. This should be fixed.
+ In the definition of TclpInitLibraryPath(). This call was introduced 1999-04-15 <stanton> with the log message "merged tcl 8.1 branch back into the main trunk"; further details are lost to history. It is not immediately clear to me why TclpInitLibraryPath is doing a case-insensitive comparison at this point, or indeed what it is doing at all.
See also #1236896 "make -nocase behave correct with non-ASCII characters". That would take care of the first batch of calls.
Tracked the introduction of the strcasecmp() call in unix/tclUnixInit.c back to another jumbo patch;
Committer: stanton <stanton> 1998-09-21 16:39:52
Changelog entry just says "Added contents of Tcl 8.1a2". Sigh.
It looks like it might be related to early Mac OS support.
When using Diet Libc (<http://www.fefe.de/dietlibc/>), Tcl fails to build with complaints regarding strcasecmp. Adding "#include <strings.h>" in generic/tclInt.h with the existing "#include <string.h>" fixes the issue and Tcl compiles cleanly.