]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
[HAVE_LIMITS_H]: Include limits.h for INT_MAX.
authorJim Meyering <jim@meyering.net>
Sun, 14 Jul 1996 22:28:52 +0000 (22:28 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 14 Jul 1996 22:28:52 +0000 (22:28 +0000)
[!INT_MAX]: Define it.
(main): Append INT_MAX to command-line-specified tab list to
ensure termination in unexpand's inner loop.
Derived from a patch from Keith Owens.

src/unexpand.c

index f5c91c00d5ae00642aa35f1b31d20f7162cc937e..6d10022494ca8d028ebf0d466a5dab0497c776cc 100644 (file)
 #include <getopt.h>
 #include <sys/types.h>
 #include "system.h"
+
+#ifdef HAVE_LIMITS_H
+# include <limits.h>
+#endif
+
+#ifndef UINT_MAX
+# define UINT_MAX ((unsigned int) ~(unsigned int) 0)
+#endif
+
+#ifndef INT_MAX
+# define INT_MAX ((int) (UINT_MAX >> 1))
+#endif
+
 #include "error.h"
 
 /* The number of bytes added at a time to the amount of memory
@@ -440,7 +453,11 @@ main (int argc, char **argv)
   else if (first_free_tab == 1)
     tab_size = tab_list[0];
   else
-    tab_size = 0;
+    {
+      /* Append a sentinel to the list of tab stop indices.  */
+      add_tabstop (INT_MAX);
+      tab_size = 0;
+    }
 
   if (optind == argc)
     file_list = stdin_argv;