diff options
author | Mark Wielaard <mjw@redhat.com> | 2015-02-04 18:14:33 +0100 |
---|---|---|
committer | Mark Wielaard <mjw@redhat.com> | 2015-02-10 21:20:38 +0100 |
commit | b1ffba5a7fe1eb1fb97f3e81dd5cc78b59eb1fea (patch) | |
tree | 8e4b94d03e580b3dca27cc1408540eab86e7ed4f /gdb/utils.c | |
parent | 01b088bc51fe37e07905d36547f4ea43904837c0 (diff) | |
download | gdb-b1ffba5a7fe1eb1fb97f3e81dd5cc78b59eb1fea.zip gdb-b1ffba5a7fe1eb1fb97f3e81dd5cc78b59eb1fea.tar.gz gdb-b1ffba5a7fe1eb1fb97f3e81dd5cc78b59eb1fea.tar.bz2 |
Change producer_is_gcc function return type to bool.
gdb/ChangeLog:
* utils.h (producer_is_gcc): Change return type to bool. Add major
argument.
* utils.c (producer_is_gcc): Likewise.
(producer_is_gcc_ge_4): Adjust producer_is_gcc call.
* dwarf2read.c (check_producer): Likewise.
Diffstat (limited to 'gdb/utils.c')
-rw-r--r-- | gdb/utils.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/gdb/utils.c b/gdb/utils.c index 909476b..2b54739 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -3259,7 +3259,9 @@ int producer_is_gcc_ge_4 (const char *producer) { int major, minor; - major = producer_is_gcc (producer, &minor); + + if (! producer_is_gcc (producer, &major, &minor)) + return -1; if (major < 4) return -1; if (major > 4) @@ -3267,17 +3269,24 @@ producer_is_gcc_ge_4 (const char *producer) return minor; } -/* Returns the major version number if the given PRODUCER string is GCC and - sets the MINOR version. Returns -1 if the given PRODUCER is NULL or it - isn't GCC. */ -int -producer_is_gcc (const char *producer, int *minor) +/* Returns true if the given PRODUCER string is GCC and sets the MAJOR + and MINOR versions when not NULL. Returns false if the given PRODUCER + is NULL or it isn't GCC. */ + +bool +producer_is_gcc (const char *producer, int *major, int *minor) { const char *cs; - int major; if (producer != NULL && strncmp (producer, "GNU ", strlen ("GNU ")) == 0) { + int maj, min; + + if (major == NULL) + major = &maj; + if (minor == NULL) + minor = &min; + /* Skip any identifier after "GNU " - such as "C11" "C++" or "Java". A full producer string might look like: "GNU C 4.7.2" @@ -3289,7 +3298,7 @@ producer_is_gcc (const char *producer, int *minor) cs++; if (*cs && isspace (*cs)) cs++; - if (sscanf (cs, "%d.%d", &major, minor) == 2) + if (sscanf (cs, "%d.%d", major, minor) == 2) return major; } |