Fix a segmentation fault occuring when using menu_add_item without a text
label. While there sync code and documentation about the possibility to use a label and options.
This commit is contained in:
@@ -31,6 +31,7 @@ v0.5dev (ongoing development)
|
|||||||
* hd44780/serial: Add support for adjustable backlight
|
* hd44780/serial: Add support for adjustable backlight
|
||||||
* Build system: Fix build with automake >= 1.11.3 (#3494755)
|
* Build system: Fix build with automake >= 1.11.3 (#3494755)
|
||||||
* Fix clang compiler warnings about obsolete GNU designated initializers
|
* Fix clang compiler warnings about obsolete GNU designated initializers
|
||||||
|
* Fix crash when adding a menu item without text and options (S. Dawson)
|
||||||
|
|
||||||
v0.5.5
|
v0.5.5
|
||||||
+ sed1330 driver: Add support for HG25504 (L. Lagendijk)
|
+ sed1330 driver: Add support for HG25504 (L. Lagendijk)
|
||||||
|
|||||||
@@ -707,6 +707,7 @@
|
|||||||
menu_set_item "test" test_ip -next "test_menu" -prev "test_alpha"
|
menu_set_item "test" test_ip -next "test_menu" -prev "test_alpha"
|
||||||
menu_set_item "test" test_menu_action -next "_close_"
|
menu_set_item "test" test_menu_action -next "_close_"
|
||||||
|
|
||||||
|
# replace the main menu with the client's menu as created above
|
||||||
menu_set_main ""
|
menu_set_main ""
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
@@ -757,7 +758,8 @@
|
|||||||
<option><replaceable>menu_id</replaceable></option>
|
<option><replaceable>menu_id</replaceable></option>
|
||||||
<option><replaceable>new_item_id</replaceable></option>
|
<option><replaceable>new_item_id</replaceable></option>
|
||||||
<option><replaceable>type</replaceable></option>
|
<option><replaceable>type</replaceable></option>
|
||||||
<optional><option><replaceable>options</replaceable></option></optional>
|
<optional><option><replaceable>text</replaceable></option></optional>
|
||||||
|
<optional><option><replaceable>item_specific_options</replaceable></option></optional>
|
||||||
</command>
|
</command>
|
||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
@@ -765,8 +767,10 @@
|
|||||||
Adds a new menu item to a menu. The main menu of a client,
|
Adds a new menu item to a menu. The main menu of a client,
|
||||||
will be created automatically as soon as the client adds
|
will be created automatically as soon as the client adds
|
||||||
an item. This main menu has an empty id ("") and the name
|
an item. This main menu has an empty id ("") and the name
|
||||||
is identical to the name of the client. The options are
|
is identical to the name of the client. The item specific options
|
||||||
described under menu_set_item below.
|
are described under menu_set_item below. Use of <replaceable>text</replaceable>
|
||||||
|
is optional and is a shortcut for "-text <replaceable>text</replaceable>"
|
||||||
|
option.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
<note>
|
<note>
|
||||||
@@ -777,6 +781,11 @@
|
|||||||
<replaceable>menu_ids</replaceable> are <emphasis>unique</emphasis>
|
<replaceable>menu_ids</replaceable> are <emphasis>unique</emphasis>
|
||||||
(at least within a clients menu hierarchy).
|
(at least within a clients menu hierarchy).
|
||||||
</para>
|
</para>
|
||||||
|
<para>
|
||||||
|
If you want to use a text label that starts with a '-' (minus)
|
||||||
|
character, you have to use the "-text <replaceable>text</replaceable>"
|
||||||
|
option.
|
||||||
|
</para>
|
||||||
</note>
|
</note>
|
||||||
<variablelist><title>menu item types</title>
|
<variablelist><title>menu item types</title>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
|
|||||||
@@ -67,13 +67,14 @@ static char *argv2string(int argc, char **argv)
|
|||||||
* Adds an item to a menu.
|
* Adds an item to a menu.
|
||||||
*
|
*
|
||||||
*\verbatim
|
*\verbatim
|
||||||
* Usage: menu_add_item <menuid> <newitemid> <type> [<text>]
|
* Usage: menu_add_item <menuid> <newitemid> <type> [<text>] {<option>}+
|
||||||
*\endverbatim
|
*\endverbatim
|
||||||
*
|
*
|
||||||
* You should use "" as id for the client's main menu. This menu will be
|
* You should use "" as id for the client's main menu. This menu will be
|
||||||
* created automatically when you add an item to it the first time.
|
* created automatically when you add an item to it the first time.
|
||||||
*
|
*
|
||||||
* You (currently?) cannot create a menu in the main level yourself.
|
* You cannot create a menu in the main level yourself, unless you replace the
|
||||||
|
* main menu with the client's menu.
|
||||||
* The names you use for items should be unique for your client.
|
* The names you use for items should be unique for your client.
|
||||||
* The text is the visible text for the item.
|
* The text is the visible text for the item.
|
||||||
*
|
*
|
||||||
@@ -86,6 +87,8 @@ static char *argv2string(int argc, char **argv)
|
|||||||
* - numeric
|
* - numeric
|
||||||
* - alpha
|
* - alpha
|
||||||
* - ip
|
* - ip
|
||||||
|
*
|
||||||
|
* For the list of supported options see menu_set_item_func.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
menu_add_item_func(Client *c, int argc, char **argv)
|
menu_add_item_func(Client *c, int argc, char **argv)
|
||||||
@@ -108,7 +111,7 @@ menu_add_item_func(Client *c, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (argc < 4) {
|
if (argc < 4) {
|
||||||
sock_send_error(c->sock, "Usage: menu_add_item <menuid> <newitemid> <type> [<text>]\n");
|
sock_send_error(c->sock, "Usage: menu_add_item <menuid> <newitemid> <type> [<text>] [<option>]+\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,8 +201,8 @@ menu_add_item_func(Client *c, int argc, char **argv)
|
|||||||
|
|
||||||
/* call menu_set_item() with a temporarily allocated argv
|
/* call menu_set_item() with a temporarily allocated argv
|
||||||
* to process the remaining options */
|
* to process the remaining options */
|
||||||
if ((argc > 5) || (argv[4][0] == '-')) {
|
if ((argc > 5) || ((argc == 5) && (argv[4][0] == '-'))) {
|
||||||
// menu_add_item <menuid> <newitemid> <type> [<text>]
|
// menu_add_item <menuid> <newitemid> <type> [<text>] [<option>]+
|
||||||
// menu_set_item <menuid> <itemid> {<option>}+
|
// menu_set_item <menuid> <itemid> {<option>}+
|
||||||
int i, j;
|
int i, j;
|
||||||
char **tmp_argv = malloc(argc * sizeof(char *));
|
char **tmp_argv = malloc(argc * sizeof(char *));
|
||||||
|
|||||||
Reference in New Issue
Block a user