MCPcopy Create free account
hub / github.com/eggert/tz / qsort_linkcmp

Function qsort_linkcmp

zic.c:958–974  ·  view source on GitHub ↗

Compare the two links A and B, for a stable sort by link name. */

Source from the content-addressed store, hash-verified

956static int
957qsort_linkcmp(void const *a, void const *b)
958{
959 struct link const *l = a;
960 struct link const *m = b;
961 int cmp = strcmp(l->l_linkname, m->l_linkname);
962 if (cmp)
963 return cmp;
964
965 /* The link names are the same. Make the sort stable by comparing
966 file numbers (where subtraction cannot overflow) and possibly
967 line numbers (where it can). */
968 cmp = l->l_filenum - m->l_filenum;
969 if (cmp)
970 return cmp;
971 return (l->l_linenum > m->l_linenum) - (l->l_linenum < m->l_linenum);
972}
973
974/* Compare the string KEY to the link B, for bsearch. */
975static int
976bsearch_linkcmp(void const *key, void const *b)
977{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected