Commit 9a96e233b051b31289c84f90a321583887b1400a

Authored by Jay Berkenbilt
1 parent 30f109e2

Remove PCRE

ChangeLog
1 2017-08-10 Jay Berkenbilt <ejb@ql.org> 1 2017-08-10 Jay Berkenbilt <ejb@ql.org>
2 2
  3 + * Remove dependency on libpcre.
  4 +
3 * Be more forgiving of certain types of errors in the xref table 5 * Be more forgiving of certain types of errors in the xref table
4 that don't interfere with interpreting the table. 6 that don't interfere with interpreting the table.
5 7
@@ -13,11 +13,11 @@ warranty. @@ -13,11 +13,11 @@ warranty.
13 Prerequisites 13 Prerequisites
14 ============= 14 =============
15 15
16 -QPDF depends on external libraries "zlib" and "pcre". These are part  
17 -of virtually all Linux distributions and are readily available;  
18 -download information appears in the documentation. For Windows, you  
19 -can download pre-built binary versions of those libraries for some  
20 -compilers; see README-windows.txt for additional details. 16 +QPDF depends on the external library "zlib". This are part of every
  17 +Linux distribution and is readily available. Download information
  18 +appears in the documentation. For Windows, you can download pre-built
  19 +binary versions of this libraries for some compilers; see
  20 +README-windows.txt for additional details.
21 21
22 QPDF requires a C++ compiler that works with STL. Your compiler must 22 QPDF requires a C++ compiler that works with STL. Your compiler must
23 also support "long long". Almost all modern compilers do. If you are 23 also support "long long". Almost all modern compilers do. If you are
@@ -34,10 +34,9 @@ you had an otherwise working qpdf. @@ -34,10 +34,9 @@ you had an otherwise working qpdf.
34 Licensing terms of embedded software 34 Licensing terms of embedded software
35 ==================================== 35 ====================================
36 36
37 -QPDF makes use of zlib and pcre for its functionality. These packages  
38 -can be downloaded separately from their own download locations, or  
39 -they can be downloaded in the external-libs area of the qpdf download  
40 -site. 37 +QPDF makes use of zlib for its functionality. This package can be
  38 +downloaded separately from its own download location, or it can be
  39 +downloaded in the external-libs area of the qpdf download site.
41 40
42 The Rijndael encryption implementation used as the basis for AES 41 The Rijndael encryption implementation used as the basis for AES
43 encryption and decryption support comes from Philip J. Erdelsky's 42 encryption and decryption support comes from Philip J. Erdelsky's
@@ -147,11 +146,11 @@ user&#39;s manual can be found in the &quot;doc&quot; directory. The docbook @@ -147,11 +146,11 @@ user&#39;s manual can be found in the &quot;doc&quot; directory. The docbook
147 sources to the user's manual can be found in the "manual" directory. 146 sources to the user's manual can be found in the "manual" directory.
148 147
149 The software library is just libqpdf, and all the header files are in 148 The software library is just libqpdf, and all the header files are in
150 -the qpdf subdirectory. If you link statically with -lqpdf, then you  
151 -will also need to link with -lpcre and -lz. The shared qpdf library  
152 -is linked with -lpcre and -lz, and none of qpdf's public header files  
153 -directly include files from pcre or libz, so in many cases, qpdf's  
154 -development files are self contained. 149 +the qpdf subdirectory. If you link statically with -lqpdf, then you
  150 +will also need to link with -lz. The shared qpdf library is linked
  151 +with -lz, and none of qpdf's public header files directly include
  152 +files from libz, so in many cases, qpdf's development files are self
  153 +contained.
155 154
156 To learn about using the library, please read comments in the header 155 To learn about using the library, please read comments in the header
157 files in include/qpdf, especially QPDF.hh, QPDFObjectHandle.hh, and 156 files in include/qpdf, especially QPDF.hh, QPDFObjectHandle.hh, and
README-what-to-download.txt
@@ -46,9 +46,8 @@ download. @@ -46,9 +46,8 @@ download.
46 * qpdf-external-libs-src.zip 46 * qpdf-external-libs-src.zip
47 47
48 If you want to build the external libraries on your own (for 48 If you want to build the external libraries on your own (for
49 - Windows or anything else), you can download this archive. In  
50 - addition to including unmodified distributions of pcre and zlib, it  
51 - includes a README file and some scripts to help you build them for  
52 - Windows. 49 + Windows or anything else), you can download this archive. In
  50 + addition to including an unmodified distribution zlib, it includes
  51 + a README file and some scripts to help you build it for Windows.
