summaryrefslogtreecommitdiff
path: root/gcc/opts-common.c
diff options
context:
space:
mode:
authorcltang <cltang@138bc75d-0d04-0410-961f-82ee72b054a4>2013-12-16 04:28:24 +0000
committercltang <cltang@138bc75d-0d04-0410-961f-82ee72b054a4>2013-12-16 04:28:24 +0000
commitde42969dc5294bd20fed6daa67e018a1ed7f89b2 (patch)
treeaf0bfba0c0d2023977d4f9c701dbda725fc6a7a7 /gcc/opts-common.c
parent622a92d1765f06adc7e153840fb46e84e6fc02e9 (diff)
downloadgcc-de42969dc5294bd20fed6daa67e018a1ed7f89b2.tar.gz
2013-12-16 Chung-Lin Tang <cltang@codesourcery.com>
* opts-common.c (integral_argument): Add support for hexadecimal command option integer arguments. Update comments. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@206008 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/opts-common.c')
-rw-r--r--gcc/opts-common.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index 9d186a759cb..161ddf0122c 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;
}