3 * Parsing for GC options.
5 * Copyright (C) 2015 Xamarin Inc
7 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
20 * mono_gc_parse_environment_string_extract_number:
21 * \param str points to the first digit of the number
22 * \param out pointer to the variable that will receive the value
23 * Tries to extract a number from the passed string, taking in to account m, k
25 * \returns TRUE if passing was successful
28 mono_gc_parse_environment_string_extract_number (const char *str
, size_t *out
)
31 int len
= strlen (str
), shift
= 0;
33 gboolean is_suffix
= FALSE
;
39 suffix
= str
[len
- 1];
54 if (!isdigit (suffix
))
60 val
= strtol (str
, &endptr
, 10);
62 if ((errno
== ERANGE
&& (val
== LONG_MAX
|| val
== LONG_MIN
))
63 || (errno
!= 0 && val
== 0) || (endptr
== str
))
69 if (*(endptr
+ 1)) /* Invalid string. */
72 unshifted
= (size_t)val
;
74 if (((size_t)val
>> shift
) != unshifted
) /* value too large */