summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-10-21 19:57:41 +0000
committerJim Meyering <jim@meyering.net>2000-10-21 19:57:41 +0000
commit13e80acf0777bb5aed3d6c766064ed23d7ae0739 (patch)
tree1b054436c4973afe2dd1b3e696b0272957dcf475 /src
parent51e2ffc52458de9b96079cf2b9fd2301eae0ec0a (diff)
downloadcoreutils-13e80acf0777bb5aed3d6c766064ed23d7ae0739.tar.xz
The command, `yes ''|./cat -n' would stop printing after INT_MAX lines.
(cat): Never let `newlines' exceed 3.
Diffstat (limited to 'src')
-rw-r--r--src/cat.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/cat.c b/src/cat.c
index 84634c2cc..9587f7865 100644
--- a/src/cat.c
+++ b/src/cat.c
@@ -350,13 +350,21 @@ cat (
if (++newlines > 0)
{
- /* Are multiple adjacent empty lines to be substituted by
- single ditto (-s), and this was the second empty line? */
-
- if (squeeze_empty_lines && newlines >= 2)
+ if (newlines >= 2)
{
- ch = *bpin++;
- continue;
+ /* Limit this to 2 here. Otherwise, with lots of
+ consecutive newlines, the counter could wrap
+ around at INT_MAX. */
+ newlines = 2;
+
+ /* Are multiple adjacent empty lines to be substituted
+ by single ditto (-s), and this was the second empty
+ line? */
+ if (squeeze_empty_lines)
+ {
+ ch = *bpin++;
+ continue;
+ }
}
/* Are line numbers to be written at empty lines (-n)? */