aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-06-15 11:43:48 -0500
committerRob Landley <rob@landley.net>2016-06-15 11:43:48 -0500
commit97ddc600c95623bf803eac4f2a4deda2a2db02d4 (patch)
treea084ef4d19fda6a3ae0c5da3fb8eee0038e0d9ac /toys/posix
parent878ff2f3d7a6a717a76ecc32904bc24bc8720245 (diff)
downloadtoybox-97ddc600c95623bf803eac4f2a4deda2a2db02d4.tar.gz
The glibc bug at https://sourceware.org/bugzilla/show_bug.cgi?id=17829
continues to get worse, and now can't handle INT_MAX/2 either. So our first workaround _also_ broke. But posix says "A negative precision is taken as if the precision were omitted." and that _doesn't_ trigger the glibc bug, so use that instead.
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/grep.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/toys/posix/grep.c b/toys/posix/grep.c
index 2ca02d2c..9e50a7ca 100644
--- a/toys/posix/grep.c
+++ b/toys/posix/grep.c
@@ -74,7 +74,7 @@ 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) xprintf("%.*s%c", trim, line, TT.outdelim);
}
// Show matches in one file
@@ -201,13 +201,13 @@ static void do_grep(int fd, char *name)
while (dlb) {
struct double_list *dl = dlist_pop(&dlb);
- outline(dl->data, '-', name, lcount-before, 0, 0);
+ outline(dl->data, '-', name, lcount-before, 0, -1);
free(dl->data);
free(dl);
before--;
}
- outline(line, ':', name, lcount, bcount, 0);
+ outline(line, ':', name, lcount, bcount, -1);
if (TT.a) after = TT.a+1;
} else outline(start+matches.rm_so, ':', name, lcount, bcount,
matches.rm_eo-matches.rm_so);
@@ -223,7 +223,7 @@ static void do_grep(int fd, char *name)
int discard = (after || TT.b);
if (after && --after) {
- outline(line, '-', name, lcount, 0, 0);
+ outline(line, '-', name, lcount, 0, -1);
discard = 0;
}
if (discard && TT.b) {
@@ -247,7 +247,7 @@ static void do_grep(int fd, char *name)
if ((toys.optflags & FLAG_m) && mcount >= TT.m) break;
}
- if (toys.optflags & FLAG_c) outline(0, ':', name, mcount, 0, 0);
+ if (toys.optflags & FLAG_c) outline(0, ':', name, mcount, 0, -1);
// loopfiles will also close the fd, but this frees an (opaque) struct.
fclose(file);