[Python-checkins] bpo-28269: Replace strcasecmp with system function _stricmp. (GH-13095)

Miss Islington (bot) webhook-mailer at python.org
Sat Aug 24 06:22:18 EDT 2019


https://github.com/python/cpython/commit/920ec4b7763d64b3742d7ddd339ad11cdbec62e9
commit: 920ec4b7763d64b3742d7ddd339ad11cdbec62e9
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-08-24T03:22:14-07:00
summary:

bpo-28269: Replace strcasecmp with system function _stricmp. (GH-13095)

(cherry picked from commit 05f2d84cae4ba1ff15b7a1d0347305393f4bdcc5)

Co-authored-by: Minmin Gong <gongminmin at msn.com>

files:
A Misc/NEWS.d/next/Windows/2019-05-05-05-23-34.bpo-28269.-MOHI7.rst
M Python/dynload_win.c

diff --git a/Misc/NEWS.d/next/Windows/2019-05-05-05-23-34.bpo-28269.-MOHI7.rst b/Misc/NEWS.d/next/Windows/2019-05-05-05-23-34.bpo-28269.-MOHI7.rst
new file mode 100644
index 000000000000..a531b98118a2
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2019-05-05-05-23-34.bpo-28269.-MOHI7.rst
@@ -0,0 +1 @@
+Replace use of :c:func:`strcasecmp` for the system function :c:func:`_stricmp`. Patch by Minmin Gong.
diff --git a/Python/dynload_win.c b/Python/dynload_win.c
index 2f28c3cf9249..6deba1134e2a 100644
--- a/Python/dynload_win.c
+++ b/Python/dynload_win.c
@@ -38,24 +38,6 @@ const char *_PyImport_DynLoadFiletab[] = {
     NULL
 };
 
-/* Case insensitive string compare, to avoid any dependencies on particular
-   C RTL implementations */
-
-static int strcasecmp (const char *string1, const char *string2)
-{
-    int first, second;
-
-    do {
-        first  = tolower(*string1);
-        second = tolower(*string2);
-        string1++;
-        string2++;
-    } while (first && first == second);
-
-    return (first - second);
-}
-
-
 /* Function to return the name of the "python" DLL that the supplied module
    directly imports.  Looks through the list of imported modules and
    returns the first entry that starts with "python" (case sensitive) and
@@ -297,7 +279,7 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,
             import_python = GetPythonImport(hDLL);
 
             if (import_python &&
-                strcasecmp(buffer,import_python)) {
+                _stricmp(buffer,import_python)) {
                 PyErr_Format(PyExc_ImportError,
                              "Module use of %.150s conflicts "
                              "with this version of Python.",



More information about the Python-checkins mailing list