summaryrefslogtreecommitdiff
path: root/src/internal/slibtool_coff_impl.c
blob: ac6a2fd0ed538d7cd2aef0a9c2eeae039c4ad626 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*******************************************************************/
/*  slibtool: a strong libtool implementation, written in C        */
/*  Copyright (C) 2016--2024  SysDeer Technologies, LLC            */
/*  Released under the Standard MIT License; see COPYING.SLIBTOOL. */
/*******************************************************************/

#include <string.h>
#include "slibtool_visibility_impl.h"

slbt_hidden int slbt_coff_qsort_strcmp(const void * a, const void * b)
{
	const char *    dot;
	const char *    mark;
	const char *    stra;
	const char *    strb;
	const char **   pstra;
	const char **   pstrb;
	char            strbufa[4096];
	char            strbufb[4096];

	pstra = (const char **)a;
	pstrb = (const char **)b;

	stra  = *pstra;
	strb  = *pstrb;

	if (!strncmp(*pstra,".weak.",6)) {
		stra = strbufa;
		mark = &(*pstra)[6];
		dot  = strchr(mark,'.');

		strncpy(strbufa,mark,dot-mark);
		strbufa[dot-mark] = '\0';
	}

	if (!strncmp(*pstrb,".weak.",6)) {
		strb = strbufb;
		mark = &(*pstrb)[6];
		dot  = strchr(mark,'.');

		strncpy(strbufb,mark,dot-mark);
		strbufb[dot-mark] = '\0';
	}

	return strcmp(stra,strb);
}