From 36f6ba825d2322ddfba60c4c0e4e648cf3655abc Mon Sep 17 00:00:00 2001 From: Manoj Ampalam Date: Wed, 26 Oct 2016 15:07:46 -0700 Subject: [PATCH] cleaning up strcasecmp --- contrib/win32/openssh/win32compat.vcxproj | 1 - .../win32/openssh/win32compat.vcxproj.filters | 3 - contrib/win32/win32compat/inc/unistd.h | 20 ---- contrib/win32/win32compat/inc/w32posix.h | 8 ++ contrib/win32/win32compat/strcasecmp.c | 103 ------------------ 5 files changed, 8 insertions(+), 127 deletions(-) delete mode 100644 contrib/win32/win32compat/strcasecmp.c diff --git a/contrib/win32/openssh/win32compat.vcxproj b/contrib/win32/openssh/win32compat.vcxproj index acbbf5e..306eaa5 100644 --- a/contrib/win32/openssh/win32compat.vcxproj +++ b/contrib/win32/openssh/win32compat.vcxproj @@ -149,7 +149,6 @@ - diff --git a/contrib/win32/openssh/win32compat.vcxproj.filters b/contrib/win32/openssh/win32compat.vcxproj.filters index 09e364e..e8e0df9 100644 --- a/contrib/win32/openssh/win32compat.vcxproj.filters +++ b/contrib/win32/openssh/win32compat.vcxproj.filters @@ -51,9 +51,6 @@ Source Files - - Source Files - Source Files diff --git a/contrib/win32/win32compat/inc/unistd.h b/contrib/win32/win32compat/inc/unistd.h index 7af6a13..0d83b05 100644 --- a/contrib/win32/win32compat/inc/unistd.h +++ b/contrib/win32/win32compat/inc/unistd.h @@ -27,26 +27,6 @@ #define getdtablesize() MAX_FDS #define gethostname w32_gethostname -#define fopen w32_fopen_utf8 - int daemon(int nochdir, int noclose); -/* Compatibility header to avoid lots of #ifdefs in includes.h on Win32 */ - -#include - -/* We can't put these in string.h since we can't easily override that header, so here they are */ -#if !defined(HAVE_STRCASECMP) && !defined(__MINGW32__) -size_t strcasecmp(const char *left, const char *right); -#endif - -#if !defined(HAVE_STRNCASECMP) && !defined(__MINGW32__) -size_t strncasecmp(const char *left, const char *right, size_t n); -#endif - -#define popen _popen -#define pclose _pclose - -/* End of prototypes in the wrong file */ - #endif diff --git a/contrib/win32/win32compat/inc/w32posix.h b/contrib/win32/win32compat/inc/w32posix.h index eb67eaa..7fbeeb0 100644 --- a/contrib/win32/win32compat/inc/w32posix.h +++ b/contrib/win32/win32compat/inc/w32posix.h @@ -163,3 +163,11 @@ struct iovec void explicit_bzero(void *b, size_t len); + +/* string.h overrides */ +#define strcasecmp _stricmp +#define strncasecmp _strnicmp +/* stdio.h overrides */ +#define fopen w32_fopen_utf8 +#define popen _popen +#define pclose _pclose diff --git a/contrib/win32/win32compat/strcasecmp.c b/contrib/win32/win32compat/strcasecmp.c deleted file mode 100644 index 91e8527..0000000 --- a/contrib/win32/win32compat/strcasecmp.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Author: NoMachine - * - * Copyright (c) 2009, 2010 NoMachine - * All rights reserved - * - * Support functions and system calls' replacements needed to let the - * software run on Win32 based operating systems. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/* Similar to strcasecmp.c from OpenBSD */ -/* Note: This could be moved to the OpenBSD-Compat layer in OpenSSH and added to config.h etc. */ - -#include "includes.h" -#if !defined(HAVE_STRCASECMP) || !defined(HAVE_STRNCASECMP) -#include -#include -#endif - -#ifndef HAVE_STRCASECMP -size_t strcasecmp(const char *left, const char *right) -{ - #if 0 - - const unsigned char *uleft = (const unsigned char *) left, *uright = (const unsigned char *) right; - - while (tolower(*uleft) == tolower(*uright)) - { - if (*uleft++ == '\0') - { - return (0); - } - - uright++; - } - - return (tolower(*uleft) - tolower(*uright)); - - #else - - return stricmp(left, right); - - #endif -} -#endif - -#ifndef HAVE_STRNCASECMP -size_t strncasecmp(const char *left, const char *right, size_t n) -{ - #if 0 - - if (n != 0) - { - const unsigned char *uleft = (const unsigned char *) left, *uright = (const unsigned char *) right; - - do - { - if (tolower(*uleft) != tolower(*uright)) - { - return (tolower(*uleft) - tolower(*uright)); - } - - if (*uleft++ == '\0') - { - break; - } - - uright++; - } - while (--n != 0); - } - - return (0); - - #else - - return strnicmp(left, right, n); - - #endif -} -#endif