char buf[16], *cursor = result;
char *cursor = result;
convert_ucs2_to_native(const PRUnichar *input, char *result, unsigned resultLen){    // this function assumes that |result| is big enough    NS_ASSERTION(resultLen == PATH_MAX, "unexpected resultLen");#ifdef HAVE_WCRTOMB    mbstate_t ps = {0};#endif    char buf[16], *cursor = result;    int i = 0;    const PRUnichar *p = input;    NS_ASSERTION(MB_CUR_MAX <= sizeof(buf), "must increase sizeof(buf)");    // perform conversion    p = input;    while (*p) {#ifdef HAVE_WCRTOMB        i = (int) wcrtomb(cursor, (wchar_t) *p, &ps);#else        // XXX is this thread-safe?        i = (int) wctomb(cursor, (wchar_t) *p);#endif        if (i < 0) {            NS_WARNING("wctomb failed: possible charset mismatch");#ifdef TOLERATE_UCONV_FAILURE            *cursor = (unsigned char) *p; // truncate            i = 1;#else            return -1;#endif        }        // most likely we're dead anyways if this assertion should fire        NS_ASSERTION(cursor + i <= result + resultLen, "wrote beyond end of string");        cursor += i;        if (cursor >= result + resultLen - 1) {            cursor  = result + resultLen - 1; // fixup cursor            break;        }        p++;    }    *cursor = '\0';    return cursor - result;}