diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/termcap.c | 15 | ||||
-rw-r--r-- | src/termcap.h | 4 | ||||
-rw-r--r-- | src/vte.c | 18 |
3 files changed, 29 insertions, 8 deletions
diff --git a/src/termcap.c b/src/termcap.c index 6096f79..79839d5 100644 --- a/src/termcap.c +++ b/src/termcap.c @@ -397,6 +397,12 @@ vte_termcap_find_l(struct vte_termcap *termcap, const char *tname, ssize_t len, char ttname[len + 1]; ssize_t clen; + g_return_val_if_fail(termcap != NULL, ""); + g_return_val_if_fail(tname != NULL, ""); + g_return_val_if_fail(len > 0, ""); + g_return_val_if_fail(cap != NULL, ""); + g_return_val_if_fail(strlen(cap) > 0, ""); + /* Find the entry by this name. */ memcpy(ttname, tname, len); ttname[len] = '\0'; @@ -484,19 +490,21 @@ static const char * vte_termcap_find(struct vte_termcap *termcap, const char *tname, const char *cap) { + g_return_val_if_fail(termcap != NULL, ""); return vte_termcap_find_l(termcap, tname, strlen(tname), cap); } -TERMCAP_MAYBE_STATIC int +TERMCAP_MAYBE_STATIC gboolean vte_termcap_find_boolean(struct vte_termcap *termcap, const char *tname, const char *cap) { const char *val; + g_return_val_if_fail(termcap != NULL, FALSE); val = vte_termcap_find(termcap, tname, cap); if ((val != NULL) && (val[0] != '\0')) { - return 1; + return TRUE; } - return 0; + return FALSE; } TERMCAP_MAYBE_STATIC long @@ -507,6 +515,7 @@ vte_termcap_find_numeric(struct vte_termcap *termcap, const char *tname, char *p; ssize_t l; long ret; + g_return_val_if_fail(termcap != NULL, 0); val = vte_termcap_find(termcap, tname, cap); if ((val != NULL) && (val[0] != '\0')) { l = strlen(cap); diff --git a/src/termcap.h b/src/termcap.h index d1928ca..2e8e044 100644 --- a/src/termcap.h +++ b/src/termcap.h @@ -32,8 +32,8 @@ struct vte_termcap *vte_termcap_new(const char *filename); void vte_termcap_free(struct vte_termcap *termcap); /* Read a boolean capability for a given terminal. */ -int vte_termcap_find_boolean(struct vte_termcap *termcap, const char *tname, - const char *cap); +gboolean vte_termcap_find_boolean(struct vte_termcap *termcap, + const char *tname, const char *cap); /* Read a numeric capability for a given terminal. */ long vte_termcap_find_numeric(struct vte_termcap *termcap, const char *tname, @@ -21,6 +21,7 @@ #include <sys/ioctl.h> #include <sys/types.h> #include <sys/param.h> +#include <sys/stat.h> #include <sys/time.h> #include <errno.h> #include <fcntl.h> @@ -64,6 +65,7 @@ #define VTE_DEF_BG 17 #define VTE_SATURATION_MAX 10000 #define VTE_SCROLLBACK_MIN 100 +#define VTE_DEFAULT_EMULATION "xterm-color" /* The structure we use to hold characters we're supposed to display -- this * includes any supported visible attributes. */ @@ -5255,7 +5257,7 @@ vte_terminal_set_emulation(VteTerminal *terminal, const char *emulation) /* Set the emulation type, for reference. */ if (emulation == NULL) { - emulation = "xterm-color"; + emulation = VTE_DEFAULT_EMULATION; } quark = g_quark_from_string(emulation); terminal->pvt->terminal = g_quark_to_string(quark); @@ -5329,8 +5331,18 @@ vte_terminal_set_emulation(VteTerminal *terminal, const char *emulation) static void vte_terminal_set_termcap(VteTerminal *terminal, const char *path) { + struct stat st; + char path_default[PATH_MAX]; + if (path == NULL) { - path = "/etc/termcap"; + snprintf(path_default, sizeof(path_default), + DATADIR "/" PACKAGE "/termcap/%s", + terminal->pvt->terminal ?: VTE_DEFAULT_EMULATION); + if (stat(path_default, &st) == 0) { + path = path_default; + } else { + path = "/etc/termcap"; + } } terminal->pvt->termcap_path = g_quark_to_string(g_quark_from_string(path)); #ifdef VTE_DEBUG @@ -5838,7 +5850,7 @@ vte_terminal_determine_colors(VteTerminal *terminal, { /* Determine what the foreground and background colors for rendering * text should be. */ - if (reverse ^ (cell && cell->reverse)) { + if (reverse) { *fore = cell ? cell->back : VTE_DEF_BG; *back = cell ? cell->fore : VTE_DEF_FG; } else { |