Hi Theo,

as you sent it, your patch is misleading since our manual page describes
two features that are not required by POSIX.

So i propose the larger patch shown below instead.

While here, clarify what "null-terminated" means.  It matters for
this page in particular because the page talks about both NUL bytes
and NULL pointers in different places.

Also, failing to state that the original input string is modified
feels like a serious omission to me.  By the way, these replacements
are indeed required by POSIX.  The strsep(3) below SEE ALSO provides
a rather weak hint, but i regard that as insufficient.

OK?
  Ingo


Index: getsubopt.3
===================================================================
RCS file: /cvs/src/lib/libc/stdlib/getsubopt.3,v
retrieving revision 1.14
diff -u -r1.14 getsubopt.3
--- getsubopt.3 15 Nov 2014 14:41:02 -0000      1.14
+++ getsubopt.3 3 Sep 2021 14:38:28 -0000
@@ -55,7 +55,9 @@
 is a pointer to a pointer to the string.
 The argument
 .Fa tokens
-is a pointer to a null-terminated array of pointers to strings.
+is a pointer to a
+.Dv NULL Ns -terminated
+array of pointers to strings.
 .Pp
 The
 .Fn getsubopt
@@ -79,6 +81,11 @@
 .Fa optionp
 will be set to point to the start of the next token in the string,
 or the NUL at the end of the string if no more tokens are present.
+The comma, space, or tab character ending the token just parsed,
+and the equal sign separating name and value if any, are replaced
+with NUL bytes in the original
+.Pf * Fa optionp
+input string.
 The external variable
 .Fa suboptarg
 will be set to point to the start of the current token, or
@@ -138,6 +145,16 @@
 .Sh SEE ALSO
 .Xr getopt 3 ,
 .Xr strsep 3
+.Sh STANDARDS
+The
+.Fn getsubopt
+function conforms to
+.St -p1003.1-2008 .
+.Pp
+Allowing space and tab characters to separate tokens
+and the external variable
+.Va suboptarg
+are extensions to that standard.
 .Sh HISTORY
 The
 .Fn getsubopt

Reply via email to