mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
scanner: add helper function to convert "since" to a version
Same code we already had, just moved into a helper function Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Yong Bakos <ybakos@humanoriented.com> Reviewed-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
parent
493eda337a
commit
6c481003a2
1 changed files with 22 additions and 11 deletions
|
|
@ -609,6 +609,27 @@ strtouint(const char *str)
|
|||
return (int)ret;
|
||||
}
|
||||
|
||||
static int
|
||||
version_from_since(struct parse_context *ctx, const char *since)
|
||||
{
|
||||
int version;
|
||||
|
||||
if (since != NULL) {
|
||||
version = strtouint(since);
|
||||
if (version == -1) {
|
||||
fail(&ctx->loc, "invalid integer (%s)\n", since);
|
||||
} else if (version > ctx->interface->version) {
|
||||
fail(&ctx->loc, "since (%u) larger than version (%u)\n",
|
||||
version, ctx->interface->version);
|
||||
}
|
||||
} else {
|
||||
version = 1;
|
||||
}
|
||||
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
static void
|
||||
start_element(void *data, const char *element_name, const char **atts)
|
||||
{
|
||||
|
|
@ -694,17 +715,7 @@ start_element(void *data, const char *element_name, const char **atts)
|
|||
if (type != NULL && strcmp(type, "destructor") == 0)
|
||||
message->destructor = 1;
|
||||
|
||||
if (since != NULL) {
|
||||
version = strtouint(since);
|
||||
if (version == -1) {
|
||||
fail(&ctx->loc, "invalid integer (%s)\n", since);
|
||||
} else if (version > ctx->interface->version) {
|
||||
fail(&ctx->loc, "since (%u) larger than version (%u)\n",
|
||||
version, ctx->interface->version);
|
||||
}
|
||||
} else {
|
||||
version = 1;
|
||||
}
|
||||
version = version_from_since(ctx, since);
|
||||
|
||||
if (version < ctx->interface->since)
|
||||
warn(&ctx->loc, "since version not increasing\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue