rendered paste bodyfunction system_extract_version($version_string) {
$core_version = substr(VERSION, 0, strpos(VERSION, '.'));
$pattern = '/DRUPAL-'. $core_version .'(?:--(?P<major>\d+)(?:-(?P<minor>\d+))?)(?P<extra>-.+)?/';
if (!$version_string) {
$version = t('undefined');
}
elseif (empty($version_string)) {
$version = t('latest dev');
}
elseif (preg_match($pattern, $version_string, $matches)) {
if (!isset($matches['major'])) {
$version = $core_version .'.x-dev';
}
elseif (!isset($matches['minor'])) {
$version = $core_version .'.x-'. $matches['major'] .'.x-dev';
}
else {
$version = $core_version .'.x-'. $matches['major'] .'-'. $matches['minor'] . drupal_strtolower($matches['extra']);
}
}
return check_plain($version);
}