Clib string & memory functions
git-svn-id: svn://kolibrios.org@553 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
48
programs/develop/open watcom/trunk/clib/string/bits.c
Normal file
48
programs/develop/open watcom/trunk/clib/string/bits.c
Normal file
@@ -0,0 +1,48 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 "setbits.h"
|
||||
|
||||
const unsigned char _HUGEDATA _Bits[] =
|
||||
{ 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
|
||||
|
||||
void __setbits( unsigned char vector[32], const char *charset )
|
||||
{
|
||||
unsigned char c;
|
||||
|
||||
memset( vector, 0, 32 );
|
||||
for( ; c = *charset; ++charset ) {
|
||||
vector[ c >> 3 ] |= _Bits[ c & 0x07 ];
|
||||
}
|
||||
}
|
139
programs/develop/open watcom/trunk/clib/string/bprintf.c
Normal file
139
programs/develop/open watcom/trunk/clib/string/bprintf.c
Normal file
@@ -0,0 +1,139 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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: This module supports formatted output to a character buffer.
|
||||
* Both character and wide character formatting are included.
|
||||
* For added library granularity, this module could be split
|
||||
* into two, with "bprintf" functions in one file and the
|
||||
* "snprintf" functions in another.
|
||||
*
|
||||
* C library functions:
|
||||
* _bprintf, _vbprintf
|
||||
* _bwprintf, _vbwprintf
|
||||
* _snprintf, _snwprintf
|
||||
* _vsnprintf, _vsnwprintf
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include "widechar.h"
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "printf.h"
|
||||
|
||||
struct buf_limit {
|
||||
CHAR_TYPE *bufptr;
|
||||
size_t bufsize;
|
||||
int bufover;
|
||||
};
|
||||
|
||||
/*
|
||||
* buf_putc -- append a character to a string in memory
|
||||
*/
|
||||
static slib_callback_t buf_putc; // setup calling convention
|
||||
static void __SLIB_CALLBACK buf_putc( SPECS __SLIB *specs, int op_char )
|
||||
{
|
||||
struct buf_limit *bufinfo;
|
||||
|
||||
bufinfo = (struct buf_limit *)specs->_dest;
|
||||
if( specs->_output_count < bufinfo->bufsize ) {
|
||||
*( bufinfo->bufptr++ ) = op_char;
|
||||
specs->_output_count++;
|
||||
} else {
|
||||
bufinfo->bufover = -1;
|
||||
}
|
||||
}
|
||||
|
||||
_WCRTLINK int __F_NAME(_vbprintf,_vbwprintf) ( CHAR_TYPE *s, size_t bufsize,
|
||||
const CHAR_TYPE *format, va_list arg)
|
||||
{
|
||||
register int len;
|
||||
auto struct buf_limit bufinfo;
|
||||
slib_callback_t *tmp;
|
||||
|
||||
bufinfo.bufptr = s;
|
||||
bufinfo.bufsize = bufsize - 1;
|
||||
bufinfo.bufover = 0;
|
||||
#if defined( __386__ ) && defined( __QNX__ )
|
||||
/* avoid some segment relocations for 32-bit QNX */
|
||||
tmp = (void (*)())buf_putc;
|
||||
#else
|
||||
tmp = buf_putc;
|
||||
#endif
|
||||
len = __F_NAME(__prtf,__wprtf)( &bufinfo, format, arg, tmp );
|
||||
s[len] = '\0';
|
||||
return( len );
|
||||
}
|
||||
|
||||
_WCRTLINK int __F_NAME(_bprintf,_bwprintf) ( CHAR_TYPE *dest, size_t bufsize,
|
||||
const CHAR_TYPE *format, ... )
|
||||
{
|
||||
auto va_list args;
|
||||
|
||||
va_start( args, format );
|
||||
return( __F_NAME(_vbprintf,_vbwprintf)( dest, bufsize, format, args ) );
|
||||
}
|
||||
|
||||
// Notes:
|
||||
// _vsnprintf, _vsnwprintf must return an error (-1) when buffer too small
|
||||
// If a NULL character can fit, append it. If not, no error.
|
||||
|
||||
_WCRTLINK int __F_NAME(_vsnprintf,_vsnwprintf) ( CHAR_TYPE *s, size_t bufsize,
|
||||
const CHAR_TYPE *format, va_list arg)
|
||||
{
|
||||
register int len;
|
||||
auto struct buf_limit bufinfo;
|
||||
slib_callback_t *tmp;
|
||||
|
||||
bufinfo.bufptr = s;
|
||||
bufinfo.bufsize = bufsize;
|
||||
bufinfo.bufover = 0;
|
||||
#if defined( __386__ ) && defined( __QNX__ )
|
||||
/* avoid some segment relocations for 32-bit QNX */
|
||||
tmp = (void (*)())buf_putc;
|
||||
#else
|
||||
tmp = buf_putc;
|
||||
#endif
|
||||
len = __F_NAME(__prtf,__wprtf)( &bufinfo, format, arg, tmp );
|
||||
if( len < bufsize ) {
|
||||
s[len] = '\0';
|
||||
}
|
||||
if( bufinfo.bufover == 0 ) {
|
||||
return( len );
|
||||
} else {
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
|
||||
_WCRTLINK int __F_NAME(_snprintf,_snwprintf) ( CHAR_TYPE *dest, size_t bufsize,
|
||||
const CHAR_TYPE *format, ... )
|
||||
{
|
||||
auto va_list args;
|
||||
|
||||
va_start( args, format );
|
||||
return( __F_NAME(_vsnprintf,_vsnwprintf)( dest, bufsize, format, args ) );
|
||||
}
|
213
programs/develop/open watcom/trunk/clib/string/cmp386.asm
Normal file
213
programs/develop/open watcom/trunk/clib/string/cmp386.asm
Normal file
@@ -0,0 +1,213 @@
|
||||
;*****************************************************************************
|
||||
;*
|
||||
;* 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: Intel 386 implementation strcmp().
|
||||
;*
|
||||
;*****************************************************************************
|
||||
|
||||
|
||||
include mdef.inc
|
||||
include struct.inc
|
||||
|
||||
ifdef _PROFILE
|
||||
include p5prof.inc
|
||||
endif
|
||||
|
||||
modstart _strcmp,para
|
||||
|
||||
cmp4 macro off
|
||||
mov ebx,off[eax] ; get dword from op1
|
||||
mov ecx,off[edx] ; get dword from op2
|
||||
cmp ecx,ebx ; compare them
|
||||
jne unequal ; quit if not equal
|
||||
ife off-12
|
||||
add eax,off+4 ; point to next group of dwords
|
||||
add edx,off+4 ; ...
|
||||
endif
|
||||
not ecx ; ...
|
||||
add ebx,0FEFEFEFFh ; determine if '\0' is one of bytes
|
||||
and ebx,ecx ; ...
|
||||
and ebx,80808080h ; ebx will be non-zero if '\0' found
|
||||
endm
|
||||
|
||||
defpe strcmp
|
||||
xdefp "C",strcmp
|
||||
ifdef _PROFILE
|
||||
P5Prolog
|
||||
endif
|
||||
ifdef __STACK__
|
||||
mov eax,4[esp] ; get p1
|
||||
mov edx,8[esp] ; get p2
|
||||
endif
|
||||
cmp eax,edx ; pointers equal ?
|
||||
je equalnorst ; yes, return 0
|
||||
ifndef __STACK__
|
||||
push ecx ; save register
|
||||
endif
|
||||
test al,3 ; p1 aligned ?
|
||||
jne realign ; no, go and realign
|
||||
test dl,3 ; p2 aligned ?
|
||||
jne slowcpy ; no, do the slow copy (impossible to align both)
|
||||
|
||||
fastcpy:
|
||||
push ebx ; save register
|
||||
|
||||
align 4
|
||||
_loop ; - loop
|
||||
cmp4 0 ; - - compare first dword
|
||||
_quif ne ; - - quit if end of string
|
||||
cmp4 4 ; - - compare second dword
|
||||
_quif ne ; - - quit if end of string
|
||||
cmp4 8 ; - - compare third dword
|
||||
_quif ne ; - - quit if end of string
|
||||
cmp4 12 ; - - compare fourth dword
|
||||
_until ne ; - until end of string
|
||||
equalrst: ; strings equal, restore registers
|
||||
pop ebx ; restore register
|
||||
ifndef __STACK__
|
||||
pop ecx ; ...
|
||||
endif
|
||||
equalnorst: ; strings equal, skip register restore
|
||||
sub eax,eax ; indicate strings equal
|
||||
ifdef _PROFILE
|
||||
P5Epilog
|
||||
endif
|
||||
ret ; return
|
||||
|
||||
unequal: ; dword was not equal
|
||||
_guess ; guess strings are equal
|
||||
cmp bl,cl ; - check low bytes
|
||||
_quif ne ; - quit if not equal
|
||||
cmp bl,0 ; - stop if end of string
|
||||
je equalrst ; - ...
|
||||
cmp bh,ch ; - check next bytes
|
||||
_quif ne ; - quit if not equal
|
||||
cmp bh,0 ; - stop if end of string
|
||||
je equalrst ; - ...
|
||||
shr ebx,16 ; - shift top 2 bytes to bottom
|
||||
shr ecx,16 ; - ...
|
||||
cmp bl,cl ; - check third byte
|
||||
_quif ne ; - quit if not equal
|
||||
cmp bl,0 ; - stop if end of string
|
||||
je equalrst ; - ...
|
||||
cmp bh,ch ; - check high order byte
|
||||
;; we know at this point that bh != ch, just have to do the compare
|
||||
;; _quif ne ; - quit if not equal
|
||||
;; cmp bh,0 ; - stop if end of string
|
||||
;; je equalrst ; - ...
|
||||
_endguess ; endguess
|
||||
sbb eax,eax ; eax = 0 if op1>op2, -1 if op1<op2
|
||||
or al,1 ; eax = 1 if op1>op2, -1 if op1<op2
|
||||
pop ebx ; restore registers
|
||||
ifndef __STACK__
|
||||
pop ecx ; ...
|
||||
endif
|
||||
ifdef _PROFILE
|
||||
P5Epilog
|
||||
endif
|
||||
ret ; return
|
||||
|
||||
align 4
|
||||
realign:
|
||||
_loop ; - loop
|
||||
mov cl,[eax] ; get byte from p1
|
||||
inc eax ; point to next byte
|
||||
mov ch,[edx] ; get byte from p2
|
||||
inc edx ; point to next byte
|
||||
cmp cl,ch ; bytes equal?
|
||||
jne unequal2 ; unequal, quit
|
||||
or cl,cl ; end of string ?
|
||||
je equal2 ; yes, quit
|
||||
test al,3 ; check alignment
|
||||
_until e ; until aligned
|
||||
test dl,3 ; p2 aligned ?
|
||||
je fastcpy ; yes
|
||||
|
||||
align 4
|
||||
slowcpy:
|
||||
_loop
|
||||
mov ecx,[eax] ; get aligned 4 bytes
|
||||
cmp cl,[edx] ; check 1st byte
|
||||
jne unequal2 ; bytes not equal
|
||||
or cl,cl ; end of string?
|
||||
je equal2 ; yes, quit
|
||||
cmp ch,[edx+1] ; check 2nd byte
|
||||
jne unequal2 ; bytes not equal
|
||||
or ch,ch ; end of string?
|
||||
je equal2 ; yes, quit
|
||||
shr ecx,16 ; move next pair of bytes to be tested
|
||||
cmp cl,[edx+2] ; check 3rd byte
|
||||
jne unequal2 ; bytes not equal
|
||||
or cl,cl ; end of string?
|
||||
je equal2 ; yes, quit
|
||||
cmp ch,[edx+3] ; check 4th byte
|
||||
jne unequal2 ; bytes not equal
|
||||
or ch,ch ; end of string?
|
||||
je equal2 ; yes, quit
|
||||
mov ecx,[eax+4] ; get next aligned 4 bytes
|
||||
cmp cl,[edx+4] ; check 5th byte
|
||||
jne unequal2 ; bytes not equal
|
||||
or cl,cl ; end of string?
|
||||
je equal2 ; yes, quit
|
||||
cmp ch,[edx+5] ; check 6th byte
|
||||
jne unequal2 ; bytes not equal
|
||||
or ch,ch ; end of string?
|
||||
je equal2 ; yes, quit
|
||||
shr ecx,16 ; move next pair of bytes to be tested
|
||||
cmp cl,[edx+6] ; check 7th byte
|
||||
jne unequal2 ; bytes not equal
|
||||
or cl,cl ; end of string?
|
||||
je equal2 ; yes, quit
|
||||
cmp ch,[edx+7] ; check 8th byte
|
||||
jne unequal2 ; bytes not equal
|
||||
add eax,8 ; next 8 bytes
|
||||
add edx,8 ; next 8 bytes
|
||||
or ch,ch ; end of string?
|
||||
_until e ; until equal
|
||||
equal2:
|
||||
xor eax,eax ; return 0
|
||||
ifndef __STACK__
|
||||
pop ecx ; restore registers
|
||||
endif
|
||||
ifdef _PROFILE
|
||||
P5Epilog
|
||||
endif
|
||||
ret ; return
|
||||
|
||||
unequal2:
|
||||
sbb eax,eax ; eax = 0 if op1>op2, -1 if op1<op2
|
||||
or al,1 ; eax = 1 if op1>op2, -1 if op1<op2
|
||||
ifndef __STACK__
|
||||
pop ecx ; restore registers
|
||||
endif
|
||||
ifdef _PROFILE
|
||||
P5Epilog
|
||||
endif
|
||||
ret ; return
|
||||
endproc strcmp
|
||||
|
||||
endmod
|
||||
end
|
46
programs/develop/open watcom/trunk/clib/string/errstr.h
Normal file
46
programs/develop/open watcom/trunk/clib/string/errstr.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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: Internal definitions for strerror() and friends.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#if defined(__NETWARE__) || defined(__WIDECHAR__)
|
||||
|
||||
extern int _WCNEAR sys_nerr;
|
||||
extern char *sys_errlist[];
|
||||
#define _sys_nerr sys_nerr
|
||||
#define _sys_errlist sys_errlist
|
||||
|
||||
#else
|
||||
|
||||
extern char *_sys_errlist[];
|
||||
extern int _WCNEAR _sys_nerr;
|
||||
|
||||
#endif
|
||||
|
||||
#define UNKNOWN_ERROR "unknown error"
|
45
programs/develop/open watcom/trunk/clib/string/fsetbits.c
Normal file
45
programs/develop/open watcom/trunk/clib/string/fsetbits.c
Normal file
@@ -0,0 +1,45 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 "setbits.h"
|
||||
|
||||
void __fsetbits( unsigned char _WCFAR *vector, const char _WCFAR *charset )
|
||||
{
|
||||
unsigned char c;
|
||||
|
||||
_fmemset( vector, 0, 32 );
|
||||
for( ; c = *charset; ++charset ) {
|
||||
vector[ c >> 3 ] |= _Bits[ c & 0x07 ];
|
||||
}
|
||||
}
|
51
programs/develop/open watcom/trunk/clib/string/fstrcat.c
Normal file
51
programs/develop/open watcom/trunk/clib/string/fstrcat.c
Normal file
@@ -0,0 +1,51 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 <stdio.h>
|
||||
#include "xstring.h"
|
||||
|
||||
#undef _fstrcat
|
||||
/* concatenate t to the end of dst */
|
||||
|
||||
_WCRTLINK char _WCFAR *_fstrcat( char _WCFAR *dst, const char _WCFAR *t )
|
||||
{
|
||||
#if defined(__INLINE_FUNCTIONS__)
|
||||
return( _inline__fstrcat( dst, t ) );
|
||||
#else
|
||||
char _WCFAR *s;
|
||||
s = dst;
|
||||
while( *s != '\0' ) ++s;
|
||||
while( *s++ = *t++ ) ;
|
||||
return( dst );
|
||||
#endif
|
||||
}
|
91
programs/develop/open watcom/trunk/clib/string/fstrchr.c
Normal file
91
programs/develop/open watcom/trunk/clib/string/fstrchr.c
Normal file
@@ -0,0 +1,91 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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>
|
||||
|
||||
#ifdef M_I86
|
||||
|
||||
extern char _WCFAR * _scan1( char _WCFAR *s, int c );
|
||||
|
||||
/* use scan1 to find the char we are looking for */
|
||||
|
||||
#pragma aux _scan1 = 0x1e /* push ds */\
|
||||
0x8e 0xda /* mov ds,dx */\
|
||||
0xad /* L1:lodsw */\
|
||||
0x38 0xd8 /* cmp al,bl */\
|
||||
0x74 0x22 /* je L3 */\
|
||||
0x84 0xc0 /* test al,al*/\
|
||||
0x74 0x19 /* je L2 */\
|
||||
0x38 0xdc /* cmp ah,bl */\
|
||||
0x74 0x1b /* je L4 */\
|
||||
0x84 0xe4 /* test ah,ah*/\
|
||||
0x74 0x11 /* je L2 */\
|
||||
0xad /* lodsw */\
|
||||
0x38 0xd8 /* cmp al,bl */\
|
||||
0x74 0x11 /* je L3 */\
|
||||
0x84 0xc0 /* test al,al*/\
|
||||
0x74 0x08 /* je L2 */\
|
||||
0x38 0xdc /* cmp ah,bl */\
|
||||
0x74 0x0a /* je L4 */\
|
||||
0x84 0xe4 /* test ah,ah*/\
|
||||
0x75 0xde /* jne L1 */\
|
||||
0x31 0xf6 /* L2:xor si,si*/\
|
||||
0x89 0xf2 /* mov dx,si */\
|
||||
0xa9 /* test ax,... */\
|
||||
0x4e /* L3:dec si */\
|
||||
0x4e /* L4:dec si */\
|
||||
0x1f /* pop ds */\
|
||||
parm caller [dx si] [bl]\
|
||||
value [dx si]\
|
||||
modify [ax dx si];
|
||||
#endif
|
||||
|
||||
|
||||
/* locate the first occurrence of c in the initial n characters of the
|
||||
string pointed to by s. The terminating null character is considered
|
||||
to be part of the string.
|
||||
If the character c is not found, NULL is returned.
|
||||
*/
|
||||
#undef _fstrchr
|
||||
|
||||
_WCRTLINK char _WCFAR *_fstrchr( const char _WCFAR *s, int c )
|
||||
{
|
||||
//#if defined(M_I86)
|
||||
//return( _scan1( (char _WCFAR *)s, c ) );
|
||||
//#else
|
||||
do {
|
||||
if( *s == c ) return( (char _WCFAR *)s );
|
||||
} while( *s++ != '\0' );
|
||||
return( NULL );
|
||||
//#endif
|
||||
}
|
50
programs/develop/open watcom/trunk/clib/string/fstrcmp.c
Normal file
50
programs/develop/open watcom/trunk/clib/string/fstrcmp.c
Normal file
@@ -0,0 +1,50 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 "xstring.h"
|
||||
|
||||
#undef _fstrcmp
|
||||
|
||||
/* return <0 if s<t, 0 if s==t, >0 if s>t */
|
||||
|
||||
_WCRTLINK int _fstrcmp( const char _WCFAR *s, const char _WCFAR *t )
|
||||
{
|
||||
#if /*defined(M_I86) &&*/ defined(__INLINE_FUNCTIONS__)
|
||||
return( _inline__fstrcmp( s, t ) );
|
||||
#else
|
||||
for( ; *s == *t; s++, t++ )
|
||||
if( *s == '\0' )
|
||||
return( 0 );
|
||||
return( *s - *t );
|
||||
#endif
|
||||
}
|
49
programs/develop/open watcom/trunk/clib/string/fstrcpy.c
Normal file
49
programs/develop/open watcom/trunk/clib/string/fstrcpy.c
Normal file
@@ -0,0 +1,49 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 "xstring.h"
|
||||
|
||||
#undef _fstrcpy
|
||||
/* copy string t to string s */
|
||||
|
||||
_WCRTLINK char _WCFAR *_fstrcpy( char _WCFAR *s, const char _WCFAR *t )
|
||||
{
|
||||
#if defined(__INLINE_FUNCTIONS__)
|
||||
return( _inline__fstrcpy( s, t ) );
|
||||
#else
|
||||
char _WCFAR *dst;
|
||||
dst = s;
|
||||
while( *dst++ = *t++ );
|
||||
return( s );
|
||||
#endif
|
||||
}
|
57
programs/develop/open watcom/trunk/clib/string/fstrcspn.c
Normal file
57
programs/develop/open watcom/trunk/clib/string/fstrcspn.c
Normal file
@@ -0,0 +1,57 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 <stddef.h>
|
||||
#include <string.h>
|
||||
#include "setbits.h"
|
||||
|
||||
/* The strcspn function computes the length of the initial segment of the
|
||||
string pointed to by str which consists entirely of characters not from
|
||||
the string pointed to by charset. The terminating NULL character is not
|
||||
considered part of charset.
|
||||
*/
|
||||
|
||||
_WCRTLINK size_t _fstrcspn( const char _WCFAR *str, const char _WCFAR *charset )
|
||||
{
|
||||
unsigned /*char*/ tc;
|
||||
unsigned char vector[32];
|
||||
size_t len;
|
||||
|
||||
__fsetbits( vector, charset );
|
||||
len = 0;
|
||||
for( ; tc = (unsigned char) *str; ++len, ++str ) {
|
||||
/* quit if we find any char in charset */
|
||||
if( ( vector[ tc >> 3 ] & _Bits[ tc & 0x07 ] ) != 0 ) break;
|
||||
}
|
||||
return( len );
|
||||
}
|
49
programs/develop/open watcom/trunk/clib/string/fstrdup.c
Normal file
49
programs/develop/open watcom/trunk/clib/string/fstrdup.c
Normal file
@@ -0,0 +1,49 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 <ctype.h>
|
||||
#include <string.h>
|
||||
#include "liballoc.h"
|
||||
|
||||
_WCRTLINK char _WCFAR *_fstrdup( const char _WCFAR *str )
|
||||
{
|
||||
char _WCFAR *mem;
|
||||
int len;
|
||||
|
||||
len = _fstrlen( str ) + 1;
|
||||
mem = lib_malloc( len );
|
||||
if( mem ) {
|
||||
(_fmemcpy)( mem, str, len );
|
||||
}
|
||||
return( mem );
|
||||
}
|
55
programs/develop/open watcom/trunk/clib/string/fstricmp.c
Normal file
55
programs/develop/open watcom/trunk/clib/string/fstricmp.c
Normal file
@@ -0,0 +1,55 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
/* return <0 if s<t, 0 if s==t, >0 if s>t */
|
||||
|
||||
_WCRTLINK int _fstricmp( const char _WCFAR *s, const char _WCFAR *t )
|
||||
{
|
||||
unsigned char c1;
|
||||
unsigned char c2;
|
||||
|
||||
for(;;) {
|
||||
c1 = *s;
|
||||
if( c1 >= 'A' && c1 <= 'Z' ) c1 += 'a' - 'A';
|
||||
c2 = *t;
|
||||
if( c2 >= 'A' && c2 <= 'Z' ) c2 += 'a' - 'A';
|
||||
if( c1 != c2 ) break;
|
||||
if( c1 == '\0' ) break;
|
||||
++s;
|
||||
++t;
|
||||
}
|
||||
return( c1 - c2 );
|
||||
}
|
49
programs/develop/open watcom/trunk/clib/string/fstrlen.c
Normal file
49
programs/develop/open watcom/trunk/clib/string/fstrlen.c
Normal file
@@ -0,0 +1,49 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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: Implementation of _fstrlen().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include "xstring.h"
|
||||
|
||||
#undef _fstrlen
|
||||
|
||||
_WCRTLINK size_t _fstrlen( const char _WCFAR *s ) /* return length of string s */
|
||||
{
|
||||
#if defined(__INLINE_FUNCTIONS__)
|
||||
return( _inline__fstrlen( s ) );
|
||||
#else
|
||||
const char _WCFAR *p;
|
||||
|
||||
p = s;
|
||||
while( *p != '\0' )
|
||||
++p;
|
||||
return( p - s );
|
||||
#endif
|
||||
}
|
52
programs/develop/open watcom/trunk/clib/string/fstrlwr.c
Normal file
52
programs/develop/open watcom/trunk/clib/string/fstrlwr.c
Normal file
@@ -0,0 +1,52 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
_WCRTLINK char _WCFAR *_fstrlwr( char _WCFAR *str )
|
||||
{
|
||||
char _WCFAR *p;
|
||||
unsigned char c;
|
||||
|
||||
p = str;
|
||||
while( c = *p ) {
|
||||
c -= 'A';
|
||||
if( c <= 'Z' - 'A' ) {
|
||||
c += 'a';
|
||||
*p = c;
|
||||
}
|
||||
++p;
|
||||
}
|
||||
return( str );
|
||||
}
|
86
programs/develop/open watcom/trunk/clib/string/fstrncat.c
Normal file
86
programs/develop/open watcom/trunk/clib/string/fstrncat.c
Normal file
@@ -0,0 +1,86 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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>
|
||||
|
||||
#ifdef M_I86
|
||||
|
||||
extern char _WCFAR *_fast_strncat( char _WCFAR *, const char _WCFAR *, size_t );
|
||||
|
||||
#pragma aux _fast_strncat = \
|
||||
0x1e /* push ds */\
|
||||
0x96 /* xchg si,ax */\
|
||||
0x8e 0xd8 /* mov ds,ax */\
|
||||
0x57 /* push di */\
|
||||
0xb9 0xff 0xff /* mov cx,ffffh */\
|
||||
0x31 0xc0 /* xor ax,ax */\
|
||||
0xf2 0xae /* repne scasb */\
|
||||
0x4f /* dec di */\
|
||||
0x89 0xd1 /* mov cx,dx */\
|
||||
0xac /* L1: lodsb */\
|
||||
0xaa /* stosb */\
|
||||
0x84 0xc0 /* test al,al */\
|
||||
0xe0 0xfa /* loopne L1 */\
|
||||
0x74 0x03 /* je L2 */\
|
||||
0x26 0x88 0x25 /* mov es:[di],ah */\
|
||||
0x58 /* L2: pop ax */\
|
||||
0x1f /* pop ds */\
|
||||
parm caller [es di] [si ax] [dx]\
|
||||
value [es ax] \
|
||||
modify exact [ax cx si di];
|
||||
#endif
|
||||
|
||||
/* concatenate t to the end of dst */
|
||||
|
||||
_WCRTLINK char _WCFAR *_fstrncat( char _WCFAR *dst, const char _WCFAR *t, size_t n )
|
||||
{
|
||||
#ifdef M_I86
|
||||
if( n ) {
|
||||
return( _fast_strncat( dst, t, n ) );
|
||||
}
|
||||
return( dst );
|
||||
#else
|
||||
char _WCFAR *s;
|
||||
|
||||
s = _fmemchr( dst, '\0', ~0 );
|
||||
while( n != 0 ) {
|
||||
*s = *t;
|
||||
if( *s == '\0' ) break;
|
||||
++s;
|
||||
++t;
|
||||
--n;
|
||||
}
|
||||
*s = '\0';
|
||||
return( dst );
|
||||
#endif
|
||||
}
|
80
programs/develop/open watcom/trunk/clib/string/fstrncmp.c
Normal file
80
programs/develop/open watcom/trunk/clib/string/fstrncmp.c
Normal file
@@ -0,0 +1,80 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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>
|
||||
|
||||
#ifdef M_I86
|
||||
|
||||
extern int _fast_strncmp( const char _WCFAR *, const char _WCFAR *, size_t );
|
||||
|
||||
#pragma aux _fast_strncmp = \
|
||||
0x1e /* push ds */ \
|
||||
0x96 /* xchg si,ax */\
|
||||
0x8e 0xd8 /* mov ds,ax */\
|
||||
0x89 0xfa /* mov dx,di */ \
|
||||
0x30 0xc0 /* xor al,al */ \
|
||||
0xf2 0xae /* repne scasb */ \
|
||||
0x89 0xf9 /* mov cx,di */ \
|
||||
0x89 0xd7 /* mov di,dx */ \
|
||||
0x29 0xf9 /* sub cx,di */ \
|
||||
0xf3 0xa6 /* repe cmpsb */ \
|
||||
0x74 0x05 /* je L1 */ \
|
||||
0x19 0xc9 /* sbb cx,cx */ \
|
||||
0x83 0xd9 0xff /* sbb cx,ffffh */ \
|
||||
/* L1: */ \
|
||||
0x1f /* pop ds */\
|
||||
parm caller [si ax] [es di] [cx] \
|
||||
value [cx] \
|
||||
modify exact [dx ax di cx si];
|
||||
#endif
|
||||
|
||||
/* return <0 if s<t, 0 if s==t, >0 if s>t */
|
||||
|
||||
_WCRTLINK int _fstrncmp( const char _WCFAR *s, const char _WCFAR *t, size_t n )
|
||||
{
|
||||
#if defined(M_I86)
|
||||
if( n ) {
|
||||
return( _fast_strncmp( s, t, n ) );
|
||||
}
|
||||
return( 0 );
|
||||
#else
|
||||
for(;;) {
|
||||
if( n == 0 ) return( 0 ); /* equal */
|
||||
if( *s != *t ) return( *s - *t ); /* less than or greater than */
|
||||
if( *s == '\0' ) return( 0 ); /* equal */
|
||||
++s;
|
||||
++t;
|
||||
--n;
|
||||
}
|
||||
#endif
|
||||
}
|
82
programs/develop/open watcom/trunk/clib/string/fstrncpy.c
Normal file
82
programs/develop/open watcom/trunk/clib/string/fstrncpy.c
Normal file
@@ -0,0 +1,82 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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>
|
||||
|
||||
#ifdef M_I86
|
||||
|
||||
extern char _WCFAR *fast_strncpy( char _WCFAR *, const char _WCFAR *, size_t );
|
||||
|
||||
#pragma aux fast_strncpy = \
|
||||
0x1e /* push ds */\
|
||||
0x96 /* xchg si,ax */\
|
||||
0x8e 0xd8 /* mov ds,ax */\
|
||||
0x57 /* push di */\
|
||||
0xac /* L1: lodsb */\
|
||||
0xaa /* stosb */\
|
||||
0x84 0xc0 /* test al,al */\
|
||||
0xe0 0xfa /* loopne L1 */\
|
||||
0x31 0xc0 /* xor ax,ax */\
|
||||
0xd1 0xe9 /* shr cx,1 */\
|
||||
0xf3 0xab /* rep stosw */\
|
||||
0x11 0xc9 /* adc cx,cx */\
|
||||
0xf3 0xaa /* rep stosb */\
|
||||
0x58 /* pop ax */\
|
||||
0x1f /* pop ds */\
|
||||
parm caller [es di] [si ax] [cx]\
|
||||
value [es ax] \
|
||||
modify exact [ax cx si di];
|
||||
#endif
|
||||
|
||||
_WCRTLINK char _WCFAR *_fstrncpy( char _WCFAR *dst, const char _WCFAR *src, size_t len )
|
||||
{
|
||||
#ifdef M_I86
|
||||
if( len ) {
|
||||
return( fast_strncpy( dst, src, len ) );
|
||||
}
|
||||
return( dst );
|
||||
#else
|
||||
char _WCFAR *ret;
|
||||
|
||||
ret = dst;
|
||||
for(;len; --len ) {
|
||||
if( *src == '\0' ) break;
|
||||
*dst++ = *src++;
|
||||
}
|
||||
while( len != 0 ) {
|
||||
*dst++ = '\0'; /* pad destination string with null chars */
|
||||
--len;
|
||||
}
|
||||
return( ret );
|
||||
#endif
|
||||
}
|
56
programs/develop/open watcom/trunk/clib/string/fstrnicm.c
Normal file
56
programs/develop/open watcom/trunk/clib/string/fstrnicm.c
Normal file
@@ -0,0 +1,56 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
/* return <0 if s<t, 0 if s==t, >0 if s>t */
|
||||
|
||||
_WCRTLINK int _fstrnicmp( const char _WCFAR *s, const char _WCFAR *t, size_t n )
|
||||
{
|
||||
unsigned char c1;
|
||||
unsigned char c2;
|
||||
|
||||
for(;;) {
|
||||
if( n == 0 ) return( 0 ); /* equal */
|
||||
c1 = *s;
|
||||
if( c1 >= 'A' && c1 <= 'Z' ) c1 += 'a' - 'A';
|
||||
c2 = *t;
|
||||
if( c2 >= 'A' && c2 <= 'Z' ) c2 += 'a' - 'A';
|
||||
if( c1 != c2 ) return( c1 - c2 ); /* less than or greater than */
|
||||
if( c1 == '\0' ) return( 0 ); /* equal */
|
||||
++s;
|
||||
++t;
|
||||
--n;
|
||||
}
|
||||
}
|
45
programs/develop/open watcom/trunk/clib/string/fstrnset.c
Normal file
45
programs/develop/open watcom/trunk/clib/string/fstrnset.c
Normal file
@@ -0,0 +1,45 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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>
|
||||
|
||||
_WCRTLINK char _WCFAR *_fstrnset( char _WCFAR *str, int c, size_t len )
|
||||
{
|
||||
char _WCFAR *p;
|
||||
|
||||
for( p = str; len; --len ) {
|
||||
if( *p == '\0' ) break;
|
||||
*p++ = c;
|
||||
}
|
||||
return( str );
|
||||
}
|
54
programs/develop/open watcom/trunk/clib/string/fstrpbrk.c
Normal file
54
programs/develop/open watcom/trunk/clib/string/fstrpbrk.c
Normal file
@@ -0,0 +1,54 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 <stddef.h>
|
||||
#include <string.h>
|
||||
#include "setbits.h"
|
||||
|
||||
/* The strpbrk function locates the first occurrence in the string pointed
|
||||
to by str of any character from the string pointed to by charset.
|
||||
*/
|
||||
|
||||
_WCRTLINK char _WCFAR *_fstrpbrk( const char _WCFAR *str, const char _WCFAR *charset )
|
||||
{
|
||||
unsigned char tc;
|
||||
unsigned char vector[32];
|
||||
|
||||
__fsetbits( vector, charset );
|
||||
for( ; tc = *str; ++str ) {
|
||||
/* quit when we find any char in charset */
|
||||
if( ( vector[ tc >> 3 ] & _Bits[ tc & 0x07 ] ) != 0 )
|
||||
return( (char _WCFAR *)str );
|
||||
}
|
||||
return( NULL );
|
||||
}
|
78
programs/develop/open watcom/trunk/clib/string/fstrrchr.c
Normal file
78
programs/develop/open watcom/trunk/clib/string/fstrrchr.c
Normal file
@@ -0,0 +1,78 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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>
|
||||
|
||||
#ifdef M_I86
|
||||
|
||||
extern char _WCFAR *_fast_strrchr( const char _WCFAR *, char );
|
||||
|
||||
#pragma aux _fast_strrchr = \
|
||||
0xb9 0xff 0xff /* mov cx,ffffh */ \
|
||||
0x30 0xc0 /* xor al,al */ \
|
||||
0xf2 0xae /* repne scasb */ \
|
||||
0xf7 0xd1 /* not cx */ \
|
||||
0x4f /* dec di */ \
|
||||
0x88 0xd8 /* mov al,bl */ \
|
||||
0xfd /* std */ \
|
||||
0xf2 0xae /* repne scasb */ \
|
||||
0xfc /* cld */ \
|
||||
0x75 0x04 /* jne L1 */ \
|
||||
0x89 0xf9 /* mov cx,di */ \
|
||||
0x41 /* inc cx */ \
|
||||
0xa9 /* hide 2 bytes */ \
|
||||
0x8e 0xc1 /* L1: mov es,cx */ \
|
||||
parm caller [es di] [bl] \
|
||||
value [es cx] \
|
||||
modify exact [es cx ax di];
|
||||
#endif
|
||||
|
||||
/* Locate the last occurrence of c in the string pointed to by s.
|
||||
The terminating null character is considered to be part of the string.
|
||||
If the character c is not found, NULL is returned.
|
||||
*/
|
||||
|
||||
_WCRTLINK char _WCFAR *_fstrrchr( const char _WCFAR *s, int c )
|
||||
{
|
||||
#if defined(M_I86)
|
||||
return( _fast_strrchr( s, c ) );
|
||||
#else
|
||||
char _WCFAR *p;
|
||||
|
||||
p = NULL; /* assume c will not be found */
|
||||
do {
|
||||
if( *s == c ) p = (char _WCFAR *)s;
|
||||
} while( *s++ != '\0' );
|
||||
return( p );
|
||||
#endif
|
||||
}
|
121
programs/develop/open watcom/trunk/clib/string/fstrrev.c
Normal file
121
programs/develop/open watcom/trunk/clib/string/fstrrev.c
Normal file
@@ -0,0 +1,121 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef M_I86
|
||||
|
||||
/*
|
||||
explanation of algorithm:
|
||||
|
||||
(1) reverse as much of the string as possible as words
|
||||
|
||||
(2) after main loop: reverse residual inner string (0-3 bytes)
|
||||
|
||||
the string falls into one of these forms:
|
||||
|
||||
{ prefix_word }* { suffix_word }*
|
||||
{ prefix_word }* middle_byte { suffix_word }*
|
||||
{ prefix_word }* pre_middle_byte post_middle_byte { suffix_word }*
|
||||
{ prefix_word }* pre_middle_byte middle_byte post_middle_byte { suffix_word }*
|
||||
|
||||
we only have to swap two bytes when:
|
||||
|
||||
len & 2 != 0 is true (ie. the carry is set after second shr cx,1)
|
||||
|
||||
*****************************************************************************
|
||||
WARNING: the code in the L1: ... reverse loop cannot modify the carry flag
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
extern void fast_rev( char _WCFAR * );
|
||||
|
||||
#pragma aux fast_rev = \
|
||||
0x1e /* push ds */\
|
||||
0x8e 0xc1 /* mov es,cx */\
|
||||
0x8e 0xd9 /* mov ds,cx */\
|
||||
0x89 0xfe /* mov si,di */\
|
||||
0xb9 0xff 0xff /* mov cx,ffff */\
|
||||
0x30 0xc0 /* xor al,al */\
|
||||
0xf2 0xae /* repne scasb */\
|
||||
0xf7 0xd1 /* not cx */\
|
||||
0x49 /* dec cx */\
|
||||
0xfd /* std */\
|
||||
0x83 0xef 0x03 /* sub di,3 */\
|
||||
0xd1 0xe9 /* shr cx,1 */\
|
||||
0xd1 0xe9 /* shr cx,1 */\
|
||||
0xe3 0x0d /* jcxz L2 */\
|
||||
0x8b 0x05 /* L1:mov ax,[di] */\
|
||||
0x86 0xe0 /* xchg ah,al */\
|
||||
0x87 0x04 /* xchg ax,[si] */\
|
||||
0x86 0xe0 /* xchg ah,al */\
|
||||
0xab /* stosw */\
|
||||
0x46 /* inc si */\
|
||||
0x46 /* inc si */\
|
||||
0xe2 0xf3 /* loop L1 */\
|
||||
0x73 0x07 /* L2:jnc L3 */\
|
||||
0x47 /* inc di */\
|
||||
0x8a 0x05 /* mov al,[di] */\
|
||||
0x86 0x04 /* xchg al,[si] */\
|
||||
0x88 0x05 /* mov [di],al */\
|
||||
0xfc /* L3:cld */\
|
||||
0x1f /* pop ds */\
|
||||
parm caller [cx di] \
|
||||
modify [si cx ax di es];
|
||||
#endif
|
||||
|
||||
_WCRTLINK char _WCFAR *_fstrrev( char _WCFAR *str ) /* reverse characters in string */
|
||||
{
|
||||
#if defined(M_I86)
|
||||
fast_rev( str );
|
||||
return( str );
|
||||
#else
|
||||
char _WCFAR *p1;
|
||||
char _WCFAR *p2;
|
||||
char c1;
|
||||
char c2;
|
||||
|
||||
p1 = str;
|
||||
p2 = p1 + _fstrlen( p1 ) - 1;
|
||||
while( p1 < p2 ) {
|
||||
c1 = *p1;
|
||||
c2 = *p2;
|
||||
*p1 = c2;
|
||||
*p2 = c1;
|
||||
++p1;
|
||||
--p2;
|
||||
}
|
||||
return( str );
|
||||
#endif
|
||||
}
|
75
programs/develop/open watcom/trunk/clib/string/fstrset.c
Normal file
75
programs/develop/open watcom/trunk/clib/string/fstrset.c
Normal file
@@ -0,0 +1,75 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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>
|
||||
|
||||
#ifdef M_I86
|
||||
|
||||
extern char _WCFAR *fast_strset( char _WCFAR *, char );
|
||||
|
||||
#pragma aux fast_strset = \
|
||||
0x1e /* push ds */\
|
||||
0x56 /* push si */\
|
||||
0x50 /* push ax */\
|
||||
0x8e 0xda /* mov ds,dx */\
|
||||
0x89 0xc6 /* mov si,ax */\
|
||||
0x88 0xdf /* mov bh,bl */\
|
||||
0xad /* L1:lodsw */\
|
||||
0x84 0xc0 /* test al,al */\
|
||||
0x74 0x0c /* je L3 */\
|
||||
0x84 0xe4 /* test ah,ah */\
|
||||
0x74 0x05 /* je L2 */\
|
||||
0x89 0x5c 0xfe /* mov -2[si],bx */\
|
||||
0xeb 0xf2 /* jmp L1 */\
|
||||
0x88 0x5c 0xfe /* L2:mov -2[si],bl */\
|
||||
0x58 /* L3:pop ax */\
|
||||
0x5e /* pop si */\
|
||||
0x1f /* pop ds */\
|
||||
parm caller [dx ax] [bl] \
|
||||
value [dx ax] \
|
||||
modify exact [bh];
|
||||
#endif
|
||||
|
||||
_WCRTLINK char _WCFAR *_fstrset( char _WCFAR *s, int c )
|
||||
{
|
||||
//#ifdef M_I86
|
||||
//return( fast_strset( s, c ) );
|
||||
//#else
|
||||
char _WCFAR *p;
|
||||
|
||||
for( p = s; *p; ++p ) {
|
||||
*p = c;
|
||||
}
|
||||
return( s );
|
||||
//#endif
|
||||
}
|
55
programs/develop/open watcom/trunk/clib/string/fstrspn.c
Normal file
55
programs/develop/open watcom/trunk/clib/string/fstrspn.c
Normal file
@@ -0,0 +1,55 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 "setbits.h"
|
||||
|
||||
/* The strspn function computes the length of the initial segment of the
|
||||
string pointed to by str which consists entirely of characters from
|
||||
the string pointed to by charset.
|
||||
*/
|
||||
|
||||
_WCRTLINK size_t _fstrspn( const char _WCFAR *str, const char _WCFAR *charset )
|
||||
{
|
||||
unsigned /*char*/ tc;
|
||||
unsigned char vector[32];
|
||||
size_t len;
|
||||
|
||||
__fsetbits( vector, charset );
|
||||
len = 0;
|
||||
for( ; tc = (unsigned char) *str; ++str, ++len ) {
|
||||
/* quit if we find any char not in charset */
|
||||
if( ( vector[ tc >> 3 ] & _Bits[ tc & 0x07 ] ) == 0 ) break;
|
||||
}
|
||||
return( len );
|
||||
}
|
47
programs/develop/open watcom/trunk/clib/string/fstrspnp.c
Normal file
47
programs/develop/open watcom/trunk/clib/string/fstrspnp.c
Normal file
@@ -0,0 +1,47 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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>
|
||||
|
||||
|
||||
_WCRTLINK char _WCFAR *_fstrspnp( const char _WCFAR *p1, const char _WCFAR *p2 )
|
||||
{
|
||||
size_t index;
|
||||
|
||||
index = _fstrspn( p1, p2 );
|
||||
if( *(p1+index) != '\0' ) {
|
||||
return( (char _WCFAR*)(p1+index) );
|
||||
} else {
|
||||
return( NULL );
|
||||
}
|
||||
}
|
93
programs/develop/open watcom/trunk/clib/string/fstrstr.c
Normal file
93
programs/develop/open watcom/trunk/clib/string/fstrstr.c
Normal file
@@ -0,0 +1,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: _fstrstr() implementation.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef M_I86
|
||||
#if defined(__QNX__)
|
||||
#include <i86.h>
|
||||
#else
|
||||
#include <dos.h>
|
||||
#endif
|
||||
|
||||
extern int i86_memeq( const char _WCFAR *, const char _WCFAR *, int );
|
||||
|
||||
#define _ZFLAG (INTR_ZF<<8)
|
||||
|
||||
#pragma aux i86_memeq = \
|
||||
0x1e /* push ds */\
|
||||
0x96 /* xchg si,ax */\
|
||||
0x8e 0xd8 /* mov ds,ax */\
|
||||
0xf3 0xa6 /* rep cmpsb */\
|
||||
0x9f /* lahf */\
|
||||
0x1f /* pop ds */\
|
||||
parm caller [si ax] [es di] [cx]\
|
||||
value [ax] \
|
||||
modify exact [si di cx ax];
|
||||
|
||||
#define memeq( p1, p2, len ) ( i86_memeq((p1),(p2),(len)) & _ZFLAG )
|
||||
|
||||
#else
|
||||
|
||||
#define memeq( p1, p2, len ) ( _fmemcmp((p1),(p2),(len)) == 0 )
|
||||
|
||||
#endif
|
||||
|
||||
/* Locate the first occurrence of the string pointed to by s2 in the
|
||||
string pointed to by s1.
|
||||
The strstr function returns a pointer to the located string, or a
|
||||
null pointer if the string is not found.
|
||||
*/
|
||||
|
||||
_WCRTLINK char _WCFAR *_fstrstr( const char _WCFAR *s1, const char _WCFAR *s2 )
|
||||
{
|
||||
char _WCFAR *end_of_s1;
|
||||
size_t s1len, s2len;
|
||||
|
||||
if( s2[0] == '\0' ) {
|
||||
return( (char _WCFAR *)s1 );
|
||||
} else if( s2[1] == '\0' ) {
|
||||
return( _fstrchr( s1, s2[0] ) );
|
||||
}
|
||||
end_of_s1 = _fmemchr( s1, '\0', ~0u );
|
||||
s2len = _fstrlen( s2 );
|
||||
for(;;) {
|
||||
s1len = end_of_s1 - s1;
|
||||
if( s1len < s2len ) break;
|
||||
s1 = _fmemchr( s1, *s2, s1len ); /* find start of possible match */
|
||||
if( s1 == NULL ) break;
|
||||
if( memeq( s1, s2, s2len ) ) return( (char _WCFAR *)s1 );
|
||||
++s1;
|
||||
}
|
||||
return( NULL );
|
||||
}
|
70
programs/develop/open watcom/trunk/clib/string/fstrtok.c
Normal file
70
programs/develop/open watcom/trunk/clib/string/fstrtok.c
Normal file
@@ -0,0 +1,70 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 <stdio.h>
|
||||
#include <string.h>
|
||||
#include "rtdata.h"
|
||||
#include "nextftok.h"
|
||||
#include "setbits.h"
|
||||
|
||||
|
||||
_WCRTLINK char _WCFAR *_fstrtok( char _WCFAR *str, const char _WCFAR *charset )
|
||||
{
|
||||
unsigned /*char*/ tc;
|
||||
unsigned char vector[32];
|
||||
unsigned char _WCFAR *p1;
|
||||
|
||||
_INITNEXTFTOK
|
||||
if( str == NULL ) {
|
||||
str = _RWD_nextftok; /* use previous value */
|
||||
if( str == NULL ) return( NULL );
|
||||
}
|
||||
__fsetbits( vector, charset );
|
||||
for( ; tc = (unsigned char) *str; ++str ) {
|
||||
/* quit if we find any char not in charset */
|
||||
if( ( vector[ tc >> 3 ] & _Bits[ tc & 0x07 ] ) == 0 ) break;
|
||||
}
|
||||
if( tc == '\0' ) return( NULL );
|
||||
p1 = str;
|
||||
for( ; tc = *p1; ++p1 ) {
|
||||
/* quit when we find any char in charset */
|
||||
if( ( vector[ tc >> 3 ] & _Bits[ tc & 0x07 ] ) != 0 ) {
|
||||
*p1 = '\0'; /* terminate the token */
|
||||
p1++; /* start of next token */
|
||||
_RWD_nextftok = p1;
|
||||
return( str );
|
||||
}
|
||||
}
|
||||
_RWD_nextftok = NULL;
|
||||
return( str );
|
||||
}
|
52
programs/develop/open watcom/trunk/clib/string/fstrupr.c
Normal file
52
programs/develop/open watcom/trunk/clib/string/fstrupr.c
Normal file
@@ -0,0 +1,52 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
_WCRTLINK char _WCFAR *_fstrupr( char _WCFAR *str )
|
||||
{
|
||||
char _WCFAR *p;
|
||||
unsigned char c;
|
||||
|
||||
p = str;
|
||||
while( c = *p ) {
|
||||
c -= 'a';
|
||||
if( c <= 'z' - 'a' ) {
|
||||
c += 'A';
|
||||
*p = c;
|
||||
}
|
||||
++p;
|
||||
}
|
||||
return( str );
|
||||
}
|
54
programs/develop/open watcom/trunk/clib/string/nextftok.h
Normal file
54
programs/develop/open watcom/trunk/clib/string/nextftok.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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"
|
||||
#if defined(__OS2__) || defined(__NT__) || defined(__NETWARE__)
|
||||
#if defined(__SW_BM)
|
||||
|
||||
#include "thread.h"
|
||||
|
||||
#define _INITNEXTFTOK
|
||||
#define _NEXTFTOK (__THREADDATAPTR->__nextftokP)
|
||||
|
||||
#else
|
||||
|
||||
static char _WCFAR *nextftok = NULL;
|
||||
|
||||
#define _INITNEXTFTOK
|
||||
#define _NEXTFTOK nextftok
|
||||
|
||||
#endif
|
||||
#else
|
||||
#define _INITNEXTFTOK
|
||||
static char _WCFAR *nextftok = NULL;
|
||||
#define _NEXTFTOK nextftok
|
||||
#endif
|
48
programs/develop/open watcom/trunk/clib/string/nexttok.h
Normal file
48
programs/develop/open watcom/trunk/clib/string/nexttok.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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"
|
||||
#define _INITNEXTTOK
|
||||
#if defined(__OS2__) || defined(__NT__) || defined(__NETWARE__)
|
||||
// the OS/2, NT and NETWARE files are identical
|
||||
// note that NETWARE is always multi-thread
|
||||
#if defined(__SW_BM)
|
||||
#include "thread.h"
|
||||
#define _NEXTTOK (__THREADDATAPTR->__nexttokP)
|
||||
#else
|
||||
static char *nexttok = NULL;
|
||||
#define _NEXTTOK nexttok
|
||||
#endif
|
||||
#else
|
||||
static char *nexttok = NULL;
|
||||
#define _NEXTTOK nexttok
|
||||
#endif
|
44
programs/develop/open watcom/trunk/clib/string/selptr.c
Normal file
44
programs/develop/open watcom/trunk/clib/string/selptr.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 <stdlib.h>
|
||||
#include "rtdata.h"
|
||||
|
||||
#ifdef __NETWARE__
|
||||
_WCRTLINKD extern char *sys_errlist[];/* strerror error message table */
|
||||
#define _sys_errlist sys_errlist
|
||||
#endif
|
||||
|
||||
_WCRTLINK char * (*__get_sys_errlist_ptr())[] {
|
||||
return &_sys_errlist;
|
||||
}
|
36
programs/develop/open watcom/trunk/clib/string/setbits.h
Normal file
36
programs/develop/open watcom/trunk/clib/string/setbits.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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: declaration for character set bit array routines
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
extern void __setbits( unsigned char *vector, const char *charset );
|
||||
extern void __fsetbits( unsigned char _WCFAR *vector, const char _WCFAR *charset );
|
||||
|
||||
extern const unsigned char _HUGEDATA _Bits[8];
|
||||
|
44
programs/develop/open watcom/trunk/clib/string/sneptr.c
Normal file
44
programs/develop/open watcom/trunk/clib/string/sneptr.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 <stdlib.h>
|
||||
#include "rtdata.h"
|
||||
|
||||
#ifdef __NETWARE__
|
||||
_WCRTLINKD extern int _WCNEAR sys_nerr; /* # of entries in sys_errlist array */
|
||||
#define _sys_nerr sys_nerr
|
||||
#endif
|
||||
|
||||
_WCRTLINK int (*__get_sys_nerr_ptr()) {
|
||||
return &_sys_nerr;
|
||||
}
|
93
programs/develop/open watcom/trunk/clib/string/snprintf.c
Normal file
93
programs/develop/open watcom/trunk/clib/string/snprintf.c
Normal file
@@ -0,0 +1,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: Implementation of snprintf().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include "widechar.h"
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "printf.h"
|
||||
|
||||
struct buf_limit {
|
||||
CHAR_TYPE *bufptr;
|
||||
size_t bufsize;
|
||||
};
|
||||
|
||||
/*
|
||||
* buf_putc -- append a character to a string in memory
|
||||
*/
|
||||
static slib_callback_t buf_putc; // setup calling convention
|
||||
static void __SLIB_CALLBACK buf_putc( SPECS __SLIB *specs, int op_char )
|
||||
{
|
||||
struct buf_limit *bufinfo;
|
||||
|
||||
bufinfo = (struct buf_limit *)specs->_dest;
|
||||
if( specs->_output_count < bufinfo->bufsize ) {
|
||||
*( bufinfo->bufptr++ ) = op_char;
|
||||
}
|
||||
specs->_output_count++;
|
||||
}
|
||||
|
||||
/*
|
||||
* buf_count_putc -- only count characters to be output
|
||||
*/
|
||||
static slib_callback_t buf_count_putc; // setup calling convention
|
||||
static void __SLIB_CALLBACK buf_count_putc( SPECS __SLIB *specs, int op_char )
|
||||
{
|
||||
specs->_output_count++;
|
||||
}
|
||||
|
||||
|
||||
_WCRTLINK int __F_NAME(vsnprintf,vsnwprintf) ( CHAR_TYPE *s, size_t bufsize,
|
||||
const CHAR_TYPE *format, va_list arg)
|
||||
{
|
||||
register int len;
|
||||
auto struct buf_limit bufinfo;
|
||||
|
||||
bufinfo.bufptr = s;
|
||||
bufinfo.bufsize = bufsize - 1;
|
||||
if( bufsize == 0 )
|
||||
len = __F_NAME(__prtf,__wprtf)( &bufinfo, format, arg, buf_count_putc );
|
||||
else {
|
||||
len = __F_NAME(__prtf,__wprtf)( &bufinfo, format, arg, buf_putc );
|
||||
s[(( len >= 0 ) && ( len < bufsize )) ? len : bufsize - 1] = '\0';
|
||||
}
|
||||
return( len );
|
||||
}
|
||||
|
||||
|
||||
_WCRTLINK int __F_NAME(snprintf,snwprintf) ( CHAR_TYPE *dest, size_t bufsize,
|
||||
const CHAR_TYPE *format, ... )
|
||||
{
|
||||
auto va_list args;
|
||||
|
||||
va_start( args, format );
|
||||
return( __F_NAME(vsnprintf,vsnwprintf)( dest, bufsize, format, args ) );
|
||||
}
|
100
programs/develop/open watcom/trunk/clib/string/snprtf_s.c
Normal file
100
programs/develop/open watcom/trunk/clib/string/snprtf_s.c
Normal file
@@ -0,0 +1,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: Implementation of snprintf_s() - safe string fmt'd output.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include "saferlib.h"
|
||||
#include "widechar.h"
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <wchar.h>
|
||||
#include "printf.h"
|
||||
|
||||
|
||||
struct buf_limit {
|
||||
CHAR_TYPE *bufptr;
|
||||
rsize_t chars_output;
|
||||
rsize_t max_chars;
|
||||
};
|
||||
|
||||
/*
|
||||
* buf_putc -- append a character to a string in memory
|
||||
*/
|
||||
static slib_callback_t buf_putc; // setup calling convention
|
||||
static void __SLIB_CALLBACK buf_putc( SPECS __SLIB *specs, int op_char )
|
||||
{
|
||||
struct buf_limit *info;
|
||||
|
||||
info = (struct buf_limit *)specs->_dest;
|
||||
if( specs->_output_count < info->max_chars ) {
|
||||
*( info->bufptr++ ) = op_char;
|
||||
info->chars_output++;
|
||||
}
|
||||
specs->_output_count++;
|
||||
}
|
||||
|
||||
|
||||
_WCRTLINK int __F_NAME(snprintf_s,snwprintf_s)( CHAR_TYPE * __restrict s, rsize_t n,
|
||||
const CHAR_TYPE * __restrict format, ... )
|
||||
{
|
||||
va_list arg;
|
||||
struct buf_limit info;
|
||||
const char *msg;
|
||||
|
||||
/* First check the critical conditions; if any of those
|
||||
* is violated, return immediately and don't touch anything.
|
||||
*/
|
||||
if( __check_constraint_nullptr_msg( msg, s )
|
||||
&& __check_constraint_maxsize_msg( msg, n )
|
||||
&& __check_constraint_zero_msg( msg, n ) ) {
|
||||
|
||||
/* The buffer looks okay, try doing something useful */
|
||||
if( __check_constraint_nullptr_msg( msg, format ) ) {
|
||||
int len;
|
||||
|
||||
info.bufptr = s;
|
||||
info.chars_output = 0;
|
||||
info.max_chars = n - 1;
|
||||
msg = NULL;
|
||||
va_start( arg, format );
|
||||
len = __F_NAME(__prtf_s,__wprtf_s)( &info, format, arg, &msg, buf_putc );
|
||||
va_end( arg );
|
||||
if( msg == NULL ) {
|
||||
/* No rt-constraint violation while formatting */
|
||||
s[info.chars_output] = NULLCHAR;
|
||||
return( len );
|
||||
}
|
||||
}
|
||||
/* Something went wrong, output buffer will contain empty string */
|
||||
*s = NULLCHAR;
|
||||
}
|
||||
__rtct_fail( __func__, msg, NULL );
|
||||
return( -1 );
|
||||
}
|
72
programs/develop/open watcom/trunk/clib/string/sprintf.c
Normal file
72
programs/develop/open watcom/trunk/clib/string/sprintf.c
Normal file
@@ -0,0 +1,72 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 "widechar.h"
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
#include "printf.h"
|
||||
|
||||
|
||||
//#ifdef __WIDECHAR__
|
||||
//_WCRTLINK int _usprintf( wchar_t *dest, const wchar_t *format, ... )
|
||||
//{
|
||||
// va_list args;
|
||||
//
|
||||
// va_start( args, format );
|
||||
// return( vswprintf( dest, INT_MAX, format, args ) );
|
||||
//}
|
||||
//#endif
|
||||
|
||||
|
||||
#ifdef __WIDECHAR__
|
||||
_WCRTLINK int swprintf( CHAR_TYPE *dest, size_t n, const CHAR_TYPE *format, ... )
|
||||
{
|
||||
auto va_list args;
|
||||
|
||||
va_start( args, format );
|
||||
return( vswprintf( dest, n, format, args ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
_WCRTLINK int __F_NAME(sprintf,_swprintf) ( CHAR_TYPE *dest, const CHAR_TYPE *format, ... )
|
||||
{
|
||||
auto va_list args;
|
||||
|
||||
va_start( args, format );
|
||||
#ifdef __WIDECHAR__
|
||||
return( _vswprintf( dest, format, args ) );
|
||||
#else
|
||||
return( vsprintf( dest, format, args ) );
|
||||
#endif
|
||||
}
|
107
programs/develop/open watcom/trunk/clib/string/sprntf_s.c
Normal file
107
programs/develop/open watcom/trunk/clib/string/sprntf_s.c
Normal file
@@ -0,0 +1,107 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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: Implementation of sprintf_s() - safe formatted string output.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include "saferlib.h"
|
||||
#include "widechar.h"
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <wchar.h>
|
||||
#include "printf.h"
|
||||
|
||||
|
||||
/*
|
||||
* mem_putc -- append a character to a string in memory, with overflow check
|
||||
*/
|
||||
|
||||
struct vsprtf_s_buf {
|
||||
CHAR_TYPE *bufptr;
|
||||
rsize_t chars_output;
|
||||
rsize_t max_chars;
|
||||
};
|
||||
|
||||
static slib_callback_t mem_putc; // set up calling convention
|
||||
static void __SLIB_CALLBACK mem_putc( SPECS __SLIB *specs, int op_char )
|
||||
{
|
||||
struct vsprtf_s_buf *info;
|
||||
|
||||
info = (struct vsprtf_s_buf *)specs->_dest;
|
||||
if( info->chars_output <= info->max_chars ) {
|
||||
*( info->bufptr++ ) = op_char;
|
||||
specs->_output_count++;
|
||||
info->chars_output++;
|
||||
}
|
||||
}
|
||||
|
||||
_WCRTLINK int __F_NAME(sprintf_s,swprintf_s)( CHAR_TYPE * __restrict s, rsize_t n,
|
||||
const CHAR_TYPE * __restrict format, ... )
|
||||
{
|
||||
va_list arg;
|
||||
struct vsprtf_s_buf info;
|
||||
const char *msg;
|
||||
int rc = 0;
|
||||
|
||||
/* First check the critical conditions; if any of those
|
||||
* is violated, return immediately and don't touch anything.
|
||||
*/
|
||||
if( __check_constraint_nullptr_msg( msg, s )
|
||||
&& __check_constraint_maxsize_msg( msg, n )
|
||||
&& __check_constraint_zero_msg( msg, n ) ) {
|
||||
|
||||
/* The buffer looks okay, try doing something useful */
|
||||
if( __check_constraint_nullptr_msg( msg, format ) ) {
|
||||
info.bufptr = s;
|
||||
info.chars_output = 0;
|
||||
info.max_chars = n - 1;
|
||||
msg = NULL;
|
||||
|
||||
va_start( arg, format );
|
||||
__F_NAME(__prtf_s,__wprtf_s)( &info, format, arg, &msg, mem_putc );
|
||||
va_end( arg );
|
||||
|
||||
if( msg == NULL ) {
|
||||
if( info.chars_output <= info.max_chars ) {
|
||||
s[info.chars_output] = NULLCHAR;
|
||||
return( info.chars_output );
|
||||
}
|
||||
/* If we got here, the output buffer was too small */
|
||||
msg = "n < chars_output";
|
||||
#ifdef __WIDECHAR__
|
||||
rc = -1; /* Return value for swprintf_s is different! */
|
||||
#endif
|
||||
}
|
||||
}
|
||||
/* Something went wrong, output buffer will contain empty string */
|
||||
*s = NULLCHAR;
|
||||
}
|
||||
__rtct_fail( __func__, msg, NULL );
|
||||
return( rc );
|
||||
}
|
77
programs/develop/open watcom/trunk/clib/string/sscanf.c
Normal file
77
programs/develop/open watcom/trunk/clib/string/sscanf.c
Normal file
@@ -0,0 +1,77 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 "widechar.h"
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "scanf.h"
|
||||
|
||||
|
||||
static int cget_string( PTR_SCNF_SPECS specs )
|
||||
{
|
||||
int c;
|
||||
|
||||
if( (c = *(specs->ptr)) != NULLCHAR ) {
|
||||
++(specs->ptr);
|
||||
} else {
|
||||
c = EOF;
|
||||
specs->eoinp = 1;
|
||||
}
|
||||
return( c );
|
||||
}
|
||||
|
||||
|
||||
static void uncget_string( int c, PTR_SCNF_SPECS specs )
|
||||
{
|
||||
--specs->ptr;
|
||||
}
|
||||
|
||||
|
||||
_WCRTLINK int __F_NAME(vsscanf,vswscanf) ( const CHAR_TYPE *dest, const CHAR_TYPE *format, va_list args )
|
||||
{
|
||||
auto SCNF_SPECS specs;
|
||||
|
||||
specs.ptr = (CHAR_TYPE *)dest;
|
||||
specs.cget_rtn = cget_string;
|
||||
specs.uncget_rtn = uncget_string;
|
||||
return( __F_NAME(__scnf,__wscnf)( (PTR_SCNF_SPECS)&specs, format, args ) );
|
||||
}
|
||||
|
||||
|
||||
_WCRTLINK int __F_NAME(sscanf,swscanf) ( const CHAR_TYPE *dest, const CHAR_TYPE *format, ... )
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start( args, format );
|
||||
return( __F_NAME(vsscanf,vswscanf)( dest, format, args ) );
|
||||
}
|
87
programs/develop/open watcom/trunk/clib/string/sscanf_s.c
Normal file
87
programs/develop/open watcom/trunk/clib/string/sscanf_s.c
Normal file
@@ -0,0 +1,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: Implementation of sscanf_s() - safe formatted string input.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include "saferlib.h"
|
||||
#include "widechar.h"
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <wchar.h>
|
||||
#include "scanf.h"
|
||||
|
||||
|
||||
static int cget_string( PTR_SCNF_SPECS specs )
|
||||
{
|
||||
int c;
|
||||
|
||||
if( (c = *(specs->ptr)) != NULLCHAR ) {
|
||||
++(specs->ptr);
|
||||
} else {
|
||||
c = EOF;
|
||||
specs->eoinp = 1;
|
||||
}
|
||||
return( c );
|
||||
}
|
||||
|
||||
|
||||
static void uncget_string( int c, PTR_SCNF_SPECS specs )
|
||||
{
|
||||
--specs->ptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
_WCRTLINK int __F_NAME(sscanf_s,swscanf_s)( const CHAR_TYPE *s, const CHAR_TYPE *format, ... )
|
||||
{
|
||||
SCNF_SPECS specs;
|
||||
const char *msg;
|
||||
int rc;
|
||||
va_list args;
|
||||
|
||||
/* Basic check for null pointers to see if we can continue */
|
||||
if( __check_constraint_nullptr_msg( msg, s )
|
||||
&& __check_constraint_nullptr_msg( msg, format ) ) {
|
||||
|
||||
specs.ptr = (CHAR_TYPE *)s;
|
||||
specs.cget_rtn = cget_string;
|
||||
specs.uncget_rtn = uncget_string;
|
||||
msg = NULL;
|
||||
va_start( args, format );
|
||||
rc = __F_NAME(__scnf_s,__wscnf_s)( (PTR_SCNF_SPECS)&specs, format, &msg, args );
|
||||
va_end( args );
|
||||
if( msg == NULL ) {
|
||||
/* no rt-constraint violation inside worker routine */
|
||||
return( rc );
|
||||
}
|
||||
}
|
||||
__rtct_fail( __func__, msg, NULL );
|
||||
return( __F_NAME(EOF,WEOF) );
|
||||
}
|
90
programs/develop/open watcom/trunk/clib/string/stncat_s.c
Normal file
90
programs/develop/open watcom/trunk/clib/string/stncat_s.c
Normal file
@@ -0,0 +1,90 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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: Implementation of strncat_s() - bounds-checking strncat().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include "saferlib.h"
|
||||
#include "widechar.h"
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
|
||||
|
||||
_WCRTLINK errno_t __F_NAME(strncat_s,wcsncat_s)( CHAR_TYPE * __restrict s1,
|
||||
rsize_t s1max, const CHAR_TYPE * __restrict s2,
|
||||
rsize_t n )
|
||||
/*************************************************************************/
|
||||
{
|
||||
errno_t rc = -1;
|
||||
const char *msg;
|
||||
|
||||
// strnlen_s is safe to use as it has no rt constraints
|
||||
rsize_t m = s1max - __F_NAME(strnlen_s,wcsnlen_s)( s1, s1max );
|
||||
|
||||
|
||||
// Verify runtime-constraints
|
||||
// s1 not NULL
|
||||
// s2 not NULL
|
||||
// s1max <= RSIZE_MAX
|
||||
// n <= RSIZE_MAX
|
||||
// s1max != 0
|
||||
// m = s1max - strnlen_s( s1, s1max ) != 0
|
||||
// if n >= m then m > strnlen_s( s2, m )
|
||||
// s1 and s2 no overlap
|
||||
if( __check_constraint_nullptr_msg( msg, s1 ) &&
|
||||
__check_constraint_nullptr_msg( msg, s2 ) &&
|
||||
__check_constraint_maxsize_msg( msg, s1max ) &&
|
||||
__check_constraint_maxsize_msg( msg, m ) &&
|
||||
__check_constraint_zero_msg( msg, s1max ) &&
|
||||
__check_constraint_zero_msg( msg, m ) &&
|
||||
((n < m) || __check_constraint_a_gt_b_msg( msg, __F_NAME(strnlen_s,wcsnlen_s)( s2, m ), m - 1 )) &&
|
||||
__check_constraint_overlap_msg( msg, s1, s1max, s2, __F_NAME(strnlen_s,wcsnlen_s)( s2, s1max ))) {
|
||||
|
||||
while( *s1 != NULLCHAR ) ++s1; //find end of field
|
||||
|
||||
while( n != 0 ) {
|
||||
*s1 = *s2;
|
||||
if( *s2 == NULLCHAR ) break;
|
||||
++s1;
|
||||
++s2;
|
||||
--n;
|
||||
}
|
||||
*s1 = NULLCHAR;
|
||||
|
||||
rc = 0;
|
||||
} else {
|
||||
// Runtime-constraints found, store zero in receiving field
|
||||
if( (s1 != NULL) && (s1max > 0) && __lte_rsizmax( s1max ) ) {
|
||||
s1[0] = NULLCHAR;
|
||||
}
|
||||
// Now call the handler
|
||||
__rtct_fail( __func__, msg, NULL );
|
||||
}
|
||||
return( rc );
|
||||
}
|
81
programs/develop/open watcom/trunk/clib/string/stncpy_s.c
Normal file
81
programs/develop/open watcom/trunk/clib/string/stncpy_s.c
Normal file
@@ -0,0 +1,81 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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: Implementation of strncpy_s() - bounds-checking strncpy().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include "saferlib.h"
|
||||
#include "widechar.h"
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
|
||||
|
||||
_WCRTLINK errno_t __F_NAME(strncpy_s,wcsncpy_s)( CHAR_TYPE * __restrict s1,
|
||||
rsize_t s1max, const CHAR_TYPE * __restrict s2,
|
||||
rsize_t n )
|
||||
/*************************************************************************/
|
||||
{
|
||||
errno_t rc = -1;
|
||||
const char *msg;
|
||||
|
||||
// strnlen_s is safe to use as it has no rt constraints
|
||||
rsize_t s2len = __F_NAME(strnlen_s,wcsnlen_s)( s2, s1max );
|
||||
|
||||
// Verify runtime-constraints
|
||||
// s1 not NULL
|
||||
// s2 not NULL
|
||||
// s1max <= RSIZE_MAX
|
||||
// n <= RSIZE_MAX
|
||||
// s1max != 0
|
||||
// if n >= s1max then s1max > strnlen_s( s2, s1max )
|
||||
// s1 s2 no overlap
|
||||
if( __check_constraint_nullptr_msg( msg, s1 ) &&
|
||||
__check_constraint_nullptr_msg( msg, s2 ) &&
|
||||
__check_constraint_maxsize_msg( msg, s1max ) &&
|
||||
__check_constraint_maxsize_msg( msg, n ) &&
|
||||
__check_constraint_zero_msg( msg, s1max ) &&
|
||||
((n < s1max) || __check_constraint_a_gt_b_msg( msg, s2len, s1max - 1 )) &&
|
||||
__check_constraint_overlap_msg( msg, s1, s1max, s2, s2len )) {
|
||||
|
||||
for( ; n; --n) {
|
||||
if( *s2 == '\0' ) break;
|
||||
*s1++ = *s2++;
|
||||
}
|
||||
*s1 = '\0';
|
||||
rc = 0;
|
||||
} else {
|
||||
// Runtime-constraints found, store zero in receiving field
|
||||
if( (s1 != NULL) && (s1max > 0) && __lte_rsizmax( s1max ) ) {
|
||||
s1[0] = '\0';
|
||||
}
|
||||
// Now call the handler
|
||||
__rtct_fail( __func__, msg, NULL );
|
||||
}
|
||||
return( rc );
|
||||
}
|
55
programs/develop/open watcom/trunk/clib/string/strcat.c
Normal file
55
programs/develop/open watcom/trunk/clib/string/strcat.c
Normal file
@@ -0,0 +1,55 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 "widechar.h"
|
||||
#include <stdio.h>
|
||||
#include "xstring.h"
|
||||
#undef strcat
|
||||
|
||||
|
||||
/* concatenate t to the end of s */
|
||||
|
||||
_WCRTLINK CHAR_TYPE *__F_NAME(strcat,wcscat) ( CHAR_TYPE *dst, const CHAR_TYPE *t )
|
||||
{
|
||||
|
||||
#if defined(__INLINE_FUNCTIONS__) && !defined(__WIDECHAR__) && defined(_M_IX86)
|
||||
return( _inline_strcat( dst, t ) );
|
||||
#else
|
||||
CHAR_TYPE *s;
|
||||
|
||||
s = dst;
|
||||
while( *s != NULLCHAR ) ++s;
|
||||
while( *s++ = *t++ ) ;
|
||||
return( dst );
|
||||
#endif
|
||||
}
|
81
programs/develop/open watcom/trunk/clib/string/strcat_s.c
Normal file
81
programs/develop/open watcom/trunk/clib/string/strcat_s.c
Normal file
@@ -0,0 +1,81 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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: Implementation of strcat_s() - bounds-checking strcat().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include "saferlib.h"
|
||||
#include "widechar.h"
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
|
||||
|
||||
_WCRTLINK errno_t __F_NAME(strcat_s,wcscat_s)( CHAR_TYPE * __restrict s1,
|
||||
rsize_t s1max, const CHAR_TYPE * __restrict s2 )
|
||||
/************************************************************************/
|
||||
{
|
||||
errno_t rc = -1;
|
||||
const char *msg;
|
||||
|
||||
// strnlen_s is safe to use as it has no rt constraints
|
||||
rsize_t m = s1max - __F_NAME(strnlen_s,wcsnlen_s)( s1, s1max );
|
||||
|
||||
// Verify runtime-constraints
|
||||
// s1 not NULL
|
||||
// s2 not NULL
|
||||
// s1max <= RSIZE_MAX
|
||||
// s1max != 0
|
||||
// m != 0
|
||||
// m > strnlen_s( s2, m )
|
||||
// s1 and s2 no overlap
|
||||
if( __check_constraint_nullptr_msg( msg, s1 ) &&
|
||||
__check_constraint_nullptr_msg( msg, s2 ) &&
|
||||
__check_constraint_maxsize_msg( msg, s1max ) &&
|
||||
__check_constraint_zero_msg( msg, s1max ) &&
|
||||
__check_constraint_zero_msg( msg, m ) &&
|
||||
__check_constraint_a_gt_b_msg( msg,
|
||||
__F_NAME(strnlen_s,wcsnlen_s)( s2, m ), m - 1 ) &&
|
||||
__check_constraint_overlap_msg( msg, s1, s1max, s2,
|
||||
__F_NAME(strnlen_s,wcsnlen_s)( s2, s1max ) ) ) {
|
||||
|
||||
while( *s1 != NULLCHAR ) ++s1; // find end of field
|
||||
while( *s1++ = *s2++ ); // append source field
|
||||
|
||||
rc = 0;
|
||||
} else {
|
||||
// Runtime-constraints found, store zero in receiving field
|
||||
if( (s1 != NULL) && (s1max > 0) && __lte_rsizmax( s1max ) ) {
|
||||
s1[0] = NULLCHAR;
|
||||
}
|
||||
// Now call the handler
|
||||
__rtct_fail( __func__, msg, NULL );
|
||||
}
|
||||
return( rc );
|
||||
}
|
||||
|
125
programs/develop/open watcom/trunk/clib/string/strchr.c
Normal file
125
programs/develop/open watcom/trunk/clib/string/strchr.c
Normal file
@@ -0,0 +1,125 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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: Implementation of strchr() and wcschr().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include "widechar.h"
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "riscstr.h"
|
||||
|
||||
#if defined(M_I86) && !defined(__WIDECHAR__)
|
||||
|
||||
extern char * _scan1();
|
||||
|
||||
/* use scan1 to find the char we are looking for */
|
||||
|
||||
#if defined(__SMALL_DATA__)
|
||||
#pragma aux _scan1 = 0xad /* L1:lodsw */\
|
||||
0x38 0xd0 /* cmp al,dl */\
|
||||
0x74 0x20 /* je L3 */\
|
||||
0x84 0xc0 /* test al,al*/\
|
||||
0x74 0x19 /* je L2 */\
|
||||
0x38 0xd4 /* cmp ah,dl */\
|
||||
0x74 0x19 /* je L4 */\
|
||||
0x84 0xe4 /* test ah,ah*/\
|
||||
0x74 0x11 /* je L2 */\
|
||||
0xad /* lodsw */\
|
||||
0x38 0xd0 /* cmp al,dl */\
|
||||
0x74 0x0f /* je L3 */\
|
||||
0x84 0xc0 /* test al,al*/\
|
||||
0x74 0x08 /* je L2 */\
|
||||
0x38 0xd4 /* cmp ah,dl */\
|
||||
0x74 0x08 /* je L4 */\
|
||||
0x84 0xe4 /* test ah,ah*/\
|
||||
0x75 0xde /* jne L1 */\
|
||||
0x31 0xf6 /* L2:xor si,si */\
|
||||
0xa9 /* test ax,... */\
|
||||
0x4e /* L3:dec si */\
|
||||
0x4e /* L4:dec si */\
|
||||
parm caller [si] [dl]\
|
||||
value [si]\
|
||||
modify [ax si];
|
||||
#else
|
||||
#pragma aux _scan1 = \
|
||||
0x1e /* push ds */ \
|
||||
0x8e 0xd9 /* mov ds,cx */ \
|
||||
0x8c 0xda /* mov dx,ds */\
|
||||
0xad /* L1:lodsw */\
|
||||
0x38 0xd8 /* cmp al,bl */\
|
||||
0x74 0x22 /* je L3 */\
|
||||
0x84 0xc0 /* test al,al*/\
|
||||
0x74 0x19 /* je L2 */\
|
||||
0x38 0xdc /* cmp ah,bl */\
|
||||
0x74 0x1b /* je L4 */\
|
||||
0x84 0xe4 /* test ah,ah*/\
|
||||
0x74 0x11 /* je L2 */\
|
||||
0xad /* lodsw */\
|
||||
0x38 0xd8 /* cmp al,bl */\
|
||||
0x74 0x11 /* je L3 */\
|
||||
0x84 0xc0 /* test al,al*/\
|
||||
0x74 0x08 /* je L2 */\
|
||||
0x38 0xdc /* cmp ah,bl */\
|
||||
0x74 0x0a /* je L4 */\
|
||||
0x84 0xe4 /* test ah,ah*/\
|
||||
0x75 0xde /* jne L1 */\
|
||||
0x31 0xf6 /* L2:xor si,si*/\
|
||||
0x89 0xf2 /* mov dx,si */\
|
||||
0xa9 /* test ax,... */\
|
||||
0x4e /* L3:dec si */\
|
||||
0x4e /* L4:dec si */\
|
||||
0x1f /* pop ds */ \
|
||||
parm caller [cx si] [bl]\
|
||||
value [dx si]\
|
||||
modify [ax dx si];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* locate the first occurrence of c in the initial n characters of the
|
||||
string pointed to by s. The terminating null character is considered
|
||||
to be part of the string.
|
||||
If the character c is not found, NULL is returned.
|
||||
*/
|
||||
#undef strchr
|
||||
|
||||
|
||||
#if defined(__RISCSTR__) && defined(__WIDECHAR__)
|
||||
_WCRTLINK CHAR_TYPE *__simple_wcschr( const CHAR_TYPE *s, INTCHAR_TYPE c )
|
||||
#else
|
||||
_WCRTLINK CHAR_TYPE *__F_NAME(strchr,wcschr)( const CHAR_TYPE *s, INTCHAR_TYPE c )
|
||||
#endif
|
||||
{
|
||||
CHAR_TYPE cc = c;
|
||||
do {
|
||||
if( *s == cc ) return( (CHAR_TYPE *)s );
|
||||
} while( *s++ != NULLCHAR );
|
||||
return( NULL );
|
||||
}
|
55
programs/develop/open watcom/trunk/clib/string/strcoll.c
Normal file
55
programs/develop/open watcom/trunk/clib/string/strcoll.c
Normal file
@@ -0,0 +1,55 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 "widechar.h"
|
||||
#include <string.h>
|
||||
#include "xstring.h"
|
||||
|
||||
#undef strcoll
|
||||
|
||||
|
||||
|
||||
/* This function is identical to strcmp, except it is suppose to use
|
||||
the current locale. We only support the "C" locale, so this code
|
||||
is identical to strcmp.
|
||||
*/
|
||||
/* return <0 if s<t, 0 if s==t, >0 if s>t */
|
||||
|
||||
|
||||
_WCRTLINK int __F_NAME(strcoll,wcscoll) ( const CHAR_TYPE *s, const CHAR_TYPE *t )
|
||||
{
|
||||
for( ; *s == *t; s++, t++ )
|
||||
if( *s == '\0' )
|
||||
return( 0 );
|
||||
return( *s - *t );
|
||||
}
|
140
programs/develop/open watcom/trunk/clib/string/strcpy.c
Normal file
140
programs/develop/open watcom/trunk/clib/string/strcpy.c
Normal file
@@ -0,0 +1,140 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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: Implementation of strcpy().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include "widechar.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "riscstr.h"
|
||||
|
||||
#undef strcpy
|
||||
|
||||
extern CHAR_TYPE *__strcpy( CHAR_TYPE *dst, const CHAR_TYPE *src );
|
||||
#if defined(__386__)
|
||||
#pragma aux __strcpy = \
|
||||
" push eax" \
|
||||
"L1: mov cl,[edx]" \
|
||||
" mov [eax],cl" \
|
||||
" cmp cl,0" \
|
||||
" je L2" \
|
||||
" mov cl,1[edx]"\
|
||||
" add edx,2" \
|
||||
" mov 1[eax],cl"\
|
||||
" add eax,2" \
|
||||
" cmp cl,0" \
|
||||
" jne L1" \
|
||||
"L2: pop eax" \
|
||||
parm [eax] [edx] value [eax] modify exact [eax edx ecx];
|
||||
#elif defined(M_I86)
|
||||
#if defined(__SMALL_DATA__)
|
||||
#pragma aux __strcpy = \
|
||||
" push di" \
|
||||
" test si,1" \
|
||||
" je L1" \
|
||||
" lodsb" \
|
||||
" mov [di],al" \
|
||||
" inc di" \
|
||||
" cmp al,0" \
|
||||
" je L3" \
|
||||
"L1: mov ax,[si]" \
|
||||
" test al,al" \
|
||||
" je L2" \
|
||||
" mov [di],ax" \
|
||||
" add di,2" \
|
||||
" test ah,ah" \
|
||||
" je L3" \
|
||||
" mov ax,2[si]" \
|
||||
" test al,al" \
|
||||
" je L2" \
|
||||
" mov [di],ax" \
|
||||
" add si,4" \
|
||||
" add di,2" \
|
||||
" test ah,ah" \
|
||||
" jne L1" \
|
||||
" je L3" \
|
||||
"L2: mov [di],al" \
|
||||
"L3: pop ax" \
|
||||
parm [di] [si] value [ax] modify exact [si di];
|
||||
#else // compact, large, or huge
|
||||
#pragma aux __strcpy = \
|
||||
" push ds" \
|
||||
" push di" \
|
||||
" mov ds,dx" \
|
||||
" test si,1" \
|
||||
" je L1" \
|
||||
" lodsb" \
|
||||
" stosb" \
|
||||
" cmp al,0" \
|
||||
" je L3" \
|
||||
"L1: mov ax,[si]" \
|
||||
" test al,al" \
|
||||
" je L2" \
|
||||
" stosw" \
|
||||
" test ah,ah" \
|
||||
" je L3" \
|
||||
" mov ax,2[si]" \
|
||||
" test al,al" \
|
||||
" je L2" \
|
||||
" stosw" \
|
||||
" add si,4" \
|
||||
" test ah,ah" \
|
||||
" jne L1" \
|
||||
" je L3" \
|
||||
"L2: stosb" \
|
||||
"L3: pop ax" \
|
||||
" mov dx,es" \
|
||||
" pop ds" \
|
||||
parm [es di] [dx si] value [dx ax] modify exact [si di];
|
||||
#endif
|
||||
#else
|
||||
/* currently no pragma for non-x86 */
|
||||
#endif
|
||||
|
||||
|
||||
/* copy string t to string s */
|
||||
|
||||
#if defined(__RISCSTR__) && defined(__WIDECHAR__)
|
||||
_WCRTLINK CHAR_TYPE *__simple_wcscpy( CHAR_TYPE *s, const CHAR_TYPE *t )
|
||||
#else
|
||||
_WCRTLINK CHAR_TYPE *__F_NAME(strcpy,wcscpy)( CHAR_TYPE *s, const CHAR_TYPE *t )
|
||||
#endif
|
||||
{
|
||||
#if !defined(__WIDECHAR__) && defined(_M_IX86)
|
||||
return( __strcpy( s, t ) );
|
||||
#else
|
||||
CHAR_TYPE *dst;
|
||||
|
||||
dst = s;
|
||||
while( *dst++ = *t++ )
|
||||
;
|
||||
return( s );
|
||||
#endif
|
||||
}
|
76
programs/develop/open watcom/trunk/clib/string/strcpy_s.c
Normal file
76
programs/develop/open watcom/trunk/clib/string/strcpy_s.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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: Implementation of strcpy_s() - bounds-checking strcpy().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include "saferlib.h"
|
||||
#include "widechar.h"
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
|
||||
|
||||
_WCRTLINK errno_t __F_NAME(strcpy_s,wcscpy_s)( CHAR_TYPE * __restrict s1,
|
||||
rsize_t s1max, const CHAR_TYPE * __restrict s2 )
|
||||
/************************************************************************/
|
||||
{
|
||||
errno_t rc = -1;
|
||||
const char *msg;
|
||||
|
||||
// strnlen_s is safe to use as it has no rt constraints
|
||||
rsize_t s2len = __F_NAME(strnlen_s,wcsnlen_s)( s2, s1max );
|
||||
|
||||
// Verify runtime-constraints
|
||||
// s1 not NULL
|
||||
// s2 not NULL
|
||||
// s1max <= RSIZE_MAX
|
||||
// s1max != 0
|
||||
// s1max > strnlen_s( s2, s1max )
|
||||
// s1 s2 no overlap
|
||||
if( __check_constraint_nullptr_msg( msg, s1 ) &&
|
||||
__check_constraint_nullptr_msg( msg, s2 ) &&
|
||||
__check_constraint_maxsize_msg( msg, s1max ) &&
|
||||
__check_constraint_zero_msg( msg, s1max ) &&
|
||||
__check_constraint_a_gt_b_msg( msg, s2len, s1max - 1 ) &&
|
||||
__check_constraint_overlap_msg( msg, s1, s1max, s2, s2len ) ) {
|
||||
|
||||
while( *s1++ = *s2++)
|
||||
;
|
||||
|
||||
rc = 0;
|
||||
} else {
|
||||
// Runtime-constraints violated, make destination string empty
|
||||
if( (s1 != NULL) && (s1max > 0) && __lte_rsizmax( s1max ) ) {
|
||||
s1[0] = NULLCHAR;
|
||||
}
|
||||
// Now call the handler
|
||||
__rtct_fail( __func__, msg, NULL );
|
||||
}
|
||||
return( rc );
|
||||
}
|
78
programs/develop/open watcom/trunk/clib/string/strcspn.c
Normal file
78
programs/develop/open watcom/trunk/clib/string/strcspn.c
Normal file
@@ -0,0 +1,78 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 "widechar.h"
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "setbits.h"
|
||||
|
||||
/* The strcspn function computes the length of the initial segment of the
|
||||
string pointed to by str which consists entirely of characters not from
|
||||
the string pointed to by charset. The terminating NULL character is not
|
||||
considered part of charset.
|
||||
*/
|
||||
|
||||
|
||||
_WCRTLINK size_t __F_NAME(strcspn,wcscspn) ( const CHAR_TYPE *str, const CHAR_TYPE *charset )
|
||||
{
|
||||
#if defined(__WIDECHAR__)
|
||||
|
||||
const CHAR_TYPE *p1;
|
||||
const CHAR_TYPE *p2;
|
||||
CHAR_TYPE tc1;
|
||||
CHAR_TYPE tc2;
|
||||
size_t len;
|
||||
|
||||
len = 0;
|
||||
for( p1 = str; tc1 = *p1; p1++, len++ ) {
|
||||
for( p2 = charset; tc2 = *p2; p2++ ) {
|
||||
if( tc1 == tc2 ) break;
|
||||
}
|
||||
if( tc2 != NULLCHAR ) break;
|
||||
}
|
||||
return( len );
|
||||
|
||||
#else
|
||||
unsigned /*char*/ tc;
|
||||
unsigned char vector[32];
|
||||
size_t len;
|
||||
|
||||
__setbits( vector, charset );
|
||||
len = 0;
|
||||
for( ; tc = (unsigned char) *str; ++len, ++str ) {
|
||||
/* quit if we find any char in charset */
|
||||
if( ( vector[ tc >> 3 ] & _Bits[ tc & 0x07 ] ) != 0 ) break;
|
||||
}
|
||||
return( len );
|
||||
#endif
|
||||
}
|
57
programs/develop/open watcom/trunk/clib/string/strdup.c
Normal file
57
programs/develop/open watcom/trunk/clib/string/strdup.c
Normal file
@@ -0,0 +1,57 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 "widechar.h"
|
||||
#include "strdup.h"
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "liballoc.h"
|
||||
|
||||
#ifdef __WIDECHAR__
|
||||
extern size_t wcslen( const CHAR_TYPE * );
|
||||
#endif
|
||||
|
||||
|
||||
_WCRTLINK CHAR_TYPE *__F_NAME(__clib_strdup,__clib_wcsdup) ( const CHAR_TYPE *str )
|
||||
{
|
||||
CHAR_TYPE *mem;
|
||||
int len;
|
||||
|
||||
len = __F_NAME(strlen,wcslen)( str ) + 1;
|
||||
mem = lib_malloc( len * CHARSIZE );
|
||||
if( mem ) {
|
||||
(memcpy)( mem, str, len * CHARSIZE );
|
||||
}
|
||||
return( mem );
|
||||
}
|
57
programs/develop/open watcom/trunk/clib/string/streln_s.c
Normal file
57
programs/develop/open watcom/trunk/clib/string/streln_s.c
Normal file
@@ -0,0 +1,57 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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: Implementation of strerrorlen_s().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include "saferlib.h"
|
||||
#include "widechar.h"
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include "errstr.h"
|
||||
|
||||
|
||||
_WCRTLINK size_t __F_NAME(strerrorlen_s,wcserrorlen_s)( errno_t errnum )
|
||||
/************************************************************************/
|
||||
{
|
||||
size_t m = 0;
|
||||
char *msg;
|
||||
|
||||
if( errnum < 0 || errnum >= _sys_nerr ) {
|
||||
msg = UNKNOWN_ERROR;
|
||||
} else {
|
||||
msg = _sys_errlist[ errnum ];
|
||||
}
|
||||
|
||||
// count chars up to '\0' assuming _sys_errlist is singlebyte
|
||||
while( *msg++ != '\0' ) {
|
||||
++m;
|
||||
}
|
||||
return( m );
|
||||
}
|
99
programs/develop/open watcom/trunk/clib/string/strerr_s.c
Normal file
99
programs/develop/open watcom/trunk/clib/string/strerr_s.c
Normal file
@@ -0,0 +1,99 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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: Implementation of strerror_s() - bounds checking strerror().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include "saferlib.h"
|
||||
#include "widechar.h"
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include <errno.h>
|
||||
#include "errstr.h"
|
||||
|
||||
|
||||
_WCRTLINK errno_t __F_NAME(strerror_s,wcserror_s)( CHAR_TYPE *s,
|
||||
rsize_t maxsize,
|
||||
errno_t errnum )
|
||||
/*****************************************************************/
|
||||
{
|
||||
errno_t rc = -1;
|
||||
|
||||
#ifdef __WIDECHAR__
|
||||
wchar_t Wide_Error_String[ 128 ];
|
||||
#endif
|
||||
char *msg;
|
||||
CHAR_TYPE *p;
|
||||
CHAR_TYPE *p2;
|
||||
size_t msglen;
|
||||
int k;
|
||||
|
||||
/* runtime-constraints */
|
||||
// s not NULL
|
||||
// maxsize <= RSIZE_MAX
|
||||
// maxsize != 0
|
||||
if( __check_constraint_nullptr( s ) &&
|
||||
__check_constraint_maxsize( maxsize ) &&
|
||||
__check_constraint_zero( maxsize ) ) {
|
||||
|
||||
if( errnum < 0 || errnum >= _sys_nerr ) {
|
||||
msg = UNKNOWN_ERROR;
|
||||
} else {
|
||||
msg = _sys_errlist[ errnum ];
|
||||
}
|
||||
|
||||
msglen = strlen( msg );
|
||||
|
||||
#ifdef __WIDECHAR__
|
||||
_AToUni( Wide_Error_String, msg );
|
||||
p2 = Wide_Error_String;
|
||||
#else
|
||||
p2 = msg;
|
||||
#endif
|
||||
p = s;
|
||||
k = 0;
|
||||
// copy string up to end of string or end of receiving field
|
||||
while ( (k < maxsize - 1) && (*p2 != NULLCHAR) ) {
|
||||
*p++ = *p2++;
|
||||
++k;
|
||||
};
|
||||
|
||||
if( (maxsize > 3) && (msglen > maxsize - 4) ) {
|
||||
/* msg does not fit, indicate it's incomplete */
|
||||
/* and terminate string */
|
||||
__F_NAME(strcpy,wcscpy)( p - 3, STRING( "..." ) );
|
||||
} else {
|
||||
*p = NULLCHAR; // terminate string
|
||||
}
|
||||
if( msglen < maxsize) {
|
||||
rc = 0; // msg not truncated
|
||||
}
|
||||
}
|
||||
return( rc );
|
||||
}
|
344
programs/develop/open watcom/trunk/clib/string/strerror.c
Normal file
344
programs/develop/open watcom/trunk/clib/string/strerror.c
Normal file
@@ -0,0 +1,344 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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: Implementation of strerror() function.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include "widechar.h"
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include "rtdata.h"
|
||||
#if defined(__NT__)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include "errstr.h"
|
||||
|
||||
|
||||
#ifndef __WIDECHAR__
|
||||
|
||||
#ifdef __LINUX__
|
||||
char *_sys_errlist[] = {
|
||||
/* 0 EOK */ "No error",
|
||||
/* 1 EPERM */ "Operation not permitted",
|
||||
/* 2 ENOENT */ "No such file or directory",
|
||||
/* 3 ESRCH */ "No such process",
|
||||
/* 4 EINTR */ "Interrupted system call",
|
||||
/* 5 EIO */ "I/O error",
|
||||
/* 6 ENXIO */ "No such device or address",
|
||||
/* 7 E2BIG */ "Arg list too long",
|
||||
/* 8 ENOEXEC */ "Exec format error",
|
||||
/* 9 EBADF */ "Bad file number",
|
||||
/* 10 ECHILD */ "No child processes",
|
||||
/* 11 EAGAIN */ "Try again",
|
||||
/* 12 ENOMEM */ "Out of memory",
|
||||
/* 13 EACCES */ "Permission denied",
|
||||
/* 14 EFAULT */ "Bad address",
|
||||
/* 15 ENOTBLK */ "Block device required",
|
||||
/* 16 EBUSY */ "Device or resource busy",
|
||||
/* 17 EEXIST */ "File exists",
|
||||
/* 18 EXDEV */ "Cross-device link",
|
||||
/* 19 ENODEV */ "No such device",
|
||||
/* 20 ENOTDIR */ "Not a directory",
|
||||
/* 21 EISDIR */ "Is a directory",
|
||||
/* 22 EINVAL */ "Invalid argument",
|
||||
/* 23 ENFILE */ "File table overflow",
|
||||
/* 24 EMFILE */ "Too many open files",
|
||||
/* 25 ENOTTY */ "Not a typewriter",
|
||||
/* 26 ETXTBSY */ "Text file busy",
|
||||
/* 27 EFBIG */ "File too large",
|
||||
/* 28 ENOSPC */ "No space left on device",
|
||||
/* 29 ESPIPE */ "Illegal seek",
|
||||
/* 30 EROFS */ "Read-only file system",
|
||||
/* 31 EMLINK */ "Too many links",
|
||||
/* 32 EPIPE */ "Broken pipe",
|
||||
/* 33 EDOM */ "Math argument out of domain of func",
|
||||
/* 34 ERANGE */ "Math result not representable",
|
||||
/* 35 EDEADLK */ "Resource deadlock would occur",
|
||||
/* 36 ENAMETOOLONG */ "File name too long",
|
||||
/* 37 ENOLCK */ "No record locks available",
|
||||
/* 38 ENOSYS */ "Function not implemented",
|
||||
/* 39 ENOTEMPTY */ "Directory not empty",
|
||||
/* 40 ELOOP */ "Too many symbolic links encountered",
|
||||
/* 41 */ "",
|
||||
/* 42 ENOMSG */ "No message of desired type",
|
||||
/* 43 EIDRM */ "Identifier removed",
|
||||
/* 44 ECHRNG */ "Channel number out of range",
|
||||
/* 45 EL2NSYNC */ "Level 2 not synchronized",
|
||||
/* 46 EL3HLT */ "Level 3 halted",
|
||||
/* 47 EL3RST */ "Level 3 reset",
|
||||
/* 48 ELNRNG */ "Link number out of range",
|
||||
/* 49 EUNATCH */ "Protocol driver not attached",
|
||||
/* 50 ENOCSI */ "No CSI structure available",
|
||||
/* 51 EL2HLT */ "Level 2 halted",
|
||||
/* 52 EBADE */ "Invalid exchange",
|
||||
/* 53 EBADR */ "Invalid request descriptor",
|
||||
/* 54 EXFULL */ "Exchange full",
|
||||
/* 55 ENOANO */ "No anode",
|
||||
/* 56 EBADRQC */ "Invalid request code",
|
||||
/* 57 EBADSLT */ "Invalid slot",
|
||||
/* 58 */ "",
|
||||
/* 59 EBFONT */ "Bad font file format",
|
||||
/* 60 ENOSTR */ "Device not a stream",
|
||||
/* 61 ENODATA */ "No data available",
|
||||
/* 62 ETIME */ "Timer expired",
|
||||
/* 63 ENOSR */ "Out of streams resources",
|
||||
/* 64 ENONET */ "Machine is not on the network",
|
||||
/* 65 ENOPKG */ "Package not installed",
|
||||
/* 66 EREMOTE */ "Object is remote",
|
||||
/* 67 ENOLINK */ "Link has been severed",
|
||||
/* 68 EADV */ "Advertise error",
|
||||
/* 69 ESRMNT */ "Srmount error",
|
||||
/* 70 ECOMM */ "Communication error on send",
|
||||
/* 71 EPROTO */ "Protocol error",
|
||||
/* 72 EMULTIHOP */ "Multihop attempted",
|
||||
/* 73 EDOTDOT */ "RFS specific error",
|
||||
/* 74 EBADMSG */ "Not a data message",
|
||||
/* 75 EOVERFLOW */ "Value too large for defined data type",
|
||||
/* 76 ENOTUNIQ */ "Name not unique on network",
|
||||
/* 77 EBADFD */ "File descriptor in bad state",
|
||||
/* 78 EREMCHG */ "Remote address changed",
|
||||
/* 79 ELIBACC */ "Can not access a needed shared library",
|
||||
/* 80 ELIBBAD */ "Accessing a corrupted shared library",
|
||||
/* 81 ELIBSCN */ ".lib section in a.out corrupted",
|
||||
/* 82 ELIBMAX */ "Attempting to link in too many shared libraries",
|
||||
/* 83 ELIBEXEC */ "Cannot exec a shared library directly",
|
||||
/* 84 EILSEQ */ "Illegal byte sequence",
|
||||
/* 85 ERESTART */ "Interrupted system call should be restarted",
|
||||
/* 86 ESTRPIPE */ "Streams pipe error",
|
||||
/* 87 EUSERS */ "Too many users",
|
||||
/* 88 ENOTSOCK */ "Socket operation on non-socket",
|
||||
/* 89 EDESTADDRREQ */ "Destination address required",
|
||||
/* 90 EMSGSIZE */ "Message too long",
|
||||
/* 91 EPROTOTYPE */ "Protocol wrong type for socket",
|
||||
/* 92 ENOPROTOOPT */ "Protocol not available",
|
||||
/* 93 EPROTONOSUPPORT */ "Protocol not supported",
|
||||
/* 94 ESOCKTNOSUPPORT */ "Socket type not supported",
|
||||
/* 95 EOPNOTSUPP */ "Operation not supported on transport endpoint",
|
||||
/* 96 EPFNOSUPPORT */ "Protocol family not supported",
|
||||
/* 97 EAFNOSUPPORT */ "Address family not supported by protocol",
|
||||
/* 98 EADDRINUSE */ "Address already in use",
|
||||
/* 99 EADDRNOTAVAIL */ "Cannot assign requested address",
|
||||
/* 100 ENETDOWN */ "Network is down",
|
||||
/* 101 ENETUNREACH */ "Network is unreachable",
|
||||
/* 102 ENETRESET */ "Network dropped connection because of reset",
|
||||
/* 103 ECONNABORTED */ "Software caused connection abort",
|
||||
/* 104 ECONNRESET */ "Connection reset by peer",
|
||||
/* 105 ENOBUFS */ "No buffer space available",
|
||||
/* 106 EISCONN */ "Transport endpoint is already connected",
|
||||
/* 107 ENOTCONN */ "Transport endpoint is not connected",
|
||||
/* 108 ESHUTDOWN */ "Cannot send after transport endpoint shutdown",
|
||||
/* 109 ETOOMANYREFS */ "Too many references: cannot splice",
|
||||
/* 110 ETIMEDOUT */ "Connection timed out",
|
||||
/* 111 ECONNREFUSED */ "Connection refused",
|
||||
/* 112 EHOSTDOWN */ "Host is down",
|
||||
/* 113 EHOSTUNREACH */ "No route to host",
|
||||
/* 114 EALREADY */ "Operation already in progress",
|
||||
/* 115 EINPROGRESS */ "Operation now in progress",
|
||||
/* 116 ESTALE */ "Stale NFS file handle",
|
||||
/* 117 EUCLEAN */ "Structure needs cleaning",
|
||||
/* 118 ENOTNAM */ "Not a XENIX named type file",
|
||||
/* 119 ENAVAIL */ "No XENIX semaphores available",
|
||||
/* 120 EISNAM */ "Is a named type file",
|
||||
/* 121 EREMOTEIO */ "Remote I/O error",
|
||||
/* 122 EDQUOT */ "Quota exceeded",
|
||||
/* 121 */ "",
|
||||
/* 123 ENOMEDIUM */ "No medium found",
|
||||
/* 124 EMEDIUMTYPE */ "Wrong medium type"
|
||||
/* if more are added, be sure to update _sys_nerr accordingly */
|
||||
};
|
||||
#else
|
||||
char *_sys_errlist[] = {
|
||||
/* 0 EZERO */ "No error",
|
||||
/* 1 ENOENT */ "No such file or directory",
|
||||
/* 2 E2BIG */ "Arg list too big",
|
||||
/* 3 ENOEXEC */ "Exec format error",
|
||||
/* 4 EBADF */ "Bad file number",
|
||||
/* 5 ENOMEM */ "Not enough memory",
|
||||
/* 6 EACCES */ "Permission denied",
|
||||
/* 7 EEXIST */ "File exists",
|
||||
/* 8 EXDEV */ "Cross-device link",
|
||||
/* 9 EINVAL */ "Invalid argument",
|
||||
/* 10 ENFILE */ "File table overflow",
|
||||
/* 11 EMFILE */ "Too many open files",
|
||||
/* 12 ENOSPC */ "No space left on device",
|
||||
/* 13 EDOM */ "Argument too large",
|
||||
/* 14 ERANGE */ "Result too large",
|
||||
/* 15 EDEADLK */ "Resource deadlock would occur",
|
||||
/* 16 EINTR */ "System call interrupted",
|
||||
/* 17 ECHILD */ "Child does not exist",
|
||||
/* 18 EAGAIN */ "Resource unavailable, try again",
|
||||
/* 19 EBUSY */ "Device or resource busy",
|
||||
/* 20 EFBIG */ "File too large",
|
||||
/* 21 EIO */ "I/O error",
|
||||
/* 22 EISDIR */ "Is a directory",
|
||||
/* 23 ENOTDIR */ "Not a directory",
|
||||
/* 24 EMLINK */ "Too many links",
|
||||
/* 25 ENOTBLK */ "Block device required",
|
||||
/* 26 ENOTTY */ "Not a character device",
|
||||
/* 27 ENXIO */ "No such device or address",
|
||||
/* 28 EPERM */ "Not owner",
|
||||
/* 29 EPIPE */ "Broken pipe",
|
||||
/* 30 EROFS */ "Read-only file system",
|
||||
/* 31 ESPIPE */ "Illegal seek",
|
||||
/* 32 ESRCH */ "No such process",
|
||||
/* 33 ETXTBSY */ "Text file busy",
|
||||
/* 34 EFAULT */ "Bad address",
|
||||
/* 35 ENAMETOOLONG */ "Filename too long",
|
||||
/* 36 ENODEV */ "No such device",
|
||||
/* 37 ENOLCK */ "No locks available in system",
|
||||
/* 38 ENOSYS */ "Unknown system call",
|
||||
/* 39 ENOTEMPTY */ "Directory not empty",
|
||||
/* 40 EILSEQ */ "Illegal multibyte sequence"
|
||||
/* if more are added, be sure to update _sys_nerr accordingly */
|
||||
};
|
||||
#endif
|
||||
|
||||
int _WCNEAR _sys_nerr = ( sizeof( _sys_errlist ) / sizeof( *_sys_errlist ) );
|
||||
|
||||
#endif
|
||||
|
||||
_WCRTLINK CHAR_TYPE *__F_NAME(strerror,wcserror)( int errnum )
|
||||
{
|
||||
#ifdef __WIDECHAR__
|
||||
static wchar_t Wide_Error_String[40];
|
||||
#endif
|
||||
char *msg;
|
||||
|
||||
if( errnum < 0 || errnum >= _sys_nerr ) {
|
||||
msg = UNKNOWN_ERROR;
|
||||
} else {
|
||||
msg = _sys_errlist[ errnum ];
|
||||
}
|
||||
return( _AToUni( Wide_Error_String, msg ) );
|
||||
}
|
||||
|
||||
// Note: Windows FORMAT_MESSAGE_MAX_WIDTH_MASK is 255
|
||||
|
||||
#if !defined(FORMAT_MESSAGE_MAX_WIDTH_MASK)
|
||||
#define FORMAT_MESSAGE_MAX_WIDTH_MASK 255
|
||||
#endif
|
||||
|
||||
#ifdef __WIDECHAR__
|
||||
static wchar_t Wide_Error_String[FORMAT_MESSAGE_MAX_WIDTH_MASK+1];
|
||||
#else
|
||||
static char Error_String[FORMAT_MESSAGE_MAX_WIDTH_MASK+1];
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
char *_strerror( const char *strErrMsg );
|
||||
|
||||
Description from the MSDN:
|
||||
|
||||
If strErrMsg is passed as NULL, _strerror returns a pointer to a
|
||||
string containing the system error message for the last library call
|
||||
that produced an error. The error-message string is terminated by
|
||||
the newline character ('\n'). If strErrMsg is not equal to NULL,
|
||||
then _strerror returns a pointer to a string containing (in order)
|
||||
your string message, a colon, a space, the system error message for
|
||||
the last library call producing an error, and a newline character.
|
||||
Your string message can be, at most, 94 bytes long.
|
||||
|
||||
The actual error number for _strerror is stored in the variable
|
||||
errno. The system error messages are accessed through the variable
|
||||
_sys_errlist, which is an array of messages ordered by error number.
|
||||
_strerror accesses the appropriate error message by using the errno
|
||||
value as an index to the variable _sys_errlist. The value of the
|
||||
variable _sys_nerr is defined as the maximum number of elements in
|
||||
the _sys_errlist array. To produce accurate results, call _strerror
|
||||
immediately after a library routine returns with an error.
|
||||
Otherwise, subsequent calls to strerror or _strerror can overwrite
|
||||
the errno value.
|
||||
|
||||
_strerror is not part of the ANSI definition but is instead a
|
||||
Microsoft extension to it. Do not use it where portability is
|
||||
desired; for ANSI compatibility, use strerror instead.
|
||||
|
||||
*/
|
||||
|
||||
_WCRTLINK CHAR_TYPE *__F_NAME(_strerror,_wcserror)( const CHAR_TYPE *strErrMsg )
|
||||
{
|
||||
int errnum;
|
||||
|
||||
errnum = _RWD_errno;
|
||||
#ifdef __WIDECHAR__
|
||||
Wide_Error_String[0] = L'\0';
|
||||
if( strErrMsg != NULL ) {
|
||||
wcsncpy( Wide_Error_String, strErrMsg, 94 );
|
||||
Wide_Error_String[94] = L'\0'; // just in case more than 94
|
||||
wcscat( Wide_Error_String, L": " );
|
||||
}
|
||||
wcscat( Wide_Error_String, wcserror( errnum ) );
|
||||
wcscat( Wide_Error_String, L"\n" );
|
||||
return( Wide_Error_String );
|
||||
#else
|
||||
Error_String[0] = '\0';
|
||||
if( strErrMsg != NULL ) {
|
||||
strncpy( Error_String, strErrMsg, 94 );
|
||||
Error_String[94] = '\0'; // just in case more than 94
|
||||
strcat( Error_String, ": " );
|
||||
}
|
||||
strcat( Error_String, strerror( errnum ) );
|
||||
strcat( Error_String, "\n" );
|
||||
return( Error_String );
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(__NT__)
|
||||
|
||||
_WCRTLINK CHAR_TYPE *__F_NAME(_doserror,_wdoserror)( int errnum )
|
||||
{
|
||||
#ifdef __WIDECHAR__
|
||||
Wide_Error_String[0] = L'\0';
|
||||
FormatMessageW( FORMAT_MESSAGE_IGNORE_INSERTS |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_MAX_WIDTH_MASK,
|
||||
NULL,
|
||||
errnum,
|
||||
0,
|
||||
Wide_Error_String,
|
||||
FORMAT_MESSAGE_MAX_WIDTH_MASK,
|
||||
NULL );
|
||||
return( Wide_Error_String );
|
||||
#else
|
||||
Error_String[0] = '\0';
|
||||
FormatMessageA( FORMAT_MESSAGE_IGNORE_INSERTS |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_MAX_WIDTH_MASK,
|
||||
NULL,
|
||||
errnum,
|
||||
0,
|
||||
Error_String,
|
||||
FORMAT_MESSAGE_MAX_WIDTH_MASK,
|
||||
NULL );
|
||||
return( Error_String );
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
62
programs/develop/open watcom/trunk/clib/string/stricmp.c
Normal file
62
programs/develop/open watcom/trunk/clib/string/stricmp.c
Normal file
@@ -0,0 +1,62 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 "widechar.h"
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include "riscstr.h"
|
||||
|
||||
/* return <0 if s<t, 0 if s==t, >0 if s>t */
|
||||
|
||||
#if defined(__RISCSTR__) && defined(__WIDECHAR__)
|
||||
_WCRTLINK int __simple__wcsicmp( const CHAR_TYPE *s, const CHAR_TYPE *t ) {
|
||||
#else
|
||||
_WCRTLINK int __F_NAME(stricmp,_wcsicmp)( const CHAR_TYPE *s, const CHAR_TYPE *t ) {
|
||||
#endif
|
||||
UCHAR_TYPE c1;
|
||||
UCHAR_TYPE c2;
|
||||
|
||||
for(;;) {
|
||||
c1 = *s;
|
||||
c2 = *t;
|
||||
if( IS_ASCII( c1 ) && IS_ASCII( c2 ) ) {
|
||||
if( c1 >= 'A' && c1 <= 'Z' ) c1 += 'a' - 'A';
|
||||
if( c2 >= 'A' && c2 <= 'Z' ) c2 += 'a' - 'A';
|
||||
}
|
||||
if( c1 != c2 ) break;
|
||||
if( c1 == NULLCHAR ) break;
|
||||
++s;
|
||||
++t;
|
||||
}
|
||||
return( c1 - c2 );
|
||||
}
|
68
programs/develop/open watcom/trunk/clib/string/strlcat.c
Normal file
68
programs/develop/open watcom/trunk/clib/string/strlcat.c
Normal file
@@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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: Implementation of BSD style strlcat() and wcslcat().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include "widechar.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
_WCRTLINK size_t __F_NAME(strlcat,wcslcat)( CHAR_TYPE *dst, const CHAR_TYPE *t, size_t n )
|
||||
{
|
||||
CHAR_TYPE *s;
|
||||
size_t len;
|
||||
|
||||
s = dst;
|
||||
// Find end of string in destination buffer but don't overrun
|
||||
for( len = n; len; --len ) {
|
||||
if( *s == NULLCHAR ) break;
|
||||
++s;
|
||||
}
|
||||
// If no null char was found in dst, the buffer is messed up; don't
|
||||
// touch it
|
||||
if( *s == NULLCHAR ) {
|
||||
--len; // Decrement len to leave space for terminating null
|
||||
while( len != 0 ) {
|
||||
*s = *t;
|
||||
if( *s == NULLCHAR ) {
|
||||
return( n - len - 1 );
|
||||
}
|
||||
++s;
|
||||
++t;
|
||||
--len;
|
||||
}
|
||||
// Buffer not large enough. Terminate and figure out desired length
|
||||
*s = NULLCHAR;
|
||||
while( *t++ != NULLCHAR )
|
||||
++n;
|
||||
--n;
|
||||
}
|
||||
return( n );
|
||||
}
|
64
programs/develop/open watcom/trunk/clib/string/strlcpy.c
Normal file
64
programs/develop/open watcom/trunk/clib/string/strlcpy.c
Normal file
@@ -0,0 +1,64 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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: Implementation of BSD style strlcpy() and wcslcpy().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include "widechar.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
_WCRTLINK size_t __F_NAME(strlcpy,wcslcpy)( CHAR_TYPE *dst, const CHAR_TYPE *src, size_t len )
|
||||
{
|
||||
const CHAR_TYPE *s;
|
||||
size_t count;
|
||||
|
||||
count = len;
|
||||
if( len ) {
|
||||
--len; // leave space for terminating null
|
||||
for( ; len; --len ) {
|
||||
if( *src == NULLCHAR ) {
|
||||
break;
|
||||
}
|
||||
*dst++ = *src++;
|
||||
}
|
||||
*dst = NULLCHAR; // terminate 'dst'
|
||||
} else {
|
||||
++count; // account for not decrementing 'len'
|
||||
}
|
||||
|
||||
if( !len ) { // source string was truncated
|
||||
s = src;
|
||||
while( *s != NULLCHAR ) {
|
||||
++s;
|
||||
}
|
||||
count += s - src; // find out how long 'src' really is
|
||||
}
|
||||
return( count - len - 1 ); // final null doesn't count
|
||||
}
|
58
programs/develop/open watcom/trunk/clib/string/strlen.c
Normal file
58
programs/develop/open watcom/trunk/clib/string/strlen.c
Normal file
@@ -0,0 +1,58 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 "widechar.h"
|
||||
#include <stdio.h>
|
||||
#include "xstring.h"
|
||||
#include "riscstr.h"
|
||||
#undef strlen
|
||||
|
||||
|
||||
#if defined(__RISCSTR__) && defined(__WIDECHAR__)
|
||||
_WCRTLINK size_t __simple_wcslen( const CHAR_TYPE *s ) /* return length of s */
|
||||
#else
|
||||
_WCRTLINK size_t __F_NAME(strlen,wcslen)( const CHAR_TYPE *s ) /* return length of s */
|
||||
#endif
|
||||
{
|
||||
|
||||
#if defined(__INLINE_FUNCTIONS__) && !defined(__WIDECHAR__) && defined(_M_IX86)
|
||||
return( _inline_strlen( s ) );
|
||||
#else
|
||||
const CHAR_TYPE *p;
|
||||
|
||||
p = s;
|
||||
while( *p != NULLCHAR )
|
||||
++p;
|
||||
return( p - s );
|
||||
#endif
|
||||
}
|
59
programs/develop/open watcom/trunk/clib/string/strlwr.c
Normal file
59
programs/develop/open watcom/trunk/clib/string/strlwr.c
Normal file
@@ -0,0 +1,59 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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: Implementation of strlwr().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include "widechar.h"
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include "riscstr.h"
|
||||
|
||||
|
||||
#if defined(__RISCSTR__) && defined(__WIDECHAR__)
|
||||
_WCRTLINK CHAR_TYPE *__simple__wcslwr( CHAR_TYPE *str ) {
|
||||
#else
|
||||
_WCRTLINK CHAR_TYPE *__F_NAME(strlwr,_wcslwr)( CHAR_TYPE *str ) {
|
||||
#endif
|
||||
CHAR_TYPE *p;
|
||||
UCHAR_TYPE c;
|
||||
|
||||
p = str;
|
||||
while( (c = *p) ) {
|
||||
if( IS_ASCII( c ) ) {
|
||||
c -= 'A';
|
||||
if( c <= 'Z' - 'A' ) {
|
||||
c += 'a';
|
||||
*p = c;
|
||||
}
|
||||
}
|
||||
++p;
|
||||
}
|
||||
return( str );
|
||||
}
|
116
programs/develop/open watcom/trunk/clib/string/strncat.c
Normal file
116
programs/develop/open watcom/trunk/clib/string/strncat.c
Normal file
@@ -0,0 +1,116 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 "widechar.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(M_I86) && !defined(__WIDECHAR__)
|
||||
|
||||
extern char *_fast_strncat( char _WCFAR *, const char *, size_t );
|
||||
|
||||
#if defined(__SMALL_DATA__)
|
||||
|
||||
#pragma aux _fast_strncat = \
|
||||
0x57 /* push di */\
|
||||
0xb9 0xff 0xff /* mov cx,ffffh */\
|
||||
0x31 0xc0 /* xor ax,ax */\
|
||||
0xf2 0xae /* repne scasb */\
|
||||
0x4f /* dec di */\
|
||||
0x89 0xd1 /* mov cx,dx */\
|
||||
0xac /* L1: lodsb */\
|
||||
0xaa /* stosb */\
|
||||
0x84 0xc0 /* test al,al */\
|
||||
0xe0 0xfa /* loopne L1 */\
|
||||
0x74 0x03 /* je L2 */\
|
||||
0x26 0x88 0x25 /* mov es:[di],ah */\
|
||||
0x58 /* L2: pop ax */\
|
||||
parm caller [es di] [si] [dx]\
|
||||
value [ax] \
|
||||
modify exact [ax cx si di];
|
||||
|
||||
#else
|
||||
|
||||
#pragma aux _fast_strncat = \
|
||||
0x1e /* push ds */ \
|
||||
0x8e 0xd9 /* mov ds,cx */ \
|
||||
0x57 /* push di */\
|
||||
0xb9 0xff 0xff /* mov cx,ffffh */\
|
||||
0x31 0xc0 /* xor ax,ax */\
|
||||
0xf2 0xae /* repne scasb */\
|
||||
0x4f /* dec di */\
|
||||
0x89 0xd1 /* mov cx,dx */\
|
||||
0xac /* L1: lodsb */\
|
||||
0xaa /* stosb */\
|
||||
0x84 0xc0 /* test al,al */\
|
||||
0xe0 0xfa /* loopne L1 */\
|
||||
0x74 0x03 /* je L2 */\
|
||||
0x26 0x88 0x25 /* mov es:[di],ah */\
|
||||
0x58 /* L2: pop ax */\
|
||||
0x1f /* pop ds */ \
|
||||
parm caller [es di] [cx si] [dx]\
|
||||
value [es ax] \
|
||||
modify exact [ax cx si di];
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* concatenate t to the end of dst */
|
||||
|
||||
_WCRTLINK CHAR_TYPE *__F_NAME(strncat,wcsncat) ( CHAR_TYPE *dst, const CHAR_TYPE *t, size_t n )
|
||||
{
|
||||
#if defined(M_I86) && !defined(__WIDECHAR__)
|
||||
if( n ) {
|
||||
return( _fast_strncat( dst, t, n ) );
|
||||
}
|
||||
return( dst );
|
||||
#else
|
||||
CHAR_TYPE *s;
|
||||
|
||||
#ifdef __WIDECHAR__
|
||||
s = dst + wcslen( dst );
|
||||
#else
|
||||
s = memchr( dst, NULLCHAR, ~0u );
|
||||
#endif
|
||||
while( n != 0 ) {
|
||||
*s = *t;
|
||||
if( *s == NULLCHAR ) break;
|
||||
++s;
|
||||
++t;
|
||||
--n;
|
||||
}
|
||||
*s = NULLCHAR;
|
||||
return( dst );
|
||||
#endif
|
||||
}
|
104
programs/develop/open watcom/trunk/clib/string/strncmp.c
Normal file
104
programs/develop/open watcom/trunk/clib/string/strncmp.c
Normal file
@@ -0,0 +1,104 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 "widechar.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "riscstr.h"
|
||||
|
||||
#if defined(M_I86) && !defined(__WIDECHAR__)
|
||||
|
||||
extern int _fast_strncmp( const char *, const char _WCFAR *, size_t );
|
||||
|
||||
#if defined(__SMALL_DATA__)
|
||||
#pragma aux _fast_strncmp = \
|
||||
0x89 0xfa /* mov dx,di */ \
|
||||
0x30 0xc0 /* xor al,al */ \
|
||||
0xf2 0xae /* repne scasb */ \
|
||||
0x89 0xf9 /* mov cx,di */ \
|
||||
0x89 0xd7 /* mov di,dx */ \
|
||||
0x29 0xf9 /* sub cx,di */ \
|
||||
0xf3 0xa6 /* repe cmpsb */ \
|
||||
0x74 0x05 /* je L1 */ \
|
||||
0x19 0xc9 /* sbb cx,cx */ \
|
||||
0x83 0xd9 0xff /* sbb cx,ffffh */ \
|
||||
/* L1: */ \
|
||||
parm caller [si] [es di] [cx] \
|
||||
value [cx] \
|
||||
modify exact [dx ax di cx si];
|
||||
#else
|
||||
#pragma aux _fast_strncmp = \
|
||||
0x1e /* push ds */ \
|
||||
0x8e 0xda /* mov ds,dx */ \
|
||||
0x89 0xfa /* mov dx,di */ \
|
||||
0x30 0xc0 /* xor al,al */ \
|
||||
0xf2 0xae /* repne scasb */ \
|
||||
0x89 0xf9 /* mov cx,di */ \
|
||||
0x89 0xd7 /* mov di,dx */ \
|
||||
0x29 0xf9 /* sub cx,di */ \
|
||||
0xf3 0xa6 /* repe cmpsb */ \
|
||||
0x74 0x05 /* je L1 */ \
|
||||
0x19 0xc9 /* sbb cx,cx */ \
|
||||
0x83 0xd9 0xff /* sbb cx,ffffh */ \
|
||||
/* L1: */ \
|
||||
0x1f /* pop ds */ \
|
||||
parm caller [dx si] [es di] [cx] \
|
||||
value [cx] \
|
||||
modify exact [dx ax di cx si];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* return <0 if s<t, 0 if s==t, >0 if s>t */
|
||||
|
||||
#if defined(__RISCSTR__) && defined(__WIDECHAR__)
|
||||
_WCRTLINK int __simple_wcsncmp( const CHAR_TYPE *s, const CHAR_TYPE *t, size_t n )
|
||||
#else
|
||||
_WCRTLINK int __F_NAME(strncmp,wcsncmp)( const CHAR_TYPE *s, const CHAR_TYPE *t, size_t n )
|
||||
#endif
|
||||
{
|
||||
#if defined(M_I86) && !defined(__WIDECHAR__)
|
||||
if( n ) {
|
||||
return( _fast_strncmp( s, t, n ) );
|
||||
}
|
||||
return( 0 );
|
||||
#else
|
||||
for(;;) {
|
||||
if( n == 0 ) return( 0 ); /* equal */
|
||||
if( *s != *t ) return( *s - *t ); /* less than or greater than */
|
||||
if( *s == NULLCHAR ) return( 0 ); /* equal */
|
||||
++s;
|
||||
++t;
|
||||
--n;
|
||||
}
|
||||
#endif
|
||||
}
|
111
programs/develop/open watcom/trunk/clib/string/strncpy.c
Normal file
111
programs/develop/open watcom/trunk/clib/string/strncpy.c
Normal file
@@ -0,0 +1,111 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 "widechar.h"
|
||||
#include <string.h>
|
||||
#include "riscstr.h"
|
||||
|
||||
#if defined(M_I86) & !defined(__WIDECHAR__)
|
||||
|
||||
extern char *fast_strncpy( char _WCFAR *, const char *, size_t );
|
||||
|
||||
#if defined(__SMALL_DATA__)
|
||||
|
||||
#pragma aux fast_strncpy = \
|
||||
0x57 /* push di */\
|
||||
0xac /* L1: lodsb */\
|
||||
0xaa /* stosb */\
|
||||
0x84 0xc0 /* test al,al */\
|
||||
0xe0 0xfa /* loopne L1 */\
|
||||
0x31 0xc0 /* xor ax,ax */\
|
||||
0xd1 0xe9 /* shr cx,1 */\
|
||||
0xf3 0xab /* rep stosw */\
|
||||
0x11 0xc9 /* adc cx,cx */\
|
||||
0xf3 0xaa /* rep stosb */\
|
||||
0x58 /* pop ax */\
|
||||
parm caller [es di] [si] [cx]\
|
||||
value [ax] \
|
||||
modify exact [ax cx si di];
|
||||
|
||||
#else
|
||||
|
||||
#pragma aux fast_strncpy = \
|
||||
0x1e /* push ds */ \
|
||||
0x8e 0xda /* mov ds,dx */ \
|
||||
0x57 /* push di */\
|
||||
0xac /* L1: lodsb */\
|
||||
0xaa /* stosb */\
|
||||
0x84 0xc0 /* test al,al */\
|
||||
0xe0 0xfa /* loopne L1 */\
|
||||
0x31 0xc0 /* xor ax,ax */\
|
||||
0xd1 0xe9 /* shr cx,1 */\
|
||||
0xf3 0xab /* rep stosw */\
|
||||
0x11 0xc9 /* adc cx,cx */\
|
||||
0xf3 0xaa /* rep stosb */\
|
||||
0x58 /* pop ax */\
|
||||
0x1f /* pop ds */ \
|
||||
parm caller [es di] [dx si] [cx]\
|
||||
value [es ax] \
|
||||
modify exact [ax cx si di];
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__RISCSTR__) && defined(__WIDECHAR__)
|
||||
_WCRTLINK CHAR_TYPE *__simple_wcsncpy( CHAR_TYPE *dst, const CHAR_TYPE *src, size_t len )
|
||||
#else
|
||||
_WCRTLINK CHAR_TYPE *__F_NAME(strncpy,wcsncpy)( CHAR_TYPE *dst, const CHAR_TYPE *src, size_t len )
|
||||
#endif
|
||||
{
|
||||
#if defined(M_I86) && !defined(__WIDECHAR__)
|
||||
if( len ) {
|
||||
return( fast_strncpy( dst, src, len ) );
|
||||
}
|
||||
return( dst );
|
||||
#else
|
||||
CHAR_TYPE *ret;
|
||||
|
||||
ret = dst;
|
||||
for(;len; --len ) {
|
||||
if( *src == NULLCHAR ) break;
|
||||
*dst++ = *src++;
|
||||
}
|
||||
while( len != 0 ) {
|
||||
*dst++ = NULLCHAR; /* pad destination string with null chars */
|
||||
--len;
|
||||
}
|
||||
return( ret );
|
||||
#endif
|
||||
}
|
65
programs/develop/open watcom/trunk/clib/string/strnicmp.c
Normal file
65
programs/develop/open watcom/trunk/clib/string/strnicmp.c
Normal file
@@ -0,0 +1,65 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 "widechar.h"
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include "riscstr.h"
|
||||
|
||||
/* return <0 if s<t, 0 if s==t, >0 if s>t */
|
||||
|
||||
|
||||
#if defined(__RISCSTR__) && defined(__WIDECHAR__)
|
||||
_WCRTLINK int __simple__wcsnicmp( const CHAR_TYPE *s, const CHAR_TYPE *t, size_t n )
|
||||
#else
|
||||
_WCRTLINK int __F_NAME(strnicmp,_wcsnicmp)( const CHAR_TYPE *s, const CHAR_TYPE *t, size_t n )
|
||||
#endif
|
||||
{
|
||||
UCHAR_TYPE c1;
|
||||
UCHAR_TYPE c2;
|
||||
|
||||
for(;;) {
|
||||
if( n == 0 ) return( 0 ); /* equal */
|
||||
c1 = *s;
|
||||
c2 = *t;
|
||||
if( IS_ASCII( c1 ) && IS_ASCII( c2 ) ) {
|
||||
if( c1 >= 'A' && c1 <= 'Z' ) c1 += 'a' - 'A';
|
||||
if( c2 >= 'A' && c2 <= 'Z' ) c2 += 'a' - 'A';
|
||||
}
|
||||
if( c1 != c2 ) return( c1 - c2 ); /* less than or greater than */
|
||||
if( c1 == NULLCHAR ) return( 0 ); /* equal */
|
||||
++s;
|
||||
++t;
|
||||
--n;
|
||||
}
|
||||
}
|
51
programs/develop/open watcom/trunk/clib/string/strnln_s.c
Normal file
51
programs/develop/open watcom/trunk/clib/string/strnln_s.c
Normal file
@@ -0,0 +1,51 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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: Implementation of strnlen_s() - "safe" strnlen().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include "saferlib.h"
|
||||
#include "widechar.h"
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
|
||||
|
||||
_WCRTLINK size_t __F_NAME(strnlen_s,wcsnlen_s)( const CHAR_TYPE *s, size_t maxsize )
|
||||
/**********************************************************************************/
|
||||
{
|
||||
size_t m = 0;
|
||||
|
||||
// ensure the pointer is not NULL
|
||||
if( s != NULL ) {
|
||||
// count chars up to '\0' or maxsize
|
||||
while( *(s + m) != NULLCHAR && m < maxsize )
|
||||
++m;
|
||||
}
|
||||
return( m );
|
||||
}
|
52
programs/develop/open watcom/trunk/clib/string/strnset.c
Normal file
52
programs/develop/open watcom/trunk/clib/string/strnset.c
Normal file
@@ -0,0 +1,52 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 "widechar.h"
|
||||
#include <string.h>
|
||||
#include "riscstr.h"
|
||||
|
||||
|
||||
#if defined(__RISCSTR__) && defined(__WIDECHAR__)
|
||||
_WCRTLINK CHAR_TYPE *__simple__wcsnset( CHAR_TYPE *str, int c, size_t len )
|
||||
#else
|
||||
_WCRTLINK CHAR_TYPE *__F_NAME(strnset,_wcsnset)( CHAR_TYPE *str, int c, size_t len )
|
||||
#endif
|
||||
{
|
||||
CHAR_TYPE *p;
|
||||
|
||||
for( p = str; len; --len ) {
|
||||
if( *p == NULLCHAR ) break;
|
||||
*p++ = c;
|
||||
}
|
||||
return( str );
|
||||
}
|
75
programs/develop/open watcom/trunk/clib/string/strpbrk.c
Normal file
75
programs/develop/open watcom/trunk/clib/string/strpbrk.c
Normal file
@@ -0,0 +1,75 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 "widechar.h"
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "setbits.h"
|
||||
|
||||
/* The strpbrk function locates the first occurrence in the string pointed
|
||||
to by str of any character from the string pointed to by charset.
|
||||
*/
|
||||
|
||||
|
||||
_WCRTLINK CHAR_TYPE *__F_NAME(strpbrk,wcspbrk) ( const CHAR_TYPE *str, const CHAR_TYPE *charset )
|
||||
{
|
||||
#if defined(__WIDECHAR__)
|
||||
|
||||
const CHAR_TYPE *p1;
|
||||
const CHAR_TYPE *p2;
|
||||
CHAR_TYPE tc1;
|
||||
CHAR_TYPE tc2;
|
||||
size_t len;
|
||||
|
||||
len = 0;
|
||||
for( p1 = str; tc1 = *p1; p1++, len++ ) {
|
||||
for( p2 = charset; tc2 = *p2; p2++ ) {
|
||||
if( tc1 == tc2 ) break;
|
||||
}
|
||||
if( tc2 != NULLCHAR ) return( (CHAR_TYPE *)p1 );
|
||||
}
|
||||
return( NULL );
|
||||
|
||||
#else
|
||||
unsigned char tc;
|
||||
unsigned char vector[32];
|
||||
|
||||
__setbits( vector, charset );
|
||||
for( ; tc = *str; ++str ) {
|
||||
/* quit when we find any char in charset */
|
||||
if( ( vector[ tc >> 3 ] & _Bits[ tc & 0x07 ] ) != 0 )
|
||||
return( (char *)str );
|
||||
}
|
||||
return( NULL );
|
||||
#endif
|
||||
}
|
106
programs/develop/open watcom/trunk/clib/string/strrchr.c
Normal file
106
programs/develop/open watcom/trunk/clib/string/strrchr.c
Normal file
@@ -0,0 +1,106 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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: Implementation of strchr() and wcsrchr().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include "widechar.h"
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "riscstr.h"
|
||||
|
||||
#if defined(M_I86) && !defined(__WIDECHAR__)
|
||||
|
||||
extern char *_fast_strrchr( const char _WCFAR *, char );
|
||||
|
||||
#if defined(__SMALL_DATA__)
|
||||
#pragma aux _fast_strrchr = \
|
||||
0xb9 0xff 0xff /* mov cx,ffffh */ \
|
||||
0x30 0xc0 /* xor al,al */ \
|
||||
0xf2 0xae /* repne scasb */ \
|
||||
0xf7 0xd1 /* not cx */ \
|
||||
0x4f /* dec di */ \
|
||||
0x88 0xd0 /* mov al,dl */ \
|
||||
0xfd /* std */ \
|
||||
0xf2 0xae /* repne scasb */ \
|
||||
0xfc /* cld */ \
|
||||
0x75 0x03 /* jne L1 */ \
|
||||
0x89 0xf9 /* mov cx,di */ \
|
||||
0x41 /* inc cx */ \
|
||||
/* L1: */ \
|
||||
parm caller [es di] [dl] \
|
||||
value [cx] \
|
||||
modify exact [cx ax di];
|
||||
#else
|
||||
#pragma aux _fast_strrchr = \
|
||||
0xb9 0xff 0xff /* mov cx,ffffh */ \
|
||||
0x30 0xc0 /* xor al,al */ \
|
||||
0xf2 0xae /* repne scasb */ \
|
||||
0xf7 0xd1 /* not cx */ \
|
||||
0x4f /* dec di */ \
|
||||
0x88 0xd8 /* mov al,bl */ \
|
||||
0xfd /* std */ \
|
||||
0xf2 0xae /* repne scasb */ \
|
||||
0xfc /* cld */ \
|
||||
0x75 0x04 /* jne L1 */ \
|
||||
0x89 0xf9 /* mov cx,di */ \
|
||||
0x41 /* inc cx */ \
|
||||
0xa9 /* hide 2 bytes */ \
|
||||
0x8e 0xc1 /* L1: mov es,cx */ \
|
||||
parm caller [es di] [bl] \
|
||||
value [es cx] \
|
||||
modify exact [es cx ax di];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Locate the last occurrence of c in the string pointed to by s.
|
||||
The terminating null character is considered to be part of the string.
|
||||
If the character c is not found, NULL is returned.
|
||||
*/
|
||||
|
||||
|
||||
#if defined(__RISCSTR__) && defined(__WIDECHAR__)
|
||||
_WCRTLINK CHAR_TYPE *__simple_wcsrchr( const CHAR_TYPE *s, INTCHAR_TYPE c )
|
||||
#else
|
||||
_WCRTLINK CHAR_TYPE *__F_NAME(strrchr,wcsrchr)( const CHAR_TYPE *s, INTCHAR_TYPE c )
|
||||
#endif
|
||||
{
|
||||
#if defined(M_I86) && !defined(__WIDECHAR__)
|
||||
return( _fast_strrchr( s, c ) );
|
||||
#else
|
||||
CHAR_TYPE *p;
|
||||
CHAR_TYPE cc = c;
|
||||
|
||||
p = NULL; /* assume c will not be found */
|
||||
do {
|
||||
if( *s == cc ) p = (CHAR_TYPE *)s;
|
||||
} while( *s++ != NULLCHAR );
|
||||
return( p );
|
||||
#endif
|
||||
}
|
157
programs/develop/open watcom/trunk/clib/string/strrev.c
Normal file
157
programs/develop/open watcom/trunk/clib/string/strrev.c
Normal file
@@ -0,0 +1,157 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 "widechar.h"
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(__WIDECHAR__)
|
||||
extern size_t wcslen( const CHAR_TYPE * );
|
||||
#endif
|
||||
|
||||
#if defined(M_I86) && !defined(__WIDECHAR__)
|
||||
|
||||
/*
|
||||
explanation of algorithm:
|
||||
|
||||
(1) reverse as much of the string as possible as words
|
||||
|
||||
(2) after main loop: reverse residual inner string (0-3 bytes)
|
||||
|
||||
the string falls into one of these forms:
|
||||
|
||||
{ prefix_word }* { suffix_word }*
|
||||
{ prefix_word }* middle_byte { suffix_word }*
|
||||
{ prefix_word }* pre_middle_byte post_middle_byte { suffix_word }*
|
||||
{ prefix_word }* pre_middle_byte middle_byte post_middle_byte { suffix_word }*
|
||||
|
||||
we only have to swap two bytes when:
|
||||
|
||||
len & 2 != 0 is true (ie. the carry is set after second shr cx,1)
|
||||
|
||||
*****************************************************************************
|
||||
WARNING: the code in the L1: ... reverse loop cannot modify the carry flag
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
extern void fast_rev( char *, char _WCFAR * );
|
||||
|
||||
#if defined(__SMALL_DATA__)
|
||||
#pragma aux fast_rev = \
|
||||
0xb9 0xff 0xff /* mov cx,ffff */\
|
||||
0x30 0xc0 /* xor al,al */\
|
||||
0xf2 0xae /* repne scasb */\
|
||||
0xf7 0xd1 /* not cx */\
|
||||
0x49 /* dec cx */\
|
||||
0xfd /* std */\
|
||||
0x83 0xef 0x03 /* sub di,3 */\
|
||||
0xd1 0xe9 /* shr cx,1 */\
|
||||
0xd1 0xe9 /* shr cx,1 */\
|
||||
0xe3 0x0d /* jcxz L2 */\
|
||||
0x8b 0x05 /* L1:mov ax,[di] */\
|
||||
0x86 0xe0 /* xchg ah,al */\
|
||||
0x87 0x04 /* xchg ax,[si] */\
|
||||
0x86 0xe0 /* xchg ah,al */\
|
||||
0xab /* stosw */\
|
||||
0x46 /* inc si */\
|
||||
0x46 /* inc si */\
|
||||
0xe2 0xf3 /* loop L1 */\
|
||||
0x73 0x07 /* L2:jnc L3 */\
|
||||
0x47 /* inc di */\
|
||||
0x8a 0x05 /* mov al,[di] */\
|
||||
0x86 0x04 /* xchg al,[si] */\
|
||||
0x88 0x05 /* mov [di],al */\
|
||||
0xfc /* L3:cld */\
|
||||
parm caller [si] [es di] \
|
||||
value [ax] \
|
||||
modify [si cx ax di];
|
||||
#else
|
||||
#pragma aux fast_rev = \
|
||||
0x1e /* push ds */ \
|
||||
0x8e 0xda /* mov ds,dx */ \
|
||||
0xb9 0xff 0xff /* mov cx,ffff */\
|
||||
0x30 0xc0 /* xor al,al */\
|
||||
0xf2 0xae /* repne scasb */\
|
||||
0xf7 0xd1 /* not cx */\
|
||||
0x49 /* dec cx */\
|
||||
0xfd /* std */\
|
||||
0x83 0xef 0x03 /* sub di,3 */\
|
||||
0xd1 0xe9 /* shr cx,1 */\
|
||||
0xd1 0xe9 /* shr cx,1 */\
|
||||
0xe3 0x0d /* jcxz L2 */\
|
||||
0x8b 0x05 /* L1:mov ax,[di] */\
|
||||
0x86 0xe0 /* xchg ah,al */\
|
||||
0x87 0x04 /* xchg ax,[si] */\
|
||||
0x86 0xe0 /* xchg ah,al */\
|
||||
0xab /* stosw */\
|
||||
0x46 /* inc si */\
|
||||
0x46 /* inc si */\
|
||||
0xe2 0xf3 /* loop L1 */\
|
||||
0x73 0x07 /* L2:jnc L3 */\
|
||||
0x47 /* inc di */\
|
||||
0x8a 0x05 /* mov al,[di] */\
|
||||
0x86 0x04 /* xchg al,[si] */\
|
||||
0x88 0x05 /* mov [di],al */\
|
||||
0xfc /* L3:cld */\
|
||||
0x1f /* pop ds */ \
|
||||
parm caller [dx si] [es di] \
|
||||
value [ax] \
|
||||
modify [si cx ax di];
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
_WCRTLINK CHAR_TYPE *__F_NAME(strrev,_wcsrev) ( CHAR_TYPE *str ) { /* reverse characters in string */
|
||||
#if defined(M_I86) && !defined(__WIDECHAR__)
|
||||
fast_rev( str, (char _WCFAR *) str );
|
||||
return( str );
|
||||
#else
|
||||
CHAR_TYPE *p1;
|
||||
CHAR_TYPE *p2;
|
||||
CHAR_TYPE c1;
|
||||
CHAR_TYPE c2;
|
||||
|
||||
p1 = str;
|
||||
p2 = p1 + __F_NAME(strlen,wcslen)( p1 ) - 1;
|
||||
while( p1 < p2 ) {
|
||||
c1 = *p1;
|
||||
c2 = *p2;
|
||||
*p1 = c2;
|
||||
*p2 = c1;
|
||||
++p1;
|
||||
--p2;
|
||||
}
|
||||
return( str );
|
||||
#endif
|
||||
}
|
50
programs/develop/open watcom/trunk/clib/string/strset.c
Normal file
50
programs/develop/open watcom/trunk/clib/string/strset.c
Normal file
@@ -0,0 +1,50 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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: Implementation of strset() and _wcsset()
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include "widechar.h"
|
||||
#include <string.h>
|
||||
#include "riscstr.h"
|
||||
|
||||
|
||||
#if defined(__RISCSTR__) && defined(__WIDECHAR__)
|
||||
_WCRTLINK CHAR_TYPE *__simple__wcsset( CHAR_TYPE *s, INTCHAR_TYPE c )
|
||||
#else
|
||||
_WCRTLINK CHAR_TYPE *__F_NAME(strset,_wcsset)( CHAR_TYPE *s, INTCHAR_TYPE c )
|
||||
#endif
|
||||
{
|
||||
CHAR_TYPE *p;
|
||||
|
||||
for( p = s; *p; ++p ) {
|
||||
*p = c;
|
||||
}
|
||||
return( s );
|
||||
}
|
78
programs/develop/open watcom/trunk/clib/string/strspn.c
Normal file
78
programs/develop/open watcom/trunk/clib/string/strspn.c
Normal file
@@ -0,0 +1,78 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 "widechar.h"
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "setbits.h"
|
||||
|
||||
/* The strspn function computes the length of the initial segment of the
|
||||
string pointed to by str which consists entirely of characters from
|
||||
the string pointed to by charset.
|
||||
*/
|
||||
|
||||
|
||||
_WCRTLINK size_t __F_NAME(strspn,wcsspn) ( const CHAR_TYPE *str, const CHAR_TYPE *charset )
|
||||
{
|
||||
#if defined(__WIDECHAR__)
|
||||
|
||||
const CHAR_TYPE *p1;
|
||||
const CHAR_TYPE *p2;
|
||||
CHAR_TYPE tc1;
|
||||
CHAR_TYPE tc2;
|
||||
size_t len;
|
||||
|
||||
len = 0;
|
||||
for( p1 = str; tc1 = *p1; p1++, len++ ) {
|
||||
for( p2 = charset; tc2 = *p2; p2++ ) {
|
||||
if( tc1 == tc2 ) break;
|
||||
}
|
||||
if( tc2 == NULLCHAR ) break;
|
||||
}
|
||||
return( len );
|
||||
|
||||
|
||||
#else
|
||||
unsigned /*char*/ tc;
|
||||
unsigned char vector[32];
|
||||
size_t len;
|
||||
|
||||
__setbits( vector, charset );
|
||||
len = 0;
|
||||
for( ; tc = (unsigned char) *str; ++str, ++len ) {
|
||||
/* quit if we find any char not in charset */
|
||||
if( ( vector[ tc >> 3 ] & _Bits[ tc & 0x07 ] ) == 0 ) break;
|
||||
}
|
||||
return( len );
|
||||
#endif
|
||||
}
|
48
programs/develop/open watcom/trunk/clib/string/strspnp.c
Normal file
48
programs/develop/open watcom/trunk/clib/string/strspnp.c
Normal file
@@ -0,0 +1,48 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 "widechar.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
_WCRTLINK CHAR_TYPE *__F_NAME(strspnp,_wcsspnp)( const CHAR_TYPE *p1, const CHAR_TYPE *p2 )
|
||||
{
|
||||
size_t index;
|
||||
|
||||
index = __F_NAME(strspn,wcsspn)( p1, p2 );
|
||||
if( *(p1+index) != __F_NAME('\0',L'\0') ) {
|
||||
return( (CHAR_TYPE*)(p1+index) );
|
||||
} else {
|
||||
return( NULL );
|
||||
}
|
||||
}
|
113
programs/develop/open watcom/trunk/clib/string/strstr.c
Normal file
113
programs/develop/open watcom/trunk/clib/string/strstr.c
Normal file
@@ -0,0 +1,113 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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: Implementation of strstr() and wcsstr().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include "widechar.h"
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#if defined(_M_IX86)
|
||||
#include <i86.h>
|
||||
#endif
|
||||
|
||||
#if defined(M_I86) && !defined( __WIDECHAR__ )
|
||||
|
||||
extern int i86_memeq( const char *, const char _WCFAR *, int );
|
||||
|
||||
#define _ZFLAG (INTR_ZF<<8)
|
||||
|
||||
#if defined(__SMALL_DATA__)
|
||||
|
||||
#pragma aux i86_memeq = \
|
||||
0xf3 0xa6 /* rep cmpsb */\
|
||||
0x9f /* lahf */\
|
||||
parm caller [si] [es di] [cx]\
|
||||
value [ax] \
|
||||
modify exact [si di cx ax];
|
||||
|
||||
#else
|
||||
|
||||
#pragma aux i86_memeq = \
|
||||
0x1e /* push ds */ \
|
||||
0x8e 0xda /* mov ds,dx */ \
|
||||
0xf3 0xa6 /* rep cmpsb */\
|
||||
0x9f /* lahf */\
|
||||
0x1f /* pop ds */ \
|
||||
parm caller [dx si] [es di] [cx]\
|
||||
value [ax] \
|
||||
modify exact [si di cx ax];
|
||||
|
||||
#endif
|
||||
|
||||
#define memeq( p1, p2, len ) ( i86_memeq((p1),(p2),(len)) & _ZFLAG )
|
||||
|
||||
#else
|
||||
|
||||
#define memeq( p1, p2, len ) ( memcmp((p1),(p2),(len)*CHARSIZE) == 0 )
|
||||
|
||||
#endif
|
||||
|
||||
/* Locate the first occurrence of the string pointed to by s2 in the
|
||||
string pointed to by s1.
|
||||
The strstr function returns a pointer to the located string, or a
|
||||
null pointer if the string is not found.
|
||||
*/
|
||||
|
||||
|
||||
_WCRTLINK CHAR_TYPE *__F_NAME(strstr,wcsstr) ( const CHAR_TYPE *s1, const CHAR_TYPE *s2 )
|
||||
{
|
||||
CHAR_TYPE *end_of_s1;
|
||||
size_t s1len, s2len;
|
||||
|
||||
if( s2[0] == NULLCHAR ) {
|
||||
return( (CHAR_TYPE *)s1 );
|
||||
} else if( s2[1] == NULLCHAR ) {
|
||||
return( __F_NAME(strchr,wcschr)( s1, s2[0] ) );
|
||||
}
|
||||
#ifdef __WIDECHAR__
|
||||
end_of_s1 = (CHAR_TYPE*)s1 + wcslen( s1 );
|
||||
#else
|
||||
end_of_s1 = memchr( s1, NULLCHAR, ~0u );
|
||||
#endif
|
||||
s2len = __F_NAME(strlen,wcslen)( s2 );
|
||||
for(;;) {
|
||||
s1len = end_of_s1 - s1;
|
||||
if( s1len < s2len ) break;
|
||||
#ifdef __WIDECHAR__
|
||||
s1 = wcschr( s1, *s2 ); /* find start of possible match */
|
||||
#else
|
||||
s1 = memchr( s1, *s2, s1len ); /* find start of possible match */
|
||||
#endif
|
||||
if( s1 == NULL ) break;
|
||||
if( memeq( s1, s2, s2len ) ) return( (CHAR_TYPE *)s1 );
|
||||
++s1;
|
||||
}
|
||||
return( NULL );
|
||||
}
|
139
programs/develop/open watcom/trunk/clib/string/strtok.c
Normal file
139
programs/develop/open watcom/trunk/clib/string/strtok.c
Normal file
@@ -0,0 +1,139 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 "widechar.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "rtdata.h"
|
||||
#ifdef __WIDECHAR__
|
||||
#include "nextwtok.h"
|
||||
#else
|
||||
#include "nexttok.h"
|
||||
#endif
|
||||
#include "setbits.h"
|
||||
|
||||
|
||||
#ifdef __WIDECHAR__
|
||||
_WCRTLINK wchar_t *_ustrtok( wchar_t *str, const wchar_t *charset )
|
||||
{
|
||||
return( wcstok( str, charset, NULL ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __WIDECHAR__
|
||||
_WCRTLINK wchar_t *wcstok( wchar_t *str, const wchar_t *charset, wchar_t **ptr )
|
||||
#else
|
||||
_WCRTLINK char *strtok( char *str, const char *charset )
|
||||
#endif
|
||||
{
|
||||
#if defined(__WIDECHAR__)
|
||||
CHAR_TYPE *p1;
|
||||
const CHAR_TYPE *p2;
|
||||
CHAR_TYPE tc1;
|
||||
CHAR_TYPE tc2;
|
||||
#else
|
||||
unsigned /*char*/ tc;
|
||||
unsigned char vector[32];
|
||||
unsigned char *p1;
|
||||
#endif
|
||||
|
||||
#if defined(__WIDECHAR__)
|
||||
/* if necessary, continue from where we left off */
|
||||
if( str == NULL ) {
|
||||
if( ptr == NULL ) {
|
||||
str = _RWD_nextwtok;
|
||||
} else {
|
||||
str = *ptr; /* use previous value */
|
||||
}
|
||||
if( str == NULL ) return( NULL );
|
||||
}
|
||||
|
||||
/* skip characters until we reach one not in charset */
|
||||
for( ; tc1 = *str; str++ ) {
|
||||
for( p2 = charset; tc2 = *p2; p2++ ) {
|
||||
if( tc1 == tc2 ) break;
|
||||
}
|
||||
if( tc2 == NULLCHAR ) break;
|
||||
}
|
||||
if( tc1 == NULLCHAR ) return( NULL );
|
||||
/* skip characters until we reach one in charset */
|
||||
for( p1 = str; tc1 = *p1; p1++ ) {
|
||||
for( p2 = charset; tc2 = *p2; p2++ ) {
|
||||
if( tc1 == tc2 ) break;
|
||||
}
|
||||
if( tc2 != NULLCHAR ){
|
||||
*p1 = NULLCHAR; /* terminate the token */
|
||||
p1++; /* start of next token */
|
||||
if( ptr == NULL ) {
|
||||
_RWD_nextwtok = p1;
|
||||
} else {
|
||||
*ptr = p1;
|
||||
}
|
||||
return( str );
|
||||
}
|
||||
}
|
||||
if( ptr == NULL ) {
|
||||
_RWD_nextwtok = NULL;
|
||||
} else {
|
||||
*ptr = NULL;
|
||||
}
|
||||
#else
|
||||
/* if necessary, continue from where we left off */
|
||||
_INITNEXTTOK
|
||||
if( str == NULL ) {
|
||||
str = (CHAR_TYPE*)_RWD_nexttok; /* use previous value */
|
||||
if( str == NULL ) return( NULL );
|
||||
}
|
||||
|
||||
__setbits( vector, charset );
|
||||
for( ; tc = (unsigned char) *str; ++str ) {
|
||||
/* quit if we find any char not in charset */
|
||||
if( ( vector[ tc >> 3 ] & _Bits[ tc & 0x07 ] ) == 0 ) break;
|
||||
}
|
||||
if( tc == '\0' ) return( NULL );
|
||||
p1 = str;
|
||||
for( ; tc = *p1; ++p1 ) {
|
||||
/* quit when we find any char in charset */
|
||||
if( ( vector[ tc >> 3 ] & _Bits[ tc & 0x07 ] ) != 0 ) {
|
||||
*p1 = '\0'; /* terminate the token */
|
||||
p1++; /* start of next token */
|
||||
_RWD_nexttok = p1;
|
||||
return( str );
|
||||
}
|
||||
}
|
||||
_RWD_nexttok = NULL;
|
||||
#endif
|
||||
|
||||
return( str );
|
||||
}
|
137
programs/develop/open watcom/trunk/clib/string/strtok_s.c
Normal file
137
programs/develop/open watcom/trunk/clib/string/strtok_s.c
Normal file
@@ -0,0 +1,137 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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: Implementation of strtok_s() - bounds-checking strtok().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include "saferlib.h"
|
||||
#include "widechar.h"
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include "setbits.h"
|
||||
|
||||
|
||||
_WCRTLINK CHAR_TYPE *__F_NAME(strtok_s,wcstok_s)( CHAR_TYPE * __restrict s1,
|
||||
rsize_t * __restrict s1max, const CHAR_TYPE * __restrict s2,
|
||||
CHAR_TYPE ** __restrict ptr )
|
||||
/****************************************************************************/
|
||||
{
|
||||
#ifdef __WIDECHAR__
|
||||
const CHAR_TYPE *p2;
|
||||
CHAR_TYPE tc2;
|
||||
#else
|
||||
char vector[32];
|
||||
#endif
|
||||
char *msg = NULL;
|
||||
CHAR_TYPE *p1 = s1;
|
||||
CHAR_TYPE *str;
|
||||
rsize_t m;
|
||||
CHAR_TYPE tc1;
|
||||
|
||||
// Verify runtime-constraints
|
||||
// s1max not NULL
|
||||
// s2 not NULL
|
||||
// ptr not NULL
|
||||
// *s1max <= RSIZE_MAX
|
||||
// if s1 == NULL then *ptr != NULL
|
||||
if( __check_constraint_nullptr_msg( msg, s1max ) &&
|
||||
__check_constraint_nullptr_msg( msg, s2 ) &&
|
||||
__check_constraint_nullptr_msg( msg, ptr ) &&
|
||||
__check_constraint_maxsize_msg( msg, *s1max ) &&
|
||||
((s1 != NULL) || __check_constraint_nullptr_msg( msg, *ptr )) ) {
|
||||
|
||||
/* if necessary, continue from where we left off */
|
||||
if( s1 == NULL ) {
|
||||
p1 = *ptr; /* use previous value */
|
||||
}
|
||||
#ifndef __WIDECHAR__
|
||||
__setbits( vector, s2 );
|
||||
#endif
|
||||
m = *s1max;
|
||||
for( ; tc1 = *p1; ++p1 ) {
|
||||
if( ! ((m == 0) ? ( msg = "no start of token found" ), 0 : 1 ) ) {
|
||||
break; /* limit reached, quit */
|
||||
}
|
||||
|
||||
#ifdef __WIDECHAR__
|
||||
for( p2 = s2; tc2 = *p2; p2++ ) {
|
||||
if( tc1 == tc2 ) break;
|
||||
}
|
||||
if( tc2 == NULLCHAR ) break;
|
||||
#else
|
||||
/* quit if we find any char not in charset */
|
||||
if( ( vector[ tc1 >> 3 ] & _Bits[ tc1 & 0x07 ] ) == 0 ) break;
|
||||
#endif
|
||||
--m;
|
||||
}
|
||||
|
||||
if( msg == NULL ) { /* no rt-constraint violated */
|
||||
if( tc1 == NULLCHAR ) return( NULL ); /* no (more) tokens */
|
||||
} else {
|
||||
/* Now call the handler */
|
||||
__rtct_fail( __func__, msg, NULL );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
str = p1++; /* start of token */
|
||||
|
||||
for( ; tc1 = *p1; p1++ ) {
|
||||
if( ! ((m == 0) ? ( msg = "no closing token delimiter found" ), 0 : 1 ) ) {
|
||||
break; /* limit reached, quit */
|
||||
}
|
||||
|
||||
--m;
|
||||
|
||||
/* skip characters until we reach one in delimiterset */
|
||||
#ifdef __WIDECHAR__
|
||||
for( p2 = s2; tc2 = *p2; p2++ ) {
|
||||
if( tc1 == tc2 ) break;
|
||||
}
|
||||
if( tc2 != NULLCHAR ) {
|
||||
#else
|
||||
if( ( vector[ tc1 >> 3 ] & _Bits[ tc1 & 0x07 ] ) != 0 ) {
|
||||
#endif
|
||||
*p1 = NULLCHAR; /* terminate the token */
|
||||
p1++; /* start of next token */
|
||||
*ptr = p1;
|
||||
*s1max = m;
|
||||
return( str );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( msg != NULL ) { /* rt-constraint violated */
|
||||
/* Now call the handler */
|
||||
__rtct_fail( __func__, msg, NULL );
|
||||
return( NULL );
|
||||
} else {
|
||||
*ptr = NULL; /* last token reached */
|
||||
*s1max = 0;
|
||||
}
|
||||
return( str );
|
||||
}
|
59
programs/develop/open watcom/trunk/clib/string/strupr.c
Normal file
59
programs/develop/open watcom/trunk/clib/string/strupr.c
Normal file
@@ -0,0 +1,59 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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: Implementation of strupr().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "variety.h"
|
||||
#include "widechar.h"
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include "riscstr.h"
|
||||
|
||||
|
||||
#if defined(__RISCSTR__) && defined(__WIDECHAR__)
|
||||
_WCRTLINK CHAR_TYPE *__simple__wcsupr( CHAR_TYPE *str ) {
|
||||
#else
|
||||
_WCRTLINK CHAR_TYPE *__F_NAME(strupr,_wcsupr)( CHAR_TYPE *str ) {
|
||||
#endif
|
||||
CHAR_TYPE *p;
|
||||
UCHAR_TYPE c;
|
||||
|
||||
p = str;
|
||||
while( (c = *p) ) {
|
||||
if( IS_ASCII( c ) ) {
|
||||
c -= 'a';
|
||||
if( c <= 'z' - 'a' ) {
|
||||
c += 'A';
|
||||
*p = c;
|
||||
}
|
||||
}
|
||||
++p;
|
||||
}
|
||||
return( str );
|
||||
}
|
55
programs/develop/open watcom/trunk/clib/string/strxfrm.c
Normal file
55
programs/develop/open watcom/trunk/clib/string/strxfrm.c
Normal file
@@ -0,0 +1,55 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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 "widechar.h"
|
||||
#include <string.h>
|
||||
|
||||
/* Transform the string so that two transformed strings can be properly
|
||||
compared in the current locale.
|
||||
We only support the "C" locale, so just copy the string.
|
||||
*/
|
||||
|
||||
_WCRTLINK size_t __F_NAME(strxfrm,wcsxfrm)( CHAR_TYPE *dst, const CHAR_TYPE *src, size_t n )
|
||||
{
|
||||
size_t len;
|
||||
|
||||
len = 0;
|
||||
for(;;) {
|
||||
if( len < n ) *dst = *src;
|
||||
if( *src == __F_NAME('\0',L'\0') ) break;
|
||||
++src;
|
||||
++dst;
|
||||
++len;
|
||||
}
|
||||
return( len );
|
||||
}
|
Reference in New Issue
Block a user