[PATCH] parse-options: fix the description of defval

Subsystems: the rest

DORMANTno replies

5 messages, 2 authors, 2016-06-15 · open the first message on its own page

[PATCH] parse-options: fix the description of defval

From: Ivan Ukhov <hidden>
Date: 2016-06-15 23:04:18

Since the deletion of OPT_SET_PTR, defval can no longer contain a pointer.

Signed-off-by: Ivan Ukhov <redacted>
---
 parse-options.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/parse-options.h b/parse-options.h
index 7940bc7..c71e9da 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -95,8 +95,7 @@ typedef int parse_opt_ll_cb(struct parse_opt_ctx_t *ctx,
  *
  * `defval`::
  *   default value to fill (*->value) with for PARSE_OPT_OPTARG.
- *   OPTION_{BIT,SET_INT} store the {mask,integer,pointer} to put in
- *   the value when met.
+ *   OPTION_{BIT,SET_INT} store the {mask,integer} to put in the value when met.
  *   CALLBACKS can use it like they want.
  */
 struct option {
--
1.8.4

Re: [PATCH] parse-options: fix the description of defval

From: Paul Tan <hidden>
Date: 2016-06-15 23:04:18

Hi,

On Sun, Mar 29, 2015 at 4:32 PM, Ivan Ukhov [off-list ref] wrote:
Since the deletion of OPT_SET_PTR, defval can no longer contain a pointer.
Actually, it can contain a pointer for OPTION_CMDMODE, OPTION_STRING
and OPTION_FILENAME. Since we are on the topic of updating the
documentation, I think it would be great if the documentation
mentioned these option types as well.

Thanks,
Paul

Re: [PATCH] parse-options: fix the description of defval

From: Ivan Ukhov <hidden>
Date: 2016-06-15 23:04:18

Hello Paul,

On Mar 29, 2015, at 11:08 AM, Paul Tan [off-list ref] wrote:

Actually, it can contain a pointer for OPTION_CMDMODE, OPTION_STRING
and OPTION_FILENAME.
I have checked the definitions of the three macros you mentioned, and it seems that none of them uses defval to store pointers. OPTION_CMDMODE stores chars and integers. OPTION_STRING does not use defval at all (pointers go in a different field of the option struct), and the same applies to OPTION_FILENAME. I am probably missing something; can you please clarify what you mean? Thank you.


Regards,
Ivan

Re: [PATCH] parse-options: fix the description of defval

From: Paul Tan <hidden>
Date: 2016-06-15 23:04:18

Hi,

On Sun, Mar 29, 2015 at 5:28 PM, Ivan Ukhov [off-list ref] wrote:
I have checked the definitions of the three macros you mentioned, and it seems that none of them uses defval to store pointers. OPTION_CMDMODE stores chars and integers. OPTION_STRING does not use defval at all (pointers go in a different field of the option struct), and the same applies to OPTION_FILENAME. I am probably missing something; can you please clarify what you mean? Thank you.
For OPTION_STRING, if the PARSE_OPT_OPTARG flag is set (as the
documentation already states), the option can be provided on the
command line without any corresponding argument. If provided as so,
the string pointer of defval is used.

See get_value() in parse-options.c

I haven't used the other option types before yet (just did a grep
'defval' in parse-options.c) so I don't know what they do with defval.
That's why it would be nice if they were documented :-)

Regards,
Paul

Re: [PATCH] parse-options: fix the description of defval

From: Ivan Ukhov <hidden>
Date: 2016-06-15 23:04:18

Hello Paul,


Yes, you are right. Thank you for the clarification!


Regards,
Ivan
On Mar 29, 2015, at 3:27 PM, Paul Tan [off-list ref] wrote:

Hi,

On Sun, Mar 29, 2015 at 5:28 PM, Ivan Ukhov [off-list ref] wrote:
quoted
I have checked the definitions of the three macros you mentioned, and it seems that none of them uses defval to store pointers. OPTION_CMDMODE stores chars and integers. OPTION_STRING does not use defval at all (pointers go in a different field of the option struct), and the same applies to OPTION_FILENAME. I am probably missing something; can you please clarify what you mean? Thank you.
For OPTION_STRING, if the PARSE_OPT_OPTARG flag is set (as the
documentation already states), the option can be provided on the
command line without any corresponding argument. If provided as so,
the string pointer of defval is used.

See get_value() in parse-options.c

I haven't used the other option types before yet (just did a grep
'defval' in parse-options.c) so I don't know what they do with defval.
That's why it would be nice if they were documented :-)

Regards,
Paul
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help