mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Win32 fixes - Irssi now compiles with MSVC++ :)
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@851 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
14e5dc8b8e
commit
e3084d3ffa
@ -117,10 +117,13 @@ int ignore_check(SERVER_REC *server, const char *nick, const char *host,
|
||||
if (patt_len <= best_patt) continue;
|
||||
}
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (rec->regexp) {
|
||||
ok = !rec->regexp_compiled ? FALSE :
|
||||
regexec(&rec->preg, text, 0, NULL, 0) == 0;
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
ok = rec->fullword ?
|
||||
stristr_full(text, rec->pattern) != NULL :
|
||||
stristr(text, rec->pattern) != NULL;
|
||||
@ -257,10 +260,11 @@ static void ignore_remove_config(IGNORE_REC *rec)
|
||||
|
||||
void ignore_add_rec(IGNORE_REC *rec)
|
||||
{
|
||||
#ifdef HAVE_REGEX_H
|
||||
rec->regexp_compiled = !rec->regexp || rec->pattern == NULL ? FALSE :
|
||||
regcomp(&rec->preg, rec->pattern,
|
||||
REG_EXTENDED|REG_ICASE|REG_NOSUB) == 0;
|
||||
|
||||
#endif
|
||||
ignores = g_slist_append(ignores, rec);
|
||||
ignore_set_config(rec);
|
||||
|
||||
@ -272,7 +276,9 @@ static void ignore_destroy(IGNORE_REC *rec)
|
||||
ignores = g_slist_remove(ignores, rec);
|
||||
signal_emit("ignore destroyed", 1, rec);
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (rec->regexp_compiled) regfree(&rec->preg);
|
||||
#endif
|
||||
if (rec->time_tag > 0) g_source_remove(rec->time_tag);
|
||||
if (rec->channels != NULL) g_strfreev(rec->channels);
|
||||
g_free_not_null(rec->mask);
|
||||
|
@ -185,7 +185,8 @@ static void show_help(const char *data)
|
||||
if (last != NULL && g_strcasecmp(rec->cmd, last->cmd) == 0)
|
||||
continue; /* don't display same command twice */
|
||||
|
||||
if (strlen(rec->cmd) >= findlen && g_strncasecmp(rec->cmd, data, findlen) == 0)
|
||||
if ((int)strlen(rec->cmd) >= findlen &&
|
||||
g_strncasecmp(rec->cmd, data, findlen) == 0)
|
||||
{
|
||||
if (rec->cmd[findlen] == '\0')
|
||||
{
|
||||
@ -306,8 +307,8 @@ static void cmd_cat(const char *data)
|
||||
/* SYNTAX: EXEC <cmd line> */
|
||||
static void cmd_exec(const char *cmdline)
|
||||
{
|
||||
int buflen = 512;
|
||||
char tmpbuf[buflen];
|
||||
#ifndef WIN32
|
||||
char tmpbuf[512];
|
||||
char *foo;
|
||||
FILE *stream;
|
||||
|
||||
@ -320,7 +321,7 @@ static void cmd_exec(const char *cmdline)
|
||||
return;
|
||||
}
|
||||
|
||||
while (fgets(tmpbuf, buflen, stream)) {
|
||||
while (fgets(tmpbuf, sizeof(tmpbuf), stream)) {
|
||||
/* strip \n characters appended from fgets
|
||||
This is safer than using gets, though it is more work tbd
|
||||
*/
|
||||
@ -337,9 +338,9 @@ static void cmd_exec(const char *cmdline)
|
||||
}
|
||||
|
||||
pclose(stream);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* SYNTAX: BEEP */
|
||||
static void cmd_beep(void)
|
||||
{
|
||||
|
@ -33,7 +33,9 @@
|
||||
#include "gui-entry.h"
|
||||
#include "gui-windows.h"
|
||||
|
||||
#include <regex.h>
|
||||
#ifdef HAVE_REGEX_H
|
||||
# include <regex.h>
|
||||
#endif
|
||||
|
||||
/* how often to scan line cache for lines not accessed for a while (ms) */
|
||||
#define LINE_CACHE_CHECK_TIME (5*60*1000)
|
||||
@ -740,7 +742,9 @@ static void signal_window_item_update(WINDOW_REC *window)
|
||||
|
||||
GList *gui_window_find_text(WINDOW_REC *window, gchar *text, GList *startline, int regexp, int fullword)
|
||||
{
|
||||
#ifdef HAVE_REGEX_H
|
||||
regex_t preg;
|
||||
#endif
|
||||
GList *tmp;
|
||||
GList *matches;
|
||||
gchar *str, *ptr;
|
||||
@ -751,8 +755,10 @@ GList *gui_window_find_text(WINDOW_REC *window, gchar *text, GList *startline, i
|
||||
|
||||
matches = NULL; size = 1024; str = g_malloc(1024);
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (regcomp(&preg, text, REG_ICASE|REG_EXTENDED|REG_NOSUB) != 0)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
if (startline == NULL) startline = WINDOW_GUI(window)->lines;
|
||||
for (tmp = startline; tmp != NULL; tmp = tmp->next)
|
||||
@ -790,15 +796,19 @@ GList *gui_window_find_text(WINDOW_REC *window, gchar *text, GList *startline, i
|
||||
}
|
||||
str[n] = '\0';
|
||||
|
||||
if (regexp ? regexec(&preg, str, 0, NULL, 0) == 0 :
|
||||
if (
|
||||
#ifdef HAVE_REGEX_H
|
||||
regexp ? regexec(&preg, str, 0, NULL, 0) == 0 :
|
||||
#endif
|
||||
fullword ? stristr_full(str, text) != NULL :
|
||||
stristr(str, text) != NULL) {
|
||||
/* matched */
|
||||
matches = g_list_append(matches, rec);
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_REGEX_H
|
||||
regfree(&preg);
|
||||
|
||||
#endif
|
||||
if (str != NULL) g_free(str);
|
||||
return matches;
|
||||
}
|
||||
|
@ -90,12 +90,14 @@ static void read_signals(void)
|
||||
const char *ignores;
|
||||
|
||||
ignores = settings_get_str("ignore_signals");
|
||||
#ifndef WIN32
|
||||
signal(SIGHUP, find_substr(ignores, "hup") ? SIG_IGN : SIG_DFL);
|
||||
signal(SIGQUIT, find_substr(ignores, "quit") ? SIG_IGN : SIG_DFL);
|
||||
signal(SIGTERM, find_substr(ignores, "term") ? SIG_IGN : SIG_DFL);
|
||||
signal(SIGALRM, find_substr(ignores, "alrm") ? SIG_IGN : SIG_DFL);
|
||||
signal(SIGUSR1, find_substr(ignores, "usr1") ? SIG_IGN : SIG_DFL);
|
||||
signal(SIGUSR2, find_substr(ignores, "usr2") ? SIG_IGN : SIG_DFL);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void read_settings(void)
|
||||
@ -111,7 +113,9 @@ static int init_curses(void)
|
||||
{
|
||||
char ansi_tab[8] = { 0, 4, 2, 6, 1, 5, 3, 7 };
|
||||
int num;
|
||||
#ifndef WIN32
|
||||
struct sigaction act;
|
||||
#endif
|
||||
|
||||
if (!initscr())
|
||||
return FALSE;
|
||||
@ -119,10 +123,12 @@ static int init_curses(void)
|
||||
if (COLS < MIN_SCREEN_WIDTH)
|
||||
COLS = MIN_SCREEN_WIDTH;
|
||||
|
||||
#ifndef WIN32
|
||||
sigemptyset (&act.sa_mask);
|
||||
act.sa_flags = 0;
|
||||
act.sa_handler = sigint_handler;
|
||||
sigaction(SIGINT, &act, NULL);
|
||||
#endif
|
||||
#ifdef SIGWINCH
|
||||
act.sa_handler = sig_winch;
|
||||
sigaction(SIGWINCH, &act, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user