summaryrefslogtreecommitdiffstats
path: root/contrib/dialog/rc.c
diff options
context:
space:
mode:
authornwhitehorn <nwhitehorn@FreeBSD.org>2012-10-21 18:25:12 +0000
committernwhitehorn <nwhitehorn@FreeBSD.org>2012-10-21 18:25:12 +0000
commit59ae05f843643afc6998fcc4b2b415d89a8635ee (patch)
tree74dabcbe10843be3b85112de4524f2abb8e4112f /contrib/dialog/rc.c
parent2ad040bf3f552fc8b740e79fe6db1bf91414d583 (diff)
parenta94245b3d36b447d1f761028da7e072210e64b43 (diff)
downloadFreeBSD-src-59ae05f843643afc6998fcc4b2b415d89a8635ee.zip
FreeBSD-src-59ae05f843643afc6998fcc4b2b415d89a8635ee.tar.gz
Update dialog to 20120706: includes minor useability enhancements and
fixes for warnings encountered with clang.
Diffstat (limited to 'contrib/dialog/rc.c')
-rw-r--r--contrib/dialog/rc.c45
1 files changed, 36 insertions, 9 deletions
diff --git a/contrib/dialog/rc.c b/contrib/dialog/rc.c
index 2e2c7e6..cc6af29 100644
--- a/contrib/dialog/rc.c
+++ b/contrib/dialog/rc.c
@@ -1,5 +1,5 @@
/*
- * $Id: rc.c,v 1.47 2011/06/20 22:30:04 tom Exp $
+ * $Id: rc.c,v 1.49 2011/10/15 00:56:44 tom Exp $
*
* rc.c -- routines for processing the configuration file
*
@@ -203,9 +203,10 @@ attr_to_str(char *str, int fg, int bg, int hl)
/*
* Extract the foreground, background and highlight values from an attribute
- * represented as a string in this form:
+ * represented as a string in one of two forms:
*
* "(foreground,background,highlight)"
+ " "xxxx_color"
*/
static int
str_to_attr(char *str, int *fg, int *bg, int *hl)
@@ -214,8 +215,15 @@ str_to_attr(char *str, int *fg, int *bg, int *hl)
unsigned j;
char tempstr[MAX_LEN + 1], *part;
- if (str[0] != '(' || lastch(str) != ')')
+ if (str[0] != '(' || lastch(str) != ')') {
+ if ((i = find_color(str)) >= 0) {
+ *fg = dlg_color_table[i].fg;
+ *bg = dlg_color_table[i].bg;
+ *hl = dlg_color_table[i].hilite;
+ return 0;
+ }
return -1; /* invalid representation */
+ }
/* remove the parenthesis */
strcpy(tempstr, str + 1);
@@ -424,13 +432,29 @@ dlg_create_rc(const char *filename)
#ifdef HAVE_COLOR
for (i = 0; i < (unsigned) dlg_color_count(); ++i) {
char buffer[MAX_LEN + 1];
+ unsigned j;
+ bool repeat = FALSE;
fprintf(rc_file, "\n# %s\n", dlg_color_table[i].comment);
- fprintf(rc_file, "%s = %s\n", dlg_color_table[i].name,
- attr_to_str(buffer,
- dlg_color_table[i].fg,
- dlg_color_table[i].bg,
- dlg_color_table[i].hilite));
+ for (j = 0; j != i; ++j) {
+ if (dlg_color_table[i].fg == dlg_color_table[j].fg
+ && dlg_color_table[i].bg == dlg_color_table[j].bg
+ && dlg_color_table[i].hilite == dlg_color_table[j].hilite) {
+ fprintf(rc_file, "%s = %s\n",
+ dlg_color_table[i].name,
+ dlg_color_table[j].name);
+ repeat = TRUE;
+ break;
+ }
+ }
+
+ if (!repeat) {
+ fprintf(rc_file, "%s = %s\n", dlg_color_table[i].name,
+ attr_to_str(buffer,
+ dlg_color_table[i].fg,
+ dlg_color_table[i].bg,
+ dlg_color_table[i].hilite));
+ }
}
#endif /* HAVE_COLOR */
dlg_dump_keys(rc_file);
@@ -507,7 +531,10 @@ dlg_parse_rc(void)
lastch(str) = '\0';
if (begins_with(str, "bindkey", &params)) {
- dlg_parse_bindkey(params);
+ if (!dlg_parse_bindkey(params)) {
+ fprintf(stderr, "\nParse error: line %d of configuration\n", l);
+ result = -1;
+ }
continue;
}
parse = parse_line(str, &var, &value); /* parse current line */
OpenPOWER on IntegriCloud