diff --git a/include/progind.cpp b/include/progind.cpp
index b4ab86320..7c143b497 100755
--- a/include/progind.cpp
+++ b/include/progind.cpp
@@ -127,6 +127,15 @@ RCT* TIndwin::get_bar_rct(RCT& r) const
return &r;
}
+void TIndwin::sec2str(unsigned long ss, TString& str) const
+{
+ const unsigned long hh = ss / 3600;
+ ss -= hh*3600;
+ const unsigned long mm = ss / 60;
+ ss -= mm *60;
+ str.format("%02ld:%02ld:%02ld", hh, mm, ss);
+}
+
void TIndwin::update_bar()
{
if (_status >= _max)
@@ -156,19 +165,6 @@ void TIndwin::update_bar()
const int lasti = (b.bottom-b.top)/2;
for (int i = 0; i <= lasti; i++)
{
-/*
- set_pen(blend_colors(FOCUS_BACK_COLOR, MASK_BACK_COLOR, double(i) / double(lasti)));
- PNT pt = { b.top+i, b.left };
- xvt_dwin_draw_set_pos(w, pt);
- pt.h = b.right;
- xvt_dwin_draw_line(w, pt);
-
- pt.h = b.left;
- pt.v = b.bottom-i-1;
- xvt_dwin_draw_set_pos(w, pt);
- pt.h = b.right;
- xvt_dwin_draw_line(w, pt);
-*/
const short cy = b.top + (b.bottom-b.top)/4;
RCT g = b; g.bottom = cy;
xvt_dwin_draw_gradient_linear(w, &g, BTN_LIGHT_COLOR, BTN_BACK_COLOR, 90);
@@ -179,16 +175,14 @@ void TIndwin::update_bar()
if (prc > 0)
{
const unsigned long elapsed_time = (clock() - _start_time)/CLOCKS_PER_SEC;
- const unsigned long total_time = (unsigned long)(elapsed_time / prc);
- unsigned long ss = total_time - elapsed_time;
- const unsigned long hh = ss / 3600;
- ss -= hh*3600;
- const unsigned long mm = ss / 60;
- ss -= mm *60;
+ const unsigned long total_time = (unsigned long)(elapsed_time / prc + 0.5);
+ TString8 str_res, str_tot;
+ sec2str(total_time - elapsed_time, str_res);
+ sec2str(total_time, str_tot);
+
TString80 n;
- n.format("%d%% - %s %02lu:%02lu:%02lu",
- int(prc*100.0+0.5), TR("Tempo residuo stimato"), hh, mm, ss);
-
+ n.format("%d%% - %s %s - %s %s", int(prc*100.0+0.5),
+ TR("Tempo residuo"), (const char*)str_res, TR("Tempo totale"), (const char*)str_tot);
b = r;
b.top = b.bottom+2;
b.bottom = b.top + CHARY;
diff --git a/include/progind.h b/include/progind.h
index 1905bc645..1b5ce40a0 100755
--- a/include/progind.h
+++ b/include/progind.h
@@ -54,6 +54,9 @@ protected:
// @cmember Calcola il rettangolo della barra di attesa
RCT* get_bar_rct(RCT& r) const;
+ // @cmember converte secondi in una stringa nel formato hh:mm:ss
+ void sec2str(unsigned long ss, TString& str) const;
+
// @cmember Gestisce gli eventi tasto della finestra
virtual bool on_key(KEY k);
diff --git a/include/reprint.cpp b/include/reprint.cpp
index a99530377..d41e73b46 100755
--- a/include/reprint.cpp
+++ b/include/reprint.cpp
@@ -17,6 +17,12 @@
static bool _print_aborted = false;
+#if _MSC_VER >= 1400
+ #define SAFE_SCAN sscanf_s
+#else
+ #define SAFE_SCAN sscanf
+#endif
+
///////////////////////////////////////////////////////////
// Utility
///////////////////////////////////////////////////////////
@@ -1296,7 +1302,7 @@ bool TBook::print_page(TWindow& win, size_t page)
{
COLOR col = COLOR_BLACK;
PAT_STYLE pat = PAT_SOLID;
- sscanf(str, "", &col, &pat);
+ SAFE_SCAN(str, "", &col, &pat);
if (pat <= PAT_HOLLOW)
win.hide_brush();
else
@@ -1319,7 +1325,7 @@ bool TBook::print_page(TWindow& win, size_t page)
if (str.starts_with("", &x, &y, &dx, &dy);
+ SAFE_SCAN(str, "", &x, &y, &dx, &dy);
_rect.set(x, y, dx, dy);
win.log2dev(_rect, rct);
continue;
@@ -1373,7 +1379,7 @@ bool TBook::print_page(TWindow& win, size_t page)
COLOR col = COLOR_BLACK;
int width = 0;
PEN_STYLE style = P_SOLID;
- sscanf(str, "", &col, &width, &style);
+ SAFE_SCAN(str, "", &col, &width, &style);
if (width < 0)
win.hide_pen();
else
@@ -1418,15 +1424,15 @@ bool TBook::print_page(TWindow& win, size_t page)
}
if (str.starts_with("",
- &_horizontal_alignment, &_vertical_alignment);
+ SAFE_SCAN(str, "",
+ &_horizontal_alignment, &_vertical_alignment);
continue;
}
if (str.starts_with("", &fore, &back, &opaque);
+ SAFE_SCAN(str, "", &fore, &back, &opaque);
win.set_color(fore, back);
win.set_opaque_text(opaque != 0);
continue;
@@ -1478,7 +1484,7 @@ bool TBook::export_text(const TFilename& fname)
if (str.starts_with("", &x, &y, &dx, &dy);
+ SAFE_SCAN(str, "", &x, &y, &dx, &dy);
row = y * lpi() / res.y;
col = x * cpi() / res.x;
wid = dx * cpi() / res.x;
@@ -1585,8 +1591,8 @@ bool TBook::export_text(const TFilename& fname)
} else
if (str.starts_with("",
- &_horizontal_alignment, &_vertical_alignment);
+ SAFE_SCAN(str, "",
+ &_horizontal_alignment, &_vertical_alignment);
continue;
}
}
@@ -1669,7 +1675,7 @@ void TBook::split_file(int colonne)
if (str.starts_with("", &x, &y, &dx, &dy);
+ SAFE_SCAN(str, "", &x, &y, &dx, &dy);
str.format("", x-rct_page.x, y, dx, dy);
} else
if (str.starts_with("