]>
git.saurik.com Git - apple/boot.git/blob - gen/libsa/string1.c
0b4bb39130da758d23aac9978f9aaea59424665a
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 /* string operations */
28 /*#if DONT_USE_GCC_BUILT_IN_STRLEN*/
30 #define tolower(c) ((int)((c) & ~0x20))
31 #define toupper(c) ((int)((c) | 0x20))
33 int strlen(const char *s
)
45 strcmp(const char *s1
, const char *s2
)
47 while (*s1
&& (*s1
== *s2
)) {
54 int strncmp(const char *s1
, const char *s2
, size_t len
)
57 while (--n
>= 0 && *s1
== *s2
++)
60 return(n
<0 ? 0 : *s1
- *--s2
);
64 strcpy(char *s1
, const char *s2
)
66 register char *ret
= s1
;
73 strncpy(char *s1
, const char *s2
, size_t n
)
75 register char *ret
= s1
;
76 while (n
&& (*s1
++ = *s2
++))
85 register int c
= *str
;
87 if (c
<= '7' && c
>= '0')
89 else if (c
<= 'h' && c
>= 'a')
99 while (*str
== ' ' || *str
== '\t')
101 while (*str
>= '0' && *str
<= '9') {
109 char *strncat(char *s1
, const char *s2
, size_t n
)
111 register char *ret
= s1
;
120 char *strcat(char *s1
, const char *s2
)
122 return(strncat(s1
, s2
, strlen(s2
)));
126 int strncasecmp(const char *s1
, const char *s2
, size_t len
)
128 register int n
= len
;
129 while (--n
>= 0 && tolower(*s1
) == tolower(*s2
++))
132 return(n
<0 ? 0 : tolower(*s1
) - tolower(*--s2
));