Skip to content

Commit

Permalink
Merge pull request meztez#30 from meztez/printf
Browse files Browse the repository at this point in the history
Fix non-literal printf format strings
  • Loading branch information
meztez authored Dec 5, 2023
2 parents 8ac9834 + 85e50f0 commit 9057d58
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/RProgress.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ class RProgress {
first(true), format(format), total(total), current(0), extra(0), count(0),
width(width), cursor_char(cursor_char), complete_char(complete_char),
incomplete_char(incomplete_char), clear(clear), show_after(show_after),
last_draw(""), start(0), toupdate(false),
complete(false), reverse(false) {
last_draw(""), start(0), toupdate(false), complete(false), reverse(false) {

supported = is_supported();
use_stderr = default_stderr();
Expand All @@ -72,8 +71,7 @@ class RProgress {
first(true), format(format), total(total), current(0), extra(0), count(0),
width(width), cursor_char(1, complete_char), complete_char(1, complete_char),
incomplete_char(1, incomplete_char), clear(clear), show_after(show_after),
last_draw(""), start(0), toupdate(false),
complete(false), reverse(false) {
last_draw(""), start(0), toupdate(false), complete(false), reverse(false) {

supported = is_supported();
use_stderr = default_stderr();
Expand Down Expand Up @@ -211,7 +209,6 @@ class RProgress {
if (last_draw.length() > str.length()) { clear_line(use_stderr, width); }
cursor_to_start(use_stderr);
if (use_stderr) {
// use a format to avoid special treatment for in string %
REprintf("%s", str.c_str());
} else {
Rprintf("%s", str.c_str());
Expand Down Expand Up @@ -255,9 +252,9 @@ class RProgress {
spaces[width + 1] = '\0';

if (use_stderr) {
REprintf(spaces);
REprintf("%s", spaces);
} else {
Rprintf(spaces);
Rprintf("%s", spaces);
}
free(spaces);
}
Expand Down

0 comments on commit 9057d58

Please sign in to comment.