3 * Herbert Xu <herbert@gondor.apana.org.au>. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #define isalnum _isalnum
31 #define iscntrl _iscntrl
32 #define islower _islower
33 #define isspace _isspace
34 #define isalpha _isalpha
35 #define isdigit _isdigit
36 #define isprint _isprint
37 #define isupper _isupper
38 #define isblank _isblank
39 #define isgraph _isgraph
40 #define ispunct _ispunct
41 #define isxdigit _isxdigit
65 void *mempcpy(void *dest
, const void *src
, size_t n
)
67 return memcpy(dest
, src
, n
) + n
;
72 char *stpcpy(char *dest
, const char *src
)
74 size_t len
= strlen(src
);
76 return mempcpy(dest
, src
, len
);
80 #ifndef HAVE_STRCHRNUL
81 char *strchrnul(const char *s
, int c
)
83 char *p
= strchr(s
, c
);
85 p
= (char *)s
+ strlen(s
);
90 #ifndef HAVE_STRSIGNAL
91 char *strsignal(int sig
)
95 if ((unsigned)sig
< NSIG
&& sys_siglist
[sig
])
96 return (char *)sys_siglist
[sig
];
97 fmtstr(buf
, sizeof(buf
), "Signal %d", sig
);
103 void *bsearch(const void *key
, const void *base
, size_t nmemb
,
104 size_t size
, int (*cmp
)(const void *, const void *))
107 size_t mididx
= nmemb
/ 2;
108 const void *midobj
= base
+ mididx
* size
;
109 int diff
= cmp(key
, midobj
);
112 return (void *)midobj
;
115 base
= midobj
+ size
;
126 long sysconf(int name
)
128 sh_error("no sysconf for: %d", name
);
173 #if HAVE_DECL_ISBLANK
190 int isxdigit(int c
) {
195 #if !HAVE_DECL_ISBLANK
197 return c
== ' ' || c
== '\t';