Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
OS/2: don't report failures on Unicode conversion on older OS/2 insta…
…lls.
  • Loading branch information
icculus committed Sep 15, 2017
1 parent e728c65 commit 7a26b83
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/physfs_platform_os2.c
Expand Up @@ -135,11 +135,22 @@ static char *cvtUtf8ToCodepage(const char *utf8str)

static char *cvtCodepageToUtf8(const char *cpstr)
{
const size_t len = strlen(cpstr) + 1;
char *retvalbuf = (char *) allocator.Malloc(len * 4);
char *retval = NULL;
if (uconvdll)

BAIL_IF(!retvalbuf, PHYSFS_ERR_OUT_OF_MEMORY, NULL);

if (!uconvdll)
{
/* There's really not much we can do on older OS/2s except pray this
is latin1-compatible. */
retval = retvalbuf;
PHYSFS_utf8FromLatin1(cpstr, retval, len * 4);
} /* if */
else
{
int rc;
size_t len = strlen(cpstr) + 1;
size_t cplen = len;
size_t unilen = len;
size_t subs = 0;
Expand All @@ -151,12 +162,11 @@ static char *cvtCodepageToUtf8(const char *cpstr)
GOTO_IF(rc != ULS_SUCCESS, PHYSFS_ERR_BAD_FILENAME, done);
GOTO_IF(subs > 0, PHYSFS_ERR_BAD_FILENAME, done);
assert(cplen == 0);
retval = (char *) allocator.Malloc(len * 4);
GOTO_IF(!retval, PHYSFS_ERR_OUT_OF_MEMORY, done);
retval = retvalbuf;
PHYSFS_utf8FromUcs2((const PHYSFS_uint16 *) uc2ptr, retval, len * 4);
done:
__PHYSFS_smallFree(uc2ptr);
} /* if */
} /* else */

return retval;
} /* cvtCodepageToUtf8 */
Expand Down

0 comments on commit 7a26b83

Please sign in to comment.