retitle 348072 qsort/bsearch should use more robust example code tags 348072 + patch thanks
Here's a patch for the remaining issue. diff -Nurp manpages-2.39/man3/bsearch.3 manpages-2.39.hacked/man3/bsearch.3 --- manpages-2.39/man3/bsearch.3 2006-08-03 15:57:30.000000000 +0200 +++ manpages-2.39.hacked/man3/bsearch.3 2006-10-01 13:54:59.000000000 +0200 @@ -75,7 +75,7 @@ struct mi { { 9, "sep" }, {10, "oct" }, {11, "nov" }, {12, "dec" } }; -#define nr_of_months (sizeof(months)/sizeof(months[0])) +#define nr_of_months (sizeof months / sizeof *months) static int compmi(const void *m1, const void *m2) { struct mi *mi1 = (struct mi *) m1; @@ -86,12 +86,12 @@ static int compmi(const void *m1, const int main(int argc, char **argv) { int i; - qsort(months, nr_of_months, sizeof(struct mi), compmi); + qsort(months, nr_of_months, sizeof *months, compmi); for (i = 1; i < argc; i++) { struct mi key, *res; key.name = argv[i]; res = bsearch(&key, months, nr_of_months, - sizeof(struct mi), compmi); + sizeof *months, compmi); if (res == NULL) printf("'%s': unknown month\en", argv[i]); else diff -Nurp manpages-2.39/man3/qsort.3 manpages-2.39.hacked/man3/qsort.3 --- manpages-2.39/man3/qsort.3 2006-08-03 15:57:30.000000000 +0200 +++ manpages-2.39.hacked/man3/qsort.3 2006-10-01 13:53:16.000000000 +0200 @@ -98,7 +98,7 @@ main(int argc, char *argv[]) assert(argc > 1); - qsort(&argv[1], argc - 1, sizeof(char *), cmpstringp); + qsort(&argv[1], argc - 1, sizeof argv[1], cmpstringp); for (j = 1; j < argc; j++) puts(argv[j]); -- Falk -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]