diff options
author | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
---|---|---|
committer | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
commit | e611b132f9b8abe35b362e5870b74bce94a1e58e (patch) | |
tree | a5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/crt32/mbstring/mbsncmp.c | |
download | NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2 NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip |
Diffstat (limited to 'private/crt32/mbstring/mbsncmp.c')
-rw-r--r-- | private/crt32/mbstring/mbsncmp.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/private/crt32/mbstring/mbsncmp.c b/private/crt32/mbstring/mbsncmp.c new file mode 100644 index 000000000..d9bbcdfaa --- /dev/null +++ b/private/crt32/mbstring/mbsncmp.c @@ -0,0 +1,69 @@ +/*** +*mbsncmp.c - Compare n characters of two MBCS strings +* +* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved. +* +*Purpose: +* Compare n characters of two MBCS strings +* +*Revision History: +* 11-19-92 KRS Ported from 16-bit sources. +* +*******************************************************************************/ + +#ifdef _MBCS +#include <cruntime.h> +#include <mbdata.h> +#include <mbctype.h> +#include <mbstring.h> + +/*** +*int mbsncmp(s1, s2, n) - Compare n characters of two MBCS strings +* +*Purpose: +* Compares up to n charcters of two strings for lexical order. +* Strings are compared on a character basis, not a byte basis. +* +*Entry: +* unsigned char *s1, *s2 = strings to compare +* size_t n = maximum number of characters to compare +* +*Exit: +* returns <0 if s1 < s2 +* returns 0 if s1 == s2 +* returns >0 if s1 > s2 +* +*Exceptions: +* +*******************************************************************************/ + +int _CRTAPI1 _mbsncmp( s1, s2, n ) +const unsigned char *s1; +const unsigned char *s2; +size_t n; +{ + unsigned short c1, c2; + + if (n==0) + return(0); + + while (n--) { + + c1 = *s1++; + if (_ISLEADBYTE(c1)) + c1 = ( (*s1 == '\0') ? 0 : ((c1<<8) | *s1++) ); + + c2 = *s2++; + if (_ISLEADBYTE(c2)) + c2 = ( (*s2 == '\0') ? 0 : ((c2<<8) | *s2++) ); + + if (c1 != c2) + return( (c1 > c2) ? 1 : -1); + + if (c1 == 0) + return(0); + } + + return(0); +} +#endif /* _MBCS */ |