From f199fc477963290a9bbc3a212f22926eb8f4ec9b Mon Sep 17 00:00:00 2001 From: Johan Malm Date: Thu, 6 Aug 2020 15:09:13 +0100 Subject: [PATCH] tokenize.c, parse.c: rename functions --- include/theme/xbm/parse.h | 10 +++++++--- include/theme/xbm/tokenize.h | 9 +-------- src/theme/xbm/parse.c | 4 ++-- src/theme/xbm/tokenize.c | 2 +- src/theme/xbm/xbm.c | 8 +++++--- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/include/theme/xbm/parse.h b/include/theme/xbm/parse.h index 3af8616e..bd9e0652 100644 --- a/include/theme/xbm/parse.h +++ b/include/theme/xbm/parse.h @@ -17,11 +17,15 @@ struct pixmap { }; /** - * xbm_create_pixmap - parse xbm tokens and create pixmap + * parse_xbm_tokens - parse xbm tokens and create pixmap * @tokens: token vector */ -struct pixmap xbm_create_pixmap(struct token *tokens); +struct pixmap parse_xbm_tokens(struct token *tokens); -struct pixmap xbm_create_pixmap_builtin(const char *button); +/** + * parse_xbm_builtin - parse builtin xbm button and create pixmap + * @button: button byte array (xbm format) + */ +struct pixmap parse_xbm_builtin(const char *button); #endif /* __LABWC_PARSE_H */ diff --git a/include/theme/xbm/tokenize.h b/include/theme/xbm/tokenize.h index 38324a59..019eadcb 100644 --- a/include/theme/xbm/tokenize.h +++ b/include/theme/xbm/tokenize.h @@ -28,13 +28,6 @@ struct token { * @buffer: buffer containing xbm file * return token vector */ -struct token *xbm_tokenize(char *buffer); - -/** - * xbm_read_file - read file into buffer (as it's easier to tokenize that way) - * @filename: file to be read - * return allocated memory - */ -char *xbm_read_file(const char *filename); +struct token *tokenize_xbm(char *buffer); #endif /* __LABWC_TOKENIZE_H */ diff --git a/src/theme/xbm/parse.c b/src/theme/xbm/parse.c index 491ef269..a4823072 100644 --- a/src/theme/xbm/parse.c +++ b/src/theme/xbm/parse.c @@ -46,7 +46,7 @@ static void process_bytes(struct pixmap *pixmap, struct token *tokens) } } -struct pixmap xbm_create_pixmap(struct token *tokens) +struct pixmap parse_xbm_tokens(struct token *tokens) { struct pixmap pixmap = { 0 }; @@ -68,7 +68,7 @@ out: /* Assuming a 6x6 button for the time being */ /* TODO: pass width, height, vargs bytes */ -struct pixmap xbm_create_pixmap_builtin(const char *button) +struct pixmap parse_xbm_builtin(const char *button) { struct pixmap pixmap = { 0 }; diff --git a/src/theme/xbm/tokenize.c b/src/theme/xbm/tokenize.c index 52209dff..9cc74a83 100644 --- a/src/theme/xbm/tokenize.c +++ b/src/theme/xbm/tokenize.c @@ -78,7 +78,7 @@ static void get_special_char_token() current_buffer_position++; } -struct token *xbm_tokenize(char *buffer) +struct token *tokenize_xbm(char *buffer) { tokens = NULL; nr_tokens = 0; diff --git a/src/theme/xbm/xbm.c b/src/theme/xbm/xbm.c index 6fa98933..92581146 100644 --- a/src/theme/xbm/xbm.c +++ b/src/theme/xbm/xbm.c @@ -33,7 +33,7 @@ static struct wlr_texture *texture_from_pixmap(struct wlr_renderer *renderer, static struct wlr_texture *texture_from_builtin(struct wlr_renderer *renderer, const char *button) { - struct pixmap pixmap = xbm_create_pixmap_builtin(button); + struct pixmap pixmap = parse_xbm_builtin(button); struct wlr_texture *texture = texture_from_pixmap(renderer, &pixmap); if (pixmap.data) free(pixmap.data); @@ -51,13 +51,15 @@ static char *xbm_path(const char *button) static void load_button(struct wlr_renderer *renderer, const char *filename, struct wlr_texture **texture, char *button) { + /* Read file into memory as it's easier to tokenzie that way */ char *buffer = grab_file(xbm_path(filename)); if (!buffer) goto out; fprintf(stderr, "loading %s\n", filename); - struct token *tokens = xbm_tokenize(buffer); + struct token *tokens = tokenize_xbm(buffer); free(buffer); - struct pixmap pixmap = xbm_create_pixmap(tokens); + + struct pixmap pixmap = parse_xbm_tokens(tokens); *texture = texture_from_pixmap(renderer, &pixmap); if (tokens) free(tokens);