Hi all,

PSARC case for strsep() [1] still lacks a man page diff. Since strsep() 
shares some deficiencies with strtok() and we have functions that do not 
have any of those problems in libc (str[c]spn()) strsep() should be used 
merely as a compatibility tool (see CR 6487100). I tried to get that 
message into the man page.

Also, for the above reasons, the man page diff lacks strsep() example.

Could someone review the changes ?

The majority of the man page additions come from NetBSD's STRSEP(3) (I 
hope it's not a problem).


v.

[1] http://www.opensolaris.org/os/community/arc/caselog/2008/305


--- string_3C.orig      Sun Jul 13 14:06:41 2008
+++ string_3C.new       Sun Jul 13 14:26:14 2008
@@ -8,8 +8,8 @@
  NAME
       string, strcasecmp, strncasecmp, strcat,  strncat,        strlcat,
       strchr,  strrchr, strcmp, strncmp,       strcpy, strncpy, strlcpy,
-     strcspn, strspn, strdup, strlen, strnlen, strpbrk,  strstr,
-     strtok, strtok_r -        string operations
+     strcspn, strspn, strdup, strlen, strnlen, strpbrk,  strsep,
+     strstr, strtok, strtok_r -        string operations

  SYNOPSIS
       #include <strings.h>
@@ -83,6 +83,9 @@
       char *strpbrk(const char *s1, const char *s2);


+     char *strsep(char **stringp, const char *delim);
+
+
       char *strstr(const       char *s1, const char *s2);


@@ -279,6 +282,20 @@
       occurrence        in string s1 of any character from string s2, or
       a null pointer if no character from s2 exists in s1.

+  strsep()
+    The strsep() function locates, in the null-terminated string referenced
+    by *stringp, the first occurrence of any character in the string delim
+    (or the terminating `\0' character) and replaces it with a `\0'.  The
+    location of the next character after the delimiter character (or 
NULL, if
+    the end of the string was reached) is stored in *stringp.  The original
+    value of *stringp is returned.
+
+    An ``empty'' field, i.e., one caused by two adjacent delimiter charac-
+    ters, can be detected by comparing the location referenced by the 
pointer
+    returned by strsep() to `\0'.
+
+    If *stringp is initially NULL, strsep() returns NULL.
+
    strstr()
       The strstr() function locates the first  occurrence  of  the
       string  s2        (excluding  the  terminating  null character) in
@@ -489,7 +506,16 @@
         token = "90"
         token = "45"

+WARNINGS
+     The strsep() function is intended as a replacement for the 
strtok() func-
+     tion.  While the strtok() function should be preferred for portability
+     reasons (it conforms to ANSI X3.159-1989 (``ANSI C89'')) it is 
unable to
+     handle empty fields, i.e., detect fields delimited by two adjacent 
delim-
+     iter characters, or to be used for more than a single string at a 
time.

+     However, both strtok() and strsep() modify the original string.
+     strspn() or strcspn() should be used instead.
+
  ATTRIBUTES
       See attributes(5) for descriptions       of the  following  attri-
       butes:
@@ -512,7 +538,7 @@
       ing functions are Async-Signal-Safe.


-     For all except strlcat() and strlcpy(), see standards(5).
+     For all except strlcat(), strlcpy() and strsep() see standards(5).

  SEE ALSO
       malloc(3C), setlocale(3C),       strxfrm(3C), attributes(5), stan-


Reply via email to