1 /* @(#) pf_clib.c 96/12/18 1.12 */
2 /***************************************************************
3 ** Duplicate functions from stdlib for PForth based on 'C'
5 ** This code duplicates some of the code in the 'C' lib
6 ** because it reduces the dependency on foreign libraries
7 ** for monitor mode where no OS is available.
10 ** Copyright 1994 3DO, Phil Burk, Larry Polansky, David Rosenboom
12 ** The pForth software code is dedicated to the public domain,
13 ** and any third party may reproduce, distribute and modify
14 ** the pForth software code or any derivative works thereof
15 ** without any compensation or license. The pForth software
16 ** code is provided on an "as is" basis without any warranty
17 ** of any kind, including, without limitation, the implied
18 ** warranties of merchantability and fitness for a particular
19 ** purpose and their equivalents under the laws of any jurisdiction.
21 ****************************************************************
22 ** 961124 PLB Advance pointers in pfCopyMemory() and pfSetMemory()
23 ***************************************************************/
28 /* Count chars until NUL. Replace strlen() */
29 #define NUL ((char) 0)
30 cell_t pfCStringLength( const char *s )
33 while( *s++ != NUL ) len++;
37 /* void *memset (void *s, cell_t c, size_t n); */
38 void *pfSetMemory( void *s, cell_t c, cell_t n )
40 uint8_t *p = s, byt = (uint8_t) c;
41 while( (n--) > 0) *p++ = byt;
45 /* void *memccpy (void *s1, const void *s2, cell_t c, size_t n); */
46 void *pfCopyMemory( void *s1, const void *s2, cell_t n)
49 const uint8_t *p2 = s2;
50 while( (n--) > 0) *p1++ = *p2++;
54 #endif /* PF_NO_CLIB */
56 char pfCharToUpper( char c )
58 return (char) ( ((c>='a') && (c<='z')) ? (c - ('a' - 'A')) : c );
61 char pfCharToLower( char c )
63 return (char) ( ((c>='A') && (c<='Z')) ? (c + ('a' - 'A')) : c );