-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hrvoje Niksic wrote:
| Micah Cowan <[EMAIL PROTECTED]> writes:
|
|> Also: the fix to the locale/progress-bar issues resulted in the
|> added use of a couple wide-character/multibyte-related functions,
|> mbtowc and wcwidth.
|
| So far Wget has avoided explicit use of wc/mb functions on the account
| of portability.  Fortunately in most cases we don't really care about
| character representation of strings we use, progress.c being a notable
| exception.  I suggest that we check for availability of multibyte
| functions and, where missing, disable NLS and define stubs such as:
|
| #ifndef HAVE_WCHAR_T
| typedef char wchar_t
| #endif
| int
| mbtowc(wchar_t *pwc, const char *s, size_t n)
| {
|   if (!s)
|     return 0;
|   if (pwc)
|     *pwc = *s;
|   return *s != '\0';
| }
|
| int
| wcwidth(wchar_t c)
| {
|   return 1;
| }

The wcwidth definition is equivalent to what I'm currently doing when
it's missing (except that I used a function-like macro).

As to wchar_t and mbtowc: I'm curious how many systems we're still
trying to support actually lack these, given that they've been around
since the very first C standard?

Still, I suppose the fact that I bothered to check for wchar.h means
I've already committed to dealing with their absence. It's just one more
check for mbtowc.

| Disabling NLS should automatically diasble the use of multibyte
| functions, as well as (probably) the other way around.

Yeah, I'm with the "other way around" bit; at least for mbtowc. For
wcwidth, perhaps we'd let it proceed, but configure should warn that
some character sets (Asian ones that include "fullwidth" characters that
are used in the progress bar) may have issues with the progress-bar output.

Or perhaps we just consider that an unsupported environment, and disable
NLS. I'm cool with that, too, as they'll otherwise have to deal with an
ugly, scrolling progress bar. However, it would still work for all the
non-Asian locales (and at least one or two of the Asian ones). I suppose
proceed-at-your-peril is the more appropriate response.

| That should
| ensure that Wget remain usable on platforms where NLS or wide-char
| support or both are broken.  After all, for most users (even those who
| don't speak English) Wget remains a simple command-line network
| utility, and translations are not of utmost importance to that target
| audience.
|
|> [wcwidth] is defined in SUS, but not POSIX,
|
| FWIW, the Linux man page lists it as conforming to POSIX.1-2001.

Hm, perhaps a bug report should be issued for that; SUSv3 has it wrapped
in an [XSI] tag. It does mention, though, that the function was
originally going to be part of the 1995 ammendment to the C standard,
but was dropped (which, IMO is really a shame, since it would then have
been more reliably present).

Huh, actually: my man page gives it as conforming to C99(!), which is
just plain wrong.

- --
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
http://micah.cowan.name/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHp13D7M8hyUobTrERAvi3AJ94MlhZ7u0DWMUNZz7Ql6Ra9FNvYwCeKvSk
spalSXYiQOoQ3J37sFMHKRU=
=+t52
-----END PGP SIGNATURE-----

Reply via email to