summaryrefslogtreecommitdiffstats
path: root/private/utils/untfs/src/hackwc.cxx
blob: b25ed903060268cc2aa2a9e8e5f3e1af96bf0f64 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*++

Copyright (c) 1991	Microsoft Corporation

Module Name:

    hackwc.cxx

Abstract:

    This module contains the definition for a hack that allows me
    to compare attribute names correctly.

    The comparison of attribute names is binary (word by word);
    I can't use WSTRING because it's comparisons are all based
    on the locale, while this comparison is locale-independent.

Author:

	Bill McJohn (billmc) 14-Aug-91

Environment:

	ULIB, User Mode

--*/

#include <pch.cxx>

#define _NTAPI_ULIB_
#define _UNTFS_MEMBER_

#include "ulib.hxx"
#include "error.hxx"
#include "untfs.hxx"

#include "hackwc.hxx"

INT
CountedWCMemCmp(
    IN PCWSTR String1,
    IN ULONG Length1,
    IN PCWSTR String2,
    IN ULONG Length2
    )
/*++

Routine Description:

    This function compares two counted wide-character buffers.
    It compares word-by-word, rather than byte by byte.

Arguments:

    String1 -- supplies the first wide-character buffer
    Length1 -- supplies the number of wide characters in String1
    String2 -- supplies the second wide-character buffer
    Length2 -- supplies the number of wide characters in String2

Return Value:

    a negative value if String1 is less than String2
    zero if String1 equals String2
    a positive value if String1 is greater than String2

--*/
{
    ULONG i;
    LONG res;

    i = ( Length1 < Length2 ) ? Length1 : Length2;

    while( i-- ) {

        if( (res = *String1++ - *String2++) != 0 ) {

            return res;
        }
    }

    return Length1 - Length2;
}