X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fwctob.c;h=508f896be6d25466b5ba91ced4e767b0e304c2f5;hb=fdd1b511c5c12912aae79b58e0c5f6ffa0492d6e;hp=4fa71b0d83ef7df68f7a1d33417a291d09a5d7ad;hpb=172b44d208f0bf8f949168d2e42b76202ee4180f;p=gnulib.git diff --git a/lib/wctob.c b/lib/wctob.c index 4fa71b0d8..508f896be 100644 --- a/lib/wctob.c +++ b/lib/wctob.c @@ -1,5 +1,5 @@ /* Convert wide character to unibyte character. - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008, 2010-2013 Free Software Foundation, Inc. Written by Bruno Haible , 2008. This program is free software: you can redistribute it and/or modify @@ -30,8 +30,9 @@ wctob (wint_t wc) if (!(MB_CUR_MAX <= sizeof (buf))) abort (); - if (wctomb (buf, wc) == 1) - return (unsigned char) buf[0]; - else - return EOF; + /* Handle the case where WEOF is a value that does not fit in a wchar_t. */ + if (wc == (wchar_t)wc) + if (wctomb (buf, (wchar_t)wc) == 1) + return (unsigned char) buf[0]; + return EOF; }