changeset 168:aab824406d3d

misc: all printf-like function are name foof and vfoof
author David Demelier <markand@malikania.fr>
date Tue, 20 Oct 2020 15:09:39 +0200
parents b9b826cd9832
children eb0a7ab71023
files examples/example-debug.c examples/example-trace.c libcore/core/error.c libcore/core/error.h libcore/core/panic.c libcore/core/save.c libcore/core/script.c libcore/core/trace.c libcore/core/trace.h librpg/rpg/map.c librpg/rpg/map_state.c librpg/rpg/message.c libui/ui/button.c libui/ui/debug.c libui/ui/debug.h tests/test-error.c
diffstat 16 files changed, 72 insertions(+), 72 deletions(-) [+]
line wrap: on
line diff
--- a/examples/example-debug.c	Tue Oct 20 14:58:51 2020 +0200
+++ b/examples/example-debug.c	Tue Oct 20 15:09:39 2020 +0200
@@ -74,8 +74,8 @@
 
 		painter_set_color(0x4f8fbaff);
 		painter_clear();
-		debug(&report, "Game running.");
-		debug(&report, "mouse: %d, %d", x, y);
+		debugf(&report, "Game running.");
+		debugf(&report, "mouse: %d, %d", x, y);
 		painter_present();
 
 		if ((elapsed = clock_elapsed(&clock)) < 20)
--- a/examples/example-trace.c	Tue Oct 20 14:58:51 2020 +0200
+++ b/examples/example-trace.c	Tue Oct 20 15:09:39 2020 +0200
@@ -66,12 +66,12 @@
 					trace_hud_clear();
 					break;
 				default:
-					trace("keydown pressed: %d", ev.key.key);
+					tracef("keydown pressed: %d", ev.key.key);
 					break;
 				}
 				break;
 			case EVENT_CLICKDOWN:
-				trace("click at %d,%d", ev.click.x, ev.click.y);
+				tracef("click at %d,%d", ev.click.x, ev.click.y);
 				break;
 			case EVENT_QUIT:
 				return;
--- a/libcore/core/error.c	Tue Oct 20 14:58:51 2020 +0200
+++ b/libcore/core/error.c	Tue Oct 20 15:09:39 2020 +0200
@@ -36,29 +36,21 @@
 }
 
 bool
-error_errno(void)
-{
-	error_printf("%s", strerror(errno));
-
-	return false;
-}
-
-bool
-error_printf(const char *fmt, ...)
+errorf(const char *fmt, ...)
 {
 	assert(fmt);
 
 	va_list ap;
 
 	va_start(ap, fmt);
-	error_vprintf(fmt, ap);
+	verrorf(fmt, ap);
 	va_end(ap);
 
 	return false;
 }
 
 bool
-error_vprintf(const char *fmt, va_list ap)
+verrorf(const char *fmt, va_list ap)
 {
 	assert(fmt);
 
@@ -67,12 +59,20 @@
 	return false;
 }
 
+bool
+error_errno(void)
+{
+	errorf("%s", strerror(errno));
+
+	return false;
+}
+
 /* private: error_p.h */
 
 bool
 error_sdl(void)
 {
-	error_printf("%s", SDL_GetError());
+	errorf("%s", SDL_GetError());
 
 	return false;
 }
--- a/libcore/core/error.h	Tue Oct 20 14:58:51 2020 +0200
+++ b/libcore/core/error.h	Tue Oct 20 15:09:39 2020 +0200
@@ -39,6 +39,27 @@
 error(void);
 
 /**
+ * Set the game error with a printf-like format.
+ *
+ * \pre fmt != NULL
+ * \param fmt the format string
+ * \return Always false.
+ */
+bool
+errorf(const char *fmt, ...) PLAT_PRINTF(1, 2);
+
+/**
+ * Similar to \ref errorf.
+ *
+ * \pre fmt != NULL
+ * \param fmt the format stinrg
+ * \param ap the variadic arguments pointer
+ * \return Always false.
+ */
+bool
+verrorf(const char *fmt, va_list ap) PLAT_PRINTF(1, 0);
+
+/**
  * Convenient helper that sets last error from global C errno and then return
  * false.
  *
@@ -47,25 +68,4 @@
 bool
 error_errno(void);
 
-/**
- * Set the game error with a printf-like format.
- *
- * \pre fmt != NULL
- * \param fmt the format string
- * \return Always false.
- */
-bool
-error_printf(const char *fmt, ...) PLAT_PRINTF(1, 2);
-
-/**
- * Similar to \ref error_printf.
- *
- * \pre fmt != NULL
- * \param fmt the format stinrg
- * \param ap the variadic arguments pointer
- * \return Always false.
- */
-bool
-error_vprintf(const char *fmt, va_list ap) PLAT_PRINTF(1, 0);
-
 #endif /* !MOLKO_ERROR_H */
--- a/libcore/core/panic.c	Tue Oct 20 14:58:51 2020 +0200
+++ b/libcore/core/panic.c	Tue Oct 20 15:09:39 2020 +0200
@@ -45,7 +45,7 @@
 	 * called.
 	 */
 	va_start(ap, fmt);
-	error_vprintf(fmt, ap);
+	verrorf(fmt, ap);
 	va_end(ap);
 
 	panic();
@@ -57,7 +57,7 @@
 	assert(fmt);
 	assert(panic_handler);
 
-	error_vprintf(fmt, ap);
+	verrorf(fmt, ap);
 	panic();
 }
 
--- a/libcore/core/save.c	Tue Oct 20 14:58:51 2020 +0200
+++ b/libcore/core/save.c	Tue Oct 20 15:09:39 2020 +0200
@@ -79,7 +79,7 @@
 exec(const char *sql)
 {
 	if (sqlite3_exec(db, sql, NULL, NULL, NULL) != SQLITE_OK)
-		return error_printf("%s", sqlite3_errmsg(db));
+		return errorf("%s", sqlite3_errmsg(db));
 
 	return true;
 }
@@ -96,9 +96,9 @@
 	assert(path);
 
 	if (sqlite3_open(path, &db) != SQLITE_OK)
-		return error_printf("database open error: %s", sqlite3_errmsg(db));
+		return errorf("database open error: %s", sqlite3_errmsg(db));
 	if (sqlite3_exec(db, sinit, NULL, NULL, NULL) != SQLITE_OK)
-		return error_printf("database init error: %s", sqlite3_errmsg(db));
+		return errorf("database init error: %s", sqlite3_errmsg(db));
 
 	return true;
 }
@@ -131,7 +131,7 @@
 		exec(srollback);
 	}
 
-	return error_printf("%s", sqlite3_errmsg(db));
+	return errorf("%s", sqlite3_errmsg(db));
 }
 
 const char *
@@ -172,7 +172,7 @@
 	if (stmt)
 		sqlite3_finalize(stmt);
 
-	error_printf("%s", sqlite3_errmsg(db));
+	errorf("%s", sqlite3_errmsg(db));
 
 	return NULL;
 }
@@ -201,7 +201,7 @@
 	if (stmt)
 		sqlite3_finalize(stmt);
 
-	error_printf("%s", sqlite3_errmsg(db));
+	errorf("%s", sqlite3_errmsg(db));
 
 	return false;
 }
--- a/libcore/core/script.c	Tue Oct 20 14:58:51 2020 +0200
+++ b/libcore/core/script.c	Tue Oct 20 15:09:39 2020 +0200
@@ -72,7 +72,7 @@
 	assert(a);
 
 	if (s->actionsz >= SCRIPT_ACTION_MAX)
-		return error_printf("script is full");
+		return errorf("script is full");
 
 	s->actions[s->actionsz++] = a;
 
--- a/libcore/core/trace.c	Tue Oct 20 14:58:51 2020 +0200
+++ b/libcore/core/trace.c	Tue Oct 20 15:09:39 2020 +0200
@@ -32,7 +32,7 @@
 void (*trace_handler)(const char *) = default_handler;
 
 void
-trace(const char *fmt, ...)
+tracef(const char *fmt, ...)
 {
 	assert(fmt);
 
@@ -42,12 +42,12 @@
 		return;
 
 	va_start(ap, fmt);
-	vtrace(fmt, ap);
+	vtracef(fmt, ap);
 	va_end(ap);
 }
 
 void
-vtrace(const char *fmt, va_list ap)
+vtracef(const char *fmt, va_list ap)
 {
 	assert(fmt);
 
--- a/libcore/core/trace.h	Tue Oct 20 14:58:51 2020 +0200
+++ b/libcore/core/trace.h	Tue Oct 20 15:09:39 2020 +0200
@@ -56,16 +56,16 @@
  * \param fmt the printf(3) format string
  */
 void
-trace(const char *fmt, ...) PLAT_PRINTF(1, 2);
+tracef(const char *fmt, ...) PLAT_PRINTF(1, 2);
 
 /**
- * Similar to \ref trace with a va_list arguments pointer.
+ * Similar to \ref tracef with a va_list arguments pointer.
  *
  * \pre fmt != NULL
  * \param fmt the printf(3) format string
  * \param ap the argument list
  */
 void
-vtrace(const char *fmt, va_list ap) PLAT_PRINTF(1, 0);
+vtracef(const char *fmt, va_list ap) PLAT_PRINTF(1, 0);
 
 #endif /* !MOLKO_TRACE_H */
--- a/librpg/rpg/map.c	Tue Oct 20 14:58:51 2020 +0200
+++ b/librpg/rpg/map.c	Tue Oct 20 15:09:39 2020 +0200
@@ -92,13 +92,13 @@
 check(struct map_data *data)
 {
 	if (strlen(data->title) == 0)
-		return error_printf("data has no title");
+		return errorf("data has no title");
 	if (data->w == 0 || data->h == 0)
-		return error_printf("data has null sizes");
+		return errorf("data has null sizes");
 	if (data->tile_w == 0 || data->tile_h == 0)
-		return error_printf("data has null tile sizes");
+		return errorf("data has null tile sizes");
 	if (!data->layers[0].tiles || !data->layers[1].tiles)
-		return error_printf("could not allocate data");
+		return errorf("could not allocate data");
 
 	return true;
 }
--- a/librpg/rpg/map_state.c	Tue Oct 20 14:58:51 2020 +0200
+++ b/librpg/rpg/map_state.c	Tue Oct 20 15:09:39 2020 +0200
@@ -338,9 +338,9 @@
 		PLAYER()->x - VIEW()->x,
 		PLAYER()->y - VIEW()->y);
 
