diff options
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: */ |