aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-lang.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2015-09-10 11:48:47 -0400
committerSimon Marchi <simon.marchi@ericsson.com>2015-09-10 11:48:47 -0400
commit5da1a4d34e730e0b4e2f034c81d22d5948a6ce67 (patch)
treed4b2aaa8eb7eeddfc11f8df56bb476a9153cd3f8 /gdb/ada-lang.c
parent108d56a48b0970a53e237af76440df4a75ff7329 (diff)
downloadgdb-5da1a4d34e730e0b4e2f034c81d22d5948a6ce67.zip
gdb-5da1a4d34e730e0b4e2f034c81d22d5948a6ce67.tar.gz
gdb-5da1a4d34e730e0b4e2f034c81d22d5948a6ce67.tar.bz2
Small refactor in ada-lang.c:scan_discrim_bound
Factor out common arithmetic operations for clarity. gdb/ChangeLog: * ada-lang.c (scan_discrim_bound): Factor out arithmetic operations.
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r--gdb/ada-lang.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index a514f65..d166d1c 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -11432,24 +11432,29 @@ scan_discrim_bound (const char *str, int k, struct value *dval, LONGEST * px,
{
static char *bound_buffer = NULL;
static size_t bound_buffer_len = 0;
- const char *pend, *bound;
+ const char *pstart, *pend, *bound;
struct value *bound_val;
if (dval == NULL || str == NULL || str[k] == '\0')
return 0;
- pend = strstr (str + k, "__");
+ pstart = str + k;
+ pend = strstr (pstart, "__");
if (pend == NULL)
{
- bound = str + k;
+ bound = pstart;
k += strlen (bound);
}
else
{
- GROW_VECT (bound_buffer, bound_buffer_len, pend - (str + k) + 1);
+ int len = pend - pstart;
+
+ /* Strip __ and beyond. */
+ GROW_VECT (bound_buffer, bound_buffer_len, len + 1);
+ strncpy (bound_buffer, pstart, len);
+ bound_buffer[len] = '\0';
+
bound = bound_buffer;
- strncpy (bound_buffer, str + k, pend - (str + k));
- bound_buffer[pend - (str + k)] = '\0';
k = pend - str;
}