#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <wchar.h>

#define HAVE_BROKEN_MBSTOWCS
#ifdef HAVE_BROKEN_MBSTOWCS
size_t  __non_broken_mbstowcs(wchar_t* pwcs, const char* s, size_t n)
{
    if (pwcs == NULL)
        return strlen(s);
    else
        return mbstowcs(pwcs, s, n);
}
#define mbstowcs    __non_broken_mbstowcs
#endif

int main()
{
    wchar_t     output[100];
    const char  input[] = "foo bar 12345";

    printf("mbstowcs(NULL, input, 0) = %d (shoud be %d)\n",
            mbstowcs(NULL, input, 0),
            strlen(input));
    mbstowcs(output, "foo bar 12345", sizeof output - 1);
    fputws(output, stdout);
    fputc('\n', stdout);
    return 0;
}
