Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Ignore the sdmc: prefix in fs.list; added missing space on some strin…
…gs for the null-termination
  • Loading branch information
Reuh committed Oct 25, 2015
1 parent 0efdc23 commit d015918
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion source/font.c
Expand Up @@ -91,7 +91,7 @@ static int font_object_width(lua_State *L) {
int size = luaL_optinteger(L, 3, 9);

// Wide caracters support. (wchar = UTF32 on 3DS.)
wchar_t wtext[len];
wchar_t wtext[len+1];
len = mbstowcs(wtext, text, len);
*(wtext+len) = 0x0; // text end

Expand Down
4 changes: 3 additions & 1 deletion source/fs.c
Expand Up @@ -20,6 +20,8 @@ void load_lzlib(lua_State *L);
static int fs_list(lua_State *L) {
const char *path = luaL_checkstring(L, 1);

if (strncmp(path, "sdmc:", 5) == 0) path += 5; // Ignore sdmc: prefix

lua_newtable(L);
int i = 1; // table index

Expand All @@ -36,7 +38,7 @@ static int fs_list(lua_State *L) {

if (!entriesRead) break;

uint8_t name[256]; // utf8 file name
uint8_t name[0x106+1]; // utf8 file name
size_t size = utf16_to_utf8(name, buffer.name, 0x106);
*(name+size) = 0x0; // mark text end

Expand Down
4 changes: 2 additions & 2 deletions source/gfx.c
Expand Up @@ -276,7 +276,7 @@ static int gfx_text(lua_State *L) {
if (font->font == NULL) luaL_error(L, "The font object was unloaded");

// Wide caracters support. (wchar = UTF32 on 3DS.)
wchar_t wtext[len];
wchar_t wtext[len+1];
len = mbstowcs(wtext, text, len);
*(wtext+len) = 0x0; // text end

Expand Down Expand Up @@ -316,7 +316,7 @@ static int gfx_wrappedText(lua_State *L) {

// Wide caracters support. (wchar = UTF32 on 3DS.)
// Disabled as sftd_draw_wtext_wrap() doesn't exist.
/*wchar_t wtext[len];
/*wchar_t wtext[len+1];
len = mbstowcs(wtext, text, len);
*(wtext+len) = 0x0; // text end */

Expand Down

0 comments on commit d015918

Please sign in to comment.