diff options
author | Pedro Alves <palves@redhat.com> | 2016-11-08 15:26:44 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2016-11-08 15:26:44 +0000 |
commit | 3ab692db7f4d96022a132379614031a852de6f35 (patch) | |
tree | dcc4b2cdf8d475300d5b72633589d458820166d8 /gdb/guile/scm-value.c | |
parent | 09b0e4b047b44063cf4c8c00527886743619c24e (diff) | |
download | gdb-3ab692db7f4d96022a132379614031a852de6f35.zip gdb-3ab692db7f4d96022a132379614031a852de6f35.tar.gz gdb-3ab692db7f4d96022a132379614031a852de6f35.tar.bz2 |
Use ui_file_as_string in gdb/guile/
gdb/ChangeLog:
2016-11-08 Pedro Alves <palves@redhat.com>
* guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Use
ui_file_as_string and adjust to use std::string.
* guile/scm-disasm.c (gdbscm_arch_disassemble): Likewise.
* guile/scm-frame.c (frscm_print_frame_smob): Likewise.
* guile/scm-type.c (tyscm_type_name): Use ui_file_as_string and
adjust to use std::string. Throw exception directly instead of
returning it in EXCP output parameter.
(tyscm_print_type_smob, gdbscm_type_print_name): Adjust to
tyscm_type_name interface change.
* guile/scm-value.c (vlscm_print_value_smob, gdbscm_value_print):
Use ui_file_as_string and std::string.
Diffstat (limited to 'gdb/guile/scm-value.c')
-rw-r--r-- | gdb/guile/scm-value.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index 416e488..fa0e2b7 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -141,7 +141,6 @@ static int vlscm_print_value_smob (SCM self, SCM port, scm_print_state *pstate) { value_smob *v_smob = (value_smob *) SCM_SMOB_DATA (self); - char *s = NULL; struct value_print_options opts; if (pstate->writingp) @@ -162,7 +161,9 @@ vlscm_print_value_smob (SCM self, SCM port, scm_print_state *pstate) struct cleanup *old_chain = make_cleanup_ui_file_delete (stb); common_val_print (v_smob->value, stb, 0, &opts, current_language); - s = ui_file_xstrdup (stb, NULL); + + std::string s = ui_file_as_string (stb); + scm_puts (s.c_str (), port); do_cleanups (old_chain); } @@ -172,12 +173,6 @@ vlscm_print_value_smob (SCM self, SCM port, scm_print_state *pstate) } END_CATCH - if (s != NULL) - { - scm_puts (s, port); - xfree (s); - } - if (pstate->writingp) scm_puts (">", port); @@ -1282,7 +1277,7 @@ gdbscm_value_print (SCM self) = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct value *value = v_smob->value; struct value_print_options opts; - char *s = NULL; + std::string s; SCM result; get_user_print_options (&opts); @@ -1294,7 +1289,7 @@ gdbscm_value_print (SCM self) struct cleanup *old_chain = make_cleanup_ui_file_delete (stb); common_val_print (value, stb, 0, &opts, current_language); - s = ui_file_xstrdup (stb, NULL); + s = ui_file_as_string (stb); do_cleanups (old_chain); } @@ -1309,9 +1304,8 @@ gdbscm_value_print (SCM self) IWBN to use scm_take_locale_string here, but we'd have to temporarily override the default port conversion handler because contrary to documentation it doesn't necessarily free the input string. */ - result = scm_from_stringn (s, strlen (s), host_charset (), + result = scm_from_stringn (s.c_str (), s.size (), host_charset (), SCM_FAILED_CONVERSION_QUESTION_MARK); - xfree (s); return result; } |