From: Jim Meyering Date: Sun, 14 Jul 1996 22:28:52 +0000 (+0000) Subject: [HAVE_LIMITS_H]: Include limits.h for INT_MAX. X-Git-Tag: TEXTUTILS-1_19b~178 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d026dd508d744c089765fdb033b7e51485d0b5a;p=thirdparty%2Fcoreutils.git [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. --- diff --git a/src/unexpand.c b/src/unexpand.c index f5c91c00d5..6d10022494 100644 --- a/src/unexpand.c +++ b/src/unexpand.c @@ -44,6 +44,19 @@ #include #include #include "system.h" + +#ifdef HAVE_LIMITS_H +# include +#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;