From 0537481027528b1013c490fa8979f3d650308501 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Tue, 10 Apr 2001 01:28:38 +0000
Subject: [PATCH] glob() now sorts alphabetically by default (ala Unix), but
 case-insensitive. getfreediskspace now returns (2GB) if more than 4GB free.

---
 src/sbbs3/wrappers.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/sbbs3/wrappers.c b/src/sbbs3/wrappers.c
index 4ca145165d..6ddde1d2ad 100644
--- a/src/sbbs3/wrappers.c
+++ b/src/sbbs3/wrappers.c
@@ -90,6 +90,13 @@
 #ifdef __BORLANDC__
 	#pragma argsused
 #endif
+
+static int glob_compare( const void *arg1, const void *arg2 )
+{
+   /* Compare all of both strings: */
+   return stricmp( * ( char** ) arg1, * ( char** ) arg2 );
+}
+
 int	DLLCALL	glob(const char *pattern, int flags, void* unused, glob_t* glob)
 {
     struct	_finddata_t ff;
@@ -140,6 +147,10 @@ int	DLLCALL	glob(const char *pattern, int flags, void* unused, glob_t* glob)
 	if(found==0)
 		return(GLOB_NOMATCH);
 
+	if(!(flags&GLOB_NOSORT)) {
+		qsort(glob->gl_pathv,found,sizeof(char*),glob_compare);
+	}
+
 	return(0);	/* success */
 }
 
@@ -384,7 +395,7 @@ ulong DLLCALL getfreediskspace(char* path)
 #else
 		if(avail.u.HighPart)
 #endif
-			return(~0);	/* 4GB max */
+			return(0x7fffffff);	/* 2GB max */
 
 #ifdef _ANONYMOUS_STRUCT
 		return(avail.LowPart);
-- 
GitLab