Uploaded image for project: 'SWORD'
  1. SWORD
  2. API-80

use of stricmp() is non-standard and causes build failure in cygwin

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core
    • Labels:
      None
    • Environment:

      winxp+cygwin

      Description

      src/utilfuns/swobject.cpp uses stricmp(). this is not standard ANSI C and causes a compile failure in cygwin because cygwin libc does not provide a compatibility hook for it, as does glibc. however, cygwin does provide <string.h> which helpfully #defines stricmp to strcasecmp, which is the ANSI C standard name for that function.

      an update was attempted in mid-march (see sword-devel archives):
      > In utilstr.h in the namespace sword we have our own
      > stricmp. i changed swobject to use that instead.

      this simply moved the flaw from a compilation error to a link error. for building gnomesword under cygwin, the sword build process does this to correct the problem on the fly:

      mv src/utilfuns/swobject.cpp src/utilfuns/swobject.cpp.ORIG
      sed < src/utilfuns/swobject.cpp.ORIG \
      -e 's/<utilstr.h>/&\n#include <string.h>/' \
      -e 's/sword::stricmp/stricmp/' \
      > src/utilfuns/swobject.cpp

      this corrects the problem, but is nothing but a hack.

      corrections available:
      [a] replace all use of stricmp with strcasecmp.
      short of that,
      [b] remove the attempted fix (2nd -e expression hack fix) and make swobject.cpp #include <string.h>.

      correction [a] is vastly to be preferred, because it is Correct, whereas the both the current state of the code and correction [b] constitute nothing more than crude hacks.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              karl karl kleinpaste
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: