commit 6889fe73af2a0c518dfd29c77305704ad3a5e82b
parent b67502fe2a4f80b6aa16f55e479fdc902d149dbc
Author: lumidify <nobody@lumidify.org>
Date:   Tue, 14 Apr 2020 18:59:03 +0200
Miscellaneous style changes
Diffstat:
3 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/button.c b/button.c
@@ -68,7 +68,7 @@ void ltk_button_ini_handler(LtkTheme *theme, const char *prop, const char *value
 	} else if (strcmp(prop, "text_color") == 0) {
 		theme->button->text_color = ltk_create_xcolor(value);
 	} else {
-		printf("WARNING: Unknown property \"%s\" for button style.\n");
+		(void)printf("WARNING: Unknown property \"%s\" for button style.\n");
 	}
 }
 
@@ -174,7 +174,7 @@ LtkButton *ltk_create_button(LtkWindow *window, const char *text, void (*callbac
 void ltk_destroy_button(LtkButton *button)
 {
 	if (!button) {
-		printf("WARNING: Tried to destroy NULL button.\n");
+		(void)printf("WARNING: Tried to destroy NULL button.\n");
 	}
 	if (button->text) XDestroyImage(button->text);
 	if (button->text_hover) XDestroyImage(button->text_hover);
diff --git a/ltk.c b/ltk.c
@@ -72,7 +72,7 @@ void ltk_quit(void)
 
 void ltk_fatal(const char *msg)
 {
-	fprintf(stderr, msg);
+	(void)fprintf(stderr, msg);
 	ltk_clean_up();
 	exit(1);
 };
@@ -230,7 +230,7 @@ LtkTheme *ltk_load_theme(const char *path)
 	theme->window = malloc(sizeof(LtkWindowTheme));
 	theme->button = NULL;
 	if (ini_parse(path, ltk_ini_handler, theme) < 0) {
-		fprintf(stderr, "ERROR: Can't load theme %s\n.", path);
+		(void)fprintf(stderr, "ERROR: Can't load theme %s\n.", path);
 		exit(1);
 	}
 
diff --git a/text-hb.c b/text-hb.c
@@ -114,7 +114,7 @@ ltk_init_text(char *font_name)
 {
 	LtkTextManager *tm = malloc(sizeof(LtkTextManager));
 	if (!tm) {
-		printf("Memory exhausted when trying to create text manager.");
+		(void)printf("Memory exhausted when trying to create text manager.");
 		exit(1);
 	}
 	tm->font_paths = kh_init(fontid);
@@ -155,7 +155,7 @@ ltk_create_glyph_info(LtkFont *font, unsigned int id, float scale)
 {
 	LtkGlyphInfo *glyph = malloc(sizeof(LtkGlyphInfo));
 	if (!glyph) {
-		printf("Out of memory!\n");
+		(void)printf("Out of memory!\n");
 		exit(1);
 	}
 	
@@ -253,13 +253,13 @@ ltk_create_font(char *path, uint16_t id)
 	long len;
 	LtkFont *font = malloc(sizeof(LtkFont));
 	if (!font) {
-		fprintf(stderr, "Out of memory!\n");
+		(void)fprintf(stderr, "Out of memory!\n");
 		exit(1);
 	}
 	char *contents = ltk_read_file(path, &len);
 	if (!stbtt_InitFont(&font->info, contents, 0))
 	{
-		fprintf(stderr, "Failed to load font %s\n", path);
+		(void)fprintf(stderr, "Failed to load font %s\n", path);
 		exit(1);
 	}
 	/* FIXME: make use of the destroy function (last argument to hb_blob_create - see hb-blob.cc in harfbuzz source) */
@@ -355,7 +355,10 @@ ltk_create_text_line(LtkTextManager *tm, char *text, uint16_t fontid, uint16_t s
 
 	for (int p = 0; p <= ulen; p++) {
 		cur_script = hb_unicode_script(ufuncs, vis_str[p]);
-		if (p == ulen || (last_script != cur_script && cur_script != HB_SCRIPT_INHERITED && cur_script != HB_SCRIPT_COMMON)) {
+		if (p == ulen ||
+			(last_script != cur_script &&
+			 cur_script != HB_SCRIPT_INHERITED &&
+			 cur_script != HB_SCRIPT_COMMON)) {
 			FcPattern *pat = FcPatternDuplicate(tm->fcpattern);
 			FcPattern *match;
 			FcResult result;
@@ -379,7 +382,13 @@ ltk_create_text_line(LtkTextManager *tm, char *text, uint16_t fontid, uint16_t s
 			if (p == ulen) {
 				last_script = cur_script;
 			}
-			new_ts = ltk_create_text_segment(tm, vis_str + start_pos, p - start_pos, cur_font_id, size, last_script);
+			/* FIXME: There should be better handling for cases
+			   where an error occurs while creating the segment */
+			new_ts = ltk_create_text_segment(
+				tm, vis_str + start_pos,
+				p - start_pos, cur_font_id,
+				size, last_script
+			);
 			if (!new_ts) continue;
 			new_ts->next = NULL;
 			if (!tl->start_segment) tl->start_segment = new_ts;
@@ -404,7 +413,7 @@ ltk_create_text_line(LtkTextManager *tm, char *text, uint16_t fontid, uint16_t s
 	tl->w = tl->h = 0;
 	while (ts) {
 		if (HB_DIRECTION_IS_HORIZONTAL(ts->dir) != is_hor) {
-			fprintf(stderr, "WARNING: mixed horizontal/vertical text is not supported; ignoring\n");
+			(void)fprintf(stderr, "WARNING: mixed horizontal/vertical text is not supported; ignoring\n");
 			continue;
 		}
 		if (is_hor) {
@@ -462,7 +471,7 @@ ltk_create_text_segment(LtkTextManager *tm, uint32_t *text, unsigned int len, ui
 
 	LtkTextSegment *ts = malloc(sizeof(LtkTextSegment));
 	if (!ts) {
-		fprintf(stderr, "Out of memory!\n");
+		(void)fprintf(stderr, "Out of memory!\n");
 		exit(1);
 	}
 	ts->str = malloc(sizeof(uint32_t) * (len + 1));
@@ -476,7 +485,7 @@ ltk_create_text_segment(LtkTextManager *tm, uint32_t *text, unsigned int len, ui
 	hb_glyph_position_t *gpos, *gp;
 	unsigned int text_len = 0;
 	if (len < 1) {
-		printf("WARNING: ltk_render_text_segment: length of text is less than 1.\n");
+		(void)printf("WARNING: ltk_render_text_segment: length of text is less than 1.\n");
 		return NULL;
 	}