forked from Imagelibrary/binutils-gdb
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:
@@ -68,4 +68,13 @@ char *savestring (const char *ptr, size_t len);
|
||||
|
||||
extern char *safe_strerror (int);
|
||||
|
||||
/* Return non-zero if the start of STRING matches PATTERN, zero
|
||||
otherwise. */
|
||||
|
||||
static inline int
|
||||
startswith (const char *string, const char *pattern)
|
||||
{
|
||||
return strncmp (string, pattern, strlen (pattern)) == 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user