Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Backports:SLE-12:Update
wayland
0004-scanner-Add-location-to-elements-so-we-can...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0004-scanner-Add-location-to-elements-so-we-can-give-bett.patch of Package wayland
From a71cf48ce0d92d891461fd2a2da05860b418dcee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= <krh@bitplanet.net> Date: Fri, 15 Nov 2013 14:37:55 -0800 Subject: [PATCH 2/2] scanner: Add location to elements so we can give better errors/warnings --- src/scanner.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/scanner.c b/src/scanner.c index a96d3e7..9624618 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -64,6 +64,7 @@ struct protocol { }; struct interface { + struct location loc; char *name; char *uppercase_name; int version; @@ -76,6 +77,7 @@ struct interface { }; struct message { + struct location loc; char *name; char *uppercase_name; struct wl_list arg_list; @@ -268,6 +270,19 @@ fail(struct location *loc, const char *msg, ...) exit(EXIT_FAILURE); } +static void +warn(struct location *loc, const char *msg, ...) +{ + va_list ap; + + va_start(ap, msg); + fprintf(stderr, "%s:%d: warning: ", + loc->filename, loc->line_number); + vfprintf(stderr, msg, ap); + fprintf(stderr, "\n"); + va_end(ap); +} + static int is_nullable_type(struct arg *arg) { @@ -345,6 +360,7 @@ start_element(void *data, const char *element_name, const char **atts) fail(&ctx->loc, "no interface version given"); interface = xmalloc(sizeof *interface); + interface->loc = ctx->loc; interface->name = xstrdup(name); interface->uppercase_name = uppercase_dup(name); interface->version = version; @@ -362,6 +378,7 @@ start_element(void *data, const char *element_name, const char **atts) fail(&ctx->loc, "no request name given"); message = xmalloc(sizeof *message); + message->loc = ctx->loc; message->name = xstrdup(name); message->uppercase_name = uppercase_dup(name); wl_list_init(&message->arg_list); @@ -619,9 +636,10 @@ emit_stubs(struct wl_list *message_list, struct interface *interface) } if (!has_destructor && has_destroy) { - fprintf(stderr, - "interface %s has method named destroy but" - "no destructor", interface->name); + fail(&interface->loc, + "interface '%s' has method named destroy " + "but no destructor", + interface->name); exit(EXIT_FAILURE); } @@ -640,10 +658,10 @@ emit_stubs(struct wl_list *message_list, struct interface *interface) wl_list_for_each(m, message_list, link) { if (m->new_id_count > 1) { - fprintf(stderr, - "warning: %s::%s has more than " - "one new_id arg, not emitting stub\n", - interface->name, m->name); + warn(&m->loc, + "request '%s::%s' has more than " + "one new_id arg, not emitting stub\n", + interface->name, m->name); continue; } -- 2.8.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor