Mercurial > hg > octave-shane > gnulib-hg
comparison lib/wctob.c @ 13303:522a26cf44a2
wctob: Fix for weird platforms.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Mon, 03 May 2010 10:07:34 +0200 |
parents | c2cbabec01dd |
children | 97fc9a21a8fb |
comparison
equal
deleted
inserted
replaced
13302:38bc4e23ff1e | 13303:522a26cf44a2 |
---|---|
1 /* Convert wide character to unibyte character. | 1 /* Convert wide character to unibyte character. |
2 Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. | 2 Copyright (C) 2008, 2010 Free Software Foundation, Inc. |
3 Written by Bruno Haible <bruno@clisp.org>, 2008. | 3 Written by Bruno Haible <bruno@clisp.org>, 2008. |
4 | 4 |
5 This program is free software: you can redistribute it and/or modify | 5 This program is free software: you can redistribute it and/or modify |
6 it under the terms of the GNU General Public License as published by | 6 it under the terms of the GNU General Public License as published by |
7 the Free Software Foundation; either version 3 of the License, or | 7 the Free Software Foundation; either version 3 of the License, or |
28 { | 28 { |
29 char buf[64]; | 29 char buf[64]; |
30 | 30 |
31 if (!(MB_CUR_MAX <= sizeof (buf))) | 31 if (!(MB_CUR_MAX <= sizeof (buf))) |
32 abort (); | 32 abort (); |
33 if (wctomb (buf, wc) == 1) | 33 /* Handle the case where WEOF is a value that does not fit in a wchar_t. */ |
34 return (unsigned char) buf[0]; | 34 if (wc == (wchar_t)wc) |
35 else | 35 if (wctomb (buf, (wchar_t)wc) == 1) |
36 return EOF; | 36 return (unsigned char) buf[0]; |
37 return EOF; | |
37 } | 38 } |