Don't use printf("%d") just to convert an int to a string.

std::to_string, std::to_wstring are more appropriate
This commit is contained in:
Aaron Gyes
2019-02-18 23:12:03 -08:00
parent 59cb2d02a8
commit c2bc0c67f2
3 changed files with 5 additions and 10 deletions

View File

@@ -1796,16 +1796,13 @@ static void validate_new_termsize(struct winsize *new_termsize, const environmen
/// Export the new terminal size as env vars and to the kernel if possible.
static void export_new_termsize(struct winsize *new_termsize, env_stack_t &vars) {
wchar_t buf[64];
auto cols = vars.get(L"COLUMNS", ENV_EXPORT);
swprintf(buf, 64, L"%d", (int)new_termsize->ws_col);
vars.set_one(L"COLUMNS", ENV_GLOBAL | (cols.missing_or_empty() ? ENV_DEFAULT : ENV_EXPORT),
buf);
std::to_wstring(int(new_termsize->ws_col)));
auto lines = vars.get(L"LINES", ENV_EXPORT);
swprintf(buf, 64, L"%d", (int)new_termsize->ws_row);
vars.set_one(L"LINES", ENV_GLOBAL | (lines.missing_or_empty() ? ENV_DEFAULT : ENV_EXPORT), buf);
vars.set_one(L"LINES", ENV_GLOBAL | (lines.missing_or_empty() ? ENV_DEFAULT : ENV_EXPORT),
std::to_wstring(int(new_termsize->ws_row)));
#ifdef HAVE_WINSIZE
// Only write the new terminal size if we are in the foreground (#4477)