Cleanup: Converted all sprintf to snprintf
This commit is contained in:
@@ -467,9 +467,9 @@ std::string Chart::render ()
|
||||
|
||||
// Draw y-axis labels.
|
||||
char label [12];
|
||||
sprintf (label, "%*d", _max_label, _labels[2]);
|
||||
snprintf (label, 12, "%*d", _max_label, _labels[2]);
|
||||
_grid.replace (LOC (1, _max_label - strlen (label)), strlen (label), label);
|
||||
sprintf (label, "%*d", _max_label, _labels[1]);
|
||||
snprintf (label, 12, "%*d", _max_label, _labels[1]);
|
||||
_grid.replace (LOC (1 + (_graph_height / 2), _max_label - strlen (label)), strlen (label), label);
|
||||
_grid.replace (LOC (_graph_height + 1, _max_label - 1), 1, "0");
|
||||
|
||||
@@ -527,7 +527,7 @@ std::string Chart::render ()
|
||||
calculateRates ();
|
||||
char rate[12];
|
||||
if (_net_fix_rate != 0.0)
|
||||
sprintf (rate, "%.1f/d", _net_fix_rate);
|
||||
snprintf (rate, 12, "%.1f/d", _net_fix_rate);
|
||||
else
|
||||
strcpy (rate, "-");
|
||||
|
||||
@@ -729,24 +729,24 @@ void Chart::generateBars ()
|
||||
std::string month = ISO8601d::monthName (cursor.month ());
|
||||
bar._major_label = month.substr (0, 3);
|
||||
|
||||
sprintf (str, "%02d", cursor.day ());
|
||||
snprintf (str, 12, "%02d", cursor.day ());
|
||||
bar._minor_label = str;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'W': // year/week
|
||||
sprintf (str, "%d", cursor.year ());
|
||||
snprintf (str, 12, "%d", cursor.year ());
|
||||
bar._major_label = str;
|
||||
|
||||
sprintf (str, "%02d", cursor.weekOfYear (0));
|
||||
snprintf (str, 12, "%02d", cursor.weekOfYear (0));
|
||||
bar._minor_label = str;
|
||||
break;
|
||||
|
||||
case 'M': // year/month
|
||||
sprintf (str, "%d", cursor.year ());
|
||||
snprintf (str, 12, "%d", cursor.year ());
|
||||
bar._major_label = str;
|
||||
|
||||
sprintf (str, "%02d", cursor.month ());
|
||||
snprintf (str, 12, "%02d", cursor.month ());
|
||||
bar._minor_label = str;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ int CmdColor::execute (std::string& output)
|
||||
char label [12];
|
||||
for (int g = 0; g < 6; ++g)
|
||||
{
|
||||
sprintf (label, " %d", g);
|
||||
snprintf (label, 12, " %d", g);
|
||||
out << Color::colorize (label, "bold green");
|
||||
for (int r = 0; r < 6; ++r)
|
||||
{
|
||||
|
||||
@@ -108,7 +108,7 @@ int CmdLogo::execute (std::string& output)
|
||||
{
|
||||
value += 167;
|
||||
char block [24];
|
||||
sprintf (block, "\033[48;5;%dm \033[0m", value);
|
||||
snprintf (block, 24, "\033[48;5;%dm \033[0m", value);
|
||||
output += block;
|
||||
}
|
||||
}
|
||||
@@ -122,7 +122,7 @@ int CmdLogo::execute (std::string& output)
|
||||
{
|
||||
value += 167;
|
||||
char block [24];
|
||||
sprintf (block, "\033[48;5;%dm \033[0m", value);
|
||||
snprintf (block, 24, "\033[48;5;%dm \033[0m", value);
|
||||
output += block;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ int CmdSummary::execute (std::string& output)
|
||||
|
||||
char percent[12] = "0%";
|
||||
if (c + p)
|
||||
sprintf (percent, "%d%%", 100 * c / (c + p));
|
||||
snprintf (percent, 12, "%d%%", 100 * c / (c + p));
|
||||
view.set (row, 3, percent);
|
||||
processed.push_back (i.first);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user