~mingw-w64/mingw-w64/experimental

« back to all changes in this revision

Viewing changes to ros-privexp/mingw-w64-crt/misc/wmemcmp.c

  • Committer: NightStrike
  • Date: 2010-08-11 22:20:57 UTC
  • Revision ID: svn-v4:4407c894-4637-0410-b4f5-ada5f102cad1:experimental:3266
Branch for adding option for supporting ros

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * This file has no copyright assigned and is placed in the Public Domain.
 
3
 * This file is part of the w64 mingw-runtime package.
 
4
 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
 
5
 */
 
6
/*      This source code was extracted from the Q8 package created and placed
 
7
    in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil>
 
8
    last edit:  1999/11/05      gwyn@arl.mil
 
9
 
 
10
    Implements subclause 7.24 of ISO/IEC 9899:1999 (E).
 
11
 
 
12
        It supports an encoding where all char codes are mapped
 
13
        to the *same* code values within a wchar_t or wint_t,
 
14
        so long as no other wchar_t codes are used by the program.
 
15
 
 
16
*/
 
17
 
 
18
#define __CRT__NO_INLINE
 
19
#include        <wchar.h>
 
20
 
 
21
#if 0
 
22
int
 
23
wmemcmp(s1, s2, n)
 
24
        register const wchar_t  *s1;
 
25
        register const wchar_t  *s2;
 
26
        size_t                          n;
 
27
{
 
28
        if ( n == 0 || s1 == s2 )
 
29
                return 0;               /* even for NULL pointers */
 
30
 
 
31
        if ( (s1 != NULL) != (s2 != NULL) )
 
32
                return s2 == NULL ? 1 : -1;     /* robust */
 
33
 
 
34
        for ( ; n > 0; ++s1, ++s2, --n )
 
35
                if ( *s1 != *s2 )
 
36
                        return *s1 - *s2;
 
37
 
 
38
        return 0;
 
39
}
 
40
#endif
 
41
 
 
42
int __cdecl wmemcmp(const wchar_t *_S1,const wchar_t *_S2,size_t _N)
 
43
{
 
44
        if (_N == 0 || _S1 == _S2)
 
45
                return 0;       /* even for NULL pointers */
 
46
 
 
47
        if ((_S1 != NULL) != (_S2 != NULL))
 
48
                return _S2 == NULL ? 1 : -1;    /* robust */
 
49
 
 
50
        for ( ; 0 < _N; ++_S1, ++_S2, --_N)
 
51
                if (*_S1 != *_S2)
 
52
                        return (*_S1 < *_S2 ? -1 : +1);
 
53
 
 
54
        return 0;
 
55
}
 
56