Change streq to return bool
I wanted to use streq with std::unique in another (upcoming) patch in this seres, so I changed it to return bool. To my surprise, this lead to regressions. The cause turned out to be that streq was used as an htab callback -- by casting it to the correct function type. This sort of cast is invalid, so this patch adds a variant which is directly suitable for use by htab. (Note that I did not add an overload, as I could not get that to work with template deduction in the other patch.) ChangeLog 2018-04-05 Tom Tromey <tom@tromey.com> * completer.c (completion_tracker::completion_tracker): Remove cast. (completion_tracker::discard_completions): Likewise. * breakpoint.c (ambiguous_names_p): Remove cast. * ada-lang.c (_initialize_ada_language): Remove cast. * utils.h (streq): Update. (streq_hash): Add new declaration. * utils.c (streq): Return bool. (streq_hash): New function.
This commit is contained in:
parent
9be2c17a90
commit
459a2e4ccf
6 changed files with 37 additions and 12 deletions
13
gdb/utils.c
13
gdb/utils.c
|
@ -2601,13 +2601,22 @@ strcmp_iw_ordered (const char *string1, const char *string2)
|
|||
}
|
||||
}
|
||||
|
||||
/* A simple comparison function with opposite semantics to strcmp. */
|
||||
/* See utils.h. */
|
||||
|
||||
int
|
||||
bool
|
||||
streq (const char *lhs, const char *rhs)
|
||||
{
|
||||
return !strcmp (lhs, rhs);
|
||||
}
|
||||
|
||||
/* See utils.h. */
|
||||
|
||||
int
|
||||
streq_hash (const void *lhs, const void *rhs)
|
||||
{
|
||||
return streq ((const char *) lhs, (const char *) rhs);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue