From 674684246f30567eaf337009d896e400f4babeb6 Mon Sep 17 00:00:00 2001 From: postscript-dev Date: Fri, 4 Feb 2022 15:21:35 +0000 Subject: [PATCH 1/4] Fix `exiv2`: verbose extract stdout mutli-file When using `exiv2 --verbose`, `--extract` with stdout and multiple files, the output is concatenated together. --- src/exiv2.cpp | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/exiv2.cpp b/src/exiv2.cpp index c353ea0419..8478278e54 100644 --- a/src/exiv2.cpp +++ b/src/exiv2.cpp @@ -159,23 +159,28 @@ int main(int argc, char* const argv[]) // Process all files int n = 1; int s = static_cast(params.files_.size()); - int w = s > 9 ? s > 99 ? 3 : 2 : 1; - for (auto&& file : params.files_) { - // If extracting to stdout then ignore verbose - if (params.verbose_ && !(params.action_ & Action::extract && params.target_ & Params::ctStdInOut)) { - std::cout << _("File") << " " << std::setw(w) << std::right << n++ << "/" << s << ": " << file - << std::endl; - } - task->setBinary(params.binary_); - int ret = task->run(file); - if (rc == 0) - rc = ret; + if (params.action_ & Action::extract && params.target_ & Params::ctStdInOut && s > 1) { + std::cerr << params.progname() << ": " << _("Only one file is allowed when extracting to stdout") << std::endl; + rc = 1; } + else { + int w = s > 9 ? s > 99 ? 3 : 2 : 1; + for (auto&& file : params.files_) { + // If extracting to stdout then ignore verbose + if (params.verbose_ && !(params.action_ & Action::extract && params.target_ & Params::ctStdInOut)) { + std::cout << _("File") << " " << std::setw(w) << std::right << n++ << "/" << s << ": " << file + << std::endl; + } + task->setBinary(params.binary_); + int ret = task->run(file); + if (rc == 0) + rc = ret; + } - taskFactory.cleanup(); - Params::cleanup(); - Exiv2::XmpParser::terminate(); - + taskFactory.cleanup(); + Params::cleanup(); + Exiv2::XmpParser::terminate(); + } } catch (const std::exception& exc) { std::cerr << "Uncaught exception: " << exc.what() << std::endl; rc = 1; From febb4e5417addcd28377342af13b6bee1f8f82b3 Mon Sep 17 00:00:00 2001 From: postscript-dev Date: Fri, 4 Feb 2022 15:29:20 +0000 Subject: [PATCH 2/4] Update doc: verbose extract to stdout with files --- exiv2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exiv2.md b/exiv2.md index c3134ad043..6049327f4b 100644 --- a/exiv2.md +++ b/exiv2.md @@ -660,7 +660,7 @@ Extract target(s) for the [extract](#ex_extract) action. Possible targets are: | C | Extract ICC profile, to a file called *\.icc* (see [ICC PROFILES](#icc_profiles)) | | X | Extract metadata to an XMP sidecar file, \.xmp. Other targets cannot be used with this, as only XMP data is written. Extracted XMP tags include those converted from Exif and IPTC | | XX | Extract "raw" metadata to a sidecar file, \.exv. The remaining targets determine which metadata to include, possible are Exif and IPTC (XMP is always included) | -| - | Output to stdout (see [--insert tgt2](#insert_tgt2) for an example of this feature). This argument ignores [--verbose](#verbose) | +| - | Output to stdout (see example in [--insert tgt2](#insert_tgt2)). This ignores [--verbose](#verbose) and only allows extracting from 1 file | To extract to a location other than the current directory, use [--location dir](#location_dir). From b6abab5d6215f2109a2f7ff07a7490b3205c67f5 Mon Sep 17 00:00:00 2001 From: postscript-dev Date: Fri, 4 Feb 2022 16:39:33 +0000 Subject: [PATCH 3/4] Add test: verbose extract to stdout with files --- test/data/pr_2068_poc1.jpg | Bin 0 -> 4745 bytes tests/bugfixes/github/test_pr_2068.py | 16 ++++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 test/data/pr_2068_poc1.jpg create mode 100644 tests/bugfixes/github/test_pr_2068.py diff --git a/test/data/pr_2068_poc1.jpg b/test/data/pr_2068_poc1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9394df8dd3c7379b76c7d20a5abcbd88c46ec08c GIT binary patch literal 4745 zcmb7DcR196|Noq`viII+kHaC#DA}iT&L#?H6xmT$BF?-s@5q*UXGCR{m9rB?Ns-7X z7m>Yv`~IHi_xu0%djI!Y@8@|x&-;A(d>&wf8=DyeAP@*J{Wrk*3}67zQq$1VP}9=V z(9+S-(lf9zFkHC6z{SGK#Kz0T$H&X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3usX9x&kU6 z&BVj=%-P*OBQ~}N0(w5wdW4MjZqWwwl>{COiPxbe!)0-%I7e=E{%CngQ*OWap?V(k ztd*~173`Hr3>@K>4c*KadGuWL9=MJG!J!+zP6u|2!xdSzgg!lI7vDKdFVC>Z1IxRG3CdQv+apUGPEJK#Z*b^g3R?)Z)c2*10J`*Rz{zt|@Ex zQG0y;^|v?J!wlcw{{2ov3&<4Tn;ALP%aaZ6c&)wE;ARFCY=@}FM&c4XkKA06FN3s0 zfCJZMuJqr->mt=u*jKSwyR&7*!MLqo^6FBYz~yf2b{xGc Date: Fri, 4 Feb 2022 17:15:59 +0000 Subject: [PATCH 4/4] Update test to use existing image --- test/data/pr_2068_poc1.jpg | Bin 4745 -> 0 bytes tests/bugfixes/github/test_pr_2068.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 test/data/pr_2068_poc1.jpg diff --git a/test/data/pr_2068_poc1.jpg b/test/data/pr_2068_poc1.jpg deleted file mode 100644 index 9394df8dd3c7379b76c7d20a5abcbd88c46ec08c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4745 zcmb7DcR196|Noq`viII+kHaC#DA}iT&L#?H6xmT$BF?-s@5q*UXGCR{m9rB?Ns-7X z7m>Yv`~IHi_xu0%djI!Y@8@|x&-;A(d>&wf8=DyeAP@*J{Wrk*3}67zQq$1VP}9=V z(9+S-(lf9zFkHC6z{SGK#Kz0T$H&XX!y_OpB`P2Y5#r$yQxt{D9Nfw z$;!$8w**8-N5??Vz{$YCDJ#GuAp8Huc@Mx&58MC&{bvLI@nC9pfQCbymQz(9FffQkx4^Uv{*`yYU)0Cq4n zhq$V~1Sb~^MdKE9{uN;Qx0H$<%nn=u#?fxy161Q|ki!W}2Aw^0R3MR!FnV%~r2xzF zYxIcCPhyFwrCr*%OnI$|d$wWy=dzY_;KsbsJrwU{8}&poA2AbX3adhkH%5hgF(V%#1s7DVLd`D=&Aph-T%Yf3kGb z2b=mPR^q&6gZ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