diff options
Diffstat (limited to 'src/scanner.c')
-rw-r--r-- | src/scanner.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/src/scanner.c b/src/scanner.c index 5f06e8e..a239c71 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -31,6 +31,7 @@ #include <stdbool.h> #include <stdio.h> #include <stdarg.h> +#include <stdint.h> #include <string.h> #include <errno.h> #include <ctype.h> @@ -49,6 +50,8 @@ extern int DTD_DATA_len; #include "wayland-util.h" +#define PROGRAM_NAME "wayland-scanner" + enum side { CLIENT, SERVER, @@ -57,8 +60,8 @@ enum side { static int usage(int ret) { - fprintf(stderr, "usage: ./scanner [OPTION] [client-header|server-header|code]" - " [input_file output_file]\n"); + fprintf(stderr, "usage: %s [OPTION] [client-header|server-header|code]" + " [input_file output_file]\n", PROGRAM_NAME); fprintf(stderr, "\n"); fprintf(stderr, "Converts XML protocol descriptions supplied on " "stdin or input file to client\n" @@ -76,7 +79,7 @@ usage(int ret) static int scanner_version(int ret) { - fprintf(stderr, "wayland-scanner %s\n", WAYLAND_VERSION); + fprintf(stderr, "%s %s\n", PROGRAM_NAME, WAYLAND_VERSION); exit(ret); } @@ -236,7 +239,7 @@ static void * fail_on_null(void *p) { if (p == NULL) { - fprintf(stderr, "wayland-scanner: out of memory\n"); + fprintf(stderr, "%s: out of memory\n", PROGRAM_NAME); exit(EXIT_FAILURE); } @@ -574,8 +577,17 @@ free_interface(struct interface *interface) free(interface); } -/* convert string to unsigned integer, - * in the case of error, return -1 */ +/* Convert string to unsigned integer + * + * Parses a non-negative base-10 number from the given string. If the + * specified string is blank, contains non-numerical characters, is out + * of range, or results in a negative number, -1 is returned to indicate + * an error. + * + * Upon error, this routine does not modify or set errno. + * + * Returns -1 on error, or a non-negative integer on success + */ static int strtouint(const char *str) { @@ -808,7 +820,7 @@ find_enumeration(struct protocol *protocol, struct interface *i; struct enumeration *e; char *enum_name; - uint idx = 0, j; + uint32_t idx = 0, j; for (j = 0; j + 1 < strlen(enum_attribute); j++) { if (enum_attribute[j] == '.') { @@ -962,7 +974,7 @@ emit_opcodes(struct wl_list *message_list, struct interface *interface) opcode = 0; wl_list_for_each(m, message_list, link) - printf("#define %s_%s\t%d\n", + printf("#define %s_%s %d\n", interface->uppercase_name, m->uppercase_name, opcode++); printf("\n"); @@ -975,7 +987,7 @@ emit_opcode_versions(struct wl_list *message_list, struct interface *interface) wl_list_for_each(m, message_list, link) { printf("/**\n * @ingroup iface_%s\n */\n", interface->name); - printf("#define %s_%s_SINCE_VERSION\t%d\n", + printf("#define %s_%s_SINCE_VERSION %d\n", interface->uppercase_name, m->uppercase_name, m->since); } @@ -1350,7 +1362,7 @@ emit_structs(struct wl_list *message_list, struct interface *interface, enum sid if (side == CLIENT) { printf("/**\n" - " * @ingroup %s_iface\n" + " * @ingroup iface_%s\n" " */\n", interface->name); printf("static inline int\n" "%s_add_listener(struct %s *%s,\n" @@ -1467,7 +1479,7 @@ emit_header(struct protocol *protocol, enum side side) const char *s = (side == SERVER) ? "SERVER" : "CLIENT"; char **p, *prev; - printf("/* Generated by wayland-scanner %s */\n\n", WAYLAND_VERSION); + printf("/* Generated by %s %s */\n\n", PROGRAM_NAME, WAYLAND_VERSION); printf("#ifndef %s_%s_PROTOCOL_H\n" "#define %s_%s_PROTOCOL_H\n" @@ -1542,10 +1554,12 @@ emit_header(struct protocol *protocol, enum side side) emit_structs(&i->request_list, i, side); emit_opcodes(&i->event_list, i); emit_opcode_versions(&i->event_list, i); + emit_opcode_versions(&i->request_list, i); emit_event_wrappers(&i->event_list, i); } else { emit_structs(&i->event_list, i, side); emit_opcodes(&i->request_list, i); + emit_opcode_versions(&i->event_list, i); emit_opcode_versions(&i->request_list, i); emit_stubs(&i->request_list, i); } @@ -1670,7 +1684,7 @@ emit_code(struct protocol *protocol) struct wl_array types; char **p, *prev; - printf("/* Generated by wayland-scanner %s */\n\n", WAYLAND_VERSION); + printf("/* Generated by %s %s */\n\n", PROGRAM_NAME, WAYLAND_VERSION); if (protocol->copyright) format_text_to_comment(protocol->copyright, true); |