X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fwctob.c;h=d87d18042c03101814e2ecafab99fc5b330fa49c;hb=cd56634a4a8179fd5a4419fbb3e27211b042ab1c;hp=c8381dbf9db2f0ad23a6be1e19fe681a87bd070e;hpb=3030c5b5e0a5199e16b05927da72c43c42f211c3;p=gnulib.git diff --git a/lib/wctob.c b/lib/wctob.c index c8381dbf9..d87d18042 100644 --- a/lib/wctob.c +++ b/lib/wctob.c @@ -1,5 +1,5 @@ /* Convert wide character to unibyte character. - Copyright (C) 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 2008, 2010-2014 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; }