summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2009-10-29 17:13:36 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2009-10-29 17:13:36 +0000
commit5ca112b21e2fd65aa66644ff6131a0b428ef1f75 (patch)
tree6ec59df43ad12cd6c023d8ed71c499942199707a /apps
parent8fb258856c537d02ed4ebd11397f055f9dc3cc5f (diff)
downloadrockbox-5ca112b21e2fd65aa66644ff6131a0b428ef1f75.tar.gz
rockbox-5ca112b21e2fd65aa66644ff6131a0b428ef1f75.zip
Lua: return nil when function failed instead of returning nothing
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23405 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/lua/rocklib.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c
index ca77d5ea8f..73c3851bc1 100644
--- a/apps/plugins/lua/rocklib.c
+++ b/apps/plugins/lua/rocklib.c
@@ -330,12 +330,11 @@ RB_WRAP(lcd_get_backdrop)
330{ 330{
331 fb_data* backdrop = rb->lcd_get_backdrop(); 331 fb_data* backdrop = rb->lcd_get_backdrop();
332 if(backdrop == NULL) 332 if(backdrop == NULL)
333 return 0; 333 lua_pushnil(L);
334 else 334 else
335 {
336 rli_wrap(L, backdrop, LCD_WIDTH, LCD_HEIGHT); 335 rli_wrap(L, backdrop, LCD_WIDTH, LCD_HEIGHT);
337 return 1; 336
338 } 337 return 1;
339} 338}
340#endif /* LCD_DEPTH > 1 */ 339#endif /* LCD_DEPTH > 1 */
341 340
@@ -478,24 +477,28 @@ RB_WRAP(read_bmp_file)
478 if(result > 0) 477 if(result > 0)
479 { 478 {
480 bm.data = (unsigned char*) rli_alloc(L, bm.width, bm.height); 479 bm.data = (unsigned char*) rli_alloc(L, bm.width, bm.height);
481 rb->read_bmp_file(filename, &bm, result, format, NULL); 480 if(rb->read_bmp_file(filename, &bm, result, format, NULL) < 0)
482 481 {
483 return 1; 482 /* Error occured, drop newly allocated image from stack */
483 lua_pop(L, 1);
484 lua_pushnil(L);
485 }
484 } 486 }
487 else
488 lua_pushnil(L);
485 489
486 return 0; 490 return 1;
487} 491}
488 492
489RB_WRAP(current_path) 493RB_WRAP(current_path)
490{ 494{
491 const char *current_path = get_current_path(L, 1); 495 const char *current_path = get_current_path(L, 1);
492 if(current_path != NULL) 496 if(current_path != NULL)
493 {
494 lua_pushstring(L, current_path); 497 lua_pushstring(L, current_path);
495 return 1;
496 }
497 else 498 else
498 return 0; 499 lua_pushnil(L);
500
501 return 1;
499} 502}
500 503
501static void fill_text_message(lua_State *L, struct text_message * message, 504static void fill_text_message(lua_State *L, struct text_message * message,