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.
This commit is contained in:
Gary Benson 2015-03-06 09:42:06 +00:00
parent e80417caef
commit 61012eef84
77 changed files with 309 additions and 329 deletions

View file

@ -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))