Skip to content

Commit

Permalink
Remove c_format as redundant (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
anutosh491 authored Nov 18, 2024
1 parent b1f9f75 commit e702dd9
Showing 1 changed file with 0 additions and 23 deletions.
23 changes: 0 additions & 23 deletions src/xinterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,29 +339,6 @@ __get_cxx_version ()
restore_output();
}

static std::string c_format(const char* format, std::va_list args)
{
// Call vsnprintf once to determine the required buffer length. The
// return value is the number of characters _excluding_ the null byte.
std::va_list args_bufsz;
va_copy(args_bufsz, args);
std::size_t bufsz = vsnprintf(NULL, 0, format, args_bufsz);
va_end(args_bufsz);

// Create an empty string of that size.
std::string s(bufsz, 0);

// Now format the data into this string and return it.
std::va_list args_format;
va_copy(args_format, args);
// The second parameter is the maximum number of bytes that vsnprintf
// will write _including_ the terminating null byte.
vsnprintf(&s[0], s.size() + 1, format, args_format);
va_end(args_format);

return s;
}

void interpreter::redirect_output()
{
p_cout_strbuf = std::cout.rdbuf();
Expand Down

0 comments on commit e702dd9

Please sign in to comment.