Use ui_file_as_string in gdb/ada-valprint.c
gdb/ChangeLog: 2016-11-08 Pedro Alves <palves@redhat.com> * ada-valprint.c (ada_print_floating): Use ui_file_as_string and std::string.
This commit is contained in:
parent
a0f86e7358
commit
77e1c7426a
|
@ -1,3 +1,8 @@
|
||||||
|
2016-11-08 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
|
* ada-valprint.c (ada_print_floating): Use ui_file_as_string and
|
||||||
|
std::string.
|
||||||
|
|
||||||
2016-11-08 Pedro Alves <palves@redhat.com>
|
2016-11-08 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
* xtensa-tdep.c (xtensa_verify_config): Use ui_file_as_string and
|
* xtensa-tdep.c (xtensa_verify_config): Use ui_file_as_string and
|
||||||
|
|
|
@ -298,49 +298,50 @@ static void
|
||||||
ada_print_floating (const gdb_byte *valaddr, struct type *type,
|
ada_print_floating (const gdb_byte *valaddr, struct type *type,
|
||||||
struct ui_file *stream)
|
struct ui_file *stream)
|
||||||
{
|
{
|
||||||
char *s, *result;
|
|
||||||
struct ui_file *tmp_stream = mem_fileopen ();
|
struct ui_file *tmp_stream = mem_fileopen ();
|
||||||
struct cleanup *cleanups = make_cleanup_ui_file_delete (tmp_stream);
|
struct cleanup *cleanups = make_cleanup_ui_file_delete (tmp_stream);
|
||||||
|
|
||||||
print_floating (valaddr, type, tmp_stream);
|
print_floating (valaddr, type, tmp_stream);
|
||||||
result = ui_file_xstrdup (tmp_stream, NULL);
|
|
||||||
make_cleanup (xfree, result);
|
std::string s = ui_file_as_string (tmp_stream);
|
||||||
|
size_t skip_count = 0;
|
||||||
|
|
||||||
/* Modify for Ada rules. */
|
/* Modify for Ada rules. */
|
||||||
|
|
||||||
s = strstr (result, "inf");
|
size_t pos = s.find ("inf");
|
||||||
if (s == NULL)
|
if (pos == std::string::npos)
|
||||||
s = strstr (result, "Inf");
|
pos = s.find ("Inf");
|
||||||
if (s == NULL)
|
if (pos == std::string::npos)
|
||||||
s = strstr (result, "INF");
|
pos = s.find ("INF");
|
||||||
if (s != NULL)
|
if (pos != std::string::npos)
|
||||||
strcpy (s, "Inf");
|
s.replace (pos, 3, "Inf");
|
||||||
|
|
||||||
if (s == NULL)
|
if (pos == std::string::npos)
|
||||||
{
|
{
|
||||||
s = strstr (result, "nan");
|
pos = s.find ("nan");
|
||||||
if (s == NULL)
|
if (pos == std::string::npos)
|
||||||
s = strstr (result, "NaN");
|
pos = s.find ("NaN");
|
||||||
if (s == NULL)
|
if (pos == std::string::npos)
|
||||||
s = strstr (result, "Nan");
|
pos = s.find ("Nan");
|
||||||
if (s != NULL)
|
if (pos != std::string::npos)
|
||||||
{
|
{
|
||||||
s[0] = s[2] = 'N';
|
s[pos] = s[pos + 2] = 'N';
|
||||||
if (result[0] == '-')
|
if (s[0] == '-')
|
||||||
result += 1;
|
skip_count = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s == NULL && strchr (result, '.') == NULL)
|
if (pos == std::string::npos
|
||||||
|
&& s.find ('.') == std::string::npos)
|
||||||
{
|
{
|
||||||
s = strchr (result, 'e');
|
pos = s.find ('e');
|
||||||
if (s == NULL)
|
if (pos == std::string::npos)
|
||||||
fprintf_filtered (stream, "%s.0", result);
|
fprintf_filtered (stream, "%s.0", s.c_str ());
|
||||||
else
|
else
|
||||||
fprintf_filtered (stream, "%.*s.0%s", (int) (s-result), result, s);
|
fprintf_filtered (stream, "%.*s.0%s", (int) pos, s.c_str (), &s[pos]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fprintf_filtered (stream, "%s", result);
|
fprintf_filtered (stream, "%s", &s[skip_count]);
|
||||||
|
|
||||||
do_cleanups (cleanups);
|
do_cleanups (cleanups);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue