Date: Sat, 4 Nov 1995 19:03:50 +0100 (MET) From: J Wunsch <j@uriah.heep.sax.de> To: jkh@freefall.freebsd.org (Jordan K. Hubbard) Cc: CVS-commiters@freefall.freebsd.org, cvs-user@freefall.freebsd.org Subject: Re: cvs commit: src/release/sysinstall command.c config.c disks.c label.c sysinstall.h Message-ID: <199511041803.TAA02420@uriah.heep.sax.de> In-Reply-To: <199511041545.HAA28940@freefall.freebsd.org> from "Jordan K. Hubbard" at Nov 4, 95 07:45:33 am
next in thread | previous in thread | raw e-mail | index | archive | help
As Jordan K. Hubbard wrote:
>
> Log:
> Avoid doing disk selection twice in novice install.
> Finally sort the fstab file entries correctly! qsort() either
> doesn't work or isn't working as documented.
qsort() usage is somewhat obfuscated:
j@uriah 222% cat foo.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
const char *text[] = {
"foo", "bar", "mumble", "murx", "junk", "rubbish",
"trash", "bin", "junkpointer"
};
int
compar(const void *a, const void *b)
{
return strcmp((const char *)*((const char **)a),
(const char *)*((const char **)b));
}
int main(void)
{
const char **cp;
int i;
qsort(text, sizeof text / sizeof(const char *), sizeof(const char *),
compar);
for(cp = text, i = 0;
i < sizeof text / sizeof(const char *);
cp++, i++)
printf("%s\n", *cp);
return 0;
}
j@uriah 223% cc -Wall foo.c
j@uriah 224% ./a.out
bar
bin
foo
junk
junkpointer
mumble
murx
rubbish
trash
--
cheers, J"org
joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199511041803.TAA02420>
