From f89c67d20b3014038d023f8b686a3df2c797bd9f Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Thu, 8 Mar 2001 16:49:37 +0000 Subject: Add in wordexp support (mostly stubbed out for now) since the busybox shell, lash, is about to start using wordexp. -Erik --- include/string.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'include') 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 -- cgit v1.2.3