mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-22 04:21:23 +00:00
reformat the compare func used in qsort
This commit is contained in:
parent
6c628db56a
commit
aab11cd873
2 changed files with 13 additions and 7 deletions
12
src/d_main.c
12
src/d_main.c
|
@ -1842,17 +1842,21 @@ static boolean check_top_dir(const char **path, const char *top)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cmp_strlen_desc(const void *a, const void *b)
|
static int cmp_strlen_desc(const void *A, const void *B)
|
||||||
{
|
{
|
||||||
return ((int)strlen(*(const char*const*)b) - (int)strlen(*(const char*const*)a));
|
const char *pA = A;
|
||||||
|
const char *pB = B;
|
||||||
|
size_t As = strlen(pA);
|
||||||
|
size_t Bs = strlen(pB);
|
||||||
|
return ((int)Bs - (int)As);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean D_IsPathAllowed(const char *path)
|
boolean D_IsPathAllowed(const char *path)
|
||||||
{
|
{
|
||||||
const char *paths[] = {
|
char *paths[] = {
|
||||||
srb2home,
|
srb2home,
|
||||||
srb2path,
|
srb2path,
|
||||||
cv_addons_folder.string
|
cv_addons_folder.zstring
|
||||||
};
|
};
|
||||||
|
|
||||||
const size_t n_paths = sizeof paths / sizeof *paths;
|
const size_t n_paths = sizeof paths / sizeof *paths;
|
||||||
|
|
|
@ -700,9 +700,11 @@ static void initdirpath(char *dirpath, size_t *dirpathindex, int depthleft)
|
||||||
}
|
}
|
||||||
|
|
||||||
//sortdir by name?
|
//sortdir by name?
|
||||||
static int lumpnamecompare( const void *A, const void *B )
|
static int lumpnamecompare(const void *A, const void *B)
|
||||||
{
|
{
|
||||||
return strcmp( (((lumpinfo_t *)A)->fullname), (((lumpinfo_t *)B)->fullname));
|
const lumpinfo_t *pA = A;
|
||||||
|
const lumpinfo_t *pB = B;
|
||||||
|
return strcmp((pA->fullname), (pB->fullname));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -897,7 +899,7 @@ lumpinfo_t *getdirectoryfiles(const char *path, UINT16 *nlmp, UINT16 *nfolders)
|
||||||
free(dirhandle);
|
free(dirhandle);
|
||||||
|
|
||||||
//sort files and directories
|
//sort files and directories
|
||||||
qsort ( lumpinfo, numlumps, sizeof( lumpinfo_t ), lumpnamecompare );
|
qsort (lumpinfo, numlumps, sizeof(lumpinfo_t), lumpnamecompare);
|
||||||
|
|
||||||
(*nlmp) = numlumps;
|
(*nlmp) = numlumps;
|
||||||
return lumpinfo;
|
return lumpinfo;
|
||||||
|
|
Loading…
Reference in a new issue