Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] size-sorting globs now work for giant files



There was a bug where globs like *(OL[1]) failed to return the largest
file if it was larger that 4GB in size. The bug was an improper int ->
long cast. Patch attached.

dima
From e0e323f27b48180fe32680e2c6a17930c4e5a7ee Mon Sep 17 00:00:00 2001
From: Dima Kogan <dima@xxxxxxxxxxxxxxx>
Date: Sat, 16 Jun 2012 18:04:57 -0700
Subject: [PATCH] zsh glob sorting now works with giant files

globs like *(OL[1]) now correctly expand to the largest file even if its
size is larger that 4GB
---
 Src/glob.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Src/glob.c b/Src/glob.c
index d3ce733..ca2ffaf 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -997,7 +997,9 @@ gmatchcmp(Gmatch a, Gmatch b)
 	    break;
 	}
 	if (r)
-	    return (int) ((s->tp & GS_DESC) ? -r : r);
+	    return (s->tp & GS_DESC) ?
+	      (r < 0L ? 1 : -1) :
+	      (r > 0L ? 1 : -1);
     }
     return 0;
 }
-- 
1.7.10



Messages sorted by: Reverse Date, Date, Thread, Author