~ubuntu-branches/ubuntu/precise/eglibc/precise-201308281639

« back to all changes in this revision

Viewing changes to wcsmbs/wmemcmp.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-02-08 01:58:09 UTC
  • mfrom: (1.5.3) (288.1.12 precise)
  • Revision ID: package-import@ubuntu.com-20120208015809-ulscst7uteq3e22z
Tags: 2.15~pre6-0ubuntu10
Merge from Debian (r5151, 2.13-26).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
 
1
/* Copyright (C) 1996, 1997, 2011 Free Software Foundation, Inc.
2
2
   This file is part of the GNU C Library.
3
3
   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
4
4
 
19
19
 
20
20
#include <wchar.h>
21
21
 
 
22
#ifndef WMEMCMP
 
23
# define WMEMCMP wmemcmp
 
24
#endif
22
25
 
23
26
int
24
 
wmemcmp (s1, s2, n)
 
27
WMEMCMP (s1, s2, n)
25
28
     const wchar_t *s1;
26
29
     const wchar_t *s2;
27
30
     size_t n;
28
31
{
29
 
  register wint_t c1;
30
 
  register wint_t c2;
 
32
  register wchar_t c1;
 
33
  register wchar_t c2;
31
34
 
32
35
  while (n >= 4)
33
36
    {
34
 
      c1 = (wint_t) s1[0];
35
 
      c2 = (wint_t) s2[0];
36
 
      if (c1 - c2 != 0)
37
 
        return c1 - c2;
38
 
      c1 = (wint_t) s1[1];
39
 
      c2 = (wint_t) s2[1];
40
 
      if (c1 - c2 != 0)
41
 
        return c1 - c2;
42
 
      c1 = (wint_t) s1[2];
43
 
      c2 = (wint_t) s2[2];
44
 
      if (c1 - c2 != 0)
45
 
        return c1 - c2;
46
 
      c1 = (wint_t) s1[3];
47
 
      c2 = (wint_t) s2[3];
48
 
      if (c1 - c2 != 0)
49
 
        return c1 - c2;
 
37
      c1 = s1[0];
 
38
      c2 = s2[0];
 
39
      if (c1 - c2 != 0)
 
40
        return c1 > c2 ? 1 : -1;
 
41
      c1 = s1[1];
 
42
      c2 = s2[1];
 
43
      if (c1 - c2 != 0)
 
44
        return c1 > c2 ? 1 : -1;
 
45
      c1 = s1[2];
 
46
      c2 = s2[2];
 
47
      if (c1 - c2 != 0)
 
48
        return c1 > c2 ? 1 : -1;
 
49
      c1 = s1[3];
 
50
      c2 = s2[3];
 
51
      if (c1 - c2 != 0)
 
52
        return c1 > c2 ? 1 : -1;
50
53
      s1 += 4;
51
54
      s2 += 4;
52
55
      n -= 4;
54
57
 
55
58
  if (n > 0)
56
59
    {
57
 
      c1 = (wint_t) s1[0];
58
 
      c2 = (wint_t) s2[0];
59
 
      if (c1 - c2 != 0)
60
 
        return c1 - c2;
61
 
      ++s1;
62
 
      ++s2;
63
 
      --n;
64
 
    }
65
 
  if (n > 0)
66
 
    {
67
 
      c1 = (wint_t) s1[0];
68
 
      c2 = (wint_t) s2[0];
69
 
      if (c1 - c2 != 0)
70
 
        return c1 - c2;
71
 
      ++s1;
72
 
      ++s2;
73
 
      --n;
74
 
    }
75
 
  if (n > 0)
76
 
    {
77
 
      c1 = (wint_t) s1[0];
78
 
      c2 = (wint_t) s2[0];
79
 
      if (c1 - c2 != 0)
80
 
        return c1 - c2;
 
60
      c1 = s1[0];
 
61
      c2 = s2[0];
 
62
      if (c1 - c2 != 0)
 
63
        return c1 > c2 ? 1 : -1;
 
64
      ++s1;
 
65
      ++s2;
 
66
      --n;
 
67
    }
 
68
  if (n > 0)
 
69
    {
 
70
      c1 = s1[0];
 
71
      c2 = s2[0];
 
72
      if (c1 - c2 != 0)
 
73
        return c1 > c2 ? 1 : -1;
 
74
      ++s1;
 
75
      ++s2;
 
76
      --n;
 
77
    }
 
78
  if (n > 0)
 
79
    {
 
80
      c1 = s1[0];
 
81
      c2 = s2[0];
 
82
      if (c1 - c2 != 0)
 
83
        return c1 > c2 ? 1 : -1;
81
84
    }
82
85
 
83
86
  return 0;