aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2018-08-13 03:57:52 +0200
committerJay Berkenbilt <ejb@ql.org>2018-08-13 03:57:52 +0200
commita2f62935b35aebe68a5a2f7e729ae4bb8734cfc7 (patch)
tree9bcb9a5e4c8b116ffa81e3b942a0ee472ab6b3c6
parent3d6615b2764da759c5b9354c40cd1a32b84ee039 (diff)
downloadqpdf-a2f62935b35aebe68a5a2f7e729ae4bb8734cfc7.tar.zst
Catch exceptions as const references (fixes #236)
This fix allows qpdf to compile/test cleanly with gcc 8.
-rw-r--r--examples/pdf-split-pages.cc2
-rw-r--r--libqpdf/MD5.cc2
-rw-r--r--libtests/qutil.cc4
-rw-r--r--qpdf/qpdf.cc4
-rw-r--r--qpdf/test_driver.cc16
5 files changed, 14 insertions, 14 deletions
diff --git a/examples/pdf-split-pages.cc b/examples/pdf-split-pages.cc
index b65f96ee..aa089e5a 100644
--- a/examples/pdf-split-pages.cc
+++ b/examples/pdf-split-pages.cc
@@ -77,7 +77,7 @@ int main(int argc, char* argv[])
{
process(whoami, argv[1], argv[2]);
}
- catch (std::exception e)
+ catch (std::exception const& e)
{
std::cerr << whoami << ": exception: " << e.what() << std::endl;
return 2;
diff --git a/libqpdf/MD5.cc b/libqpdf/MD5.cc
index 0504e2d4..275567da 100644
--- a/libqpdf/MD5.cc
+++ b/libqpdf/MD5.cc
@@ -421,7 +421,7 @@ MD5::checkFileChecksum(char const* const checksum,
std::string actual_checksum = getFileChecksum(filename, up_to_size);
result = (checksum == actual_checksum);
}
- catch (std::runtime_error)
+ catch (std::runtime_error const&)
{
// Ignore -- return false
}
diff --git a/libtests/qutil.cc b/libtests/qutil.cc
index a7479fb5..78c52156 100644
--- a/libtests/qutil.cc
+++ b/libtests/qutil.cc
@@ -26,7 +26,7 @@ void test_to_number(char const* str, int_T wanted, bool error,
result = fn(str);
worked = (wanted == result);
}
- catch (std::runtime_error)
+ catch (std::runtime_error const&)
{
threw = true;
}
@@ -247,7 +247,7 @@ void same_file_test()
fclose(QUtil::safe_fopen("qutil.out", "r"));
fclose(QUtil::safe_fopen("other-file", "r"));
}
- catch (std::exception)
+ catch (std::exception const&)
{
std::cout << "same_file_test expects to have qutil.out and other-file"
" exist in the current directory\n";
diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc
index 9655049f..158bb993 100644
--- a/qpdf/qpdf.cc
+++ b/qpdf/qpdf.cc
@@ -773,7 +773,7 @@ static std::vector<int> parse_numrange(char const* range, int max,
}
}
}
- catch (std::runtime_error e)
+ catch (std::runtime_error const& e)
{
if (throw_error)
{
@@ -1372,7 +1372,7 @@ static void parse_rotation_parameter(Options& o, std::string const& parameter)
parse_numrange(range.c_str(), 0, true);
range_valid = true;
}
- catch (std::runtime_error)
+ catch (std::runtime_error const&)
{
// ignore
}
diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc
index c167b643..14a317ba 100644
--- a/qpdf/test_driver.cc
+++ b/qpdf/test_driver.cc
@@ -717,7 +717,7 @@ void runtest(int n, char const* filename1, char const* arg2)
// Do it wrong first...
pdf.replaceObject(qdict.getObjGen(), qdict);
}
- catch (std::logic_error)
+ catch (std::logic_error const&)
{
std::cout << "caught logic error as expected" << std::endl;
}
@@ -1003,7 +1003,7 @@ void runtest(int n, char const* filename1, char const* arg2)
res2.unparseResolved();
std::cout << "oops -- didn't throw" << std::endl;
}
- catch (std::logic_error e)
+ catch (std::logic_error const& e)
{
std::cout << "logic error: " << e.what() << std::endl;
}
@@ -1012,7 +1012,7 @@ void runtest(int n, char const* filename1, char const* arg2)
res2.makeDirect();
std::cout << "oops -- didn't throw" << std::endl;
}
- catch (std::logic_error e)
+ catch (std::logic_error const& e)
{
std::cout << "logic error: " << e.what() << std::endl;
}
@@ -1109,7 +1109,7 @@ void runtest(int n, char const* filename1, char const* arg2)
pdf.copyForeignObject(pdf.getTrailer().getKey("/QTest"));
std::cout << "oops -- didn't throw" << std::endl;
}
- catch (std::logic_error e)
+ catch (std::logic_error const& e)
{
std::cout << "logic error: " << e.what() << std::endl;
}
@@ -1118,7 +1118,7 @@ void runtest(int n, char const* filename1, char const* arg2)
pdf.copyForeignObject(QPDFObjectHandle::newInteger(1));
std::cout << "oops -- didn't throw" << std::endl;
}
- catch (std::logic_error e)
+ catch (std::logic_error const& e)
{
std::cout << "logic error: " << e.what() << std::endl;
}
@@ -1139,7 +1139,7 @@ void runtest(int n, char const* filename1, char const* arg2)
w.write();
std::cout << "oops -- didn't throw" << std::endl;
}
- catch (std::logic_error e)
+ catch (std::logic_error const& e)
{
std::cout << "logic error: " << e.what() << std::endl;
}
@@ -1185,7 +1185,7 @@ void runtest(int n, char const* filename1, char const* arg2)
QPDFObjectHandle::parse("[1 0 R]", "indirect test");
std::cout << "oops -- didn't throw" << std::endl;
}
- catch (std::logic_error e)
+ catch (std::logic_error const& e)
{
std::cout << "logic error parsing indirect: " << e.what()
<< std::endl;
@@ -1195,7 +1195,7 @@ void runtest(int n, char const* filename1, char const* arg2)
QPDFObjectHandle::parse("0 trailing", "trailing test");
std::cout << "oops -- didn't throw" << std::endl;
}
- catch (std::runtime_error e)
+ catch (std::runtime_error const& e)
{
std::cout << "trailing data: " << e.what()
<< std::endl;