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/utils.c | |
parent | e80417caef36c7d5e3d1da6a3b396a872d9d7201 (diff) | |
download | binutils-gdb-61012eef8463764ccd9117dc1c9bc43cc452b7cc.tar.gz |
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/utils.c')
-rw-r--r-- | gdb/utils.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/gdb/utils.c b/gdb/utils.c index 4f9f4f05a2d..7172bba719e 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -2663,8 +2663,7 @@ subset_compare (char *string_to_compare, char *template_string) if (template_string != (char *) NULL && string_to_compare != (char *) NULL && strlen (string_to_compare) <= strlen (template_string)) match = - (strncmp - (template_string, string_to_compare, strlen (string_to_compare)) == 0); + (startswith (template_string, string_to_compare)); else match = 0; return match; @@ -3278,7 +3277,7 @@ producer_is_gcc (const char *producer, int *major, int *minor) { const char *cs; - if (producer != NULL && strncmp (producer, "GNU ", strlen ("GNU ")) == 0) + if (producer != NULL && startswith (producer, "GNU ")) { int maj, min; |