From df2627424d9afc77f4c6adf7520b253036a3ae84 Mon Sep 17 00:00:00 2001 From: midipix Date: Sat, 17 Feb 2024 20:03:00 +0000 Subject: ar mode: pretty printer: symbols, mapfile: produce a sorted output by default. --- src/arbits/slbt_archive_mapstrv.c | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/arbits/slbt_archive_mapstrv.c (limited to 'src/arbits/slbt_archive_mapstrv.c') diff --git a/src/arbits/slbt_archive_mapstrv.c b/src/arbits/slbt_archive_mapstrv.c new file mode 100644 index 0000000..eadf809 --- /dev/null +++ b/src/arbits/slbt_archive_mapstrv.c @@ -0,0 +1,41 @@ +/*******************************************************************/ +/* slibtool: a skinny libtool implementation, written in C */ +/* Copyright (C) 2016--2024 SysDeer Technologies, LLC */ +/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */ +/*******************************************************************/ + +#include +#include +#include +#include "slibtool_driver_impl.h" +#include "slibtool_errinfo_impl.h" +#include "slibtool_ar_impl.h" + +static int slbt_strcmp(const void * a, const void * b) +{ + return strcmp(*(const char **)a,*(const char **)b); +} + +int slbt_update_mapstrv( + const struct slbt_driver_ctx * dctx, + struct slbt_archive_meta_impl * mctx) +{ + size_t nsyms; + const char ** symv; + const char ** mapstrv; + + for (nsyms=0,symv=mctx->symstrv; *symv; symv++) + nsyms++; + + if (!(mapstrv = calloc(nsyms+1,sizeof(const char *)))) + return SLBT_SYSTEM_ERROR(dctx,0); + + for (nsyms=0,symv=mctx->symstrv; *symv; symv++) + mapstrv[nsyms++] = *symv; + + qsort(mapstrv,nsyms,sizeof(const char *),slbt_strcmp); + + mctx->mapstrv = mapstrv; + + return 0; +} -- cgit v1.2.3