aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--TODO5
-rw-r--r--include/qpdf/Pipeline.hh18
-rw-r--r--include/qpdf/Pl_Flate.hh15
-rw-r--r--include/qpdf/Pl_StdioFile.hh15
-rw-r--r--include/qpdf/QEXC.hh135
-rw-r--r--include/qpdf/QPDFExc.hh5
-rw-r--r--include/qpdf/QUtil.hh26
-rw-r--r--libqpdf/BitStream.cc3
-rw-r--r--libqpdf/BitWriter.cc2
-rw-r--r--libqpdf/Buffer.cc1
-rw-r--r--libqpdf/MD5.cc15
-rw-r--r--libqpdf/PCRE.cc48
-rw-r--r--libqpdf/Pipeline.cc5
-rw-r--r--libqpdf/Pl_ASCII85Decoder.cc10
-rw-r--r--libqpdf/Pl_ASCIIHexDecoder.cc7
-rw-r--r--libqpdf/Pl_Buffer.cc5
-rw-r--r--libqpdf/Pl_Count.cc1
-rw-r--r--libqpdf/Pl_Discard.cc1
-rw-r--r--libqpdf/Pl_Flate.cc5
-rw-r--r--libqpdf/Pl_LZWDecoder.cc6
-rw-r--r--libqpdf/Pl_MD5.cc7
-rw-r--r--libqpdf/Pl_PNGFilter.cc8
-rw-r--r--libqpdf/Pl_QPDFTokenizer.cc7
-rw-r--r--libqpdf/Pl_RC4.cc4
-rw-r--r--libqpdf/Pl_StdioFile.cc13
-rw-r--r--libqpdf/QEXC.cc77
-rw-r--r--libqpdf/QPDF.cc24
-rw-r--r--libqpdf/QPDFExc.cc8
-rw-r--r--libqpdf/QPDFObject.cc1
-rw-r--r--libqpdf/QPDFObjectHandle.cc38
-rw-r--r--libqpdf/QPDFTokenizer.cc16
-rw-r--r--libqpdf/QPDFWriter.cc11
-rw-r--r--libqpdf/QPDFXRefEntry.cc1
-rw-r--r--libqpdf/QPDF_Array.cc7
-rw-r--r--libqpdf/QPDF_Bool.cc1
-rw-r--r--libqpdf/QPDF_Dictionary.cc1
-rw-r--r--libqpdf/QPDF_Integer.cc1
-rw-r--r--libqpdf/QPDF_Name.cc1
-rw-r--r--libqpdf/QPDF_Null.cc1
-rw-r--r--libqpdf/QPDF_Real.cc1
-rw-r--r--libqpdf/QPDF_Stream.cc14
-rw-r--r--libqpdf/QPDF_String.cc1
-rw-r--r--libqpdf/QPDF_encryption.cc3
-rw-r--r--libqpdf/QPDF_linearization.cc37
-rw-r--r--libqpdf/QPDF_optimization.cc8
-rw-r--r--libqpdf/QTC.cc1
-rw-r--r--libqpdf/QUtil.cc33
-rw-r--r--libqpdf/RC4.cc1
-rw-r--r--libqpdf/bits.icc8
-rw-r--r--libqpdf/build.mk3
-rw-r--r--libqpdf/qpdf/MD5.hh5
-rw-r--r--libqpdf/qpdf/PCRE.hh27
-rw-r--r--libqpdf/qpdf/Pl_ASCII85Decoder.hh1
-rw-r--r--libqpdf/qpdf/Pl_ASCIIHexDecoder.hh1
-rw-r--r--libqpdf/qpdf/Pl_LZWDecoder.hh1
-rw-r--r--libqpdf/qpdf/Pl_MD5.hh1
-rw-r--r--libqpdf/qpdf/Pl_PNGFilter.hh15
-rw-r--r--libqpdf/qpdf/Pl_QPDFTokenizer.hh1
-rw-r--r--libqpdf/qpdf/Pl_RC4.hh16
-rw-r--r--libqpdf/qpdf/QPDF_Array.hh1
-rw-r--r--libqpdf/qpdf/QPDF_Bool.hh1
-rw-r--r--libqpdf/qpdf/QPDF_Dictionary.hh1
-rw-r--r--libqpdf/qpdf/QPDF_Integer.hh1
-rw-r--r--libqpdf/qpdf/QPDF_Name.hh1
-rw-r--r--libqpdf/qpdf/QPDF_Null.hh1
-rw-r--r--libqpdf/qpdf/QPDF_Real.hh1
-rw-r--r--libqpdf/qpdf/QPDF_Stream.hh1
-rw-r--r--libqpdf/qpdf/QPDF_String.hh1
-rw-r--r--libqpdf/qpdf/RC4.hh1
-rw-r--r--libtests/bits.cc1
-rw-r--r--libtests/buffer.cc1
-rw-r--r--libtests/build.mk1
-rw-r--r--libtests/flate.cc4
-rw-r--r--libtests/md5.cc1
-rw-r--r--libtests/pcre.cc3
-rw-r--r--libtests/png_filter.cc5
-rw-r--r--libtests/pointer_holder.cc1
-rw-r--r--libtests/qexc.cc53
-rw-r--r--libtests/qtest/buffer/buffer.out2
-rw-r--r--libtests/qtest/qexc.test28
-rw-r--r--libtests/qtest/qexc/test0.out2
-rw-r--r--libtests/qtest/qexc/test1.out1
-rw-r--r--libtests/qtest/qexc/test2.out2
-rw-r--r--libtests/qtest/qutil/qutil.out10
-rw-r--r--libtests/qutil.cc31
-rw-r--r--libtests/rc4.cc1
-rw-r--r--qpdf/qpdf.cc3
-rw-r--r--qpdf/test_driver.cc4
89 files changed, 251 insertions, 651 deletions
diff --git a/ChangeLog b/ChangeLog
index 8930e06b..23354fb6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-09-26 Jay Berkenbilt <ejb@ql.org>
+
+ * Removed all references to QEXC; now using std::runtime_error and
+ std::logic_error and their subclasses for all exceptions.
+
2009-05-03 Jay Berkenbilt <ejb@ql.org>
* 2.0.6. release
diff --git a/TODO b/TODO
index 314836d7..8a56811e 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,11 @@
2.1
===
+ * Be able to trap I/O errors separately from other errors; especially
+ be able to separate errors that the user can fix (like permission
+ errors) from errors that they probably can't fix like corrupted PDF
+ files, unsupported filters, or internal errors.
+
* Add ability to create new streams or replace stream data. Consider
stream data sources to include a file and offset, a buffer, or a
some kind of callback mechanism. Find messages exchanged with
diff --git a/include/qpdf/Pipeline.hh b/include/qpdf/Pipeline.hh
index 358bcb03..8bdbfcac 100644
--- a/include/qpdf/Pipeline.hh
+++ b/include/qpdf/Pipeline.hh
@@ -31,27 +31,11 @@
#define __PIPELINE_HH__
#include <qpdf/DLL.hh>
-
-#include <qpdf/QEXC.hh>
+#include <string>
class Pipeline
{
public:
- class Exception: public QEXC::General
- {
- public:
- DLL_EXPORT
- Exception(std::string const& message) :
- QEXC::General(message)
- {
- }
-
- DLL_EXPORT
- virtual ~Exception() throw()
- {
- }
- };
-
DLL_EXPORT
Pipeline(char const* identifier, Pipeline* next);
diff --git a/include/qpdf/Pl_Flate.hh b/include/qpdf/Pl_Flate.hh
index 60b3fd8a..286d80e8 100644
--- a/include/qpdf/Pl_Flate.hh
+++ b/include/qpdf/Pl_Flate.hh
@@ -15,21 +15,6 @@
class Pl_Flate: public Pipeline
{
public:
- class Exception: public Pipeline::Exception
- {
- public:
- DLL_EXPORT
- Exception(std::string const& message) :
- Pipeline::Exception(message)
- {
- }
-
- DLL_EXPORT
- virtual ~Exception() throw ()
- {
- }
- };
-
static int const def_bufsize = 65536;
enum action_e { a_inflate, a_deflate };
diff --git a/include/qpdf/Pl_StdioFile.hh b/include/qpdf/Pl_StdioFile.hh
index 84324d54..3bb9f257 100644
--- a/include/qpdf/Pl_StdioFile.hh
+++ b/include/qpdf/Pl_StdioFile.hh
@@ -21,21 +21,6 @@
class Pl_StdioFile: public Pipeline
{
public:
- class Exception: public Pipeline::Exception
- {
- public:
- DLL_EXPORT
- Exception(std::string const& message) :
- Pipeline::Exception(message)
- {
- }
-
- DLL_EXPORT
- virtual ~Exception() throw ()
- {
- }
- };
-
// f is externally maintained; this class just writes to and
// flushes it. It does not close it.
DLL_EXPORT
diff --git a/include/qpdf/QEXC.hh b/include/qpdf/QEXC.hh
deleted file mode 100644
index 49be72a8..00000000
--- a/include/qpdf/QEXC.hh
+++ /dev/null
@@ -1,135 +0,0 @@
-// Copyright (c) 2005-2009 Jay Berkenbilt
-//
-// This file is part of qpdf. This software may be distributed under
-// the terms of version 2 of the Artistic License which may be found
-// in the source distribution. It is provided "as is" without express
-// or implied warranty.
-
-#ifndef __QEXC_HH__
-#define __QEXC_HH__
-
-#include <qpdf/DLL.hh>
-
-#include <string>
-#include <exception>
-#include <errno.h>
-
-namespace QEXC
-{
- // This namespace contains all exception classes used by the
- // library.
-
- // The class hierarchy is as follows:
-
- // std::exception
- // |
- // +-> QEXC::Base
- // |
- // +-> QEXC::General
- // |
- // +-> QEXC::Internal
-
- // QEXC::General is the base class of all standard user-defined
- // exceptions and "expected" error conditions raised by QClass.
- // Applications or libraries using QClass are encouraged to derive
- // their own exceptions from these classes if they wish. It is
- // entirely reasonable for code to catch QEXC::General or specific
- // subclasses of it as part of normal error handling.
-
- // QEXC::Internal is reserved for internal errors. These should
- // be used only for situations that indicate a likely bug in the
- // software itself. This may include improper use of a library
- // function. Operator errors should not be able to cause Internal
- // errors. (There may be some exceptions to this such as users
- // invoking programs that were intended only to be invoked by
- // other programs.) QEXC::Internal should generally not be
- // trapped except in terminate handlers or top-level exception
- // handlers which will want to translate them into error messages
- // and cause the program to exit. Such top-level handlers may
- // want to catch std::exception instead.
-
- // All subclasses of QEXC::Base implement a const unparse() method
- // which returns a std::string const&. They also override
- // std::exception::what() to return a char* with the same value.
- // unparse() should be implemented in such a way that a program
- // catching QEXC::Base or std::exception can use the text returned
- // by unparse() (or what()) without any exception-specific
- // adornment. (The program may prefix the program name or other
- // general information.) Note that std::exception::what() is a
- // const method that returns a const char*. For this reason, it
- // is essential that unparse() return a const reference to a
- // string so that what() can be implemented by calling unparse().
- // This means that the string that unparse() returns a reference
- // to must not be allocated on the stack in the call to unparse().
- // The recommended way to do this is for derived exception classes
- // to store their string descriptions by calling the protected
- // setMessage() method and then to not override unparse().
-
- class Base: public std::exception
- {
- // This is the common base class for all exceptions in qclass.
- // Application/library code should not generally catch this
- // directly. See above for caveats.
- public:
- DLL_EXPORT
- Base();
- DLL_EXPORT
- Base(std::string const& message);
- DLL_EXPORT
- virtual ~Base() throw() {}
- DLL_EXPORT
- virtual std::string const& unparse() const;
- DLL_EXPORT
- virtual const char* what() const throw();
-
- protected:
- DLL_EXPORT
- void setMessage(std::string const& message);
-
- private:
- std::string message;
- };
-
- class General: public Base
- {
- // This is the base class for normal user/library-defined
- // error conditions.
- public:
- DLL_EXPORT
- General();
- DLL_EXPORT
- General(std::string const& message);
- DLL_EXPORT
- virtual ~General() throw() {};
- };
-
- // Note that Internal is not derived from General. Internal
- // errors are too severe. We don't want internal errors
- // accidentally trapped as part of QEXC::General. If you are
- // going to deal with internal errors, you have to do so
- // explicitly.
- class Internal: public Base
- {
- public:
- DLL_EXPORT
- Internal(std::string const& message);
- DLL_EXPORT
- virtual ~Internal() throw() {};
- };
-
- class System: public General
- {
- public:
- DLL_EXPORT
- System(std::string const& prefix, int sys_errno);
- DLL_EXPORT
- virtual ~System() throw() {};
- DLL_EXPORT
- int getErrno() const;
-
- private:
- int sys_errno;
- };
-};
-
-#endif // __QEXC_HH__
diff --git a/include/qpdf/QPDFExc.hh b/include/qpdf/QPDFExc.hh
index 81e62cfd..ebfa870b 100644
--- a/include/qpdf/QPDFExc.hh
+++ b/include/qpdf/QPDFExc.hh
@@ -8,9 +8,10 @@
#ifndef __QPDFEXC_HH__
#define __QPDFEXC_HH__
-#include <qpdf/QEXC.hh>
+#include <qpdf/DLL.hh>
+#include <stdexcept>
-class QPDFExc: public QEXC::General
+class QPDFExc: public std::runtime_error
{
public:
DLL_EXPORT
diff --git a/include/qpdf/QUtil.hh b/include/qpdf/QUtil.hh
index 1d2b2b1b..bfd59b61 100644
--- a/include/qpdf/QUtil.hh
+++ b/include/qpdf/QUtil.hh
@@ -8,13 +8,13 @@
#ifndef __QUTIL_HH__
#define __QUTIL_HH__
+#include <qpdf/DLL.hh>
#include <string>
#include <list>
+#include <stdexcept>
#include <stdio.h>
#include <sys/stat.h>
-#include <qpdf/QEXC.hh>
-
namespace QUtil
{
// This is a collection of useful utility functions that don't
@@ -24,15 +24,25 @@ namespace QUtil
DLL_EXPORT
std::string double_to_string(double, int decimal_places = 0);
- // If status is -1, convert the current value of errno to a
- // QEXC::System exception. Otherwise, return status.
+ // Throw std::runtime_error with a string formed by appending to
+ // "description: " the standard string corresponding to the
+ // current value of errno.
+ DLL_EXPORT
+ void throw_system_error(std::string const& description);
+
+ // The status argument is assumed to be the return value of a
+ // standard library call that sets errno when it fails. If status
+ // is -1, convert the current value of errno to a
+ // std::runtime_error that includes the standard error string.
+ // Otherwise, return status.
DLL_EXPORT
- int os_wrapper(std::string const& description, int status)
- throw (QEXC::System);
+ int os_wrapper(std::string const& description, int status);
+ // The FILE* argument is assumed to be the return of fopen. If
+ // null, throw std::runtime_error. Otherwise, return the FILE*
+ // argument.
DLL_EXPORT
- FILE* fopen_wrapper(std::string const&, FILE*)
- throw (QEXC::System);
+ FILE* fopen_wrapper(std::string const&, FILE*);
DLL_EXPORT
char* copy_string(std::string const&);
diff --git a/libqpdf/BitStream.cc b/libqpdf/BitStream.cc
index c30f1f2d..72a50706 100644
--- a/libqpdf/BitStream.cc
+++ b/libqpdf/BitStream.cc
@@ -38,7 +38,8 @@ BitStream::skipToNextByte()
unsigned int bits_to_skip = bit_offset + 1;
if (bits_available < bits_to_skip)
{
- throw QEXC::Internal("overflow skipping to next byte in bitstream");
+ throw std::logic_error(
+ "INTERNAL ERROR: overflow skipping to next byte in bitstream");
}
bit_offset = 7;
++p;
diff --git a/libqpdf/BitWriter.cc b/libqpdf/BitWriter.cc
index b9b3caec..96a9b4ce 100644
--- a/libqpdf/BitWriter.cc
+++ b/libqpdf/BitWriter.cc
@@ -1,5 +1,3 @@
-
-
#include <qpdf/BitWriter.hh>
// See comments in bits.cc
diff --git a/libqpdf/Buffer.cc b/libqpdf/Buffer.cc
index dfed6010..2d1763bb 100644
--- a/libqpdf/Buffer.cc
+++ b/libqpdf/Buffer.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/Buffer.hh>
#include <string.h>
diff --git a/libqpdf/MD5.cc b/libqpdf/MD5.cc
index b05afa8b..8f6f7ecd 100644
--- a/libqpdf/MD5.cc
+++ b/libqpdf/MD5.cc
@@ -28,6 +28,7 @@
/////////////////////////////////////////////////////////////////////////
#include <qpdf/MD5.hh>
+#include <qpdf/QUtil.hh>
#include <stdio.h>
#include <memory.h>
@@ -330,15 +331,12 @@ void MD5::encodeDataIncrementally(char const* data, int len)
DLL_EXPORT
void MD5::encodeFile(char const *filename, int up_to_size)
- throw (QEXC::System)
{
- FILE *file;
unsigned char buffer[1024];
- if ((file = fopen (filename, "rb")) == NULL)
- {
- throw QEXC::System(std::string("MD5: can't open ") + filename, errno);
- }
+ FILE *file = QUtil::fopen_wrapper(
+ std::string("MD5: open ") + filename,
+ fopen(filename, "rb"));
int len;
int so_far = 0;
@@ -365,7 +363,8 @@ void MD5::encodeFile(char const *filename, int up_to_size)
// Assume, perhaps incorrectly, that errno was set by the
// underlying call to read....
(void) fclose(file);
- throw QEXC::System(std::string("MD5: read error on ") + filename, errno);
+ QUtil::throw_system_error(
+ std::string("MD5: read error on ") + filename);
}
(void) fclose(file);
@@ -446,7 +445,7 @@ MD5::checkFileChecksum(char const* const checksum,
std::string actual_checksum = getFileChecksum(filename, up_to_size);
result = (checksum == actual_checksum);
}
- catch (QEXC::System)
+ catch (std::runtime_error)
{
// Ignore -- return false
}
diff --git a/libqpdf/PCRE.cc b/libqpdf/PCRE.cc
index 3236e941..859c5c49 100644
--- a/libqpdf/PCRE.cc
+++ b/libqpdf/PCRE.cc
@@ -1,19 +1,13 @@
-
#include <qpdf/PCRE.hh>
#include <qpdf/QUtil.hh>
+#include <stdexcept>
#include <iostream>
#include <string.h>
DLL_EXPORT
-PCRE::Exception::Exception(std::string const& message)
-{
- this->setMessage("PCRE error: " + message);
-}
-
-DLL_EXPORT
PCRE::NoBackref::NoBackref() :
- Exception("no match")
+ std::logic_error("PCRE error: no match")
{
}
@@ -87,7 +81,6 @@ PCRE::Match::operator bool()
DLL_EXPORT
std::string
PCRE::Match::getMatch(int n, int flags)
- throw(QEXC::General, Exception)
{
// This method used to be implemented in terms of
// pcre_get_substring, but that function gives you an empty string
@@ -116,7 +109,7 @@ PCRE::Match::getMatch(int n, int flags)
DLL_EXPORT
void
-PCRE::Match::getOffsetLength(int n, int& offset, int& length) throw(Exception)
+PCRE::Match::getOffsetLength(int n, int& offset, int& length)
{
if ((this->nmatches < 0) ||
(n > this->nmatches - 1) ||
@@ -130,7 +123,7 @@ PCRE::Match::getOffsetLength(int n, int& offset, int& length) throw(Exception)
DLL_EXPORT
int
-PCRE::Match::getOffset(int n) throw(Exception)
+PCRE::Match::getOffset(int n)
{
int offset;
int length;
@@ -140,7 +133,7 @@ PCRE::Match::getOffset(int n) throw(Exception)
DLL_EXPORT
int
-PCRE::Match::getLength(int n) throw(Exception)
+PCRE::Match::getLength(int n)
{
int offset;
int length;
@@ -156,7 +149,7 @@ PCRE::Match::nMatches() const
}
DLL_EXPORT
-PCRE::PCRE(char const* pattern, int options) throw (PCRE::Exception)
+PCRE::PCRE(char const* pattern, int options)
{
char const *errptr;
int erroffset;
@@ -171,7 +164,7 @@ PCRE::PCRE(char const* pattern, int options) throw (PCRE::Exception)
" failed at offset " +
QUtil::int_to_string(erroffset) + ": " +
errptr);
- throw Exception(message);
+ throw std::runtime_error("PCRE error: " + message);
}
}
@@ -184,7 +177,6 @@ PCRE::~PCRE()
DLL_EXPORT
PCRE::Match
PCRE::match(char const* subject, int options, int startoffset, int size)
- throw (QEXC::General, Exception)
{
if (size == -1)
{
@@ -210,12 +202,12 @@ PCRE::match(char const* subject, int options, int startoffset, int size)
case PCRE_ERROR_BADOPTION:
message = "bad option passed to PCRE::match()";
- throw Exception(message);
+ throw std::logic_error(message);
break;
case PCRE_ERROR_NOMEMORY:
message = "insufficient memory";
- throw Exception(message);
+ throw std::runtime_error(message);
break;
case PCRE_ERROR_NULL:
@@ -223,7 +215,7 @@ PCRE::match(char const* subject, int options, int startoffset, int size)
case PCRE_ERROR_UNKNOWN_NODE:
default:
message = "pcre_exec returned " + QUtil::int_to_string(status);
- throw QEXC::Internal(message);
+ throw std::logic_error(message);
}
}
@@ -258,9 +250,9 @@ PCRE::test(int n)
{
PCRE pcre1("a**");
}
- catch (Exception& e)
+ catch (std::exception& e)
{
- std::cout << e.unparse() << std::endl;
+ std::cout << e.what() << std::endl;
}
PCRE pcre2("^([^\\s:]*)\\s*:\\s*(.*?)\\s*$");
@@ -281,17 +273,17 @@ PCRE::test(int n)
{
std::cout << m2.getMatch(3) << std::endl;
}
- catch (Exception& e)
+ catch (std::exception& e)
{
- std::cout << e.unparse() << std::endl;
+ std::cout << e.what() << std::endl;
}
try
{
std::cout << m2.getOffset(3) << std::endl;
}
- catch (Exception& e)
+ catch (std::exception& e)
{
- std::cout << e.unparse() << std::endl;
+ std::cout << e.what() << std::endl;
}
}
PCRE pcre3("^(a+)(b+)?$");
@@ -312,9 +304,9 @@ PCRE::test(int n)
std::cout << "can't see this" << std::endl;
}
}
- catch (Exception& e)
+ catch (std::exception& e)
{
- std::cout << e.unparse() << std::endl;
+ std::cout << e.what() << std::endl;
}
// backref: 1 2 3 4 5
@@ -370,8 +362,8 @@ PCRE::test(int n)
}
}
}
- catch (QEXC::General& e)
+ catch (std::exception& e)
{
- std::cout << "unexpected exception: " << e.unparse() << std::endl;
+ std::cout << "unexpected exception: " << e.what() << std::endl;
}
}
diff --git a/libqpdf/Pipeline.cc b/libqpdf/Pipeline.cc
index d9f70b67..9f5dc0a9 100644
--- a/libqpdf/Pipeline.cc
+++ b/libqpdf/Pipeline.cc
@@ -1,6 +1,5 @@
-
-
#include <qpdf/Pipeline.hh>
+#include <stdexcept>
DLL_EXPORT
Pipeline::Pipeline(char const* identifier, Pipeline* next) :
@@ -19,7 +18,7 @@ Pipeline::getNext(bool allow_null)
{
if ((next == 0) && (! allow_null))
{
- throw Exception(
+ throw std::logic_error(
this->identifier +
": Pipeline::getNext() called on pipeline with no next");
}
diff --git a/libqpdf/Pl_ASCII85Decoder.cc b/libqpdf/Pl_ASCII85Decoder.cc
index 999ef0ae..d018e2de 100644
--- a/libqpdf/Pl_ASCII85Decoder.cc
+++ b/libqpdf/Pl_ASCII85Decoder.cc
@@ -1,6 +1,6 @@
#include <qpdf/Pl_ASCII85Decoder.hh>
-#include <qpdf/QEXC.hh>
#include <qpdf/QTC.hh>
+#include <stdexcept>
#include <string.h>
DLL_EXPORT
@@ -40,7 +40,7 @@ Pl_ASCII85Decoder::write(unsigned char* buf, int len)
}
else
{
- throw QEXC::General(
+ throw std::runtime_error(
"broken end-of-data sequence in base 85 data");
}
}
@@ -65,7 +65,7 @@ Pl_ASCII85Decoder::write(unsigned char* buf, int len)
case 'z':
if (pos != 0)
{
- throw QEXC::General(
+ throw std::runtime_error(
"unexpected z during base 85 decode");
}
else
@@ -78,8 +78,8 @@ Pl_ASCII85Decoder::write(unsigned char* buf, int len)
default:
if ((buf[i] < 33) || (buf[i] > 117))
{
- throw QEXC::General
- ("character out of range during base 85 decode");
+ throw std::runtime_error(
+ "character out of range during base 85 decode");
}
else
{
diff --git a/libqpdf/Pl_ASCIIHexDecoder.cc b/libqpdf/Pl_ASCIIHexDecoder.cc
index 728e3eb8..00439c17 100644
--- a/libqpdf/Pl_ASCIIHexDecoder.cc
+++ b/libqpdf/Pl_ASCIIHexDecoder.cc
@@ -1,6 +1,6 @@
#include <qpdf/Pl_ASCIIHexDecoder.hh>
-#include <qpdf/QEXC.hh>
#include <qpdf/QTC.hh>
+#include <stdexcept>
#include <string.h>
#include <ctype.h>
@@ -61,8 +61,9 @@ Pl_ASCIIHexDecoder::write(unsigned char* buf, int len)
char t[2];
t[0] = ch;
t[1] = 0;
- throw QEXC::General(
- std::string("character out of range during base Hex decode: ") + t);
+ throw std::runtime_error(
+ std::string("character out of range"
+ " during base Hex decode: ") + t);
}
break;
}
diff --git a/libqpdf/Pl_Buffer.cc b/libqpdf/Pl_Buffer.cc
index 25aff218..cdbad568 100644
--- a/libqpdf/Pl_Buffer.cc
+++ b/libqpdf/Pl_Buffer.cc
@@ -1,6 +1,5 @@
-
#include <qpdf/Pl_Buffer.hh>
-#include <qpdf/QEXC.hh>
+#include <stdexcept>
#include <assert.h>
#include <string.h>
@@ -50,7 +49,7 @@ Pl_Buffer::getBuffer()
{
if (! this->ready)
{
- throw QEXC::Internal("Pl_Buffer::getBuffer() called when not ready");
+ throw std::logic_error("Pl_Buffer::getBuffer() called when not ready");
}
Buffer* b = new Buffer(this->total_size);
diff --git a/libqpdf/Pl_Count.cc b/libqpdf/Pl_Count.cc
index 81ef7033..c9eb8597 100644
--- a/libqpdf/Pl_Count.cc
+++ b/libqpdf/Pl_Count.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/Pl_Count.hh>
DLL_EXPORT
diff --git a/libqpdf/Pl_Discard.cc b/libqpdf/Pl_Discard.cc
index 22c1a14e..7c7f457a 100644
--- a/libqpdf/Pl_Discard.cc
+++ b/libqpdf/Pl_Discard.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/Pl_Discard.hh>
// Exercised in md5 test suite
diff --git a/libqpdf/Pl_Flate.cc b/libqpdf/Pl_Flate.cc
index ff3331fc..ad902c65 100644
--- a/libqpdf/Pl_Flate.cc
+++ b/libqpdf/Pl_Flate.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/Pl_Flate.hh>
#include <qpdf/QUtil.hh>
@@ -38,7 +37,7 @@ Pl_Flate::write(unsigned char* data, int len)
{
if (this->outbuf == 0)
{
- throw Exception(
+ throw std::logic_error(
this->identifier +
": Pl_Flate: write() called after finish() called");
}
@@ -197,6 +196,6 @@ Pl_Flate::checkError(char const* prefix, int error_code)
}
}
- throw Exception(msg);
+ throw std::runtime_error(msg);
}
}
diff --git a/libqpdf/Pl_LZWDecoder.cc b/libqpdf/Pl_LZWDecoder.cc
index 050998d6..68f1ae3e 100644
--- a/libqpdf/Pl_LZWDecoder.cc
+++ b/libqpdf/Pl_LZWDecoder.cc
@@ -1,7 +1,7 @@
#include <qpdf/Pl_LZWDecoder.hh>
-#include <qpdf/QEXC.hh>
#include <qpdf/QTC.hh>
+#include <stdexcept>
#include <string.h>
#include <assert.h>
@@ -185,7 +185,7 @@ Pl_LZWDecoder::handleCode(int code)
unsigned int idx = code - 258;
if (idx > table_size)
{
- throw QEXC::General("LZWDecoder: bad code received");
+ throw std::runtime_error("LZWDecoder: bad code received");
}
else if (idx == table_size)
{
@@ -204,7 +204,7 @@ Pl_LZWDecoder::handleCode(int code)
unsigned int new_idx = 258 + table_size;
if (new_idx == 4096)
{
- throw QEXC::General("LZWDecoder: table full");
+ throw std::runtime_error("LZWDecoder: table full");
}
addToTable(next);
unsigned int change_idx = new_idx + code_change_delta;
diff --git a/libqpdf/Pl_MD5.cc b/libqpdf/Pl_MD5.cc
index f368b93b..1fe91bf5 100644
--- a/libqpdf/Pl_MD5.cc
+++ b/libqpdf/Pl_MD5.cc
@@ -1,7 +1,5 @@
-
#include <qpdf/Pl_MD5.hh>
-
-#include <qpdf/QEXC.hh>
+#include <stdexcept>
DLL_EXPORT
Pl_MD5::Pl_MD5(char const* identifier, Pipeline* next) :
@@ -42,7 +40,8 @@ Pl_MD5::getHexDigest()
{
if (this->in_progress)
{
- throw QEXC::General("digest requested for in-progress MD5 Pipeline");
+ throw std::logic_error(
+ "digest requested for in-progress MD5 Pipeline");
}
return this->md5.unparse();
}
diff --git a/libqpdf/Pl_PNGFilter.cc b/libqpdf/Pl_PNGFilter.cc
index 792b4a02..9e493793 100644
--- a/libqpdf/Pl_PNGFilter.cc
+++ b/libqpdf/Pl_PNGFilter.cc
@@ -1,5 +1,5 @@
-
#include <qpdf/Pl_PNGFilter.hh>
+#include <stdexcept>
#include <string.h>
DLL_EXPORT
@@ -85,7 +85,7 @@ Pl_PNGFilter::decodeRow()
break;
case 1: // sub
- throw Exception("sub filter not implemented");
+ throw std::logic_error("sub filter not implemented");
break;
case 2: // up
@@ -96,11 +96,11 @@ Pl_PNGFilter::decodeRow()
break;
case 3: // average
- throw Exception("average filter not implemented");
+ throw std::logic_error("average filter not implemented");
break;
case 4: // Paeth
- throw Exception("Paeth filter not implemented");
+ throw std::logic_error("Paeth filter not implemented");
break;
default:
diff --git a/libqpdf/Pl_QPDFTokenizer.cc b/libqpdf/Pl_QPDFTokenizer.cc
index 96328408..28ea4faa 100644
--- a/libqpdf/Pl_QPDFTokenizer.cc
+++ b/libqpdf/Pl_QPDFTokenizer.cc
@@ -1,7 +1,7 @@
-
#include <qpdf/Pl_QPDFTokenizer.hh>
#include <qpdf/QPDF_String.hh>
#include <qpdf/QPDF_Name.hh>
+#include <stdexcept>
#include <string.h>
Pl_QPDFTokenizer::Pl_QPDFTokenizer(char const* identifier, Pipeline* next) :
@@ -134,8 +134,9 @@ Pl_QPDFTokenizer::checkUnread()
processChar(this->char_to_unread);
if (this->unread_char)
{
- throw QEXC::Internal("unread_char still true after processing "
- "unread character");
+ throw std::logic_error(
+ "INTERNAL ERROR: unread_char still true after processing "
+ "unread character");
}
}
}
diff --git a/libqpdf/Pl_RC4.cc b/libqpdf/Pl_RC4.cc
index e176511f..1a5dc031 100644
--- a/libqpdf/Pl_RC4.cc
+++ b/libqpdf/Pl_RC4.cc
@@ -1,6 +1,4 @@
-
#include <qpdf/Pl_RC4.hh>
-
#include <qpdf/QUtil.hh>
DLL_EXPORT
@@ -30,7 +28,7 @@ Pl_RC4::write(unsigned char* data, int len)
{
if (this->outbuf == 0)
{
- throw Exception(
+ throw std::logic_error(
this->identifier +
": Pl_RC4: write() called after finish() called");
}
diff --git a/libqpdf/Pl_StdioFile.cc b/libqpdf/Pl_StdioFile.cc
index 37ae5333..9504c61b 100644
--- a/libqpdf/Pl_StdioFile.cc
+++ b/libqpdf/Pl_StdioFile.cc
@@ -1,6 +1,6 @@
-
#include <qpdf/Pl_StdioFile.hh>
-
+#include <qpdf/QUtil.hh>
+#include <stdexcept>
#include <errno.h>
DLL_EXPORT
@@ -25,8 +25,8 @@ Pl_StdioFile::write(unsigned char* buf, int len)
so_far = fwrite(buf, 1, len, this->file);
if (so_far == 0)
{
- throw QEXC::System(this->identifier + ": Pl_StdioFile::write",
- errno);
+ QUtil::throw_system_error(
+ this->identifier + ": Pl_StdioFile::write");
}
else
{
@@ -46,7 +46,8 @@ Pl_StdioFile::finish()
}
else
{
- throw QEXC::Internal(this->identifier +
- ": Pl_StdioFile::finish: stream already closed");
+ throw std::logic_error(
+ this->identifier +
+ ": Pl_StdioFile::finish: stream already closed");
}
}
diff --git a/libqpdf/QEXC.cc b/libqpdf/QEXC.cc
deleted file mode 100644
index d8154f33..00000000
--- a/libqpdf/QEXC.cc
+++ /dev/null
@@ -1,77 +0,0 @@
-
-#include <qpdf/QEXC.hh>
-#include <string.h>
-#include <errno.h>
-
-DLL_EXPORT
-QEXC::Base::Base()
-{
- // nothing needed
-}
-
-DLL_EXPORT
-QEXC::Base::Base(std::string const& message) :
- message(message)
-{
- // nothing needed
-}
-
-DLL_EXPORT
-std::string const&
-QEXC::Base::unparse() const
-{
- return this->message;
-}
-
-DLL_EXPORT
-void
-QEXC::Base::setMessage(std::string const& message)
-{
- this->message = message;
-}
-
-DLL_EXPORT
-const char*
-QEXC::Base::what() const throw()
-{
- // Since unparse() returns a const string reference, its
- // implementors must arrange to have it return a reference to a
- // string that is not going to disappear. It is therefore safe
- // for us to return it's c_str() pointer.
- return this->unparse().c_str();
-}
-
-DLL_EXPORT
-QEXC::General::General()
-{
- // nothing needed
-}
-
-DLL_EXPORT
-QEXC::General::General(std::string const& message) :
- Base(message)
-{
- // nothing needed
-}
-
-DLL_EXPORT
-QEXC::System::System(std::string const& prefix, int sys_errno)
-{
- // Note: using sys_errno in case errno is a macro.
- this->sys_errno = sys_errno;
- this->setMessage(prefix + ": " + strerror(sys_errno));
-}
-
-DLL_EXPORT
-int
-QEXC::System::getErrno() const
-{
- return this->sys_errno;
-}
-
-DLL_EXPORT
-QEXC::Internal::Internal(std::string const& message) :
- Base("INTERNAL ERROR: " + message)
-{
- // nothing needed
-}
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc
index ba71e629..d49ad5f1 100644
--- a/libqpdf/QPDF.cc
+++ b/libqpdf/QPDF.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/QPDF.hh>
#include <vector>
@@ -197,7 +196,8 @@ QPDF::BufferInputSource::seek(off_t offset, int whence)
break;
default:
- throw QEXC::Internal("invalid argument to BufferInputSource::seek");
+ throw std::logic_error(
+ "INTERNAL ERROR: invalid argument to BufferInputSource::seek");
break;
}
}
@@ -392,7 +392,7 @@ QPDF::parse()
void
QPDF::warn(QPDFExc const& e)
{
- this->warnings.push_back(e.unparse());
+ this->warnings.push_back(e.what());
if (! this->suppress_warnings)
{
std::cerr << "WARNING: " << this->warnings.back() << std::endl;
@@ -956,8 +956,8 @@ QPDF::showXRefTable()
break;
default:
- throw QEXC::Internal("unknown cross-reference table type while"
- " showing xref_table");
+ throw std::logic_error("unknown cross-reference table type while"
+ " showing xref_table");
break;
}
std::cout << std::endl;
@@ -988,7 +988,8 @@ QPDF::readObjectInternal(InputSource* input,
// Although dictionaries and arrays arbitrarily nest, these
// variables indicate what is at the top of the stack right
// now, so they can, by definition, never both be true.
- throw QEXC::Internal("readObjectInternal: in_dict && in_array");
+ throw std::logic_error(
+ "INTERNAL ERROR: readObjectInternal: in_dict && in_array");
}
QPDFObjectHandle object;
@@ -1121,9 +1122,10 @@ QPDF::readObjectInternal(InputSource* input,
}
else if (! object.isInitialized())
{
- throw QEXC::Internal(std::string("uninitialized object (token = ") +
- QUtil::int_to_string(token.getType()) +
- ", " + token.getValue() + ")");
+ throw std::logic_error(
+ "INTERNAL ERROR: uninitialized object (token = " +
+ QUtil::int_to_string(token.getType()) +
+ ", " + token.getValue() + ")");
}
else
{
@@ -1846,13 +1848,13 @@ QPDF::pipeStreamData(int objid, int generation,
pipeline->write((unsigned char*)buf, len);
}
}
- catch (QEXC::General& e)
+ catch (std::runtime_error& e)
{
QTC::TC("qpdf", "QPDF decoding error warning");
warn(QPDFExc(this->file.getName(), this->file.getLastOffset(),
"error decoding stream data for object " +
QUtil::int_to_string(objid) + " " +
- QUtil::int_to_string(generation) + ": " + e.unparse()));
+ QUtil::int_to_string(generation) + ": " + e.what()));
}
pipeline->finish();
}
diff --git a/libqpdf/QPDFExc.cc b/libqpdf/QPDFExc.cc
index bac52e03..ddd175ed 100644
--- a/libqpdf/QPDFExc.cc
+++ b/libqpdf/QPDFExc.cc
@@ -1,19 +1,17 @@
-
#include <qpdf/QPDFExc.hh>
-
#include <qpdf/QUtil.hh>
DLL_EXPORT
QPDFExc::QPDFExc(std::string const& message) :
- QEXC::General(message)
+ std::runtime_error(message)
{
}
DLL_EXPORT
QPDFExc::QPDFExc(std::string const& filename, int offset,
std::string const& message) :
- QEXC::General(filename + ": offset " + QUtil::int_to_string(offset) +
- ": " + message)
+ std::runtime_error(filename + ": offset " + QUtil::int_to_string(offset) +
+ ": " + message)
{
}
diff --git a/libqpdf/QPDFObject.cc b/libqpdf/QPDFObject.cc
index 6c4963e2..8df2b480 100644
--- a/libqpdf/QPDFObject.cc
+++ b/libqpdf/QPDFObject.cc
@@ -1,2 +1 @@
-
#include <qpdf/QPDFObject.hh>
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc
index f1c9db23..c5de7503 100644
--- a/libqpdf/QPDFObjectHandle.cc
+++ b/libqpdf/QPDFObjectHandle.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/QPDFObjectHandle.hh>
#include <qpdf/QPDF.hh>
@@ -13,9 +12,9 @@
#include <qpdf/QPDF_Stream.hh>
#include <qpdf/QTC.hh>
-#include <qpdf/QEXC.hh>
#include <qpdf/QUtil.hh>
+#include <stdexcept>
#include <stdlib.h>
DLL_EXPORT
@@ -114,7 +113,7 @@ QPDFObjectHandle::getNumericValue()
}
else
{
- throw QEXC::Internal("getNumericValue called for non-numeric object");
+ throw std::logic_error("getNumericValue called for non-numeric object");
}
return result;
}
@@ -416,9 +415,10 @@ QPDFObjectHandle::getPageContents()
}
else
{
- throw QEXC::General("unknown item type while inspecting "
- "element of /Contents array in page "
- "dictionary");
+ throw std::runtime_error(
+ "unknown item type while inspecting "
+ "element of /Contents array in page "
+ "dictionary");
}
}
}
@@ -428,8 +428,8 @@ QPDFObjectHandle::getPageContents()
}
else
{
- throw QEXC::General("unknown object type inspecting /Contents "
- "key in page dictionary");
+ throw std::runtime_error("unknown object type inspecting /Contents "
+ "key in page dictionary");
}
return result;
@@ -542,7 +542,8 @@ QPDFObjectHandle::makeDirectInternal(std::set<int>& visited)
if (isStream())
{
QTC::TC("qpdf", "QPDFObjectHandle ERR clone stream");
- throw QEXC::General("attempt to make a stream into a direct object");
+ throw std::runtime_error(
+ "attempt to make a stream into a direct object");
}
int cur_objid = this->objid;
@@ -551,8 +552,9 @@ QPDFObjectHandle::makeDirectInternal(std::set<int>& visited)
if (visited.count(cur_objid))
{
QTC::TC("qpdf", "QPDFObjectHandle makeDirect loop");
- throw QEXC::General("loop detected while converting object from "
- "indirect to direct");
+ throw std::runtime_error(
+ "loop detected while converting object from "
+ "indirect to direct");
}
visited.insert(cur_objid);
}
@@ -620,8 +622,8 @@ QPDFObjectHandle::makeDirectInternal(std::set<int>& visited)
}
else
{
- throw QEXC::Internal("QPDFObjectHandle::makeIndirect: "
- "unknown object type");
+ throw std::logic_error("QPDFObjectHandle::makeIndirect: "
+ "unknown object type");
}
this->obj = new_obj;
@@ -644,8 +646,8 @@ QPDFObjectHandle::assertInitialized() const
{
if (! this->initialized)
{
- throw QEXC::Internal("operation attempted on uninitialized "
- "QPDFObjectHandle");
+ throw std::logic_error("operation attempted on uninitialized "
+ "QPDFObjectHandle");
}
}
@@ -654,8 +656,8 @@ QPDFObjectHandle::assertType(char const* type_name, bool istype)
{
if (! istype)
{
- throw QEXC::Internal(std::string("operation for ") + type_name +
- " object attempted on object of wrong type");
+ throw std::logic_error(std::string("operation for ") + type_name +
+ " object attempted on object of wrong type");
}
}
@@ -665,7 +667,7 @@ QPDFObjectHandle::assertPageObject()
if (! (this->isDictionary() && this->hasKey("/Type") &&
(this->getKey("/Type").getName() == "/Page")))
{
- throw QEXC::Internal("page operation called on non-Page object");
+ throw std::logic_error("page operation called on non-Page object");
}
}
diff --git a/libqpdf/QPDFTokenizer.cc b/libqpdf/QPDFTokenizer.cc
index 4b6e7848..4d9b375a 100644
--- a/libqpdf/QPDFTokenizer.cc
+++ b/libqpdf/QPDFTokenizer.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/QPDFTokenizer.hh>
// DO NOT USE ctype -- it is locale dependent for some things, and
@@ -6,9 +5,9 @@
// be used.
#include <qpdf/PCRE.hh>
-#include <qpdf/QEXC.hh>
#include <qpdf/QTC.hh>
+#include <stdexcept>
#include <string.h>
// See note above about ctype.
@@ -55,8 +54,9 @@ QPDFTokenizer::presentCharacter(char ch)
if (state == st_token_ready)
{
- throw QEXC::Internal("QPDF tokenizer presented character "
- "while token is waiting");
+ throw std::logic_error(
+ "INTERNAL ERROR: QPDF tokenizer presented character "
+ "while token is waiting");
}
char orig_ch = ch;
@@ -237,8 +237,9 @@ QPDFTokenizer::presentCharacter(char ch)
// last_char_was_bs is set/cleared below as appropriate
if (bs_num_count)
{
- throw QEXC::Internal("QPDFTokenizer: bs_num_count != 0 "
- "when ch == '\\'");
+ throw std::logic_error(
+ "INTERNAL ERROR: QPDFTokenizer: bs_num_count != 0 "
+ "when ch == '\\'");
}
}
else if (ch == '(')
@@ -333,7 +334,8 @@ QPDFTokenizer::presentCharacter(char ch)
}
else
{
- throw QEXC::Internal("invalid state while reading token");
+ throw std::logic_error(
+ "INTERNAL ERROR: invalid state while reading token");
}
if ((state == st_token_ready) && (type == tt_word))
diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc
index b4b4b6d2..88dc9e8f 100644
--- a/libqpdf/QPDFWriter.cc
+++ b/libqpdf/QPDFWriter.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/QPDFWriter.hh>
#include <assert.h>
@@ -479,8 +478,8 @@ QPDFWriter::enqueueObject(QPDFObjectHandle object)
}
else if (object.isScalar())
{
- throw QEXC::Internal(
- "QPDFWriter::enqueueObject: indirect scalar: " +
+ throw std::logic_error(
+ "INTERNAL ERROR: QPDFWriter::enqueueObject: indirect scalar: " +
std::string(this->filename) + " " +
QUtil::int_to_string(object.getObjectID()) + " " +
QUtil::int_to_string(object.getGeneration()));
@@ -559,8 +558,8 @@ QPDFWriter::unparseChild(QPDFObjectHandle child, int level, int flags)
{
if (child.isScalar())
{
- throw QEXC::Internal(
- "QPDFWriter::unparseChild: indirect scalar: " +
+ throw std::logic_error(
+ "INTERNAL ERROR: QPDFWriter::unparseChild: indirect scalar: " +
QUtil::int_to_string(child.getObjectID()) + " " +
QUtil::int_to_string(child.getGeneration()));
}
@@ -1599,7 +1598,7 @@ QPDFWriter::writeXRefStream(int xref_id, int max_id, int max_offset,
break;
default:
- throw QEXC::Internal("invalid type writing xref stream");
+ throw std::logic_error("invalid type writing xref stream");
break;
}
}
diff --git a/libqpdf/QPDFXRefEntry.cc b/libqpdf/QPDFXRefEntry.cc
index 68c58689..70c02579 100644
--- a/libqpdf/QPDFXRefEntry.cc
+++ b/libqpdf/QPDFXRefEntry.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/QPDFXRefEntry.hh>
#include <qpdf/QPDFExc.hh>
#include <qpdf/QUtil.hh>
diff --git a/libqpdf/QPDF_Array.cc b/libqpdf/QPDF_Array.cc
index d1edbfdd..b7227f0d 100644
--- a/libqpdf/QPDF_Array.cc
+++ b/libqpdf/QPDF_Array.cc
@@ -1,7 +1,5 @@
-
#include <qpdf/QPDF_Array.hh>
-
-#include <qpdf/QEXC.hh>
+#include <stdexcept>
QPDF_Array::QPDF_Array(std::vector<QPDFObjectHandle> const& items) :
items(items)
@@ -37,7 +35,8 @@ QPDF_Array::getItem(int n) const
{
if ((n < 0) || (n >= (int)this->items.size()))
{
- throw QEXC::Internal("bounds array accessing QPDF_Array element");
+ throw std::logic_error(
+ "INTERNAL ERROR: bounds array accessing QPDF_Array element");
}
return this->items[n];
}
diff --git a/libqpdf/QPDF_Bool.cc b/libqpdf/QPDF_Bool.cc
index 2b50c4c2..4bcbfc32 100644
--- a/libqpdf/QPDF_Bool.cc
+++ b/libqpdf/QPDF_Bool.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/QPDF_Bool.hh>
QPDF_Bool::QPDF_Bool(bool val) :
diff --git a/libqpdf/QPDF_Dictionary.cc b/libqpdf/QPDF_Dictionary.cc
index 654df688..36c4590d 100644
--- a/libqpdf/QPDF_Dictionary.cc
+++ b/libqpdf/QPDF_Dictionary.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/QPDF_Dictionary.hh>
#include <qpdf/QPDF_Null.hh>
diff --git a/libqpdf/QPDF_Integer.cc b/libqpdf/QPDF_Integer.cc
index 988519d0..da3b7dc9 100644
--- a/libqpdf/QPDF_Integer.cc
+++ b/libqpdf/QPDF_Integer.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/QPDF_Integer.hh>
#include <qpdf/QUtil.hh>
diff --git a/libqpdf/QPDF_Name.cc b/libqpdf/QPDF_Name.cc
index c640fe83..ce2184f8 100644
--- a/libqpdf/QPDF_Name.cc
+++ b/libqpdf/QPDF_Name.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/QPDF_Name.hh>
#include <string.h>
diff --git a/libqpdf/QPDF_Null.cc b/libqpdf/QPDF_Null.cc
index 57a78b7e..811ddd2e 100644
--- a/libqpdf/QPDF_Null.cc
+++ b/libqpdf/QPDF_Null.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/QPDF_Null.hh>
QPDF_Null::~QPDF_Null()
diff --git a/libqpdf/QPDF_Real.cc b/libqpdf/QPDF_Real.cc
index 87a19cb2..9236e92e 100644
--- a/libqpdf/QPDF_Real.cc
+++ b/libqpdf/QPDF_Real.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/QPDF_Real.hh>
QPDF_Real::QPDF_Real(std::string const& val) :
diff --git a/libqpdf/QPDF_Stream.cc b/libqpdf/QPDF_Stream.cc
index 5d12da32..a9e2ec51 100644
--- a/libqpdf/QPDF_Stream.cc
+++ b/libqpdf/QPDF_Stream.cc
@@ -1,7 +1,5 @@
-
#include <qpdf/QPDF_Stream.hh>
-#include <qpdf/QEXC.hh>
#include <qpdf/QUtil.hh>
#include <qpdf/Pipeline.hh>
#include <qpdf/Pl_Flate.hh>
@@ -17,6 +15,8 @@
#include <qpdf/QPDFExc.hh>
#include <qpdf/Pl_QPDFTokenizer.hh>
+#include <stdexcept>
+
QPDF_Stream::QPDF_Stream(QPDF* qpdf, int objid, int generation,
QPDFObjectHandle stream_dict,
off_t offset, int length) :
@@ -29,8 +29,9 @@ QPDF_Stream::QPDF_Stream(QPDF* qpdf, int objid, int generation,
{
if (! stream_dict.isDictionary())
{
- throw QEXC::Internal("stream object instantiated with non-dictionary "
- "object for dictionary");
+ throw std::logic_error(
+ "stream object instantiated with non-dictionary "
+ "object for dictionary");
}
}
@@ -298,8 +299,9 @@ QPDF_Stream::pipeStreamData(Pipeline* pipeline, bool filter,
}
else
{
- throw QEXC::Internal("QPDFStream: unknown filter "
- "encountered after check");
+ throw std::logic_error(
+ "INTERNAL ERROR: QPDFStream: unknown filter "
+ "encountered after check");
}
}
}
diff --git a/libqpdf/QPDF_String.cc b/libqpdf/QPDF_String.cc
index 739006b4..69c2ecb7 100644
--- a/libqpdf/QPDF_String.cc
+++ b/libqpdf/QPDF_String.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/QPDF_String.hh>
#include <qpdf/QUtil.hh>
diff --git a/libqpdf/QPDF_encryption.cc b/libqpdf/QPDF_encryption.cc
index 02517aed..00766b60 100644
--- a/libqpdf/QPDF_encryption.cc
+++ b/libqpdf/QPDF_encryption.cc
@@ -386,7 +386,8 @@ QPDF::getKeyForObject(int objid, int generation)
{
if (! this->encrypted)
{
- throw QEXC::Internal("request for encryption key in non-encrypted PDF");
+ throw std::logic_error(
+ "request for encryption key in non-encrypted PDF");
}
if (! ((objid == this->cached_key_objid) &&
diff --git a/libqpdf/QPDF_linearization.cc b/libqpdf/QPDF_linearization.cc
index 281748b5..a6b1c2d0 100644
--- a/libqpdf/QPDF_linearization.cc
+++ b/libqpdf/QPDF_linearization.cc
@@ -1177,8 +1177,9 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data)
{
// Note that we can't call optimize here because we don't know
// whether it should be called with or without allow changes.
- throw QEXC::Internal("QPDF::calculateLinearizationData "
- "called before optimize()");
+ throw std::logic_error(
+ "INTERNAL ERROR: QPDF::calculateLinearizationData "
+ "called before optimize()");
}
// Separate objects into the categories sufficient for us to
@@ -1336,8 +1337,9 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data)
break;
case ObjUser::ou_bad:
- throw QEXC::Internal("QPDF::calculateLinearizationData: "
- "invalid user type");
+ throw std::logic_error(
+ "INTERNAL ERROR: QPDF::calculateLinearizationData: "
+ "invalid user type");
break;
}
}
@@ -1444,8 +1446,9 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data)
ObjGen first_page_og(pages[0].getObjectID(), pages[0].getGeneration());
if (! lc_first_page_private.count(first_page_og))
{
- throw QEXC::Internal("QPDF::calculateLinearizationData: first page "
- "object not in lc_first_page_private");
+ throw std::logic_error(
+ "INTERNAL ERROR: QPDF::calculateLinearizationData: first page "
+ "object not in lc_first_page_private");
}
lc_first_page_private.erase(first_page_og);
this->c_linp.first_page_object = pages[0].getObjectID();
@@ -1492,7 +1495,8 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data)
ObjGen page_og(pages[i].getObjectID(), pages[i].getGeneration());
if (! lc_other_page_private.count(page_og))
{
- throw QEXC::Internal(
+ throw std::logic_error(
+ "INTERNAL ERROR: "
"QPDF::calculateLinearizationData: page object for page " +
QUtil::int_to_string(i) + " not in lc_other_page_private");
}
@@ -1522,8 +1526,9 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data)
// That should have covered all part7 objects.
if (! lc_other_page_private.empty())
{
- throw QEXC::Internal(
- "QPDF::calculateLinearizationData: lc_other_page_private is "
+ throw std::logic_error(
+ "INTERNAL ERROR:"
+ " QPDF::calculateLinearizationData: lc_other_page_private is "
"not empty after generation of part7");
}
@@ -1601,7 +1606,8 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data)
}
if (! lc_thumbnail_private.empty())
{
- throw QEXC::Internal(
+ throw std::logic_error(
+ "INTERNAL ERROR: "
"QPDF::calculateLinearizationData: lc_thumbnail_private "
"not empty after placing thumbnails");
}
@@ -1633,11 +1639,12 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data)
unsigned int num_wanted = this->object_to_obj_users.size();
if (num_placed != num_wanted)
{
- throw QEXC::Internal("QPDF::calculateLinearizationData: wrong "
- "number of objects placed (num_placed = " +
- QUtil::int_to_string(num_placed) +
- "; number of objects: " +
- QUtil::int_to_string(num_wanted));
+ throw std::logic_error(
+ "INTERNAL ERROR: QPDF::calculateLinearizationData: wrong "
+ "number of objects placed (num_placed = " +
+ QUtil::int_to_string(num_placed) +
+ "; number of objects: " +
+ QUtil::int_to_string(num_wanted));
}
// Calculate shared object hint table information including
diff --git a/libqpdf/QPDF_optimization.cc b/libqpdf/QPDF_optimization.cc
index edd9bba9..7a45d43e 100644
--- a/libqpdf/QPDF_optimization.cc
+++ b/libqpdf/QPDF_optimization.cc
@@ -78,8 +78,9 @@ QPDF::flattenScalarReferences()
{
if (node.isScalar())
{
- throw QEXC::Internal(
- "flattenScalarReferences landed at indirect scalar");
+ throw std::logic_error(
+ "INTERNAL ERROR:"
+ " flattenScalarReferences landed at indirect scalar");
}
ObjGen og(node.getObjectID(), node.getGeneration());
if (visited.count(og) > 0)
@@ -124,7 +125,8 @@ QPDF::flattenScalarReferences()
{
// QPDF_Dictionary.getKeys() never returns null
// keys.
- throw QEXC::Internal("dictionary with null key found");
+ throw std::logic_error(
+ "INTERNAL ERROR: dictionary with null key found");
}
else if (oh.isScalar())
{
diff --git a/libqpdf/QTC.cc b/libqpdf/QTC.cc
index eea7c514..5ce91aad 100644
--- a/libqpdf/QTC.cc
+++ b/libqpdf/QTC.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/QTC.hh>
#include <set>
diff --git a/libqpdf/QUtil.cc b/libqpdf/QUtil.cc
index 0d0b4667..1b9ca924 100644
--- a/libqpdf/QUtil.cc
+++ b/libqpdf/QUtil.cc
@@ -1,4 +1,4 @@
-
+#include <qpdf/DLL.hh>
#include <qpdf/QUtil.hh>
#include <stdio.h>
#include <errno.h>
@@ -25,9 +25,9 @@ QUtil::int_to_string(int num, int fullpad)
// -2 or -1 to leave space for the possible negative sign and for NUL...
if (abs(fullpad) > (int)sizeof(t) - ((num < 0)?2:1))
{
- throw QEXC::Internal("Util::int_to_string has been called with "
- "a padding value greater than its internal "
- "limit");
+ throw std::logic_error("Util::int_to_string has been called with "
+ "a padding value greater than its internal "
+ "limit");
}
if (fullpad)
@@ -62,9 +62,9 @@ QUtil::double_to_string(double num, int decimal_places)
// always pass in those cases.
if (decimal_places + 1 + (int)lhs.length() > (int)sizeof(t) - 1)
{
- throw QEXC::Internal("Util::double_to_string has been called with "
- "a number and a decimal places specification "
- "that would break an internal limit");
+ throw std::logic_error("Util::double_to_string has been called with "
+ "a number and a decimal places specification "
+ "that would break an internal limit");
}
if (decimal_places)
@@ -79,23 +79,30 @@ QUtil::double_to_string(double num, int decimal_places)
}
DLL_EXPORT
+void
+QUtil::throw_system_error(std::string const& description)
+{
+ throw std::runtime_error(description + ": " + strerror(errno));
+}
+
+DLL_EXPORT
int
-QUtil::os_wrapper(std::string const& description, int status) throw (QEXC::System)
+QUtil::os_wrapper(std::string const& description, int status)
{
if (status == -1)
{
- throw QEXC::System(description, errno);
+ throw_system_error(description);
}
return status;
}
DLL_EXPORT
FILE*
-QUtil::fopen_wrapper(std::string const& description, FILE* f) throw (QEXC::System)
+QUtil::fopen_wrapper(std::string const& description, FILE* f)
{
if (f == 0)
{
- throw QEXC::System(description, errno);
+ throw_system_error(description);
}
return f;
}
@@ -240,7 +247,7 @@ QUtil::toUTF8(unsigned long uval)
if (uval > 0x7fffffff)
{
- throw QEXC::General("bounds error in QUtil::toUTF8");
+ throw std::runtime_error("bounds error in QUtil::toUTF8");
}
else if (uval < 128)
{
@@ -267,7 +274,7 @@ QUtil::toUTF8(unsigned long uval)
--cur_byte;
if (cur_byte < bytes)
{
- throw QEXC::Internal("QUtil::toUTF8: overflow error");
+ throw std::logic_error("QUtil::toUTF8: overflow error");
}
}
// If maxval is k bits long, the high (7 - k) bits of the
diff --git a/libqpdf/RC4.cc b/libqpdf/RC4.cc
index 74b538b5..c51ebacd 100644
--- a/libqpdf/RC4.cc
+++ b/libqpdf/RC4.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/RC4.hh>
#include <string.h>
diff --git a/libqpdf/bits.icc b/libqpdf/bits.icc
index 465bf5b9..e6abdf0e 100644
--- a/libqpdf/bits.icc
+++ b/libqpdf/bits.icc
@@ -3,8 +3,8 @@
#define __BITS_CC__
#include <algorithm>
+#include <stdexcept>
#include <qpdf/QTC.hh>
-#include <qpdf/QEXC.hh>
#include <qpdf/Pipeline.hh>
// These functions may be run at places where the function call
@@ -28,11 +28,11 @@ read_bits(unsigned char const*& p, unsigned int& bit_offset,
if (bits_wanted > bits_available)
{
- throw QEXC::General("overflow reading bit stream");
+ throw std::length_error("overflow reading bit stream");
}
if (bits_wanted > 32)
{
- throw QEXC::Internal("read_bits: too many bits requested");
+ throw std::out_of_range("read_bits: too many bits requested");
}
unsigned long result = 0;
@@ -99,7 +99,7 @@ write_bits(unsigned char& ch, unsigned int& bit_offset,
{
if (bits > 32)
{
- throw QEXC::Internal("write_bits: too many bits requested");
+ throw std::out_of_range("write_bits: too many bits requested");
}
// bit_offset + 1 is the number of bits left in ch
diff --git a/libqpdf/build.mk b/libqpdf/build.mk
index 3ee11dfa..6d807a6a 100644
--- a/libqpdf/build.mk
+++ b/libqpdf/build.mk
@@ -22,7 +22,6 @@ SRCS_libqpdf = \
libqpdf/Pl_QPDFTokenizer.cc \
libqpdf/Pl_RC4.cc \
libqpdf/Pl_StdioFile.cc \
- libqpdf/QEXC.cc \
libqpdf/QPDF.cc \
libqpdf/QPDFExc.cc \
libqpdf/QPDFObject.cc \
@@ -69,5 +68,5 @@ $(OBJS_libqpdf): libqpdf/$(OUTPUT_DIR)/%.lo: libqpdf/%.cc
# * Otherwise, increment REVISION
libqpdf/$(OUTPUT_DIR)/libqpdf.la: $(OBJS_libqpdf)
- $(call makelib,$(OBJS_libqpdf),$@,2,1,1)
+ $(call makelib,$(OBJS_libqpdf),$@,3,0,0)
diff --git a/libqpdf/qpdf/MD5.hh b/libqpdf/qpdf/MD5.hh
index ae2e2113..c1babb29 100644
--- a/libqpdf/qpdf/MD5.hh
+++ b/libqpdf/qpdf/MD5.hh
@@ -1,10 +1,8 @@
-
#ifndef __MD5_HH__
#define __MD5_HH__
#include <string>
#include <qpdf/DLL.hh>
-#include <qpdf/QEXC.hh>
#include <qpdf/qpdf-config.h>
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
@@ -26,8 +24,7 @@ class MD5
// encodes file and finalizes
DLL_EXPORT
- void encodeFile(char const* filename, int up_to_size = -1)
- throw(QEXC::System);
+ void encodeFile(char const* filename, int up_to_size = -1);
// appends string to current md5 object
DLL_EXPORT
diff --git a/libqpdf/qpdf/PCRE.hh b/libqpdf/qpdf/PCRE.hh
index ba6f6670..919431a3 100644
--- a/libqpdf/qpdf/PCRE.hh
+++ b/libqpdf/qpdf/PCRE.hh
@@ -10,9 +10,9 @@
#endif
#include <pcre.h>
#include <string>
+#include <stdexcept>
#include <qpdf/DLL.hh>
-#include <qpdf/QEXC.hh>
// Note: this class does not encapsulate all features of the PCRE
// package -- only those that I actually need right now are here.
@@ -20,18 +20,9 @@
class PCRE
{
public:
- class Exception: public QEXC::General
- {
- public:
- DLL_EXPORT
- Exception(std::string const& message);
- DLL_EXPORT
- virtual ~Exception() throw() {}
- };
-
// This is thrown when an attempt is made to access a non-existent
// back reference.
- class NoBackref: public Exception
+ class NoBackref: public std::logic_error
{
public:
DLL_EXPORT
@@ -65,14 +56,13 @@ class PCRE
// see getMatch flags below
DLL_EXPORT
- std::string getMatch(int n, int flags = 0)
- throw(QEXC::General, Exception);
+ std::string getMatch(int n, int flags = 0);
DLL_EXPORT
- void getOffsetLength(int n, int& offset, int& length) throw(Exception);
+ void getOffsetLength(int n, int& offset, int& length);
DLL_EXPORT
- int getOffset(int n) throw(Exception);
+ int getOffset(int n);
DLL_EXPORT
- int getLength(int n) throw(Exception);
+ int getLength(int n);
// nMatches returns the number of available matches including
// match 0 which is the whole string. In other words, if you
@@ -105,14 +95,13 @@ class PCRE
// The value passed in as options is passed to pcre_exec. See man
// pcreapi for details.
DLL_EXPORT
- PCRE(char const* pattern, int options = 0) throw(Exception);
+ PCRE(char const* pattern, int options = 0);
DLL_EXPORT
~PCRE();
DLL_EXPORT
Match match(char const* subject, int options = 0, int startoffset = 0,
- int size = -1)
- throw(QEXC::General, Exception);
+ int size = -1);
DLL_EXPORT
static void test(int n = 0);
diff --git a/libqpdf/qpdf/Pl_ASCII85Decoder.hh b/libqpdf/qpdf/Pl_ASCII85Decoder.hh
index 6efd8199..a2c38da3 100644
--- a/libqpdf/qpdf/Pl_ASCII85Decoder.hh
+++ b/libqpdf/qpdf/Pl_ASCII85Decoder.hh
@@ -1,4 +1,3 @@
-
#ifndef __PL_ASCII85DECODER_HH__
#define __PL_ASCII85DECODER_HH__
diff --git a/libqpdf/qpdf/Pl_ASCIIHexDecoder.hh b/libqpdf/qpdf/Pl_ASCIIHexDecoder.hh
index 068294d7..8a7b1899 100644
--- a/libqpdf/qpdf/Pl_ASCIIHexDecoder.hh
+++ b/libqpdf/qpdf/Pl_ASCIIHexDecoder.hh
@@ -1,4 +1,3 @@
-
#ifndef __PL_ASCIIHEXDECODER_HH__
#define __PL_ASCIIHEXDECODER_HH__
diff --git a/libqpdf/qpdf/Pl_LZWDecoder.hh b/libqpdf/qpdf/Pl_LZWDecoder.hh
index 4d348406..3226cd6a 100644
--- a/libqpdf/qpdf/Pl_LZWDecoder.hh
+++ b/libqpdf/qpdf/Pl_LZWDecoder.hh
@@ -1,4 +1,3 @@
-
#ifndef __PL_LZWDECODER_HH__
#define __PL_LZWDECODER_HH__
diff --git a/libqpdf/qpdf/Pl_MD5.hh b/libqpdf/qpdf/Pl_MD5.hh
index 9da018d1..13973f29 100644
--- a/libqpdf/qpdf/Pl_MD5.hh
+++ b/libqpdf/qpdf/Pl_MD5.hh
@@ -1,4 +1,3 @@
-
#ifndef __PL_MD5_HH__
#define __PL_MD5_HH__
diff --git a/libqpdf/qpdf/Pl_PNGFilter.hh b/libqpdf/qpdf/Pl_PNGFilter.hh
index 1d9afabd..eb2ed028 100644
--- a/libqpdf/qpdf/Pl_PNGFilter.hh
+++ b/libqpdf/qpdf/Pl_PNGFilter.hh
@@ -19,21 +19,6 @@
class Pl_PNGFilter: public Pipeline
{
public:
- class Exception: public Pipeline::Exception
- {
- public:
- DLL_EXPORT
- Exception(std::string const& message) :
- Pipeline::Exception(message)
- {
- }
-
- DLL_EXPORT
- virtual ~Exception() throw ()
- {
- }
- };
-
// Encoding is not presently supported
enum action_e { a_encode, a_decode };
diff --git a/libqpdf/qpdf/Pl_QPDFTokenizer.hh b/libqpdf/qpdf/Pl_QPDFTokenizer.hh
index 448dbb18..d300d7cd 100644
--- a/libqpdf/qpdf/Pl_QPDFTokenizer.hh
+++ b/libqpdf/qpdf/Pl_QPDFTokenizer.hh
@@ -1,4 +1,3 @@
-
#ifndef __PL_QPDFTOKENIZER_HH__
#define __PL_QPDFTOKENIZER_HH__
diff --git a/libqpdf/qpdf/Pl_RC4.hh b/libqpdf/qpdf/Pl_RC4.hh
index 01b651a5..907b4af8 100644
--- a/libqpdf/qpdf/Pl_RC4.hh
+++ b/libqpdf/qpdf/Pl_RC4.hh
@@ -1,4 +1,3 @@
-
#ifndef __PL_RC4_HH__
#define __PL_RC4_HH__
@@ -9,21 +8,6 @@
class Pl_RC4: public Pipeline
{
public:
- class Exception: public Pipeline::Exception
- {
- public:
- DLL_EXPORT
- Exception(std::string const& message) :
- Pipeline::Exception(message)
- {
- }
-
- DLL_EXPORT
- virtual ~Exception() throw()
- {
- }
- };
-
static int const def_bufsize = 65536;
// key_len of -1 means treat key_data as a null-terminated string
diff --git a/libqpdf/qpdf/QPDF_Array.hh b/libqpdf/qpdf/QPDF_Array.hh
index 371be50e..fce36a4c 100644
--- a/libqpdf/qpdf/QPDF_Array.hh
+++ b/libqpdf/qpdf/QPDF_Array.hh
@@ -1,4 +1,3 @@
-
#ifndef __QPDF_ARRAY_HH__
#define __QPDF_ARRAY_HH__
diff --git a/libqpdf/qpdf/QPDF_Bool.hh b/libqpdf/qpdf/QPDF_Bool.hh
index 06aca822..90dc590e 100644
--- a/libqpdf/qpdf/QPDF_Bool.hh
+++ b/libqpdf/qpdf/QPDF_Bool.hh
@@ -1,4 +1,3 @@
-
#ifndef __QPDF_BOOL_HH__
#define __QPDF_BOOL_HH__
diff --git a/libqpdf/qpdf/QPDF_Dictionary.hh b/libqpdf/qpdf/QPDF_Dictionary.hh
index b960050a..a6b1e77b 100644
--- a/libqpdf/qpdf/QPDF_Dictionary.hh
+++ b/libqpdf/qpdf/QPDF_Dictionary.hh
@@ -1,4 +1,3 @@
-
#ifndef __QPDF_DICTIONARY_HH__
#define __QPDF_DICTIONARY_HH__
diff --git a/libqpdf/qpdf/QPDF_Integer.hh b/libqpdf/qpdf/QPDF_Integer.hh
index fb6360b2..cc11cd65 100644
--- a/libqpdf/qpdf/QPDF_Integer.hh
+++ b/libqpdf/qpdf/QPDF_Integer.hh
@@ -1,4 +1,3 @@
-
#ifndef __QPDF_INTEGER_HH__
#define __QPDF_INTEGER_HH__
diff --git a/libqpdf/qpdf/QPDF_Name.hh b/libqpdf/qpdf/QPDF_Name.hh
index a32f6f4f..361556a0 100644
--- a/libqpdf/qpdf/QPDF_Name.hh
+++ b/libqpdf/qpdf/QPDF_Name.hh
@@ -1,4 +1,3 @@
-
#ifndef __QPDF_NAME_HH__
#define __QPDF_NAME_HH__
diff --git a/libqpdf/qpdf/QPDF_Null.hh b/libqpdf/qpdf/QPDF_Null.hh
index 60c1ae35..086a3228 100644
--- a/libqpdf/qpdf/QPDF_Null.hh
+++ b/libqpdf/qpdf/QPDF_Null.hh
@@ -1,4 +1,3 @@
-
#ifndef __QPDF_NULL_HH__
#define __QPDF_NULL_HH__
diff --git a/libqpdf/qpdf/QPDF_Real.hh b/libqpdf/qpdf/QPDF_Real.hh
index b950c569..76777477 100644
--- a/libqpdf/qpdf/QPDF_Real.hh
+++ b/libqpdf/qpdf/QPDF_Real.hh
@@ -1,4 +1,3 @@
-
#ifndef __QPDF_REAL_HH__
#define __QPDF_REAL_HH__
diff --git a/libqpdf/qpdf/QPDF_Stream.hh b/libqpdf/qpdf/QPDF_Stream.hh
index 71381fd3..c969255d 100644
--- a/libqpdf/qpdf/QPDF_Stream.hh
+++ b/libqpdf/qpdf/QPDF_Stream.hh
@@ -1,4 +1,3 @@
-
#ifndef __QPDF_STREAM_HH__
#define __QPDF_STREAM_HH__
diff --git a/libqpdf/qpdf/QPDF_String.hh b/libqpdf/qpdf/QPDF_String.hh
index f3063c50..82860e9d 100644
--- a/libqpdf/qpdf/QPDF_String.hh
+++ b/libqpdf/qpdf/QPDF_String.hh
@@ -1,4 +1,3 @@
-
#ifndef __QPDF_STRING_HH__
#define __QPDF_STRING_HH__
diff --git a/libqpdf/qpdf/RC4.hh b/libqpdf/qpdf/RC4.hh
index 657bf35b..c26f3d0f 100644
--- a/libqpdf/qpdf/RC4.hh
+++ b/libqpdf/qpdf/RC4.hh
@@ -1,4 +1,3 @@
-
#ifndef __RC4_HH__
#define __RC4_HH__
diff --git a/libtests/bits.cc b/libtests/bits.cc
index 89516ae6..b1857988 100644
--- a/libtests/bits.cc
+++ b/libtests/bits.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/BitStream.hh>
#include <qpdf/BitWriter.hh>
#include <qpdf/Pl_Buffer.hh>
diff --git a/libtests/buffer.cc b/libtests/buffer.cc
index 13d16b50..a359a6eb 100644
--- a/libtests/buffer.cc
+++ b/libtests/buffer.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/Pl_Buffer.hh>
#include <qpdf/Pl_Count.hh>
#include <qpdf/Pl_Discard.hh>
diff --git a/libtests/build.mk b/libtests/build.mk
index 4a58fcaa..4e2fe9be 100644
--- a/libtests/build.mk
+++ b/libtests/build.mk
@@ -9,7 +9,6 @@ BINS_libtests = \
pcre \
png_filter \
pointer_holder \
- qexc \
qutil \
rc4
diff --git a/libtests/flate.cc b/libtests/flate.cc
index d05e7f92..dc65c565 100644
--- a/libtests/flate.cc
+++ b/libtests/flate.cc
@@ -105,9 +105,9 @@ int main(int argc, char* argv[])
{
run(filename);
}
- catch (QEXC::General& e)
+ catch (std::exception& e)
{
- std::cout << e.unparse() << std::endl;
+ std::cout << e.what() << std::endl;
}
return 0;
}
diff --git a/libtests/md5.cc b/libtests/md5.cc
index 1d33f9a6..9b1ae483 100644
--- a/libtests/md5.cc
+++ b/libtests/md5.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/MD5.hh>
#include <qpdf/Pl_MD5.hh>
#include <qpdf/Pl_Discard.hh>
diff --git a/libtests/pcre.cc b/libtests/pcre.cc
index 8ff7fba0..6ebec01e 100644
--- a/libtests/pcre.cc
+++ b/libtests/pcre.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/PCRE.hh>
#include <iostream>
#include <string.h>
@@ -12,7 +11,7 @@ int main(int argc, char* argv[])
PCRE("^([\\p{L}]+)", PCRE_UTF8);
std::cout << "1" << std::endl;
}
- catch (PCRE::Exception& e)
+ catch (std::exception& e)
{
std::cout << "0" << std::endl;
}
diff --git a/libtests/png_filter.cc b/libtests/png_filter.cc
index a4b8a110..b735f338 100644
--- a/libtests/png_filter.cc
+++ b/libtests/png_filter.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/Pl_PNGFilter.hh>
#include <qpdf/Pl_StdioFile.hh>
@@ -79,9 +78,9 @@ int main(int argc, char* argv[])
{
run(filename, encode, columns);
}
- catch (QEXC::General& e)
+ catch (std::exception& e)
{
- std::cout << e.unparse() << std::endl;
+ std::cout << e.what() << std::endl;
}
return 0;
}
diff --git a/libtests/pointer_holder.cc b/libtests/pointer_holder.cc
index 9176df17..173a8266 100644
--- a/libtests/pointer_holder.cc
+++ b/libtests/pointer_holder.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/PointerHolder.hh>
#include <iostream>
diff --git a/libtests/qexc.cc b/libtests/qexc.cc
deleted file mode 100644
index 6a89f68d..00000000
--- a/libtests/qexc.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-
-#include <qpdf/QEXC.hh>
-#include <iostream>
-#include <errno.h>
-#include <stdlib.h>
-
-void f(int n)
-{
- switch (n)
- {
- case 0:
- throw QEXC::General("general exception");
- break;
-
- case 1:
- throw QEXC::Internal("internal error");
- break;
-
- case 2:
- throw QEXC::System("doing something", EINVAL);
- break;
- }
-}
-
-int main(int argc, char* argv[])
-{
- if (argc != 2)
- {
- std::cerr << "usage: qexc n" << std::endl;
- exit(2);
- }
-
- try
- {
- f(atoi(argv[1]));
- }
- catch (QEXC::General& e)
- {
- std::cerr << "exception: " << e.unparse() << std::endl;
- std::cerr << "what: " << e.what() << std::endl;
- exit(2);
- }
- catch (std::exception& e)
- {
- std::cerr << "uncaught exception: " << e.what() << std::endl;
- exit(3);
- }
- catch (...)
- {
- exit(4);
- }
- return 0;
-}
diff --git a/libtests/qtest/buffer/buffer.out b/libtests/qtest/buffer/buffer.out
index 9ee2b545..787a38ed 100644
--- a/libtests/qtest/buffer/buffer.out
+++ b/libtests/qtest/buffer/buffer.out
@@ -5,7 +5,7 @@ data: 1234567890abcdefghij
count: 32
size: 11
data: qwertyuiop
-INTERNAL ERROR: Pl_Buffer::getBuffer() called when not ready
+Pl_Buffer::getBuffer() called when not ready
size: 9
data: mooquack
done
diff --git a/libtests/qtest/qexc.test b/libtests/qtest/qexc.test
deleted file mode 100644
index 350ceba8..00000000
--- a/libtests/qtest/qexc.test
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env perl
-
-require 5.008;
-BEGIN { $^W = 1; }
-use strict;
-
-chdir("qexc") or die "chdir qexc failed: $!\n";
-
-require TestDriver;
-
-my $td = new TestDriver('qexc');
-
-my @tests =
- (['general exception', 2],
- ['internal error', 3],
- ['system exception', 2],
- );
-
-for (my $i = 0; $i < scalar(@tests); ++$i)
-{
- $td->runtest($tests[$i]->[0],
- {$td->COMMAND => "qexc $i"},
- {$td->FILE => "test$i.out",
- $td->EXIT_STATUS => $tests[$i]->[1]},
- $td->NORMALIZE_NEWLINES);
-}
-
-$td->report(scalar(@tests));
diff --git a/libtests/qtest/qexc/test0.out b/libtests/qtest/qexc/test0.out
deleted file mode 100644
index 7a6dba88..00000000
--- a/libtests/qtest/qexc/test0.out
+++ /dev/null
@@ -1,2 +0,0 @@
-exception: general exception
-what: general exception
diff --git a/libtests/qtest/qexc/test1.out b/libtests/qtest/qexc/test1.out
deleted file mode 100644
index cb18f40c..00000000
--- a/libtests/qtest/qexc/test1.out
+++ /dev/null
@@ -1 +0,0 @@
-uncaught exception: INTERNAL ERROR: internal error
diff --git a/libtests/qtest/qexc/test2.out b/libtests/qtest/qexc/test2.out
deleted file mode 100644
index 0f1994f7..00000000
--- a/libtests/qtest/qexc/test2.out
+++ /dev/null
@@ -1,2 +0,0 @@
-exception: doing something: Invalid argument
-what: doing something: Invalid argument
diff --git a/libtests/qtest/qutil/qutil.out b/libtests/qtest/qutil/qutil.out
index f7af8903..a48e6266 100644
--- a/libtests/qtest/qutil/qutil.out
+++ b/libtests/qtest/qutil/qutil.out
@@ -4,11 +4,11 @@
3.141590
3.142
1000.123000
-exception 1: INTERNAL ERROR: Util::int_to_string has been called with a padding value greater than its internal limit
-exception 2: INTERNAL ERROR: Util::int_to_string has been called with a padding value greater than its internal limit
-exception 3: INTERNAL ERROR: Util::int_to_string has been called with a padding value greater than its internal limit
-exception 4: INTERNAL ERROR: Util::double_to_string has been called with a number and a decimal places specification that would break an internal limit
-exception 5: INTERNAL ERROR: Util::double_to_string has been called with a number and a decimal places specification that would break an internal limit
+exception 1: Util::int_to_string has been called with a padding value greater than its internal limit
+exception 2: Util::int_to_string has been called with a padding value greater than its internal limit
+exception 3: Util::int_to_string has been called with a padding value greater than its internal limit
+exception 4: Util::double_to_string has been called with a number and a decimal places specification that would break an internal limit
+exception 5: Util::double_to_string has been called with a number and a decimal places specification that would break an internal limit
one
7
compare okay
diff --git a/libtests/qutil.cc b/libtests/qutil.cc
index 0dfa0277..d1c090fb 100644
--- a/libtests/qutil.cc
+++ b/libtests/qutil.cc
@@ -1,4 +1,3 @@
-
#include <iostream>
#include <stdio.h>
#include <sys/types.h>
@@ -27,9 +26,9 @@ void string_conversion_test()
// int_to_string bounds error
std::cout << QUtil::int_to_string(1, 50) << std::endl;
}
- catch(QEXC::Internal &e)
+ catch (std::logic_error &e)
{
- std::cout << "exception 1: " << e.unparse() << std::endl;
+ std::cout << "exception 1: " << e.what() << std::endl;
}
try
@@ -37,9 +36,9 @@ void string_conversion_test()
// QUtil::int_to_string bounds error
std::cout << QUtil::int_to_string(1, -50) << std::endl;
}
- catch(QEXC::Internal &e)
+ catch (std::logic_error& e)
{
- std::cout << "exception 2: " << e.unparse() << std::endl;
+ std::cout << "exception 2: " << e.what() << std::endl;
}
try
@@ -47,9 +46,9 @@ void string_conversion_test()
// QUtil::int_to_string bounds error
std::cout << QUtil::int_to_string(-1, 49) << std::endl;
}
- catch(QEXC::Internal &e)
+ catch (std::logic_error& e)
{
- std::cout << "exception 3: " << e.unparse() << std::endl;
+ std::cout << "exception 3: " << e.what() << std::endl;
}
@@ -58,9 +57,9 @@ void string_conversion_test()
// QUtil::double_to_string bounds error
std::cout << QUtil::double_to_string(3.14159, 1024) << std::endl;
}
- catch(QEXC::Internal &e)
+ catch (std::logic_error& e)
{
- std::cout << "exception 4: " << e.unparse() << std::endl;
+ std::cout << "exception 4: " << e.what() << std::endl;
}
try
@@ -68,9 +67,9 @@ void string_conversion_test()
// QUtil::double_to_string bounds error
std::cout << QUtil::double_to_string(1000.0, 95) << std::endl;
}
- catch(QEXC::Internal &e)
+ catch (std::logic_error& e)
{
- std::cout << "exception 5: " << e.unparse() << std::endl;
+ std::cout << "exception 5: " << e.what() << std::endl;
}
std::string embedded_null = "one";
@@ -101,9 +100,9 @@ void os_wrapper_test()
std::cout << "after open" << std::endl;
(void) close(fd);
}
- catch (QEXC::System& s)
+ catch (std::runtime_error& s)
{
- std::cout << "exception: " << s.unparse() << std::endl;
+ std::cout << "exception: " << s.what() << std::endl;
}
}
@@ -118,9 +117,9 @@ void fopen_wrapper_test()
std::cout << "after fopen" << std::endl;
(void) fclose(f);
}
- catch (QEXC::System& s)
+ catch (std::runtime_error& s)
{
- std::cout << "exception: " << s.unparse() << std::endl;
+ std::cout << "exception: " << s.what() << std::endl;
}
}
@@ -171,7 +170,7 @@ void to_utf8_test()
{
print_utf8(0x80000000UL);
}
- catch (QEXC::General& e)
+ catch (std::runtime_error& e)
{
std::cout << "0x80000000: " << e.what() << std::endl;
}
diff --git a/libtests/rc4.cc b/libtests/rc4.cc
index 195740ec..8f809ec1 100644
--- a/libtests/rc4.cc
+++ b/libtests/rc4.cc
@@ -1,4 +1,3 @@
-
#include <qpdf/Pl_RC4.hh>
#include <qpdf/Pl_StdioFile.hh>
diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc
index 12053cbe..bcf2e33e 100644
--- a/qpdf/qpdf.cc
+++ b/qpdf/qpdf.cc
@@ -1,4 +1,3 @@
-
#include <iostream>
#include <string.h>
#include <stdlib.h>
@@ -943,7 +942,7 @@ int main(int argc, char* argv[])
}
else
{
- throw QEXC::Internal("bad encryption keylen");
+ throw std::logic_error("bad encryption keylen");
}
}
if (linearize)
diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc
index 192577c5..48c0eb41 100644
--- a/qpdf/test_driver.cc
+++ b/qpdf/test_driver.cc
@@ -284,8 +284,8 @@ void runtest(int n, char const* filename)
}
else
{
- throw QEXC::General(std::string("invalid test ") +
- QUtil::int_to_string(n));
+ throw std::runtime_error(std::string("invalid test ") +
+ QUtil::int_to_string(n));
}
std::cout << "test " << n << " done" << std::endl;