|
Lines 930-960
Link Here
|
| 930 |
|
930 |
|
| 931 |
/* Return the value of darwin_macosx_version_min suitable for the |
931 |
/* Return the value of darwin_macosx_version_min suitable for the |
| 932 |
__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro, |
932 |
__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro, |
| 933 |
so '10.4.2' becomes 1042. |
933 |
so '10.4.2' becomes 1042 and '10.10.2' becomes 101002. |
|
|
934 |
Cap patch level to 9 in the old format. |
| 934 |
Print a warning if the version number is not known. */ |
935 |
Print a warning if the version number is not known. */ |
| 935 |
static const char * |
936 |
static const char * |
| 936 |
/* APPLE LOCAL ARM 5683689 */ |
937 |
/* APPLE LOCAL ARM 5683689 */ |
| 937 |
macosx_version_as_macro (void) |
938 |
macosx_version_as_macro (void) |
| 938 |
{ |
939 |
{ |
| 939 |
static char result[] = "1000"; |
940 |
static char result[7] = "1000"; |
|
|
941 |
int inputindex = 3, outputindex = 2; |
| 940 |
|
942 |
|
|
|
943 |
/* make sure version starts with "10." - makes sure we can safely start |
| 944 |
* parsing at inputindex == 3 */ |
| 941 |
if (strncmp (darwin_macosx_version_min, "10.", 3) != 0) |
945 |
if (strncmp (darwin_macosx_version_min, "10.", 3) != 0) |
| 942 |
goto fail; |
946 |
goto fail; |
|
|
947 |
|
| 948 |
/* first character of minor version needs to be digit */ |
| 943 |
if (! ISDIGIT (darwin_macosx_version_min[3])) |
949 |
if (! ISDIGIT (darwin_macosx_version_min[3])) |
| 944 |
goto fail; |
950 |
goto fail; |
| 945 |
result[2] = darwin_macosx_version_min[3]; |
951 |
|
| 946 |
if (darwin_macosx_version_min[4] != '\0') |
952 |
result[outputindex++] = darwin_macosx_version_min[inputindex++]; |
|
|
953 |
|
| 954 |
if (ISDIGIT (darwin_macosx_version_min[inputindex])) { |
| 955 |
/* Starting with OS X 10.10, the macro ends '00' rather than '0', |
| 956 |
i.e. 10.10.x becomes 101000 rather than 10100. */ |
| 957 |
result[outputindex++] = darwin_macosx_version_min[inputindex++]; |
| 958 |
result[4] = '0'; |
| 959 |
result[5] = '0'; |
| 960 |
result[6] = '\0'; |
| 961 |
} |
| 962 |
|
| 963 |
/* if we're out of input, leave patch level at 0 or 00 and finish */ |
| 964 |
if (darwin_macosx_version_min[inputindex] == '\0') |
| 965 |
return result; |
| 966 |
|
| 967 |
/* a dot *must* follow now */ |
| 968 |
if (darwin_macosx_version_min[inputindex++] != '.') |
| 969 |
goto fail; |
| 970 |
|
| 971 |
/* a digit must follow after the dot */ |
| 972 |
if (! ISDIGIT (darwin_macosx_version_min[inputindex])) |
| 973 |
goto fail; |
| 974 |
|
| 975 |
/* old-style macro */ |
| 976 |
if (outputindex == 3) |
| 977 |
{ |
| 978 |
/* one-digit patch level */ |
| 979 |
if (darwin_macosx_version_min[inputindex + 1] == '\0') |
| 947 |
{ |
980 |
{ |
| 948 |
if (darwin_macosx_version_min[4] != '.') |
981 |
result[outputindex] = darwin_macosx_version_min[inputindex]; |
| 949 |
goto fail; |
982 |
return result; |
| 950 |
if (! ISDIGIT (darwin_macosx_version_min[5])) |
|
|
| 951 |
goto fail; |
| 952 |
if (darwin_macosx_version_min[6] != '\0') |
| 953 |
goto fail; |
| 954 |
result[3] = darwin_macosx_version_min[5]; |
| 955 |
} |
983 |
} |
| 956 |
else |
984 |
|
| 957 |
result[3] = '0'; |
985 |
inputindex++; |
|
|
986 |
if (! ISDIGIT (darwin_macosx_version_min[inputindex++])) |
| 987 |
goto fail; |
| 988 |
|
| 989 |
/* three digits? */ |
| 990 |
if (darwin_macosx_version_min[inputindex] != '\0') |
| 991 |
goto fail; |
| 992 |
|
| 993 |
/* no room for another digit. Traditional Apple GCC 4.2.1 doesn't accept |
| 994 |
* it but current clang caps it to 9. We choose to be in line with clang. */ |
| 995 |
result[outputindex] = '9'; |
| 996 |
return result; |
| 997 |
} |
| 998 |
|
| 999 |
/* new-style macro */ |
| 1000 |
|
| 1001 |
/* leave a leading zero if only one digit is following */ |
| 1002 |
if (darwin_macosx_version_min[inputindex + 1] == '\0') { |
| 1003 |
result[outputindex + 1] = darwin_macosx_version_min[inputindex]; |
| 1004 |
return result; |
| 1005 |
} |
| 1006 |
|
| 1007 |
result[outputindex++] = darwin_macosx_version_min[inputindex++]; |
| 1008 |
|
| 1009 |
/* a digit must follow now */ |
| 1010 |
if (! ISDIGIT (darwin_macosx_version_min[inputindex])) |
| 1011 |
goto fail; |
| 1012 |
|
| 1013 |
result[outputindex] = darwin_macosx_version_min[inputindex++]; |
| 1014 |
|
| 1015 |
/* no more input allowed */ |
| 1016 |
if (darwin_macosx_version_min[inputindex] != '\0') |
| 1017 |
goto fail; |
| 958 |
|
1018 |
|
| 959 |
return result; |
1019 |
return result; |
| 960 |
|
1020 |
|