Blame wcsmbs/wcsncase.c

Packit Service 82fcde
/* Compare at most N wide characters of two strings without taking care
Packit Service 82fcde
   for the case.
Packit Service 82fcde
   Copyright (C) 1992-2018 Free Software Foundation, Inc.
Packit Service 82fcde
   This file is part of the GNU C Library.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is free software; you can redistribute it and/or
Packit Service 82fcde
   modify it under the terms of the GNU Lesser General Public
Packit Service 82fcde
   License as published by the Free Software Foundation; either
Packit Service 82fcde
   version 2.1 of the License, or (at your option) any later version.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service 82fcde
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 82fcde
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 82fcde
   Lesser General Public License for more details.
Packit Service 82fcde
Packit Service 82fcde
   You should have received a copy of the GNU Lesser General Public
Packit Service 82fcde
   License along with the GNU C Library; if not, see
Packit Service 82fcde
   <http://www.gnu.org/licenses/>.  */
Packit Service 82fcde
Packit Service 82fcde
#ifdef HAVE_CONFIG_H
Packit Service 82fcde
# include <config.h>
Packit Service 82fcde
#endif
Packit Service 82fcde
Packit Service 82fcde
#include <wchar.h>
Packit Service 82fcde
#include <wctype.h>
Packit Service 82fcde
Packit Service 82fcde
#ifndef weak_alias
Packit Service 82fcde
# define __wcsncasecmp wcsncasecmp
Packit Service 82fcde
# define TOLOWER(Ch) towlower (Ch)
Packit Service 82fcde
#else
Packit Service 82fcde
# ifdef USE_IN_EXTENDED_LOCALE_MODEL
Packit Service 82fcde
#  define __wcsncasecmp __wcsncasecmp_l
Packit Service 82fcde
#  define TOLOWER(Ch) __towlower_l ((Ch), loc)
Packit Service 82fcde
# else
Packit Service 82fcde
#  define TOLOWER(Ch) towlower (Ch)
Packit Service 82fcde
# endif
Packit Service 82fcde
#endif
Packit Service 82fcde
Packit Service 82fcde
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
Packit Service 82fcde
# define LOCALE_PARAM , locale_t loc
Packit Service 82fcde
#else
Packit Service 82fcde
# define LOCALE_PARAM
Packit Service 82fcde
#endif
Packit Service 82fcde
Packit Service 82fcde
/* Compare no more than N wide characters of S1 and S2,
Packit Service 82fcde
   ignoring case, returning less than, equal to or
Packit Service 82fcde
   greater than zero if S1 is lexicographically less
Packit Service 82fcde
   than, equal to or greater than S2.  */
Packit Service 82fcde
int
Packit Service 82fcde
__wcsncasecmp (const wchar_t *s1, const wchar_t *s2, size_t n LOCALE_PARAM)
Packit Service 82fcde
{
Packit Service 82fcde
  wint_t c1, c2;
Packit Service 82fcde
Packit Service 82fcde
  if (s1 == s2 || n == 0)
Packit Service 82fcde
    return 0;
Packit Service 82fcde
Packit Service 82fcde
  do
Packit Service 82fcde
    {
Packit Service 82fcde
      c1 = (wint_t) TOLOWER (*s1++);
Packit Service 82fcde
      c2 = (wint_t) TOLOWER (*s2++);
Packit Service 82fcde
      if (c1 == L'\0' || c1 != c2)
Packit Service 82fcde
	return c1 - c2;
Packit Service 82fcde
    } while (--n > 0);
Packit Service 82fcde
Packit Service 82fcde
  return c1 - c2;
Packit Service 82fcde
}
Packit Service 82fcde
#ifndef __wcsncasecmp
Packit Service 82fcde
weak_alias (__wcsncasecmp, wcsncasecmp)
Packit Service 82fcde
#endif