Commit 317c1849 by Chung-Lin Tang Committed by Chung-Lin Tang

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
parent de9d8725
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> 2013-12-14 Jan Hubicka <jh@suse.cz>
PR ipa/59265 PR ipa/59265
...@@ -147,7 +147,7 @@ find_opt (const char *input, unsigned int lang_mask) ...@@ -147,7 +147,7 @@ find_opt (const char *input, unsigned int lang_mask)
return match_wrong_lang; 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. */ value, otherwise return -1. */
int int
...@@ -161,6 +161,17 @@ integral_argument (const char *arg) ...@@ -161,6 +161,17 @@ integral_argument (const char *arg)
if (*p == '\0') if (*p == '\0')
return atoi (arg); 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; return -1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment