]>
git.saurik.com Git - apple/bootx.git/blob - bootx.tproj/libclite.subproj/string.c
2 * Copyright (c) 2000 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@
26 * string.c - string operations.
28 * Copyright (c) 1998-2000 Apple Computer, Inc.
35 /*#if DONT_USE_GCC_BUILT_IN_STRLEN*/
37 #define tolower(c) ((int)((c) & ~0x20))
38 #define toupper(c) ((int)((c) | 0x20))
40 int strlen(const char *s
)
52 strcmp(const char *s1
, const char *s2
)
54 while (*s1
&& (*s1
== *s2
)) {
61 int strncmp(const char *s1
, const char *s2
, size_t len
)
64 while (--n
>= 0 && *s1
== *s2
++)
67 return(n
<0 ? 0 : *s1
- *--s2
);
71 strcpy(char *s1
, const char *s2
)
73 register char *ret
= s1
;
80 strncpy(char *s1
, const char *s2
, size_t n
)
82 register char *ret
= s1
;
83 while (n
&& (*s1
++ = *s2
++))
92 register int c
= *str
;
94 if (c
<= '7' && c
>= '0')
96 else if (c
<= 'h' && c
>= 'a')
103 atoi(const char *str
)
105 register int sum
= 0;
106 while (*str
== ' ' || *str
== '\t')
108 while (*str
>= '0' && *str
<= '9') {
116 char *strncat(char *s1
, const char *s2
, size_t n
)
118 register char *ret
= s1
;
127 char *strcat(char *s1
, const char *s2
)
129 return(strncat(s1
, s2
, strlen(s2
)));
133 int strncasecmp(const char *s1
, const char *s2
, size_t len
)
135 register int n
= len
;
136 while (--n
>= 0 && tolower(*s1
) == tolower(*s2
++))
139 return(n
<0 ? 0 : tolower(*s1
) - tolower(*--s2
));