| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: index.c,v 1.1.1.1 2016/01/14 00:11:29 christos Exp $ */ | | 1 | /* $NetBSD: index.c,v 1.2 2024/04/16 23:43:08 christos Exp $ */ |
2 | | | 2 | |
3 | /* index.c -- indexing for Texinfo. | | 3 | /* index.c -- indexing for Texinfo. |
4 | Id: index.c,v 1.17 2004/11/30 02:03:23 karl Exp | | 4 | Id: index.c,v 1.17 2004/11/30 02:03:23 karl Exp |
5 | | | 5 | |
6 | Copyright (C) 1998, 1999, 2002, 2003, 2004 Free Software Foundation, | | 6 | Copyright (C) 1998, 1999, 2002, 2003, 2004 Free Software Foundation, |
7 | Inc. | | 7 | Inc. |
8 | | | 8 | |
9 | This program is free software; you can redistribute it and/or modify | | 9 | This program is free software; you can redistribute it and/or modify |
10 | it under the terms of the GNU General Public License as published by | | 10 | it under the terms of the GNU General Public License as published by |
11 | the Free Software Foundation; either version 2, or (at your option) | | 11 | the Free Software Foundation; either version 2, or (at your option) |
12 | any later version. | | 12 | any later version. |
13 | | | 13 | |
14 | This program is distributed in the hope that it will be useful, | | 14 | This program is distributed in the hope that it will be useful, |
| @@ -501,28 +501,50 @@ cm_findex (void) /* F | | | @@ -501,28 +501,50 @@ cm_findex (void) /* F |
501 | } | | 501 | } |
502 | | | 502 | |
503 | void | | 503 | void |
504 | cm_tindex (void) /* Data Type index. */ | | 504 | cm_tindex (void) /* Data Type index. */ |
505 | { | | 505 | { |
506 | index_add_arg ("tp"); | | 506 | index_add_arg ("tp"); |
507 | } | | 507 | } |
508 | | | 508 | |
509 | int | | 509 | int |
510 | index_element_compare (const void *element1, const void *element2) | | 510 | index_element_compare (const void *element1, const void *element2) |
511 | { | | 511 | { |
512 | INDEX_ELT **elt1 = (INDEX_ELT **) element1; | | 512 | INDEX_ELT **elt1 = (INDEX_ELT **) element1; |
513 | INDEX_ELT **elt2 = (INDEX_ELT **) element2; | | 513 | INDEX_ELT **elt2 = (INDEX_ELT **) element2; |
| | | 514 | int ret = 0; |
514 | | | 515 | |
515 | return index_compare_fn ((*elt1)->entry, (*elt2)->entry); | | 516 | /* Find a stable sort order. */ |
| | | 517 | if (ret == 0) |
| | | 518 | ret = index_compare_fn ((*elt1)->entry, (*elt2)->entry); |
| | | 519 | if (ret == 0) |
| | | 520 | ret = strcmp ((*elt1)->defining_file, (*elt2)->defining_file); |
| | | 521 | if (ret == 0) |
| | | 522 | ret = strcmp ((*elt1)->node, (*elt2)->node); |
| | | 523 | if (ret == 0) |
| | | 524 | if ((*elt1)->defining_line < (*elt2)->defining_line) |
| | | 525 | ret = -1; |
| | | 526 | else if ((*elt1)->defining_line > (*elt2)->defining_line) |
| | | 527 | ret = 1; |
| | | 528 | if (ret == 0) |
| | | 529 | if ((*elt1)->entry_number < (*elt2)->entry_number) |
| | | 530 | ret = -1; |
| | | 531 | else if ((*elt1)->entry_number > (*elt2)->entry_number) |
| | | 532 | ret = 1; |
| | | 533 | if (ret == 0) { |
| | | 534 | abort (); |
| | | 535 | } |
| | | 536 | |
| | | 537 | return ret; |
516 | } | | 538 | } |
517 | | | 539 | |
518 | /* Force all index entries to be unique. */ | | 540 | /* Force all index entries to be unique. */ |
519 | static void | | 541 | static void |
520 | make_index_entries_unique (INDEX_ELT **array, int count) | | 542 | make_index_entries_unique (INDEX_ELT **array, int count) |
521 | { | | 543 | { |
522 | int i, j; | | 544 | int i, j; |
523 | INDEX_ELT **copy; | | 545 | INDEX_ELT **copy; |
524 | int counter = 1; | | 546 | int counter = 1; |
525 | | | 547 | |
526 | copy = xmalloc ((1 + count) * sizeof (INDEX_ELT *)); | | 548 | copy = xmalloc ((1 + count) * sizeof (INDEX_ELT *)); |
527 | | | 549 | |
528 | for (i = 0, j = 0; i < count; i++) | | 550 | for (i = 0, j = 0; i < count; i++) |