diff -r 000000000000 -r bde4ae8d615e os/ossrv/genericopenlibs/cstdlib/LCHAR/STRCMP.C --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/os/ossrv/genericopenlibs/cstdlib/LCHAR/STRCMP.C Fri Jun 15 03:10:57 2012 +0200 @@ -0,0 +1,92 @@ +/* +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* FUNCTION +* <>---character string compare +* INDEX +* strcmp +* ANSI_SYNOPSIS +* #include +* int strcmp(const char *<[a]>, const char *<[b]>); +* TRAD_SYNOPSIS +* #include +* int strcmp(<[a]>, <[b]>) +* char *<[a]>; +* char *<[b]>; +* <> compares the string at <[a]> to +* the string at <[b]>. +* RETURNS +* If <<*<[a]>>> sorts lexicographically after <<*<[b]>>>, +* <> returns a number greater than zero. If the two +* strings match, <> returns zero. If <<*<[a]>>> +* sorts lexicographically before <<*<[b]>>>, <> returns a +* number less than zero. +* PORTABILITY +* <> is ANSI C. +* <> requires no supporting OS subroutines. +* QUICKREF +* strcmp ansi pure +* +* +*/ + + + +#include + +/** +Compare two strings. +Compares string1 to s1 character by character. +This function starts comparing the first character of each string. +If they are equal to each other continues with the following pair +until the characters differ or until end of string is reached. +@return a value indicating the lexicographical relation between the strings +@param s1 Null-terminated string to compare. +@param s2 Null-terminated string to compare. +*/ +EXPORT_C int +strcmp (const char *s1, const char *s2) +{ + const unsigned char* p1=(const unsigned char*)s1; + const unsigned char* p2=(const unsigned char*)s2; + for (;;) + { + int c1=*p1++; + int d=c1-*p2++; + if (d!=0) + return d; + if (c1==0) + return d; + } +} + +/** +Compare the wide-character string pointed to by s1 to the wide-character +string pointed to by s2. +@return an integer greater than, equal to, or less than zero, if the +wide-character string pointed to by s1 is greater than, equal to, +or less than the wide-character string pointed to by s2. +*/ +EXPORT_C int wcscmp (const wchar_t *s1, const wchar_t *s2) +{ + for (;;) + { + int c1=*s1++; + int d=c1-*s2++; + if (d!=0) + return d; + if (c1==0) + return d; + } +}