diff options
author | Rob Landley <rob@landley.net> | 2015-04-28 12:18:17 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2015-04-28 12:18:17 -0500 |
commit | 789665dc51c85f6fabfaf6f70f12d54b9df117df (patch) | |
tree | 17bfcabc2f272156a62605b10539bfb2675b0721 /toys/other/truncate.c | |
parent | 89701da1fef87dad77927d30194ab28f19d26366 (diff) | |
download | toybox-789665dc51c85f6fabfaf6f70f12d54b9df117df.tar.gz |
Fix truncate prefix bug and add truncate test suite entry.
Diffstat (limited to 'toys/other/truncate.c')
-rw-r--r-- | toys/other/truncate.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/toys/other/truncate.c b/toys/other/truncate.c index 2b3d4795..bfe1f10c 100644 --- a/toys/other/truncate.c +++ b/toys/other/truncate.c @@ -16,7 +16,7 @@ config TRUNCATE -s New size (with optional prefix and suffix) SIZE prefix: + add, - subtract, < shrink to, > expand to, - / block size rounding down, % block size rounding up + / multiple rounding down, % multiple rounding up SIZE suffix: k=1024, m=1024^2, g=1024^3, t=1024^4, p=1024^5, e=1024^6 */ @@ -41,7 +41,8 @@ static void do_truncate(int fd, char *name) size = fdlength(fd); if (TT.type<2) size += TT.size*(1-(2*TT.type)); else if (TT.type<4) { - if ((TT.type==3) ? size > TT.size : size < TT.size) size = TT.size; + if ((TT.type==2) ? (size <= TT.size) : (size >= TT.size)) return; + size = TT.size; } else { size = (size+(TT.type-4)*(TT.size-1))/TT.size; size *= TT.size; |