diff options
author | midipix <writeonce@midipix.org> | 2024-02-17 00:44:29 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2024-02-17 00:44:29 +0000 |
commit | 7ffcb591bd686006e325722b45c1fe91d1ff3eff (patch) | |
tree | 63b8da166c53a4689adef4fe02d290093760e041 | |
parent | 0b177bee8b822e7291764b8c7c097125218da782 (diff) | |
download | slibtool-7ffcb591bd686006e325722b45c1fe91d1ff3eff.tar.bz2 slibtool-7ffcb591bd686006e325722b45c1fe91d1ff3eff.tar.xz |
ar mode: posix pretty printer: multiple inputs: also print the archive name.
-rw-r--r-- | src/arbits/output/slbt_ar_output_arname.c | 39 | ||||
-rw-r--r-- | src/logic/slbt_exec_ar.c | 13 |
2 files changed, 36 insertions, 16 deletions
diff --git a/src/arbits/output/slbt_ar_output_arname.c b/src/arbits/output/slbt_ar_output_arname.c index 4ee722a..38917e7 100644 --- a/src/arbits/output/slbt_ar_output_arname.c +++ b/src/arbits/output/slbt_ar_output_arname.c @@ -15,17 +15,32 @@ | SLBT_PRETTY_POSIX \ | SLBT_PRETTY_HEXDATA) +static int slbt_ar_output_arname_impl( + const struct slbt_driver_ctx * dctx, + const struct slbt_archive_ctx * actx, + const struct slbt_fd_ctx * fdctx, + const char * fmt) +{ + const char * path; + const char mema[] = "<memory_object>"; + + path = actx->path && *actx->path ? *actx->path : mema; + + if (slbt_dprintf(fdctx->fdout,fmt,path) < 0) + return SLBT_SYSTEM_ERROR(dctx,0); + + return 0; +} static int slbt_ar_output_arname_posix( const struct slbt_driver_ctx * dctx, const struct slbt_archive_ctx * actx, const struct slbt_fd_ctx * fdctx) { - (void)dctx; - (void)actx; - (void)fdctx; - - /* posix ar(1) does not print the <archive> file-name */ + if (slbt_ar_output_arname_impl( + dctx,actx,fdctx, + "%s:\n") < 0) + return SLBT_NESTED_ERROR(dctx); return 0; } @@ -35,18 +50,12 @@ static int slbt_ar_output_arname_yaml( const struct slbt_archive_ctx * actx, const struct slbt_fd_ctx * fdctx) { - const char * path; - const char mema[] = "<memory_object>"; - - path = actx->path && *actx->path ? *actx->path : mema; - - if (slbt_dprintf( - fdctx->fdout, + if (slbt_ar_output_arname_impl( + dctx,actx,fdctx, "Archive:\n" " - Meta:\n" - " - [ name: %s ]\n\n", - path) < 0) - return SLBT_SYSTEM_ERROR(dctx,0); + " - [ name: %s ]\n\n") < 0) + return SLBT_NESTED_ERROR(dctx); return 0; } diff --git a/src/logic/slbt_exec_ar.c b/src/logic/slbt_exec_ar.c index eab86ea..9b400af 100644 --- a/src/logic/slbt_exec_ar.c +++ b/src/logic/slbt_exec_ar.c @@ -79,10 +79,21 @@ static int slbt_exec_ar_perform_archive_actions( { struct slbt_archive_ctx ** arctxp; struct slbt_archive_ctx * arctx; + bool farname; + + switch (dctx->cctx->fmtflags & SLBT_PRETTY_FLAGS) { + case SLBT_PRETTY_POSIX: + farname = (arctxv[0] && arctxv[1]); + break; + + default: + farname = true; + break; + } for (arctxp=arctxv; *arctxp; arctxp++) { if (dctx->cctx->fmtflags & SLBT_DRIVER_MODE_AR_OUTPUTS) - if (slbt_ar_output_arname(*arctxp) < 0) + if (farname && (slbt_ar_output_arname(*arctxp) < 0)) return SLBT_NESTED_ERROR(dctx); if (dctx->cctx->fmtflags & SLBT_OUTPUT_ARCHIVE_MEMBERS) |