mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
Implement one qsort() comparator function for strings and use it.
This commit is contained in:
parent
cfd5bce43d
commit
5ed882763a
4 changed files with 11 additions and 10 deletions
|
@ -786,12 +786,6 @@ Cmd_Exists(char *cmd_name)
|
|||
return false;
|
||||
}
|
||||
|
||||
int
|
||||
qsort_strcomp(const void *s1, const void *s2)
|
||||
{
|
||||
return strcmp(*(char **)s1, *(char **)s2);
|
||||
}
|
||||
|
||||
char *
|
||||
Cmd_CompleteCommand(char *partial)
|
||||
{
|
||||
|
@ -877,7 +871,7 @@ Cmd_CompleteCommand(char *partial)
|
|||
}
|
||||
|
||||
/* Sort it */
|
||||
qsort(pmatch, i, sizeof(pmatch[0]), qsort_strcomp);
|
||||
qsort(pmatch, i, sizeof(pmatch[0]), Q_sort_strcomp);
|
||||
|
||||
Com_Printf("\n\n");
|
||||
|
||||
|
|
|
@ -1802,8 +1802,6 @@ FS_InitFilesystem(void)
|
|||
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.
|
||||
* Returns an alphabetized array of unique relative dir names.
|
||||
|
@ -1894,7 +1892,7 @@ FS_ListMods(int *nummods)
|
|||
|
||||
modnames[nmods] = 0;
|
||||
|
||||
qsort(modnames, nmods, sizeof(modnames[0]), qsort_strcomp);
|
||||
qsort(modnames, nmods, sizeof(modnames[0]), Q_sort_strcomp);
|
||||
|
||||
*nummods = nmods;
|
||||
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(). */
|
||||
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);
|
||||
|
|
|
@ -1195,6 +1195,12 @@ FILE *Q_fopen(const char *file, const char *mode)
|
|||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
Q_sort_strcomp(const void *s1, const void *s2)
|
||||
{
|
||||
return strcmp(*(char **)s1, *(char **)s2);
|
||||
}
|
||||
|
||||
/*
|
||||
* =====================================================================
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue