version 1.48, 2017/01/13 11:56:43 |
version 1.49, 2017/01/24 20:05:15 |
|
|
} |
} |
|
|
static void |
static void |
tty_term_override(struct tty_term *term, const char *overrides) |
tty_term_override(struct tty_term *term, const char *override) |
{ |
{ |
const struct tty_term_code_entry *ent; |
const struct tty_term_code_entry *ent; |
struct tty_code *code; |
struct tty_code *code; |
char *termnext, *termstr; |
char *next, *s, *copy, *cp, *value; |
char *entnext, *entstr; |
|
char *s, *ptr, *val; |
|
const char *errstr; |
const char *errstr; |
u_int i; |
u_int i; |
int n, removeflag; |
int n, remove; |
|
|
s = xstrdup(overrides); |
copy = next = xstrdup(override); |
|
|
termnext = s; |
s = strsep(&next, ":"); |
while ((termstr = strsep(&termnext, ",")) != NULL) { |
if (s == NULL || next == NULL || fnmatch(s, term->name, 0) != 0) { |
entnext = termstr; |
free(copy); |
|
return; |
|
} |
|
|
entstr = strsep(&entnext, ":"); |
while ((s = strsep(&next, ":")) != NULL) { |
if (entstr == NULL || entnext == NULL) |
if (*s == '\0') |
continue; |
continue; |
if (fnmatch(entstr, term->name, 0) != 0) |
value = NULL; |
continue; |
|
while ((entstr = strsep(&entnext, ":")) != NULL) { |
|
if (*entstr == '\0') |
|
continue; |
|
|
|
val = NULL; |
remove = 0; |
removeflag = 0; |
if ((cp = strchr(s, '=')) != NULL) { |
if ((ptr = strchr(entstr, '=')) != NULL) { |
*cp++ = '\0'; |
*ptr++ = '\0'; |
value = xstrdup(cp); |
val = xstrdup(ptr); |
if (strunvis(value, cp) == -1) { |
if (strunvis(val, ptr) == -1) { |
free(value); |
free(val); |
value = xstrdup(cp); |
val = xstrdup(ptr); |
} |
} |
} else if (s[strlen(s) - 1] == '@') { |
} else if (entstr[strlen(entstr) - 1] == '@') { |
s[strlen(s) - 1] = '\0'; |
entstr[strlen(entstr) - 1] = '\0'; |
remove = 1; |
removeflag = 1; |
} else |
} else |
value = xstrdup(""); |
val = xstrdup(""); |
|
|
|
log_debug("%s override: %s %s", |
if (remove) |
term->name, entstr, removeflag ? "@" : val); |
log_debug("%s override: %s@", term->name, s); |
for (i = 0; i < tty_term_ncodes(); i++) { |
else |
ent = &tty_term_codes[i]; |
log_debug("%s override: %s=%s", term->name, s, value); |
if (strcmp(entstr, ent->name) != 0) |
|
continue; |
|
code = &term->codes[i]; |
|
|
|
if (removeflag) { |
for (i = 0; i < tty_term_ncodes(); i++) { |
code->type = TTYCODE_NONE; |
ent = &tty_term_codes[i]; |
continue; |
if (strcmp(s, ent->name) != 0) |
} |
continue; |
switch (ent->type) { |
code = &term->codes[i]; |
case TTYCODE_NONE: |
|
|
if (remove) { |
|
code->type = TTYCODE_NONE; |
|
continue; |
|
} |
|
switch (ent->type) { |
|
case TTYCODE_NONE: |
|
break; |
|
case TTYCODE_STRING: |
|
if (code->type == TTYCODE_STRING) |
|
free(code->value.string); |
|
code->value.string = xstrdup(value); |
|
code->type = ent->type; |
|
break; |
|
case TTYCODE_NUMBER: |
|
n = strtonum(value, 0, INT_MAX, &errstr); |
|
if (errstr != NULL) |
break; |
break; |
case TTYCODE_STRING: |
code->value.number = n; |
if (code->type == TTYCODE_STRING) |
code->type = ent->type; |
free(code->value.string); |
break; |
code->value.string = xstrdup(val); |
case TTYCODE_FLAG: |
code->type = ent->type; |
code->value.flag = 1; |
break; |
code->type = ent->type; |
case TTYCODE_NUMBER: |
break; |
n = strtonum(val, 0, INT_MAX, &errstr); |
|
if (errstr != NULL) |
|
break; |
|
code->value.number = n; |
|
code->type = ent->type; |
|
break; |
|
case TTYCODE_FLAG: |
|
code->value.flag = 1; |
|
code->type = ent->type; |
|
break; |
|
} |
|
} |
} |
|
|
free(val); |
|
} |
} |
} |
|
|
|
|
free(value); |
|
} |
free(s); |
free(s); |
} |
} |
|
|
|
|
struct tty_term *term; |
struct tty_term *term; |
const struct tty_term_code_entry *ent; |
const struct tty_term_code_entry *ent; |
struct tty_code *code; |
struct tty_code *code; |
u_int i; |
struct options_entry *o; |
|
u_int size, i; |
int n, error; |
int n, error; |
const char *s, *acs; |
const char *s, *acs; |
|
|
|
|
} |
} |
|
|
/* Apply terminal overrides. */ |
/* Apply terminal overrides. */ |
s = options_get_string(global_options, "terminal-overrides"); |
o = options_get_only(global_options, "terminal-overrides"); |
tty_term_override(term, s); |
if (options_array_size(o, &size) != -1) { |
|
for (i = 0; i < size; i++) { |
|
s = options_array_get(o, i); |
|
if (s != NULL) |
|
tty_term_override(term, s); |
|
} |
|
} |
|
|
/* Delete curses data. */ |
/* Delete curses data. */ |
del_curterm(cur_term); |
del_curterm(cur_term); |