summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1996-07-14 22:28:52 +0000
committerJim Meyering <jim@meyering.net>1996-07-14 22:28:52 +0000
commit7d026dd508d744c089765fdb033b7e51485d0b5a (patch)
tree40ccc90dd73866540453156fa75032740ccea2a1
parent178f23fbb719a46f16e4426615731984e77dfb14 (diff)
downloadcoreutils-7d026dd508d744c089765fdb033b7e51485d0b5a.tar.xz
[HAVE_LIMITS_H]: Include limits.h for INT_MAX.
[!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.
-rw-r--r--src/unexpand.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/unexpand.c b/src/unexpand.c
index f5c91c00d..6d1002249 100644
--- a/src/unexpand.c
+++ b/src/unexpand.c
@@ -44,6 +44,19 @@
#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;