Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F140104631
D13701.id37283.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
8 KB
Referenced Files
None
Subscribers
None
D13701.id37283.diff
View Options
Index: Mk/bsd.options.mk
===================================================================
--- Mk/bsd.options.mk
+++ Mk/bsd.options.mk
@@ -19,6 +19,8 @@
# least 1 among N
# OPTIONS_GROUP - List of group-choice grouped options: 0 or
# more among N
+# OPTIONS_SECTION_ORDER - List of all sections in the desired order, or
+# empty for default ordering
#
# OPTIONS_SINGLE_${NAME} - List of OPTIONS grouped as single choice (for
# the single named as ${NAME} as defined in
@@ -32,6 +34,10 @@
# OPTIONS_GROUP_${NAME} - List of OPTIONS grouped as group-choice (for
# the group named as ${NAME} as defined in
# OPTIONS_GROUP)
+# OPTIONS_SINGLE_${NAME}_SELECTED - The selected single choice option (for
+# the single named as ${NAME})
+# OPTIONS_RADIO_${NAME}_SELECTED - The selected radio choice option (for
+# the radio named as ${NAME})
#
# OPTIONS_EXCLUDE - List of options unsupported (useful for slave ports)
# OPTIONS_EXCLUDE_${ARCH} - List of options unsupported on a given ${ARCH}
Index: Mk/bsd.port.mk
===================================================================
--- Mk/bsd.port.mk
+++ Mk/bsd.port.mk
@@ -4869,6 +4869,7 @@
OPTIONS_SINGLE="${OPTIONS_SINGLE}" \
OPTIONS_RADIO="${OPTIONS_RADIO}" \
OPTIONS_GROUP="${OPTIONS_GROUP}" \
+ OPTIONS_SECTION_ORDER="${OPTIONS_SECTION_ORDER}" \
NEW_OPTIONS="${NEW_OPTIONS}" \
DIALOG4PORTS="${DIALOG4PORTS}" \
PREFIX="${PREFIX}" \
Index: ports-mgmt/dialog4ports/Makefile
===================================================================
--- ports-mgmt/dialog4ports/Makefile
+++ ports-mgmt/dialog4ports/Makefile
@@ -3,7 +3,7 @@
PORTNAME= dialog4ports
PORTVERSION= 0.1.6
-PORTREVISION?= 0
+PORTREVISION?= 1
CATEGORIES= ports-mgmt
MASTER_SITES= http://m1cro.me/dialog4ports/ \
http://files.etoilebsd.net/dialog4ports/ \
Index: ports-mgmt/dialog4ports/files/patch-dialog4ports.c
===================================================================
--- /dev/null
+++ ports-mgmt/dialog4ports/files/patch-dialog4ports.c
@@ -0,0 +1,223 @@
+--- dialog4ports.c.orig 2016-07-08 14:49:08 UTC
++++ dialog4ports.c
+@@ -43,6 +43,7 @@
+
+ static int list_no = 0;
+ static int group = 0;
++static char const *env_delimiter = " \t";
+
+ /* The initial items size */
+ static int items_sz = 5;
+@@ -50,6 +51,12 @@ static int items_sz = 5;
+ static StringList *enable_items = NULL;
+ /* New items */
+ static StringList *new_items = NULL;
++/* One options section */
++struct section {
++ char env_name[32];
++ char section_name[256];
++ int type;
++};
+
+ /* add item to items */
+ static void
+@@ -126,74 +133,161 @@ parse_env_sl(char const *env_name)
+
+ /* parsing part */
+ static int
+-parsing_env(dialog_mixedlist **items, char const *env_name, int type)
++parse_env_all(dialog_mixedlist **items, char const *env_name, int type)
+ {
+- char *env, buf[256];
+- char const *delimiter = " \t";
+- char *token, *token2;
++ char *env;
++ char *token;
+ char *temp, *tofree;
+- char *temp2, *tofree2;
+
+ env = getenv(env_name);
+ if (env == NULL)
+ return (0);
+
+- if (strcmp(env_name, "ALL_OPTIONS") == 0) {
+- tofree = temp = strdup(env);
++ tofree = temp = strdup(env);
++ while ((token = strsep(&temp, env_delimiter)) != NULL) {
++ if (token[0] == '\0')
++ continue;
++ add_item(items, token, get_desc(token, ""), is_enable(token),
++ is_new(token), type, group);
++ }
++ free(tofree);
+
+- while ((token = strsep(&temp, delimiter)) != NULL) {
+- if (token[0] == '\0')
+- continue;
+- add_item(items, token, get_desc(token, ""), is_enable(token),
+- is_new(token), type, group);
++ group++;
++
++ return (0);
++}
++
++static void
++order_sections(struct section **sections, int sections_size)
++{
++ char *env;
++ char *token, *temp, *tofree;
++ struct section *ordered_sections, *sec;
++ int i, found;
++
++ env = getenv("OPTIONS_SECTION_ORDER");
++ if (env == NULL || env[0] == '\0')
++ return;
++
++ if (sections_size == 0)
++ errx(EXIT_FAILURE, "OPTIONS_SECTION_ORDER is defined, but there are no option sections");
++
++ ordered_sections = malloc(sizeof(struct section)*sections_size);
++ sec = ordered_sections;
++ found = 0;
++
++ tofree = temp = strdup(env);
++ while ((token = strsep(&temp, env_delimiter)) != NULL) {
++ if (token[0] == '\0')
++ continue;
++
++ for (i = 0; i < sections_size; i++) {
++ if (strcmp((*sections)[i].section_name, token) == 0) {
++ *sec++ = (*sections)[i];
++ found++;
++ break;
++ }
+ }
+- free(tofree);
+- } else {
++ if (i >= sections_size)
++ errx(EXIT_FAILURE, "can't find section %s from OPTIONS_SECTION_ORDER in any option group", token);
++ }
++ free(tofree);
++
++ if (found != sections_size)
++ errx(EXIT_FAILURE, "Items in OPTIONS_SECTION_ORDER should match the declared option sections");
++
++ free(*sections);
++ *sections = ordered_sections;
++}
++
++static void
++read_env_section(struct section **sections, int *sections_size, char const *env_name, int type)
++{
++ char *env;
++ char *token;
++ char *temp, *tofree;
++ struct section *new_section;
++
++ env = getenv(env_name);
++ if (env == NULL)
++ return;
++
++ tofree = temp = strdup(env);
++ while ((token = strsep(&temp, env_delimiter)) != NULL) {
++ if (token[0] == '\0')
++ continue;
++
++ if (*sections_size == 0)
++ *sections = malloc(sizeof(struct section));
++ else
++ *sections = realloc(*sections, sizeof(struct section) * (*sections_size + 1));
++
++ new_section = *sections + *sections_size;
++
++ strcpy(new_section->env_name, env_name);
++ strncpy(new_section->section_name, token, sizeof(new_section->section_name));
++ new_section->type = type;
++
++ ++*sections_size;
++ }
++ free(tofree);
++}
++
++static int
++add_sections(dialog_mixedlist **items, struct section *sections, int sections_size)
++{
++ int i;
++ char *env, buf[256];
++ char *token;
++ char *temp, *tofree;
++ struct section *sec = sections;
++
++ for (i = 0; i < sections_size; i++, sec++) {
++ add_item(items, get_desc(sec->section_name, sec->section_name), "", false, false,
++ ITEM_SEPARATOR, group);
++
++ snprintf(buf, sizeof(buf), "%s_%s", sec->env_name, sec->section_name);
++ env = getenv(buf);
++ if (env == NULL)
++ errx(EXIT_FAILURE, "%s does not exists", buf);
++
+ tofree = temp = strdup(env);
+- while ((token = strsep(&temp, delimiter)) != NULL) {
++ while ((token = strsep(&temp, env_delimiter)) != NULL) {
+ if (token[0] == '\0')
+ continue;
+- add_item(items, get_desc(token, token), "", false, false,
+- ITEM_SEPARATOR, group);
+-
+- snprintf(buf, sizeof(buf), "%s_%s", env_name, token);
+- env = getenv(buf);
+- if (env == NULL)
+- errx(EXIT_FAILURE, "%s does not exists", buf);
+- tofree2 = temp2 = strdup(env);
+- while ((token2 = strsep(&temp2, delimiter)) != NULL) {
+- if (token2[0] == '\0')
+- continue;
+- add_item(items, token2, get_desc(token2, ""),
+- is_enable(token2), is_new(token2), type, group);
+- }
+- free(tofree2);
+- group++;
++ add_item(items, token, get_desc(token, ""),
++ is_enable(token), is_new(token), sec->type, group);
+ }
+-
+ free(tofree);
++ group++;
+ }
++
+ if (group == 0)
+ group++;
+
+ return (0);
+ }
+
+-
+ /* prepare items for next drawing*/
+ static dialog_mixedlist *
+ prepare_items(void)
+ {
+ dialog_mixedlist *items = NULL;
++ struct section *sections = NULL;
++ int sections_size = 0;
+
+ enable_items = parse_env_sl("PORT_OPTIONS");
+ new_items = parse_env_sl("NEW_OPTIONS");
+
+- parsing_env(&items, "ALL_OPTIONS", ITEM_CHECK);
+- parsing_env(&items, "OPTIONS_GROUP", ITEM_CHECK);
+- parsing_env(&items, "OPTIONS_MULTI", ITEM_CHECK);
+- parsing_env(&items, "OPTIONS_SINGLE", ITEM_RADIO);
+- parsing_env(&items, "OPTIONS_RADIO", ITEM_RADIO);
++ parse_env_all(&items, "ALL_OPTIONS", ITEM_CHECK);
++ read_env_section(§ions, §ions_size, "OPTIONS_GROUP", ITEM_CHECK);
++ read_env_section(§ions, §ions_size, "OPTIONS_MULTI", ITEM_CHECK);
++ read_env_section(§ions, §ions_size, "OPTIONS_SINGLE", ITEM_RADIO);
++ read_env_section(§ions, §ions_size, "OPTIONS_RADIO", ITEM_RADIO);
++
++ order_sections(§ions, sections_size);
++
++ add_sections(&items, sections, sections_size);
+
+ return (items);
+ }
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 21, 7:08 AM (9 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27109279
Default Alt Text
D13701.id37283.diff (8 KB)
Attached To
Mode
D13701: ports-mgmt/dialog4ports: Implemented "OPTIONS_SECTION_ORDER" feature allowing to order sections {pending maintainer's approval, or Jan 12}
Attached
Detach File
Event Timeline
Log In to Comment