├── .dir-locals.el
├── .gitignore
├── COPYING
├── Makefile.am
├── NEWS
├── README.ja.md
├── README.md
├── autogen.sh
├── configure.ac
├── m4
├── ax_compare_version.m4
├── ax_cxx_compile_stdcxx.m4
└── ax_cxx_compile_stdcxx_11.m4
├── man
├── Makefile.am
└── extractpdfmark.1
├── src
├── Makefile.am
├── cmdlineparse.hh
├── encodename.cc
├── iconv_wrapper.hh
├── main.cc
├── output-pdfmark.cc
├── output-pdfmark.hh
├── poppler-core
│ ├── Makefile.am
│ ├── destname-private.hh
│ ├── destname.cc
│ ├── pagemode.cc
│ ├── poppler-core.cc
│ └── poppler-core.hh
├── poppler-cpp
│ ├── Makefile.am
│ ├── destname-cpp.cc
│ ├── pagemode-cpp.cc
│ ├── poppler-cpp.cc
│ └── poppler-cpp.hh
├── poppler-glib
│ ├── Makefile.am
│ ├── destname-glib.cc
│ ├── pagemode-glib.cc
│ ├── poppler-glib.cc
│ └── poppler-glib.hh
├── utf16.cc
├── utf16.hh
├── utf8.cc
└── utf8.hh
└── test
├── Makefile.am
├── addnamedict.ps
├── binary.tex
├── destonly.tex
├── desttype.tex
├── nodest.tex
├── pagemode-fullscreen.tex
├── pagemode-thumbs.tex
├── pagemode-usenone.tex
├── pdfdocencoding.tex
├── special-chars.tex
├── test-expected-pdfmark.sh
├── test-round.sh
├── utf16.tex
└── utf8.tex
/.dir-locals.el:
--------------------------------------------------------------------------------
1 | ;;; Directory Local Variables
2 | ;;; See Info node `(emacs) Directory Variables' for more information.
3 |
4 | ((c++-mode
5 | (c-file-style . "gnu")
6 | (indent-tabs-mode . nil))
7 | (autoconf-mode
8 | (indent-tabs-mode . nil))
9 | (shellscript-mode
10 | (indent-tabs-mode . nil)))
11 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *~
2 | .\#*
3 | \#*
4 | \#.*
5 | /build/
6 | /autom4te.cache/
7 | /aclocal.m4
8 | /compile
9 | /config.h.in
10 | /configure
11 | /depcomp
12 | /install-sh
13 | Makefile.in
14 | /missing
15 | .deps/
16 | Makefile
17 | config.h
18 | config.log
19 | config.status
20 | stamp-h1
21 | *.o
22 | *.exe
23 | extractpdfmark
24 | /test-driver
25 | config.guess
26 | config.rpath
27 | config.sub
28 |
--------------------------------------------------------------------------------
/COPYING:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/Makefile.am:
--------------------------------------------------------------------------------
1 | SUBDIRS = src man test
2 |
3 | dist_doc_DATA = README.md README.ja.md COPYING NEWS
4 | EXTRA_DIST = autogen.sh
5 |
6 | ACLOCAL_AMFLAGS = -I m4
7 |
--------------------------------------------------------------------------------
/NEWS:
--------------------------------------------------------------------------------
1 | Release 1.1.1 (2022-09-30):
2 | Fix handling a named destination with an empty string name
3 | https://github.com/trueroad/extractpdfmark/issues/3
4 |
5 | Exclude deprecated poppler-core interface for poppler 0.76+
6 |
7 | Add stable poppler-glib interface for poppler 0.78.0+
8 |
9 | Release 1.1.0 (2019-02-11):
10 | Add stable poppler-cpp interface for poppler 0.74.0+
11 |
12 | Release 1.0.3 (2018-12-09):
13 | Support poppler 0.72.0
14 |
15 | Release 1.0.2 (2017-04-17):
16 | Add manpage
17 | Improve README
18 |
19 | Release 1.0.1 (2016-10-23):
20 | Add GCC 4.8.x support
21 |
22 | Release 1.0.0 (2016-10-10):
23 | Initial release
24 |
--------------------------------------------------------------------------------
/README.ja.md:
--------------------------------------------------------------------------------
1 |
2 | # Extract PDFmark
3 |
4 | [ Japanese (日本語) / [English](./README.md) ]
5 |
6 | PDF からページモードやリンクの宛先名を抽出し PDFmark として保存します
7 |
8 | https://github.com/trueroad/extractpdfmark
9 | http://www.ctan.org/pkg/extractpdfmark
10 |
11 | TeX のようなシステムを使って PDF のドキュメントを作る場合、
12 | 図としてたくさんの小さな PDF を用意して、
13 | メインの PDF に貼り付けるようなことが行われます。
14 | このとき、図の PDF では同じフォントを使っていることが多いと思います。
15 |
16 | 図の PDF にフォントのサブセットが埋め込まれていた場合、
17 | TeX システムはそのフォントをそのままメインの PDF に埋め込みます。
18 | 結果として、
19 | メイン PDF には重複した同じフォントの異なるサブセットが埋め込まれます。
20 | サブセットが異なるため重複したフォントを削除することはできません。
21 | よってメイン PDF のファイルサイズは、かなり大きくなってしまいます。
22 |
23 | 一方、図の PDF にフォントをフルセットで埋め込んだ場合、
24 | TeX システムはフルセットのフォントをメインの PDF へ埋め込みます。
25 | メイン PDF にはたくさんの重複したフォントが埋め込まれますが、
26 | すべて同じフルセットのフォントです。
27 | そのため、Ghostscript を使えば重複を削除することができ、
28 | これによってメイン PDF のサイズを低減することができます。
29 | (注意: Ghostscript 9.17 から 9.21 は重複フォント削除のために
30 | `-dPDFDontUseFontObjectNum` コマンドラインオプションが必要です。
31 | Ghostscript 9.22 以降は重複フォント削除ができなくなくなったため、
32 | フルセット埋め込みの方法を採ることができません。
33 | 詳細は https://ghostscript.com/pipermail/gs-devel/2017-September/date.html
34 | や http://lists.gnu.org/archive/html/lilypond-devel/2017-09/index.html
35 | をご覧ください。
36 | この場合は、次に示すフォントを一切埋め込まない方法を採る必要があります。)
37 |
38 | さらに、図の PDF に一切フォントを埋め込まなかった場合、
39 | TeX システムはフォントが欠けたメイン PDF を出力します。
40 | この場合、Ghostscript は必要なフォントを埋め込むことができるので、
41 | 必要なディスク容量を劇的に減らすことができるようになります。
42 | (注意: Ghostscript 9.26 以降で CID フォントを埋め込みたい場合は、
43 | https://bugs.ghostscript.com/show_bug.cgi?id=700367
44 | と https://bugs.ghostscript.com/show_bug.cgi?id=700436
45 | をご覧ください。)
46 |
47 | いずれの方法でも、
48 | Ghostscript へ TeX システムの出力したメイン PDF を入力し、
49 | 最終的な PDF を出力することになります。
50 | しかし、残念ながら、この処理で Ghostscript は PDF のページモードや
51 | リンクの宛先名を残してくれません。
52 | そのため、最終的な PDF は意図したとおりに開かれなかったり、
53 | リモートからのリンクが機能しなくなったりしてしまいます。
54 |
55 | http://bugs.ghostscript.com/show_bug.cgi?id=696943
56 | http://bugs.ghostscript.com/show_bug.cgi?id=695760
57 |
58 | Extract PDFmark は PDF からページモードやリンクの宛先名を抽出し、
59 | PDFmark として保存することができます。
60 | このツールを使うと、ページモードやリンク先名を残したまま、
61 | サイズの小さい PDF を得ることができます。
62 |
63 | ## 使い方
64 |
65 | $ extractpdfmark TeX出力.pdf > 抽出したPDFmark.ps
66 | $ gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite \
67 | -dPDFDontUseFontObjectNum -dPrinted=false \
68 | -sOutputFile=最終.pdf TeX出力.pdf 抽出したPDFmark.ps
69 |
70 | (注意: Ghostscript 9.26 以降は `-dPrinted=false`
71 | コマンドラインオプションが必要です。詳細は
72 | https://bugs.ghostscript.com/show_bug.cgi?id=699830
73 | をご覧ください。)
74 |
75 | ## バイナリパッケージからのインストール
76 |
77 | いくつかのディストリビューションには `extractpdfmark` パッケージがあります。
78 |
79 | * Debian
80 | * Ubuntu
81 | * Fedora
82 | * Cygwin
83 | * etc.
84 |
85 | ## [ソース tarball](https://github.com/trueroad/extractpdfmark/releases/download/v1.1.1/extractpdfmark-1.1.1.tar.gz) からのインストール
86 |
87 | ### 必要なもの
88 |
89 | Extract PDFmark は poppler にある 3 種類のインタフェースのうち、
90 | どれかを必要とします。
91 | Extract PDFmark をビルドする際に、どれを使用するか選択してください。
92 |
93 | #### poppler-cpp I/F (推奨)
94 |
95 | [poppler](https://poppler.freedesktop.org/) 0.74.0 以降が必要です。
96 | Extract PDFmark の configure スクリプトは、
97 | pkg-config が poppler-cpp >= 0.74.0 を見つけたら
98 | poppler-cpp I/F を選択します。
99 |
100 | configure スクリプトのオプション `--with-poppler=cpp` によって、
101 | 本 I/F の使用を明示的に指定できます。
102 |
103 | パッケージを使って準備したい場合には、以下が便利でしょう。
104 |
105 | * Debian / Ubuntu
106 | + libpoppler-cpp-dev
107 | * Fedora
108 | + poppler-cpp-devel
109 | * Cygwin
110 | + libpoppler-cpp-devel
111 |
112 | #### poppler-glib I/F
113 |
114 | [poppler](https://poppler.freedesktop.org/) 0.78.0 以降が必要です。
115 | Extract PDFmark の configure スクリプトは、
116 | pkg-config が poppler-cpp >= 0.74.0 を見つけられず、
117 | かつ poppler-glib >= 0.78.0 を見つけたら
118 | poppler-glib I/F を選択します。
119 |
120 | configure スクリプトのオプション `--with-poppler=glib` によって、
121 | 本 I/F の使用を明示的に指定できます。
122 |
123 | #### poppler-core I/F (非推奨)
124 |
125 | [poppler](https://poppler.freedesktop.org/) 0.13.3 から 0.75.0
126 | に以下のオプションをつけてビルドしたものが必要です
127 | (推奨 poppler 0.48.0 から 0.73.0)。
128 |
129 | * --enable-xpdf-headers (poppler 0.59.0 まで)
130 | * -DENABLE_XPDF_HEADERS=ON (poppler 0.60.0 から 0.72.0)
131 | * -DENABLE_UNSTABLE_API_ABI_HEADERS=ON (poppler 0.73.0 から 0.75.0)
132 |
133 | poppler 0.74.0 以降の場合は、この I/F より poppler-cpp I/F の方を推奨します。
134 | poppler 0.76.0 でこの I/F に破壊的変更が入ったため、
135 | poppler 0.76.0 以降ではこの I/F を使ったExtract PDFmarkのビルドが失敗します。
136 |
137 | Extract PDFmark の configure スクリプトは、
138 | pkg-config が poppler-cpp >= 0.74.0 を見つけられず、
139 | poppler-glib >= 0.78.0 を見つけられず、
140 | かつ poppler 0.24.4 - 0.75.0 を見つけたら
141 | poppler-core I/F を選択します。
142 | 本 I/F には private 版と通常版の 2 種類があります。
143 | poppler 0.24.4 から 0.47.0 の場合は private 版が選択されます。
144 | poppler 0.48.0 から 0.75.0 の場合は通常版が選択されます。
145 |
146 | configure スクリプトのオプション `--with-poppler=core-private` によって、
147 | private 版の使用を明示的に指定できます(poppler 0.13.3 から 0.75.0 用)。
148 | configure スクリプトのオプション `--with-poppler=core` によって、
149 | 通常版の使用を明示的に指定できます(poppler 0.48.0 から 0.75.0 用)。
150 | poppler 0.13.3 から 0.24.3 を使うには、
151 | configure スクリプトのオプション `--with-poppler=core-private` を
152 | 明示的に指定する必要があります。
153 | しかし、これらのバージョンでは Extract PDFmark の `make check`
154 | で一部のテストに失敗します。
155 |
156 | パッケージを使って準備したい場合には、以下が便利でしょう。
157 |
158 | * Debian / Ubuntu
159 | + libpoppler-private-dev
160 | + libpoppler-dev
161 | * Fedora
162 | + poppler-devel
163 | * Cygwin
164 | + libpoppler-devel
165 |
166 | ### ビルド・インストール方法
167 |
168 | $ ./configure
169 | $ make
170 | $ make install
171 |
172 | `Ghostscript` 9.14 以降と `diff` 等があれば、
173 | 以下のようにインストール前にテストすることができます。
174 |
175 | $ ./configure
176 | $ make
177 | $ make check
178 | $ make install
179 |
180 | ## [Git リポジトリ](https://github.com/trueroad/extractpdfmark)からのインストール
181 |
182 | ソース tarball のビルド要件と追加の要件が必要です。
183 |
184 | ### 追加で必要なもの
185 |
186 | Autoconf 2.69 以降
187 | Automake
188 | autopoint 0.19.6 以降(gettext 0.19.6 以降)
189 |
190 | ### 追加で推奨するもの
191 |
192 | pdfTeX (テスト PDF の生成用)
193 | Ghostscript 9.14 以降(`make check` 用)
194 |
195 | ### ビルド・インストール方法
196 |
197 | $ git clone https://github.com/trueroad/extractpdfmark.git
198 | $ cd extractpdfmark
199 | $ ./autogen.sh
200 | $ mkdir build
201 | $ cd build
202 | $ ../configure
203 | $ make
204 | $ make check
205 | $ make install
206 |
207 | ## News
208 |
209 | [News](./NEWS)
210 |
211 | ## ライセンス
212 |
213 | Copyright (C) 2016-2022 Masamichi Hosoda
214 |
215 | Extract PDFmark is free software: you can redistribute it and/or modify
216 | it under the terms of the GNU General Public License as published by
217 | the Free Software Foundation, either version 3 of the License, or
218 | (at your option) any later version.
219 |
220 | Extract PDFmark is distributed in the hope that it will be useful,
221 | but WITHOUT ANY WARRANTY; without even the implied warranty of
222 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
223 | GNU General Public License for more details.
224 |
225 | You should have received a copy of the GNU General Public License
226 | along with Extract PDFmark. If not, see .
227 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # Extract PDFmark
3 |
4 | [ [Japanese (日本語)](./README.ja.md) / English ]
5 |
6 | Extract page mode and named destinations as PDFmark from PDF
7 |
8 | https://github.com/trueroad/extractpdfmark
9 | http://www.ctan.org/pkg/extractpdfmark
10 |
11 | When you create a PDF document using something like a TeX system
12 | you may include many small PDF files in the main PDF file.
13 | It is common for each of the small PDF files to use the same fonts.
14 |
15 | If the small PDF files contain embedded font subsets,
16 | the TeX system includes them as-is in the main PDF.
17 | As a result,
18 | several subsets of the same font are embedded in the main PDF.
19 | It is not possible to remove the duplicates since they are different subsets.
20 | This vastly increases the size of the main PDF file.
21 |
22 | On the other hand,
23 | if the small PDF files contain embedded full font sets,
24 | the TeX system also includes all of them in the main PDF.
25 | This time, the main PDF contains duplicates of the same full sets of fonts.
26 | Therefore, Ghostscript can remove the duplicates.
27 | This may considerably reduce the main PDF-file's size.
28 | (Note: Ghostscript 9.17 - 9.21 needs `-dPDFDontUseFontObjectNum`
29 | commandline option for removing duplicate fonts.
30 | If you use Ghostscript 9.22+, you cannot use this "full set embedding" method
31 | since it cannot remove duplicate fonts.
32 | See https://ghostscript.com/pipermail/gs-devel/2017-September/date.html
33 | and http://lists.gnu.org/archive/html/lilypond-devel/2017-09/index.html .
34 | In this case, you can use "*not* embedding" method as following.)
35 |
36 | Finally,
37 | if the small PDF files contain some fonts that are *not* embedded,
38 | the TeX system outputs the main PDF file with some fonts missing.
39 | In this case, Ghostscript can embed the necessary fonts.
40 | It can significantly reduce the required disk size.
41 | (Note: If you use Ghostscript 9.26+ and want to embed CID fonts,
42 | see https://bugs.ghostscript.com/show_bug.cgi?id=700367
43 | and https://bugs.ghostscript.com/show_bug.cgi?id=700436 .)
44 |
45 | Either way,
46 | when Ghostscript reads the main PDF produced by the TeX system
47 | and outputs the final PDF
48 | it does not preserve PDF page-mode and named-destinations etc.
49 | As a result,
50 | when you open the final PDF,
51 | it is not displayed correctly.
52 | Also, remote PDF links will not work correctly.
53 |
54 | http://bugs.ghostscript.com/show_bug.cgi?id=696943
55 | http://bugs.ghostscript.com/show_bug.cgi?id=695760
56 |
57 | This program is able to extract page mode and named destinations
58 | as PDFmark from PDF.
59 | By using this you can get the small PDF files
60 | that have preserved them.
61 |
62 | ## Usage
63 |
64 | $ extractpdfmark TeX-System-Outputted.pdf > Extracted-PDFmark.ps
65 | $ gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite \
66 | -dPDFDontUseFontObjectNum -dPrinted=false \
67 | -sOutputFile=Final.pdf TeX-System-Outputted.pdf Extracted-PDFmark.ps
68 |
69 | (Note: Ghostscript 9.26+ needs `-dPrinted=false` commandline option.
70 | See https://bugs.ghostscript.com/show_bug.cgi?id=699830 .)
71 |
72 | ## Install from binary package
73 |
74 | Some distributions have `extractpdfmark` package.
75 |
76 | * Debian
77 | * Ubuntu
78 | * Fedora
79 | * Cygwin
80 | * etc.
81 |
82 | ## Install from [source tarball](https://github.com/trueroad/extractpdfmark/releases/download/v1.1.1/extractpdfmark-1.1.1.tar.gz)
83 |
84 | ### Required
85 |
86 | Extract PDFmark requires one of the three interfaces of poppler.
87 | Please choose which to use when building Extrcat PDFmark.
88 |
89 | #### poppler-cpp I/F (recommended)
90 |
91 | [poppler](https://poppler.freedesktop.org/) 0.74.0+ is required.
92 | Extract PDFmark's configure script selects poppler-cpp I/F
93 | if pkg-config finds poppler-cpp >= 0.74.0.
94 |
95 | The configure script's option `--with-poppler=cpp` specifies
96 | explicitly using this interface.
97 |
98 | When you would like to use packages for preparing the required library,
99 | the following might be convenient.
100 |
101 | * Debian / Ubuntu
102 | + libpoppler-cpp-dev
103 | * Fedora
104 | + poppler-cpp-devel
105 | * Cygwin
106 | + libpoppler-cpp-devel
107 |
108 | #### poppler-glib I/F
109 |
110 | [poppler](https://poppler.freedesktop.org/) 0.78.0+ is required.
111 | Extract PDFmark's configure script selects poppler-glib I/F
112 | if pkg-config does not find poppler-cpp >= 0.74.0,
113 | and finds poppler-glib 0.78.0+.
114 |
115 | The configure script's option `--with-poppler=glib` specifies
116 | explicitly using this interface.
117 |
118 | #### poppler-core I/F (deprecated)
119 |
120 | [poppler](https://poppler.freedesktop.org/) 0.13.3 - 0.75.0
121 | built with the following option is required
122 | (recommended poppler 0.48.0 - 0.73.0).
123 |
124 | * --enable-xpdf-headers (poppler 0.59.0 and before)
125 | * -DENABLE_XPDF_HEADERS=ON (poppler 0.60.0 - 0.72.0)
126 | * -DENABLE_UNSTABLE_API_ABI_HEADERS=ON (poppler 0.73.0 - 0.75.0)
127 |
128 | If you have poppler 0.74.0+, poppler-cpp I/F
129 | instead of this I/F is recommended.
130 | Extract PDFmark build with this I/F on poppler-0.76.0+ fails
131 | since poppler-0.76.0 has a disruptive change to the I/F.
132 |
133 | Extract PDFmark's configure script selects poppler-core I/F
134 | if pkg-config does not find poppler-cpp >= 0.74.0,
135 | does not find poppler-glib >= 0.78.0,
136 | and finds poppler 0.24.4 - 0.75.0.
137 | There are two versions of this interface, private and normal.
138 | For popler 0.24.4 - 0.47.0, private version is selected.
139 | For popler 0.48.0 - 0.75.0, normal version is selected.
140 |
141 | The configure script's option `--with-poppler=core-private` specifies
142 | explicitly using private version (for poppler 0.13.3 - 0.75.0).
143 | The configure script's option `--with-poppler=core` specifies
144 | explicitly using normal version (for poppler 0.48.0 - 0.75.0).
145 | If you would like to use poppler 0.13.3 - 0.24.3,
146 | it is necessary to specify explicitly configure script's option
147 | `--with-poppler=core-private`.
148 | However, Extract PDFmark with these versions of popler fails
149 | some tests in `make check`.
150 |
151 | When you would like to use packages for preparing the required library,
152 | the following might be convenient.
153 |
154 | * Debian / Ubuntu
155 | + libpoppler-private-dev
156 | + libpoppler-dev
157 | * Fedora
158 | + poppler-devel
159 | * Cygwin
160 | + libpoppler-devel
161 |
162 | ### Build & install
163 |
164 | $ ./configure
165 | $ make
166 | $ make install
167 |
168 | If you have `Ghostscript` 9.14+ and `diff` etc.,
169 | you can run tests before installation as follows.
170 |
171 | $ ./configure
172 | $ make
173 | $ make check
174 | $ make install
175 |
176 | ## Install from [Git repository](https://github.com/trueroad/extractpdfmark)
177 |
178 | Source tarball build requirements and additional requirements are necessary.
179 |
180 | ### Additional required
181 |
182 | Autoconf 2.69+
183 | Automake
184 | autopoint 0.19.6+ (gettext 0.19.6+)
185 |
186 | ### Additional recommended
187 |
188 | pdfTeX (for generating test PDFs)
189 | Ghostscript 9.14+ (for `make check`)
190 |
191 | ### Build & install
192 |
193 | $ git clone https://github.com/trueroad/extractpdfmark.git
194 | $ cd extractpdfmark
195 | $ ./autogen.sh
196 | $ mkdir build
197 | $ cd build
198 | $ ../configure
199 | $ make
200 | $ make check
201 | $ make install
202 |
203 | ## News
204 |
205 | [News](./NEWS)
206 |
207 | ## Licence
208 |
209 | Copyright (C) 2016-2022 Masamichi Hosoda
210 |
211 | Extract PDFmark is free software: you can redistribute it and/or modify
212 | it under the terms of the GNU General Public License as published by
213 | the Free Software Foundation, either version 3 of the License, or
214 | (at your option) any later version.
215 |
216 | Extract PDFmark is distributed in the hope that it will be useful,
217 | but WITHOUT ANY WARRANTY; without even the implied warranty of
218 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
219 | GNU General Public License for more details.
220 |
221 | You should have received a copy of the GNU General Public License
222 | along with Extract PDFmark. If not, see .
223 |
--------------------------------------------------------------------------------
/autogen.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | CURRENT_DIR=`pwd`
4 | AUTOPOINT_TMP_DIR=`mktemp -d autopoint.tmp.XXXXXXXXXX`
5 |
6 | echo "*** Entering temporary directory ${AUTOPOINT_TMP_DIR}"
7 | cd ${AUTOPOINT_TMP_DIR}
8 |
9 | echo
10 | echo "*** Creating dummy configure.ac"
11 | {
12 | cat < configure.ac
17 |
18 | echo
19 | echo "*** Invoking autopoint"
20 |
21 | autopoint ||
22 | {
23 | echo
24 | echo "WARNING: autopoint failed."
25 | echo "WARNING: It is required for getting \`config.rpath'."
26 | echo "WARNING: Please install autopoint 0.19.6 or newer."
27 | echo "WARNING: Depending on the platform, this is either"
28 | echo "WARNING: a separate package or part of \`gettext-devel'."
29 | }
30 |
31 | echo
32 | echo "*** Leaving temporary directory ${AUTOPOINT_TMP_DIR}"
33 | cd ${CURRENT_DIR}
34 |
35 | echo
36 | echo "*** Copying config.rpath from temporary directory"
37 | cp ${AUTOPOINT_TMP_DIR}/config.rpath . ||
38 | {
39 | echo
40 | echo "WARNING: Copy failed."
41 | if [ -e config.rpath ]; then
42 | echo "WARNING: Using existing \`config.rpath'."
43 | else
44 | echo
45 | echo "ERROR: config.rpath does not exist."
46 | echo "ERROR: Please install autopoint 0.19.6 or newer."
47 | echo "ERROR: Depending on the platform, this is either"
48 | echo "ERROR: a separate package or part of \`gettext-devel'."
49 | echo "ERROR: Or, please copy \`config.rpath'."
50 | exit 1
51 | fi
52 | }
53 |
54 | echo
55 | echo "*** Deleting temporary directory"
56 | rm -fr ${AUTOPOINT_TMP_DIR}
57 |
58 | echo
59 | echo "*** Invoking autoreconf"
60 | autoreconf -v -i
61 |
--------------------------------------------------------------------------------
/configure.ac:
--------------------------------------------------------------------------------
1 | # -*- Autoconf -*-
2 | # Process this file with autoconf to produce a configure script.
3 |
4 | AC_PREREQ([2.69])
5 | AC_INIT([Extract PDFmark], [1.1.1], , [extractpdfmark],
6 | [https://github.com/trueroad/extractpdfmark])
7 | AM_INIT_AUTOMAKE([foreign])
8 | AC_CONFIG_SRCDIR([src/main.cc])
9 | AC_CONFIG_HEADERS([config.h])
10 |
11 | PACKAGE_COPYRIGHT="Copyright (C) 2016-2022 Masamichi Hosoda"
12 | PACKAGE_LICENSE="License: GPL3+"
13 |
14 | AC_SUBST([PACKAGE_COPYRIGHT])
15 | AC_SUBST([PACKAGE_LICENSE])
16 | AC_DEFINE_UNQUOTED([PACKAGE_COPYRIGHT], ["$PACKAGE_COPYRIGHT"],
17 | [Define to the copyright of this package.])
18 | AC_DEFINE_UNQUOTED([PACKAGE_LICENSE], ["$PACKAGE_LICENSE"],
19 | [Define to the license of this package.])
20 |
21 | # Checks for programs.
22 | AC_PROG_CXX
23 | AX_CXX_COMPILE_STDCXX_11([noext], [mandatory])
24 | AC_PROG_RANLIB
25 | AC_PROG_GREP
26 |
27 | AC_PATH_PROG([DIFF], [diff])
28 | AS_IF([test "x$DIFF" = x],
29 | [AC_MSG_WARN([diff isn't found. `make check' will skip tests.])])
30 | AC_SUBST([DIFF])
31 |
32 | AC_PATH_PROG([GHOSTSCRIPT], [gs])
33 | AS_IF([test ! "x$GHOSTSCRIPT" = x],
34 | [AC_MSG_CHECKING([for gs version ( >= 9.14 )])
35 | gs_ver=`$GHOSTSCRIPT --version`
36 | AX_COMPARE_VERSION([$gs_ver], [ge], [9.14],
37 | [AC_MSG_RESULT([yes])],
38 | [AC_MSG_RESULT([no])
39 | GHOSTSCRIPT=])])
40 | AM_CONDITIONAL([HAVE_GHOSTSCRIPT], [test ! "x$GHOSTSCRIPT" = x])
41 | AM_COND_IF([HAVE_GHOSTSCRIPT],
42 | ,
43 | [AC_MSG_WARN(
44 | [Ghostscript isn't found. `make check' will skip some tests.])])
45 | AC_SUBST([GHOSTSCRIPT])
46 |
47 | AC_MSG_CHECKING([for pre-generated test PDFs])
48 | AS_IF([test ! -e ${srcdir}/test/desttype.pdf],
49 | [AC_MSG_RESULT([no])
50 | AC_PATH_PROG([PDFTEX], [pdftex])
51 | AS_IF([test "x$PDFTEX" = x],
52 | [AC_MSG_WARN(
53 | [pdftex isn't found. Test PDFs cannot be generated.])
54 | AC_MSG_WARN(
55 | [You cannot use `make check'.])],
56 | [AM_COND_IF([HAVE_GHOSTSCRIPT],
57 | [AC_MSG_NOTICE(
58 | [pdftex is found. Test PDFs will be generated.])],
59 | [AC_MSG_WARN(
60 | [pdftex is found but ghostscript isn't found.])
61 | AC_MSG_WARN(
62 | [You cannot use `make check'.])])])],
63 | [AC_MSG_RESULT([yes])])
64 | AC_SUBST([PDFTEX])
65 |
66 | AC_MSG_CHECKING([for pre-generated expected PDFmark files])
67 | AS_IF([test ! -e ${srcdir}/test/desttype-expected.pdfmark],
68 | [AC_MSG_RESULT([no])
69 | AC_MSG_WARN(
70 | [PDFmark files will be generated.])
71 | AC_MSG_WARN(
72 | [`make check' cannot compare with the correct expected results.])],
73 | [AC_MSG_RESULT([yes])])
74 |
75 | # Checks for libraries.
76 | PKG_PROG_PKG_CONFIG
77 |
78 | AC_ARG_WITH([poppler],
79 | AS_HELP_STRING([--with-poppler=@<:@auto|cpp|glib|core|core-private@:>@],
80 | [Poppler I/F (default: auto)]),
81 | ,
82 | [with_poppler=auto])
83 | AS_CASE(["$with_poppler"],
84 | ["cpp"],
85 | [AC_MSG_NOTICE([--with-poppler=cpp requires poppler >= 0.74.0])
86 | PKG_CHECK_MODULES([POPPLER_CPP], [poppler-cpp >= 0.74.0])],
87 | ["glib"],
88 | [AC_MSG_NOTICE([--with-poppler=glib requires poppler >= 0.78.0])
89 | PKG_CHECK_MODULES([POPPLER_GLIB], [poppler-glib >= 0.78.0])],
90 | ["core"],
91 | [AC_MSG_NOTICE(
92 | [--with-poppler=core requires poppler 0.48.0 - 0.75.0])
93 | PKG_CHECK_MODULES([POPPLER],
94 | [poppler >= 0.48.0 poppler <= 0.75.0])],
95 | ["core-private"],
96 | [AC_MSG_NOTICE(
97 | [--with-poppler=core-private requires poppler 0.13.3 - 0.75.0])
98 | PKG_CHECK_MODULES([POPPLER],
99 | [poppler >= 0.24.4 poppler <= 0.75.0],,
100 | [PKG_CHECK_MODULES([POPPLER], [poppler >= 0.19.2],
101 | [AC_MSG_WARN([poppler < 0.24.4 is found.])
102 | AC_MSG_WARN([`make check' will fail some tests.])],
103 | [PKG_CHECK_MODULES([POPPLER], [poppler >= 0.13.3])
104 | AC_MSG_WARN([poppler < 0.19.2 is found.])
105 | AC_MSG_WARN([`make check' will fail some tests.])
106 | AC_DEFINE_UNQUOTED([POPPLER_CORE_IF_VERSION],
107 | ["`$PKG_CONFIG --modversion poppler`"],
108 | [Define poppler version if POPPLER_VERSION cannot be used.])])])],
109 | ["auto"],
110 | [AC_MSG_NOTICE([selecting for --with-poppler=auto])
111 | AC_MSG_NOTICE([ trying for cpp (poppler-cpp >= 0.74.0)])
112 | PKG_CHECK_MODULES(
113 | [POPPLER_CPP], [poppler-cpp >= 0.74.0],
114 | [with_poppler="cpp"],
115 | [AC_MSG_NOTICE([ trying for glib (poppler-glib >= 0.78.0)])
116 | PKG_CHECK_MODULES(
117 | [POPPLER_GLIB], [poppler-glib >= 0.78.0],
118 | [with_poppler="glib"],
119 | [AC_MSG_NOTICE(
120 | [ trying for core (poppler 0.48.0 - 0.75.0)])
121 | PKG_CHECK_MODULES(
122 | [POPPLER], [poppler >= 0.48.0 poppler <= 0.75.0],
123 | [with_poppler="core"],
124 | [AC_MSG_NOTICE(
125 | [ trying for core-private (poppler >= 0.24.4)])
126 | PKG_CHECK_MODULES([POPPLER],
127 | [poppler >= 0.24.4 poppler <= 0.75.0],
128 | [with_poppler="core-private"])])])])
129 | AC_MSG_NOTICE([use --with-poppler=$with_poppler])],
130 | [AC_MSG_ERROR([unrecognized --with-poppler argument: $with_poppler])])
131 | AS_CASE(["$with_poppler"],
132 | ["cpp"],
133 | [POPPLER_IF="poppler-cpp"
134 | use_library="cpp"],
135 | ["glib"],
136 | [POPPLER_IF="poppler-glib"
137 | use_library="glib"],
138 | ["core"],
139 | [POPPLER_IF="poppler-core"
140 | use_library="core"
141 | AC_DEFINE([HAVE_POPPLER_CORE_IF], [1],
142 | [Define if poppler-core is selected])],
143 | ["core-private"],
144 | [POPPLER_IF="poppler-core private"
145 | use_library="core"],
146 | [AC_MSG_ERROR([programming error])])
147 | AM_CONDITIONAL([USE_POPPLER_CORE], [test $use_library = core])
148 | AM_CONDITIONAL([USE_POPPLER_GLIB], [test $use_library = glib])
149 | AM_CONDITIONAL([USE_POPPLER_CPP], [test $use_library = cpp])
150 | AC_DEFINE_UNQUOTED([PACKAGE_STRING], ["$PACKAGE_STRING (with $POPPLER_IF)"],
151 | [Define to the full name and version, method of this package.])
152 |
153 | # Checks for header files.
154 | AM_COND_IF([USE_POPPLER_CORE],
155 | [AC_LANG_PUSH([C++])
156 | TEMP_CPPFLAGS=$CPPFLAGS
157 | CPPFLAGS="$CPPFLAGS $POPPLER_CFLAGS"
158 | AC_CHECK_HEADERS([Link.h PDFDoc.h PDFDocFactory.h],
159 | ,
160 | [AC_MSG_ERROR([poppler xpdf headers are not found.])])
161 | CPPFLAGS=$TMP_CPPFLAGS
162 | AC_LANG_POP])
163 |
164 | AC_ARG_ENABLE([codecvt],
165 | [AS_HELP_STRING(
166 | [--enable-codecvt],
167 | [enable codecvt for UTF-8 checking (default is disable)])],
168 | ,
169 | [enable_codecvt=no])
170 | AS_IF([test "x$enable_codecvt" != xno],
171 | [AC_LANG_PUSH([C++])
172 | AC_CHECK_HEADERS([codecvt])
173 | AC_LANG_POP])
174 | AS_IF([test "x$ac_cv_header_codecvt" == xyes],
175 | [AC_DEFINE([USE_CODECVT], [1], [Define if codecvt is enabled.])])
176 |
177 | AC_ARG_ENABLE([iconv],
178 | [AS_HELP_STRING(
179 | [--disable-iconv],
180 | [disable iconv for UTF-8 checking (default is enable)])],
181 | ,
182 | [enable_iconv=yes])
183 | # AM_ICONV does not seem to be able to put in IF block.
184 | AM_ICONV
185 | AM_CONDITIONAL([USE_ICONV],
186 | [test "x$enable_iconv" = xyes && \
187 | test "x$am_cv_func_iconv" = xyes && \
188 | test "x$ac_cv_header_codecvt" != xyes])
189 | AM_COND_IF([USE_ICONV],
190 | [AC_DEFINE([USE_ICONV], [1], [Define if iconv is enabled.])],
191 | [AS_IF([test "x$ac_cv_header_codecvt" != xyes],
192 | [AC_MSG_WARN(
193 | [Some `make check' will fail since both codecvt and iconv are disabled.])])])
194 |
195 | # Checks for typedefs, structures, and compiler characteristics.
196 | AM_COND_IF([USE_POPPLER_CORE],
197 | [AC_LANG_PUSH([C++])
198 | TEMP_CPPFLAGS=$CPPFLAGS
199 | CPPFLAGS="$CPPFLAGS $POPPLER_CFLAGS"
200 | AC_MSG_CHECKING([for poppler's GooString::c_str ()])
201 | AC_COMPILE_IFELSE(
202 | [AC_LANG_PROGRAM(
203 | [[ #include ]],
204 | [[ GooString goo; const char *dummy = goo.c_str (); ]])],
205 | [AC_MSG_RESULT([yes])
206 | AC_DEFINE([HAS_GOOSTRING_C_STR], [1],
207 | [Define if poppler's GooString::c_str () exists])],
208 | [AC_MSG_RESULT([no])])
209 | CPPFLAGS=$TMP_CPPFLAGS
210 | AC_LANG_POP])
211 |
212 | # Checks for library functions.
213 |
214 | AC_CONFIG_FILES([Makefile
215 | src/Makefile
216 | src/poppler-core/Makefile
217 | src/poppler-glib/Makefile
218 | src/poppler-cpp/Makefile
219 | man/Makefile
220 | test/Makefile])
221 | AC_OUTPUT
222 |
--------------------------------------------------------------------------------
/m4/ax_compare_version.m4:
--------------------------------------------------------------------------------
1 | # ===========================================================================
2 | # https://www.gnu.org/software/autoconf-archive/ax_compare_version.html
3 | # ===========================================================================
4 | #
5 | # SYNOPSIS
6 | #
7 | # AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
8 | #
9 | # DESCRIPTION
10 | #
11 | # This macro compares two version strings. Due to the various number of
12 | # minor-version numbers that can exist, and the fact that string
13 | # comparisons are not compatible with numeric comparisons, this is not
14 | # necessarily trivial to do in a autoconf script. This macro makes doing
15 | # these comparisons easy.
16 | #
17 | # The six basic comparisons are available, as well as checking equality
18 | # limited to a certain number of minor-version levels.
19 | #
20 | # The operator OP determines what type of comparison to do, and can be one
21 | # of:
22 | #
23 | # eq - equal (test A == B)
24 | # ne - not equal (test A != B)
25 | # le - less than or equal (test A <= B)
26 | # ge - greater than or equal (test A >= B)
27 | # lt - less than (test A < B)
28 | # gt - greater than (test A > B)
29 | #
30 | # Additionally, the eq and ne operator can have a number after it to limit
31 | # the test to that number of minor versions.
32 | #
33 | # eq0 - equal up to the length of the shorter version
34 | # ne0 - not equal up to the length of the shorter version
35 | # eqN - equal up to N sub-version levels
36 | # neN - not equal up to N sub-version levels
37 | #
38 | # When the condition is true, shell commands ACTION-IF-TRUE are run,
39 | # otherwise shell commands ACTION-IF-FALSE are run. The environment
40 | # variable 'ax_compare_version' is always set to either 'true' or 'false'
41 | # as well.
42 | #
43 | # Examples:
44 | #
45 | # AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8])
46 | # AX_COMPARE_VERSION([3.15],[lt],[3.15.8])
47 | #
48 | # would both be true.
49 | #
50 | # AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8])
51 | # AX_COMPARE_VERSION([3.15],[gt],[3.15.8])
52 | #
53 | # would both be false.
54 | #
55 | # AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8])
56 | #
57 | # would be true because it is only comparing two minor versions.
58 | #
59 | # AX_COMPARE_VERSION([3.15.7],[eq0],[3.15])
60 | #
61 | # would be true because it is only comparing the lesser number of minor
62 | # versions of the two values.
63 | #
64 | # Note: The characters that separate the version numbers do not matter. An
65 | # empty string is the same as version 0. OP is evaluated by autoconf, not
66 | # configure, so must be a string, not a variable.
67 | #
68 | # The author would like to acknowledge Guido Draheim whose advice about
69 | # the m4_case and m4_ifvaln functions make this macro only include the
70 | # portions necessary to perform the specific comparison specified by the
71 | # OP argument in the final configure script.
72 | #
73 | # LICENSE
74 | #
75 | # Copyright (c) 2008 Tim Toolan
76 | #
77 | # Copying and distribution of this file, with or without modification, are
78 | # permitted in any medium without royalty provided the copyright notice
79 | # and this notice are preserved. This file is offered as-is, without any
80 | # warranty.
81 |
82 | #serial 13
83 |
84 | dnl #########################################################################
85 | AC_DEFUN([AX_COMPARE_VERSION], [
86 | AC_REQUIRE([AC_PROG_AWK])
87 |
88 | # Used to indicate true or false condition
89 | ax_compare_version=false
90 |
91 | # Convert the two version strings to be compared into a format that
92 | # allows a simple string comparison. The end result is that a version
93 | # string of the form 1.12.5-r617 will be converted to the form
94 | # 0001001200050617. In other words, each number is zero padded to four
95 | # digits, and non digits are removed.
96 | AS_VAR_PUSHDEF([A],[ax_compare_version_A])
97 | A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \
98 | -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \
99 | -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \
100 | -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \
101 | -e 's/[[^0-9]]//g'`
102 |
103 | AS_VAR_PUSHDEF([B],[ax_compare_version_B])
104 | B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \
105 | -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \
106 | -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \
107 | -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \
108 | -e 's/[[^0-9]]//g'`
109 |
110 | dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary
111 | dnl # then the first line is used to determine if the condition is true.
112 | dnl # The sed right after the echo is to remove any indented white space.
113 | m4_case(m4_tolower($2),
114 | [lt],[
115 | ax_compare_version=`echo "x$A
116 | x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"`
117 | ],
118 | [gt],[
119 | ax_compare_version=`echo "x$A
120 | x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"`
121 | ],
122 | [le],[
123 | ax_compare_version=`echo "x$A
124 | x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"`
125 | ],
126 | [ge],[
127 | ax_compare_version=`echo "x$A
128 | x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"`
129 | ],[
130 | dnl Split the operator from the subversion count if present.
131 | m4_bmatch(m4_substr($2,2),
132 | [0],[
133 | # A count of zero means use the length of the shorter version.
134 | # Determine the number of characters in A and B.
135 | ax_compare_version_len_A=`echo "$A" | $AWK '{print(length)}'`
136 | ax_compare_version_len_B=`echo "$B" | $AWK '{print(length)}'`
137 |
138 | # Set A to no more than B's length and B to no more than A's length.
139 | A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"`
140 | B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"`
141 | ],
142 | [[0-9]+],[
143 | # A count greater than zero means use only that many subversions
144 | A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`
145 | B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`
146 | ],
147 | [.+],[
148 | AC_WARNING(
149 | [invalid OP numeric parameter: $2])
150 | ],[])
151 |
152 | # Pad zeros at end of numbers to make same length.
153 | ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`"
154 | B="$B`echo $A | sed 's/./0/g'`"
155 | A="$ax_compare_version_tmp_A"
156 |
157 | # Check for equality or inequality as necessary.
158 | m4_case(m4_tolower(m4_substr($2,0,2)),
159 | [eq],[
160 | test "x$A" = "x$B" && ax_compare_version=true
161 | ],
162 | [ne],[
163 | test "x$A" != "x$B" && ax_compare_version=true
164 | ],[
165 | AC_WARNING([invalid OP parameter: $2])
166 | ])
167 | ])
168 |
169 | AS_VAR_POPDEF([A])dnl
170 | AS_VAR_POPDEF([B])dnl
171 |
172 | dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE.
173 | if test "$ax_compare_version" = "true" ; then
174 | m4_ifvaln([$4],[$4],[:])dnl
175 | m4_ifvaln([$5],[else $5])dnl
176 | fi
177 | ]) dnl AX_COMPARE_VERSION
178 |
--------------------------------------------------------------------------------
/m4/ax_cxx_compile_stdcxx.m4:
--------------------------------------------------------------------------------
1 | # ===========================================================================
2 | # https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html
3 | # ===========================================================================
4 | #
5 | # SYNOPSIS
6 | #
7 | # AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional])
8 | #
9 | # DESCRIPTION
10 | #
11 | # Check for baseline language coverage in the compiler for the specified
12 | # version of the C++ standard. If necessary, add switches to CXX and
13 | # CXXCPP to enable support. VERSION may be '11', '14', '17', or '20' for
14 | # the respective C++ standard version.
15 | #
16 | # The second argument, if specified, indicates whether you insist on an
17 | # extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
18 | # -std=c++11). If neither is specified, you get whatever works, with
19 | # preference for no added switch, and then for an extended mode.
20 | #
21 | # The third argument, if specified 'mandatory' or if left unspecified,
22 | # indicates that baseline support for the specified C++ standard is
23 | # required and that the macro should error out if no mode with that
24 | # support is found. If specified 'optional', then configuration proceeds
25 | # regardless, after defining HAVE_CXX${VERSION} if and only if a
26 | # supporting mode is found.
27 | #
28 | # LICENSE
29 | #
30 | # Copyright (c) 2008 Benjamin Kosnik
31 | # Copyright (c) 2012 Zack Weinberg
32 | # Copyright (c) 2013 Roy Stogner
33 | # Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov
34 | # Copyright (c) 2015 Paul Norman
35 | # Copyright (c) 2015 Moritz Klammler
36 | # Copyright (c) 2016, 2018 Krzesimir Nowak
37 | # Copyright (c) 2019 Enji Cooper
38 | # Copyright (c) 2020 Jason Merrill
39 | # Copyright (c) 2021 Jörn Heusipp
40 | #
41 | # Copying and distribution of this file, with or without modification, are
42 | # permitted in any medium without royalty provided the copyright notice
43 | # and this notice are preserved. This file is offered as-is, without any
44 | # warranty.
45 |
46 | #serial 15
47 |
48 | dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
49 | dnl (serial version number 13).
50 |
51 | AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
52 | m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"],
53 | [$1], [14], [ax_cxx_compile_alternatives="14 1y"],
54 | [$1], [17], [ax_cxx_compile_alternatives="17 1z"],
55 | [$1], [20], [ax_cxx_compile_alternatives="20"],
56 | [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl
57 | m4_if([$2], [], [],
58 | [$2], [ext], [],
59 | [$2], [noext], [],
60 | [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl
61 | m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true],
62 | [$3], [mandatory], [ax_cxx_compile_cxx$1_required=true],
63 | [$3], [optional], [ax_cxx_compile_cxx$1_required=false],
64 | [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])])
65 | AC_LANG_PUSH([C++])dnl
66 | ac_success=no
67 |
68 | m4_if([$2], [], [dnl
69 | AC_CACHE_CHECK(whether $CXX supports C++$1 features by default,
70 | ax_cv_cxx_compile_cxx$1,
71 | [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
72 | [ax_cv_cxx_compile_cxx$1=yes],
73 | [ax_cv_cxx_compile_cxx$1=no])])
74 | if test x$ax_cv_cxx_compile_cxx$1 = xyes; then
75 | ac_success=yes
76 | fi])
77 |
78 | m4_if([$2], [noext], [], [dnl
79 | if test x$ac_success = xno; then
80 | for alternative in ${ax_cxx_compile_alternatives}; do
81 | switch="-std=gnu++${alternative}"
82 | cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
83 | AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
84 | $cachevar,
85 | [ac_save_CXX="$CXX"
86 | CXX="$CXX $switch"
87 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
88 | [eval $cachevar=yes],
89 | [eval $cachevar=no])
90 | CXX="$ac_save_CXX"])
91 | if eval test x\$$cachevar = xyes; then
92 | CXX="$CXX $switch"
93 | if test -n "$CXXCPP" ; then
94 | CXXCPP="$CXXCPP $switch"
95 | fi
96 | ac_success=yes
97 | break
98 | fi
99 | done
100 | fi])
101 |
102 | m4_if([$2], [ext], [], [dnl
103 | if test x$ac_success = xno; then
104 | dnl HP's aCC needs +std=c++11 according to:
105 | dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf
106 | dnl Cray's crayCC needs "-h std=c++11"
107 | for alternative in ${ax_cxx_compile_alternatives}; do
108 | for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
109 | cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
110 | AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
111 | $cachevar,
112 | [ac_save_CXX="$CXX"
113 | CXX="$CXX $switch"
114 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
115 | [eval $cachevar=yes],
116 | [eval $cachevar=no])
117 | CXX="$ac_save_CXX"])
118 | if eval test x\$$cachevar = xyes; then
119 | CXX="$CXX $switch"
120 | if test -n "$CXXCPP" ; then
121 | CXXCPP="$CXXCPP $switch"
122 | fi
123 | ac_success=yes
124 | break
125 | fi
126 | done
127 | if test x$ac_success = xyes; then
128 | break
129 | fi
130 | done
131 | fi])
132 | AC_LANG_POP([C++])
133 | if test x$ax_cxx_compile_cxx$1_required = xtrue; then
134 | if test x$ac_success = xno; then
135 | AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.])
136 | fi
137 | fi
138 | if test x$ac_success = xno; then
139 | HAVE_CXX$1=0
140 | AC_MSG_NOTICE([No compiler with C++$1 support was found])
141 | else
142 | HAVE_CXX$1=1
143 | AC_DEFINE(HAVE_CXX$1,1,
144 | [define if the compiler supports basic C++$1 syntax])
145 | fi
146 | AC_SUBST(HAVE_CXX$1)
147 | ])
148 |
149 |
150 | dnl Test body for checking C++11 support
151 |
152 | m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11],
153 | _AX_CXX_COMPILE_STDCXX_testbody_new_in_11
154 | )
155 |
156 | dnl Test body for checking C++14 support
157 |
158 | m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14],
159 | _AX_CXX_COMPILE_STDCXX_testbody_new_in_11
160 | _AX_CXX_COMPILE_STDCXX_testbody_new_in_14
161 | )
162 |
163 | dnl Test body for checking C++17 support
164 |
165 | m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17],
166 | _AX_CXX_COMPILE_STDCXX_testbody_new_in_11
167 | _AX_CXX_COMPILE_STDCXX_testbody_new_in_14
168 | _AX_CXX_COMPILE_STDCXX_testbody_new_in_17
169 | )
170 |
171 | dnl Test body for checking C++20 support
172 |
173 | m4_define([_AX_CXX_COMPILE_STDCXX_testbody_20],
174 | _AX_CXX_COMPILE_STDCXX_testbody_new_in_11
175 | _AX_CXX_COMPILE_STDCXX_testbody_new_in_14
176 | _AX_CXX_COMPILE_STDCXX_testbody_new_in_17
177 | _AX_CXX_COMPILE_STDCXX_testbody_new_in_20
178 | )
179 |
180 |
181 | dnl Tests for new features in C++11
182 |
183 | m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
184 |
185 | // If the compiler admits that it is not ready for C++11, why torture it?
186 | // Hopefully, this will speed up the test.
187 |
188 | #ifndef __cplusplus
189 |
190 | #error "This is not a C++ compiler"
191 |
192 | // MSVC always sets __cplusplus to 199711L in older versions; newer versions
193 | // only set it correctly if /Zc:__cplusplus is specified as well as a
194 | // /std:c++NN switch:
195 | // https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
196 | #elif __cplusplus < 201103L && !defined _MSC_VER
197 |
198 | #error "This is not a C++11 compiler"
199 |
200 | #else
201 |
202 | namespace cxx11
203 | {
204 |
205 | namespace test_static_assert
206 | {
207 |
208 | template
209 | struct check
210 | {
211 | static_assert(sizeof(int) <= sizeof(T), "not big enough");
212 | };
213 |
214 | }
215 |
216 | namespace test_final_override
217 | {
218 |
219 | struct Base
220 | {
221 | virtual ~Base() {}
222 | virtual void f() {}
223 | };
224 |
225 | struct Derived : public Base
226 | {
227 | virtual ~Derived() override {}
228 | virtual void f() override {}
229 | };
230 |
231 | }
232 |
233 | namespace test_double_right_angle_brackets
234 | {
235 |
236 | template < typename T >
237 | struct check {};
238 |
239 | typedef check single_type;
240 | typedef check> double_type;
241 | typedef check>> triple_type;
242 | typedef check>>> quadruple_type;
243 |
244 | }
245 |
246 | namespace test_decltype
247 | {
248 |
249 | int
250 | f()
251 | {
252 | int a = 1;
253 | decltype(a) b = 2;
254 | return a + b;
255 | }
256 |
257 | }
258 |
259 | namespace test_type_deduction
260 | {
261 |
262 | template < typename T1, typename T2 >
263 | struct is_same
264 | {
265 | static const bool value = false;
266 | };
267 |
268 | template < typename T >
269 | struct is_same
270 | {
271 | static const bool value = true;
272 | };
273 |
274 | template < typename T1, typename T2 >
275 | auto
276 | add(T1 a1, T2 a2) -> decltype(a1 + a2)
277 | {
278 | return a1 + a2;
279 | }
280 |
281 | int
282 | test(const int c, volatile int v)
283 | {
284 | static_assert(is_same::value == true, "");
285 | static_assert(is_same::value == false, "");
286 | static_assert(is_same::value == false, "");
287 | auto ac = c;
288 | auto av = v;
289 | auto sumi = ac + av + 'x';
290 | auto sumf = ac + av + 1.0;
291 | static_assert(is_same::value == true, "");
292 | static_assert(is_same::value == true, "");
293 | static_assert(is_same::value == true, "");
294 | static_assert(is_same::value == false, "");
295 | static_assert(is_same::value == true, "");
296 | return (sumf > 0.0) ? sumi : add(c, v);
297 | }
298 |
299 | }
300 |
301 | namespace test_noexcept
302 | {
303 |
304 | int f() { return 0; }
305 | int g() noexcept { return 0; }
306 |
307 | static_assert(noexcept(f()) == false, "");
308 | static_assert(noexcept(g()) == true, "");
309 |
310 | }
311 |
312 | namespace test_constexpr
313 | {
314 |
315 | template < typename CharT >
316 | unsigned long constexpr
317 | strlen_c_r(const CharT *const s, const unsigned long acc) noexcept
318 | {
319 | return *s ? strlen_c_r(s + 1, acc + 1) : acc;
320 | }
321 |
322 | template < typename CharT >
323 | unsigned long constexpr
324 | strlen_c(const CharT *const s) noexcept
325 | {
326 | return strlen_c_r(s, 0UL);
327 | }
328 |
329 | static_assert(strlen_c("") == 0UL, "");
330 | static_assert(strlen_c("1") == 1UL, "");
331 | static_assert(strlen_c("example") == 7UL, "");
332 | static_assert(strlen_c("another\0example") == 7UL, "");
333 |
334 | }
335 |
336 | namespace test_rvalue_references
337 | {
338 |
339 | template < int N >
340 | struct answer
341 | {
342 | static constexpr int value = N;
343 | };
344 |
345 | answer<1> f(int&) { return answer<1>(); }
346 | answer<2> f(const int&) { return answer<2>(); }
347 | answer<3> f(int&&) { return answer<3>(); }
348 |
349 | void
350 | test()
351 | {
352 | int i = 0;
353 | const int c = 0;
354 | static_assert(decltype(f(i))::value == 1, "");
355 | static_assert(decltype(f(c))::value == 2, "");
356 | static_assert(decltype(f(0))::value == 3, "");
357 | }
358 |
359 | }
360 |
361 | namespace test_uniform_initialization
362 | {
363 |
364 | struct test
365 | {
366 | static const int zero {};
367 | static const int one {1};
368 | };
369 |
370 | static_assert(test::zero == 0, "");
371 | static_assert(test::one == 1, "");
372 |
373 | }
374 |
375 | namespace test_lambdas
376 | {
377 |
378 | void
379 | test1()
380 | {
381 | auto lambda1 = [](){};
382 | auto lambda2 = lambda1;
383 | lambda1();
384 | lambda2();
385 | }
386 |
387 | int
388 | test2()
389 | {
390 | auto a = [](int i, int j){ return i + j; }(1, 2);
391 | auto b = []() -> int { return '0'; }();
392 | auto c = [=](){ return a + b; }();
393 | auto d = [&](){ return c; }();
394 | auto e = [a, &b](int x) mutable {
395 | const auto identity = [](int y){ return y; };
396 | for (auto i = 0; i < a; ++i)
397 | a += b--;
398 | return x + identity(a + b);
399 | }(0);
400 | return a + b + c + d + e;
401 | }
402 |
403 | int
404 | test3()
405 | {
406 | const auto nullary = [](){ return 0; };
407 | const auto unary = [](int x){ return x; };
408 | using nullary_t = decltype(nullary);
409 | using unary_t = decltype(unary);
410 | const auto higher1st = [](nullary_t f){ return f(); };
411 | const auto higher2nd = [unary](nullary_t f1){
412 | return [unary, f1](unary_t f2){ return f2(unary(f1())); };
413 | };
414 | return higher1st(nullary) + higher2nd(nullary)(unary);
415 | }
416 |
417 | }
418 |
419 | namespace test_variadic_templates
420 | {
421 |
422 | template
423 | struct sum;
424 |
425 | template
426 | struct sum
427 | {
428 | static constexpr auto value = N0 + sum::value;
429 | };
430 |
431 | template <>
432 | struct sum<>
433 | {
434 | static constexpr auto value = 0;
435 | };
436 |
437 | static_assert(sum<>::value == 0, "");
438 | static_assert(sum<1>::value == 1, "");
439 | static_assert(sum<23>::value == 23, "");
440 | static_assert(sum<1, 2>::value == 3, "");
441 | static_assert(sum<5, 5, 11>::value == 21, "");
442 | static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, "");
443 |
444 | }
445 |
446 | // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
447 | // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function
448 | // because of this.
449 | namespace test_template_alias_sfinae
450 | {
451 |
452 | struct foo {};
453 |
454 | template
455 | using member = typename T::member_type;
456 |
457 | template
458 | void func(...) {}
459 |
460 | template
461 | void func(member*) {}
462 |
463 | void test();
464 |
465 | void test() { func(0); }
466 |
467 | }
468 |
469 | } // namespace cxx11
470 |
471 | #endif // __cplusplus >= 201103L
472 |
473 | ]])
474 |
475 |
476 | dnl Tests for new features in C++14
477 |
478 | m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[
479 |
480 | // If the compiler admits that it is not ready for C++14, why torture it?
481 | // Hopefully, this will speed up the test.
482 |
483 | #ifndef __cplusplus
484 |
485 | #error "This is not a C++ compiler"
486 |
487 | #elif __cplusplus < 201402L && !defined _MSC_VER
488 |
489 | #error "This is not a C++14 compiler"
490 |
491 | #else
492 |
493 | namespace cxx14
494 | {
495 |
496 | namespace test_polymorphic_lambdas
497 | {
498 |
499 | int
500 | test()
501 | {
502 | const auto lambda = [](auto&&... args){
503 | const auto istiny = [](auto x){
504 | return (sizeof(x) == 1UL) ? 1 : 0;
505 | };
506 | const int aretiny[] = { istiny(args)... };
507 | return aretiny[0];
508 | };
509 | return lambda(1, 1L, 1.0f, '1');
510 | }
511 |
512 | }
513 |
514 | namespace test_binary_literals
515 | {
516 |
517 | constexpr auto ivii = 0b0000000000101010;
518 | static_assert(ivii == 42, "wrong value");
519 |
520 | }
521 |
522 | namespace test_generalized_constexpr
523 | {
524 |
525 | template < typename CharT >
526 | constexpr unsigned long
527 | strlen_c(const CharT *const s) noexcept
528 | {
529 | auto length = 0UL;
530 | for (auto p = s; *p; ++p)
531 | ++length;
532 | return length;
533 | }
534 |
535 | static_assert(strlen_c("") == 0UL, "");
536 | static_assert(strlen_c("x") == 1UL, "");
537 | static_assert(strlen_c("test") == 4UL, "");
538 | static_assert(strlen_c("another\0test") == 7UL, "");
539 |
540 | }
541 |
542 | namespace test_lambda_init_capture
543 | {
544 |
545 | int
546 | test()
547 | {
548 | auto x = 0;
549 | const auto lambda1 = [a = x](int b){ return a + b; };
550 | const auto lambda2 = [a = lambda1(x)](){ return a; };
551 | return lambda2();
552 | }
553 |
554 | }
555 |
556 | namespace test_digit_separators
557 | {
558 |
559 | constexpr auto ten_million = 100'000'000;
560 | static_assert(ten_million == 100000000, "");
561 |
562 | }
563 |
564 | namespace test_return_type_deduction
565 | {
566 |
567 | auto f(int& x) { return x; }
568 | decltype(auto) g(int& x) { return x; }
569 |
570 | template < typename T1, typename T2 >
571 | struct is_same
572 | {
573 | static constexpr auto value = false;
574 | };
575 |
576 | template < typename T >
577 | struct is_same
578 | {
579 | static constexpr auto value = true;
580 | };
581 |
582 | int
583 | test()
584 | {
585 | auto x = 0;
586 | static_assert(is_same::value, "");
587 | static_assert(is_same::value, "");
588 | return x;
589 | }
590 |
591 | }
592 |
593 | } // namespace cxx14
594 |
595 | #endif // __cplusplus >= 201402L
596 |
597 | ]])
598 |
599 |
600 | dnl Tests for new features in C++17
601 |
602 | m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
603 |
604 | // If the compiler admits that it is not ready for C++17, why torture it?
605 | // Hopefully, this will speed up the test.
606 |
607 | #ifndef __cplusplus
608 |
609 | #error "This is not a C++ compiler"
610 |
611 | #elif __cplusplus < 201703L && !defined _MSC_VER
612 |
613 | #error "This is not a C++17 compiler"
614 |
615 | #else
616 |
617 | #include
618 | #include
619 | #include
620 |
621 | namespace cxx17
622 | {
623 |
624 | namespace test_constexpr_lambdas
625 | {
626 |
627 | constexpr int foo = [](){return 42;}();
628 |
629 | }
630 |
631 | namespace test::nested_namespace::definitions
632 | {
633 |
634 | }
635 |
636 | namespace test_fold_expression
637 | {
638 |
639 | template
640 | int multiply(Args... args)
641 | {
642 | return (args * ... * 1);
643 | }
644 |
645 | template
646 | bool all(Args... args)
647 | {
648 | return (args && ...);
649 | }
650 |
651 | }
652 |
653 | namespace test_extended_static_assert
654 | {
655 |
656 | static_assert (true);
657 |
658 | }
659 |
660 | namespace test_auto_brace_init_list
661 | {
662 |
663 | auto foo = {5};
664 | auto bar {5};
665 |
666 | static_assert(std::is_same, decltype(foo)>::value);
667 | static_assert(std::is_same::value);
668 | }
669 |
670 | namespace test_typename_in_template_template_parameter
671 | {
672 |
673 | template typename X> struct D;
674 |
675 | }
676 |
677 | namespace test_fallthrough_nodiscard_maybe_unused_attributes
678 | {
679 |
680 | int f1()
681 | {
682 | return 42;
683 | }
684 |
685 | [[nodiscard]] int f2()
686 | {
687 | [[maybe_unused]] auto unused = f1();
688 |
689 | switch (f1())
690 | {
691 | case 17:
692 | f1();
693 | [[fallthrough]];
694 | case 42:
695 | f1();
696 | }
697 | return f1();
698 | }
699 |
700 | }
701 |
702 | namespace test_extended_aggregate_initialization
703 | {
704 |
705 | struct base1
706 | {
707 | int b1, b2 = 42;
708 | };
709 |
710 | struct base2
711 | {
712 | base2() {
713 | b3 = 42;
714 | }
715 | int b3;
716 | };
717 |
718 | struct derived : base1, base2
719 | {
720 | int d;
721 | };
722 |
723 | derived d1 {{1, 2}, {}, 4}; // full initialization
724 | derived d2 {{}, {}, 4}; // value-initialized bases
725 |
726 | }
727 |
728 | namespace test_general_range_based_for_loop
729 | {
730 |
731 | struct iter
732 | {
733 | int i;
734 |
735 | int& operator* ()
736 | {
737 | return i;
738 | }
739 |
740 | const int& operator* () const
741 | {
742 | return i;
743 | }
744 |
745 | iter& operator++()
746 | {
747 | ++i;
748 | return *this;
749 | }
750 | };
751 |
752 | struct sentinel
753 | {
754 | int i;
755 | };
756 |
757 | bool operator== (const iter& i, const sentinel& s)
758 | {
759 | return i.i == s.i;
760 | }
761 |
762 | bool operator!= (const iter& i, const sentinel& s)
763 | {
764 | return !(i == s);
765 | }
766 |
767 | struct range
768 | {
769 | iter begin() const
770 | {
771 | return {0};
772 | }
773 |
774 | sentinel end() const
775 | {
776 | return {5};
777 | }
778 | };
779 |
780 | void f()
781 | {
782 | range r {};
783 |
784 | for (auto i : r)
785 | {
786 | [[maybe_unused]] auto v = i;
787 | }
788 | }
789 |
790 | }
791 |
792 | namespace test_lambda_capture_asterisk_this_by_value
793 | {
794 |
795 | struct t
796 | {
797 | int i;
798 | int foo()
799 | {
800 | return [*this]()
801 | {
802 | return i;
803 | }();
804 | }
805 | };
806 |
807 | }
808 |
809 | namespace test_enum_class_construction
810 | {
811 |
812 | enum class byte : unsigned char
813 | {};
814 |
815 | byte foo {42};
816 |
817 | }
818 |
819 | namespace test_constexpr_if
820 | {
821 |
822 | template
823 | int f ()
824 | {
825 | if constexpr(cond)
826 | {
827 | return 13;
828 | }
829 | else
830 | {
831 | return 42;
832 | }
833 | }
834 |
835 | }
836 |
837 | namespace test_selection_statement_with_initializer
838 | {
839 |
840 | int f()
841 | {
842 | return 13;
843 | }
844 |
845 | int f2()
846 | {
847 | if (auto i = f(); i > 0)
848 | {
849 | return 3;
850 | }
851 |
852 | switch (auto i = f(); i + 4)
853 | {
854 | case 17:
855 | return 2;
856 |
857 | default:
858 | return 1;
859 | }
860 | }
861 |
862 | }
863 |
864 | namespace test_template_argument_deduction_for_class_templates
865 | {
866 |
867 | template
868 | struct pair
869 | {
870 | pair (T1 p1, T2 p2)
871 | : m1 {p1},
872 | m2 {p2}
873 | {}
874 |
875 | T1 m1;
876 | T2 m2;
877 | };
878 |
879 | void f()
880 | {
881 | [[maybe_unused]] auto p = pair{13, 42u};
882 | }
883 |
884 | }
885 |
886 | namespace test_non_type_auto_template_parameters
887 | {
888 |
889 | template
890 | struct B
891 | {};
892 |
893 | B<5> b1;
894 | B<'a'> b2;
895 |
896 | }
897 |
898 | namespace test_structured_bindings
899 | {
900 |
901 | int arr[2] = { 1, 2 };
902 | std::pair pr = { 1, 2 };
903 |
904 | auto f1() -> int(&)[2]
905 | {
906 | return arr;
907 | }
908 |
909 | auto f2() -> std::pair&
910 | {
911 | return pr;
912 | }
913 |
914 | struct S
915 | {
916 | int x1 : 2;
917 | volatile double y1;
918 | };
919 |
920 | S f3()
921 | {
922 | return {};
923 | }
924 |
925 | auto [ x1, y1 ] = f1();
926 | auto& [ xr1, yr1 ] = f1();
927 | auto [ x2, y2 ] = f2();
928 | auto& [ xr2, yr2 ] = f2();
929 | const auto [ x3, y3 ] = f3();
930 |
931 | }
932 |
933 | namespace test_exception_spec_type_system
934 | {
935 |
936 | struct Good {};
937 | struct Bad {};
938 |
939 | void g1() noexcept;
940 | void g2();
941 |
942 | template
943 | Bad
944 | f(T*, T*);
945 |
946 | template
947 | Good
948 | f(T1*, T2*);
949 |
950 | static_assert (std::is_same_v);
951 |
952 | }
953 |
954 | namespace test_inline_variables
955 | {
956 |
957 | template void f(T)
958 | {}
959 |
960 | template inline T g(T)
961 | {
962 | return T{};
963 | }
964 |
965 | template<> inline void f<>(int)
966 | {}
967 |
968 | template<> int g<>(int)
969 | {
970 | return 5;
971 | }
972 |
973 | }
974 |
975 | } // namespace cxx17
976 |
977 | #endif // __cplusplus < 201703L && !defined _MSC_VER
978 |
979 | ]])
980 |
981 |
982 | dnl Tests for new features in C++20
983 |
984 | m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_20], [[
985 |
986 | #ifndef __cplusplus
987 |
988 | #error "This is not a C++ compiler"
989 |
990 | #elif __cplusplus < 202002L && !defined _MSC_VER
991 |
992 | #error "This is not a C++20 compiler"
993 |
994 | #else
995 |
996 | #include
997 |
998 | namespace cxx20
999 | {
1000 |
1001 | // As C++20 supports feature test macros in the standard, there is no
1002 | // immediate need to actually test for feature availability on the
1003 | // Autoconf side.
1004 |
1005 | } // namespace cxx20
1006 |
1007 | #endif // __cplusplus < 202002L && !defined _MSC_VER
1008 |
1009 | ]])
1010 |
--------------------------------------------------------------------------------
/m4/ax_cxx_compile_stdcxx_11.m4:
--------------------------------------------------------------------------------
1 | # =============================================================================
2 | # https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
3 | # =============================================================================
4 | #
5 | # SYNOPSIS
6 | #
7 | # AX_CXX_COMPILE_STDCXX_11([ext|noext], [mandatory|optional])
8 | #
9 | # DESCRIPTION
10 | #
11 | # Check for baseline language coverage in the compiler for the C++11
12 | # standard; if necessary, add switches to CXX and CXXCPP to enable
13 | # support.
14 | #
15 | # This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX
16 | # macro with the version set to C++11. The two optional arguments are
17 | # forwarded literally as the second and third argument respectively.
18 | # Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for
19 | # more information. If you want to use this macro, you also need to
20 | # download the ax_cxx_compile_stdcxx.m4 file.
21 | #
22 | # LICENSE
23 | #
24 | # Copyright (c) 2008 Benjamin Kosnik
25 | # Copyright (c) 2012 Zack Weinberg
26 | # Copyright (c) 2013 Roy Stogner
27 | # Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov
28 | # Copyright (c) 2015 Paul Norman
29 | # Copyright (c) 2015 Moritz Klammler
30 | #
31 | # Copying and distribution of this file, with or without modification, are
32 | # permitted in any medium without royalty provided the copyright notice
33 | # and this notice are preserved. This file is offered as-is, without any
34 | # warranty.
35 |
36 | #serial 18
37 |
38 | AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX])
39 | AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [AX_CXX_COMPILE_STDCXX([11], [$1], [$2])])
40 |
--------------------------------------------------------------------------------
/man/Makefile.am:
--------------------------------------------------------------------------------
1 | man_MANS = extractpdfmark.1
2 | EXTRA_DIST = $(man_MANS)
3 |
--------------------------------------------------------------------------------
/man/extractpdfmark.1:
--------------------------------------------------------------------------------
1 | .TH EXTRACTPDFMARK 1 "January 26, 2019"
2 | .SH NAME
3 | extractpdfmark \- Extract page mode and named destinations as PDFmark from PDF
4 | .SH SYNOPSIS
5 | .B extractpdfmark
6 | .IR file.pdf " > " file.ps
7 | .SH DESCRIPTION
8 | This manual page documents briefly the
9 | .B extractpdfmark
10 | command.
11 | .PP
12 | When you create a PDF document using a TeX system, you may include
13 | many small PDF files in the main PDF file.
14 | It is common for each of those files to use the same fonts.
15 | .PP
16 | If the small PDF files contain embedded font subsets, the TeX system
17 | includes them as-is in the main PDF.
18 | As a result, several subsets of the same font are embedded in the main PDF.
19 | It is not possible to remove the duplicates since the subsets differ.
20 | This vastly increases the size of the main PDF file.
21 | .PP
22 | On the other hand, if the small PDF files contain embedded full font
23 | sets, the TeX system also includes all of them in the main PDF.
24 | This time, the main PDF contains duplicates of the same full sets of
25 | fonts.
26 | Therefore, Ghostscript can remove the duplicates.
27 | This may considerably reduce the main PDF\-file's size.
28 | (Note: Ghostscript 9.17 - 9.21 needs
29 | .I -dPDFDontUseFontObjectNum
30 | commandline option for removing duplicate fonts.
31 | If you use Ghostscript 9.22+, you cannot use this "full set embedding" method
32 | since it cannot remove duplicate fonts.
33 | In this case, you can use "*not* embedding" method as following.)
34 | .PP
35 | Finally, if the small PDF files contain some fonts that are not
36 | embedded, the TeX system outputs the main PDF file with some fonts
37 | missing.
38 | In this case, Ghostscript can embed the necessary fonts.
39 | It can also significantly reduce the required disk size.
40 | .PP
41 | Either way, when Ghostscript reads the main PDF produced by the
42 | TeX system and outputs the final PDF it does not preserve PDF
43 | page\-mode and named\-destinations, etc.
44 | As a result, when you open the final PDF, it is not displayed correctly.
45 | Also, remote PDF links will not work.
46 | .PP
47 | This program is able to extract the page mode and named destinations
48 | as PDFmark from PDF.
49 | By using this you can get the small PDF files that have preserved them.
50 | .SH EXAMPLE
51 | .EX
52 | $ extractpdfmark TeX-System-Outputted.pdf > Extracted-PDFmark.ps
53 | $ gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite \e
54 | -dPDFDontUseFontObjectNum -dPrinted=false \e
55 | -sOutputFile=Final.pdf \e
56 | TeX-System-Outputted.pdf Extracted-PDFmark.ps
57 | .EE
58 | .PP
59 | (Note: Ghostscript 9.26+ needs
60 | .I -dPrinted=false
61 | commandline option.)
62 |
--------------------------------------------------------------------------------
/src/Makefile.am:
--------------------------------------------------------------------------------
1 | SUBDIRS =
2 |
3 | bin_PROGRAMS = extractpdfmark
4 | extractpdfmark_SOURCES = main.cc cmdlineparse.hh \
5 | output-pdfmark.cc output-pdfmark.hh \
6 | encodename.cc \
7 | utf16.cc utf16.hh \
8 | utf8.cc utf8.hh
9 |
10 | extractpdfmark_LDADD =
11 | extractpdfmark_LDFLAGS =
12 | extractpdfmark_DEPENDENCIES =
13 |
14 | if USE_POPPLER_CORE
15 | SUBDIRS += poppler-core
16 | extractpdfmark_LDADD += -lextractpdfmark-poppler-core $(POPPLER_LIBS)
17 | extractpdfmark_LDFLAGS += -L./poppler-core
18 | extractpdfmark_DEPENDENCIES += ./poppler-core/libextractpdfmark-poppler-core.a
19 | endif
20 |
21 | if USE_POPPLER_GLIB
22 | SUBDIRS += poppler-glib
23 | extractpdfmark_LDADD += -lextractpdfmark-poppler-glib $(POPPLER_GLIB_LIBS)
24 | extractpdfmark_LDFLAGS += -L./poppler-glib
25 | extractpdfmark_DEPENDENCIES += ./poppler-glib/libextractpdfmark-poppler-glib.a
26 | endif
27 |
28 | if USE_POPPLER_CPP
29 | SUBDIRS += poppler-cpp
30 | extractpdfmark_LDADD += -lextractpdfmark-poppler-cpp $(POPPLER_CPP_LIBS)
31 | extractpdfmark_LDFLAGS += -L./poppler-cpp
32 | extractpdfmark_DEPENDENCIES += ./poppler-cpp/libextractpdfmark-poppler-cpp.a
33 | endif
34 |
35 | if USE_ICONV
36 | extractpdfmark_SOURCES += iconv_wrapper.hh
37 | extractpdfmark_LDADD += $(LIBICONV)
38 | endif
39 |
--------------------------------------------------------------------------------
/src/cmdlineparse.hh:
--------------------------------------------------------------------------------
1 | //
2 | // One header file Commandline Parse for C++11 2017-01-29.01 GPL
3 | // https://github.com/trueroad/cmdlineparse/
4 | //
5 | // Copyright (C) 2016, 2017 Masamichi Hosoda
6 | //
7 | // One header file Commandline Parse for C++11 is free software:
8 | // you can redistribute it and/or modify
9 | // it under the terms of the GNU General Public License as published by
10 | // the Free Software Foundation, either version 3 of the License, or
11 | // (at your option) any later version.
12 | //
13 | // One header file Commandline Parse for C++11 is distributed
14 | // in the hope that it will be useful,
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | // GNU General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU General Public License
20 | // along with One header file Commandline Parse for C++11.
21 | // If not, see .
22 | //
23 |
24 | #ifndef INCLUDE_GUARD_CMDLINEPARSE_HH
25 | #define INCLUDE_GUARD_CMDLINEPARSE_HH
26 |
27 | #include
28 | #include