summaryrefslogtreecommitdiff
path: root/include/string.h
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2003-08-01 20:08:59 +0000
committerManuel Novoa III <mjn3@codepoet.org>2003-08-01 20:08:59 +0000
commit1217289737588e65b088b3535428b27c7287d699 (patch)
tree6a292ac767d219702e26a6a2111737f84a96900c /include/string.h
parent32b76c5ec3c257b7287913d0d1a96e0cbb2e9c6a (diff)
Add a new *scanf implementation, includeing the *wscanf functions.
Should be standards compliant and with several optional features, including support for hexadecimal float notation, locale awareness, glibc-like locale-specific digit grouping with the `'' flag, and positional arg support. I tested it pretty well (finding several bugs in glibc's scanf in the process), but it is brand new so be aware. The *wprintf functions now support floating point output. Also, a couple of bugs were squashed. Finally, %a/%A conversions are now implemented. Implement the glibc xlocale interface for thread-specific locale support. Also add the various *_l(args, locale_t loc_arg) funcs. NOTE!!! setlocale() is NOT threadsafe! NOTE!!! The strto{floating point} conversion functions are now locale aware. The also now support hexadecimal floating point notation. Add the wcsto{floating point} conversion functions. Fix a bug in mktime() related to dst. Note that unlike glibc's mktime, uClibc's version always normalizes the struct tm before attempting to determine the correct dst setting if tm_isdst == -1 on entry. Add a stub version of the libintl functions. (untested) Fixed a known memory leak in setlocale() related to the collation data. Add lots of new config options (which Erik agreed to sort out :-), including finally exposing some of the stripped down stdio configs. Be careful with those though, as they haven't been tested in a long time. (temporary) GOTCHAs... The ctype functions are currently incorrect for 8-bit locales. They will be fixed shortly. The ctype functions are now table-based, resulting in larger staticly linked binaries. I'll be adding an option to use the old approach in the stub locale configuration.
Diffstat (limited to 'include/string.h')
-rw-r--r--include/string.h75
1 files changed, 48 insertions, 27 deletions
diff --git a/include/string.h b/include/string.h
index 8aa40f262..f3ef812bf 100644
--- a/include/string.h
+++ b/include/string.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,92,93,95,96,97,98,99,2000,2001 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1993, 1995-2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -33,6 +33,7 @@ __BEGIN_DECLS
#include <stddef.h>
+__BEGIN_NAMESPACE_STD
/* Copy N bytes of SRC to DEST. */
extern void *memcpy (void *__restrict __dest,
__const void *__restrict __src, size_t __n) __THROW;
@@ -40,6 +41,7 @@ extern void *memcpy (void *__restrict __dest,
correct behavior for overlapping strings. */
extern void *memmove (void *__dest, __const void *__src, size_t __n)
__THROW;
+__END_NAMESPACE_STD
/* Copy no more than N bytes of SRC to DEST, stopping when C is found.
Return the position in DEST one byte past where C was copied,
@@ -51,6 +53,7 @@ extern void *memccpy (void *__restrict __dest, __const void *__restrict __src,
#endif /* SVID. */
+__BEGIN_NAMESPACE_STD
/* Set N bytes of S to C. */
extern void *memset (void *__s, int __c, size_t __n) __THROW;
@@ -61,18 +64,20 @@ extern int memcmp (__const void *__s1, __const void *__s2, size_t __n)
/* Search N bytes of S for C. */
extern void *memchr (__const void *__s, int __c, size_t __n)
__THROW __attribute_pure__;
+__END_NAMESPACE_STD
#ifdef __USE_GNU
/* Search in S for C. This is similar to `memchr' but there is no
length limit. */
extern void *rawmemchr (__const void *__s, int __c) __THROW __attribute_pure__;
-#endif
/* Search N bytes of S for the final occurrence of C. */
extern void *memrchr (__const void *__s, int __c, size_t __n)
__THROW __attribute_pure__;
+#endif
+__BEGIN_NAMESPACE_STD
/* Copy SRC to DEST. */
extern char *strcpy (char *__restrict __dest, __const char *__restrict __src)
__THROW;
@@ -100,20 +105,22 @@ extern int strcoll (__const char *__s1, __const char *__s2)
/* Put a transformation of SRC into no more than N bytes of DEST. */
extern size_t strxfrm (char *__restrict __dest,
__const char *__restrict __src, size_t __n) __THROW;
+__END_NAMESPACE_STD
-#if 0
-/*#ifdef __USE_GNU*/
+#ifdef __UCLIBC_HAS_XLOCALE__
+#ifdef __USE_GNU
/* The following functions are equivalent to the both above but they
take the locale they use for the collation as an extra argument.
This is not standardsized but something like will come. */
# include <xlocale.h>
/* Compare the collated forms of S1 and S2 using rules from L. */
-extern int __strcoll_l (__const char *__s1, __const char *__s2, __locale_t __l)
+extern int strcoll_l (__const char *__s1, __const char *__s2, __locale_t __l)
__THROW __attribute_pure__;
/* Put a transformation of SRC into no more than N bytes of DEST. */
-extern size_t __strxfrm_l (char *__dest, __const char *__src, size_t __n,
- __locale_t __l) __THROW;
+extern size_t strxfrm_l (char *__dest, __const char *__src, size_t __n,
+ __locale_t __l) __THROW;
+#endif
#endif
#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
@@ -152,17 +159,20 @@ extern char *strndup (__const char *__string, size_t __n)
}))
#endif
+__BEGIN_NAMESPACE_STD
/* Find the first occurrence of C in S. */
extern char *strchr (__const char *__s, int __c) __THROW __attribute_pure__;
/* Find the last occurrence of C in S. */
extern char *strrchr (__const char *__s, int __c) __THROW __attribute_pure__;
+__END_NAMESPACE_STD
#ifdef __USE_GNU
-/* This funciton is similar to `strchr'. But it returns a pointer to
+/* This function is similar to `strchr'. But it returns a pointer to
the closing NUL byte in case C is not found in S. */
extern char *strchrnul (__const char *__s, int __c) __THROW __attribute_pure__;
#endif
+__BEGIN_NAMESPACE_STD
/* Return the length of the initial segment of S which
consists entirely of characters not in REJECT. */
extern size_t strcspn (__const char *__s, __const char *__reject)
@@ -178,15 +188,11 @@ extern char *strpbrk (__const char *__s, __const char *__accept)
extern char *strstr (__const char *__haystack, __const char *__needle)
__THROW __attribute_pure__;
-#ifdef __USE_GNU
-/* Similar to `strstr' but this function ignores the case of both strings. */
-extern char *strcasestr (__const char *__haystack, __const char *__needle)
- __THROW __attribute_pure__;
-#endif
/* Divide S into tokens separated by characters in DELIM. */
extern char *strtok (char *__restrict __s, __const char *__restrict __delim)
__THROW;
+__END_NAMESPACE_STD
/* Divide S into tokens separated by characters in DELIM. Information
passed between calls are stored in SAVE_PTR. */
@@ -199,6 +205,12 @@ extern char *strtok_r (char *__restrict __s, __const char *__restrict __delim,
#endif
#ifdef __USE_GNU
+/* Similar to `strstr' but this function ignores the case of both strings. */
+extern char *strcasestr (__const char *__haystack, __const char *__needle)
+ __THROW __attribute_pure__;
+#endif
+
+#ifdef __USE_GNU
/* Find the first occurrence of NEEDLE in HAYSTACK.
NEEDLE is NEEDLELEN bytes long;
HAYSTACK is HAYSTACKLEN bytes long. */
@@ -215,8 +227,10 @@ extern void *mempcpy (void *__restrict __dest,
#endif
+__BEGIN_NAMESPACE_STD
/* Return the length of S. */
extern size_t strlen (__const char *__s) __THROW __attribute_pure__;
+__END_NAMESPACE_STD
#ifdef __USE_GNU
/* Find the length of STRING, but scan at most MAXLEN characters.
@@ -226,12 +240,17 @@ extern size_t strnlen (__const char *__string, size_t __maxlen)
#endif
+__BEGIN_NAMESPACE_STD
/* Return a string describing the meaning of the `errno' code in ERRNUM. */
extern char *strerror (int __errnum) __THROW;
-
-/* Reentrant versions of `strerror'. If a temporary buffer is required,
- at most BUFLEN bytes of BUF will be used. These symbols are _NOT_ intended
- to be applications, and can change at any time. */
+__END_NAMESPACE_STD
+#if defined __USE_XOPEN2K || defined __USE_MISC
+/* Reentrant version of `strerror'. If a temporary buffer is required, at
+ most BUFLEN bytes of BUF will be used. */
+/* extern char *strerror_r (int __errnum, char *__buf, size_t __buflen) __THROW; */
+
+/* uClibc Note: glibc's strerror_r is different from that specified in SUSv3.
+ * So we try to compensate based on feature macros. */
extern char *_glibc_strerror_r (int __errnum, char *__buf, size_t __buflen) __THROW;
extern int _susv3_strerror_r (int __errnum, char *__buf, size_t buflen) __THROW;
@@ -243,7 +262,7 @@ extern int __REDIRECT (strerror_r,
# else
# define strerror_r _susv3_strerror_r
# endif
-#elif defined(__USE_MISC)
+#else /* defined(__USE_XOPEN2K) && !defined(__USE_GNU) */
# ifdef __REDIRECT
extern char *__REDIRECT (strerror_r,
(int __errnum, char *__buf, size_t buflen) __THROW,
@@ -251,13 +270,14 @@ extern char *__REDIRECT (strerror_r,
# else
# define strerror_r _glibc_strerror_r
# endif
+#endif /* defined(__USE_XOPEN2K) && !defined(__USE_GNU) */
#endif
/* We define this function always since `bzero' is sometimes needed when
the namespace rules does not allow this. */
extern void __bzero (void *__s, size_t __n) __THROW;
-#if defined __USE_BSD
+#ifdef __USE_BSD
/* Copy N bytes of SRC to DEST (like memmove, but args reversed). */
extern void bcopy (__const void *__src, void *__dest, size_t __n) __THROW;
@@ -280,8 +300,7 @@ extern int ffs (int __i) __THROW __attribute__ ((__const__));
/* The following two functions are non-standard but necessary for non-32 bit
platforms. */
-# if 0
-/*# ifdef __USE_GNU*/
+# ifdef __USE_GNU
extern int ffsl (long int __l) __THROW __attribute__ ((__const__));
# ifdef __GNUC__
__extension__ extern int ffsll (long long int __ll)
@@ -298,17 +317,18 @@ extern int strncasecmp (__const char *__s1, __const char *__s2, size_t __n)
__THROW __attribute_pure__;
#endif /* Use BSD. */
-#if 0
-/*#ifdef __USE_GNU*/
+#ifdef __UCLIBC_HAS_XLOCALE__
+#ifdef __USE_GNU
/* Again versions of a few functions which use the given locale instead
of the global one. */
-extern int __strcasecmp_l (__const char *__s1, __const char *__s2,
- __locale_t __loc) __THROW __attribute_pure__;
+extern int strcasecmp_l (__const char *__s1, __const char *__s2,
+ __locale_t __loc) __THROW __attribute_pure__;
-extern int __strncasecmp_l (__const char *__s1, __const char *__s2,
- size_t __n, __locale_t __loc)
+extern int strncasecmp_l (__const char *__s1, __const char *__s2,
+ size_t __n, __locale_t __loc)
__THROW __attribute_pure__;
#endif
+#endif
#ifdef __USE_BSD
/* Return the next DELIM-delimited token from *STRINGP,
@@ -357,6 +377,7 @@ extern char *basename (__const char *__filename) __THROW;
# endif
#endif
+
#if 0
#if defined __GNUC__ && __GNUC__ >= 2
# if defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ \