From 3c514f8e20ea8762025a12f9edbea27967e31d76 Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Wed, 23 Aug 2017 14:20:07 -0400 Subject: puzzles: misc. changes and sync with upstream This brings puzzles up-to-date with Simon's tree, along with the rockbox-specific changes I made. Note that I also got rid of some of the ugly floating-point code in rbwrappers.c and replaced it with wrappers for our fixed-point library. Change-Id: Ibfb79acb15517116a26de1c3ea89e025146b9e2e --- apps/plugins/puzzles/src/misc.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'apps/plugins/puzzles/src/misc.c') diff --git a/apps/plugins/puzzles/src/misc.c b/apps/plugins/puzzles/src/misc.c index 9904aee75e..2bf35d391b 100644 --- a/apps/plugins/puzzles/src/misc.c +++ b/apps/plugins/puzzles/src/misc.c @@ -361,16 +361,21 @@ void draw_text_outline(drawing *dr, int x, int y, int fonttype, } -/* kludge for non-compliant sprintf() */ +/* kludge for sprintf() in Rockbox not supporting "%-8.8s" */ void copy_left_justified(char *buf, size_t sz, const char *str) { + size_t len = strlen(str); + assert(sz > 0); memset(buf, ' ', sz - 1); - int len = strlen(str); - if(len <= sz - 1) - memcpy(buf, str, len); - else - fatal("overrun"); + assert(len <= sz - 1); + memcpy(buf, str, len); buf[sz - 1] = 0; } +/* another kludge for platforms without %g support in *printf() */ +int ftoa(char *buf, float f) +{ + return sprintf(buf, "%d.%06d", (int)f, (int)((f - (int)f)*1e6)); +} + /* vim: set shiftwidth=4 tabstop=8: */ -- cgit v1.2.3