-	debug(&report, "position: %d, %d", PLAYER()->x,
+	debugf(&report, "position: %d, %d", PLAYER()->x,
 	    PLAYER()->y);
-	debug(&report, "view: %d, %d", VIEW()->x,
+	debugf(&report, "view: %d, %d", VIEW()->x,
 	    VIEW()->y);
 }
 
--- a/librpg/rpg/message.c	Tue Oct 20 14:58:51 2020 +0200
+++ b/librpg/rpg/message.c	Tue Oct 20 15:09:39 2020 +0200
@@ -131,9 +131,9 @@
 		label.flags = LABEL_FLAGS_SHADOW;
 
 		if (label.x + lw > msg->w)
-			trace("message width too small: %u < %u", msg->w, min_width(msg));
+			tracef("message width too small: %u < %u", msg->w, min_width(msg));
 		if (label.y + lh > msg->h)
-			trace("message height too small: %u < %u", msg->h, min_height(msg));
+			tracef("message height too small: %u < %u", msg->h, min_height(msg));
 
 		/*
 		 * The function label_draw will use THEME_COLOR_NORMAL to draw
@@ -164,7 +164,7 @@
 	    : MESSAGE_STATE_SHOWING;
 
 	if (msg->flags & MESSAGE_FLAGS_AUTOMATIC && msg->timeout == 0)
-		trace("message is automatic but has zero timeout");
+		tracef("message is automatic but has zero timeout");
 }
 
 void
@@ -270,7 +270,7 @@
 	unsigned int w, h;
 
 	if (msg->w == 0 || msg->h == 0) {
-		trace("message has null dimensions");
+		tracef("message has null dimensions");
 		return;
 	}
 
--- a/libui/ui/button.c	Tue Oct 20 14:58:51 2020 +0200
+++ b/libui/ui/button.c	Tue Oct 20 15:09:39 2020 +0200
@@ -69,9 +69,9 @@
 	label_query(&label, &lw, &lh);
 
 	if (lw > button->w)
-		trace("button is too small for text: %u < %u", button->w, lw);
+		tracef("button is too small for text: %u < %u", button->w, lw);
 	if (lh > button->h)
-		trace("button is too small for text: %u < %u", button->h, lh);
+		tracef("button is too small for text: %u < %u", button->h, lh);
 
 	align(ALIGN_CENTER, &label.x, &label.y, lw, lh,
 	    button->x, button->y, button->w, button->h);
--- a/libui/ui/debug.c	Tue Oct 20 14:58:51 2020 +0200
+++ b/libui/ui/debug.c	Tue Oct 20 15:09:39 2020 +0200
@@ -31,7 +31,7 @@
 };
 
 void
-debug(struct debug_report *report, const char *fmt, ...)
+debugf(struct debug_report *report, const char *fmt, ...)
 {
 	assert(report);
 	assert(fmt);
@@ -42,12 +42,12 @@
 	va_list ap;
 
 	va_start(ap, fmt);
-	vdebug(report, fmt, ap);
+	vdebugf(report, fmt, ap);
 	va_end(ap);
 }
 
 void
-vdebug(struct debug_report *report, const char *fmt, va_list ap)
+vdebugf(struct debug_report *report, const char *fmt, va_list ap)
 {
 	assert(report);
 	assert(fmt);
--- a/libui/ui/debug.h	Tue Oct 20 14:58:51 2020 +0200
+++ b/libui/ui/debug.h	Tue Oct 20 15:09:39 2020 +0200
@@ -32,7 +32,7 @@
  * debug_options.enabled variable is set to true. However, you need to specify
  * the font to use in order to work.
  *
- * Each call to \ref debug or \ref vdebug automatically adjust
+ * Each call to \ref debugf or \ref vdebugf automatically adjust
  * next coordinate for rendering the text. As such, user may simply print
  * several lines of text without having to deal with that manually.
  */
@@ -86,10 +86,10 @@
  *       result is truncated.
  */
 void
-debug(struct debug_report *report, const char *fmt, ...) PLAT_PRINTF(2, 3);
+debugf(struct debug_report *report, const char *fmt, ...) PLAT_PRINTF(2, 3);
 
 /**
- * Similar to \ref debug with a va_list arguments pointer.
+ * Similar to \ref debugf with a va_list arguments pointer.
  *
  * \pre fmt != NULL
  * \param report the reporting context
@@ -97,6 +97,6 @@
  * \param ap the argument list
  */
 void
-vdebug(struct debug_report *report, const char *fmt, va_list ap) PLAT_PRINTF(2, 0);
+vdebugf(struct debug_report *report, const char *fmt, va_list ap) PLAT_PRINTF(2, 0);
 
 #endif /* !MOLKO_DEBUG_H */
--- a/tests/test-error.c	Tue Oct 20 14:58:51 2020 +0200
+++ b/tests/test-error.c	Tue Oct 20 15:09:39 2020 +0200
@@ -23,7 +23,7 @@
 TEST
 simple(void)
 {
-	error_printf("Failed: %d", 123);
+	errorf("Failed: %d", 123);
 	ASSERT_STR_EQ("Failed: 123", error());
 	PASS();
 }