summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2006-07-16 16:44:58 +0000
committerSebastien Helleu <flashcode@flashtux.org>2006-07-16 16:44:58 +0000
commita0e5c4567b7c22586c9e14b7f39fadf1a53dd7a5 (patch)
tree006d75bb14998356718f26642343e4e49b07eca4
parentadded some panel functions, fixed refresh bugs when terminal is resized: too many refreshs, display bug with splited windows (diff)
downloadweechat-a0e5c4567b7c22586c9e14b7f39fadf1a53dd7a5.tar.xz
weechat-a0e5c4567b7c22586c9e14b7f39fadf1a53dd7a5.zip
Fixed crash on DCC buffer under Darwin 8 (bug #17115)
-rw-r--r--ChangeLog1
-rw-r--r--src/gui/curses/gui-curses-chat.c31
-rw-r--r--weechat/ChangeLog1
-rw-r--r--weechat/src/gui/curses/gui-curses-chat.c31
4 files changed, 48 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 78b20ae55..e5c914999 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@ WeeChat - Wee Enhanced Environment for Chat
ChangeLog - 2006-07-16
Version 0.2.0 (under dev!):
+ * fixed crash on DCC buffer under Darwin 8 (bug #17115)
* added configure option for doc XSL prefix (bug #16991)
* fixed bug with spaces in script names (bug #16957)
* fixed random crash when "MODE #chan -l" is received
diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c
index c0e1c1d49..0fd86c6ad 100644
--- a/src/gui/curses/gui-curses-chat.c
+++ b/src/gui/curses/gui-curses-chat.c
@@ -876,9 +876,10 @@ gui_chat_draw (t_gui_buffer *buffer, int erase)
t_irc_dcc *dcc_first, *dcc_selected, *ptr_dcc;
char format_empty[32];
int i, j, line_pos, count, num_bars;
+ unsigned long pct_complete;
char *unit_name[] = { N_("bytes"), N_("Kb"), N_("Mb"), N_("Gb") };
- char *unit_format[] = { "%.0Lf", "%.1Lf", "%.02Lf", "%.02Lf" };
- long unit_divide[] = { 1, 1024, 1024*1024, 1024*1024*1024 };
+ char *unit_format[] = { "%.0f", "%.1f", "%.02f", "%.02f" };
+ float unit_divide[] = { 1, 1024, 1024*1024, 1024*1024*1024 };
int num_unit;
char format[32], date[128], *buf;
struct tm *date_tmp;
@@ -956,9 +957,14 @@ gui_chat_draw (t_gui_buffer *buffer, int erase)
{
wprintw (GUI_CURSES(ptr_win)->win_chat, " [");
if (ptr_dcc->size == 0)
- num_bars = 10;
+ {
+ if (ptr_dcc->status == DCC_DONE)
+ num_bars = 10;
+ else
+ num_bars = 0;
+ }
else
- num_bars = (int)((((long double)(ptr_dcc->pos)/(long double)(ptr_dcc->size))*100) / 10);
+ num_bars = (int)((((float)(ptr_dcc->pos)/(float)(ptr_dcc->size))*100) / 10);
for (j = 0; j < num_bars - 1; j++)
wprintw (GUI_CURSES(ptr_win)->win_chat, "=");
if (num_bars > 0)
@@ -974,15 +980,24 @@ gui_chat_draw (t_gui_buffer *buffer, int erase)
num_unit = 2;
else
num_unit = 3;
+ if (ptr_dcc->size == 0)
+ {
+ if (ptr_dcc->status == DCC_DONE)
+ pct_complete = 100;
+ else
+ pct_complete = 0;
+ }
+ else
+ pct_complete = (unsigned long)(((float)(ptr_dcc->pos)/(float)(ptr_dcc->size))*100);
wprintw (GUI_CURSES(ptr_win)->win_chat, "] %3lu%% ",
- (unsigned long)(((long double)(ptr_dcc->pos)/(long double)(ptr_dcc->size))*100));
+ pct_complete);
sprintf (format, "%s %%s / %s %%s",
unit_format[num_unit],
unit_format[num_unit]);
wprintw (GUI_CURSES(ptr_win)->win_chat, format,
- ((long double)(ptr_dcc->pos)) / ((long double)(unit_divide[num_unit])),
+ ((float)(ptr_dcc->pos)) / ((float)(unit_divide[num_unit])),
unit_name[num_unit],
- ((long double)(ptr_dcc->size)) / ((long double)(unit_divide[num_unit])),
+ ((float)(ptr_dcc->size)) / ((float)(unit_divide[num_unit])),
unit_name[num_unit]);
if (ptr_dcc->bytes_per_sec < 1024*1024)
@@ -1005,7 +1020,7 @@ gui_chat_draw (t_gui_buffer *buffer, int erase)
CHANNEL(buffer),
unit_name[num_unit]);
wprintw (GUI_CURSES(ptr_win)->win_chat, format,
- ((long double) ptr_dcc->bytes_per_sec) / ((long double)(unit_divide[num_unit])),
+ ((float)ptr_dcc->bytes_per_sec) / ((float)(unit_divide[num_unit])),
buf);
free (buf);
}
diff --git a/weechat/ChangeLog b/weechat/ChangeLog
index 78b20ae55..e5c914999 100644
--- a/weechat/ChangeLog
+++ b/weechat/ChangeLog
@@ -4,6 +4,7 @@ WeeChat - Wee Enhanced Environment for Chat
ChangeLog - 2006-07-16
Version 0.2.0 (under dev!):
+ * fixed crash on DCC buffer under Darwin 8 (bug #17115)
* added configure option for doc XSL prefix (bug #16991)
* fixed bug with spaces in script names (bug #16957)
* fixed random crash when "MODE #chan -l" is received
diff --git a/weechat/src/gui/curses/gui-curses-chat.c b/weechat/src/gui/curses/gui-curses-chat.c
index c0e1c1d49..0fd86c6ad 100644
--- a/weechat/src/gui/curses/gui-curses-chat.c
+++ b/weechat/src/gui/curses/gui-curses-chat.c
@@ -876,9 +876,10 @@ gui_chat_draw (t_gui_buffer *buffer, int erase)
t_irc_dcc *dcc_first, *dcc_selected, *ptr_dcc;
char format_empty[32];
int i, j, line_pos, count, num_bars;
+ unsigned long pct_complete;
char *unit_name[] = { N_("bytes"), N_("Kb"), N_("Mb"), N_("Gb") };
- char *unit_format[] = { "%.0Lf", "%.1Lf", "%.02Lf", "%.02Lf" };
- long unit_divide[] = { 1, 1024, 1024*1024, 1024*1024*1024 };
+ char *unit_format[] = { "%.0f", "%.1f", "%.02f", "%.02f" };
+ float unit_divide[] = { 1, 1024, 1024*1024, 1024*1024*1024 };
int num_unit;
char format[32], date[128], *buf;
struct tm *date_tmp;
@@ -956,9 +957,14 @@ gui_chat_draw (t_gui_buffer *buffer, int erase)
{
wprintw (GUI_CURSES(ptr_win)->win_chat, " [");
if (ptr_dcc->size == 0)
- num_bars = 10;
+ {
+ if (ptr_dcc->status == DCC_DONE)
+ num_bars = 10;
+ else
+ num_bars = 0;
+ }
else
- num_bars = (int)((((long double)(ptr_dcc->pos)/(long double)(ptr_dcc->size))*100) / 10);
+ num_bars = (int)((((float)(ptr_dcc->pos)/(float)(ptr_dcc->size))*100) / 10);
for (j = 0; j < num_bars - 1; j++)
wprintw (GUI_CURSES(ptr_win)->win_chat, "=");
if (num_bars > 0)
@@ -974,15 +980,24 @@ gui_chat_draw (t_gui_buffer *buffer, int erase)
num_unit = 2;
else
num_unit = 3;
+ if (ptr_dcc->size == 0)
+ {
+ if (ptr_dcc->status == DCC_DONE)
+ pct_complete = 100;
+ else
+ pct_complete = 0;
+ }
+ else
+ pct_complete = (unsigned long)(((float)(ptr_dcc->pos)/(float)(ptr_dcc->size))*100);
wprintw (GUI_CURSES(ptr_win)->win_chat, "] %3lu%% ",
- (unsigned long)(((long double)(ptr_dcc->pos)/(long double)(ptr_dcc->size))*100));
+ pct_complete);
sprintf (format, "%s %%s / %s %%s",
unit_format[num_unit],
unit_format[num_unit]);
wprintw (GUI_CURSES(ptr_win)->win_chat, format,
- ((long double)(ptr_dcc->pos)) / ((long double)(unit_divide[num_unit])),
+ ((float)(ptr_dcc->pos)) / ((float)(unit_divide[num_unit])),
unit_name[num_unit],
- ((long double)(ptr_dcc->size)) / ((long double)(unit_divide[num_unit])),
+ ((float)(ptr_dcc->size)) / ((float)(unit_divide[num_unit])),
unit_name[num_unit]);
if (ptr_dcc->bytes_per_sec < 1024*1024)
@@ -1005,7 +1020,7 @@ gui_chat_draw (t_gui_buffer *buffer, int erase)
CHANNEL(buffer),
unit_name[num_unit]);
wprintw (GUI_CURSES(ptr_win)->win_chat, format,
- ((long double) ptr_dcc->bytes_per_sec) / ((long double)(unit_divide[num_unit])),
+ ((float)ptr_dcc->bytes_per_sec) / ((float)(unit_divide[num_unit])),
buf);
free (buf);
}