aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChung-Lin Tang <cltang@codesourcery.com>2013-12-16 04:28:24 +0000
committerChung-Lin Tang <cltang@gcc.gnu.org>2013-12-16 04:28:24 +0000
commit317c1849286a2acdf6e72bc2b0973d52b4ba5202 (patch)
treeaf0bfba0c0d2023977d4f9c701dbda725fc6a7a7
parentde9d8725274105280786bcbf77696ef234200c83 (diff)
downloadgcc-317c1849286a2acdf6e72bc2b0973d52b4ba5202.zip
gcc-317c1849286a2acdf6e72bc2b0973d52b4ba5202.tar.gz
gcc-317c1849286a2acdf6e72bc2b0973d52b4ba5202.tar.bz2
opts-common.c (integral_argument): Add support for hexadecimal command option integer arguments.
2013-12-16 Chung-Lin Tang <cltang@codesourcery.com> * opts-common.c (integral_argument): Add support for hexadecimal command option integer arguments. Update comments. From-SVN: r206008
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/opts-common.c13
2 files changed, 17 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 023a229..8b61a44 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2013-12-16 Chung-Lin Tang <cltang@codesourcery.com>
+
+ * opts-common.c (integral_argument): Add support for
+ hexadecimal command option integer arguments. Update comments.
+
2013-12-14 Jan Hubicka <jh@suse.cz>
PR ipa/59265
diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index 9d186a7..161ddf0 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -147,7 +147,7 @@ find_opt (const char *input, unsigned int lang_mask)
return match_wrong_lang;
}
-/* If ARG is a non-negative integer made up solely of digits, return its
+/* If ARG is a non-negative decimal or hexadecimal integer, return its
value, otherwise return -1. */
int
@@ -161,6 +161,17 @@ integral_argument (const char *arg)
if (*p == '\0')
return atoi (arg);
+ /* It wasn't a decimal number - try hexadecimal. */
+ if (arg[0] == '0' && (arg[1] == 'x' || arg[1] == 'X'))
+ {
+ p = arg + 2;
+ while (*p && ISXDIGIT (*p))
+ p++;
+
+ if (p != arg + 2 && *p == '\0')
+ return strtol (arg, NULL, 16);
+ }
+
return -1;
}