Implement one qsort() comparator function for strings and use it.
This commit is contained in:
parent
cfd5bce43d
commit
5ed882763a
|
@ -786,12 +786,6 @@ Cmd_Exists(char *cmd_name)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
qsort_strcomp(const void *s1, const void *s2)
|
|
||||||
{
|
|
||||||
return strcmp(*(char **)s1, *(char **)s2);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
Cmd_CompleteCommand(char *partial)
|
Cmd_CompleteCommand(char *partial)
|
||||||
{
|
{
|
||||||
|
@ -877,7 +871,7 @@ Cmd_CompleteCommand(char *partial)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sort it */
|
/* Sort it */
|
||||||
qsort(pmatch, i, sizeof(pmatch[0]), qsort_strcomp);
|
qsort(pmatch, i, sizeof(pmatch[0]), Q_sort_strcomp);
|
||||||
|
|
||||||
Com_Printf("\n\n");
|
Com_Printf("\n\n");
|
||||||
|
|
||||||
|
|
|
@ -1802,8 +1802,6 @@ FS_InitFilesystem(void)
|
||||||
Com_Printf("Using '%s' for writing.\n", fs_gamedir);
|
Com_Printf("Using '%s' for writing.\n", fs_gamedir);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int qsort_strcomp(const void *s1, const void *s2);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Combs all Raw search paths to find game dirs containing PAK/PK2/PK3 files.
|
* Combs all Raw search paths to find game dirs containing PAK/PK2/PK3 files.
|
||||||
* Returns an alphabetized array of unique relative dir names.
|
* Returns an alphabetized array of unique relative dir names.
|
||||||
|
@ -1894,7 +1892,7 @@ FS_ListMods(int *nummods)
|
||||||
|
|
||||||
modnames[nmods] = 0;
|
modnames[nmods] = 0;
|
||||||
|
|
||||||
qsort(modnames, nmods, sizeof(modnames[0]), qsort_strcomp);
|
qsort(modnames, nmods, sizeof(modnames[0]), Q_sort_strcomp);
|
||||||
|
|
||||||
*nummods = nmods;
|
*nummods = nmods;
|
||||||
return modnames;
|
return modnames;
|
||||||
|
|
|
@ -290,6 +290,9 @@ int Q_strlcat(char *dst, const char *src, int size);
|
||||||
/* Unicode wrappers that also make sure it's a regular file around fopen(). */
|
/* Unicode wrappers that also make sure it's a regular file around fopen(). */
|
||||||
FILE *Q_fopen(const char *file, const char *mode);
|
FILE *Q_fopen(const char *file, const char *mode);
|
||||||
|
|
||||||
|
/* Comparator function for qsort(), compares strings. */
|
||||||
|
int Q_sort_strcomp(const void *s1, const void *s2);
|
||||||
|
|
||||||
/* ============================================= */
|
/* ============================================= */
|
||||||
|
|
||||||
short BigShort(short l);
|
short BigShort(short l);
|
||||||
|
|
|
@ -1195,6 +1195,12 @@ FILE *Q_fopen(const char *file, const char *mode)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
Q_sort_strcomp(const void *s1, const void *s2)
|
||||||
|
{
|
||||||
|
return strcmp(*(char **)s1, *(char **)s2);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* =====================================================================
|
* =====================================================================
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue