util: add a env getter for versions
This lets us parse a standard major.minor version. Reviewed-by: Karol Herbst <kherbst@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7520>
This commit is contained in:
@@ -216,6 +216,30 @@ debug_get_num_option(const char *name, long dfault)
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
debug_get_version_option(const char *name, unsigned *major, unsigned *minor)
|
||||
{
|
||||
const char *str;
|
||||
|
||||
str = os_get_option(name);
|
||||
if (str) {
|
||||
unsigned v_maj, v_min;
|
||||
int n;
|
||||
|
||||
n = sscanf(str, "%u.%u", &v_maj, &v_min);
|
||||
if (n != 2) {
|
||||
debug_printf("Illegal version specified for %s : %s\n", name, str);
|
||||
return;
|
||||
}
|
||||
*major = v_maj;
|
||||
*minor = v_min;
|
||||
}
|
||||
|
||||
if (debug_get_option_should_print())
|
||||
debug_printf("%s: %s = %u.%u\n", __FUNCTION__, name, *major, *minor);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static bool
|
||||
str_has_option(const char *str, const char *name)
|
||||
|
||||
@@ -157,6 +157,9 @@ debug_disable_error_message_boxes(void);
|
||||
long
|
||||
debug_get_num_option(const char *name, long dfault);
|
||||
|
||||
void
|
||||
debug_get_version_option(const char *name, unsigned *major, unsigned *minor);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
__declspec(noreturn)
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user