1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LCHAR/STRPBRK.C Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,76 @@
1.4 +/*
1.5 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +* FUNCTION
1.19 +* <<strpbrk>>---find chars in string
1.20 +* INDEX
1.21 +* strpbrk
1.22 +* ANSI_SYNOPSIS
1.23 +* #include <string.h>
1.24 +* char *strpbrk(const char *<[s1]>, const char *<[s2]>);
1.25 +* TRAD_SYNOPSIS
1.26 +* #include <string.h>
1.27 +* char *strpbrk(<[s1]>, <[s2]>)
1.28 +* char *<[s1]>;
1.29 +* char *<[s2]>;
1.30 +* This function locates the first occurence in the string
1.31 +* pointed to by <[s1]> of any character in string pointed to by
1.32 +* <[s2]> (excluding the terminating null character).
1.33 +* RETURNS
1.34 +* <<strpbrk>> returns a pointer to the character found in <[s1]>, or a
1.35 +* null pointer if no character from <[s2]> occurs in <[s1]>.
1.36 +* PORTABILITY
1.37 +* <<strpbrk>> requires no supporting OS subroutines.
1.38 +*
1.39 +*
1.40 +*/
1.41 +
1.42 +
1.43 +
1.44 +#include <string.h>
1.45 +
1.46 +/**
1.47 +Scan string for specified characters.
1.48 +Scans string1 character by character, returning a pointer to the first character
1.49 +that matches with any of the characters in string2.
1.50 +The search does not includes the terminating null-characters.
1.51 +@return A pointer to the first appearance in string1 of a character specified in s2.
1.52 +If none of the characters specified in s2 exists in s1, a NULL pointer is returned.
1.53 +@param s1 Null-terminated string to be scanned.
1.54 +@param s2 Null-terminated string containing the character set to search for.
1.55 +*/
1.56 +EXPORT_C char *
1.57 +strpbrk (const char *s1, const char *s2)
1.58 +{
1.59 + const char *c = s2;
1.60 + if (!*s1)
1.61 + return (char *) NULL;
1.62 +
1.63 + while (*s1)
1.64 + {
1.65 + for (c = s2; *c; c++)
1.66 + {
1.67 + if (*s1 == *c)
1.68 + break;
1.69 + }
1.70 + if (*c)
1.71 + break;
1.72 + s1++;
1.73 + }
1.74 +
1.75 + if (*c == '\0')
1.76 + s1 = NULL;
1.77 +
1.78 + return (char *) s1;
1.79 +}