Index: gcc/config/darwin-c.c
===================================================================
--- gcc/config/darwin-c.c.orig
+++ gcc/config/darwin-c.c
@@ -564,29 +564,180 @@ find_subframework_header (cpp_reader *pf
-/* Return the value of darwin_macosx_version_min suitable for the
- __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro,
- so '10.4.2' becomes 1040. The lowest digit is always zero.
- Print a warning if the version number can't be understood. */
+/* Given a version string, return the version as a statically-allocated
+ array of three non-negative integers. If the version string is
+ Version strings must consist of one, two, or three tokens, each
+ separated by a single period. Each token must contain only the
+ characters '0' through '9' and is converted to an equivalent
+ integer. Omitted tokens are treated as zeros. For example:
+ "10.10" becomes {10,10,0}
+ "10.10.1" becomes {10,10,1}
+ "10.000010.1" becomes {10,10,1}
+ "10.010.001" becomes {10,10,1}
+ "000010.10.00001" becomes {10,10,1} */
+enum version_components { MAJOR, MINOR, TINY };
+static const unsigned long *
+parse_version (const char *version_str)
+ static unsigned long version_array[3];
+ version_len = strlen (version_str);
+ /* Version string must consist of digits and periods only. */
+ if (strspn (version_str, "0123456789.") != version_len)
+ if (! ISDIGIT (version_str[0]) || ! ISDIGIT (version_str[version_len - 1]))
+ version_array[MAJOR] = strtoul (version_str, &end, 10);
+ version_str = end + ((*end == '.') ? 1 : 0);
+ /* Version string must not contain adjacent periods. */
+ if (*version_str == '.')
+ version_array[MINOR] = strtoul (version_str, &end, 10);
+ version_str = end + ((*end == '.') ? 1 : 0);
+ version_array[TINY] = strtoul (version_str, &end, 10);