Welcome to little lamb

Code » limb » commit 693a3e2

parseopt(3): Specify valid values for shortopt & id

author Olivier Brunel
2023-04-02 14:28:45 UTC
committer Olivier Brunel
2023-05-20 18:06:34 UTC
parent 9f89f001deef5aa3fb89ef0c137694d179f02a55

parseopt(3): Specify valid values for shortopt & id

Note that we don't check/enforce those, we just assume this to be the
case, it is UB if not.

src/doc/parseopt.h/parseopt.3.md +9 -4

diff --git a/src/doc/parseopt.h/parseopt.3.md b/src/doc/parseopt.h/parseopt.3.md
index d684d35..a9e9d48 100644
--- a/src/doc/parseopt.h/parseopt.3.md
+++ b/src/doc/parseopt.h/parseopt.3.md
@@ -96,10 +96,12 @@ declared as such :
 The meanings of different members are :
 
 : `shortopt`
-:: The character of the short option
+:: The character of the short option. Obviously this should be a character that
+:: can be found on the command line. Valid values are comprised between 33
+:: (0x21) and 126 (0x7E), which includes all alphanumeric ASCII characters.
 
 : `longopt`
-:: The name of the long option
+:: The name of the long option.
 
 : `arg`
 :: One of the constants *ARG_NONE*, *ARG_REQ* or *ARG_OPT* to indicate whether
@@ -111,8 +113,11 @@ The meanings of different members are :
 
 : `id`
 :: An integer value unique to this option, to recognize when it is parsed. It
-:: should be a positive non-zero value. If zero, `shortopt` will be returned
-:: instead.
+:: must be a value >= 128 (0x80), or 0 (*ID_SHORTOPT*) in which case `shortopt`
+:: will be returned instead.
+:: ! INFO:
+:: ! Other values (between 1 and 32) are reserved for internal use by
+:: ! [loadopt](3) and its handling of options.
 
 The last element of the array must be set to *OPTION_DONE* (all members set to 0
 except `flags` set to 1) to indicate the end.