Skip to content

Remove c_format as redundant #182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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