jstrspn.c
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 87 行
C
87 行
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#include "variety.h"
#include <jstring.h>
/**
*
* Name: jstrspn
*
* Synopsis: unsigned int jstrspn( JSTRING str1, JSTRING str2 );
*
* JSTRING str1; 僒乕僠偝傟傞暥帤楍
* JSTRING str2; str1 偺拞偐傜僒乕僠偡傞暥帤偺廤崌
* unsigned ret; str2 偱巜掕偟偨暥帤偵堦抳偟側偄嵟弶偺暥帤傪
* 巜偡僀儞僨僢僋僗
*
* Description: jstrspn 娭悢偼, 暥帤楍 str1 偺拞偐傜丄暥帤楍 str2 偱巜掕偟偨
* 暥帤楍拞偺偄偢傟偺暥帤偲傕堦抳偟側偄丄嵟弶偺暥帤傪巜偡
* 僀儞僨僢僋僗傪曉偟傑偡丅str1 偺愭摢偐傜栠傝抣偑帵偡僶僀僩悢暘
* 偼丄str2 偱巜掕偟偨暥帤楍拞偺暥帤偩偗偱峔惉偝傟偰偄傞偙偲傪
* 堄枴偟傑偡丅str1 偑 str2 偱巜掕偟偨暥帤埲奜偱巒傑偭偰偄傞
* 偲偒偼丄0 傪曉偟傑偡丅
*
* Name: jstrspn
*
* Synopsis: ret = jstrspn( str1, str2 );
*
* JSTRING str1; 2-byte KANJI string
* JSTRING str2; 2-byte KANJI characters
* unsigned ret; Index to the first character in string str1
* which does not consist of string str2.
*
* Description: Jstrspn function returns the index to the first character in
* the string str1 which is not included in the string str2.
* In the other words, The string from the head of the string
* str1 through the ret bytes is consists of the characters in
* the string str2.
*
* Return: If the string str1 starts with a character which is not
* included in the string str2, this function returns 0.
*
**/
_WCRTLINK size_t jstrspn( const JCHAR *str1, const JCHAR *str2 )
{
const JCHAR *s1, *next_s1, *s2;
JMOJI c1, c2;
for( s1 = str1; next_s1 = jgetmoji( s1, &c1 ), c1; s1 = next_s1) {
for( s2 = str2;
( s2 = jgetmoji( s2, &c2 ), c2 ) && ( c1 != c2 );
);
if( !c2 ) break;
}
return ( s1 - str1 );
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?