diff options
author | Gary Benson <gbenson@redhat.com> | 2015-03-06 09:42:06 +0000 |
---|---|---|
committer | Gary Benson <gbenson@redhat.com> | 2015-03-06 09:42:06 +0000 |
commit | 61012eef8463764ccd9117dc1c9bc43cc452b7cc (patch) | |
tree | f576a77bcb77e71cc60e6592b56d2aa915b50c36 /gdb/breakpoint.c | |
parent | e80417caef36c7d5e3d1da6a3b396a872d9d7201 (diff) | |
download | gdb-61012eef8463764ccd9117dc1c9bc43cc452b7cc.zip gdb-61012eef8463764ccd9117dc1c9bc43cc452b7cc.tar.gz gdb-61012eef8463764ccd9117dc1c9bc43cc452b7cc.tar.bz2 |
New common function "startswith"
This commit introduces a new inline common function "startswith"
which takes two string arguments and returns nonzero if the first
string starts with the second. It also updates the 295 places
where this logic was written out longhand to use the new function.
gdb/ChangeLog:
* common/common-utils.h (startswith): New inline function.
All places where this logic was used updated to use the above.
Diffstat (limited to 'gdb/breakpoint.c')
-rw-r--r-- | gdb/breakpoint.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index c5d3240..d85f271 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -9729,7 +9729,7 @@ parse_breakpoint_sals (char **address, /* If no arg given, or if first arg is 'if ', use the default breakpoint. */ if ((*address) == NULL - || (strncmp ((*address), "if", 2) == 0 && isspace ((*address)[2]))) + || (startswith ((*address), "if") && isspace ((*address)[2]))) { /* The last displayed codepoint, if it's valid, is our default breakpoint address. */ @@ -11401,7 +11401,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, tok++; toklen = end_tok - tok + 1; - if (toklen == 6 && !strncmp (tok, "thread", 6)) + if (toklen == 6 && startswith (tok, "thread")) { /* At this point we've found a "thread" token, which means the user is trying to set a watchpoint that triggers @@ -11423,7 +11423,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, if (!valid_thread_id (thread)) invalid_thread_id_error (thread); } - else if (toklen == 4 && !strncmp (tok, "mask", 4)) + else if (toklen == 4 && startswith (tok, "mask")) { /* We've found a "mask" token, which means the user wants to create a hardware watchpoint that is going to have the mask @@ -15493,7 +15493,7 @@ strace_command (char *arg, int from_tty) /* Decide if we are dealing with a static tracepoint marker (`-m'), or with a normal static tracepoint. */ - if (arg && strncmp (arg, "-m", 2) == 0 && isspace (arg[2])) + if (arg && startswith (arg, "-m") && isspace (arg[2])) ops = &strace_marker_breakpoint_ops; else ops = &tracepoint_breakpoint_ops; |