aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-core/toybox/toybox/0002-Fix-trimmed-printf-in-grep.patch
blob: 37808d03bc56b2e6f6a8a6a82ccb8d532d01adbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From 9c51a0d7690fb3b08871dae2486af4032d8442fb Mon Sep 17 00:00:00 2001
From: Paul Barker <paul@paulbarker.me.uk>
Date: Sat, 4 Jun 2016 15:42:48 +0100
Subject: [PATCH 2/2] Fix trimmed printf in grep

Using a default trim value of INT_MAX/2 when printing a line causes nothing to
be printed on a system built using OpenEmbedded for the qemux86 target. This may
also affect other systems.

Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
Upstream-status: Submitted
---
 toys/posix/grep.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/toys/posix/grep.c b/toys/posix/grep.c
index 2ca02d2..f38c538 100644
--- a/toys/posix/grep.c
+++ b/toys/posix/grep.c
@@ -74,7 +74,10 @@ static void outline(char *line, char dash, char *name, long lcount, long bcount,
   if (!line || (lcount && (toys.optflags&FLAG_n)))
     printf("%ld%c", lcount, line ? dash : TT.outdelim);
   if (bcount && (toys.optflags&FLAG_b)) printf("%ld%c", bcount-1, dash);
-  if (line) xprintf("%.*s%c", trim ? trim : INT_MAX/2, line, TT.outdelim);
+  if (line) {
+    if (trim) xprintf("%.*s%c", trim, line, TT.outdelim);
+    else xprintf("%s%c", line, TT.outdelim);
+  }
 }
 
 // Show matches in one file
-- 
2.1.4