From ad305da3b6ca5a16ac98e6efaae21f3c4d5cebf4 Mon Sep 17 00:00:00 2001
From: Assaf Gordon <assafgordon@gmail.com>
Date: Sun, 10 Jan 2016 18:37:12 -0500
Subject: [PATCH] size: avoid block-size rounding with k/m/g suffixes to -size

---
 find/parser.c | 11 +++++++++++
 po/.gitignore |  1 +
 2 files changed, 12 insertions(+)

diff --git a/find/parser.c b/find/parser.c
index 4c1a2ed..4f0dc39 100644
--- a/find/parser.c
+++ b/find/parser.c
@@ -2146,6 +2146,7 @@ parse_size (const struct parser_table* entry, char **argv, int *arg_ptr)
   uintmax_t num;
   char suffix;
   enum comparison_type c_type;
+  bool normalize_size = false;
 
   int blksize = 512;
   int len;
@@ -2176,16 +2177,19 @@ parse_size (const struct parser_table* entry, char **argv, int *arg_ptr)
 
     case 'k':
       blksize = 1024;
+      normalize_size = true;
       arg[len - 1] = '\0';
       break;
 
     case 'M':			/* Megabytes */
       blksize = 1024*1024;
+      normalize_size = true;
       arg[len - 1] = '\0';
       break;
 
     case 'G':			/* Gigabytes */
       blksize = 1024*1024*1024;
+      normalize_size = true;
       arg[len - 1] = '\0';
       break;
 
@@ -2223,6 +2227,13 @@ parse_size (const struct parser_table* entry, char **argv, int *arg_ptr)
 	     arg, tail);
       return false;
     }
+
+  if (normalize_size && (c_type==COMP_GT || c_type==COMP_LT))
+    {
+      /* TODO: handle overflow */
+      num *= blksize;
+      blksize = 1;
+    }
   our_pred = insert_primary (entry, arg);
   our_pred->args.size.kind = c_type;
   our_pred->args.size.blocksize = blksize;
diff --git a/po/.gitignore b/po/.gitignore
index 6e8a88b..bb891f4 100644
--- a/po/.gitignore
+++ b/po/.gitignore
@@ -1,3 +1,4 @@
+/Makefile.in.in~
 /cat-id-tbl.c
 /*.gmo
 /Makefile
-- 
2.4.3

