summaryrefslogtreecommitdiff
path: root/include/string.h
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-03-08 16:49:37 +0000
committerEric Andersen <andersen@codepoet.org>2001-03-08 16:49:37 +0000
commitf89c67d20b3014038d023f8b686a3df2c797bd9f (patch)
treeb0168b139177edee99b0edca650ead82198b8a26 /include/string.h
parent8bceedc67ca3ec732f7d6524cb023352d4aaf0c7 (diff)
Add in wordexp support (mostly stubbed out for now) since the busybox
shell, lash, is about to start using wordexp. -Erik
Diffstat (limited to 'include/string.h')
-rw-r--r--include/string.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/include/string.h b/include/string.h
index 58614b291..6dff15b2d 100644
--- a/include/string.h
+++ b/include/string.h
@@ -118,4 +118,29 @@ int bcmp(const void *s1, const void *s2, size_t n);
/* Linux silly hour */
char *strfry __P ((char *));
+/* Find the length of STRING, but scan at most MAXLEN characters.
+ If no '\0' terminator is found in that many characters, return MAXLEN. */
+extern size_t strnlen __P ((__const char *__string, size_t __maxlen));
+
+/* Duplicate S, returning an identical alloca'd string. */
+# define strdupa(s) \
+ (__extension__ \
+ ({ \
+ __const char *__old = (s); \
+ size_t __len = strlen (__old) + 1; \
+ char *__new = __builtin_alloca (__len); \
+ (char *) memcpy (__new, __old, __len); \
+ }))
+
+/* Return an alloca'd copy of at most N bytes of string. */
+# define strndupa(s, n) \
+ (__extension__ \
+ ({ \
+ __const char *__old = (s); \
+ size_t __len = strnlen (__old, (n)); \
+ char *__new = __builtin_alloca (__len + 1); \
+ __new[__len] = '\0'; \
+ (char *) memcpy (__new, __old, __len); \
+ }))
+
#endif