jstrrev.c
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 93 行
C
93 行
/****************************************************************************
*
* 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 <string.h>
#include <jstring.h>
#include <jctype.h>
/**
*
* Name: jstrrev -- 暥帤楍傪斀揮偡傞
*
* Synopsis: p = jstrrev( s );
*
* JSTRING p,s; 暥帤楍
*
* Description: 偙偺娭悢偼暥帤楍傪斀揮偟傑偡丅偮傑傝丄暥帤楍偺拞揰偵娭偟偰丄
* 夞揮偝偣傞娭悢偺娍帤斉偱偁傞丅娍帤偼侾暥帤偲偟偰埖傢傟丄
* 暥帤楍偺拞偺娍帤偺戞侾僶僀僩偲戞俀僶僀僩偺弴彉偼曐偨傟傞丅
*
* Returns: jstrrev 娭悢偼丄堷悢 s 偲摨偠抣傪曉偡丅
*
*
* Name: jstrrev -- reverse a character string
*
* Synopsis: p = jstrrev( s );
*
* JSTRING p,s; string pointer
*
* Description: This function reverses a character string. That is, it
* "rotates" the string about its mid-point (KANJI version).
* So the KANJI letter consider to 1 character, it to be kept
* the order for the first byte code and second byte code of
* a KANJI letter inward string.
*
* Returns: The jstrrev function returns the same value of argument "s".
*
**/
_WCRTLINK JSTRING jstrrev( JCHAR *s )
{
JCHAR *p, *q, *r;
p = s;
q = p + strlen( p );
while( p < q ) {
if( iskanji( *p ) ) {
if( iskanji2( *( r = p + 1 ) ) ) {
*p ^= *r;
*r ^= *p;
*p++ ^= *r;
}
}
p++;
}
p = s;
while( p < --q ) {
*p ^= *q;
*q ^= *p;
*p++ ^= *q;
}
return( s );
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?