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/p-typeprint.c | |
parent | e80417caef36c7d5e3d1da6a3b396a872d9d7201 (diff) | |
download | fsf-binutils-gdb-61012eef8463764ccd9117dc1c9bc43cc452b7cc.zip fsf-binutils-gdb-61012eef8463764ccd9117dc1c9bc43cc452b7cc.tar.gz fsf-binutils-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/p-typeprint.c')
-rw-r--r-- | gdb/p-typeprint.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c index 5a7a887..b5bf4d4 100644 --- a/gdb/p-typeprint.c +++ b/gdb/p-typeprint.c @@ -154,8 +154,8 @@ void pascal_type_print_method_args (const char *physname, const char *methodname, struct ui_file *stream) { - int is_constructor = (strncmp (physname, "__ct__", 6) == 0); - int is_destructor = (strncmp (physname, "__dt__", 6) == 0); + int is_constructor = (startswith (physname, "__ct__")); + int is_destructor = (startswith (physname, "__dt__")); if (is_constructor || is_destructor) { @@ -567,7 +567,7 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show, { QUIT; /* Don't print out virtual function table. */ - if ((strncmp (TYPE_FIELD_NAME (type, i), "_vptr", 5) == 0) + if ((startswith (TYPE_FIELD_NAME (type, i), "_vptr")) && is_cplus_marker ((TYPE_FIELD_NAME (type, i))[5])) continue; @@ -643,8 +643,8 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show, { const char *physname = TYPE_FN_FIELD_PHYSNAME (f, j); - int is_constructor = (strncmp (physname, "__ct__", 6) == 0); - int is_destructor = (strncmp (physname, "__dt__", 6) == 0); + int is_constructor = (startswith (physname, "__ct__")); + int is_destructor = (startswith (physname, "__dt__")); QUIT; if (TYPE_FN_FIELD_PROTECTED (f, j)) |