53 52
54 If you want to build on Windows, please see also README-windows.txt. 53 If you want to build on Windows, please see also README-windows.txt.
README-windows.txt
@@ -84,29 +84,32 @@ installers are provided, they might do that already by default. @@ -84,29 +84,32 @@ installers are provided, they might do that already by default.
84 External Libraries 84 External Libraries
85 ================== 85 ==================
86 86
87 -In order to build qpdf, you must have copies of zlib and pcre. The  
88 -easy way to get them is to download them from the qpdf download area.  
89 -There are packages called external-libs-bin.zip and  
90 -external-libs-src.zip. If you are building with MSVC 2010 or MINGW,  
91 -you can just extract the qpdf-external-libs-bin.zip zip file into the  
92 -top-level qpdf source tree. Note that you need the 2012-06-20 version  
93 -(at least) to build qpdf 3.0 or greater since this includes 64-bit  
94 -libraries. It will create a directory called external-libs which  
95 -contains header files and precompiled libraries. Passing  
96 ---enable-external-libs to ./configure (which is done automatically if  
97 -you follow the instructions below) is sufficient to find them.  
98 -  
99 -You can also obtain pcre and zlib directly on your own and install  
100 -them. If you are using mingw, you can just set CPPFLAGS, LDFLAGS, and  
101 -LIBS when you run ./configure so that it can find the header files and  
102 -libraries. If you are building with msvc and you want to do this, it  
103 -probably won't work because ./configure doesn't know how to interpret  
104 -LDFLAGS and LIBS properly for MSVC (though qpdf's own build system  
105 -does). In this case, you can probably get away with cheating by  
106 -passing --enable-external-libs to ./configure and then just editing  
107 -CPPFLAGS, LDFLAGS, LIBS in the generated autoconf.mk file. Note that  
108 -you should use UNIX-like syntax (-I, -L, -l) even though this is not  
109 -what cl takes on the command line. qpdf's build rules will fix it. 87 +In order to build qpdf, you must have a copy of zlib. The easy way to
  88 +get it is to download it from the qpdf download area. There are
  89 +packages called external-libs-bin.zip and external-libs-src.zip. If
  90 +you are building with MSVC 2010 or MINGW, you can just extract the
  91 +qpdf-external-libs-bin.zip zip file into the top-level qpdf source
  92 +tree. Note that you need the 2012-06-20 version (at least) to build
  93 +qpdf 3.0 or greater since this includes 64-bit libraries. The
  94 +2017-08-10 version includes libraries built with MSVC 2015 and
  95 +contains only zlib. Older versions also contain pcre, which is no
  96 +longer required as of qpdf 7.0.0. Extracting the zip will create a
  97 +directory called external-libs which contains header files and
  98 +precompiled libraries. Passing --enable-external-libs to ./configure
  99 +(which is done automatically if you follow the instructions below) is
  100 +sufficient to find them.
  101 +
  102 +You can also obtain zlib directly on your own and install it. If you
  103 +are using mingw, you can just set CPPFLAGS, LDFLAGS, and LIBS when you
  104 +run ./configure so that it can find the header files and libraries. If
  105 +you are building with msvc and you want to do this, it probably won't
  106 +work because ./configure doesn't know how to interpret LDFLAGS and
  107 +LIBS properly for MSVC (though qpdf's own build system does). In this
  108 +case, you can probably get away with cheating by passing
  109 +--enable-external-libs to ./configure and then just editing CPPFLAGS,
  110 +LDFLAGS, LIBS in the generated autoconf.mk file. Note that you should
  111 +use UNIX-like syntax (-I, -L, -l) even though this is not what cl
  112 +takes on the command line. qpdf's build rules will fix it.
110 113
111 You can also download qpdf-external-libs-src.zip and follow the 114 You can also download qpdf-external-libs-src.zip and follow the
112 instructions in the README.txt there for how to build external libs. 115 instructions in the README.txt there for how to build external libs.
README.maintainer
@@ -113,7 +113,12 @@ Release Reminders @@ -113,7 +113,12 @@ Release Reminders
113 version control system into a directory called qpdf-external-libs 113 version control system into a directory called qpdf-external-libs
114 and just make a zip file of the result called 114 and just make a zip file of the result called
115 qpdf-external-libs-src.zip. See the README.txt file there for 115 qpdf-external-libs-src.zip. See the README.txt file there for
116 - information on creating binary external libs releases. 116 + information on creating binary external libs releases. Run this
  117 + from the external-libs repository:
  118 +
  119 + git archive --prefix=external-libs/ HEAD . | (cd /tmp; tar xf -)
  120 + cd /tmp
  121 + zip -r qpdf-external-libs-src.zip external-libs
117 122
118 * To create Windows binary releases, extract the qpdf source 123 * To create Windows binary releases, extract the qpdf source
119 distribution in Windows (MSYS + MINGW, MSVC). From the extracted 124 distribution in Windows (MSYS + MINGW, MSVC). From the extracted
@@ -7,9 +7,6 @@ version if needed. @@ -7,9 +7,6 @@ version if needed.
7 Soon 7 Soon
8 ==== 8 ====
9 9
10 - * Eliminate dependency on PCRE. There aren't that many regular  
11 - expressions, and they are used only for internal purposes.  
12 -  
13 * Consider whether there should be a mode in which QPDFObjectHandle 10 * Consider whether there should be a mode in which QPDFObjectHandle
14 returns nulls for operations on the wrong type instead of asserting 11 returns nulls for operations on the wrong type instead of asserting
15 the type. The way things are wired up now, this would have to be a 12 the type. The way things are wired up now, this would have to be a
configure.ac
@@ -82,8 +82,6 @@ fi @@ -82,8 +82,6 @@ fi
82 if test "$BUILD_INTERNAL_LIBS" = "0"; then 82 if test "$BUILD_INTERNAL_LIBS" = "0"; then
83 AC_CHECK_HEADER(zlib.h,,[MISSING_ZLIB_H=1; MISSING_ANY=1]) 83 AC_CHECK_HEADER(zlib.h,,[MISSING_ZLIB_H=1; MISSING_ANY=1])
84 AC_SEARCH_LIBS(deflate,z zlib,,[MISSING_ZLIB=1; MISSING_ANY=1]) 84 AC_SEARCH_LIBS(deflate,z zlib,,[MISSING_ZLIB=1; MISSING_ANY=1])
85 - AC_CHECK_HEADER(pcre.h,,[MISSING_PCRE_H=1; MISSING_ANY=1])  
86 - AC_SEARCH_LIBS(pcre_compile,pcre,,[MISSING_PCRE=1; MISSING_ANY=1])  
87 fi 85 fi
88 86
89 if test "x$qpdf_OS_SECURE_RANDOM" = "x1"; then 87 if test "x$qpdf_OS_SECURE_RANDOM" = "x1"; then
@@ -453,14 +451,6 @@ if test &quot;$MISSING_ZLIB&quot; = &quot;1&quot;; then @@ -453,14 +451,6 @@ if test &quot;$MISSING_ZLIB&quot; = &quot;1&quot;; then
453 AC_MSG_WARN(unable to find required library z (or zlib)) 451 AC_MSG_WARN(unable to find required library z (or zlib))
454 fi 452 fi
455 453
456 -if test "$MISSING_PCRE_H" = "1"; then  
457 - AC_MSG_WARN(unable to find required header pcre.h)  
458 -fi  
459 -  
460 -if test "$MISSING_PCRE" = "1"; then  
461 - AC_MSG_WARN(unable to find required library pcre)  
462 -fi  
463 -  
464 if test "$MISSING_DOCBOOK_FO" = "1"; then 454 if test "$MISSING_DOCBOOK_FO" = "1"; then
465 AC_MSG_WARN(docbook fo stylesheets are required to build PDF documentation) 455 AC_MSG_WARN(docbook fo stylesheets are required to build PDF documentation)
466 fi 456 fi
@@ -497,7 +487,7 @@ if test &quot;$USE_EXTERNAL_LIBS&quot; = &quot;1&quot;; then @@ -497,7 +487,7 @@ if test &quot;$USE_EXTERNAL_LIBS&quot; = &quot;1&quot;; then
497 # much trouble getting it to work with a different compiler. 487 # much trouble getting it to work with a different compiler.
498 CPPFLAGS="$CPPFLAGS -Iexternal-libs/include" 488 CPPFLAGS="$CPPFLAGS -Iexternal-libs/include"
499 LDFLAGS="$LDFLAGS -Lexternal-libs/lib-$BUILDRULES$WINDOWS_WORDSIZE" 489 LDFLAGS="$LDFLAGS -Lexternal-libs/lib-$BUILDRULES$WINDOWS_WORDSIZE"
500 - LIBS="$LIBS -lz -lpcre" 490 + LIBS="$LIBS -lz"
501 fi 491 fi
502 492
503 AC_OUTPUT 493 AC_OUTPUT
ispell-words
@@ -727,7 +727,6 @@ lld @@ -727,7 +727,6 @@ lld
727 lookup 727 lookup
728 lossy 728 lossy
729 LowPart 729 LowPart
730 -lpcre  
731 lqpdf 730 lqpdf
732 lsb 731 lsb
733 lt 732 lt
@@ -914,7 +913,6 @@ pb @@ -914,7 +913,6 @@ pb
914 pbytes 913 pbytes
915 pc 914 pc
916 pcre 915 pcre
917 -pcreapi  
918 pdf 916 pdf
919 PDFรข 917 PDFรข
920 PDFContext 918 PDFContext
libqpdf.pc.in
@@ -6,6 +6,6 @@ includedir=@includedir@ @@ -6,6 +6,6 @@ includedir=@includedir@
6 Name: libqpdf 6 Name: libqpdf
7 Description: PDF transformation library 7 Description: PDF transformation library
8 Version: @PACKAGE_VERSION@ 8 Version: @PACKAGE_VERSION@
9 -Requires.private: zlib, libpcre 9 +Requires.private: zlib
10 Libs: -L${libdir} -lqpdf 10 Libs: -L${libdir} -lqpdf
11 Cflags: -I${includedir} 11 Cflags: -I${includedir}
libqpdf/PCRE.cc deleted
1 -#include <qpdf/PCRE.hh>  
2 -#include <qpdf/QUtil.hh>  
3 -  
4 -#include <stdexcept>  
5 -#include <iostream>  
6 -#include <string.h>  
7 -  
8 -PCRE::NoBackref::NoBackref() :  
9 - std::logic_error("PCRE error: no match")  
10 -{  
11 -}  
12 -  
13 -PCRE::Match::Match(int nbackrefs, char const* subject)  
14 -{  
15 - this->init(-1, nbackrefs, subject);  
16 -}  
17 -  
18 -PCRE::Match::~Match()  
19 -{  
20 - this->destroy();  
21 -}  
22 -  
23 -PCRE::Match::Match(Match const& rhs)  
24 -{  
25 - this->copy(rhs);  
26 -}  
27 -  
28 -PCRE::Match&  
29 -PCRE::Match::operator=(Match const& rhs)  
30 -{  
31 - if (this != &rhs)  
32 - {  
33 - this->destroy();  
34 - this->copy(rhs);  
35 - }  
36 - return *this;  
37 -}  
38 -  
39 -void  
40 -PCRE::Match::init(int nmatches, int nbackrefs, char const* subject)  
41 -{  
42 - this->nmatches = nmatches;  
43 - this->nbackrefs = nbackrefs;  
44 - this->subject = subject;  
45 - this->ovecsize = 3 * (1 + nbackrefs);  
46 - this->ovector = 0;  
47 - if (this->ovecsize)  
48 - {  
49 - this->ovector = new int[this->ovecsize];  
50 - }  
51 -}  
52 -  
53 -void  
54 -PCRE::Match::copy(Match const& rhs)  
55 -{  
56 - this->init(rhs.nmatches, rhs.nbackrefs, rhs.subject);  
57 - int i;  
58 - for (i = 0; i < this->ovecsize; ++i)  
59 - {  
60 - this->ovector[i] = rhs.ovector[i];  
61 - }  
62 -}  
63 -  
64 -void  
65 -PCRE::Match::destroy()  
66 -{  
67 - delete [] this->ovector;  
68 -}  
69 -  
70 -PCRE::Match::operator bool()  
71 -{  
72 - return (this->nmatches >= 0);  
73 -}  
74 -  
75 -std::string  
76 -PCRE::Match::getMatch(int n, int flags)  
77 -{  
78 - // This method used to be implemented in terms of  
79 - // pcre_get_substring, but that function gives you an empty string  
80 - // for an unmatched backreference that is in range.  
81 -  
82 - int offset;  
83 - int length;  
84 - try  
85 - {  
86 - getOffsetLength(n, offset, length);  
87 - }  
88 - catch (NoBackref&)  
89 - {  
90 - if (flags & gm_no_substring_returns_empty)  
91 - {  
92 - return "";  
93 - }  
94 - else  
95 - {  
96 - throw;  
97 - }  
98 - }  
99 -  
100 - return std::string(this->subject).substr(offset, length);  
101 -}  
102 -  
103 -void  
104 -PCRE::Match::getOffsetLength(int n, int& offset, int& length)  
105 -{  
106 - if ((this->nmatches < 0) ||  
107 - (n > this->nmatches - 1) ||  
108 - (this->ovector[n * 2] == -1))  
109 - {  
110 - throw NoBackref();  
111 - }  
112 - offset = this->ovector[n * 2];  
113 - length = this->ovector[n * 2 + 1] - offset;  
114 -}  
115 -  
116 -int  
117 -PCRE::Match::getOffset(int n)  
118 -{  
119 - int offset;  
120 - int length;  
121 - this->getOffsetLength(n, offset, length);  
122 - return offset;  
123 -}  
124 -  
125 -int  
126 -PCRE::Match::getLength(int n)  
127 -{  
128 - int offset;  
129 - int length;  
130 - this->getOffsetLength(n, offset, length);  
131 - return length;  
132 -}  
133 -  
134 -int  
135 -PCRE::Match::nMatches() const  
136 -{  
137 - return this->nmatches;  
138 -}  
139 -  
140 -PCRE::PCRE(char const* pattern, int options)  
141 -{  
142 - char const *errptr;  
143 - int erroffset;  
144 - this->code = pcre_compile(pattern, options, &errptr, &erroffset, 0);  
145 - if (this->code)  
146 - {  
147 - pcre_fullinfo(this->code, 0, PCRE_INFO_CAPTURECOUNT, &(this->nbackrefs));  
148 - }  
149 - else  
150 - {  
151 - std::string message = (std::string("compilation of ") + pattern +  
152 - " failed at offset " +  
153 - QUtil::int_to_string(erroffset) + ": " +  
154 - errptr);  
155 - throw std::runtime_error("PCRE error: " + message);  
156 - }  
157 -}  
158 -  
159 -PCRE::~PCRE()  
160 -{  
161 - pcre_free(this->code);  
162 -}  
163 -  
164 -PCRE::Match  
165 -PCRE::match(char const* subject, int options, int startoffset, int size)  
166 -{  
167 - if (size == -1)  
168 - {  
169 - size = strlen(subject);  
170 - }  
171 -  
172 - Match result(this->nbackrefs, subject);  
173 - int status = pcre_exec(this->code, 0, subject, size,  
174 - startoffset, options,  
175 - result.ovector, result.ovecsize);  
176 - if (status >= 0)  
177 - {  
178 - result.nmatches = status;  
179 - }  
180 - else  
181 - {  
182 - std::string message;  
183 -  
184 - switch (status)  
185 - {  
186 - case PCRE_ERROR_NOMATCH:  
187 - break;  
188 -  
189 - case PCRE_ERROR_BADOPTION:  
190 - message = "bad option passed to PCRE::match()";  
191 - throw std::logic_error(message);  
192 - break;  
193 -  
194 - case PCRE_ERROR_NOMEMORY:  
195 - message = "insufficient memory";  
196 - throw std::runtime_error(message);  
197 - break;  
198 -  
199 - case PCRE_ERROR_NULL:  
200 - case PCRE_ERROR_BADMAGIC:  
201 - case PCRE_ERROR_UNKNOWN_NODE:  
202 - default:  
203 - message = "pcre_exec returned " + QUtil::int_to_string(status);  
204 - throw std::logic_error(message);  
205 - }  
206 - }  
207 -  
208 - return result;  
209 -}  
210 -  
211 -void  
212 -PCRE::test(int n)  
213 -{  
214 - try  
215 - {  
216 - if (n == 1)  
217 - {  
218 - static char const* utf8 = "abฯ€defq";  
219 - PCRE u1("^([[:alpha:]]+)");  
220 - PCRE u2("^([\\p{L}]+)", PCRE_UTF8);  
221 - PCRE::Match m1 = u1.match(utf8);  
222 - if (m1)  
223 - {  
224 - std::cout << "no utf8: " << m1.getMatch(1) << std::endl;  
225 - }  
226 - PCRE::Match m2 = u2.match(utf8);  
227 - if (m2)  
228 - {  
229 - std::cout << "utf8: " << m2.getMatch(1) << std::endl;  
230 - }  
231 - return;  
232 - }  
233 -  
234 - try  
235 - {  
236 - PCRE pcre1("a**");  
237 - }  
238 - catch (std::exception& e)  
239 - {  
240 - std::cout << e.what() << std::endl;  
241 - }  
242 -  
243 - PCRE pcre2("^([^\\s:]*)\\s*:\\s*(.*?)\\s*$");  
244 - PCRE::Match m2 = pcre2.match("key: value one two three ");  
245 - if (m2)  
246 - {  
247 - std::cout << m2.nMatches() << std::endl;  
248 - std::cout << m2.getMatch(0) << std::endl;  
249 - std::cout << m2.getOffset(0) << std::endl;  
250 - std::cout << m2.getLength(0) << std::endl;  
251 - std::cout << m2.getMatch(1) << std::endl;  
252 - std::cout << m2.getOffset(1) << std::endl;  
253 - std::cout << m2.getLength(1) << std::endl;  
254 - std::cout << m2.getMatch(2) << std::endl;  
255 - std::cout << m2.getOffset(2) << std::endl;  
256 - std::cout << m2.getLength(2) << std::endl;  
257 - try  
258 - {  
259 - std::cout << m2.getMatch(3) << std::endl;  
260 - }  
261 - catch (std::exception& e)  
262 - {  
263 - std::cout << e.what() << std::endl;  
264 - }  
265 - try  
266 - {  
267 - std::cout << m2.getOffset(3) << std::endl;  
268 - }  
269 - catch (std::exception& e)  
270 - {  
271 - std::cout << e.what() << std::endl;  
272 - }  
273 - }  
274 - PCRE pcre3("^(a+)(b+)?$");  
275 - PCRE::Match m3 = pcre3.match("aaa");  
276 - try  
277 - {  
278 - if (m3)  
279 - {  
280 - std::cout << m3.nMatches() << std::endl;  
281 - std::cout << m3.getMatch(0) << std::endl;  
282 - std::cout << m3.getMatch(1) << std::endl;  
283 - std::cout << "-"  
284 - << m3.getMatch(  
285 - 2, Match::gm_no_substring_returns_empty)  
286 - << "-" << std::endl;  
287 - std::cout << "hello" << std::endl;  
288 - std::cout << m3.getMatch(2) << std::endl;  
289 - std::cout << "can't see this" << std::endl;  
290 - }  
291 - }  
292 - catch (std::exception& e)  
293 - {  
294 - std::cout << e.what() << std::endl;  
295 - }  
296 -  
297 - // backref: 1 2 3 4 5  
298 - PCRE pcre4("^((?:(a(b)?)(?:,(c))?)|(c))?$");  
299 - static char const* candidates[] = {  
300 - "qqqcqqq", // no match  
301 - "ab,c", // backrefs: 0, 1, 2, 3, 4  
302 - "ab", // backrefs: 0, 1, 2, 3  
303 - "a", // backrefs: 0, 1, 2  
304 - "a,c", // backrefs: 0, 1, 2, 4  
305 - "c", // backrefs: 0, 1, 5  
306 - "", // backrefs: 0  
307 - 0  
308 - };  
309 - for (char const** p = candidates; *p; ++p)  
310 - {  
311 - PCRE::Match m(pcre4.match(*p));  
312 - if (m)  
313 - {  
314 - int nmatches = m.nMatches();  
315 - for (int i = 0; i < nmatches; ++i)  
316 - {  
317 - std::cout << *p << ": " << i << ": ";  
318 - try  
319 - {  
320 - std::string match = m.getMatch(i);  
321 - std::cout << match;  
322 - }  
323 - catch (NoBackref&)  
324 - {  
325 - std::cout << "no backref (getMatch)";  
326 - }  
327 - std::cout << std::endl;  
328 -  
329 - std::cout << *p << ": " << i << ": ";  
330 - try  
331 - {  
332 - int offset;  
333 - int length;  
334 - m.getOffsetLength(i, offset, length);  
335 - std::cout << offset << ", " << length;  
336 - }  
337 - catch (NoBackref&)  
338 - {  
339 - std::cout << "no backref (getOffsetLength)";  
340 - }  
341 - std:: cout << std::endl;  
342 - }  
343 - }  
344 - else  
345 - {  
346 - std::cout << *p << ": no match" << std::endl;  
347 - }  
348 - }  
349 - }  
350 - catch (std::exception& e)  
351 - {  
352 - std::cout << "unexpected exception: " << e.what() << std::endl;  
353 - }  
354 -}  
libqpdf/build.mk
@@ -14,7 +14,6 @@ SRCS_libqpdf = \ @@ -14,7 +14,6 @@ SRCS_libqpdf = \
14 libqpdf/InsecureRandomDataProvider.cc \ 14 libqpdf/InsecureRandomDataProvider.cc \
15 libqpdf/MD5.cc \ 15 libqpdf/MD5.cc \
16 libqpdf/OffsetInputSource.cc \ 16 libqpdf/OffsetInputSource.cc \
17 - libqpdf/PCRE.cc \  
18 libqpdf/Pipeline.cc \ 17 libqpdf/Pipeline.cc \
19 libqpdf/Pl_AES_PDF.cc \ 18 libqpdf/Pl_AES_PDF.cc \
20 libqpdf/Pl_ASCII85Decoder.cc \ 19 libqpdf/Pl_ASCII85Decoder.cc \
libqpdf/qpdf/PCRE.hh deleted
1 -// This is a C++ wrapper class around Philip Hazel's perl-compatible  
2 -// regular expressions library.  
3 -//  
4 -  
5 -#ifndef __PCRE_HH__  
6 -#define __PCRE_HH__  
7 -  
8 -#include <qpdf/DLL.h>  
9 -  
10 -#ifdef _WIN32  
11 -# define PCRE_STATIC  
12 -#endif  
13 -#include <pcre.h>  
14 -#include <string>  
15 -#include <stdexcept>  
16 -  
17 -// Note: this class does not encapsulate all features of the PCRE  
18 -// package -- only those that I actually need right now are here.  
19 -  
20 -class PCRE  
21 -{  
22 - public:  
23 - // This is thrown when an attempt is made to access a non-existent  
24 - // back reference.  
25 - class NoBackref: public std::logic_error  
26 - {  
27 - public:  
28 - QPDF_DLL  
29 - NoBackref();  
30 - virtual ~NoBackref() throw() {}  
31 - };  
32 -  
33 - class Match  
34 - {  
35 - friend class PCRE;  
36 - public:  
37 - QPDF_DLL  
38 - Match(int nbackrefs, char const* subject);  
39 - QPDF_DLL  
40 - Match(Match const&);  
41 - QPDF_DLL  
42 - Match& operator=(Match const&);  
43 - QPDF_DLL  
44 - ~Match();  
45 - QPDF_DLL  
46 - operator bool();  
47 -  
48 - // All the back reference accessing routines may throw the  
49 - // special exception NoBackref (derived from Exception) if the  
50 - // back reference does not exist. Exception will be thrown  
51 - // for other error conditions. This allows callers to trap  
52 - // this condition explicitly when they care about the  
53 - // difference between a backreference matching an empty string  
54 - // and not matching at all.  
55 -  
56 - // see getMatch flags below  
57 - QPDF_DLL  
58 - std::string getMatch(int n, int flags = 0);  
59 - QPDF_DLL  
60 - void getOffsetLength(int n, int& offset, int& length);  
61 - QPDF_DLL  
62 - int getOffset(int n);  
63 - QPDF_DLL  
64 - int getLength(int n);  
65 -  
66 - // nMatches returns the number of available matches including  
67 - // match 0 which is the whole string. In other words, if you  
68 - // have one backreference in your expression and the  
69 - // expression matches, nMatches() will return 2, getMatch(0)  
70 - // will return the whole string, getMatch(1) will return the  
71 - // text that matched the backreference, and getMatch(2) will  
72 - // throw an exception because it is out of range.  
73 - QPDF_DLL  
74 - int nMatches() const;  
75 -  
76 - // Flags for getMatch  
77 -  
78 - // getMatch on a substring that didn't match should return  
79 - // empty string instead of throwing an exception  
80 - static int const gm_no_substring_returns_empty = (1 << 0);  
81 -  
82 - private:  
83 - void init(int nmatches, int nbackrefs, char const* subject);  
84 - void copy(Match const&);  
85 - void destroy();  
86 -  
87 - int nbackrefs;  
88 - char const* subject;  
89 - int* ovector;  
90 - int ovecsize;  
91 - int nmatches;  
92 - };  
93 -  
94 - // The value passed in as options is passed to pcre_exec. See man  
95 - // pcreapi for details.  
96 - QPDF_DLL  
97 - PCRE(char const* pattern, int options = 0);  
98 - QPDF_DLL  
99 - ~PCRE();  
100 -  
101 - QPDF_DLL  
102 - Match match(char const* subject, int options = 0, int startoffset = 0,  
103 - int size = -1);  
104 -  
105 - QPDF_DLL  
106 - static void test(int n = 0);  
107 -  
108 - private:  
109 - // prohibit copying and assignment  
110 - PCRE(PCRE const&);  
111 - PCRE& operator=(PCRE const&);  
112 -  
113 - pcre* code;  
114 - int nbackrefs;  
115 -};  
116 -  
117 -#endif // __PCRE_HH__  
libtests/build.mk
@@ -9,7 +9,6 @@ BINS_libtests = \ @@ -9,7 +9,6 @@ BINS_libtests = \
9 input_source \ 9 input_source \
10 lzw \ 10 lzw \
11 md5 \ 11 md5 \
12 - pcre \  
13 png_filter \ 12 png_filter \
14 pointer_holder \ 13 pointer_holder \
15 qutil \ 14 qutil \
libtests/pcre.cc deleted
1 -#include <qpdf/PCRE.hh>  
2 -#include <iostream>  
3 -#include <string.h>  
4 -  
5 -int main(int argc, char* argv[])  
6 -{  
7 - if ((argc == 2) && (strcmp(argv[1], "--unicode-classes-supported") == 0))  
8 - {  
9 - try  
10 - {  
11 - PCRE("^([\\p{L}]+)", PCRE_UTF8);  
12 - std::cout << "1" << std::endl;  
13 - }  
14 - catch (std::exception&)  
15 - {  
16 - std::cout << "0" << std::endl;  
17 - }  
18 - return 0;  
19 - }  
20 -  
21 - if ((argc == 2) && (strcmp(argv[1], "--unicode-classes") == 0))  
22 - {  
23 - PCRE::test(1);  
24 - }  
25 - else  
26 - {  
27 - PCRE::test();  
28 - }  
29 - return 0;  
30 -}  
libtests/qtest/pcre.test deleted
1 -#!/usr/bin/env perl  
2 -require 5.008;  
3 -BEGIN { $^W = 1; }  
4 -use strict;  
5 -  
6 -chdir("pcre") or die "chdir testdir failed: $!\n";  
7 -  
8 -require TestDriver;  
9 -  
10 -my $td = new TestDriver('pcre');  
11 -  
12 -$td->runtest("PCRE",  
13 - {$td->COMMAND => "pcre"},  
14 - {$td->FILE => "pcre.out",  
15 - $td->EXIT_STATUS => 0},  
16 - $td->NORMALIZE_NEWLINES);  
17 -  
18 -chop(my $supported = `pcre --unicode-classes-supported`);  
19 -if ($supported =~ m/^1/)  
20 -{  
21 - my $xflags = 0;  
22 - if (`pcre --unicode-classes | wc -l` == 1)  
23 - {  
24 - # On Red Hat Enterprise Linux 5, the version of pcre provided  
25 - # by default claims to support unicode character classes, but  
26 - # they don't actually work. Since qpdf doesn't use this  
27 - # functionality, we won't care if this particular test case  
28 - # fails. If someone were to make general use of this wrapper,  
29 - # this test should be re-enabled, but on the other hand, they  
30 - # could just use the C++ interface that's been added to pcre  
31 - # since this code was written.  
32 - $xflags |= $td->EXPECT_FAILURE;  
33 - }  
34 - $td->runtest("unicode character classes",  
35 - {$td->COMMAND => "pcre --unicode-classes"},  
36 - {$td->FILE => "pcre-unicode-classes.out",  
37 - $td->EXIT_STATUS => 0},  
38 - $td->NORMALIZE_NEWLINES | $xflags);  
39 -}  
40 -else  
41 -{  
42 - $td->runtest("unicode classes are not supported",  
43 - {$td->STRING => "1"},  
44 - {$td->STRING => "1"});  
45 -}  
46 -  
47 -$td->report(2);  
libtests/qtest/pcre/pcre-unicode-classes.out deleted
1 -no utf8: ab  
2 -utf8: abฯ€defq  
libtests/qtest/pcre/pcre.out deleted
1 -PCRE error: compilation of a** failed at offset 2: nothing to repeat  
2 -3  
3 -key: value one two three  
4 -0  
5 -25  
6 -key  
7 -0  
8 -3  
9 -value one two three  
10 -5  
11 -19  
12 -PCRE error: no match  
13 -PCRE error: no match  
14 -2  
15 -aaa  
16 -aaa  
17 ---  
18 -hello  
19 -PCRE error: no match  
20 -qqqcqqq: no match  
21 -ab,c: 0: ab,c  
22 -ab,c: 0: 0, 4  
23 -ab,c: 1: ab,c  
24 -ab,c: 1: 0, 4  
25 -ab,c: 2: ab  
26 -ab,c: 2: 0, 2  
27 -ab,c: 3: b  
28 -ab,c: 3: 1, 1  
29 -ab,c: 4: c  
30 -ab,c: 4: 3, 1  
31 -ab: 0: ab  
32 -ab: 0: 0, 2  
33 -ab: 1: ab  
34 -ab: 1: 0, 2  
35 -ab: 2: ab  
36 -ab: 2: 0, 2  
37 -ab: 3: b  
38 -ab: 3: 1, 1  
39 -a: 0: a  
40 -a: 0: 0, 1  
41 -a: 1: a  
42 -a: 1: 0, 1  
43 -a: 2: a  
44 -a: 2: 0, 1  
45 -a,c: 0: a,c  
46 -a,c: 0: 0, 3  
47 -a,c: 1: a,c  
48 -a,c: 1: 0, 3  
49 -a,c: 2: a  
50 -a,c: 2: 0, 1  
51 -a,c: 3: no backref (getMatch)  
52 -a,c: 3: no backref (getOffsetLength)  
53 -a,c: 4: c  
54 -a,c: 4: 2, 1  
55 -c: 0: c  
56 -c: 0: 0, 1  
57 -c: 1: c  
58 -c: 1: 0, 1  
59 -c: 2: no backref (getMatch)  
60 -c: 2: no backref (getOffsetLength)  
61 -c: 3: no backref (getMatch)  
62 -c: 3: no backref (getOffsetLength)  
63 -c: 4: no backref (getMatch)  
64 -c: 4: no backref (getOffsetLength)  
65 -c: 5: c  
66 -c: 5: 0, 1  
67 -: 0:  
68 -: 0: 0, 0  
manual/qpdf-manual.xml
@@ -93,7 +93,7 @@ @@ -93,7 +93,7 @@
93 <sect1 id="ref.prerequisites"> 93 <sect1 id="ref.prerequisites">
94 <title>System Requirements</title> 94 <title>System Requirements</title>
95 <para> 95 <para>
96 - The qpdf package has relatively few external dependencies. In 96 + The qpdf package has only one external dependencies. In
97 order to build qpdf, the following packages are required: 97 order to build qpdf, the following packages are required:
98 <itemizedlist> 98 <itemizedlist>
99 <listitem> 99 <listitem>
@@ -103,11 +103,6 @@ @@ -103,11 +103,6 @@
103 </listitem> 103 </listitem>
104 <listitem> 104 <listitem>
105 <para> 105 <para>
106 - pcre: <ulink url="http://www.pcre.org/">http://www.pcre.org/</ulink>  
107 - </para>  
108 - </listitem>  
109 - <listitem>  
110 - <para>  
111 gnu make 3.81 or newer: <ulink url="http://www.gnu.org/software/make">http://www.gnu.org/software/make</ulink> 106 gnu make 3.81 or newer: <ulink url="http://www.gnu.org/software/make">http://www.gnu.org/software/make</ulink>
112 </para> 107 </para>
113 </listitem> 108 </listitem>
@@ -1466,7 +1461,7 @@ outfile.pdf&lt;/option&gt; @@ -1466,7 +1461,7 @@ outfile.pdf&lt;/option&gt;
1466 </para> 1461 </para>
1467 <para> 1462 <para>
1468 When linking against the qpdf static library, you may also need to 1463 When linking against the qpdf static library, you may also need to
1469 - specify <literal>-lpcre -lz</literal> on your link command. If 1464 + specify <literal>-lz</literal> on your link command. If
1470 your system understands how to read libtool 1465 your system understands how to read libtool
1471 <filename>.la</filename> files, this may not be necessary. 1466 <filename>.la</filename> files, this may not be necessary.
1472 </para> 1467 </para>