"python" optionally followed by an explicit numeric version (digits and dots * only, e.g. "python3", "python3.12"). Bounded and explicit so arbitrary * suffixes like "python-wrapper" are rejected. */
| 1093 | * only, e.g. "python3", "python3.12"). Bounded and explicit so arbitrary |
| 1094 | * suffixes like "python-wrapper" are rejected. */ |
| 1095 | static bool is_python_interp(const char *base) { |
| 1096 | if (strncmp(base, "python", SLEN("python")) != 0) { |
| 1097 | return false; |
| 1098 | } |
| 1099 | const char *version = base + SLEN("python"); |
| 1100 | if (*version == '\0') { |
| 1101 | return true; |
| 1102 | } |
| 1103 | |
| 1104 | /* Each numeric component must contain at least one digit. */ |
| 1105 | bool need_digit = true; |
| 1106 | for (const char *v = version; *v; v++) { |
| 1107 | if (isdigit((unsigned char)*v)) { |
| 1108 | need_digit = false; |
| 1109 | } else if (*v == '.' && !need_digit) { |
| 1110 | need_digit = true; |
| 1111 | } else { |
| 1112 | return false; |
| 1113 | } |
| 1114 | } |
| 1115 | return !need_digit; |
| 1116 | } |
| 1117 | |
| 1118 | /* Map an interpreter basename to a language, or CBM_LANG_COUNT if unrecognized. |
| 1119 | * Non-python interpreters are matched exactly (no prefix/suffix logic). */ |
no outgoing calls
no test coverage detected