1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-27 13:26:38 +02:00

Fixed some portability bugs (patch #5271)

This commit is contained in:
Sebastien Helleu
2006-10-12 17:16:14 +00:00
parent 481e6f8e7f
commit 9b91c91577
16 changed files with 38 additions and 28 deletions
+1
View File
@@ -5,6 +5,7 @@ ChangeLog - 2006-10-12
Version 0.2.2 (under dev!):
* fixed some portability bugs (patch #5271)
* fixed iconv detection for BSD (patch #5456)
* fixed typo in configure.in (bash specific test) (patch #5450)
* mode changes with /op, /deop, /voice, /devoice, /halfop, /dehalfop are
+4
View File
@@ -28,7 +28,11 @@
#include <unistd.h>
#include <string.h>
#include <stdarg.h>
#ifdef HAVE_FLOCK
#include <sys/file.h>
#endif
#include <sys/types.h>
#include <time.h>
+3 -3
View File
@@ -1873,7 +1873,7 @@ config_read ()
return -2;
snprintf (filename, filename_length, "%s%s" WEECHAT_CONFIG_NAME,
weechat_home, DIR_SEPARATOR);
if ((file = fopen (filename, "rt")) == NULL)
if ((file = fopen (filename, "r")) == NULL)
{
gui_printf (NULL, _("%s config file \"%s\" not found.\n"),
WEECHAT_WARNING, filename);
@@ -2158,7 +2158,7 @@ config_create_default ()
return -2;
snprintf (filename, filename_length, "%s%s" WEECHAT_CONFIG_NAME,
weechat_home, DIR_SEPARATOR);
if ((file = fopen (filename, "wt")) == NULL)
if ((file = fopen (filename, "w")) == NULL)
{
gui_printf (NULL, _("%s cannot create file \"%s\"\n"),
WEECHAT_ERROR, filename);
@@ -2365,7 +2365,7 @@ config_write (char *config_name)
weechat_home, DIR_SEPARATOR);
}
if ((file = fopen (filename, "wt")) == NULL)
if ((file = fopen (filename, "w")) == NULL)
{
gui_printf (NULL, _("%s cannot create file \"%s\"\n"),
WEECHAT_ERROR, filename);
+2 -3
View File
@@ -67,7 +67,6 @@ gui_main_loop ()
{
fd_set read_fd;
static struct timeval timeout, tv;
static struct timezone tz;
t_irc_server *ptr_server;
t_gui_buffer *ptr_buffer;
int old_day, old_min, old_sec, diff;
@@ -219,14 +218,14 @@ gui_main_loop ()
&& (new_time >= ptr_server->lag_next_check))
{
server_sendf (ptr_server, "PING %s\r\n", ptr_server->address);
gettimeofday (&(ptr_server->lag_check_time), &tz);
gettimeofday (&(ptr_server->lag_check_time), NULL);
}
/* lag timeout => disconnect */
if ((ptr_server->lag_check_time.tv_sec != 0)
&& (cfg_irc_lag_disconnect > 0))
{
gettimeofday (&tv, &tz);
gettimeofday (&tv, NULL);
diff = (int) get_timeval_diff (&(ptr_server->lag_check_time), &tv);
if (diff / 1000 > cfg_irc_lag_disconnect * 60)
{
+2 -4
View File
@@ -856,7 +856,6 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *nick, char *argumen
{
char *host2, *pos, *pos2, *pos_usec;
struct timeval tv;
struct timezone tz;
long sec1, usec1, sec2, usec2, difftime;
t_irc_channel *ptr_channel;
int highlight;
@@ -922,7 +921,7 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *nick, char *argumen
{
pos2[0] = '\0';
gettimeofday (&tv, &tz);
gettimeofday (&tv, NULL);
sec1 = atol (pos);
usec1 = atol (pos_usec);
sec2 = tv.tv_sec;
@@ -1191,7 +1190,6 @@ int
irc_cmd_recv_pong (t_irc_server *server, char *host, char *nick, char *arguments)
{
struct timeval tv;
struct timezone tz;
int old_lag;
/* make gcc happy */
@@ -1203,7 +1201,7 @@ irc_cmd_recv_pong (t_irc_server *server, char *host, char *nick, char *arguments
{
/* calculate lag (time diff with lag check) */
old_lag = server->lag;
gettimeofday (&tv, &tz);
gettimeofday (&tv, NULL);
server->lag = (int) get_timeval_diff (&(server->lag_check_time), &tv);
if (old_lag != server->lag)
gui_status_draw (gui_current_window->buffer, 1);
+1 -2
View File
@@ -458,7 +458,6 @@ irc_cmd_send_ctcp (t_irc_server *server, t_irc_channel *channel,
{
char *pos_type, *pos_args, *pos;
struct timeval tv;
struct timezone tz;
/* make gcc happy */
(void) channel;
@@ -500,7 +499,7 @@ irc_cmd_send_ctcp (t_irc_server *server, t_irc_channel *channel,
if ((ascii_strcasecmp (pos_type, "ping") == 0) && (!pos_args))
{
gettimeofday (&tv, &tz);
gettimeofday (&tv, NULL);
server_sendf (server, "PRIVMSG %s :\01PING %d %d\01\r\n",
arguments, tv.tv_sec, tv.tv_usec);
gui_printf (server->buffer, " %s%d %d\n",
+4
View File
@@ -36,6 +36,10 @@
#include "../gui/gui.h"
#ifndef NI_MAXHOST
#define NI_MAXHOST 256
#endif
/* prefixes for chat window */
#define PREFIX_SERVER "-@-"
+2 -2
View File
@@ -240,7 +240,7 @@ plugin_config_read ()
return;
snprintf (filename, filename_length, "%s%s" WEECHAT_PLUGINS_CONFIG_NAME,
weechat_home, DIR_SEPARATOR);
if ((file = fopen (filename, "rt")) == NULL)
if ((file = fopen (filename, "r")) == NULL)
return;
line_number = 0;
@@ -347,7 +347,7 @@ plugin_config_write ()
snprintf (filename, filename_length, "%s%s" WEECHAT_PLUGINS_CONFIG_NAME,
weechat_home, DIR_SEPARATOR);
if ((file = fopen (filename, "wt")) == NULL)
if ((file = fopen (filename, "w")) == NULL)
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s cannot create file \"%s\"\n"),
+1
View File
@@ -5,6 +5,7 @@ ChangeLog - 2006-10-12
Version 0.2.2 (under dev!):
* fixed some portability bugs (patch #5271)
* fixed iconv detection for BSD (patch #5456)
* fixed typo in configure.in (bash specific test) (patch #5450)
* mode changes with /op, /deop, /voice, /devoice, /halfop, /dehalfop are
+4
View File
@@ -28,7 +28,11 @@
#include <unistd.h>
#include <string.h>
#include <stdarg.h>
#ifdef HAVE_FLOCK
#include <sys/file.h>
#endif
#include <sys/types.h>
#include <time.h>
+3 -3
View File
@@ -1873,7 +1873,7 @@ config_read ()
return -2;
snprintf (filename, filename_length, "%s%s" WEECHAT_CONFIG_NAME,
weechat_home, DIR_SEPARATOR);
if ((file = fopen (filename, "rt")) == NULL)
if ((file = fopen (filename, "r")) == NULL)
{
gui_printf (NULL, _("%s config file \"%s\" not found.\n"),
WEECHAT_WARNING, filename);
@@ -2158,7 +2158,7 @@ config_create_default ()
return -2;
snprintf (filename, filename_length, "%s%s" WEECHAT_CONFIG_NAME,
weechat_home, DIR_SEPARATOR);
if ((file = fopen (filename, "wt")) == NULL)
if ((file = fopen (filename, "w")) == NULL)
{
gui_printf (NULL, _("%s cannot create file \"%s\"\n"),
WEECHAT_ERROR, filename);
@@ -2365,7 +2365,7 @@ config_write (char *config_name)
weechat_home, DIR_SEPARATOR);
}
if ((file = fopen (filename, "wt")) == NULL)
if ((file = fopen (filename, "w")) == NULL)
{
gui_printf (NULL, _("%s cannot create file \"%s\"\n"),
WEECHAT_ERROR, filename);
+2 -3
View File
@@ -67,7 +67,6 @@ gui_main_loop ()
{
fd_set read_fd;
static struct timeval timeout, tv;
static struct timezone tz;
t_irc_server *ptr_server;
t_gui_buffer *ptr_buffer;
int old_day, old_min, old_sec, diff;
@@ -219,14 +218,14 @@ gui_main_loop ()
&& (new_time >= ptr_server->lag_next_check))
{
server_sendf (ptr_server, "PING %s\r\n", ptr_server->address);
gettimeofday (&(ptr_server->lag_check_time), &tz);
gettimeofday (&(ptr_server->lag_check_time), NULL);
}
/* lag timeout => disconnect */
if ((ptr_server->lag_check_time.tv_sec != 0)
&& (cfg_irc_lag_disconnect > 0))
{
gettimeofday (&tv, &tz);
gettimeofday (&tv, NULL);
diff = (int) get_timeval_diff (&(ptr_server->lag_check_time), &tv);
if (diff / 1000 > cfg_irc_lag_disconnect * 60)
{
+2 -4
View File
@@ -856,7 +856,6 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *nick, char *argumen
{
char *host2, *pos, *pos2, *pos_usec;
struct timeval tv;
struct timezone tz;
long sec1, usec1, sec2, usec2, difftime;
t_irc_channel *ptr_channel;
int highlight;
@@ -922,7 +921,7 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *nick, char *argumen
{
pos2[0] = '\0';
gettimeofday (&tv, &tz);
gettimeofday (&tv, NULL);
sec1 = atol (pos);
usec1 = atol (pos_usec);
sec2 = tv.tv_sec;
@@ -1191,7 +1190,6 @@ int
irc_cmd_recv_pong (t_irc_server *server, char *host, char *nick, char *arguments)
{
struct timeval tv;
struct timezone tz;
int old_lag;
/* make gcc happy */
@@ -1203,7 +1201,7 @@ irc_cmd_recv_pong (t_irc_server *server, char *host, char *nick, char *arguments
{
/* calculate lag (time diff with lag check) */
old_lag = server->lag;
gettimeofday (&tv, &tz);
gettimeofday (&tv, NULL);
server->lag = (int) get_timeval_diff (&(server->lag_check_time), &tv);
if (old_lag != server->lag)
gui_status_draw (gui_current_window->buffer, 1);
+1 -2
View File
@@ -458,7 +458,6 @@ irc_cmd_send_ctcp (t_irc_server *server, t_irc_channel *channel,
{
char *pos_type, *pos_args, *pos;
struct timeval tv;
struct timezone tz;
/* make gcc happy */
(void) channel;
@@ -500,7 +499,7 @@ irc_cmd_send_ctcp (t_irc_server *server, t_irc_channel *channel,
if ((ascii_strcasecmp (pos_type, "ping") == 0) && (!pos_args))
{
gettimeofday (&tv, &tz);
gettimeofday (&tv, NULL);
server_sendf (server, "PRIVMSG %s :\01PING %d %d\01\r\n",
arguments, tv.tv_sec, tv.tv_usec);
gui_printf (server->buffer, " %s%d %d\n",
+4
View File
@@ -36,6 +36,10 @@
#include "../gui/gui.h"
#ifndef NI_MAXHOST
#define NI_MAXHOST 256
#endif
/* prefixes for chat window */
#define PREFIX_SERVER "-@-"
+2 -2
View File
@@ -240,7 +240,7 @@ plugin_config_read ()
return;
snprintf (filename, filename_length, "%s%s" WEECHAT_PLUGINS_CONFIG_NAME,
weechat_home, DIR_SEPARATOR);
if ((file = fopen (filename, "rt")) == NULL)
if ((file = fopen (filename, "r")) == NULL)
return;
line_number = 0;
@@ -347,7 +347,7 @@ plugin_config_write ()
snprintf (filename, filename_length, "%s%s" WEECHAT_PLUGINS_CONFIG_NAME,
weechat_home, DIR_SEPARATOR);
if ((file = fopen (filename, "wt")) == NULL)
if ((file = fopen (filename, "w")) == NULL)
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s cannot create file \"%s\"\n"),