Provide an inline startswith function in bfd.h
bfd/ * bfd-in.h (startswith): New inline. (CONST_STRNEQ): Use startswith. * bfd-in2.h: Regenerate. gdbsupport/ * common-utils.h (startswith): Delete version now supplied by bfd.h. libctf/ * ctf-impl.h: Include string.h.
This commit is contained in:
parent
38e41a8845
commit
e93388417c
7 changed files with 35 additions and 12 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2021-03-21 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
|
* bfd-in.h (startswith): New inline.
|
||||||
|
(CONST_STRNEQ): Use startswith.
|
||||||
|
* bfd-in2.h: Regenerate.
|
||||||
|
|
||||||
2021-03-20 Alan Modra <amodra@gmail.com>
|
2021-03-20 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
PR 27590
|
PR 27590
|
||||||
|
|
10
bfd/bfd-in.h
10
bfd/bfd-in.h
|
@ -65,7 +65,6 @@ extern "C" {
|
||||||
definition of strncmp is provided here.
|
definition of strncmp is provided here.
|
||||||
|
|
||||||
Note - these macros do NOT work if STR2 is not a constant string. */
|
Note - these macros do NOT work if STR2 is not a constant string. */
|
||||||
#define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0)
|
|
||||||
/* strcpy() can have a similar problem, but since we know we are
|
/* strcpy() can have a similar problem, but since we know we are
|
||||||
copying a constant string, we can use memcpy which will be faster
|
copying a constant string, we can use memcpy which will be faster
|
||||||
since there is no need to check for a NUL byte inside STR. We
|
since there is no need to check for a NUL byte inside STR. We
|
||||||
|
@ -564,3 +563,12 @@ struct ecoff_debug_swap;
|
||||||
struct ecoff_extr;
|
struct ecoff_extr;
|
||||||
struct bfd_link_info;
|
struct bfd_link_info;
|
||||||
struct bfd_link_hash_entry;
|
struct bfd_link_hash_entry;
|
||||||
|
|
||||||
|
/* Return TRUE if the start of STR matches PREFIX, FALSE otherwise. */
|
||||||
|
|
||||||
|
static inline bfd_boolean
|
||||||
|
startswith (const char *str, const char *prefix)
|
||||||
|
{
|
||||||
|
return strncmp (str, prefix, strlen (prefix)) == 0;
|
||||||
|
}
|
||||||
|
#define CONST_STRNEQ(STR1,STR2) startswith (STR1, STR2)
|
||||||
|
|
|
@ -72,7 +72,6 @@ extern "C" {
|
||||||
definition of strncmp is provided here.
|
definition of strncmp is provided here.
|
||||||
|
|
||||||
Note - these macros do NOT work if STR2 is not a constant string. */
|
Note - these macros do NOT work if STR2 is not a constant string. */
|
||||||
#define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0)
|
|
||||||
/* strcpy() can have a similar problem, but since we know we are
|
/* strcpy() can have a similar problem, but since we know we are
|
||||||
copying a constant string, we can use memcpy which will be faster
|
copying a constant string, we can use memcpy which will be faster
|
||||||
since there is no need to check for a NUL byte inside STR. We
|
since there is no need to check for a NUL byte inside STR. We
|
||||||
|
@ -571,6 +570,15 @@ struct ecoff_debug_swap;
|
||||||
struct ecoff_extr;
|
struct ecoff_extr;
|
||||||
struct bfd_link_info;
|
struct bfd_link_info;
|
||||||
struct bfd_link_hash_entry;
|
struct bfd_link_hash_entry;
|
||||||
|
|
||||||
|
/* Return TRUE if the start of STR matches PREFIX, FALSE otherwise. */
|
||||||
|
|
||||||
|
static inline bfd_boolean
|
||||||
|
startswith (const char *str, const char *prefix)
|
||||||
|
{
|
||||||
|
return strncmp (str, prefix, strlen (prefix)) == 0;
|
||||||
|
}
|
||||||
|
#define CONST_STRNEQ(STR1,STR2) startswith (STR1, STR2)
|
||||||
/* Extracted from init.c. */
|
/* Extracted from init.c. */
|
||||||
unsigned int bfd_init (void);
|
unsigned int bfd_init (void);
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2021-03-21 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
|
* common-utils.h (startswith): Delete version now supplied by bfd.h.
|
||||||
|
|
||||||
2021-02-05 Paul E. Murphy <murphy@linux.ibm.com>
|
2021-02-05 Paul E. Murphy <murphy@linux.ibm.com>
|
||||||
|
|
||||||
* common-defs.h (ATTRIBUTE_PRINTF): Rename
|
* common-defs.h (ATTRIBUTE_PRINTF): Rename
|
||||||
|
|
|
@ -116,16 +116,8 @@ std::string extract_string_maybe_quoted (const char **arg);
|
||||||
|
|
||||||
extern const char *safe_strerror (int);
|
extern const char *safe_strerror (int);
|
||||||
|
|
||||||
/* Return true if the start of STRING matches PATTERN, false otherwise. */
|
/* Version of startswith that takes string_view arguments. Return
|
||||||
|
true if the start of STRING matches PATTERN, false otherwise. */
|
||||||
static inline bool
|
|
||||||
startswith (const char *string, const char *pattern)
|
|
||||||
{
|
|
||||||
return strncmp (string, pattern, strlen (pattern)) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Version of startswith that takes string_view arguments. See comment
|
|
||||||
above. */
|
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
startswith (gdb::string_view string, gdb::string_view pattern)
|
startswith (gdb::string_view string, gdb::string_view pattern)
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2021-03-21 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
|
* ctf-impl.h: Include string.h.
|
||||||
|
|
||||||
2021-03-18 Nick Alcock <nick.alcock@oracle.com>
|
2021-03-18 Nick Alcock <nick.alcock@oracle.com>
|
||||||
|
|
||||||
* ctf-types.c (ctf_type_encoding): Support, after a fashion, for enums.
|
* ctf-types.c (ctf_type_encoding): Support, after a fashion, for enums.
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <elf.h>
|
#include <elf.h>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue