]>
git.saurik.com Git - apple/boot.git/blob - gen/libsa/string1.c
6291112af727677909188db17215702e051c8cf9
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.1 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
24 /* string operations */
27 /*#if DONT_USE_GCC_BUILT_IN_STRLEN*/
29 #define tolower(c) ((int)((c) & ~0x20))
30 #define toupper(c) ((int)((c) | 0x20))
32 int strlen(const char *s
)
44 strcmp(const char *s1
, const char *s2
)
46 while (*s1
&& (*s1
== *s2
)) {
53 int strncmp(const char *s1
, const char *s2
, size_t len
)
56 while (--n
>= 0 && *s1
== *s2
++)
59 return(n
<0 ? 0 : *s1
- *--s2
);
63 strcpy(char *s1
, const char *s2
)
65 register char *ret
= s1
;
72 strncpy(char *s1
, const char *s2
, size_t n
)
74 register char *ret
= s1
;
75 while (n
&& (*s1
++ = *s2
++))
84 register int c
= *str
;
86 if (c
<= '7' && c
>= '0')
88 else if (c
<= 'h' && c
>= 'a')
98 while (*str
== ' ' || *str
== '\t')
100 while (*str
>= '0' && *str
<= '9') {
108 char *strncat(char *s1
, const char *s2
, size_t n
)
110 register char *ret
= s1
;
119 char *strcat(char *s1
, const char *s2
)
121 return(strncat(s1
, s2
, strlen(s2
)));
125 int strncasecmp(const char *s1
, const char *s2
, size_t len
)
127 register int n
= len
;
128 while (--n
>= 0 && tolower(*s1
) == tolower(*s2
++))
131 return(n
<0 ? 0 : tolower(*s1
) - tolower(*--s2
));