summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-10-24 12:42:48 (GMT)
committerBrad King <brad.king@kitware.com>2018-10-24 14:51:11 (GMT)
commit95c8a03f00f7e29e1d50b9db8885f487fbd0845d (patch)
tree1250176059f881363287a2b3f129bb20485a9843
parent3e5548784da085ee3a5ce3f7213c0cf281b68f31 (diff)
downloadCMake-95c8a03f00f7e29e1d50b9db8885f487fbd0845d.zip
CMake-95c8a03f00f7e29e1d50b9db8885f487fbd0845d.tar.gz
CMake-95c8a03f00f7e29e1d50b9db8885f487fbd0845d.tar.bz2
cmake: Distinguish '-E tar' warnings from errors copying data
The logic added by commit v3.12.0-rc1~62^2 (cmake: Teach '-E tar' to report errors copying data, 2018-05-16) incorrectly reports failure in the case of ARCHIVE_WARN. Convert this case to a warning. Fixes: #18496
-rw-r--r--Source/cmSystemTools.cxx44
1 files changed, 31 insertions, 13 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 72fd2bb..75c8caf 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1703,6 +1703,32 @@ void list_item_verbose(FILE* out, struct archive_entry* entry)
fflush(out);
}
+bool la_diagnostic(struct archive* ar, __LA_SSIZE_T r)
+{
+ // See archive.h definition of ARCHIVE_OK for return values.
+
+ if (r >= ARCHIVE_OK) {
+ return true;
+ }
+
+ if (r >= ARCHIVE_WARN) {
+ const char* warn = archive_error_string(ar);
+ if (!warn) {
+ warn = "unknown warning";
+ }
+ std::cerr << "cmake -E tar: warning: " << warn << '\n';
+ return true;
+ }
+
+ // Error.
+ const char* err = archive_error_string(ar);
+ if (!err) {
+ err = "unknown error";
+ }
+ std::cerr << "cmake -E tar: error: " << err << '\n';
+ return false;
+}
+
// Return 'true' on success
bool copy_data(struct archive* ar, struct archive* aw)
{
@@ -1716,24 +1742,17 @@ bool copy_data(struct archive* ar, struct archive* aw)
# endif
for (;;) {
- // Return value:
- // * ARCHIVE_OK - read succeed
- // * ARCHIVE_EOF - no more data to read left
+ // See archive.h definition of ARCHIVE_OK for return values.
r = archive_read_data_block(ar, &buff, &size, &offset);
if (r == ARCHIVE_EOF) {
return true;
}
- if (r != ARCHIVE_OK) {
+ if (!la_diagnostic(ar, r)) {
return false;
}
- // Return value:
- // * >= ARCHIVE_OK - write succeed
- // * < ARCHIVE_OK - write failed
- const __LA_SSIZE_T w_size =
- archive_write_data_block(aw, buff, size, offset);
- if (w_size < ARCHIVE_OK) {
- cmSystemTools::Message("archive_write_data_block()",
- archive_error_string(aw));
+ // See archive.h definition of ARCHIVE_OK for return values.
+ __LA_SSIZE_T const w = archive_write_data_block(aw, buff, size, offset);
+ if (!la_diagnostic(ar, w)) {
return false;
}
}
@@ -1792,7 +1811,6 @@ bool extract_tar(const char* outFileName, bool verbose, bool extract)
r = archive_write_header(ext, entry);
if (r == ARCHIVE_OK) {
if (!copy_data(a, ext)) {
- cmSystemTools::Error("Problem with copy_data");
break;
}
r = archive_write_finish_entry(ext);