[postgis-devel] use of strnicmp

Greg Troxel gdt at lexort.com
Fri Sep 22 10:04:15 PDT 2017


Greg Troxel <gdt at lexort.com> writes:

> Building 2.3.3 on NetBSD, I am running into an error about strnicmp.
> There's a comment in the source about it:
>
>   /* if we are in Unix define stricmp to be strcasecmp and strnicmp to */
>   /* be strncasecmp. I'm not sure if all Unices have these, but Linux */
>   /* does. */
>
> In general, the right approach (in the Unix part of the world) is to
> look at the POSIX standards, and strongly prefer those.  strcasecmp is
> in POSIX, and dates from 4.4BSD, so it's been around a really long time
> (25 years?).  I have no idea about sticmp, but it seems to be an MS
> thing.
>
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/strcasecmp.html
>
> I haven't figured out why the defines aren't working, but it seems like
> the code should be based on HAVE_FOO, with some way to set those
> semi-manually on Windows (assuming the windows build doesn't use
> autoconf).

The problem is that there are a bunch of ifdefs that define UNIX on a
number of operating systems, and further define LINUX on systems that
aren't Linux, but they don't cover everything.  This seems overly
complicated and wrong; a LINUX ifdef should be used only for things
where the POSIX approach doesn't work and some non-standard Linuxism has
to be used.

As I understand it, there is windows that probably doesn't use autoconf,
and then a wide variety of almost-entirely POSIX systems that do.  So it
seems like the right thing is to get rid of #ifdef UNIX and instead to
use #ifndef WINDOWS, for the right value of windows.

After removing the #ifdef UNIX around the code that defines stricmp to
strcasecmp, raster builds, but some of the tests fail.

I haven't looked at 2.4.0 in this regard yet.  I just noticed a failure
of 2.3.3 as we prepare for the next pkgsrc branch.  It must have worked
when I updated, but perhaps UNIX was defined in the environment for some
reason and now isn't.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 162 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20170922/f8a12d6f/attachment.sig>


More information about the postgis-devel mailing list