diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common.h | 1 | ||||
-rw-r--r-- | src/core/misc.c | 38 | ||||
-rw-r--r-- | src/fe-common/core/chat-completion.c | 14 | ||||
-rw-r--r-- | src/fe-common/core/completion.c | 25 | ||||
-rw-r--r-- | src/fe-common/core/fe-server.c | 17 | ||||
-rw-r--r-- | src/fe-text/term-terminfo.c | 13 |
6 files changed, 82 insertions, 26 deletions
diff --git a/src/common.h b/src/common.h index b4fc6d28..100d00cb 100644 --- a/src/common.h +++ b/src/common.h @@ -9,6 +9,7 @@ #define IRSSI_ABI_VERSION 10 #define DEFAULT_SERVER_ADD_PORT 6667 +#define DEFAULT_SERVER_ADD_TLS_PORT 6697 #ifdef HAVE_CONFIG_H #include "irssi-config.h" diff --git a/src/core/misc.c b/src/core/misc.c index 4b1e72f6..7249b1a7 100644 --- a/src/core/misc.c +++ b/src/core/misc.c @@ -777,24 +777,35 @@ int parse_uint(const char *nptr, char **endptr, int base, guint *number) return TRUE; } +static int parse_number_sign(const char *input, char **endptr, int *sign) +{ + int sign_ = 1; + + while (i_isspace(*input)) + input++; + + if (*input == '-') { + sign_ = -sign_; + input++; + } + + *sign = sign_; + *endptr = (char *) input; + return TRUE; +} + static int parse_time_interval_uint(const char *time, guint *msecs) { const char *desc; guint number; - int sign, len, ret, digits; + int len, ret, digits; *msecs = 0; /* max. return value is around 24 days */ - number = 0; sign = 1; ret = TRUE; digits = FALSE; + number = 0; ret = TRUE; digits = FALSE; while (i_isspace(*time)) time++; - if (*time == '-') { - sign = -sign; - time++; - while (i_isspace(*time)) - time++; - } for (;;) { if (i_isdigit(*time)) { char *endptr; @@ -824,7 +835,6 @@ static int parse_time_interval_uint(const char *time, guint *msecs) if (*time != '\0') return FALSE; *msecs += number * 1000; /* assume seconds */ - *msecs *= sign; return TRUE; } @@ -862,7 +872,6 @@ static int parse_time_interval_uint(const char *time, guint *msecs) digits = FALSE; } - *msecs *= sign; return ret; } @@ -956,15 +965,18 @@ int parse_size(const char *size, int *bytes) int parse_time_interval(const char *time, int *msecs) { guint msecs_; - int ret; + char *number; + int ret, sign; + + parse_number_sign(time, &number, &sign); - ret = parse_time_interval_uint(time, &msecs_); + ret = parse_time_interval_uint(number, &msecs_); if (msecs_ > (1U << 31)) { return FALSE; } - *msecs = msecs_; + *msecs = msecs_ * sign; return ret; } diff --git a/src/fe-common/core/chat-completion.c b/src/fe-common/core/chat-completion.c index 1f00feaf..97cd0565 100644 --- a/src/fe-common/core/chat-completion.c +++ b/src/fe-common/core/chat-completion.c @@ -1011,13 +1011,17 @@ static void sig_complete_target(GList **list, WINDOW_REC *window, } } +static void event_text(const char *data, SERVER_REC *server, WI_ITEM_REC *item); + /* expand \n, \t and \\ */ static char *expand_escapes(const char *line, SERVER_REC *server, WI_ITEM_REC *item) { char *ptr, *ret; - int chr; + const char *prev; + int chr; + prev = line; ret = ptr = g_malloc(strlen(line)+1); for (; *line != '\0'; line++) { if (*line != '\\') { @@ -1036,9 +1040,11 @@ static char *expand_escapes(const char *line, SERVER_REC *server, /* newline .. we need to send another "send text" event to handle it (or actually the text before the newline..) */ - if (ret != ptr) { - *ptr = '\0'; - signal_emit("send text", 3, ret, server, item); + if (prev != line) { + char *prev_line = g_strndup(prev, (line - prev) - 1); + event_text(prev_line, server, item); + g_free(prev_line); + prev = line + 1; ptr = ret; } } else if (chr != -1) { diff --git a/src/fe-common/core/completion.c b/src/fe-common/core/completion.c index a97adc21..78b1b24b 100644 --- a/src/fe-common/core/completion.c +++ b/src/fe-common/core/completion.c @@ -137,8 +137,9 @@ char *word_complete(WINDOW_REC *window, const char *line, int *pos, int erase, i int old_startpos, old_wordlen; GString *result; - char *word, *wordstart, *linestart, *ret; - int continue_complete, want_space; + const char *cmdchars; + char *word, *wordstart, *linestart, *ret, *data; + int continue_complete, want_space, expand_escapes; g_return_val_if_fail(line != NULL, NULL); g_return_val_if_fail(pos != NULL, NULL); @@ -241,14 +242,24 @@ char *word_complete(WINDOW_REC *window, const char *line, int *pos, int erase, i if (complist == NULL) return NULL; + /* get the cmd char */ + cmdchars = settings_get_str("cmdchars"); + + /* get the expand_escapes setting */ + expand_escapes = settings_get_bool("expand_escapes"); + + /* escape if the word doesn't begin with '/' and expand_escapes are turned on */ + data = strchr(cmdchars, *line) == NULL && expand_escapes ? + escape_string(complist->data) : g_strdup(complist->data); + /* word completed */ - *pos = startpos+strlen(complist->data); + *pos = startpos + strlen(data); /* replace the word in line - we need to return a full new line */ result = g_string_new(line); g_string_erase(result, startpos, wordlen); - g_string_insert(result, startpos, complist->data); + g_string_insert(result, startpos, data); if (want_space) { if (!isseparator(result->str[*pos])) @@ -256,13 +267,17 @@ char *word_complete(WINDOW_REC *window, const char *line, int *pos, int erase, i (*pos)++; } - wordlen = strlen(complist->data); + wordlen = strlen(data); last_line_pos = *pos; g_free_not_null(last_line); last_line = g_strdup(result->str); ret = result->str; g_string_free(result, FALSE); + + /* free the data */ + g_free(data); + return ret; } diff --git a/src/fe-common/core/fe-server.c b/src/fe-common/core/fe-server.c index e8e9f33f..810afe83 100644 --- a/src/fe-common/core/fe-server.c +++ b/src/fe-common/core/fe-server.c @@ -117,7 +117,18 @@ static void cmd_server_add_modify(const char *data, gboolean add) return; if (*addr == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); - port = *portstr == '\0' ? DEFAULT_SERVER_ADD_PORT : atoi(portstr); + + value = g_hash_table_lookup(optlist, "port"); + + if (*portstr != '\0') + port = atoi(portstr); + else if (value != NULL && *value != '\0') + port = atoi(value); + else if (g_hash_table_lookup(optlist, "tls") || + g_hash_table_lookup(optlist, "ssl")) + port = DEFAULT_SERVER_ADD_TLS_PORT; + else + port = DEFAULT_SERVER_ADD_PORT; chatnet = g_hash_table_lookup(optlist, "network"); @@ -139,8 +150,8 @@ static void cmd_server_add_modify(const char *data, gboolean add) rec->address = g_strdup(addr); rec->port = port; } else { - value = g_hash_table_lookup(optlist, "port"); - if (value != NULL && *value != '\0') rec->port = atoi(value); + if (*portstr != '\0' || g_hash_table_lookup(optlist, "port")) + rec->port = port; if (*password != '\0') g_free_and_null(rec->password); if (g_hash_table_lookup(optlist, "host")) { diff --git a/src/fe-text/term-terminfo.c b/src/fe-text/term-terminfo.c index 3098a4e4..bca37efc 100644 --- a/src/fe-text/term-terminfo.c +++ b/src/fe-text/term-terminfo.c @@ -102,6 +102,17 @@ static GSourceFuncs sigcont_funcs = { .dispatch = sigcont_dispatch }; +static void term_atexit(void) +{ + if (!quitting && current_term && current_term->TI_rmcup) { + /* Unexpected exit, avoid switching out of alternate screen + to keep any on-screen errors (like noperl_die()'s) */ + current_term->TI_rmcup = NULL; + } + + term_deinit(); +} + int term_init(void) { struct sigaction act; @@ -140,7 +151,7 @@ int term_init(void) term_set_input_type(TERM_TYPE_8BIT); term_common_init(); - atexit(term_deinit); + atexit(term_atexit); return TRUE; } |