]> sjero.net Git - wget/commitdiff
wget: Fix --version wrapping issue
authorWill Dietz <w@wdtz.org>
Thu, 8 Aug 2013 16:16:10 +0000 (11:16 -0500)
committerGiuseppe Scrivano <gscrivan@redhat.com>
Fri, 9 Aug 2013 18:35:23 +0000 (20:35 +0200)
src/ChangeLog
src/main.c

index fe7ce5f4a049d011f08d99a2ff0a927098f47e57..ab38d45ebda71d4e03a80a349f331359a2bd7c5e 100644 (file)
@@ -1,3 +1,7 @@
+2013-08-08  Will Dietz  <w@wdtz.org> (tiny change):
+
+       * main.c (format_and_print_line): Wrap correctly long tokens.
+
 2013-07-16  Darshit Shah  <darnir@gmail.com>
 
        * wget.h (err_t): Added new errors, ATTRMISSING and UNKNOWNATTR to
index 8ce0eb3ff252f47c26d824e3074ec29b113ea065..6b71a20d3b7b50060930e5c3dff04121c39472f8 100644 (file)
@@ -840,15 +840,16 @@ format_and_print_line (const char *prefix, const char *line,
 
   assert (prefix != NULL);
   assert (line != NULL);
+  assert (line_length > TABULATION);
 
   line_dup = xstrdup (line);
 
-  if (line_length <= 0)
-    line_length = MAX_CHARS_PER_LINE - TABULATION;
-
   if (printf ("%s", prefix) < 0)
     return -1;
-  remaining_chars = line_length;
+
+  /* Wrap to new line after prefix. */
+  remaining_chars = 0;
+
   /* We break on spaces. */
   token = strtok (line_dup, " ");
   while (token != NULL)
@@ -856,7 +857,7 @@ format_and_print_line (const char *prefix, const char *line,
       /* If however a token is much larger than the maximum
          line length, all bets are off and we simply print the
          token on the next line. */
-      if (remaining_chars <= strlen (token))
+      if (remaining_chars <= (int) strlen (token))
         {
           if (printf ("\n%*c", TABULATION, ' ') < 0)
             return -1;
@@ -930,7 +931,7 @@ print_version (void)
 
 #ifdef ENABLE_NLS
   if (format_and_print_line (locale_title,
-                        LOCALEDIR,
+                             LOCALEDIR,
                              MAX_CHARS_PER_LINE) < 0)
     exit (3);
 #endif /* def ENABLE_NLS */