Back to index

glibc  2.9
Functions
wcsncmp.c File Reference
#include <wchar.h>

Go to the source code of this file.

Functions

int wcsncmp (wchar_t *s1, const wchar_t *s2, size_t n) const

Function Documentation

int wcsncmp ( wchar_t *  s1,
const wchar_t *  s2,
size_t  n 
) const

Definition at line 28 of file wcsncmp.c.

{
  wint_t c1 = L'\0';
  wint_t c2 = L'\0';

  if (n >= 4)
    {
      size_t n4 = n >> 2;
      do
       {
         c1 = (wint_t) *s1++;
         c2 = (wint_t) *s2++;
         if (c1 == L'\0' || c1 != c2)
           return c1 - c2;
         c1 = (wint_t) *s1++;
         c2 = (wint_t) *s2++;
         if (c1 == L'\0' || c1 != c2)
           return c1 - c2;
         c1 = (wint_t) *s1++;
         c2 = (wint_t) *s2++;
         if (c1 == L'\0' || c1 != c2)
           return c1 - c2;
         c1 = (wint_t) *s1++;
         c2 = (wint_t) *s2++;
         if (c1 == L'\0' || c1 != c2)
           return c1 - c2;
       } while (--n4 > 0);
      n &= 3;
    }

  while (n > 0)
    {
      c1 = (wint_t) *s1++;
      c2 = (wint_t) *s2++;
      if (c1 == L'\0' || c1 != c2)
       return c1 - c2;
      n--;
    }

  return c1 - c2;
}