1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

Deal with progress bars in environs lacking mbtowc or wcwidth.

This commit is contained in:
Micah Cowan 2008-02-06 18:10:24 -08:00
parent c1b7382ec4
commit e95867e6cc
4 changed files with 30 additions and 5 deletions

View File

@ -197,7 +197,7 @@ AC_FUNC_ALLOCA
AC_FUNC_MMAP AC_FUNC_MMAP
AC_FUNC_FSEEKO AC_FUNC_FSEEKO
AC_CHECK_FUNCS(strptime timegm snprintf vsnprintf vasprintf drand48) AC_CHECK_FUNCS(strptime timegm snprintf vsnprintf vasprintf drand48)
AC_CHECK_FUNCS(strtoll usleep ftello sigblock sigsetjmp memrchr wcwidth) AC_CHECK_FUNCS(strtoll usleep ftello sigblock sigsetjmp memrchr wcwidth mbtowc)
if test x"$ENABLE_OPIE" = xyes; then if test x"$ENABLE_OPIE" = xyes; then
AC_LIBOBJ([ftp-opie]) AC_LIBOBJ([ftp-opie])

View File

@ -767,10 +767,7 @@ update_speed_ring (struct bar_progress *bp, wgint howmuch, double dltime)
#endif #endif
} }
#if ! HAVE_WCWIDTH #if HAVE_MBTOWC && HAVE_WCWIDTH
#define wcwidth(wc) (1)
#endif
int int
count_cols (const char *mbs) count_cols (const char *mbs)
{ {
@ -796,6 +793,11 @@ count_cols (const char *mbs)
} }
return cols; return cols;
} }
#else
# define count_cols(mbs) ((int)(strlen(mbs)))
# undef wcwidth
# define wcwidth(wc) (1)
#endif
/* Translation note: "ETA" is English-centric, but this must /* Translation note: "ETA" is English-centric, but this must
be short, ideally 3 chars. Abbreviate if necessary. */ be short, ideally 3 chars. Abbreviate if necessary. */
@ -811,7 +813,11 @@ get_eta (void)
int nbytes; int nbytes;
int ncols; int ncols;
#if HAVE_WCWIDTH && HAVE_MBTOWC
eta_trans = _(eta_str); eta_trans = _(eta_str);
#else
eta_trans = eta_str;
#endif
/* Determine the number of bytes used in the translated string, /* Determine the number of bytes used in the translated string,
* versus the number of columns used. This is to figure out how * versus the number of columns used. This is to figure out how

View File

@ -1221,6 +1221,12 @@ get_grouping_data (const char **sep, const char **grouping)
struct lconv *lconv = localeconv (); struct lconv *lconv = localeconv ();
cached_sep = lconv->thousands_sep; cached_sep = lconv->thousands_sep;
cached_grouping = lconv->grouping; cached_grouping = lconv->grouping;
#if ! USE_NLS_PROGRESS_BAR
/* We can't count column widths, so ensure that the separator
* is single-byte only (let check below determine what byte). */
if (strlen(cached_sep) > 1)
cached_sep = "";
#endif
if (!*cached_sep) if (!*cached_sep)
{ {
/* Many locales (such as "C" or "hr_HR") don't specify /* Many locales (such as "C" or "hr_HR") don't specify

View File

@ -67,6 +67,19 @@ as that of the covered work. */
variables. -- explanation partly taken from GNU make. */ variables. -- explanation partly taken from GNU make. */
#define N_(string) string #define N_(string) string
#if ! ENABLE_NLS
# undef HAVE_WCHAR_H
# undef HAVE_WCWIDTH
# undef HAVE_MBTOWC
#endif /* not ENABLE_NLS */
#if HAVE_WCWIDTH && HAVE_MBTOWC
# define USE_NLS_PROGRESS_BAR 1
#else
/* Just to be a little paranoid about it. */
# undef USE_NLS_PROGRESS_BAR
#endif
/* I18N NOTE: You will notice that none of the DEBUGP messages are /* I18N NOTE: You will notice that none of the DEBUGP messages are
marked as translatable. This is intentional, for a few reasons: marked as translatable. This is intentional, for a few reasons: