]> sjero.net Git - wget/commitdiff
Deal with progress bars in environs lacking mbtowc or wcwidth.
authorMicah Cowan <micah@cowan.name>
Thu, 7 Feb 2008 02:10:24 +0000 (18:10 -0800)
committerMicah Cowan <micah@cowan.name>
Thu, 7 Feb 2008 02:10:24 +0000 (18:10 -0800)
configure.ac
src/progress.c
src/utils.c
src/wget.h

index 5e7e7a2f9939c82382a7bc2c7776046bc8e2ea86..a49de3cd073fec3e3b9a917f259b27be2e3595d4 100644 (file)
@@ -197,7 +197,7 @@ AC_FUNC_ALLOCA
 AC_FUNC_MMAP
 AC_FUNC_FSEEKO
 AC_CHECK_FUNCS(strptime timegm snprintf vsnprintf vasprintf drand48)
 AC_FUNC_MMAP
 AC_FUNC_FSEEKO
 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
   AC_LIBOBJ([ftp-opie])
 
 if test x"$ENABLE_OPIE" = xyes; then
   AC_LIBOBJ([ftp-opie])
index 2db82fda35820e5ee8d4090d0a9fdc66e3ff46b6..80dab04a1c808102ea58fb5b9734707e7137176b 100644 (file)
@@ -767,10 +767,7 @@ update_speed_ring (struct bar_progress *bp, wgint howmuch, double dltime)
 #endif
 }
 
 #endif
 }
 
-#if ! HAVE_WCWIDTH
-#define wcwidth(wc) (1)
-#endif
-
+#if HAVE_MBTOWC && HAVE_WCWIDTH
 int
 count_cols (const char *mbs)
 {
 int
 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
    be short, ideally 3 chars.  Abbreviate if necessary.  */
 
 /* Translation note: "ETA" is English-centric, but this must
    be short, ideally 3 chars.  Abbreviate if necessary.  */
@@ -811,7 +813,11 @@ get_eta (void)
       int nbytes;
       int ncols;
 
       int nbytes;
       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,
        * versus the number of columns used. This is to figure out how
 
       /* Determine the number of bytes used in the translated string,
        * versus the number of columns used. This is to figure out how
index 5be8ddcf607f4263d272f47cbfaae9a78b3ca843..920f3b54482f0232c4a26b62e988e19a516686e2 100644 (file)
@@ -1221,6 +1221,12 @@ get_grouping_data (const char **sep, const char **grouping)
       struct lconv *lconv = localeconv ();
       cached_sep = lconv->thousands_sep;
       cached_grouping = lconv->grouping;
       struct lconv *lconv = localeconv ();
       cached_sep = lconv->thousands_sep;
       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)
         {
           /* Many locales (such as "C" or "hr_HR") don't specify
       if (!*cached_sep)
         {
           /* Many locales (such as "C" or "hr_HR") don't specify
index 566c8ae44ec7bc767efcc0c5b07adbfb6f2262b8..08d8d8374ebd803b1cee0cf3681b6cb47ff74786 100644 (file)
@@ -67,6 +67,19 @@ as that of the covered work.  */
    variables.  -- explanation partly taken from GNU make.  */
 #define N_(string) string
 
    variables.  -- explanation partly taken from GNU make.  */
 #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
    marked as translatable.  This is intentional, for a few reasons:
 
 /* I18N NOTE: You will notice that none of the DEBUGP messages are
    marked as translatable.  This is intentional, for a few reasons: