2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-01 06:25:34 +00:00

[2369] Use createSreamName() from #2371 instead of using sprintf()

This commit is contained in:
Mukund Sivaraman
2012-10-31 13:04:03 +05:30
parent ba71154440
commit 0dd898f809

View File

@@ -14,25 +14,29 @@
#include <dns/inputsource.h>
#include <cstdio>
using namespace std;
namespace isc {
namespace dns {
namespace master_lexer_internal {
namespace { // unnamed namespace
std::string
createStreamName(std::istream& input_stream) {
std::stringstream ss;
ss << "stream-" << &input_stream;
return (ss.str());
}
} // end of unnamed namespace
InputSource::InputSource(std::istream& input_stream) :
at_eof_(false),
line_(1),
saved_line_(line_),
buffer_pos_(buffer_.size()),
name_(createStreamName(input_stream)),
input_(input_stream)
{
char buf[FILENAME_MAX];
snprintf(buf, sizeof(buf), "stream-%p", &input_stream);
name_ = buf;
}
{}
InputSource::InputSource(const char* filename) :
at_eof_(false),
@@ -42,7 +46,7 @@ InputSource::InputSource(const char* filename) :
name_(filename),
input_(file_stream_)
{
file_stream_.open(filename, fstream::in);
file_stream_.open(filename, std::fstream::in);
}
InputSource::~InputSource()