FreeBSD Bugzilla – Attachment 189231 Details for
Bug 224737
ports-mgmt/dialog4ports: Implemented "OPTIONS_SECTION_ORDER" feature allowing to order sections
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
dialog4ports.patch (text/plain), 7.21 KB, created by
Yuri Victorovich
on 2017-12-30 22:41:19 UTC
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Yuri Victorovich
Created:
2017-12-30 22:41:19 UTC
Size:
7.21 KB
patch
obsolete
>Index: ports-mgmt/dialog4ports/Makefile >=================================================================== >--- ports-mgmt/dialog4ports/Makefile (revision 457588) >+++ ports-mgmt/dialog4ports/Makefile (working copy) >@@ -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 >=================================================================== >--- ports-mgmt/dialog4ports/files/patch-dialog4ports.c (nonexistent) >+++ ports-mgmt/dialog4ports/files/patch-dialog4ports.c (working copy) >@@ -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_and_type { >++ 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_and_type **sections, int sections_size) >++{ >++ char *env; >++ char *token, *temp, *tofree; >++ struct section_and_type *ordered_sections, *sec; >++ int i; >++ >++ 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_and_type)*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_and_type **sections, int *sections_size, char const *env_name, int type) >++{ >++ char *env; >++ char *token; >++ char *temp, *tofree; >++ struct section_and_type *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_and_type)); >++ else >++ *sections = realloc(*sections, sizeof(struct section_and_type) * (*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_and_type *sections, int sections_size) >++{ >++ int i; >++ char *env, buf[256]; >++ char *token; >++ char *temp, *tofree; >++ struct section_and_type *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_and_type *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); >+ } > >Property changes on: ports-mgmt/dialog4ports/files/patch-dialog4ports.c >___________________________________________________________________ >Added: fbsd:nokeywords >## -0,0 +1 ## >+yes >\ No newline at end of property >Added: svn:eol-style >## -0,0 +1 ## >+native >\ No newline at end of property >Added: svn:mime-type >## -0,0 +1 ## >+text/plain >\ No newline at end of property
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 224737
:
189231
|
189232
|
190241