From 886c09eb7caa4f82d98ca87dab24418a344f5ae7 Mon Sep 17 00:00:00 2001 From: midipix Date: Sat, 16 Mar 2024 17:34:12 +0000 Subject: code base: internals: move slbt_coff_strcmp() to own translation unit. --- project/common.mk | 1 + project/headers.mk | 1 + src/arbits/slbt_archive_mapstrv.c | 39 +-------------------------------- src/internal/slibtool_coff_impl.c | 46 +++++++++++++++++++++++++++++++++++++++ src/internal/slibtool_coff_impl.h | 6 +++++ 5 files changed, 55 insertions(+), 38 deletions(-) create mode 100644 src/internal/slibtool_coff_impl.c create mode 100644 src/internal/slibtool_coff_impl.h diff --git a/project/common.mk b/project/common.mk index 8499440..e7d687a 100644 --- a/project/common.mk +++ b/project/common.mk @@ -64,6 +64,7 @@ FALLBACK_SRCS = \ src/fallback/slbt_archive_import_mri.c \ INTERNAL_SRCS = \ + src/internal/$(PACKAGE)_coff_impl.c \ src/internal/$(PACKAGE)_dprintf_impl.c \ src/internal/$(PACKAGE)_errinfo_impl.c \ src/internal/$(PACKAGE)_lconf_impl.c \ diff --git a/project/headers.mk b/project/headers.mk index aad65cc..b986ec2 100644 --- a/project/headers.mk +++ b/project/headers.mk @@ -7,6 +7,7 @@ API_HEADERS = \ INTERNAL_HEADERS = \ $(PROJECT_DIR)/src/internal/argv/argv.h \ $(PROJECT_DIR)/src/internal/$(PACKAGE)_ar_impl.h \ + $(PROJECT_DIR)/src/internal/$(PACKAGE)_coff_impl.h \ $(PROJECT_DIR)/src/internal/$(PACKAGE)_dprintf_impl.h \ $(PROJECT_DIR)/src/internal/$(PACKAGE)_driver_impl.h \ $(PROJECT_DIR)/src/internal/$(PACKAGE)_errinfo_impl.h \ diff --git a/src/arbits/slbt_archive_mapstrv.c b/src/arbits/slbt_archive_mapstrv.c index 10d59f1..c8c27e9 100644 --- a/src/arbits/slbt_archive_mapstrv.c +++ b/src/arbits/slbt_archive_mapstrv.c @@ -11,50 +11,13 @@ #include "slibtool_errinfo_impl.h" #include "slibtool_visibility_impl.h" #include "slibtool_ar_impl.h" +#include "slibtool_coff_impl.h" static int slbt_strcmp(const void * a, const void * b) { return strcmp(*(const char **)a,*(const char **)b); } -static int slbt_coff_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); -} - slbt_hidden int slbt_update_mapstrv( const struct slbt_driver_ctx * dctx, struct slbt_archive_meta_impl * mctx) diff --git a/src/internal/slibtool_coff_impl.c b/src/internal/slibtool_coff_impl.c new file mode 100644 index 0000000..8d405ac --- /dev/null +++ b/src/internal/slibtool_coff_impl.c @@ -0,0 +1,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 +#include "slibtool_visibility_impl.h" + +slbt_hidden int slbt_coff_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); +} diff --git a/src/internal/slibtool_coff_impl.h b/src/internal/slibtool_coff_impl.h new file mode 100644 index 0000000..c733b0f --- /dev/null +++ b/src/internal/slibtool_coff_impl.h @@ -0,0 +1,6 @@ +#ifndef SLIBTOOL_COFF_IMPL_H +#define SLIBTOOL_COFF_IMPL_H + +int slbt_coff_strcmp(const void * a, const void * b); + +#endif -- cgit v1.2.3