aboutsummaryrefslogtreecommitdiff
path: root/gdb/c-exp.y
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2017-10-05 19:14:08 +0200
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2017-10-05 19:14:08 +0200
commit3b4b2f160d288b85a1379d24fd0f4de19062f3fd (patch)
treea2e1e9b581fe59bae11bf476291b127713777be8 /gdb/c-exp.y
parent1841ee5d0300cf00022c8aadfe16725c5e86fe1d (diff)
downloadgdb-3b4b2f160d288b85a1379d24fd0f4de19062f3fd.zip
gdb-3b4b2f160d288b85a1379d24fd0f4de19062f3fd.tar.gz
gdb-3b4b2f160d288b85a1379d24fd0f4de19062f3fd.tar.bz2
Clean up some DFP interfaces
This cleans up a number of interfaces in dfp.c / dfp.h. Specifically: - The decimal_from_string / decimal_to_string routines are C++-ified to operate on std::string instead of character buffers. In the decimal_from_string, the boolean return value now actually is bool instead of an int. - The decimal_from_integral and decimal_from_doublest routines take an struct value as input. This is not really appropriate at the low level the DFP routines sit, so this replaced them with new routines decimal_from_longest / decimal_from_ulongest / decimal_from_doublest that operate on contents instead. - To mirror the decimal_from_[u]longest, a new decimal_to_longest routine is added as well, which can be used in unpack_long to avoid an unnecessary conversion via DOUBLEST. Note that the decimal_from_longest / decimal_from_ulongest routines are actually more powerful than decimal_from_integral: the old routine would only accept integer *types* of at most four bytes size, while the new routines accept all integer *values* that fit in an [u]int32_t, no matter which type they came from. The DFP tests are updated to allow for this larger range of integers that can be converted. gdb/ChangeLog: 2017-10-05 Ulrich Weigand <uweigand@de.ibm.com> * dfp.h (MAX_DECIMAL_STRING): Move to dfp.c. (decimal_to_string): Return std::string object. (decimal_from_string): Accept std::string object. Return bool. (decimal_from_integral, decimal_from_doublest): Remove. (decimal_from_longest): Add prototype. (decimal_from_ulongest): Likewise. (decimal_to_longest): Likewise. (decimal_from_doublest): Likewise. * dfp.c: Do not include "gdbtypes.h" or "value.h". (MAX_DECIMAL_STRING): Move here. (decimal_to_string): Return std::string object. (decimal_from_string): Accept std::string object. Return bool. (decimal_from_integral): Remove, replace by ... (decimal_from_longest, decimal_from_ulongest): ... these new functions. (decimal_to_longest): New function. (decimal_from_floating): Remove, replace by ... (decimal_from_doublest): ... this new function. (decimal_to_doublest): Update to new decimal_to_string interface. * value.c (unpack_long): Use decimal_to_longest. * valops.c (value_cast): Use decimal_from_doublest instead of decimal_from_floating. Use decimal_from_[u]longest isntead of decimal_from_integral. * valarith.c (value_args_as_decimal): Likewise. * valprint.c (print_decimal_floating): Update to new decimal_to_string interface. * printcmd.c (printf_decfloat): Likewise. * c-exp.y (parse_number): Update to new decimal_from_string interface. gdb/testsuite/ChangeLog: 2017-10-05 Ulrich Weigand <uweigand@de.ibm.com> * gdb.base/dfp-exprs.exp: Update tests to larger range of supported integer-to-dfp conversion. * gdb.base/dfp-test.exp: Likewise.
Diffstat (limited to 'gdb/c-exp.y')
-rw-r--r--gdb/c-exp.y12
1 files changed, 3 insertions, 9 deletions
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 43af80c..7c050b4 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -1791,37 +1791,31 @@ parse_number (struct parser_state *par_state,
if (len >= 2 && p[len - 2] == 'd' && p[len - 1] == 'f')
{
- p[len - 2] = '\0';
putithere->typed_val_decfloat.type
= parse_type (par_state)->builtin_decfloat;
decimal_from_string (putithere->typed_val_decfloat.val, 4,
gdbarch_byte_order (parse_gdbarch (par_state)),
- p);
- p[len - 2] = 'd';
+ std::string (p, len - 2));
return DECFLOAT;
}
if (len >= 2 && p[len - 2] == 'd' && p[len - 1] == 'd')
{
- p[len - 2] = '\0';
putithere->typed_val_decfloat.type
= parse_type (par_state)->builtin_decdouble;
decimal_from_string (putithere->typed_val_decfloat.val, 8,
gdbarch_byte_order (parse_gdbarch (par_state)),
- p);
- p[len - 2] = 'd';
+ std::string (p, len - 2));
return DECFLOAT;
}
if (len >= 2 && p[len - 2] == 'd' && p[len - 1] == 'l')
{
- p[len - 2] = '\0';
putithere->typed_val_decfloat.type
= parse_type (par_state)->builtin_declong;
decimal_from_string (putithere->typed_val_decfloat.val, 16,
gdbarch_byte_order (parse_gdbarch (par_state)),
- p);
- p[len - 2] = 'd';
+ std::string (p, len - 2));
return DECFLOAT;
}