sort: fix --debug display with very large offsets
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 27 Jul 2010 18:01:10 +0000 (11:01 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 27 Jul 2010 18:01:48 +0000 (11:01 -0700)
* src/sort.c (mark_key): Don't assume offset <= INT_MAX.
Make the code a bit clearer when width != 0.

src/sort.c

index 588bae8..f552d21 100644 (file)
@@ -2162,14 +2162,17 @@ count_tabs (char const *text, size_t len)
 static void
 mark_key (size_t offset, size_t width)
 {
-  printf ("%*s", (int) offset, "");
+  while (offset--)
+    putchar (' ');
 
   if (!width)
     printf (_("^ no match for key\n"));
   else
     {
-      while (width--)
+      do
         putchar ('_');
+      while (--width);
+
       putchar ('\n');
     }
 }