diff options
author | Rafaël Carré <rafael.carre@gmail.com> | 2010-06-20 21:53:47 +0000 |
---|---|---|
committer | Rafaël Carré <rafael.carre@gmail.com> | 2010-06-20 21:53:47 +0000 |
commit | 298316d19297eea82869b63235b535e5904fc0dd (patch) | |
tree | 0426e9c8cecac7532a88888e78e5e54ea9bb6145 /apps/plugins/text_viewer/tv_settings.c | |
parent | 17a2f9d8d2dfddd8d2d81ff638e21302efef1c8e (diff) | |
download | rockbox-298316d19297eea82869b63235b535e5904fc0dd.tar.gz rockbox-298316d19297eea82869b63235b535e5904fc0dd.zip |
text_viewer: cleanup & bugfix
cleanup:
- don't use enum in struct / return values
- don't use a getter for preferences but a global pointer
- explicitely make enums start at 0
- use static tables for header/footer settings
- remove unneeded memset before strlcpy
- use static buffer allocation, not dynamic
- check header/footer preferences before using the callbacks
- don't include font filename in archos player preferences (break
file format)
bugfix:
- statically allocate old preferences in tv_set_preferences()
Sometimes I can read a file on Clipv2, but it still aborts quite often
refs: FS#11399
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26998 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/text_viewer/tv_settings.c')
-rw-r--r-- | apps/plugins/text_viewer/tv_settings.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/apps/plugins/text_viewer/tv_settings.c b/apps/plugins/text_viewer/tv_settings.c index 6b16218523..428666de24 100644 --- a/apps/plugins/text_viewer/tv_settings.c +++ b/apps/plugins/text_viewer/tv_settings.c | |||
@@ -181,9 +181,9 @@ static bool tv_read_preferences(int pfd, int version, struct tv_preferences *pre | |||
181 | else | 181 | else |
182 | prefs->indent_spaces = 2; | 182 | prefs->indent_spaces = 2; |
183 | 183 | ||
184 | #ifdef HAVE_LCD_BITMAP | ||
184 | rb->memcpy(prefs->font_name, buf + read_size - MAX_PATH, MAX_PATH); | 185 | rb->memcpy(prefs->font_name, buf + read_size - MAX_PATH, MAX_PATH); |
185 | 186 | ||
186 | #ifdef HAVE_LCD_BITMAP | ||
187 | prefs->font = rb->font_get(FONT_UI); | 187 | prefs->font = rb->font_get(FONT_UI); |
188 | #endif | 188 | #endif |
189 | 189 | ||
@@ -213,7 +213,9 @@ static bool tv_write_preferences(int pfd, const struct tv_preferences *prefs) | |||
213 | *p++ = prefs->narrow_mode; | 213 | *p++ = prefs->narrow_mode; |
214 | *p++ = prefs->indent_spaces; | 214 | *p++ = prefs->indent_spaces; |
215 | 215 | ||
216 | #ifdef HAVE_LCD_BITMAP | ||
216 | rb->memcpy(buf + 28, prefs->font_name, MAX_PATH); | 217 | rb->memcpy(buf + 28, prefs->font_name, MAX_PATH); |
218 | #endif | ||
217 | 219 | ||
218 | return (rb->write(pfd, buf, TV_PREFERENCES_SIZE) >= 0); | 220 | return (rb->write(pfd, buf, TV_PREFERENCES_SIZE) >= 0); |
219 | } | 221 | } |
@@ -457,7 +459,6 @@ static bool tv_copy_settings(int sfd, int dfd, int size) | |||
457 | 459 | ||
458 | bool tv_save_settings(void) | 460 | bool tv_save_settings(void) |
459 | { | 461 | { |
460 | const struct tv_preferences *prefs = tv_get_preferences(); | ||
461 | unsigned char buf[MAX_PATH+2]; | 462 | unsigned char buf[MAX_PATH+2]; |
462 | unsigned int fcount = 0; | 463 | unsigned int fcount = 0; |
463 | unsigned int i; | 464 | unsigned int i; |
@@ -502,7 +503,7 @@ bool tv_save_settings(void) | |||
502 | } | 503 | } |
503 | 504 | ||
504 | size = (buf[MAX_PATH] << 8) | buf[MAX_PATH + 1]; | 505 | size = (buf[MAX_PATH] << 8) | buf[MAX_PATH + 1]; |
505 | if (rb->strcmp(buf, prefs->file_name) == 0) | 506 | if (rb->strcmp(buf, preferences->file_name) == 0) |
506 | rb->lseek(ofd, size, SEEK_CUR); | 507 | rb->lseek(ofd, size, SEEK_CUR); |
507 | else | 508 | else |
508 | { | 509 | { |
@@ -522,12 +523,11 @@ bool tv_save_settings(void) | |||
522 | { | 523 | { |
523 | /* save to current read file's preferences and bookmarks */ | 524 | /* save to current read file's preferences and bookmarks */ |
524 | res = false; | 525 | res = false; |
525 | rb->memset(buf, 0, MAX_PATH); | 526 | rb->strlcpy(buf, preferences->file_name, MAX_PATH); |
526 | rb->strlcpy(buf, prefs->file_name, MAX_PATH); | ||
527 | 527 | ||
528 | if (rb->write(tfd, buf, MAX_PATH + 2) >= 0) | 528 | if (rb->write(tfd, buf, MAX_PATH + 2) >= 0) |
529 | { | 529 | { |
530 | if (tv_write_preferences(tfd, prefs)) | 530 | if (tv_write_preferences(tfd, preferences)) |
531 | { | 531 | { |
532 | size = tv_serialize_bookmarks(tfd); | 532 | size = tv_serialize_bookmarks(tfd); |
533 | if (size > 0) | 533 | if (size > 0) |