[PATCH v2 wayland 2/5] scanner: add helper function to convert "since" to a version

Yong Bakos junk at humanoriented.com
Fri Jan 20 14:15:49 UTC 2017


Peter,

> On Jan 11, 2017, at 4:13 PM, Peter Hutterer <peter.hutterer at who-t.net> wrote:
> 
> Same code we already had, just moved into a helper function
> 
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> Reviewed-by: Yong Bakos <ybakos at humanoriented.com>

No change from v1 here and so remains

Reviewed-by: Yong Bakos <ybakos at humanoriented.com>
Tested-by: Yong Bakos <ybakos at humanoriented.com>

yong


> ---
> No changes to v1 
> 
> src/scanner.c | 33 ++++++++++++++++++++++-----------
> 1 file changed, 22 insertions(+), 11 deletions(-)
> 
> diff --git a/src/scanner.c b/src/scanner.c
> index a239c71..5d66fa4 100644
> --- a/src/scanner.c
> +++ b/src/scanner.c
> @@ -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");
> -- 
> 2.9.3
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel



More information about the wayland-devel mailing list