This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] avr: simplify some option parsing with strcasecmp ()
- From: Trevor Saunders <tbsaunde at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 3 Apr 2016 23:05:36 -0000
- Subject: [binutils-gdb] avr: simplify some option parsing with strcasecmp ()
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f73e41ef3703be34db1c7e08271e6ac8bd758144
commit f73e41ef3703be34db1c7e08271e6ac8bd758144
Author: Trevor Saunders <tbsaunde+binutils@tbsaunde.org>
Date: Sat Apr 2 07:57:10 2016 -0400
avr: simplify some option parsing with strcasecmp ()
Instead of canonicalizing the argument we can just use a case insensitive
compare.
gas/ChangeLog:
2016-04-03 Trevor Saunders <tbsaunde+binutils@tbsaunde.org>
* config/tc-avr.c (md_parse_option): Use strcasecmp () to compare
strings.
Diff:
---
gas/ChangeLog | 5 +++++
gas/config/tc-avr.c | 13 +------------
2 files changed, 6 insertions(+), 12 deletions(-)
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 6c76391..8d6ba9b 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,8 @@
+2016-04-03 Trevor Saunders <tbsaunde+binutils@tbsaunde.org>
+
+ * config/tc-avr.c (md_parse_option): Use strcasecmp () to compare
+ strings.
+
2016-04-02 Alan Modra <amodra@gmail.com>
PR 19896
diff --git a/gas/config/tc-avr.c b/gas/config/tc-avr.c
index 852002f..999ffb4 100644
--- a/gas/config/tc-avr.c
+++ b/gas/config/tc-avr.c
@@ -562,22 +562,11 @@ md_parse_option (int c, const char *arg)
case OPTION_MMCU:
{
int i;
- char *s = xmalloc (strlen (arg) + 1);
-
- {
- char *t = s;
- const char *arg1 = arg;
-
- do
- *t = TOLOWER (*arg1++);
- while (*t++);
- }
for (i = 0; mcu_types[i].name; ++i)
- if (strcmp (mcu_types[i].name, s) == 0)
+ if (strcasecmp (mcu_types[i].name, arg) == 0)
break;
- free (s);
if (!mcu_types[i].name)
{
show_mcu_list (stderr);