Commit 4be58168 by Benjamin Kosnik Committed by Benjamin Kosnik

re PR libstdc++/13109 (libstdc++-v3 bootstrap failure on Tru64 UNIX V4.0F: snprintf missing)


2003-11-20  Benjamin Kosnik  <bkoz@redhat.com>

	PR libstdc++/13109
	* include/debug/formatter.h (_Error_formatter::_M_format_word): New.
	* src/debug.cc (__gnu_debug): Format.
	(_Error_formatter::_M_format_word): Define, use, instantiate.

From-SVN: r73770
parent 0fd18701
2003-11-20 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/13109
* include/debug/formatter.h (_Error_formatter::_M_format_word): New.
* src/debug.cc (__gnu_debug): Format.
(_Error_formatter::_M_format_word): Define, use, instantiate.
2003-11-20 Paolo Carlini <pcarlini@suse.de> 2003-11-20 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/11602 PR libstdc++/11602
......
...@@ -191,15 +191,13 @@ namespace __gnu_debug ...@@ -191,15 +191,13 @@ namespace __gnu_debug
_Parameter() : _M_kind(__unused_param) { } _Parameter() : _M_kind(__unused_param) { }
_Parameter(long __value, const char* __name) _Parameter(long __value, const char* __name) : _M_kind(__integer)
: _M_kind(__integer)
{ {
_M_variant._M_integer._M_name = __name; _M_variant._M_integer._M_name = __name;
_M_variant._M_integer._M_value = __value; _M_variant._M_integer._M_value = __value;
} }
_Parameter(const char* __value, const char* __name) _Parameter(const char* __value, const char* __name) : _M_kind(__string)
: _M_kind(__string)
{ {
_M_variant._M_string._M_name = __name; _M_variant._M_string._M_name = __name;
_M_variant._M_string._M_value = __value; _M_variant._M_string._M_value = __value;
...@@ -358,6 +356,10 @@ namespace __gnu_debug ...@@ -358,6 +356,10 @@ namespace __gnu_debug
_M_max_length(78), _M_column(1), _M_first_line(true), _M_wordwrap(false) _M_max_length(78), _M_column(1), _M_first_line(true), _M_wordwrap(false)
{ } { }
template<typename _T>
void
_M_format_word(char*, int, const char*, _T) const;
void void
_M_print_word(const char* __word) const; _M_print_word(const char* __word) const;
......
...@@ -46,17 +46,24 @@ namespace __gnu_debug ...@@ -46,17 +46,24 @@ namespace __gnu_debug
{ {
"function requires a valid iterator range [%1.name;, %2.name;)", "function requires a valid iterator range [%1.name;, %2.name;)",
"attempt to insert into container with a singular iterator", "attempt to insert into container with a singular iterator",
"attempt to insert into container with an iterator from a different container", "attempt to insert into container with an iterator"
" from a different container",
"attempt to erase from container with a %2.state; iterator", "attempt to erase from container with a %2.state; iterator",
"attempt to erase from container with an iterator from a different container", "attempt to erase from container with an iterator"
"attempt to subscript container with out-of-bounds index %2;, but container only holds %3; elements", " from a different container",
"attempt to subscript container with out-of-bounds index %2;,"
" but container only holds %3; elements",
"attempt to access an element in an empty container", "attempt to access an element in an empty container",
"elements in iterator range [%1.name;, %2.name;) are not partitioned by the value %3;", "elements in iterator range [%1.name;, %2.name;)"
"elements in iterator range [%1.name;, %2.name;) are not partitioned by the predicate %3; and value %4;", " are not partitioned by the value %3;",
"elements in iterator range [%1.name;, %2.name;)"
" are not partitioned by the predicate %3; and value %4;",
"elements in iterator range [%1.name;, %2.name;) are not sorted", "elements in iterator range [%1.name;, %2.name;) are not sorted",
"elements in iterator range [%1.name;, %2.name;) are not sorted according to the predicate %3;", "elements in iterator range [%1.name;, %2.name;)"
" are not sorted according to the predicate %3;",
"elements in iterator range [%1.name;, %2.name;) do not form a heap", "elements in iterator range [%1.name;, %2.name;) do not form a heap",
"elements in iterator range [%1.name;, %2.name;) do not form a heap with respect to the predicate %3;", "elements in iterator range [%1.name;, %2.name;)"
" do not form a heap with respect to the predicate %3;",
"attempt to write through a singular bitset reference", "attempt to write through a singular bitset reference",
"attempt to read from a singular bitset reference", "attempt to read from a singular bitset reference",
"attempt to flip a singular bitset reference", "attempt to flip a singular bitset reference",
...@@ -64,27 +71,35 @@ namespace __gnu_debug ...@@ -64,27 +71,35 @@ namespace __gnu_debug
"attempt to splice lists with inequal allocators", "attempt to splice lists with inequal allocators",
"attempt to splice elements referenced by a %1.state; iterator", "attempt to splice elements referenced by a %1.state; iterator",
"attempt to splice an iterator from a different container", "attempt to splice an iterator from a different container",
"splice destination %1.name; occurs within source range [%2.name;, %3.name;)", "splice destination %1.name;"
" occurs within source range [%2.name;, %3.name;)",
"attempt to initialize an iterator that will immediately become singular", "attempt to initialize an iterator that will immediately become singular",
"attempt to copy-construct an iterator from a singular iterator", "attempt to copy-construct an iterator from a singular iterator",
"attempt to construct a constant iterator from a singular mutable iterator", "attempt to construct a constant iterator"
" from a singular mutable iterator",
"attempt to copy from a singular iterator", "attempt to copy from a singular iterator",
"attempt to dereference a %1.state; iterator", "attempt to dereference a %1.state; iterator",
"attempt to increment a %1.state; iterator", "attempt to increment a %1.state; iterator",
"attempt to decrement a %1.state; iterator", "attempt to decrement a %1.state; iterator",
"attempt to subscript a %1.state; iterator %2; step from its current position, which falls outside its dereferenceable range", "attempt to subscript a %1.state; iterator %2; step from"
"attempt to advance a %1.state; iterator %2; steps, which falls outside its valid range", " its current position, which falls outside its dereferenceable range",
"attempt to retreat a %1.state; iterator %2; steps, which falls outside its valid range", "attempt to advance a %1.state; iterator %2; steps,"
" which falls outside its valid range",
"attempt to retreat a %1.state; iterator %2; steps,"
" which falls outside its valid range",
"attempt to compare a %1.state; iterator to a %2.state; iterator", "attempt to compare a %1.state; iterator to a %2.state; iterator",
"attempt to compare iterators from different sequences", "attempt to compare iterators from different sequences",
"attempt to order a %1.state; iterator to a %2.state; iterator", "attempt to order a %1.state; iterator to a %2.state; iterator",
"attempt to order iterators from different sequences", "attempt to order iterators from different sequences",
"attempt to compute the difference between a %1.state; iterator to a %2.state; iterator", "attempt to compute the difference between a %1.state;"
"attempt to compute the different between two iterators from different sequences", " iterator to a %2.state; iterator",
"attempt to compute the different between two iterators"
" from different sequences",
"attempt to dereference an end-of-stream istream_iterator", "attempt to dereference an end-of-stream istream_iterator",
"attempt to increment an end-of-stream istream_iterator", "attempt to increment an end-of-stream istream_iterator",
"attempt to output via an ostream_iterator with no associated stream", "attempt to output via an ostream_iterator with no associated stream",
"attempt to dereference an end-of-stream istreambuf_iterator (this is a GNU extension)", "attempt to dereference an end-of-stream istreambuf_iterator"
" (this is a GNU extension)",
"attempt to increment an end-of-stream istreambuf_iterator" "attempt to increment an end-of-stream istreambuf_iterator"
}; };
...@@ -132,15 +147,14 @@ namespace __gnu_debug ...@@ -132,15 +147,14 @@ namespace __gnu_debug
_Safe_sequence_base:: _Safe_sequence_base::
_M_revalidate_singular() _M_revalidate_singular()
{ {
for (_Safe_iterator_base* iter = _M_iterators; iter; _Safe_iterator_base* iter;
iter = iter->_M_next) for (iter = _M_iterators; iter; iter = iter->_M_next)
{ {
iter->_M_version = _M_version; iter->_M_version = _M_version;
iter = iter->_M_next; iter = iter->_M_next;
} }
for (_Safe_iterator_base* iter = _M_const_iterators; iter; for (iter = _M_const_iterators; iter; iter = iter->_M_next)
iter = iter->_M_next)
{ {
iter->_M_version = _M_version; iter->_M_version = _M_version;
iter = iter->_M_next; iter = iter->_M_next;
...@@ -154,13 +168,14 @@ namespace __gnu_debug ...@@ -154,13 +168,14 @@ namespace __gnu_debug
swap(_M_iterators, __x._M_iterators); swap(_M_iterators, __x._M_iterators);
swap(_M_const_iterators, __x._M_const_iterators); swap(_M_const_iterators, __x._M_const_iterators);
swap(_M_version, __x._M_version); swap(_M_version, __x._M_version);
for (_Safe_iterator_base* iter = _M_iterators; iter; iter = iter->_M_next) _Safe_iterator_base* iter;
for (iter = _M_iterators; iter; iter = iter->_M_next)
iter->_M_sequence = this; iter->_M_sequence = this;
for (_Safe_iterator_base* iter = __x._M_iterators; iter; iter = iter->_M_next) for (iter = __x._M_iterators; iter; iter = iter->_M_next)
iter->_M_sequence = &__x; iter->_M_sequence = &__x;
for (_Safe_iterator_base* iter = _M_const_iterators; iter; iter = iter->_M_next) for (iter = _M_const_iterators; iter; iter = iter->_M_next)
iter->_M_sequence = this; iter->_M_sequence = this;
for (_Safe_iterator_base* iter = __x._M_const_iterators; iter; iter = iter->_M_next) for (iter = __x._M_const_iterators; iter; iter = iter->_M_next)
iter->_M_sequence = &__x; iter->_M_sequence = &__x;
} }
...@@ -200,8 +215,10 @@ namespace __gnu_debug ...@@ -200,8 +215,10 @@ namespace __gnu_debug
if (_M_sequence) if (_M_sequence)
{ {
// Remove us from this sequence's list // Remove us from this sequence's list
if (_M_prior) _M_prior->_M_next = _M_next; if (_M_prior)
if (_M_next) _M_next->_M_prior = _M_prior; _M_prior->_M_next = _M_next;
if (_M_next)
_M_next->_M_prior = _M_prior;
if (_M_sequence->_M_const_iterators == this) if (_M_sequence->_M_const_iterators == this)
_M_sequence->_M_const_iterators = _M_next; _M_sequence->_M_const_iterators = _M_next;
...@@ -224,14 +241,13 @@ namespace __gnu_debug ...@@ -224,14 +241,13 @@ namespace __gnu_debug
_Safe_iterator_base:: _Safe_iterator_base::
_M_can_compare(const _Safe_iterator_base& __x) const _M_can_compare(const _Safe_iterator_base& __x) const
{ {
return (! _M_singular() && !__x._M_singular() return (!_M_singular() && !__x._M_singular()
&& _M_sequence == __x._M_sequence); && _M_sequence == __x._M_sequence);
} }
void void
_Error_formatter::_Parameter:: _Error_formatter::_Parameter::
_M_print_field(const _Error_formatter* __formatter, _M_print_field(const _Error_formatter* __formatter, const char* __name) const
const char* __name) const
{ {
assert(this->_M_kind != _Parameter::__unused_param); assert(this->_M_kind != _Parameter::__unused_param);
const int bufsize = 64; const int bufsize = 64;
...@@ -246,7 +262,8 @@ namespace __gnu_debug ...@@ -246,7 +262,8 @@ namespace __gnu_debug
} }
else if (strcmp(__name, "address") == 0) else if (strcmp(__name, "address") == 0)
{ {
snprintf(buf, bufsize, "%p", _M_variant._M_iterator._M_address); __formatter->_M_format_word(buf, bufsize, "%p",
_M_variant._M_iterator._M_address);
__formatter->_M_print_word(buf); __formatter->_M_print_word(buf);
} }
else if (strcmp(__name, "type") == 0) else if (strcmp(__name, "type") == 0)
...@@ -280,7 +297,8 @@ namespace __gnu_debug ...@@ -280,7 +297,8 @@ namespace __gnu_debug
else if (strcmp(__name, "sequence") == 0) else if (strcmp(__name, "sequence") == 0)
{ {
assert(_M_variant._M_iterator._M_sequence); assert(_M_variant._M_iterator._M_sequence);
snprintf(buf, bufsize, "%p", _M_variant._M_iterator._M_sequence); __formatter->_M_format_word(buf, bufsize, "%p",
_M_variant._M_iterator._M_sequence);
__formatter->_M_print_word(buf); __formatter->_M_print_word(buf);
} }
else if (strcmp(__name, "seq_type") == 0) else if (strcmp(__name, "seq_type") == 0)
...@@ -302,7 +320,8 @@ namespace __gnu_debug ...@@ -302,7 +320,8 @@ namespace __gnu_debug
else if (strcmp(__name, "address") == 0) else if (strcmp(__name, "address") == 0)
{ {
assert(_M_variant._M_sequence._M_address); assert(_M_variant._M_sequence._M_address);
snprintf(buf, bufsize, "%p", _M_variant._M_sequence._M_address); __formatter->_M_format_word(buf, bufsize, "%p",
_M_variant._M_sequence._M_address);
__formatter->_M_print_word(buf); __formatter->_M_print_word(buf);
} }
else if (strcmp(__name, "type") == 0) else if (strcmp(__name, "type") == 0)
...@@ -352,12 +371,12 @@ namespace __gnu_debug ...@@ -352,12 +371,12 @@ namespace __gnu_debug
__formatter->_M_print_word("iterator "); __formatter->_M_print_word("iterator ");
if (_M_variant._M_iterator._M_name) if (_M_variant._M_iterator._M_name)
{ {
snprintf(buf, bufsize, "\"%s\" ", __formatter->_M_format_word(buf, bufsize, "\"%s\" ",
_M_variant._M_iterator._M_name); _M_variant._M_iterator._M_name);
__formatter->_M_print_word(buf); __formatter->_M_print_word(buf);
} }
snprintf(buf, bufsize, "@ 0x%p {\n", __formatter->_M_format_word(buf, bufsize, "@ 0x%p {\n",
_M_variant._M_iterator._M_address); _M_variant._M_iterator._M_address);
__formatter->_M_print_word(buf); __formatter->_M_print_word(buf);
if (_M_variant._M_iterator._M_type) if (_M_variant._M_iterator._M_type)
...@@ -391,7 +410,8 @@ namespace __gnu_debug ...@@ -391,7 +410,8 @@ namespace __gnu_debug
__formatter->_M_print_word("' "); __formatter->_M_print_word("' ");
} }
snprintf(buf, bufsize, "@ 0x%p\n", _M_variant._M_sequence._M_address); __formatter->_M_format_word(buf, bufsize, "@ 0x%p\n",
_M_variant._M_sequence._M_address);
__formatter->_M_print_word(buf); __formatter->_M_print_word(buf);
} }
__formatter->_M_print_word("}\n"); __formatter->_M_print_word("}\n");
...@@ -401,12 +421,12 @@ namespace __gnu_debug ...@@ -401,12 +421,12 @@ namespace __gnu_debug
__formatter->_M_print_word("sequence "); __formatter->_M_print_word("sequence ");
if (_M_variant._M_sequence._M_name) if (_M_variant._M_sequence._M_name)
{ {
snprintf(buf, bufsize, "\"%s\" ", __formatter->_M_format_word(buf, bufsize, "\"%s\" ",
_M_variant._M_sequence._M_name); _M_variant._M_sequence._M_name);
__formatter->_M_print_word(buf); __formatter->_M_print_word(buf);
} }
snprintf(buf, bufsize, "@ 0x%p {\n", __formatter->_M_format_word(buf, bufsize, "@ 0x%p {\n",
_M_variant._M_sequence._M_address); _M_variant._M_sequence._M_address);
__formatter->_M_print_word(buf); __formatter->_M_print_word(buf);
...@@ -435,14 +455,14 @@ namespace __gnu_debug ...@@ -435,14 +455,14 @@ namespace __gnu_debug
_M_wordwrap = false; _M_wordwrap = false;
if (_M_file) if (_M_file)
{ {
snprintf(buf, bufsize, "%s:", _M_file); _M_format_word(buf, bufsize, "%s:", _M_file);
_M_print_word(buf); _M_print_word(buf);
_M_column += strlen(buf); _M_column += strlen(buf);
} }
if (_M_line > 0) if (_M_line > 0)
{ {
snprintf(buf, bufsize, "%u:", _M_line); _M_format_word(buf, bufsize, "%u:", _M_line);
_M_print_word(buf); _M_print_word(buf);
_M_column += strlen(buf); _M_column += strlen(buf);
} }
...@@ -476,6 +496,20 @@ namespace __gnu_debug ...@@ -476,6 +496,20 @@ namespace __gnu_debug
abort(); abort();
} }
template<typename _T>
void
_Error_formatter::_M_format_word(char* __buf,
int __n __attribute__((__unused__)),
const char* __fmt, _T __s) const
{
#ifdef _GLIBCXX_USE_C99
std::snprintf(__buf, __n, __fmt, __s);
#else
std::sprintf(__buf, __fmt, __s);
#endif
}
void void
_Error_formatter::_M_print_word(const char* __word) const _Error_formatter::_M_print_word(const char* __word) const
{ {
...@@ -540,12 +574,13 @@ namespace __gnu_debug ...@@ -540,12 +574,13 @@ namespace __gnu_debug
if (isspace(*__end)) ++__end; if (isspace(*__end)) ++__end;
assert(__end - __start + 1< bufsize); assert(__end - __start + 1< bufsize);
snprintf(buf, __end - __start + 1, "%s", __start); _M_format_word(buf, __end - __start + 1, "%s", __start);
_M_print_word(buf); _M_print_word(buf);
__start = __end; __start = __end;
// Skip extra whitespace // Skip extra whitespace
while (*__start == ' ') ++__start; while (*__start == ' ')
++__start;
continue; continue;
} }
...@@ -575,7 +610,7 @@ namespace __gnu_debug ...@@ -575,7 +610,7 @@ namespace __gnu_debug
buf[0] = '\0'; buf[0] = '\0';
if (_M_parameters[param]._M_kind == _Parameter::__integer) if (_M_parameters[param]._M_kind == _Parameter::__integer)
{ {
snprintf(buf, bufsize, "%ld", _M_format_word(buf, bufsize, "%ld",
_M_parameters[param]._M_variant._M_integer._M_value); _M_parameters[param]._M_variant._M_integer._M_value);
_M_print_word(buf); _M_print_word(buf);
} }
...@@ -601,4 +636,25 @@ namespace __gnu_debug ...@@ -601,4 +636,25 @@ namespace __gnu_debug
_M_parameters[param]._M_print_field(this, field); _M_parameters[param]._M_print_field(this, field);
} }
} }
// Instantiations.
template
void
_Error_formatter::_M_format_word(char* __buf, int __n, const char* __fmt,
const void* __s) const;
template
void
_Error_formatter::_M_format_word(char* __buf, int __n, const char* __fmt,
long __s) const;
template
void
_Error_formatter::_M_format_word(char* __buf, int __n, const char* __fmt,
unsigned int __s) const;
template
void
_Error_formatter::_M_format_word(char* __buf, int __n, const char* __fmt,
const char* __s) const;
} // namespace __gnu_debug } // namespace __gnu_debug
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment