#15349 closed defect (fixed)

no 'strcasecmp' with c++11 in Mingw32

Reported by: guenter Owned by:
Priority: normal Milestone:
Component: build Version: 2.9.5
Keywords: Cc:
Blocked By: Blocking:
Patch: yes

Description

D:\wxWidgets-2.9.5.vadz.2\include/wx/string.h: In function 'int Stricmp(const char*, const char*)':
D:\wxWidgets-2.9.5.vadz.2\include/wx/string.h:182:31: error: 'strcasecmp' was not declared in this scope

With compile option '-std=c++11' mingw32 defines __STRICT_ANSI__. With that there is no 'strcasecmp' available for implementing 'Stricmp'.

$ git diff -w -- include/wx/string.h
diff --git a/include/wx/string.h b/include/wx/string.h
index 53ae890..78ce224 100644
--- a/include/wx/string.h
+++ b/include/wx/string.h
@@ -168,6 +168,14 @@ inline int Stricmp(const char *psz1, const char *psz2)
   return stricmp(psz1, psz2);
 #elif defined(__WXPM__)
   return stricmp(psz1, psz2);
+#elif defined(__MINGW32__) && defined(__STRICT_ANSI__)
+    register char c1, c2;
+    do {
+      c1 = tolower(*psz1++);
+      c2 = tolower(*psz2++);
+    } while ( c1 && (c1 == c2) );
+
+    return c1 - c2;
 #elif defined(HAVE_STRCASECMP_IN_STRING_H) || \
       defined(HAVE_STRCASECMP_IN_STRINGS_H) || \
       defined(__GNUWIN32__)


Attachments (1)

strcasecmp.patch download (647 bytes) - added by guenter 15 months ago.
patch for wx/string.h

Download all attachments as: .zip

Change History (4)

Changed 15 months ago by guenter

patch for wx/string.h

comment:1 Changed 15 months ago by guenter

  • Patch set

comment:2 Changed 15 months ago by vadz

  • Status changed from new to confirmed

Actually I have really no idea why do we repeat all these tests here when we already have wxCRT_StricmpA() defined in wx/wxcrtbase.h. I'll just change the code to use it instead.

comment:3 Changed 15 months ago by VZ

  • Resolution set to fixed
  • Status changed from confirmed to closed

(In [74571]) Just forward Stricmp() in wx/string.h to wxCRT_StricmpA().

Don't redo the tests already done in wx/wxcrtbase.h in wx/string.h too,
especially as they were not done correctly there (they didn't take into
account the case of MinGW in strict ANSI mode). Just call wxCRT_StricmpA().

This also allows us to get rid of HAVE_STRCASECMP_IN_STRING[S]_H tests in
configure.

Closes #15349.

Note: See TracTickets for help on using tickets.