summaryrefslogtreecommitdiff
path: root/src/arbits/output
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-02-17 20:03:00 +0000
committermidipix <writeonce@midipix.org>2024-02-17 20:03:00 +0000
commitdf2627424d9afc77f4c6adf7520b253036a3ae84 (patch)
tree2a5a1243e84931259a8637a52eee3daab1feda8d /src/arbits/output
parent6b3bd56ddd0f33a1a0a4830c638567c24524c07c (diff)
downloadslibtool-df2627424d9afc77f4c6adf7520b253036a3ae84.tar.bz2
slibtool-df2627424d9afc77f4c6adf7520b253036a3ae84.tar.xz
ar mode: pretty printer: symbols, mapfile: produce a sorted output by default.
Diffstat (limited to 'src/arbits/output')
-rw-r--r--src/arbits/output/slbt_ar_output_mapfile.c12
-rw-r--r--src/arbits/output/slbt_ar_output_symbols.c11
2 files changed, 21 insertions, 2 deletions
diff --git a/src/arbits/output/slbt_ar_output_mapfile.c b/src/arbits/output/slbt_ar_output_mapfile.c
index 09774bd..3455c37 100644
--- a/src/arbits/output/slbt_ar_output_mapfile.c
+++ b/src/arbits/output/slbt_ar_output_mapfile.c
@@ -20,21 +20,31 @@ static int slbt_ar_output_mapfile_impl(
struct slbt_archive_meta_impl * mctx,
int fdout)
{
+ bool fsort;
const char * regex;
const char ** symv;
+ const char ** symstrv;
regex_t regctx;
regmatch_t pmatch[2] = {0};
+ fsort = true;
+
if (slbt_dprintf(fdout,"{\n" "\t" "global:\n") < 0)
return SLBT_SYSTEM_ERROR(dctx,0);
+ if (fsort && !mctx->mapstrv)
+ if (slbt_update_mapstrv(dctx,mctx) < 0)
+ return SLBT_NESTED_ERROR(dctx);
+
if ((regex = dctx->cctx->regex))
if (regcomp(&regctx,regex,REG_NEWLINE))
return SLBT_CUSTOM_ERROR(
dctx,
SLBT_ERR_FLOW_ERROR);
- for (symv=mctx->symstrv; *symv; symv++)
+ symstrv = fsort ? mctx->mapstrv : mctx->symstrv;
+
+ for (symv=symstrv; *symv; symv++)
if (!regex || !regexec(&regctx,*symv,1,pmatch,0))
if (slbt_dprintf(fdout,"\t\t%s;\n",*symv) < 0)
return SLBT_SYSTEM_ERROR(dctx,0);
diff --git a/src/arbits/output/slbt_ar_output_symbols.c b/src/arbits/output/slbt_ar_output_symbols.c
index cfd0be8..167de50 100644
--- a/src/arbits/output/slbt_ar_output_symbols.c
+++ b/src/arbits/output/slbt_ar_output_symbols.c
@@ -25,12 +25,19 @@ static int slbt_ar_output_symbols_posix(
const struct slbt_fd_ctx * fdctx)
{
int fdout;
+ bool fsort;
const char * regex;
const char ** symv;
+ const char ** symstrv;
regex_t regctx;
regmatch_t pmatch[2] = {0};
fdout = fdctx->fdout;
+ fsort = true;
+
+ if (fsort && !mctx->mapstrv)
+ if (slbt_update_mapstrv(dctx,mctx) < 0)
+ return SLBT_NESTED_ERROR(dctx);
if ((regex = dctx->cctx->regex))
if (regcomp(&regctx,regex,REG_NEWLINE))
@@ -38,7 +45,9 @@ static int slbt_ar_output_symbols_posix(
dctx,
SLBT_ERR_FLOW_ERROR);
- for (symv=mctx->symstrv; *symv; symv++)
+ symstrv = fsort ? mctx->mapstrv : mctx->symstrv;
+
+ for (symv=symstrv; *symv; symv++)
if (!regex || !regexec(&regctx,*symv,1,pmatch,0))
if (slbt_dprintf(fdout,"%s\n",*symv) < 0)
return SLBT_SYSTEM_ERROR(dctx,0);