diff options
author | Franklin Wei <git@fwei.tk> | 2017-08-23 14:20:07 -0400 |
---|---|---|
committer | Franklin Wei <git@fwei.tk> | 2017-08-23 14:22:09 -0400 |
commit | 3c514f8e20ea8762025a12f9edbea27967e31d76 (patch) | |
tree | ed44527b00a128ce85f507e1abda8dbbbf7de4cb /apps/plugins/puzzles/src/misc.c | |
parent | 4dd300d9f0229269aa8f9a46b07a5aa65f882985 (diff) | |
download | rockbox-3c514f8e20ea8762025a12f9edbea27967e31d76.tar.gz rockbox-3c514f8e20ea8762025a12f9edbea27967e31d76.zip |
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
Diffstat (limited to 'apps/plugins/puzzles/src/misc.c')
-rw-r--r-- | apps/plugins/puzzles/src/misc.c | 17 |
1 files changed, 11 insertions, 6 deletions
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, | |||
361 | 361 | ||
362 | } | 362 | } |
363 | 363 | ||
364 | /* kludge for non-compliant sprintf() */ | 364 | /* kludge for sprintf() in Rockbox not supporting "%-8.8s" */ |
365 | void copy_left_justified(char *buf, size_t sz, const char *str) | 365 | void copy_left_justified(char *buf, size_t sz, const char *str) |
366 | { | 366 | { |
367 | size_t len = strlen(str); | ||
368 | assert(sz > 0); | ||
367 | memset(buf, ' ', sz - 1); | 369 | memset(buf, ' ', sz - 1); |
368 | int len = strlen(str); | 370 | assert(len <= sz - 1); |
369 | if(len <= sz - 1) | 371 | memcpy(buf, str, len); |
370 | memcpy(buf, str, len); | ||
371 | else | ||
372 | fatal("overrun"); | ||
373 | buf[sz - 1] = 0; | 372 | buf[sz - 1] = 0; |
374 | } | 373 | } |
375 | 374 | ||
375 | /* another kludge for platforms without %g support in *printf() */ | ||
376 | int ftoa(char *buf, float f) | ||
377 | { | ||
378 | return sprintf(buf, "%d.%06d", (int)f, (int)((f - (int)f)*1e6)); | ||
379 | } | ||
380 | |||
376 | /* vim: set shiftwidth=4 tabstop=8: */ | 381 | /* vim: set shiftwidth=4 tabstop=8: */ |