fjstrset.c

来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 100 行

C
100
字号
/****************************************************************************
*
*                            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>
#include <string.h>

/********************************************************************
*
*  Name:        _fjstrset       暥帤楍偵暥帤傪杽傔傞
*
*  Synopsis:    p = _fjstrset( str, c, n );
*
*               FJSTRING        p;      str偲摨偠億僀儞僞
*               FJSTRING        str;    暥帤傪杽傔傞暥帤楍
*               JMOJI   c;      杽傔傞暥帤偺抣
*
*  Description: _fjstrset娭悢偼暥帤楍str傪堷悢 c 偺抣偱杽傔傑偡丅c 偑娍帤偺
*               応崌丄崅埵俉價僢僩偑丄娍帤偺戞侾僶僀僩偱丄掅埵俉價僢僩偑娍帤偺
*               戞俀僶僀僩偱偡丅戞俀僶僀僩偑 NULL偺応崌丄戞侾僶僀僩傕 NULL
*               偲偟偰埖偄傑偡丅傕偟丄 c 偵侾僶僀僩暥帤傪巜掕偡傞応崌偵偼丄
*               忋埵僶僀僩偼丄侽偵偡傞昁梫偑偁傝傑偡丅暥帤楍偺挿偝偑婏悢偺応崌
*               偵偼丄c 偑娍帤偺帪偵偼丄暥帤楍偺嵟屻偺僶僀僩偼0x20偵側傝傑偡丅
*
*  Returns:     _fjstrset娭悢偼 str 偲摨偠抣傪曉偟傑偡丅
*
*
*  Name:        _fjstrset               fill the string with a letter
*
*  Synopsis:    p = _fjstrset( str, c );
*
*               FJSTRING        p;      return value same as "str"
*               FJSTRING        str;    pointer to the string to be filled
*               JMOJI   c;      value of letter
*
*  Description: The _fjstrset function fills the string "str" with the value of
*               the argument "c". If you specify "c" with KANJI letter, JMOJI
*               consist with 16 bit and its' high byte consist with first byte
*               code of KANJI letter, and low byte consist with second byte
*               code of KANJI letter.
*               If second byte code is NULL then also consider the first byte
*               code to NULL. If you specify the 1 byte character code, it must
*               be into low byte of JMOJI, and high byte has to consist with
*               NULL code.
*               If length of the string is odd number then, and if you have
*               specified "c" with KANJI letter then, the last byte of string
*               is changed to 0x20. This function is a data independent form
*               that accept far pointer argunments. It is most useful in mix
*               memory model applications.
*
*  Returns:     The _fjstrset function returns the same value of "str".
*
***********************************************************************/

_WCRTLINK FJSTRING _WCI86FAR _fjstrset( JCHAR _WCFAR *str, JMOJI c )
{
    JCHAR _WCFAR *keep = str;
    size_t count, len;

    len = _fstrlen( str );
    if( jiszen( c ) ) {
        for( count = 0; count < len/2; count++ ) {
            str = _fjputmoji( str, c );
        }
        if( len & 1 ) *str = ' ';
    } else {
        _fmemset( str, c, len );
    }
    return keep;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?