Deleted Added
full compact
rc.c (241818) rc.c (244850)
1/*
1/*
2 * $Id: rc.c,v 1.49 2011/10/15 00:56:44 tom Exp $
2 * $Id: rc.c,v 1.47 2011/06/20 22:30:04 tom Exp $
3 *
4 * rc.c -- routines for processing the configuration file
5 *
6 * Copyright 2000-2010,2011 Thomas E. Dickey
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License, version 2.1
10 * as published by the Free Software Foundation.

--- 187 unchanged lines hidden (view full) ---

198 /* highlight */
199 strcat(str, hl ? ",ON)" : ",OFF)");
200
201 return str;
202}
203
204/*
205 * Extract the foreground, background and highlight values from an attribute
3 *
4 * rc.c -- routines for processing the configuration file
5 *
6 * Copyright 2000-2010,2011 Thomas E. Dickey
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License, version 2.1
10 * as published by the Free Software Foundation.

--- 187 unchanged lines hidden (view full) ---

198 /* highlight */
199 strcat(str, hl ? ",ON)" : ",OFF)");
200
201 return str;
202}
203
204/*
205 * Extract the foreground, background and highlight values from an attribute
206 * represented as a string in one of two forms:
206 * represented as a string in this form:
207 *
208 * "(foreground,background,highlight)"
207 *
208 * "(foreground,background,highlight)"
209 " "xxxx_color"
210 */
211static int
212str_to_attr(char *str, int *fg, int *bg, int *hl)
213{
214 int i = 0, get_fg = 1;
215 unsigned j;
216 char tempstr[MAX_LEN + 1], *part;
217
209 */
210static int
211str_to_attr(char *str, int *fg, int *bg, int *hl)
212{
213 int i = 0, get_fg = 1;
214 unsigned j;
215 char tempstr[MAX_LEN + 1], *part;
216
218 if (str[0] != '(' || lastch(str) != ')') {
219 if ((i = find_color(str)) >= 0) {
220 *fg = dlg_color_table[i].fg;
221 *bg = dlg_color_table[i].bg;
222 *hl = dlg_color_table[i].hilite;
223 return 0;
224 }
217 if (str[0] != '(' || lastch(str) != ')')
225 return -1; /* invalid representation */
218 return -1; /* invalid representation */
226 }
227
228 /* remove the parenthesis */
229 strcpy(tempstr, str + 1);
230 lastch(tempstr) = '\0';
231
232 /* get foreground and background */
233
234 while (1) {

--- 192 unchanged lines hidden (view full) ---

427 fprintf(rc_file, "%s = %s\n", vars[i].name,
428 *((bool *) vars[i].var) ? "ON" : "OFF");
429 break;
430 }
431 }
432#ifdef HAVE_COLOR
433 for (i = 0; i < (unsigned) dlg_color_count(); ++i) {
434 char buffer[MAX_LEN + 1];
219
220 /* remove the parenthesis */
221 strcpy(tempstr, str + 1);
222 lastch(tempstr) = '\0';
223
224 /* get foreground and background */
225
226 while (1) {

--- 192 unchanged lines hidden (view full) ---

419 fprintf(rc_file, "%s = %s\n", vars[i].name,
420 *((bool *) vars[i].var) ? "ON" : "OFF");
421 break;
422 }
423 }
424#ifdef HAVE_COLOR
425 for (i = 0; i < (unsigned) dlg_color_count(); ++i) {
426 char buffer[MAX_LEN + 1];
435 unsigned j;
436 bool repeat = FALSE;
437
438 fprintf(rc_file, "\n# %s\n", dlg_color_table[i].comment);
427
428 fprintf(rc_file, "\n# %s\n", dlg_color_table[i].comment);
439 for (j = 0; j != i; ++j) {
440 if (dlg_color_table[i].fg == dlg_color_table[j].fg
441 && dlg_color_table[i].bg == dlg_color_table[j].bg
442 && dlg_color_table[i].hilite == dlg_color_table[j].hilite) {
443 fprintf(rc_file, "%s = %s\n",
444 dlg_color_table[i].name,
445 dlg_color_table[j].name);
446 repeat = TRUE;
447 break;
448 }
449 }
450
451 if (!repeat) {
452 fprintf(rc_file, "%s = %s\n", dlg_color_table[i].name,
453 attr_to_str(buffer,
454 dlg_color_table[i].fg,
455 dlg_color_table[i].bg,
456 dlg_color_table[i].hilite));
457 }
429 fprintf(rc_file, "%s = %s\n", dlg_color_table[i].name,
430 attr_to_str(buffer,
431 dlg_color_table[i].fg,
432 dlg_color_table[i].bg,
433 dlg_color_table[i].hilite));
458 }
459#endif /* HAVE_COLOR */
460 dlg_dump_keys(rc_file);
461
462 (void) fclose(rc_file);
463}
464
465/*

--- 60 unchanged lines hidden (view full) ---

526 fprintf(stderr, "\nParse error: line %d of configuration"
527 " file too long.\n", l);
528 result = -1; /* parse aborted */
529 break;
530 }
531
532 lastch(str) = '\0';
533 if (begins_with(str, "bindkey", &params)) {
434 }
435#endif /* HAVE_COLOR */
436 dlg_dump_keys(rc_file);
437
438 (void) fclose(rc_file);
439}
440
441/*

--- 60 unchanged lines hidden (view full) ---

502 fprintf(stderr, "\nParse error: line %d of configuration"
503 " file too long.\n", l);
504 result = -1; /* parse aborted */
505 break;
506 }
507
508 lastch(str) = '\0';
509 if (begins_with(str, "bindkey", &params)) {
534 if (!dlg_parse_bindkey(params)) {
535 fprintf(stderr, "\nParse error: line %d of configuration\n", l);
536 result = -1;
537 }
510 dlg_parse_bindkey(params);
538 continue;
539 }
540 parse = parse_line(str, &var, &value); /* parse current line */
541
542 switch (parse) {
543 case LINE_EMPTY: /* ignore blank lines and comments */
544 break;
545 case LINE_EQUALS:

--- 67 unchanged lines hidden ---
511 continue;
512 }
513 parse = parse_line(str, &var, &value); /* parse current line */
514
515 switch (parse) {
516 case LINE_EMPTY: /* ignore blank lines and comments */
517 break;
518 case LINE_EQUALS:

--- 67 unchanged lines hidden ---