summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Egger <christoph@christoph-egger.org>2017-01-25 10:51:28 +0100
committerChristoph Egger <christoph@christoph-egger.org>2017-01-25 10:51:28 +0100
commit6e289327635da561225e54b4e6b5f9baa01042e7 (patch)
tree54364a76d30ed01c3e7a2f0738a5f675c4485daa
parent5470c465b2c8ce6a361c875b095a45469056628a (diff)
Imported Upstream version 2.0
-rw-r--r--AUTHORS5
-rw-r--r--CONTRIBUTING.md36
-rw-r--r--HACKING39
-rw-r--r--Makefile.am6
-rw-r--r--Makefile.in34
-rw-r--r--NEWS76
-rw-r--r--NEWS.md93
-rw-r--r--README.asciidoc67
-rw-r--r--README.md75
-rw-r--r--TODO13
-rw-r--r--aclocal.m4347
-rw-r--r--completion/Makefile.in17
-rw-r--r--completion/_pdfgrep65
-rw-r--r--completion/pdfgrep97
-rwxr-xr-xconfig.guess1421
-rw-r--r--config.h.in6
-rwxr-xr-xconfig.sub1807
-rwxr-xr-xconfigure382
-rw-r--r--configure.ac45
-rw-r--r--doc/Makefile.in17
-rw-r--r--doc/pdfgrep.169
-rw-r--r--doc/pdfgrep.txt43
-rw-r--r--src/Makefile.am6
-rw-r--r--src/Makefile.in31
-rw-r--r--src/cache.cc164
-rw-r--r--src/cache.h48
-rw-r--r--src/exclude.cc6
-rw-r--r--src/exclude.h2
-rw-r--r--src/output.cc285
-rw-r--r--src/output.h79
-rw-r--r--src/pdfgrep.cc635
-rw-r--r--src/pdfgrep.h60
-rw-r--r--src/regengine.cc124
-rw-r--r--src/regengine.h20
-rw-r--r--src/search.cc270
-rw-r--r--src/search.h37
-rw-r--r--testsuite/Makefile.am4
-rw-r--r--testsuite/Makefile.in25
-rw-r--r--testsuite/README.md13
-rw-r--r--testsuite/config/Makefile.in17
-rw-r--r--testsuite/global-conf.exp5
-rw-r--r--testsuite/lib/Makefile.in17
-rw-r--r--testsuite/lib/pdfgrep.exp42
-rw-r--r--testsuite/pdfgrep.tests/Makefile.am4
-rw-r--r--testsuite/pdfgrep.tests/Makefile.in21
-rw-r--r--testsuite/pdfgrep.tests/cache.exp149
-rw-r--r--testsuite/pdfgrep.tests/color.exp1
-rw-r--r--testsuite/pdfgrep.tests/context.exp413
-rw-r--r--testsuite/pdfgrep.tests/exit_status.exp6
-rw-r--r--testsuite/pdfgrep.tests/misc.exp60
-rw-r--r--testsuite/pdfgrep.tests/regex.exp119
-rw-r--r--testsuite/pdfgrep.tests/usage.exp2
52 files changed, 6236 insertions, 1189 deletions
diff --git a/AUTHORS b/AUTHORS
index 931273e..c9ded34 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -13,3 +13,8 @@ Other people that have contributed code to the project:
Thibault Marin
Julius Plenz
Florian Schmaus
+ Rainer Müller
+ Christoph Egger
+ Christian Dietrich
+ Anish Mistry
+ Oliver Kiddle
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..865e121
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,36 @@
+If you want to contribute to pdfgrep, this file is for you!
+
+# Contributing
+
+You don't have to write code to help pdfgrep. Testing, reporting bugs,
+writing/fixing documentation or packaging it for distributions is just
+as important. If you want to help, just drop me[1] a mail.
+
+For those who rather get their hands dirty with code, please read the
+following sections:
+
+# Coding Style
+
+The pdfgrep source is formatted in the classical Linux-kernel style
+described in Documentation/CodingStyle in the kernel's source tree.
+
+In particular this means that we use tabs for indentation.
+
+The code is written in a C-ish C++, which means we use classes
+sparingly and everything is mostly held in a procedural style.
+
+But: These are just guidelines. If a C++ feature makes sense to you,
+use it! If a (minor) violation of the indentation rules makes the code
+more readable: do it!
+
+# Sending Patches
+
+You can either send your patches directly to me[1], to the mailing-list[2] or
+create a pull request on GitLab[3].
+
+
+Keep on hacking!
+
+[1]: mailto:hpd@hpdeifel.de
+[2]: mailto:pdfgrep-users@pdfgrep.org
+[3]: https://gitlab.com/pdfgrep/pdfgrep
diff --git a/HACKING b/HACKING
deleted file mode 100644
index 65e5c11..0000000
--- a/HACKING
+++ /dev/null
@@ -1,39 +0,0 @@
-If you want to contribute to pdfgrep, this file is for you!
-
-* Contributing
-
-You don't have to write code to help pdfgrep. Testing, reporting bugs,
-writing/fixing documentation or packaging it for distributions is just
-as important. If you want to help, just drop me [1] a mail.
-
-For those who rather get their hands dirty with code, please read the
-following sections:
-
-* Coding Style
-
-The pdfgrep source is formatted in the classical Linux-kernel style
-described in Documentation/CodingStyle in the kernel's source tree.
-
-In particular this means that we use tabs for indentation.
-
-The code is written in a very Cish C++, that is: Use C++ where we need
-it to access the poppler API and C otherwise. The reason for this is
-that I feel that most of C++'s features would increase the complexity
-of such a small project like pdfgrep and make it difficult to use
-standard Posix functions (e.g. std::string and regcomp/regexec).
-
-BUT: These are just guidelines. If a C++ feature makes sense to you,
-use it! If a (minor) violation of the indentation rules makes the code
-more readable: do it!
-
-* Sending Patches
-
-You can either send your patches directly to me [1], to the mailing-list [2] or
-create a pull request on GitLab [3].
-
-
-Keep on hacking!
-
-[1] mailto:hpd@hpdeifel.de
-[2] mailto:pdfgrep-users@pdfgrep.org
-[3] https://gitlab.com/pdfgrep/pdfgrep
diff --git a/Makefile.am b/Makefile.am
index 217ebc8..dd0be8d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
ACLOCAL_AMFLAGS = -I m4
-EXTRA_DIST=autogen.sh README.asciidoc HACKING
+EXTRA_DIST=autogen.sh README.md CONTRIBUTING.md NEWS.md
SUBDIRS = src completion doc testsuite
@@ -18,6 +18,10 @@ cov-reset:
.PHONY: cov-report
cov-report:
+ @gcovr -r src/
+
+.PHONY: cov-report-html
+cov-report-html: coverage
@mkdir -p coverage_report
@lcov --directory src/ --capture --no-external --output-file coverage_report/pdfgrep.info
@genhtml -o coverage_report/ coverage_report/pdfgrep.info
diff --git a/Makefile.in b/Makefile.in
index 728766d..f534a4e 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -85,6 +85,8 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \
@@ -157,7 +159,8 @@ CTAGS = ctags
CSCOPE = cscope
DIST_SUBDIRS = $(SUBDIRS)
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in AUTHORS \
- COPYING INSTALL NEWS TODO compile depcomp install-sh missing
+ COPYING INSTALL compile config.guess config.sub depcomp \
+ install-sh missing
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
@@ -218,7 +221,6 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
-DEJAGNU = @DEJAGNU@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
@@ -229,14 +231,16 @@ GREP = @GREP@
HAVE_A2X = @HAVE_A2X@
HAVE_CXX11 = @HAVE_CXX11@
HAVE_GCOV = @HAVE_GCOV@
-HAVE_GENHTML = @HAVE_GENHTML@
-HAVE_LCOV = @HAVE_LCOV@
+HAVE_GCOVR = @HAVE_GCOVR@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
+LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
+LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
+LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
@@ -271,7 +275,11 @@ am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
+build = @build@
build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
builddir = @builddir@
cov_CFLAGS = @cov_CFLAGS@
cov_LDFLAGS = @cov_LDFLAGS@
@@ -280,7 +288,11 @@ datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
+host = @host@
host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
@@ -311,7 +323,7 @@ top_srcdir = @top_srcdir@
unac_CFLAGS = @unac_CFLAGS@
unac_LIBS = @unac_LIBS@
ACLOCAL_AMFLAGS = -I m4
-EXTRA_DIST = autogen.sh README.asciidoc HACKING
+EXTRA_DIST = autogen.sh README.md CONTRIBUTING.md NEWS.md
SUBDIRS = src completion doc testsuite
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
@@ -537,7 +549,7 @@ distdir: $(DISTFILES)
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r "$(distdir)"
dist-gzip: distdir
- tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+ tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz
$(am__post_remove_distdir)
dist-bzip2: distdir
@@ -563,7 +575,7 @@ dist-shar: distdir
@echo WARNING: "Support for shar distribution archives is" \
"deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
- shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+ shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz
$(am__post_remove_distdir)
dist-zip: distdir
@@ -581,7 +593,7 @@ dist dist-all:
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
- GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
+ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lz*) \
@@ -591,7 +603,7 @@ distcheck: dist
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
- GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
+ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
@@ -797,6 +809,10 @@ uninstall-am:
@ENABLE_COV_TRUE@.PHONY: cov-report
@ENABLE_COV_TRUE@cov-report:
+@ENABLE_COV_TRUE@ @gcovr -r src/
+
+@ENABLE_COV_TRUE@.PHONY: cov-report-html
+@ENABLE_COV_TRUE@cov-report-html: coverage
@ENABLE_COV_TRUE@ @mkdir -p coverage_report
@ENABLE_COV_TRUE@ @lcov --directory src/ --capture --no-external --output-file coverage_report/pdfgrep.info
@ENABLE_COV_TRUE@ @genhtml -o coverage_report/ coverage_report/pdfgrep.info
diff --git a/NEWS b/NEWS
deleted file mode 100644
index 1115773..0000000
--- a/NEWS
+++ /dev/null
@@ -1,76 +0,0 @@
-Version 1.4.0 [2015-09-24]
----------------------------
-
- - Test suite added
- - Bugfix: The tarball contains HACKING and README again
- - Bugfix: The zsh completion completes options as first
- argument correctly
- - Bugfix: Exit status is set as advertised
- - Bugfix: Spurious null bytes removed from output
- - Bugfix: Skipping of some matches in certain conditions fixed.
- - Bugfix: Empty matches don't trigger a loop
-
-Version 1.4.0 [2015-08-14]
----------------------------
-
- - PCRE support (by Julius Plenz)
- - Fixed string search
- - Ability to pass multiple passwords
- - Option to change the colon as prefix separator
- - Optional warning about PDFs that contain no searchable text
- - New option from grep: +--only-matching+
- - New option from grep: +--null+
- - Bugfix: Correctly print unicode characters
- - Installation: New configure flag +--without-libpcre+
- - Installation: New configure flag +--disable-doc+ to disable
- manpage generation with asciidoc
- - Installation: pdfgrep now requires c++11
-
-Version 1.3.2 [2015-02-20]
------------------------------
-
- - A bash completion module
- - Don't limit output to 80 characters on non-terminals
- - Print a lot less error messages by default (only with
- >= poppler-0.30.0)
- - New option +--debug+ to print verbose debug output
- - Installation: New configure flag +--with-zsh-completion+
-
-Version 1.3.1 [2014-08-10]
------------------------------
-
- - *Incompatible change*: +-r+ doesn't follow symlinks
- - A zsh completion module
- - Support for password-protected PDFs
- - Allow to omit '.' with +-r+ to search current directory
- - Add +-p+ or +--page-count+ to count matches per page (by Jascha Knack)
- - Add +-m+ or +--max-count+ to limit matches per file (by Thibault Marin)
-
-Version 1.3.0 [2012-02-14]
------------------------------
-
- - Experimental support for libunac (removing accents and ligatures
- before search)
- - Recursive search [+--recursive+] (by Mahmut Gundes)
- - Don't use colors on dumb terminals
- - A few minor bug fixes
- - Use poppler-cpp instead of the poppler core library (by Pino Toscano)
-
-Version 1.2
------------
-
- - 2 small bugfixes (+-h+ option and closing open files)
- - This is probably the last release that supports poppler < 0.14
-
-Version 1.1
------------
-
- - Respect the +GREP_COLORS+ environment variable
- - Fix buffer overflow bug
- - Don't exit on the first error
- - Use terminal width to calculate the context length
-
-Version 1.0
------------
-
- - First release
diff --git a/NEWS.md b/NEWS.md
new file mode 100644
index 0000000..dbd8bcc
--- /dev/null
+++ b/NEWS.md
@@ -0,0 +1,93 @@
+Version 2.0 [2017-01-25]
+-------------------------
+
+ - **Incompatible change**: `--context/-C` is now line based as opposed to
+ character based and works just like grep
+ - Two new options from grep: `-A/--after-context` and `-B/--before-context`
+ - Lines with multiple matches are now printed only once
+ - Optional caching of pdf-text for faster operation (by Christian Dietrich)
+ This adds a **new dependency**: libgcrypt
+ - Bash-completion improvements (by Rainer Müller)
+ - Bugfix: Fixed string search (`-F`) now works as advertised with multiple
+ patterns
+ - Bugfix: Empty pages can now be matched with `^$`
+ - Bugfix: The pattern `^` now matches *only* at the beginning of pages
+ - Bugfix: Text outside of PDF's CropBox but inside the MediaBox is not
+ ignored anymore.
+ - Various fixes for BSD support
+
+Version 1.4.1 [2015-09-26]
+---------------------------
+
+ - Test suite added
+ - Bugfix: The tarball contains HACKING and README again
+ - Bugfix: The zsh completion completes options as first
+ argument correctly
+ - Bugfix: Exit status is set as advertised
+ - Bugfix: Spurious null bytes removed from output
+ - Bugfix: Skipping of some matches in certain conditions fixed.
+ - Bugfix: Empty matches don't trigger a loop
+
+Version 1.4.0 [2015-08-14]
+---------------------------
+
+ - PCRE support (by Julius Plenz)
+ - Fixed string search
+ - Ability to pass multiple passwords
+ - Option to change the colon as prefix separator
+ - Optional warning about PDFs that contain no searchable text
+ - New option from grep: `--only-matching`
+ - New option from grep: `--null`
+ - Bugfix: Correctly print unicode characters
+ - Installation: New configure flag `--without-libpcre`
+ - Installation: New configure flag `--disable-doc` to disable
+ manpage generation with asciidoc
+ - Installation: pdfgrep now requires c++11
+
+Version 1.3.2 [2015-02-20]
+-----------------------------
+
+ - A bash completion module
+ - Don't limit output to 80 characters on non-terminals
+ - Print a lot less error messages by default (only with >= poppler-0.30.0)
+ - New option `--debug` to print verbose debug output
+ - Installation: New configure flag `--with-zsh-completion`
+
+Version 1.3.1 [2014-08-10]
+-----------------------------
+
+ - **Incompatible change**: `-r` doesn't follow symlinks
+ - A zsh completion module
+ - Support for password-protected PDFs
+ - Allow to omit '.' with `-r` to search current directory
+ - Add `-p` or `--page-count` to count matches per page (by Jascha Knack)
+ - Add `-m` or `--max-count` to limit matches per file (by Thibault Marin)
+
+Version 1.3.0 [2012-02-14]
+-----------------------------
+
+ - Experimental support for libunac (removing accents and ligatures
+ before search)
+ - Recursive search [`--recursive`] (by Mahmut Gundes)
+ - Don't use colors on dumb terminals
+ - A few minor bug fixes
+ - Use poppler-cpp instead of the poppler core library (by Pino Toscano)
+
+Version 1.2
+-----------
+
+ - 2 small bugfixes (`-h` option and closing open files)
+ - This is probably the last release that supports poppler < 0.14
+
+Version 1.1
+-----------
+
+ - Respect the `GREP_COLORS` environment variable
+ - Fix buffer overflow bug
+ - Don't exit on the first error
+ - Use terminal width to calculate the context length
+
+Version 1.0
+-----------
+
+ - First release
diff --git a/README.asciidoc b/README.asciidoc
deleted file mode 100644
index 3f9969d..0000000
--- a/README.asciidoc
+++ /dev/null
@@ -1,67 +0,0 @@
-== Overview
-
-_Pdfgrep_ is a tool to search text in PDF files. It works similarly to _grep_.
-
-== Features
-
- * search for regular expressions.
- * support for some important grep options, including:
- ** filename output.
- ** page number output.
- ** optional case insensitivity.
- ** count occurrences.
- ** recursive search
- ** support for extended or (optionally) Perl compatible regular expressions
- * and the most important feature: color output!
-
-For a complete documentation, please consult the link:pdfgrep.html[manpage].
-
-== Dependencies
-
- - poppler-cpp (poppler >= 0.14) [http://poppler.freedesktop.org/]
- - optionally libpcre [http://www.pcre.org/]
-
-== Building
-
-… is easy. Just use the standard procedure:
-
- ./configure
- make
- sudo make install
-
-The ./configure script can take lots of options to customize the build
-process, the most important of which are:
-
- --with-unac :: Build with experimental libunac support and add the
- +--unac+ flag to pdfgrep that strips all accents from characters,
- making it possible to find the character 'ä' by searching 'a'.
- --with-{zsh,bash}-completion :: Configure installation directory
- for shell completion files.
- --without-libpcre :: Disable support for perl compatible regular
- expressions.
- --disable-doc :: Disable manpage generation.
-
-See +configure --help+ for more info or read the (very extensive)
-+INSTALL+ file in the source.
-
-If you're using the git version, you will also have to run
-+./autogen.sh+ in advance.
-
-== Download
-
-Tarballs for releases are available at https://pdfgrep.org/download.html
-
-The development version is available as a git repository at
-https://gitlab.com/pdfgrep/pdfgrep
-
-== Contact
-
-General questions, suggestions, bug reports, patches or anything else
-can be sent to the mailinglist at
-mailto:pdfgrep-users@pdfgrep.org[pdfgrep-users@pdfgrep.org].
-
-You can also use the
-link:https://gitlab.com/pdfgrep/pdfgrep/issues[issue tracker] for bug
-reports or create a
-link:https://gitlab.com/pdfgrep/pdfgrep/merge_requests[merge request]
-on GitLab, if you prefer that over mailinglists.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..1ee0a03
--- /dev/null
+++ b/README.md
@@ -0,0 +1,75 @@
+## Overview
+
+*pdfgrep* is a tool to search text in PDF files. It works similarly to *grep*.
+
+## Features
+
+ - Grep compatible: pdfgrep tries to be compatible with GNU grep,
+ where it makes sense. Many of your favorite grep options are
+ supported (such as `-r`, `-i`, `-n` or `-c`).
+ - Search many PDFs at once, even recursively in directories
+ - Regular expressions: Posix or PCRE
+ - Colored output
+ - Support for password protected PDFs
+
+For a complete documentation, please consult the [manpage].
+
+## Example
+
+ $ pdfgrep --max-count 1 --context 1 --with-filename --page-number pattern rabin-karp.pdf
+ rabin-karp.pdf-1-randomized
+ rabin-karp.pdf:1:pattern-matching
+ rabin-karp.pdf-1-algorithms
+
+## Dependencies
+
+ - poppler-cpp (poppler >= 0.14) (http://poppler.freedesktop.org/)
+ - libgcrypt (https://www.gnu.org/software/libgcrypt/)
+ - optionally libpcre (http://www.pcre.org/)
+
+## Building
+
+... is easy. Just use the standard procedure:
+
+ ./configure
+ make
+ sudo make install
+
+The `./configure` script can take lots of options to customize the
+build process, the most important of which are:
+
+ - `--with-unac`: Build with experimental libunac support and add
+ the `--unac` flag to pdfgrep that strips all accents from
+ characters, making it possible to find the character 'ä' by
+ searching 'a'.
+ - `--with-{zsh,bash}-completion`: Configure installation directory
+ for shell completion files.
+ - `--without-libpcre`: Disable support for perl compatible regular
+ expressions.
+ - `--disable-doc`: Disable manpage generation.
+
+See `configure --help` for more info or read the (very extensive)
+`INSTALL` file in the source.
+
+If you're using the git version, you will also have to run
+`./autogen.sh` in advance.
+
+## Download
+
+Tarballs for releases are available at https://pdfgrep.org/download.html
+
+The development version is available as a git repository at
+https://gitlab.com/pdfgrep/pdfgrep
+
+## Contact
+
+General questions, suggestions, bug reports, patches or anything else
+can be sent to the [mailinglist](mailto:pdfgrep-users@pdfgrep.org).
+
+You can also use the [issue tracker] for bug reports or create a
+[merge request] on GitLab, if you prefer that over mailinglists.
+
+
+[manpage]: https://pdfgrep.org/doc.html
+[issue tracker]: https://gitlab.com/pdfgrep/pdfgrep/issues
+[merge request]: https://gitlab.com/pdfgrep/pdfgrep/merge_requests
diff --git a/TODO b/TODO
deleted file mode 100644
index 2386d79..0000000
--- a/TODO
+++ /dev/null
@@ -1,13 +0,0 @@
-An incomplete list of things that should be done:
-
- - Line based context: Currently there is no way to print multiple
- lines of context.
-
- - Parallelisation: PDF rendering is slow and could be a fine target
- for parallelisation.
-
- - More grep features:
- + Regex (de)selection: -E/-F/-G
- + Match control: -v
- + Context: -A/-B
- + Other: -Z
diff --git a/aclocal.m4 b/aclocal.m4
index 054bdf6..230fe6d 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -20,32 +20,207 @@ You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically 'autoreconf'.])])
-# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
-# serial 1 (pkg-config-0.24)
-#
-# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
+# libgcrypt.m4 - Autoconf macros to detect libgcrypt
+# Copyright (C) 2002, 2003, 2004, 2011, 2014 g10 Code GmbH
#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
+# This file is free software; as a special exception the author gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
+# This file is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
+# Last-changed: 2014-10-02
+
+
+dnl AM_PATH_LIBGCRYPT([MINIMUM-VERSION,
+dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
+dnl Test for libgcrypt and define LIBGCRYPT_CFLAGS and LIBGCRYPT_LIBS.
+dnl MINIMUN-VERSION is a string with the version number optionalliy prefixed
+dnl with the API version to also check the API compatibility. Example:
+dnl a MINIMUN-VERSION of 1:1.2.5 won't pass the test unless the installed
+dnl version of libgcrypt is at least 1.2.5 *and* the API number is 1. Using
+dnl this features allows to prevent build against newer versions of libgcrypt
+dnl with a changed API.
+dnl
+dnl If a prefix option is not used, the config script is first
+dnl searched in $SYSROOT/bin and then along $PATH. If the used
+dnl config script does not match the host specification the script
+dnl is added to the gpg_config_script_warn variable.
+dnl
+AC_DEFUN([AM_PATH_LIBGCRYPT],
+[ AC_REQUIRE([AC_CANONICAL_HOST])
+ AC_ARG_WITH(libgcrypt-prefix,
+ AC_HELP_STRING([--with-libgcrypt-prefix=PFX],
+ [prefix where LIBGCRYPT is installed (optional)]),
+ libgcrypt_config_prefix="$withval", libgcrypt_config_prefix="")
+ if test x"${LIBGCRYPT_CONFIG}" = x ; then
+ if test x"${libgcrypt_config_prefix}" != x ; then
+ LIBGCRYPT_CONFIG="${libgcrypt_config_prefix}/bin/libgcrypt-config"
+ else
+ case "${SYSROOT}" in
+ /*)
+ if test -x "${SYSROOT}/bin/libgcrypt-config" ; then
+ LIBGCRYPT_CONFIG="${SYSROOT}/bin/libgcrypt-config"
+ fi
+ ;;
+ '')
+ ;;
+ *)
+ AC_MSG_WARN([Ignoring \$SYSROOT as it is not an absolute path.])
+ ;;
+ esac
+ fi
+ fi
+
+ AC_PATH_PROG(LIBGCRYPT_CONFIG, libgcrypt-config, no)
+ tmp=ifelse([$1], ,1:1.2.0,$1)
+ if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
+ req_libgcrypt_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
+ min_libgcrypt_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
+ else
+ req_libgcrypt_api=0
+ min_libgcrypt_version="$tmp"
+ fi
+
+ AC_MSG_CHECKING(for LIBGCRYPT - version >= $min_libgcrypt_version)
+ ok=no
+ if test "$LIBGCRYPT_CONFIG" != "no" ; then
+ req_major=`echo $min_libgcrypt_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
+ req_minor=`echo $min_libgcrypt_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
+ req_micro=`echo $min_libgcrypt_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
+ libgcrypt_config_version=`$LIBGCRYPT_CONFIG --version`
+ major=`echo $libgcrypt_config_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
+ minor=`echo $libgcrypt_config_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
+ micro=`echo $libgcrypt_config_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
+ if test "$major" -gt "$req_major"; then
+ ok=yes
+ else
+ if test "$major" -eq "$req_major"; then
+ if test "$minor" -gt "$req_minor"; then
+ ok=yes
+ else
+ if test "$minor" -eq "$req_minor"; then
+ if test "$micro" -ge "$req_micro"; then
+ ok=yes
+ fi
+ fi
+ fi
+ fi
+ fi
+ fi
+ if test $ok = yes; then
+ AC_MSG_RESULT([yes ($libgcrypt_config_version)])
+ else
+ AC_MSG_RESULT(no)
+ fi
+ if test $ok = yes; then
+ # If we have a recent libgcrypt, we should also check that the
+ # API is compatible
+ if test "$req_libgcrypt_api" -gt 0 ; then
+ tmp=`$LIBGCRYPT_CONFIG --api-version 2>/dev/null || echo 0`
+ if test "$tmp" -gt 0 ; then
+ AC_MSG_CHECKING([LIBGCRYPT API version])
+ if test "$req_libgcrypt_api" -eq "$tmp" ; then
+ AC_MSG_RESULT([okay])
+ else
+ ok=no
+ AC_MSG_RESULT([does not match. want=$req_libgcrypt_api got=$tmp])
+ fi
+ fi
+ fi
+ fi
+ if test $ok = yes; then
+ LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG --cflags`
+ LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG --libs`
+ ifelse([$2], , :, [$2])
+ libgcrypt_config_host=`$LIBGCRYPT_CONFIG --host 2>/dev/null || echo none`
+ if test x"$libgcrypt_config_host" != xnone ; then
+ if test x"$libgcrypt_config_host" != x"$host" ; then
+ AC_MSG_WARN([[
+***
+*** The config script $LIBGCRYPT_CONFIG was
+*** built for $libgcrypt_config_host and thus may not match the
+*** used host $host.
+*** You may want to use the configure option --with-libgcrypt-prefix
+*** to specify a matching config script or use \$SYSROOT.
+***]])
+ gpg_config_script_warn="$gpg_config_script_warn libgcrypt"
+ fi
+ fi
+ else
+ LIBGCRYPT_CFLAGS=""
+ LIBGCRYPT_LIBS=""
+ ifelse([$3], , :, [$3])
+ fi
+ AC_SUBST(LIBGCRYPT_CFLAGS)
+ AC_SUBST(LIBGCRYPT_LIBS)
+])
-# PKG_PROG_PKG_CONFIG([MIN-VERSION])
-# ----------------------------------
+dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
+dnl serial 11 (pkg-config-0.29.1)
+dnl
+dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
+dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+dnl 02111-1307, USA.
+dnl
+dnl As a special exception to the GNU General Public License, if you
+dnl distribute this file as part of a program that contains a
+dnl configuration script generated by Autoconf, you may include it under
+dnl the same distribution terms that you use for the rest of that
+dnl program.
+
+dnl PKG_PREREQ(MIN-VERSION)
+dnl -----------------------
+dnl Since: 0.29
+dnl
+dnl Verify that the version of the pkg-config macros are at least
+dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
+dnl installed version of pkg-config, this checks the developer's version
+dnl of pkg.m4 when generating configure.
+dnl
+dnl To ensure that this macro is defined, also add:
+dnl m4_ifndef([PKG_PREREQ],
+dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
+dnl
+dnl See the "Since" comment for each macro you use to see what version
+dnl of the macros you require.
+m4_defun([PKG_PREREQ],
+[m4_define([PKG_MACROS_VERSION], [0.29.1])
+m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
+ [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
+])dnl PKG_PREREQ
+
+dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
+dnl ----------------------------------
+dnl Since: 0.16
+dnl
+dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
+dnl first found in the path. Checks that the version of pkg-config found
+dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
+dnl used since that's the first version where most current features of
+dnl pkg-config existed.
AC_DEFUN([PKG_PROG_PKG_CONFIG],
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
@@ -67,18 +242,19 @@ if test -n "$PKG_CONFIG"; then
PKG_CONFIG=""
fi
fi[]dnl
-])# PKG_PROG_PKG_CONFIG
+])dnl PKG_PROG_PKG_CONFIG
-# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-#
-# Check to see whether a particular set of modules exists. Similar
-# to PKG_CHECK_MODULES(), but does not set variables or print errors.
-#
-# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
-# only at the first occurence in configure.ac, so if the first place
-# it's called might be skipped (such as if it is within an "if", you
-# have to call PKG_CHECK_EXISTS manually
-# --------------------------------------------------------------
+dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------------------------------
+dnl Since: 0.18
+dnl
+dnl Check to see whether a particular set of modules exists. Similar to
+dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
+dnl
+dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+dnl only at the first occurence in configure.ac, so if the first place
+dnl it's called might be skipped (such as if it is within an "if", you
+dnl have to call PKG_CHECK_EXISTS manually
AC_DEFUN([PKG_CHECK_EXISTS],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
if test -n "$PKG_CONFIG" && \
@@ -88,8 +264,10 @@ m4_ifvaln([$3], [else
$3])dnl
fi])
-# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
-# ---------------------------------------------
+dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+dnl ---------------------------------------------
+dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
+dnl pkg_failed based on the result.
m4_define([_PKG_CONFIG],
[if test -n "$$1"; then
pkg_cv_[]$1="$$1"
@@ -101,10 +279,11 @@ m4_define([_PKG_CONFIG],
else
pkg_failed=untried
fi[]dnl
-])# _PKG_CONFIG
+])dnl _PKG_CONFIG
-# _PKG_SHORT_ERRORS_SUPPORTED
-# -----------------------------
+dnl _PKG_SHORT_ERRORS_SUPPORTED
+dnl ---------------------------
+dnl Internal check to see if pkg-config supports short errors.
AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
@@ -112,19 +291,17 @@ if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
else
_pkg_short_errors_supported=no
fi[]dnl
-])# _PKG_SHORT_ERRORS_SUPPORTED
+])dnl _PKG_SHORT_ERRORS_SUPPORTED
-# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
-# [ACTION-IF-NOT-FOUND])
-#
-#
-# Note that if there is a possibility the first call to
-# PKG_CHECK_MODULES might not happen, you should be sure to include an
-# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
-#
-#
-# --------------------------------------------------------------
+dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl [ACTION-IF-NOT-FOUND])
+dnl --------------------------------------------------------------
+dnl Since: 0.4.0
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
+dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
AC_DEFUN([PKG_CHECK_MODULES],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
@@ -178,16 +355,40 @@ else
AC_MSG_RESULT([yes])
$3
fi[]dnl
-])# PKG_CHECK_MODULES
+])dnl PKG_CHECK_MODULES
+
+
+dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl [ACTION-IF-NOT-FOUND])
+dnl ---------------------------------------------------------------------
+dnl Since: 0.29
+dnl
+dnl Checks for existence of MODULES and gathers its build flags with
+dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
+dnl and VARIABLE-PREFIX_LIBS from --libs.
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
+dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
+dnl configure.ac.
+AC_DEFUN([PKG_CHECK_MODULES_STATIC],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+_save_PKG_CONFIG=$PKG_CONFIG
+PKG_CONFIG="$PKG_CONFIG --static"
+PKG_CHECK_MODULES($@)
+PKG_CONFIG=$_save_PKG_CONFIG[]dnl
+])dnl PKG_CHECK_MODULES_STATIC
-# PKG_INSTALLDIR(DIRECTORY)
-# -------------------------
-# Substitutes the variable pkgconfigdir as the location where a module
-# should install pkg-config .pc files. By default the directory is
-# $libdir/pkgconfig, but the default can be changed by passing
-# DIRECTORY. The user can override through the --with-pkgconfigdir
-# parameter.
+dnl PKG_INSTALLDIR([DIRECTORY])
+dnl -------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable pkgconfigdir as the location where a module
+dnl should install pkg-config .pc files. By default the directory is
+dnl $libdir/pkgconfig, but the default can be changed by passing
+dnl DIRECTORY. The user can override through the --with-pkgconfigdir
+dnl parameter.
AC_DEFUN([PKG_INSTALLDIR],
[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
m4_pushdef([pkg_description],
@@ -198,16 +399,18 @@ AC_ARG_WITH([pkgconfigdir],
AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
m4_popdef([pkg_default])
m4_popdef([pkg_description])
-]) dnl PKG_INSTALLDIR
+])dnl PKG_INSTALLDIR
-# PKG_NOARCH_INSTALLDIR(DIRECTORY)
-# -------------------------
-# Substitutes the variable noarch_pkgconfigdir as the location where a
-# module should install arch-independent pkg-config .pc files. By
-# default the directory is $datadir/pkgconfig, but the default can be
-# changed by passing DIRECTORY. The user can override through the
-# --with-noarch-pkgconfigdir parameter.
+dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
+dnl --------------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable noarch_pkgconfigdir as the location where a
+dnl module should install arch-independent pkg-config .pc files. By
+dnl default the directory is $datadir/pkgconfig, but the default can be
+dnl changed by passing DIRECTORY. The user can override through the
+dnl --with-noarch-pkgconfigdir parameter.
AC_DEFUN([PKG_NOARCH_INSTALLDIR],
[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
m4_pushdef([pkg_description],
@@ -218,13 +421,15 @@ AC_ARG_WITH([noarch-pkgconfigdir],
AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
m4_popdef([pkg_default])
m4_popdef([pkg_description])
-]) dnl PKG_NOARCH_INSTALLDIR
+])dnl PKG_NOARCH_INSTALLDIR
-# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
-# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-# -------------------------------------------
-# Retrieves the value of the pkg-config variable for the given module.
+dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------
+dnl Since: 0.28
+dnl
+dnl Retrieves the value of the pkg-config variable for the given module.
AC_DEFUN([PKG_CHECK_VAR],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
@@ -233,7 +438,7 @@ _PKG_CONFIG([$1], [variable="][$3]["], [$2])
AS_VAR_COPY([$1], [pkg_cv_][$1])
AS_VAR_IF([$1], [""], [$5], [$4])dnl
-])# PKG_CHECK_VAR
+])dnl PKG_CHECK_VAR
# Copyright (C) 2002-2014 Free Software Foundation, Inc.
#
diff --git a/completion/Makefile.in b/completion/Makefile.in
index 92077e3..87690f6 100644
--- a/completion/Makefile.in
+++ b/completion/Makefile.in
@@ -88,6 +88,8 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
subdir = completion
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \
@@ -174,7 +176,6 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
-DEJAGNU = @DEJAGNU@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
@@ -185,14 +186,16 @@ GREP = @GREP@
HAVE_A2X = @HAVE_A2X@
HAVE_CXX11 = @HAVE_CXX11@
HAVE_GCOV = @HAVE_GCOV@
-HAVE_GENHTML = @HAVE_GENHTML@
-HAVE_LCOV = @HAVE_LCOV@
+HAVE_GCOVR = @HAVE_GCOVR@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
+LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
+LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
+LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
@@ -227,7 +230,11 @@ am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
+build = @build@
build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
builddir = @builddir@
cov_CFLAGS = @cov_CFLAGS@
cov_LDFLAGS = @cov_LDFLAGS@
@@ -236,7 +243,11 @@ datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
+host = @host@
host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
diff --git a/completion/_pdfgrep b/completion/_pdfgrep
index 0fd7141..b1d6a3f 100644
--- a/completion/_pdfgrep
+++ b/completion/_pdfgrep
@@ -2,7 +2,7 @@
# Zsh completion for pdfgrep.
-# Copyright (C) 2015 by Hans-Peter Deifel (hpd@hpdeifel.de)
+# Copyright (C) 2017 by Hans-Peter Deifel (hpd@hpdeifel.de)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -19,36 +19,33 @@
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301 USA.
-typeset -A opt_args
-
-local context state line
-
-_arguments -s -S \
- "(-n --page-number)"{-n,--page-number}"[Prefix match with page number]" \
- "(-i --ignore-case)"{-i,--ignore-case}"[Ignore case distinctions]" \
- "(-F --fixed-strings)"{-F,--fixed-strings}"[Use literal strings]" \
- "(-P --perl-regexp)"{-P,--perl-regexp}"[Use Perl compatible regular expression syntax]" \
- "(-H --with-filename -h --no-filename)"{-H,--with-filename}"[Print filename for each match]" \
- "(-h --no-filename -H --with-filename)"{-h,--no-filename}"[Don't print filename]" \
- "(-c --count)"{-c,--count}"[Print only a count of matches per file]" \
- "(-p --page-count)"{-p,--page-count}"[Count matches per page]" \
- "(--color)--color=[Use colors for highlighting]:Color:(always never auto)" \
- "(-C --context)"{-C,--context=}"[Limit output]:Context:" \
- "(-r -R --recursive)"{-r,-R,--recursive}"[Search directories recursively]" \
- "*--exclude=[Skip files]:Exclude:" \
- "*--include=[Opposite of exclude]:Include:" \
- "(--help)--help[show a short help message]" \
- "(-V --version)"{-V,--version}"[Show version information]" \
- "(-q --quiet)"{-q,--quiet}"[Suppress all normal output]" \
- "(-Z --null)"{-Z,--null}"[Replace colon after filename by null byte]" \
- "(--match-prefix-separator)--match-prefix-separator=[Separator between filename, page and text]:Separator:" \
- "*--password=[Password to encrypt file]:Password:" \
- "(-m --max-count)"{-m,--max-count=}"[Process at most count matches]:Count:" \
- "(--debug)"--debug"[Enable debug output]" \
- "(--warn-empty)"--warn-empty"[Warn if a PDF file contains no text]" \
- "(--unac)--unac[Remove accents and ligatures]" \
- "1:pattern:()" \
- "*:pdf file:_files -g \"*.pdf\"" \
- && return 0
-
-return 1
+_arguments -s -S -A "-*" \
+ "(-n --page-number)"{-n,--page-number}"[prefix match with page number]" \
+ "(-i --ignore-case)"{-i,--ignore-case}"[ignore case distinctions]" \
+ "(-F --fixed-strings -P --perl-regexp)"{-F,--fixed-strings}"[use literal strings]" \
+ "(-F --fixed-strings -P --perl-regexp)"{-P,--perl-regexp}"[use Perl compatible regular expression syntax]" \
+ "(-H --with-filename -h --no-filename)"{-H,--with-filename}"[print filename for each match]" \
+ "(-h --no-filename -H --with-filename)"{-h,--no-filename}"[don't print filename]" \
+ "(-c --count)"{-c,--count}"[print only a count of matches per file]" \
+ "(-p --page-count)"{-p,--page-count}"[count matches per page]" \
+ "(-C --context)"{-C,--context=}"[specify lines of context]:lines" \
+ "(-A --after-context)"{-A,--after-context=}"[specify lines of trailing context]:lines" \
+ "(-B --before-context)"{-B,--before-context=}"[specify lines of leading context]:lines" \
+ "--color=[use colors for highlighting]:color:(always never auto)" \
+ "--cache[use a cache for faster operation]" \
+ "(-r -R --recursive --dereference-recursive)"{-r,--recursive}"[search directories recursively]" \
+ "(-r -R --recursive --dereference-recursive)"{-R,--dereference-recursive}"[search directories recursively, follow symlinks]" \
+ "*--exclude=[skip files]:exclude" \
+ "*--include=[opposite of exclude]:include" \
+ "(- 1)--help[display help information]" \
+ "(- 1)"{-V,--version}"[display version information]" \
+ "(-q --quiet)"{-q,--quiet}"[suppress all normal output]" \
+ "(-Z --null)"{-Z,--null}"[replace colon after filename by null byte]" \
+ "--match-prefix-separator=[specify separator between filename, page and text]:separator" \
+ "*--password=[specify password to decrypt file]:password" \
+ "(-m --max-count)"{-m,--max-count=}"[process at most count matches]:count" \
+ "--debug[enable debug output]" \
+ "--warn-empty[warn if a PDF file contains no text]" \
+ "--unac[remove accents and ligatures]" \
+ '1: :_guard "^-*" pattern' \
+ '*:pdf file:_files -g "*.pdf(-.)"'
diff --git a/completion/pdfgrep b/completion/pdfgrep
index 2a54f42..372f76e 100644
--- a/completion/pdfgrep
+++ b/completion/pdfgrep
@@ -1,6 +1,6 @@
# Bash completion for pdfgrep
#
-# Copyright (C) 2015 by Hans-Peter Deifel (hpd@hpdeifel.de)
+# Copyright (C) 2017 by Hans-Peter Deifel (hpd@hpdeifel.de)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -19,60 +19,59 @@
_pdfgrep()
{
- local cur prev opts
- COMPREPLY=()
- cur="${COMP_WORDS[COMP_CWORD]}"
- prev="${COMP_WORDS[COMP_CWORD-1]}"
+ local cur prev words cword
+ _init_completion || return
+
+ local opts
opts=(-n --page-number \
- -i --ignore-case \
- -F --fixed-strings \
- -P --perl-regexp \
- -H --with-filename \
- -h --no-filename \
- -c --count \
- -p --page-count \
- --color \
+ -i --ignore-case \
+ -F --fixed-strings \
+ -P --perl-regexp \
+ -H --with-filename \
+ -h --no-filename \
+ -c --count \
+ -p --page-count \
-C --context \
- -r -R --recursive \
- --exclude \
- --include \
- --help \
- -V --version \
- -q --quiet \
- -Z --null\
- --match-prefix-separator \
- --password \
- -m --max-count \
- --debug \
- --warn-empty \
- --unac \
- )
+ -A --after-context \
+ -B --before-context \
+ --color \
+ --cache \
+ -r -R --recursive \
+ --exclude \
+ --include \
+ --help \
+ -V --version \
+ -q --quiet \
+ -Z --null\
+ --match-prefix-separator \
+ --password \
+ -m --max-count \
+ --debug \
+ --warn-empty \
+ --unac \
+ )
case "${prev}" in
- --color)
- COMPREPLY=( $(compgen -W "always never auto" -- ${cur}) )
- ;;
- --context)
- COMPREPLY=( $(compgen -W "line" -- ${cur}) )
- ;;
- --exclude|--include|--password|-m|--max-count|--match-prefix-separator)
- COMPREPLY=( )
- ;;
- *)
- case "${cur}" in
- -*)
- COMPREPLY=( $(compgen -W "${opts[*]}" -- ${cur}) )
- return 0
- ;;
- *)
- COMPREPLY=( $(compgen -f -X '!*.pdf' -- ${cur} ) )
- ;;
- esac
+ --color)
+ COMPREPLY=( $(compgen -W "always never auto" -- ${cur}) )
+ ;;
+ --exclude|--include|--password|-m|--max-count|--match-prefix-separator)
+ COMPREPLY=( )
+ ;;
+ *)
+ case "${cur}" in
+ -*)
+ COMPREPLY=( $(compgen -W "${opts[*]}" -- ${cur}) )
+ return
+ ;;
+ *)
+ _filedir pdf
+ ;;
+ esac
esac
- return 0
-}
-
+ return
+} &&
complete -F _pdfgrep pdfgrep
# Local Variables:
diff --git a/config.guess b/config.guess
new file mode 100755
index 0000000..6c32c86
--- /dev/null
+++ b/config.guess
@@ -0,0 +1,1421 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+# Copyright 1992-2014 Free Software Foundation, Inc.
+
+timestamp='2014-11-04'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that
+# program. This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
+#
+# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
+#
+# You can get the latest version of this script from:
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+#
+# Please send patches to <config-patches@gnu.org>.
+
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright 1992-2014 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help" >&2
+ exit 1 ;;
+ * )
+ break ;;
+ esac
+done
+
+if test $# != 0; then
+ echo "$me: too many arguments$help" >&2
+ exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,) echo "int x;" > $dummy.c ;
+ for c in cc gcc c89 c99 ; do
+ if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+ CC_FOR_BUILD="$c"; break ;
+ fi ;
+ done ;
+ if test x"$CC_FOR_BUILD" = x ; then
+ CC_FOR_BUILD=no_compiler_found ;
+ fi
+ ;;
+ ,,*) CC_FOR_BUILD=$CC ;;
+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+ PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+case "${UNAME_SYSTEM}" in
+Linux|GNU|GNU/*)
+ # If the system lacks a compiler, then just pick glibc.
+ # We could probably try harder.
+ LIBC=gnu
+
+ eval $set_cc_for_build
+ cat <<-EOF > $dummy.c
+ #include <features.h>
+ #if defined(__UCLIBC__)
+ LIBC=uclibc
+ #elif defined(__dietlibc__)
+ LIBC=dietlibc
+ #else
+ LIBC=gnu
+ #endif
+ EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
+ ;;
+esac
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+ *:NetBSD:*:*)
+ # NetBSD (nbsd) targets should (where applicable) match one or
+ # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
+ # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
+ # switched to ELF, *-*-netbsd* would select the old
+ # object file format. This provides both forward
+ # compatibility and a consistent mechanism for selecting the
+ # object file format.
+ #
+ # Note: NetBSD doesn't particularly care about the vendor
+ # portion of the name. We always set it to "unknown".
+ sysctl="sysctl -n hw.machine_arch"
+ UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+ /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+ case "${UNAME_MACHINE_ARCH}" in
+ armeb) machine=armeb-unknown ;;
+ arm*) machine=arm-unknown ;;
+ sh3el) machine=shl-unknown ;;
+ sh3eb) machine=sh-unknown ;;
+ sh5el) machine=sh5le-unknown ;;
+ *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+ esac
+ # The Operating System including object format, if it has switched
+ # to ELF recently, or will in the future.
+ case "${UNAME_MACHINE_ARCH}" in
+ arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+ eval $set_cc_for_build
+ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ELF__
+ then
+ # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+ # Return netbsd for either. FIX?
+ os=netbsd
+ else
+ os=netbsdelf
+ fi
+ ;;
+ *)
+ os=netbsd
+ ;;
+ esac
+ # The OS release
+ # Debian GNU/NetBSD machines have a different userland, and
+ # thus, need a distinct triplet. However, they do not need
+ # kernel version information, so it can be replaced with a
+ # suitable tag, in the style of linux-gnu.
+ case "${UNAME_VERSION}" in
+ Debian*)
+ release='-gnu'
+ ;;
+ *)
+ release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ ;;
+ esac
+ # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+ # contains redundant information, the shorter form:
+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+ echo "${machine}-${os}${release}"
+ exit ;;
+ *:Bitrig:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
+ echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
+ exit ;;
+ *:OpenBSD:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+ echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+ exit ;;
+ *:ekkoBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+ exit ;;
+ *:SolidBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+ exit ;;
+ macppc:MirBSD:*:*)
+ echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ *:MirBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ alpha:OSF1:*:*)
+ case $UNAME_RELEASE in
+ *4.0)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+ ;;
+ *5.*)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+ ;;
+ esac
+ # According to Compaq, /usr/sbin/psrinfo has been available on
+ # OSF/1 and Tru64 systems produced since 1995. I hope that
+ # covers most systems running today. This code pipes the CPU
+ # types through head -n 1, so we only detect the type of CPU 0.
+ ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+ case "$ALPHA_CPU_TYPE" in
+ "EV4 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "EV4.5 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "LCA4 (21066/21068)")
+ UNAME_MACHINE="alpha" ;;
+ "EV5 (21164)")
+ UNAME_MACHINE="alphaev5" ;;
+ "EV5.6 (21164A)")
+ UNAME_MACHINE="alphaev56" ;;
+ "EV5.6 (21164PC)")
+ UNAME_MACHINE="alphapca56" ;;
+ "EV5.7 (21164PC)")
+ UNAME_MACHINE="alphapca57" ;;
+ "EV6 (21264)")
+ UNAME_MACHINE="alphaev6" ;;
+ "EV6.7 (21264A)")
+ UNAME_MACHINE="alphaev67" ;;
+ "EV6.8CB (21264C)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8AL (21264B)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8CX (21264D)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.9A (21264/EV69A)")
+ UNAME_MACHINE="alphaev69" ;;
+ "EV7 (21364)")
+ UNAME_MACHINE="alphaev7" ;;
+ "EV7.9 (21364A)")
+ UNAME_MACHINE="alphaev79" ;;
+ esac
+ # A Pn.n version is a patched version.
+ # A Vn.n version is a released version.
+ # A Tn.n version is a released field test version.
+ # A Xn.n version is an unreleased experimental baselevel.
+ # 1.2 uses "1.2" for uname -r.
+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
+ exitcode=$?
+ trap '' 0
+ exit $exitcode ;;
+ Alpha\ *:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # Should we change UNAME_MACHINE based on the output of uname instead
+ # of the specific Alpha model?
+ echo alpha-pc-interix
+ exit ;;
+ 21064:Windows_NT:50:3)
+ echo alpha-dec-winnt3.5
+ exit ;;
+ Amiga*:UNIX_System_V:4.0:*)
+ echo m68k-unknown-sysv4
+ exit ;;
+ *:[Aa]miga[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-amigaos
+ exit ;;
+ *:[Mm]orph[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-morphos
+ exit ;;
+ *:OS/390:*:*)
+ echo i370-ibm-openedition
+ exit ;;
+ *:z/VM:*:*)
+ echo s390-ibm-zvmoe
+ exit ;;
+ *:OS400:*:*)
+ echo powerpc-ibm-os400
+ exit ;;
+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+ echo arm-acorn-riscix${UNAME_RELEASE}
+ exit ;;
+ arm*:riscos:*:*|arm*:RISCOS:*:*)
+ echo arm-unknown-riscos
+ exit ;;
+ SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+ echo hppa1.1-hitachi-hiuxmpp
+ exit ;;
+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+ # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+ if test "`(/bin/universe) 2>/dev/null`" = att ; then
+ echo pyramid-pyramid-sysv3
+ else
+ echo pyramid-pyramid-bsd
+ fi
+ exit ;;
+ NILE*:*:*:dcosx)
+ echo pyramid-pyramid-svr4
+ exit ;;
+ DRS?6000:unix:4.0:6*)
+ echo sparc-icl-nx6
+ exit ;;
+ DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+ case `/usr/bin/uname -p` in
+ sparc) echo sparc-icl-nx7; exit ;;
+ esac ;;
+ s390x:SunOS:*:*)
+ echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4H:SunOS:5.*:*)
+ echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+ echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
+ echo i386-pc-auroraux${UNAME_RELEASE}
+ exit ;;
+ i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
+ eval $set_cc_for_build
+ SUN_ARCH="i386"
+ # If there is a compiler, see if it is configured for 64-bit objects.
+ # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
+ # This test works for both compilers.
+ if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+ if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
+ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_64BIT_ARCH >/dev/null
+ then
+ SUN_ARCH="x86_64"
+ fi
+ fi
+ echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:6*:*)
+ # According to config.sub, this is the proper way to canonicalize
+ # SunOS6. Hard to guess exactly what SunOS6 will be like, but
+ # it's likely to be more like Solaris than SunOS4.
+ echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:*:*)
+ case "`/usr/bin/arch -k`" in
+ Series*|S4*)
+ UNAME_RELEASE=`uname -v`
+ ;;
+ esac
+ # Japanese Language versions have a version number like `4.1.3-JL'.
+ echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+ exit ;;
+ sun3*:SunOS:*:*)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ exit ;;
+ sun*:*:4.2BSD:*)
+ UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+ case "`/bin/arch`" in
+ sun3)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ ;;
+ sun4)
+ echo sparc-sun-sunos${UNAME_RELEASE}
+ ;;
+ esac
+ exit ;;
+ aushp:SunOS:*:*)
+ echo sparc-auspex-sunos${UNAME_RELEASE}
+ exit ;;
+ # The situation for MiNT is a little confusing. The machine name
+ # can be virtually everything (everything which is not
+ # "atarist" or "atariste" at least should have a processor
+ # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
+ # to the lowercase version "mint" (or "freemint"). Finally
+ # the system name "TOS" denotes a system which is actually not
+ # MiNT. But MiNT is downward compatible to TOS, so this should
+ # be no problem.
+ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+ echo m68k-milan-mint${UNAME_RELEASE}
+ exit ;;
+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+ echo m68k-hades-mint${UNAME_RELEASE}
+ exit ;;
+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+ echo m68k-unknown-mint${UNAME_RELEASE}
+ exit ;;
+ m68k:machten:*:*)
+ echo m68k-apple-machten${UNAME_RELEASE}
+ exit ;;
+ powerpc:machten:*:*)
+ echo powerpc-apple-machten${UNAME_RELEASE}
+ exit ;;
+ RISC*:Mach:*:*)
+ echo mips-dec-mach_bsd4.3
+ exit ;;
+ RISC*:ULTRIX:*:*)
+ echo mips-dec-ultrix${UNAME_RELEASE}
+ exit ;;
+ VAX*:ULTRIX*:*:*)
+ echo vax-dec-ultrix${UNAME_RELEASE}
+ exit ;;
+ 2020:CLIX:*:* | 2430:CLIX:*:*)
+ echo clipper-intergraph-clix${UNAME_RELEASE}
+ exit ;;
+ mips:*:*:UMIPS | mips:*:*:RISCos)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+ #if defined (host_mips) && defined (MIPSEB)
+ #if defined (SYSTYPE_SYSV)
+ printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_SVR4)
+ printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+ printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+ #endif
+ #endif
+ exit (-1);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c &&
+ dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+ SYSTEM_NAME=`$dummy $dummyarg` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo mips-mips-riscos${UNAME_RELEASE}
+ exit ;;
+ Motorola:PowerMAX_OS:*:*)
+ echo powerpc-motorola-powermax
+ exit ;;
+ Motorola:*:4.3:PL8-*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:Power_UNIX:*:*)
+ echo powerpc-harris-powerunix
+ exit ;;
+ m88k:CX/UX:7*:*)
+ echo m88k-harris-cxux7
+ exit ;;
+ m88k:*:4*:R4*)
+ echo m88k-motorola-sysv4
+ exit ;;
+ m88k:*:3*:R3*)
+ echo m88k-motorola-sysv3
+ exit ;;
+ AViiON:dgux:*:*)
+ # DG/UX returns AViiON for all architectures
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+ then
+ if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+ [ ${TARGET_BINARY_INTERFACE}x = x ]
+ then
+ echo m88k-dg-dgux${UNAME_RELEASE}
+ else
+ echo m88k-dg-dguxbcs${UNAME_RELEASE}
+ fi
+ else
+ echo i586-dg-dgux${UNAME_RELEASE}
+ fi
+ exit ;;
+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)
+ echo m88k-dolphin-sysv3
+ exit ;;
+ M88*:*:R3*:*)
+ # Delta 88k system running SVR3
+ echo m88k-motorola-sysv3
+ exit ;;
+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+ echo m88k-tektronix-sysv3
+ exit ;;
+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+ echo m68k-tektronix-bsd
+ exit ;;
+ *:IRIX*:*:*)
+ echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+ exit ;;
+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+ echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
+ exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
+ i*86:AIX:*:*)
+ echo i386-ibm-aix
+ exit ;;
+ ia64:AIX:*:*)
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+ exit ;;
+ *:AIX:2:3)
+ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <sys/systemcfg.h>
+
+ main()
+ {
+ if (!__power_pc())
+ exit(1);
+ puts("powerpc-ibm-aix3.2.5");
+ exit(0);
+ }
+EOF
+ if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+ then
+ echo "$SYSTEM_NAME"
+ else
+ echo rs6000-ibm-aix3.2.5
+ fi
+ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+ echo rs6000-ibm-aix3.2.4
+ else
+ echo rs6000-ibm-aix3.2
+ fi
+ exit ;;
+ *:AIX:*:[4567])
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+ if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+ IBM_ARCH=rs6000
+ else
+ IBM_ARCH=powerpc
+ fi
+ if [ -x /usr/bin/lslpp ] ; then
+ IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
+ awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+ exit ;;
+ *:AIX:*:*)
+ echo rs6000-ibm-aix
+ exit ;;
+ ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+ echo romp-ibm-bsd4.4
+ exit ;;
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
+ echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
+ exit ;; # report: romp-ibm BSD 4.3
+ *:BOSX:*:*)
+ echo rs6000-bull-bosx
+ exit ;;
+ DPX/2?00:B.O.S.:*:*)
+ echo m68k-bull-sysv3
+ exit ;;
+ 9000/[34]??:4.3bsd:1.*:*)
+ echo m68k-hp-bsd
+ exit ;;
+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+ echo m68k-hp-bsd4.4
+ exit ;;
+ 9000/[34678]??:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ case "${UNAME_MACHINE}" in
+ 9000/31? ) HP_ARCH=m68000 ;;
+ 9000/[34]?? ) HP_ARCH=m68k ;;
+ 9000/[678][0-9][0-9])
+ if [ -x /usr/bin/getconf ]; then
+ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+ sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+ case "${sc_cpu_version}" in
+ 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+ 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+ 532) # CPU_PA_RISC2_0
+ case "${sc_kernel_bits}" in
+ 32) HP_ARCH="hppa2.0n" ;;
+ 64) HP_ARCH="hppa2.0w" ;;
+ '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
+ esac ;;
+ esac
+ fi
+ if [ "${HP_ARCH}" = "" ]; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+
+ #define _HPUX_SOURCE
+ #include <stdlib.h>
+ #include <unistd.h>
+
+ int main ()
+ {
+ #if defined(_SC_KERNEL_BITS)
+ long bits = sysconf(_SC_KERNEL_BITS);
+ #endif
+ long cpu = sysconf (_SC_CPU_VERSION);
+
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+ case CPU_PA_RISC2_0:
+ #if defined(_SC_KERNEL_BITS)
+ switch (bits)
+ {
+ case 64: puts ("hppa2.0w"); break;
+ case 32: puts ("hppa2.0n"); break;
+ default: puts ("hppa2.0"); break;
+ } break;
+ #else /* !defined(_SC_KERNEL_BITS) */
+ puts ("hppa2.0"); break;
+ #endif
+ default: puts ("hppa1.0"); break;
+ }
+ exit (0);
+ }
+EOF
+ (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+ test -z "$HP_ARCH" && HP_ARCH=hppa
+ fi ;;
+ esac
+ if [ ${HP_ARCH} = "hppa2.0w" ]
+ then
+ eval $set_cc_for_build
+
+ # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+ # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
+ # generating 64-bit code. GNU and HP use different nomenclature:
+ #
+ # $ CC_FOR_BUILD=cc ./config.guess
+ # => hppa2.0w-hp-hpux11.23
+ # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+ # => hppa64-hp-hpux11.23
+
+ if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+ grep -q __LP64__
+ then
+ HP_ARCH="hppa2.0w"
+ else
+ HP_ARCH="hppa64"
+ fi
+ fi
+ echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+ exit ;;
+ ia64:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ echo ia64-hp-hpux${HPUX_REV}
+ exit ;;
+ 3050*:HI-UX:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <unistd.h>
+ int
+ main ()
+ {
+ long cpu = sysconf (_SC_CPU_VERSION);
+ /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+ true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
+ results, however. */
+ if (CPU_IS_PA_RISC (cpu))
+ {
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+ default: puts ("hppa-hitachi-hiuxwe2"); break;
+ }
+ }
+ else if (CPU_IS_HP_MC68K (cpu))
+ puts ("m68k-hitachi-hiuxwe2");
+ else puts ("unknown-hitachi-hiuxwe2");
+ exit (0);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo unknown-hitachi-hiuxwe2
+ exit ;;
+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+ echo hppa1.1-hp-bsd
+ exit ;;
+ 9000/8??:4.3bsd:*:*)
+ echo hppa1.0-hp-bsd
+ exit ;;
+ *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+ echo hppa1.0-hp-mpeix
+ exit ;;
+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+ echo hppa1.1-hp-osf
+ exit ;;
+ hp8??:OSF1:*:*)
+ echo hppa1.0-hp-osf
+ exit ;;
+ i*86:OSF1:*:*)
+ if [ -x /usr/sbin/sysversion ] ; then
+ echo ${UNAME_MACHINE}-unknown-osf1mk
+ else
+ echo ${UNAME_MACHINE}-unknown-osf1
+ fi
+ exit ;;
+ parisc*:Lites*:*:*)
+ echo hppa1.1-hp-lites
+ exit ;;
+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+ echo c1-convex-bsd
+ exit ;;
+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+ echo c34-convex-bsd
+ exit ;;
+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+ echo c38-convex-bsd
+ exit ;;
+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+ echo c4-convex-bsd
+ exit ;;
+ CRAY*Y-MP:*:*:*)
+ echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*[A-Z]90:*:*:*)
+ echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+ -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*TS:*:*:*)
+ echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*T3E:*:*:*)
+ echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*SV1:*:*:*)
+ echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ *:UNICOS/mp:*:*)
+ echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+ FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+ echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
+ 5000:UNIX_System_V:4.*:*)
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+ echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
+ i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+ echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+ exit ;;
+ sparc*:BSD/OS:*:*)
+ echo sparc-unknown-bsdi${UNAME_RELEASE}
+ exit ;;
+ *:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+ exit ;;
+ *:FreeBSD:*:*)
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ case ${UNAME_PROCESSOR} in
+ amd64)
+ echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ *)
+ echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ esac
+ exit ;;
+ i*:CYGWIN*:*)
+ echo ${UNAME_MACHINE}-pc-cygwin
+ exit ;;
+ *:MINGW64*:*)
+ echo ${UNAME_MACHINE}-pc-mingw64
+ exit ;;
+ *:MINGW*:*)
+ echo ${UNAME_MACHINE}-pc-mingw32
+ exit ;;
+ *:MSYS*:*)
+ echo ${UNAME_MACHINE}-pc-msys
+ exit ;;
+ i*:windows32*:*)
+ # uname -m includes "-pc" on this system.
+ echo ${UNAME_MACHINE}-mingw32
+ exit ;;
+ i*:PW*:*)
+ echo ${UNAME_MACHINE}-pc-pw32
+ exit ;;
+ *:Interix*:*)
+ case ${UNAME_MACHINE} in
+ x86)
+ echo i586-pc-interix${UNAME_RELEASE}
+ exit ;;
+ authenticamd | genuineintel | EM64T)
+ echo x86_64-unknown-interix${UNAME_RELEASE}
+ exit ;;
+ IA64)
+ echo ia64-unknown-interix${UNAME_RELEASE}
+ exit ;;
+ esac ;;
+ [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+ echo i${UNAME_MACHINE}-pc-mks
+ exit ;;
+ 8664:Windows_NT:*)
+ echo x86_64-pc-mks
+ exit ;;
+ i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+ # UNAME_MACHINE based on the output of uname instead of i386?
+ echo i586-pc-interix
+ exit ;;
+ i*:UWIN*:*)
+ echo ${UNAME_MACHINE}-pc-uwin
+ exit ;;
+ amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+ echo x86_64-unknown-cygwin
+ exit ;;
+ p*:CYGWIN*:*)
+ echo powerpcle-unknown-cygwin
+ exit ;;
+ prep*:SunOS:5.*:*)
+ echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ *:GNU:*:*)
+ # the GNU system
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ exit ;;
+ *:GNU/*:*:*)
+ # other systems with GNU libc and userland
+ echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
+ exit ;;
+ i*86:Minix:*:*)
+ echo ${UNAME_MACHINE}-pc-minix
+ exit ;;
+ aarch64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ aarch64_be:Linux:*:*)
+ UNAME_MACHINE=aarch64_be
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ alpha:Linux:*:*)
+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+ EV5) UNAME_MACHINE=alphaev5 ;;
+ EV56) UNAME_MACHINE=alphaev56 ;;
+ PCA56) UNAME_MACHINE=alphapca56 ;;
+ PCA57) UNAME_MACHINE=alphapca56 ;;
+ EV6) UNAME_MACHINE=alphaev6 ;;
+ EV67) UNAME_MACHINE=alphaev67 ;;
+ EV68*) UNAME_MACHINE=alphaev68 ;;
+ esac
+ objdump --private-headers /bin/sh | grep -q ld.so.1
+ if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ arc:Linux:*:* | arceb:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ arm*:Linux:*:*)
+ eval $set_cc_for_build
+ if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ARM_EABI__
+ then
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ else
+ if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ARM_PCS_VFP
+ then
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
+ else
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
+ fi
+ fi
+ exit ;;
+ avr32*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ cris:Linux:*:*)
+ echo ${UNAME_MACHINE}-axis-linux-${LIBC}
+ exit ;;
+ crisv32:Linux:*:*)
+ echo ${UNAME_MACHINE}-axis-linux-${LIBC}
+ exit ;;
+ frv:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ hexagon:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ i*86:Linux:*:*)
+ echo ${UNAME_MACHINE}-pc-linux-${LIBC}
+ exit ;;
+ ia64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ m32r*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ m68*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ mips:Linux:*:* | mips64:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef ${UNAME_MACHINE}
+ #undef ${UNAME_MACHINE}el
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=${UNAME_MACHINE}el
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=${UNAME_MACHINE}
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
+ ;;
+ openrisc*:Linux:*:*)
+ echo or1k-unknown-linux-${LIBC}
+ exit ;;
+ or32:Linux:*:* | or1k*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ padre:Linux:*:*)
+ echo sparc-unknown-linux-${LIBC}
+ exit ;;
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+ echo hppa64-unknown-linux-${LIBC}
+ exit ;;
+ parisc:Linux:*:* | hppa:Linux:*:*)
+ # Look for CPU level
+ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+ PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
+ PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
+ *) echo hppa-unknown-linux-${LIBC} ;;
+ esac
+ exit ;;
+ ppc64:Linux:*:*)
+ echo powerpc64-unknown-linux-${LIBC}
+ exit ;;
+ ppc:Linux:*:*)
+ echo powerpc-unknown-linux-${LIBC}
+ exit ;;
+ ppc64le:Linux:*:*)
+ echo powerpc64le-unknown-linux-${LIBC}
+ exit ;;
+ ppcle:Linux:*:*)
+ echo powerpcle-unknown-linux-${LIBC}
+ exit ;;
+ s390:Linux:*:* | s390x:Linux:*:*)
+ echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
+ exit ;;
+ sh64*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ sh*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ sparc:Linux:*:* | sparc64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ tile*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ vax:Linux:*:*)
+ echo ${UNAME_MACHINE}-dec-linux-${LIBC}
+ exit ;;
+ x86_64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ xtensa*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ i*86:DYNIX/ptx:4*:*)
+ # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+ # earlier versions are messed up and put the nodename in both
+ # sysname and nodename.
+ echo i386-sequent-sysv4
+ exit ;;
+ i*86:UNIX_SV:4.2MP:2.*)
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+ # I am not positive that other SVR4 systems won't match this,
+ # I just have to hope. -- rms.
+ # Use sysv4.2uw... so that sysv4* matches it.
+ echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+ exit ;;
+ i*86:OS/2:*:*)
+ # If we were able to find `uname', then EMX Unix compatibility
+ # is probably installed.
+ echo ${UNAME_MACHINE}-pc-os2-emx
+ exit ;;
+ i*86:XTS-300:*:STOP)
+ echo ${UNAME_MACHINE}-unknown-stop
+ exit ;;
+ i*86:atheos:*:*)
+ echo ${UNAME_MACHINE}-unknown-atheos
+ exit ;;
+ i*86:syllable:*:*)
+ echo ${UNAME_MACHINE}-pc-syllable
+ exit ;;
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
+ echo i386-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ i*86:*DOS:*:*)
+ echo ${UNAME_MACHINE}-pc-msdosdjgpp
+ exit ;;
+ i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+ UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+ echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+ else
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+ fi
+ exit ;;
+ i*86:*:5:[678]*)
+ # UnixWare 7.x, OpenUNIX and OpenServer 6.
+ case `/bin/uname -X | grep "^Machine"` in
+ *486*) UNAME_MACHINE=i486 ;;
+ *Pentium) UNAME_MACHINE=i586 ;;
+ *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+ esac
+ echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+ exit ;;
+ i*86:*:3.2:*)
+ if test -f /usr/options/cb.name; then
+ UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+ echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+ elif /bin/uname -X 2>/dev/null >/dev/null ; then
+ UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+ && UNAME_MACHINE=i586
+ (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+ && UNAME_MACHINE=i686
+ (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+ && UNAME_MACHINE=i686
+ echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+ else
+ echo ${UNAME_MACHINE}-pc-sysv32
+ fi
+ exit ;;
+ pc:*:*:*)
+ # Left here for compatibility:
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
+ # the processor, so we play safe by assuming i586.
+ # Note: whatever this is, it MUST be the same as what config.sub
+ # prints for the "djgpp" host, or else GDB configury will decide that
+ # this is a cross-build.
+ echo i586-pc-msdosdjgpp
+ exit ;;
+ Intel:Mach:3*:*)
+ echo i386-pc-mach3
+ exit ;;
+ paragon:*:*:*)
+ echo i860-intel-osf1
+ exit ;;
+ i860:*:4.*:*) # i860-SVR4
+ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+ echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+ else # Add other i860-SVR4 vendors below as they are discovered.
+ echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
+ fi
+ exit ;;
+ mini*:CTIX:SYS*5:*)
+ # "miniframe"
+ echo m68010-convergent-sysv
+ exit ;;
+ mc68k:UNIX:SYSTEM5:3.51m)
+ echo m68k-convergent-sysv
+ exit ;;
+ M680?0:D-NIX:5.3:*)
+ echo m68k-diab-dnix
+ exit ;;
+ M68*:*:R3V[5678]*:*)
+ test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+ 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+ OS_REL=''
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4; exit; } ;;
+ NCR*:*:4.2:* | MPRAS*:*:4.2:*)
+ OS_REL='.3'
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
+ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+ m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+ echo m68k-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ mc68030:UNIX_System_V:4.*:*)
+ echo m68k-atari-sysv4
+ exit ;;
+ TSUNAMI:LynxOS:2.*:*)
+ echo sparc-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ rs6000:LynxOS:2.*:*)
+ echo rs6000-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
+ echo powerpc-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ SM[BE]S:UNIX_SV:*:*)
+ echo mips-dde-sysv${UNAME_RELEASE}
+ exit ;;
+ RM*:ReliantUNIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ RM*:SINIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ *:SINIX-*:*:*)
+ if uname -p 2>/dev/null >/dev/null ; then
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ echo ${UNAME_MACHINE}-sni-sysv4
+ else
+ echo ns32k-sni-sysv
+ fi
+ exit ;;
+ PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel@ccMail.Census.GOV>
+ echo i586-unisys-sysv4
+ exit ;;
+ *:UNIX_System_V:4*:FTX*)
+ # From Gerald Hewes <hewes@openmarket.com>.
+ # How about differentiating between stratus architectures? -djm
+ echo hppa1.1-stratus-sysv4
+ exit ;;
+ *:*:*:FTX*)
+ # From seanf@swdc.stratus.com.
+ echo i860-stratus-sysv4
+ exit ;;
+ i*86:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo ${UNAME_MACHINE}-stratus-vos
+ exit ;;
+ *:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo hppa1.1-stratus-vos
+ exit ;;
+ mc68*:A/UX:*:*)
+ echo m68k-apple-aux${UNAME_RELEASE}
+ exit ;;
+ news*:NEWS-OS:6*:*)
+ echo mips-sony-newsos6
+ exit ;;
+ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+ if [ -d /usr/nec ]; then
+ echo mips-nec-sysv${UNAME_RELEASE}
+ else
+ echo mips-unknown-sysv${UNAME_RELEASE}
+ fi
+ exit ;;
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ echo powerpc-be-beos
+ exit ;;
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
+ echo powerpc-apple-beos
+ exit ;;
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
+ echo i586-pc-beos
+ exit ;;
+ BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
+ echo i586-pc-haiku
+ exit ;;
+ x86_64:Haiku:*:*)
+ echo x86_64-unknown-haiku
+ exit ;;
+ SX-4:SUPER-UX:*:*)
+ echo sx4-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-5:SUPER-UX:*:*)
+ echo sx5-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-6:SUPER-UX:*:*)
+ echo sx6-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-7:SUPER-UX:*:*)
+ echo sx7-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-8:SUPER-UX:*:*)
+ echo sx8-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-8R:SUPER-UX:*:*)
+ echo sx8r-nec-superux${UNAME_RELEASE}
+ exit ;;
+ Power*:Rhapsody:*:*)
+ echo powerpc-apple-rhapsody${UNAME_RELEASE}
+ exit ;;
+ *:Rhapsody:*:*)
+ echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+ exit ;;
+ *:Darwin:*:*)
+ UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+ eval $set_cc_for_build
+ if test "$UNAME_PROCESSOR" = unknown ; then
+ UNAME_PROCESSOR=powerpc
+ fi
+ if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then
+ if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+ if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_64BIT_ARCH >/dev/null
+ then
+ case $UNAME_PROCESSOR in
+ i386) UNAME_PROCESSOR=x86_64 ;;
+ powerpc) UNAME_PROCESSOR=powerpc64 ;;
+ esac
+ fi
+ fi
+ elif test "$UNAME_PROCESSOR" = i386 ; then
+ # Avoid executing cc on OS X 10.9, as it ships with a stub
+ # that puts up a graphical alert prompting to install
+ # developer tools. Any system running Mac OS X 10.7 or
+ # later (Darwin 11 and later) is required to have a 64-bit
+ # processor. This is not true of the ARM version of Darwin
+ # that Apple uses in portable devices.
+ UNAME_PROCESSOR=x86_64
+ fi
+ echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+ exit ;;
+ *:procnto*:*:* | *:QNX:[0123456789]*:*)
+ UNAME_PROCESSOR=`uname -p`
+ if test "$UNAME_PROCESSOR" = "x86"; then
+ UNAME_PROCESSOR=i386
+ UNAME_MACHINE=pc
+ fi
+ echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+ exit ;;
+ *:QNX:*:4*)
+ echo i386-pc-qnx
+ exit ;;
+ NEO-?:NONSTOP_KERNEL:*:*)
+ echo neo-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ NSE-*:NONSTOP_KERNEL:*:*)
+ echo nse-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ NSR-?:NONSTOP_KERNEL:*:*)
+ echo nsr-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ *:NonStop-UX:*:*)
+ echo mips-compaq-nonstopux
+ exit ;;
+ BS2000:POSIX*:*:*)
+ echo bs2000-siemens-sysv
+ exit ;;
+ DS/*:UNIX_System_V:*:*)
+ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+ exit ;;
+ *:Plan9:*:*)
+ # "uname -m" is not consistent, so use $cputype instead. 386
+ # is converted to i386 for consistency with other x86
+ # operating systems.
+ if test "$cputype" = "386"; then
+ UNAME_MACHINE=i386
+ else
+ UNAME_MACHINE="$cputype"
+ fi
+ echo ${UNAME_MACHINE}-unknown-plan9
+ exit ;;
+ *:TOPS-10:*:*)
+ echo pdp10-unknown-tops10
+ exit ;;
+ *:TENEX:*:*)
+ echo pdp10-unknown-tenex
+ exit ;;
+ KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+ echo pdp10-dec-tops20
+ exit ;;
+ XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+ echo pdp10-xkl-tops20
+ exit ;;
+ *:TOPS-20:*:*)
+ echo pdp10-unknown-tops20
+ exit ;;
+ *:ITS:*:*)
+ echo pdp10-unknown-its
+ exit ;;
+ SEI:*:*:SEIUX)
+ echo mips-sei-seiux${UNAME_RELEASE}
+ exit ;;
+ *:DragonFly:*:*)
+ echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ exit ;;
+ *:*VMS:*:*)
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ case "${UNAME_MACHINE}" in
+ A*) echo alpha-dec-vms ; exit ;;
+ I*) echo ia64-dec-vms ; exit ;;
+ V*) echo vax-dec-vms ; exit ;;
+ esac ;;
+ *:XENIX:*:SysV)
+ echo i386-pc-xenix
+ exit ;;
+ i*86:skyos:*:*)
+ echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+ exit ;;
+ i*86:rdos:*:*)
+ echo ${UNAME_MACHINE}-pc-rdos
+ exit ;;
+ i*86:AROS:*:*)
+ echo ${UNAME_MACHINE}-pc-aros
+ exit ;;
+ x86_64:VMkernel:*:*)
+ echo ${UNAME_MACHINE}-unknown-esx
+ exit ;;
+esac
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+ http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+and
+ http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo = `(hostinfo) 2>/dev/null`
+/bin/universe = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/config.h.in b/config.h.in
index f16a9cd..29e57e1 100644
--- a/config.h.in
+++ b/config.h.in
@@ -44,18 +44,12 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
-/* Define to 1 if you have the <sys/ioctl.h> header file. */
-#undef HAVE_SYS_IOCTL_H
-
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
-/* Define to 1 if you have the <termios.h> header file. */
-#undef HAVE_TERMIOS_H
-
/* Define to 1 if you have libunac _and_ want to use it */
#undef HAVE_UNAC
diff --git a/config.sub b/config.sub
new file mode 100755
index 0000000..7ffe373
--- /dev/null
+++ b/config.sub
@@ -0,0 +1,1807 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+# Copyright 1992-2014 Free Software Foundation, Inc.
+
+timestamp='2014-12-03'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that
+# program. This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
+
+
+# Please send patches to <config-patches@gnu.org>.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# You can get the latest version of this script from:
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support. The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+ $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright 1992-2014 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help"
+ exit 1 ;;
+
+ *local*)
+ # First pass through any local machine types.
+ echo $1
+ exit ;;
+
+ * )
+ break ;;
+ esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+ exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+ exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+ nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
+ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+ knetbsd*-gnu* | netbsd*-gnu* | \
+ kopensolaris*-gnu* | \
+ storm-chaos* | os2-emx* | rtmk-nova*)
+ os=-$maybe_os
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+ ;;
+ android-linux)
+ os=-linux-android
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
+ ;;
+ *)
+ basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+ if [ $basic_machine != $1 ]
+ then os=`echo $1 | sed 's/.*-/-/'`
+ else os=; fi
+ ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work. We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+ -sun*os*)
+ # Prevent following clause from handling this invalid input.
+ ;;
+ -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+ -apple | -axis | -knuth | -cray | -microblaze*)
+ os=
+ basic_machine=$1
+ ;;
+ -bluegene*)
+ os=-cnk
+ ;;
+ -sim | -cisco | -oki | -wec | -winbond)
+ os=
+ basic_machine=$1
+ ;;
+ -scout)
+ ;;
+ -wrs)
+ os=-vxworks
+ basic_machine=$1
+ ;;
+ -chorusos*)
+ os=-chorusos
+ basic_machine=$1
+ ;;
+ -chorusrdb)
+ os=-chorusrdb
+ basic_machine=$1
+ ;;
+ -hiux*)
+ os=-hiuxwe2
+ ;;
+ -sco6)
+ os=-sco5v6
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco5)
+ os=-sco3.2v5
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco4)
+ os=-sco3.2v4
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2.[4-9]*)
+ os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2v[4-9]*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco5v6*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco*)
+ os=-sco3.2v2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -udk*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -isc)
+ os=-isc2.2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -clix*)
+ basic_machine=clipper-intergraph
+ ;;
+ -isc*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -lynx*178)
+ os=-lynxos178
+ ;;
+ -lynx*5)
+ os=-lynxos5
+ ;;
+ -lynx*)
+ os=-lynxos
+ ;;
+ -ptx*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+ ;;
+ -windowsnt*)
+ os=`echo $os | sed -e 's/windowsnt/winnt/'`
+ ;;
+ -psos*)
+ os=-psos
+ ;;
+ -mint | -mint[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+ # Recognize the basic CPU types without company name.
+ # Some are omitted here because they have special meanings below.
+ 1750a | 580 \
+ | a29k \
+ | aarch64 | aarch64_be \
+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+ | am33_2.0 \
+ | arc | arceb \
+ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
+ | avr | avr32 \
+ | be32 | be64 \
+ | bfin \
+ | c4x | c8051 | clipper \
+ | d10v | d30v | dlx | dsp16xx \
+ | epiphany \
+ | fido | fr30 | frv \
+ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ | hexagon \
+ | i370 | i860 | i960 | ia64 \
+ | ip2k | iq2000 \
+ | k1om \
+ | le32 | le64 \
+ | lm32 \
+ | m32c | m32r | m32rle | m68000 | m68k | m88k \
+ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \
+ | mips | mipsbe | mipseb | mipsel | mipsle \
+ | mips16 \
+ | mips64 | mips64el \
+ | mips64octeon | mips64octeonel \
+ | mips64orion | mips64orionel \
+ | mips64r5900 | mips64r5900el \
+ | mips64vr | mips64vrel \
+ | mips64vr4100 | mips64vr4100el \
+ | mips64vr4300 | mips64vr4300el \
+ | mips64vr5000 | mips64vr5000el \
+ | mips64vr5900 | mips64vr5900el \
+ | mipsisa32 | mipsisa32el \
+ | mipsisa32r2 | mipsisa32r2el \
+ | mipsisa32r6 | mipsisa32r6el \
+ | mipsisa64 | mipsisa64el \
+ | mipsisa64r2 | mipsisa64r2el \
+ | mipsisa64r6 | mipsisa64r6el \
+ | mipsisa64sb1 | mipsisa64sb1el \
+ | mipsisa64sr71k | mipsisa64sr71kel \
+ | mipsr5900 | mipsr5900el \
+ | mipstx39 | mipstx39el \
+ | mn10200 | mn10300 \
+ | moxie \
+ | mt \
+ | msp430 \
+ | nds32 | nds32le | nds32be \
+ | nios | nios2 | nios2eb | nios2el \
+ | ns16k | ns32k \
+ | open8 | or1k | or1knd | or32 \
+ | pdp10 | pdp11 | pj | pjl \
+ | powerpc | powerpc64 | powerpc64le | powerpcle \
+ | pyramid \
+ | riscv32 | riscv64 \
+ | rl78 | rx \
+ | score \
+ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+ | sh64 | sh64le \
+ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+ | spu \
+ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
+ | ubicom32 \
+ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
+ | visium \
+ | we32k \
+ | x86 | xc16x | xstormy16 | xtensa \
+ | z8k | z80)
+ basic_machine=$basic_machine-unknown
+ ;;
+ c54x)
+ basic_machine=tic54x-unknown
+ ;;
+ c55x)
+ basic_machine=tic55x-unknown
+ ;;
+ c6x)
+ basic_machine=tic6x-unknown
+ ;;
+ leon|leon[3-9])
+ basic_machine=sparc-$basic_machine
+ ;;
+ m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
+ basic_machine=$basic_machine-unknown
+ os=-none
+ ;;
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+ ;;
+ ms1)
+ basic_machine=mt-unknown
+ ;;
+
+ strongarm | thumb | xscale)
+ basic_machine=arm-unknown
+ ;;
+ xgate)
+ basic_machine=$basic_machine-unknown
+ os=-none
+ ;;
+ xscaleeb)
+ basic_machine=armeb-unknown
+ ;;
+
+ xscaleel)
+ basic_machine=armel-unknown
+ ;;
+
+ # We use `pc' rather than `unknown'
+ # because (1) that's what they normally are, and
+ # (2) the word "unknown" tends to confuse beginning users.
+ i*86 | x86_64)
+ basic_machine=$basic_machine-pc
+ ;;
+ # Object if more than one company name word.
+ *-*-*)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+ # Recognize the basic CPU types with company name.
+ 580-* \
+ | a29k-* \
+ | aarch64-* | aarch64_be-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
+ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
+ | avr-* | avr32-* \
+ | be32-* | be64-* \
+ | bfin-* | bs2000-* \
+ | c[123]* | c30-* | [cjt]90-* | c4x-* \
+ | c8051-* | clipper-* | craynv-* | cydra-* \
+ | d10v-* | d30v-* | dlx-* \
+ | elxsi-* \
+ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
+ | h8300-* | h8500-* \
+ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+ | hexagon-* \
+ | i*86-* | i860-* | i960-* | ia64-* \
+ | ip2k-* | iq2000-* \
+ | k1om-* \
+ | le32-* | le64-* \
+ | lm32-* \
+ | m32c-* | m32r-* | m32rle-* \
+ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
+ | microblaze-* | microblazeel-* \
+ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+ | mips16-* \
+ | mips64-* | mips64el-* \
+ | mips64octeon-* | mips64octeonel-* \
+ | mips64orion-* | mips64orionel-* \
+ | mips64r5900-* | mips64r5900el-* \
+ | mips64vr-* | mips64vrel-* \
+ | mips64vr4100-* | mips64vr4100el-* \
+ | mips64vr4300-* | mips64vr4300el-* \
+ | mips64vr5000-* | mips64vr5000el-* \
+ | mips64vr5900-* | mips64vr5900el-* \
+ | mipsisa32-* | mipsisa32el-* \
+ | mipsisa32r2-* | mipsisa32r2el-* \
+ | mipsisa32r6-* | mipsisa32r6el-* \
+ | mipsisa64-* | mipsisa64el-* \
+ | mipsisa64r2-* | mipsisa64r2el-* \
+ | mipsisa64r6-* | mipsisa64r6el-* \
+ | mipsisa64sb1-* | mipsisa64sb1el-* \
+ | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+ | mipsr5900-* | mipsr5900el-* \
+ | mipstx39-* | mipstx39el-* \
+ | mmix-* \
+ | mt-* \
+ | msp430-* \
+ | nds32-* | nds32le-* | nds32be-* \
+ | nios-* | nios2-* | nios2eb-* | nios2el-* \
+ | none-* | np1-* | ns16k-* | ns32k-* \
+ | open8-* \
+ | or1k*-* \
+ | orion-* \
+ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
+ | pyramid-* \
+ | rl78-* | romp-* | rs6000-* | rx-* \
+ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+ | sparclite-* \
+ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
+ | tahoe-* \
+ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+ | tile*-* \
+ | tron-* \
+ | ubicom32-* \
+ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
+ | vax-* \
+ | visium-* \
+ | we32k-* \
+ | x86-* | x86_64-* | xc16x-* | xps100-* \
+ | xstormy16-* | xtensa*-* \
+ | ymp-* \
+ | z8k-* | z80-*)
+ ;;
+ # Recognize the basic CPU types without company name, with glob match.
+ xtensa*)
+ basic_machine=$basic_machine-unknown
+ ;;
+ # Recognize the various machine names and aliases which stand
+ # for a CPU type and a company and sometimes even an OS.
+ 386bsd)
+ basic_machine=i386-unknown
+ os=-bsd
+ ;;
+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+ basic_machine=m68000-att
+ ;;
+ 3b*)
+ basic_machine=we32k-att
+ ;;
+ a29khif)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ abacus)
+ basic_machine=abacus-unknown
+ ;;
+ adobe68k)
+ basic_machine=m68010-adobe
+ os=-scout
+ ;;
+ alliant | fx80)
+ basic_machine=fx80-alliant
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ ;;
+ am29k)
+ basic_machine=a29k-none
+ os=-bsd
+ ;;
+ amd64)
+ basic_machine=x86_64-pc
+ ;;
+ amd64-*)
+ basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ amdahl)
+ basic_machine=580-amdahl
+ os=-sysv
+ ;;
+ amiga | amiga-*)
+ basic_machine=m68k-unknown
+ ;;
+ amigaos | amigados)
+ basic_machine=m68k-unknown
+ os=-amigaos
+ ;;
+ amigaunix | amix)
+ basic_machine=m68k-unknown
+ os=-sysv4
+ ;;
+ apollo68)
+ basic_machine=m68k-apollo
+ os=-sysv
+ ;;
+ apollo68bsd)
+ basic_machine=m68k-apollo
+ os=-bsd
+ ;;
+ aros)
+ basic_machine=i386-pc
+ os=-aros
+ ;;
+ aux)
+ basic_machine=m68k-apple
+ os=-aux
+ ;;
+ balance)
+ basic_machine=ns32k-sequent
+ os=-dynix
+ ;;
+ blackfin)
+ basic_machine=bfin-unknown
+ os=-linux
+ ;;
+ blackfin-*)
+ basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+ os=-linux
+ ;;
+ bluegene*)
+ basic_machine=powerpc-ibm
+ os=-cnk
+ ;;
+ c54x-*)
+ basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ c55x-*)
+ basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ c6x-*)
+ basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ c90)
+ basic_machine=c90-cray
+ os=-unicos
+ ;;
+ cegcc)
+ basic_machine=arm-unknown
+ os=-cegcc
+ ;;
+ convex-c1)
+ basic_machine=c1-convex
+ os=-bsd
+ ;;
+ convex-c2)
+ basic_machine=c2-convex
+ os=-bsd
+ ;;
+ convex-c32)
+ basic_machine=c32-convex
+ os=-bsd
+ ;;
+ convex-c34)
+ basic_machine=c34-convex
+ os=-bsd
+ ;;
+ convex-c38)
+ basic_machine=c38-convex
+ os=-bsd
+ ;;
+ cray | j90)
+ basic_machine=j90-cray
+ os=-unicos
+ ;;
+ craynv)
+ basic_machine=craynv-cray
+ os=-unicosmp
+ ;;
+ cr16 | cr16-*)
+ basic_machine=cr16-unknown
+ os=-elf
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ ;;
+ crisv32 | crisv32-* | etraxfs*)
+ basic_machine=crisv32-axis
+ ;;
+ cris | cris-* | etrax*)
+ basic_machine=cris-axis
+ ;;
+ crx)
+ basic_machine=crx-unknown
+ os=-elf
+ ;;
+ da30 | da30-*)
+ basic_machine=m68k-da30
+ ;;
+ decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
+ ;;
+ decsystem10* | dec10*)
+ basic_machine=pdp10-dec
+ os=-tops10
+ ;;
+ decsystem20* | dec20*)
+ basic_machine=pdp10-dec
+ os=-tops20
+ ;;
+ delta | 3300 | motorola-3300 | motorola-delta \
+ | 3300-motorola | delta-motorola)
+ basic_machine=m68k-motorola
+ ;;
+ delta88)
+ basic_machine=m88k-motorola
+ os=-sysv3
+ ;;
+ dicos)
+ basic_machine=i686-pc
+ os=-dicos
+ ;;
+ djgpp)
+ basic_machine=i586-pc
+ os=-msdosdjgpp
+ ;;
+ dpx20 | dpx20-*)
+ basic_machine=rs6000-bull
+ os=-bosx
+ ;;
+ dpx2* | dpx2*-bull)
+ basic_machine=m68k-bull
+ os=-sysv3
+ ;;
+ ebmon29k)
+ basic_machine=a29k-amd
+ os=-ebmon
+ ;;
+ elxsi)
+ basic_machine=elxsi-elxsi
+ os=-bsd
+ ;;
+ encore | umax | mmax)
+ basic_machine=ns32k-encore
+ ;;
+ es1800 | OSE68k | ose68k | ose | OSE)
+ basic_machine=m68k-ericsson
+ os=-ose
+ ;;
+ fx2800)
+ basic_machine=i860-alliant
+ ;;
+ genix)
+ basic_machine=ns32k-ns
+ ;;
+ gmicro)
+ basic_machine=tron-gmicro
+ os=-sysv
+ ;;
+ go32)
+ basic_machine=i386-pc
+ os=-go32
+ ;;
+ h3050r* | hiux*)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ h8300hms)
+ basic_machine=h8300-hitachi
+ os=-hms
+ ;;
+ h8300xray)
+ basic_machine=h8300-hitachi
+ os=-xray
+ ;;
+ h8500hms)
+ basic_machine=h8500-hitachi
+ os=-hms
+ ;;
+ harris)
+ basic_machine=m88k-harris
+ os=-sysv3
+ ;;
+ hp300-*)
+ basic_machine=m68k-hp
+ ;;
+ hp300bsd)
+ basic_machine=m68k-hp
+ os=-bsd
+ ;;
+ hp300hpux)
+ basic_machine=m68k-hp
+ os=-hpux
+ ;;
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k2[0-9][0-9] | hp9k31[0-9])
+ basic_machine=m68000-hp
+ ;;
+ hp9k3[2-9][0-9])
+ basic_machine=m68k-hp
+ ;;
+ hp9k6[0-9][0-9] | hp6[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k7[0-79][0-9] | hp7[0-79][0-9])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k78[0-9] | hp78[0-9])
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][13679] | hp8[0-9][13679])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][0-9] | hp8[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hppa-next)
+ os=-nextstep3
+ ;;
+ hppaosf)
+ basic_machine=hppa1.1-hp
+ os=-osf
+ ;;
+ hppro)
+ basic_machine=hppa1.1-hp
+ os=-proelf
+ ;;
+ i370-ibm* | ibm*)
+ basic_machine=i370-ibm
+ ;;
+ i*86v32)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv32
+ ;;
+ i*86v4*)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv4
+ ;;
+ i*86v)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv
+ ;;
+ i*86sol2)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-solaris2
+ ;;
+ i386mach)
+ basic_machine=i386-mach
+ os=-mach
+ ;;
+ i386-vsta | vsta)
+ basic_machine=i386-unknown
+ os=-vsta
+ ;;
+ iris | iris4d)
+ basic_machine=mips-sgi
+ case $os in
+ -irix*)
+ ;;
+ *)
+ os=-irix4
+ ;;
+ esac
+ ;;
+ isi68 | isi)
+ basic_machine=m68k-isi
+ os=-sysv
+ ;;
+ leon-*|leon[3-9]-*)
+ basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'`
+ ;;
+ m68knommu)
+ basic_machine=m68k-unknown
+ os=-linux
+ ;;
+ m68knommu-*)
+ basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+ os=-linux
+ ;;
+ m88k-omron*)
+ basic_machine=m88k-omron
+ ;;
+ magnum | m3230)
+ basic_machine=mips-mips
+ os=-sysv
+ ;;
+ merlin)
+ basic_machine=ns32k-utek
+ os=-sysv
+ ;;
+ microblaze*)
+ basic_machine=microblaze-xilinx
+ ;;
+ mingw64)
+ basic_machine=x86_64-pc
+ os=-mingw64
+ ;;
+ mingw32)
+ basic_machine=i686-pc
+ os=-mingw32
+ ;;
+ mingw32ce)
+ basic_machine=arm-unknown
+ os=-mingw32ce
+ ;;
+ miniframe)
+ basic_machine=m68000-convergent
+ ;;
+ *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+ mips3*-*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+ ;;
+ mips3*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+ ;;
+ monitor)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ morphos)
+ basic_machine=powerpc-unknown
+ os=-morphos
+ ;;
+ moxiebox)
+ basic_machine=moxie-unknown
+ os=-moxiebox
+ ;;
+ msdos)
+ basic_machine=i386-pc
+ os=-msdos
+ ;;
+ ms1-*)
+ basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+ ;;
+ msys)
+ basic_machine=i686-pc
+ os=-msys
+ ;;
+ mvs)
+ basic_machine=i370-ibm
+ os=-mvs
+ ;;
+ nacl)
+ basic_machine=le32-unknown
+ os=-nacl
+ ;;
+ ncr3000)
+ basic_machine=i486-ncr
+ os=-sysv4
+ ;;
+ netbsd386)
+ basic_machine=i386-unknown
+ os=-netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-rebel
+ os=-linux
+ ;;
+ news | news700 | news800 | news900)
+ basic_machine=m68k-sony
+ os=-newsos
+ ;;
+ news1000)
+ basic_machine=m68030-sony
+ os=-newsos
+ ;;
+ news-3600 | risc-news)
+ basic_machine=mips-sony
+ os=-newsos
+ ;;
+ necv70)
+ basic_machine=v70-nec
+ os=-sysv
+ ;;
+ next | m*-next )
+ basic_machine=m68k-next
+ case $os in
+ -nextstep* )
+ ;;
+ -ns2*)
+ os=-nextstep2
+ ;;
+ *)
+ os=-nextstep3
+ ;;
+ esac
+ ;;
+ nh3000)
+ basic_machine=m68k-harris
+ os=-cxux
+ ;;
+ nh[45]000)
+ basic_machine=m88k-harris
+ os=-cxux
+ ;;
+ nindy960)
+ basic_machine=i960-intel
+ os=-nindy
+ ;;
+ mon960)
+ basic_machine=i960-intel
+ os=-mon960
+ ;;
+ nonstopux)
+ basic_machine=mips-compaq
+ os=-nonstopux
+ ;;
+ np1)
+ basic_machine=np1-gould
+ ;;
+ neo-tandem)
+ basic_machine=neo-tandem
+ ;;
+ nse-tandem)
+ basic_machine=nse-tandem
+ ;;
+ nsr-tandem)
+ basic_machine=nsr-tandem
+ ;;
+ op50n-* | op60c-*)
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+ openrisc | openrisc-*)
+ basic_machine=or32-unknown
+ ;;
+ os400)
+ basic_machine=powerpc-ibm
+ os=-os400
+ ;;
+ OSE68000 | ose68000)
+ basic_machine=m68000-ericsson
+ os=-ose
+ ;;
+ os68k)
+ basic_machine=m68k-none
+ os=-os68k
+ ;;
+ pa-hitachi)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ paragon)
+ basic_machine=i860-intel
+ os=-osf
+ ;;
+ parisc)
+ basic_machine=hppa-unknown
+ os=-linux
+ ;;
+ parisc-*)
+ basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+ os=-linux
+ ;;
+ pbd)
+ basic_machine=sparc-tti
+ ;;
+ pbb)
+ basic_machine=m68k-tti
+ ;;
+ pc532 | pc532-*)
+ basic_machine=ns32k-pc532
+ ;;
+ pc98)
+ basic_machine=i386-pc
+ ;;
+ pc98-*)
+ basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentium | p5 | k5 | k6 | nexgen | viac3)
+ basic_machine=i586-pc
+ ;;
+ pentiumpro | p6 | 6x86 | athlon | athlon_*)
+ basic_machine=i686-pc
+ ;;
+ pentiumii | pentium2 | pentiumiii | pentium3)
+ basic_machine=i686-pc
+ ;;
+ pentium4)
+ basic_machine=i786-pc
+ ;;
+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+ basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumpro-* | p6-* | 6x86-* | athlon-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentium4-*)
+ basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pn)
+ basic_machine=pn-gould
+ ;;
+ power) basic_machine=power-ibm
+ ;;
+ ppc | ppcbe) basic_machine=powerpc-unknown
+ ;;
+ ppc-* | ppcbe-*)
+ basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppcle | powerpclittle | ppc-le | powerpc-little)
+ basic_machine=powerpcle-unknown
+ ;;
+ ppcle-* | powerpclittle-*)
+ basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64) basic_machine=powerpc64-unknown
+ ;;
+ ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+ basic_machine=powerpc64le-unknown
+ ;;
+ ppc64le-* | powerpc64little-*)
+ basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ps2)
+ basic_machine=i386-ibm
+ ;;
+ pw32)
+ basic_machine=i586-unknown
+ os=-pw32
+ ;;
+ rdos | rdos64)
+ basic_machine=x86_64-pc
+ os=-rdos
+ ;;
+ rdos32)
+ basic_machine=i386-pc
+ os=-rdos
+ ;;
+ rom68k)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ rm[46]00)
+ basic_machine=mips-siemens
+ ;;
+ rtpc | rtpc-*)
+ basic_machine=romp-ibm
+ ;;
+ s390 | s390-*)
+ basic_machine=s390-ibm
+ ;;
+ s390x | s390x-*)
+ basic_machine=s390x-ibm
+ ;;
+ sa29200)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ sb1)
+ basic_machine=mipsisa64sb1-unknown
+ ;;
+ sb1el)
+ basic_machine=mipsisa64sb1el-unknown
+ ;;
+ sde)
+ basic_machine=mipsisa32-sde
+ os=-elf
+ ;;
+ sei)
+ basic_machine=mips-sei
+ os=-seiux
+ ;;
+ sequent)
+ basic_machine=i386-sequent
+ ;;
+ sh)
+ basic_machine=sh-hitachi
+ os=-hms
+ ;;
+ sh5el)
+ basic_machine=sh5le-unknown
+ ;;
+ sh64)
+ basic_machine=sh64-unknown
+ ;;
+ sparclite-wrs | simso-wrs)
+ basic_machine=sparclite-wrs
+ os=-vxworks
+ ;;
+ sps7)
+ basic_machine=m68k-bull
+ os=-sysv2
+ ;;
+ spur)
+ basic_machine=spur-unknown
+ ;;
+ st2000)
+ basic_machine=m68k-tandem
+ ;;
+ stratus)
+ basic_machine=i860-stratus
+ os=-sysv4
+ ;;
+ strongarm-* | thumb-*)
+ basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ sun2)
+ basic_machine=m68000-sun
+ ;;
+ sun2os3)
+ basic_machine=m68000-sun
+ os=-sunos3
+ ;;
+ sun2os4)
+ basic_machine=m68000-sun
+ os=-sunos4
+ ;;
+ sun3os3)
+ basic_machine=m68k-sun
+ os=-sunos3
+ ;;
+ sun3os4)
+ basic_machine=m68k-sun
+ os=-sunos4
+ ;;
+ sun4os3)
+ basic_machine=sparc-sun
+ os=-sunos3
+ ;;
+ sun4os4)
+ basic_machine=sparc-sun
+ os=-sunos4
+ ;;
+ sun4sol2)
+ basic_machine=sparc-sun
+ os=-solaris2
+ ;;
+ sun3 | sun3-*)
+ basic_machine=m68k-sun
+ ;;
+ sun4)
+ basic_machine=sparc-sun
+ ;;
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
+ ;;
+ sv1)
+ basic_machine=sv1-cray
+ os=-unicos
+ ;;
+ symmetry)
+ basic_machine=i386-sequent
+ os=-dynix
+ ;;
+ t3e)
+ basic_machine=alphaev5-cray
+ os=-unicos
+ ;;
+ t90)
+ basic_machine=t90-cray
+ os=-unicos
+ ;;
+ tile*)
+ basic_machine=$basic_machine-unknown
+ os=-linux-gnu
+ ;;
+ tx39)
+ basic_machine=mipstx39-unknown
+ ;;
+ tx39el)
+ basic_machine=mipstx39el-unknown
+ ;;
+ toad1)
+ basic_machine=pdp10-xkl
+ os=-tops20
+ ;;
+ tower | tower-32)
+ basic_machine=m68k-ncr
+ ;;
+ tpf)
+ basic_machine=s390x-ibm
+ os=-tpf
+ ;;
+ udi29k)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ ultra3)
+ basic_machine=a29k-nyu
+ os=-sym1
+ ;;
+ v810 | necv810)
+ basic_machine=v810-nec
+ os=-none
+ ;;
+ vaxv)
+ basic_machine=vax-dec
+ os=-sysv
+ ;;
+ vms)
+ basic_machine=vax-dec
+ os=-vms
+ ;;
+ vpp*|vx|vx-*)
+ basic_machine=f301-fujitsu
+ ;;
+ vxworks960)
+ basic_machine=i960-wrs
+ os=-vxworks
+ ;;
+ vxworks68)
+ basic_machine=m68k-wrs
+ os=-vxworks
+ ;;
+ vxworks29k)
+ basic_machine=a29k-wrs
+ os=-vxworks
+ ;;
+ w65*)
+ basic_machine=w65-wdc
+ os=-none
+ ;;
+ w89k-*)
+ basic_machine=hppa1.1-winbond
+ os=-proelf
+ ;;
+ xbox)
+ basic_machine=i686-pc
+ os=-mingw32
+ ;;
+ xps | xps100)
+ basic_machine=xps100-honeywell
+ ;;
+ xscale-* | xscalee[bl]-*)
+ basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
+ ;;
+ ymp)
+ basic_machine=ymp-cray
+ os=-unicos
+ ;;
+ z8k-*-coff)
+ basic_machine=z8k-unknown
+ os=-sim
+ ;;
+ z80-*-coff)
+ basic_machine=z80-unknown
+ os=-sim
+ ;;
+ none)
+ basic_machine=none-none
+ os=-none
+ ;;
+
+# Here we handle the default manufacturer of certain CPU types. It is in
+# some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ basic_machine=hppa1.1-winbond
+ ;;
+ op50n)
+ basic_machine=hppa1.1-oki
+ ;;
+ op60c)
+ basic_machine=hppa1.1-oki
+ ;;
+ romp)
+ basic_machine=romp-ibm
+ ;;
+ mmix)
+ basic_machine=mmix-knuth
+ ;;
+ rs6000)
+ basic_machine=rs6000-ibm
+ ;;
+ vax)
+ basic_machine=vax-dec
+ ;;
+ pdp10)
+ # there are many clones, so DEC is not a safe bet
+ basic_machine=pdp10-unknown
+ ;;
+ pdp11)
+ basic_machine=pdp11-dec
+ ;;
+ we32k)
+ basic_machine=we32k-att
+ ;;
+ sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
+ basic_machine=sh-unknown
+ ;;
+ sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
+ basic_machine=sparc-sun
+ ;;
+ cydra)
+ basic_machine=cydra-cydrome
+ ;;
+ orion)
+ basic_machine=orion-highlevel
+ ;;
+ orion105)
+ basic_machine=clipper-highlevel
+ ;;
+ mac | mpw | mac-mpw)
+ basic_machine=m68k-apple
+ ;;
+ pmac | pmac-mpw)
+ basic_machine=powerpc-apple
+ ;;
+ *-unknown)
+ # Make sure to match an already-canonicalized machine name.
+ ;;
+ *)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+ *-digital*)
+ basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+ ;;
+ *-commodore*)
+ basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+ ;;
+ *)
+ ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+ # First match some system type aliases
+ # that might get confused with valid system types.
+ # -solaris* is a basic system type, with this one exception.
+ -auroraux)
+ os=-auroraux
+ ;;
+ -solaris1 | -solaris1.*)
+ os=`echo $os | sed -e 's|solaris1|sunos4|'`
+ ;;
+ -solaris)
+ os=-solaris2
+ ;;
+ -svr4*)
+ os=-sysv4
+ ;;
+ -unixware*)
+ os=-sysv4.2uw
+ ;;
+ -gnu/linux*)
+ os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+ ;;
+ # First accept the basic system types.
+ # The portable systems comes first.
+ # Each alternative MUST END IN A *, to match a version number.
+ # -sysv* is not here because it comes later, after sysvr4.
+ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
+ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
+ | -sym* | -kopensolaris* | -plan9* \
+ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ | -aos* | -aros* \
+ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+ | -bitrig* | -openbsd* | -solidbsd* \
+ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* | -cegcc* \
+ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
+ | -linux-newlib* | -linux-musl* | -linux-uclibc* \
+ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*)
+ # Remember, each alternative MUST END IN *, to match a version number.
+ ;;
+ -qnx*)
+ case $basic_machine in
+ x86-* | i*86-*)
+ ;;
+ *)
+ os=-nto$os
+ ;;
+ esac
+ ;;
+ -nto-qnx*)
+ ;;
+ -nto*)
+ os=`echo $os | sed -e 's|nto|nto-qnx|'`
+ ;;
+ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+ ;;
+ -mac*)
+ os=`echo $os | sed -e 's|mac|macos|'`
+ ;;
+ -linux-dietlibc)
+ os=-linux-dietlibc
+ ;;
+ -linux*)
+ os=`echo $os | sed -e 's|linux|linux-gnu|'`
+ ;;
+ -sunos5*)
+ os=`echo $os | sed -e 's|sunos5|solaris2|'`
+ ;;
+ -sunos6*)
+ os=`echo $os | sed -e 's|sunos6|solaris3|'`
+ ;;
+ -opened*)
+ os=-openedition
+ ;;
+ -os400*)
+ os=-os400
+ ;;
+ -wince*)
+ os=-wince
+ ;;
+ -osfrose*)
+ os=-osfrose
+ ;;
+ -osf*)
+ os=-osf
+ ;;
+ -utek*)
+ os=-bsd
+ ;;
+ -dynix*)
+ os=-bsd
+ ;;
+ -acis*)
+ os=-aos
+ ;;
+ -atheos*)
+ os=-atheos
+ ;;
+ -syllable*)
+ os=-syllable
+ ;;
+ -386bsd)
+ os=-bsd
+ ;;
+ -ctix* | -uts*)
+ os=-sysv
+ ;;
+ -nova*)
+ os=-rtmk-nova
+ ;;
+ -ns2 )
+ os=-nextstep2
+ ;;
+ -nsk*)
+ os=-nsk
+ ;;
+ # Preserve the version number of sinix5.
+ -sinix5.*)
+ os=`echo $os | sed -e 's|sinix|sysv|'`
+ ;;
+ -sinix*)
+ os=-sysv4
+ ;;
+ -tpf*)
+ os=-tpf
+ ;;
+ -triton*)
+ os=-sysv3
+ ;;
+ -oss*)
+ os=-sysv3
+ ;;
+ -svr4)
+ os=-sysv4
+ ;;
+ -svr3)
+ os=-sysv3
+ ;;
+ -sysvr4)
+ os=-sysv4
+ ;;
+ # This must come after -sysvr4.
+ -sysv*)
+ ;;
+ -ose*)
+ os=-ose
+ ;;
+ -es1800*)
+ os=-ose
+ ;;
+ -xenix)
+ os=-xenix
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ os=-mint
+ ;;
+ -aros*)
+ os=-aros
+ ;;
+ -zvmoe)
+ os=-zvmoe
+ ;;
+ -dicos*)
+ os=-dicos
+ ;;
+ -nacl*)
+ ;;
+ -none)
+ ;;
+ *)
+ # Get rid of the `-' at the beginning of $os.
+ os=`echo $os | sed 's/[^-]*-//'`
+ echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system. Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+ score-*)
+ os=-elf
+ ;;
+ spu-*)
+ os=-elf
+ ;;
+ *-acorn)
+ os=-riscix1.2
+ ;;
+ arm*-rebel)
+ os=-linux
+ ;;
+ arm*-semi)
+ os=-aout
+ ;;
+ c4x-* | tic4x-*)
+ os=-coff
+ ;;
+ c8051-*)
+ os=-elf
+ ;;
+ hexagon-*)
+ os=-elf
+ ;;
+ tic54x-*)
+ os=-coff
+ ;;
+ tic55x-*)
+ os=-coff
+ ;;
+ tic6x-*)
+ os=-coff
+ ;;
+ # This must come before the *-dec entry.
+ pdp10-*)
+ os=-tops20
+ ;;
+ pdp11-*)
+ os=-none
+ ;;
+ *-dec | vax-*)
+ os=-ultrix4.2
+ ;;
+ m68*-apollo)
+ os=-domain
+ ;;
+ i386-sun)
+ os=-sunos4.0.2
+ ;;
+ m68000-sun)
+ os=-sunos3
+ ;;
+ m68*-cisco)
+ os=-aout
+ ;;
+ mep-*)
+ os=-elf
+ ;;
+ mips*-cisco)
+ os=-elf
+ ;;
+ mips*-*)
+ os=-elf
+ ;;
+ or32-*)
+ os=-coff
+ ;;
+ *-tti) # must be before sparc entry or we get the wrong os.
+ os=-sysv3
+ ;;
+ sparc-* | *-sun)
+ os=-sunos4.1.1
+ ;;
+ *-be)
+ os=-beos
+ ;;
+ *-haiku)
+ os=-haiku
+ ;;
+ *-ibm)
+ os=-aix
+ ;;
+ *-knuth)
+ os=-mmixware
+ ;;
+ *-wec)
+ os=-proelf
+ ;;
+ *-winbond)
+ os=-proelf
+ ;;
+ *-oki)
+ os=-proelf
+ ;;
+ *-hp)
+ os=-hpux
+ ;;
+ *-hitachi)
+ os=-hiux
+ ;;
+ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+ os=-sysv
+ ;;
+ *-cbm)
+ os=-amigaos
+ ;;
+ *-dg)
+ os=-dgux
+ ;;
+ *-dolphin)
+ os=-sysv3
+ ;;
+ m68k-ccur)
+ os=-rtu
+ ;;
+ m88k-omron*)
+ os=-luna
+ ;;
+ *-next )
+ os=-nextstep
+ ;;
+ *-sequent)
+ os=-ptx
+ ;;
+ *-crds)
+ os=-unos
+ ;;
+ *-ns)
+ os=-genix
+ ;;
+ i370-*)
+ os=-mvs
+ ;;
+ *-next)
+ os=-nextstep3
+ ;;
+ *-gould)
+ os=-sysv
+ ;;
+ *-highlevel)
+ os=-bsd
+ ;;
+ *-encore)
+ os=-bsd
+ ;;
+ *-sgi)
+ os=-irix
+ ;;
+ *-siemens)
+ os=-sysv4
+ ;;
+ *-masscomp)
+ os=-rtu
+ ;;
+ f30[01]-fujitsu | f700-fujitsu)
+ os=-uxpv
+ ;;
+ *-rom68k)
+ os=-coff
+ ;;
+ *-*bug)
+ os=-coff
+ ;;
+ *-apple)
+ os=-macos
+ ;;
+ *-atari*)
+ os=-mint
+ ;;
+ *)
+ os=-none
+ ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer. We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+ *-unknown)
+ case $os in
+ -riscix*)
+ vendor=acorn
+ ;;
+ -sunos*)
+ vendor=sun
+ ;;
+ -cnk*|-aix*)
+ vendor=ibm
+ ;;
+ -beos*)
+ vendor=be
+ ;;
+ -hpux*)
+ vendor=hp
+ ;;
+ -mpeix*)
+ vendor=hp
+ ;;
+ -hiux*)
+ vendor=hitachi
+ ;;
+ -unos*)
+ vendor=crds
+ ;;
+ -dgux*)
+ vendor=dg
+ ;;
+ -luna*)
+ vendor=omron
+ ;;
+ -genix*)
+ vendor=ns
+ ;;
+ -mvs* | -opened*)
+ vendor=ibm
+ ;;
+ -os400*)
+ vendor=ibm
+ ;;
+ -ptx*)
+ vendor=sequent
+ ;;
+ -tpf*)
+ vendor=ibm
+ ;;
+ -vxsim* | -vxworks* | -windiss*)
+ vendor=wrs
+ ;;
+ -aux*)
+ vendor=apple
+ ;;
+ -hms*)
+ vendor=hitachi
+ ;;
+ -mpw* | -macos*)
+ vendor=apple
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ vendor=atari
+ ;;
+ -vos*)
+ vendor=stratus
+ ;;
+ esac
+ basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+ ;;
+esac
+
+echo $basic_machine$os
+exit
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/configure b/configure
index 9027d3e..5d4af93 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for pdfgrep 1.4.1.
+# Generated by GNU Autoconf 2.69 for pdfgrep 2.0.
#
# Report bugs to <pdfgrep-users@pdfgrep.org>.
#
@@ -580,8 +580,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='pdfgrep'
PACKAGE_TARNAME='pdfgrep'
-PACKAGE_VERSION='1.4.1'
-PACKAGE_STRING='pdfgrep 1.4.1'
+PACKAGE_VERSION='2.0'
+PACKAGE_STRING='pdfgrep 2.0'
PACKAGE_BUGREPORT='pdfgrep-users@pdfgrep.org'
PACKAGE_URL=''
@@ -626,12 +626,10 @@ am__EXEEXT_TRUE
LTLIBOBJS
ENABLE_COV_FALSE
ENABLE_COV_TRUE
-HAVE_GENHTML
-HAVE_LCOV
+HAVE_GCOVR
HAVE_GCOV
cov_LDFLAGS
cov_CFLAGS
-DEJAGNU
BUILD_DOCUMENTATION_FALSE
BUILD_DOCUMENTATION_TRUE
HAVE_A2X
@@ -645,6 +643,17 @@ unac_LIBS
unac_CFLAGS
libpcre_LIBS
libpcre_CFLAGS
+LIBGCRYPT_CFLAGS
+LIBGCRYPT_LIBS
+LIBGCRYPT_CONFIG
+host_os
+host_vendor
+host_cpu
+host
+build_os
+build_vendor
+build_cpu
+build
poppler_cpp_LIBS
poppler_cpp_CFLAGS
PKG_CONFIG_LIBDIR
@@ -748,6 +757,7 @@ ac_user_opts='
enable_option_checking
enable_silent_rules
enable_dependency_tracking
+with_libgcrypt_prefix
with_libpcre
with_unac
with_zsh_completion
@@ -1316,7 +1326,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures pdfgrep 1.4.1 to adapt to many kinds of systems.
+\`configure' configures pdfgrep 2.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1377,12 +1387,16 @@ Program names:
--program-prefix=PREFIX prepend PREFIX to installed program names
--program-suffix=SUFFIX append SUFFIX to installed program names
--program-transform-name=PROGRAM run sed PROGRAM on installed program names
+
+System types:
+ --build=BUILD configure for building on BUILD [guessed]
+ --host=HOST cross-compile to build programs to run on HOST [BUILD]
_ACEOF
fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of pdfgrep 1.4.1:";;
+ short | recursive ) echo "Configuration of pdfgrep 2.0:";;
esac
cat <<\_ACEOF
@@ -1405,6 +1419,8 @@ Optional Features:
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --with-libgcrypt-prefix=PFX
+ prefix where LIBGCRYPT is installed (optional)
--without-libpcre disable support for perl compatible regular
expresssions
@@ -1508,7 +1524,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-pdfgrep configure 1.4.1
+pdfgrep configure 2.0
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1915,7 +1931,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by pdfgrep $as_me 1.4.1, which was
+It was created by pdfgrep $as_me 2.0, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -2779,7 +2795,7 @@ fi
# Define the identity of the package.
PACKAGE='pdfgrep'
- VERSION='1.4.1'
+ VERSION='2.0'
cat >>confdefs.h <<_ACEOF
@@ -4838,7 +4854,7 @@ fi
done
-for ac_header in stdlib.h string.h unistd.h sys/ioctl.h getopt.h termios.h
+for ac_header in stdlib.h string.h unistd.h getopt.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -5020,7 +5036,9 @@ fi
done
-if test -d "${GIT_DIR:-${ac_top_srcdir:-./}/.git}" ; then
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for git head" >&5
+$as_echo_n "checking for git head... " >&6; }
+if git version >/dev/null 2>&1 && test -d "${GIT_DIR:-${ac_top_srcdir:-./}/.git}" ; then
GITHEAD=`git describe 2>/dev/null`
if test -z ${GITHEAD} ; then
GITHEAD=`git rev-parse HEAD`
@@ -5031,8 +5049,6 @@ if test -d "${GIT_DIR:-${ac_top_srcdir:-./}/.git}" ; then
else
GITHEAD=
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for git head" >&5
-$as_echo_n "checking for git head... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $GITHEAD" >&5
$as_echo "$GITHEAD" >&6; }
if test "x$GITHEAD" != "x"; then :
@@ -5045,6 +5061,10 @@ _ACEOF
fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pkg-config m4 macros" >&5
+$as_echo_n "checking for pkg-config m4 macros... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
@@ -5260,6 +5280,255 @@ fi
+# Make sure we can run config.sub.
+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+ as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
+$as_echo_n "checking build system type... " >&6; }
+if ${ac_cv_build+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_build_alias=$build_alias
+test "x$ac_build_alias" = x &&
+ ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+test "x$ac_build_alias" = x &&
+ as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
+ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+ as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
+$as_echo "$ac_cv_build" >&6; }
+case $ac_cv_build in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
+esac
+build=$ac_cv_build
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_build
+shift
+build_cpu=$1
+build_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+build_os=$*
+IFS=$ac_save_IFS
+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
+$as_echo_n "checking host system type... " >&6; }
+if ${ac_cv_host+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test "x$host_alias" = x; then
+ ac_cv_host=$ac_cv_build
+else
+ ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+ as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
+$as_echo "$ac_cv_host" >&6; }
+case $ac_cv_host in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
+esac
+host=$ac_cv_host
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_host
+shift
+host_cpu=$1
+host_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+host_os=$*
+IFS=$ac_save_IFS
+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+
+
+
+
+# Check whether --with-libgcrypt-prefix was given.
+if test "${with_libgcrypt_prefix+set}" = set; then :
+ withval=$with_libgcrypt_prefix; libgcrypt_config_prefix="$withval"
+else
+ libgcrypt_config_prefix=""
+fi
+
+ if test x"${LIBGCRYPT_CONFIG}" = x ; then
+ if test x"${libgcrypt_config_prefix}" != x ; then
+ LIBGCRYPT_CONFIG="${libgcrypt_config_prefix}/bin/libgcrypt-config"
+ else
+ case "${SYSROOT}" in
+ /*)
+ if test -x "${SYSROOT}/bin/libgcrypt-config" ; then
+ LIBGCRYPT_CONFIG="${SYSROOT}/bin/libgcrypt-config"
+ fi
+ ;;
+ '')
+ ;;
+ *)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring \$SYSROOT as it is not an absolute path." >&5
+$as_echo "$as_me: WARNING: Ignoring \$SYSROOT as it is not an absolute path." >&2;}
+ ;;
+ esac
+ fi
+ fi
+
+ # Extract the first word of "libgcrypt-config", so it can be a program name with args.
+set dummy libgcrypt-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_LIBGCRYPT_CONFIG+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $LIBGCRYPT_CONFIG in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_LIBGCRYPT_CONFIG="$LIBGCRYPT_CONFIG" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_LIBGCRYPT_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ test -z "$ac_cv_path_LIBGCRYPT_CONFIG" && ac_cv_path_LIBGCRYPT_CONFIG="no"
+ ;;
+esac
+fi
+LIBGCRYPT_CONFIG=$ac_cv_path_LIBGCRYPT_CONFIG
+if test -n "$LIBGCRYPT_CONFIG"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBGCRYPT_CONFIG" >&5
+$as_echo "$LIBGCRYPT_CONFIG" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ tmp=1.0.0
+ if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
+ req_libgcrypt_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
+ min_libgcrypt_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
+ else
+ req_libgcrypt_api=0
+ min_libgcrypt_version="$tmp"
+ fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBGCRYPT - version >= $min_libgcrypt_version" >&5
+$as_echo_n "checking for LIBGCRYPT - version >= $min_libgcrypt_version... " >&6; }
+ ok=no
+ if test "$LIBGCRYPT_CONFIG" != "no" ; then
+ req_major=`echo $min_libgcrypt_version | \
+ sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\1/'`
+ req_minor=`echo $min_libgcrypt_version | \
+ sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\2/'`
+ req_micro=`echo $min_libgcrypt_version | \
+ sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\3/'`
+ libgcrypt_config_version=`$LIBGCRYPT_CONFIG --version`
+ major=`echo $libgcrypt_config_version | \
+ sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1/'`
+ minor=`echo $libgcrypt_config_version | \
+ sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\2/'`
+ micro=`echo $libgcrypt_config_version | \
+ sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\3/'`
+ if test "$major" -gt "$req_major"; then
+ ok=yes
+ else
+ if test "$major" -eq "$req_major"; then
+ if test "$minor" -gt "$req_minor"; then
+ ok=yes
+ else
+ if test "$minor" -eq "$req_minor"; then
+ if test "$micro" -ge "$req_micro"; then
+ ok=yes
+ fi
+ fi
+ fi
+ fi
+ fi
+ fi
+ if test $ok = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes ($libgcrypt_config_version)" >&5
+$as_echo "yes ($libgcrypt_config_version)" >&6; }
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ fi
+ if test $ok = yes; then
+ # If we have a recent libgcrypt, we should also check that the
+ # API is compatible
+ if test "$req_libgcrypt_api" -gt 0 ; then
+ tmp=`$LIBGCRYPT_CONFIG --api-version 2>/dev/null || echo 0`
+ if test "$tmp" -gt 0 ; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking LIBGCRYPT API version" >&5
+$as_echo_n "checking LIBGCRYPT API version... " >&6; }
+ if test "$req_libgcrypt_api" -eq "$tmp" ; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: okay" >&5
+$as_echo "okay" >&6; }
+ else
+ ok=no
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: does not match. want=$req_libgcrypt_api got=$tmp" >&5
+$as_echo "does not match. want=$req_libgcrypt_api got=$tmp" >&6; }
+ fi
+ fi
+ fi
+ fi
+ if test $ok = yes; then
+ LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG --cflags`
+ LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG --libs`
+
+
+
+
+ libgcrypt_config_host=`$LIBGCRYPT_CONFIG --host 2>/dev/null || echo none`
+ if test x"$libgcrypt_config_host" != xnone ; then
+ if test x"$libgcrypt_config_host" != x"$host" ; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
+***
+*** The config script $LIBGCRYPT_CONFIG was
+*** built for $libgcrypt_config_host and thus may not match the
+*** used host $host.
+*** You may want to use the configure option --with-libgcrypt-prefix
+*** to specify a matching config script or use \$SYSROOT.
+***" >&5
+$as_echo "$as_me: WARNING:
+***
+*** The config script $LIBGCRYPT_CONFIG was
+*** built for $libgcrypt_config_host and thus may not match the
+*** used host $host.
+*** You may want to use the configure option --with-libgcrypt-prefix
+*** to specify a matching config script or use \$SYSROOT.
+***" >&2;}
+ gpg_config_script_warn="$gpg_config_script_warn libgcrypt"
+ fi
+ fi
+ else
+ LIBGCRYPT_CFLAGS=""
+ LIBGCRYPT_LIBS=""
+
+ as_fn_error $? "*** libgcrypt not found!" "$LINENO" 5
+
+ fi
+
+
+
+
# Check whether --with-libpcre was given.
if test "${with_libpcre+set}" = set; then :
@@ -5611,14 +5880,6 @@ else
fi
-
-if test x"$DEJAGNU" = x
-then
- DEJAGNU="\$(top_srcdir)/testsuite/global-conf.exp"
-fi
-
-
-
# Coverage ssupport
# Check whether --enable-coverage was given.
if test "${enable_coverage+set}" = set; then :
@@ -5677,58 +5938,15 @@ fi
as_fn_error $? "gcov not found, but configured with --enable-coverage" "$LINENO" 5
fi
- # Extract the first word of "lcov", so it can be a program name with args.
-set dummy lcov; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_HAVE_LCOV+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$HAVE_LCOV"; then
- ac_cv_prog_HAVE_LCOV="$HAVE_LCOV" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_HAVE_LCOV="yes"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
- test -z "$ac_cv_prog_HAVE_LCOV" && ac_cv_prog_HAVE_LCOV="no"
-fi
-fi
-HAVE_LCOV=$ac_cv_prog_HAVE_LCOV
-if test -n "$HAVE_LCOV"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HAVE_LCOV" >&5
-$as_echo "$HAVE_LCOV" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
- if test "x$HAVE_LCOV" = "xno"; then :
-
- as_fn_error $? "lcov not found, but configured with --enable-coverage" "$LINENO" 5
-
-fi
- # Extract the first word of "genhtml", so it can be a program name with args.
-set dummy genhtml; ac_word=$2
+ # Extract the first word of "gcovr", so it can be a program name with args.
+set dummy gcovr; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_HAVE_GENHTML+:} false; then :
+if ${ac_cv_prog_HAVE_GCOVR+:} false; then :
$as_echo_n "(cached) " >&6
else
- if test -n "$HAVE_GENHTML"; then
- ac_cv_prog_HAVE_GENHTML="$HAVE_GENHTML" # Let the user override the test.
+ if test -n "$HAVE_GCOVR"; then
+ ac_cv_prog_HAVE_GCOVR="$HAVE_GCOVR" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
@@ -5737,7 +5955,7 @@ do
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_HAVE_GENHTML="yes"
+ ac_cv_prog_HAVE_GCOVR="yes"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
@@ -5745,22 +5963,23 @@ done
done
IFS=$as_save_IFS
- test -z "$ac_cv_prog_HAVE_GENHTML" && ac_cv_prog_HAVE_GENHTML="no"
+ test -z "$ac_cv_prog_HAVE_GCOVR" && ac_cv_prog_HAVE_GCOVR="no"
fi
fi
-HAVE_GENHTML=$ac_cv_prog_HAVE_GENHTML
-if test -n "$HAVE_GENHTML"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HAVE_GENHTML" >&5
-$as_echo "$HAVE_GENHTML" >&6; }
+HAVE_GCOVR=$ac_cv_prog_HAVE_GCOVR
+if test -n "$HAVE_GCOVR"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HAVE_GCOVR" >&5
+$as_echo "$HAVE_GCOVR" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
- if test "x$HAVE_GENHTML" = "xno"; then :
+ if test "x$HAVE_GCOVR" = "xno"; then :
- as_fn_error $? "genhtml not found, but configured with --enable-coverage" "$LINENO" 5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: gcovr not found, but configured with --enable-coverage" >&5
+$as_echo "$as_me: WARNING: gcovr not found, but configured with --enable-coverage" >&2;}
fi
@@ -6327,7 +6546,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by pdfgrep $as_me 1.4.1, which was
+This file was extended by pdfgrep $as_me 2.0, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -6393,7 +6612,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-pdfgrep config.status 1.4.1
+pdfgrep config.status 2.0
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
@@ -7258,4 +7477,3 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
fi
-
diff --git a/configure.ac b/configure.ac
index 407bc82..4f8cd73 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([pdfgrep], [1.4.1], [pdfgrep-users@pdfgrep.org])
+AC_INIT([pdfgrep], [2.0], [pdfgrep-users@pdfgrep.org])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([foreign])
AC_CONFIG_HEADER([config.h])
@@ -9,7 +9,7 @@ AC_PROG_CC
dnl check for c++11 std
AX_CXX_COMPILE_STDCXX_11([noext], [mandatory])
-AC_CHECK_HEADERS([stdlib.h string.h unistd.h sys/ioctl.h getopt.h termios.h])
+AC_CHECK_HEADERS([stdlib.h string.h unistd.h getopt.h])
AC_FUNC_MALLOC
AC_FUNC_REALLOC
@@ -17,8 +17,9 @@ AC_CHECK_FUNCS([regcomp])
AC_CHECK_FUNCS([getopt_long])
AC_CHECK_FUNCS([strcasestr])
+AC_MSG_CHECKING([for git head])
dnl git revision, code stolen from paludis
-if test -d "${GIT_DIR:-${ac_top_srcdir:-./}/.git}" ; then
+if git version >/dev/null 2>&1 && test -d "${GIT_DIR:-${ac_top_srcdir:-./}/.git}" ; then
GITHEAD=`git describe 2>/dev/null`
if test -z ${GITHEAD} ; then
GITHEAD=`git rev-parse HEAD`
@@ -29,18 +30,34 @@ if test -d "${GIT_DIR:-${ac_top_srcdir:-./}/.git}" ; then
else
GITHEAD=
fi
-AC_MSG_CHECKING([for git head])
AC_MSG_RESULT([$GITHEAD])
AS_IF([test "x$GITHEAD" != "x"], [
AC_DEFINE_UNQUOTED([PDFGREP_GIT_HEAD], ["$GITHEAD"], [Git commit used to build this programm])
])
+dnl Check for presence of PKG_CHECK_MODULES macro
+AC_MSG_CHECKING([for pkg-config m4 macros])
+ifdef([PKG_CHECK_MODULES], [AC_MSG_RESULT([yes])], [
+ AC_MSG_RESULT(no)
+ AC_MSG_ERROR([*** pkg-config macro PKG_CHECK_MODULES is not defined!
+
+This can happen when ./configure was built without pkg-config installed.
+Please install pkg-config and re-run autoconf.])
+])
dnl Poppler checking
PKG_CHECK_MODULES(poppler_cpp, poppler-cpp)
AC_SUBST(poppler_cpp_CFLAGS)
AC_SUBST(poppler_cpp_LIBS)
+dnl gcrypt library for SHA1
+AM_PATH_LIBGCRYPT([1.0.0], [
+ AC_SUBST(LIBGCRYPT_LIBS)
+ AC_SUBST(LIBGCRYPT_CFLAGS)
+], [
+ AC_MSG_ERROR([*** libgcrypt not found!])
+])
+
dnl PCRE (optional)
AC_ARG_WITH([libpcre],
AS_HELP_STRING([--without-libpcre], [disable support for perl compatible regular expresssions])
@@ -112,15 +129,6 @@ AS_IF([test "x$enable_doc" != "xno"], [
AM_CONDITIONAL([BUILD_DOCUMENTATION], [test "x$enable_doc" != "xno"])
-dnl Set global config file for DEJAGNU
-
-if test x"$DEJAGNU" = x
-then
- DEJAGNU="\$(top_srcdir)/testsuite/global-conf.exp"
-fi
-
-AC_SUBST(DEJAGNU)
-
# Coverage ssupport
AC_ARG_ENABLE([coverage],
AS_HELP_STRING([--enable-coverage], [compile for coverage reports with gcov. For testing only. (default=no)])
@@ -137,13 +145,9 @@ AS_IF([test "x$enable_coverage" = "xyes"], [
AS_IF([test "x$HAVE_GCOV" = "xno"], [
AC_MSG_ERROR([gcov not found, but configured with --enable-coverage])
])
- AC_CHECK_PROG(HAVE_LCOV, [lcov], [yes], [no])
- AS_IF([test "x$HAVE_LCOV" = "xno"], [
- AC_MSG_ERROR([lcov not found, but configured with --enable-coverage])
- ])
- AC_CHECK_PROG(HAVE_GENHTML, [genhtml], [yes], [no])
- AS_IF([test "x$HAVE_GENHTML" = "xno"], [
- AC_MSG_ERROR([genhtml not found, but configured with --enable-coverage])
+ AC_CHECK_PROG(HAVE_GCOVR, [gcovr], [yes], [no])
+ AS_IF([test "x$HAVE_GCOVR" = "xno"], [
+ AC_MSG_WARN([gcovr not found, but configured with --enable-coverage])
])
])
@@ -158,4 +162,3 @@ AC_CONFIG_FILES([Makefile
testsuite/lib/Makefile
testsuite/pdfgrep.tests/Makefile])
AC_OUTPUT
-
diff --git a/doc/Makefile.in b/doc/Makefile.in
index 92f7728..3d57df1 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -85,6 +85,8 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
subdir = doc
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \
@@ -167,7 +169,6 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
-DEJAGNU = @DEJAGNU@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
@@ -178,14 +179,16 @@ GREP = @GREP@
HAVE_A2X = @HAVE_A2X@
HAVE_CXX11 = @HAVE_CXX11@
HAVE_GCOV = @HAVE_GCOV@
-HAVE_GENHTML = @HAVE_GENHTML@
-HAVE_LCOV = @HAVE_LCOV@
+HAVE_GCOVR = @HAVE_GCOVR@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
+LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
+LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
+LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
@@ -220,7 +223,11 @@ am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
+build = @build@
build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
builddir = @builddir@
cov_CFLAGS = @cov_CFLAGS@
cov_LDFLAGS = @cov_LDFLAGS@
@@ -229,7 +236,11 @@ datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
+host = @host@
host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
diff --git a/doc/pdfgrep.1 b/doc/pdfgrep.1
index d34add8..3d3a27d 100644
--- a/doc/pdfgrep.1
+++ b/doc/pdfgrep.1
@@ -1,13 +1,13 @@
'\" t
.\" Title: pdfgrep
.\" Author: [see the "AUTHORS" section]
-.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
-.\" Date: 09/26/2015
+.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
+.\" Date: 01/25/2017
.\" Manual: Pdfgrep Manual
-.\" Source: Pdfgrep 1.4.1
+.\" Source: Pdfgrep 2.0
.\" Language: English
.\"
-.TH "PDFGREP" "1" "09/26/2015" "Pdfgrep 1\&.4\&.1" "Pdfgrep Manual"
+.TH "PDFGREP" "1" "01/25/2017" "Pdfgrep 2\&.0" "Pdfgrep Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@@ -53,6 +53,11 @@ Interpret
as a list of fixed strings separated by newlines, any of which is to be matched\&.
.RE
.PP
+\fB\-\-cache\fR
+.RS 4
+Use a cache for the rendered text to speed up the operation on large files\&.
+.RE
+.PP
\fB\-P\fR, \fB\-\-perl\-regexp\fR
.RS 4
Interpret
@@ -84,16 +89,8 @@ Suppress normal output\&. Instead print the number of matches for each input fil
\fB\-p\fR, \fB\-\-page\-count\fR
.RS 4
Like
-\fB\-c\fR, but prints the number of matches per page\&.
-.RE
-.PP
-\fB\-C\fR, \fB\-\-context\fR \fINUM\fR
-.RS 4
-Print at most
-\fIINUM\fR
-characters of context around each match\&. The exact number will vary, because pdfgrep tries to respect word boundaries\&. If
-\fINUM\fR
-is "\fBline\fR", the whole line will be printed\&. If this option is not set, pdfgrep tries to print lines that are not longer than the terminal width\&.
+\fB\-c\fR, but prints the number of matches per page\&. Implies
+\fB\-n\fR\&.
.RE
.PP
\fB\-\-color\fR \fIWHEN\fR
@@ -138,6 +135,33 @@ Same as
\fB\-r\fR, but follows all symlinks\&.
.RE
.PP
+\fB\-A\fR \fINUM\fR, \fB\-\-after\-context=NUM\fR
+.RS 4
+Print
+\fINUM\fR
+lines of context after matching lines\&. Contiguous groups of matches are separated by a line containing
+\fB\-\-\fR\&. With
+\fB\-o\fR, this option has no effect\&.
+.RE
+.PP
+\fB\-B\fR \fINUM\fR, \fB\-\-before\-context=NUM\fR
+.RS 4
+Print
+\fINUM\fR
+lines of context before matching lines\&. Contiguous groups of matches are separated by a line containing
+\fB\-\-\fR\&. With
+\fB\-o\fR, this option has no effect\&.
+.RE
+.PP
+\fB\-C\fR \fINUM\fR, \fB\-\-context=NUM\fR
+.RS 4
+Print
+\fINUM\fR
+lines of context before and after matching lines\&. Contiguous groups of matches are separated by a line containing
+\fB\-\-\fR\&. With
+\fB\-o\fR, this option has no effect\&.
+.RE
+.PP
\fB\-\-exclude=\fR\fIGLOB\fR
.RS 4
Skip files whose base name matches
@@ -221,8 +245,10 @@ for details\&.
.PP
\fB\-q\fR, \fB\-\-quiet\fR
.RS 4
-Suppress all normal output to stdout\&. Errors will be printed and the exit codes will be returned (see below)\&.
+Suppress all normal output to stdout\&. Exit immediately with exit status zero if a match is found, even in case of errors\&. Use this if you only care about the presence of matches, not their number or content\&.
.RE
+.sp
+Errors will be printed and the exit codes will be returned (see below)\&.
.PP
\fB\-\-help\fR
.RS 4
@@ -259,6 +285,14 @@ and
\fBmc\fR
have the same effect\&.
.RE
+.SH "FILES"
+.PP
+\fB${XDG_CACHE_HOME}/pdfgrep/\fR*
+.RS 4
+Cache files written and used when
+\fB\-\-cache\fR
+is enabled\&. At most 200 cache entries older than a day are retained\&.
+.RE
.SH "EXAMPLES"
.PP
\fBPrint the first ten lines matching \fR\fB\fIpattern\fR\fR\fB and print their page number\fR
@@ -312,11 +346,6 @@ had to be used\&. That\(cqs because pdfgrep itself doesn\(cqt include options to
.SS "Reporting Bugs"
.sp
Bugs can either be reportet to the mailing list (pdfgrep\-users@pdfgrep\&.org) or to the bugtracker on gitlab (https://gitlab\&.com/pdfgrep/pdfgrep/issues)\&.
-.SS "Known Bugs"
-.sp
-\fBpdfgrep\fR prints a single line multiple times, if there is more than one match in that line\&. That doesn\(cqt mirror to the behavior of \fBgrep\fR\&.
-.sp
-Also, the current context options don\(cqt have the same semantics as the \fBgrep\fR ones\&.
.SH "AUTHORS"
.sp
\fBpdfgrep\fR is maintained by Hans\-Peter Deifel\&.
diff --git a/doc/pdfgrep.txt b/doc/pdfgrep.txt
index 3b5f493..eec998b 100644
--- a/doc/pdfgrep.txt
+++ b/doc/pdfgrep.txt
@@ -24,6 +24,9 @@ pages and not on lines.
*-F*, *--fixed-strings* :: Interpret 'PATTERN' as a list of fixed
strings separated by newlines, any of which is to be matched.
+*--cache* :: Use a cache for the rendered text to speed up the
+ operation on large files.
+
*-P*, *--perl-regexp* :: Interpret 'PATTERN' as a Perl compatible
regular expression (PCRE). See 'pcresyntax'(3) for a quick overview.
@@ -42,13 +45,7 @@ pages and not on lines.
on the same page will be counted individually.
*-p*, *--page-count* :: Like *-c*, but prints the number of matches
- per page.
-
-*-C*, *--context* 'NUM' :: Print at most 'INUM' characters of context
- around each match. The exact number will vary, because pdfgrep tries
- to respect word boundaries. If 'NUM' is "*line*", the whole line
- will be printed. If this option is not set, pdfgrep tries to print
- lines that are not longer than the terminal width.
+ per page. Implies *-n*.
*--color* 'WHEN' :: Surround file names, page numbers and matched text
with escape sequences to display them in color on the terminal. (The
@@ -67,6 +64,18 @@ pages and not on lines.
*-R*, *--dereference-recursive*:: Same as *-r*, but follows all
symlinks.
+*-A* 'NUM', *--after-context=NUM*:: Print 'NUM' lines of context after
+ matching lines. Contiguous groups of matches are separated by a line
+ containing *--*. With *-o*, this option has no effect.
+
+*-B* 'NUM', *--before-context=NUM*:: Print 'NUM' lines of context
+ before matching lines. Contiguous groups of matches are separated by
+ a line containing *--*. With *-o*, this option has no effect.
+
+*-C* 'NUM', *--context=NUM*:: Print 'NUM' lines of context before and
+ after matching lines. Contiguous groups of matches are separated by
+ a line containing *--*. With *-o*, this option has no effect.
+
*--exclude=*'GLOB' :: Skip files whose base name matches 'GLOB'. See
'glob'(7) for wildcards you can use. You can use this option
multiple times to exclude more patterns. It takes precedence over
@@ -116,7 +125,12 @@ pages and not on lines.
*This option is experimental and only available if pdfgrep is
compiled with unac support.*
-*-q*, *--quiet* :: Suppress all normal output to stdout. Errors will
+*-q*, *--quiet* :: Suppress all normal output to stdout. Exit
+ immediately with exit status zero if a match is found, even in case
+ of errors. Use this if you only care about the presence of matches,
+ not their number or content.
+
+Errors will
be printed and the exit codes will be returned (see below).
*--help* :: Print a short summary of the options.
@@ -140,6 +154,12 @@ variable.
*se* are used by *pdfgrep*, where *mt*, *ms* and *mc* have the same
effect.
+== FILES
+
+*$\{XDG_CACHE_HOME\}/pdfgrep/** :: Cache files written and used when
+ *--cache* is enabled. At most 200 cache entries older than a day are
+ retained.
+
== Examples
*Print the first ten lines matching 'pattern' and print their page number* ::
+
@@ -170,13 +190,6 @@ Bugs can either be reportet to the mailing list
(pdfgrep-users@pdfgrep.org) or to the bugtracker on gitlab
(https://gitlab.com/pdfgrep/pdfgrep/issues).
-=== Known Bugs
-*pdfgrep* prints a single line multiple times, if there is more than
-one match in that line. That doesn't mirror to the behavior of *grep*.
-
-Also, the current context options don't have the same semantics as the
-*grep* ones.
-
== AUTHORS
*pdfgrep* is maintained by Hans-Peter Deifel.
diff --git a/src/Makefile.am b/src/Makefile.am
index 07885f8..dc703f2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,6 +1,6 @@
bin_PROGRAMS = pdfgrep
-pdfgrep_SOURCES = pdfgrep.h pdfgrep.cc output.cc output.h exclude.cc exclude.h regengine.h regengine.cc
+pdfgrep_SOURCES = pdfgrep.h pdfgrep.cc output.cc output.h exclude.cc exclude.h regengine.h regengine.cc search.h search.cc cache.h cache.cc
-pdfgrep_LDADD = $(poppler_cpp_LIBS) $(unac_LIBS) $(libpcre_LIBS) $(cov_LDFLAGS)
-AM_CPPFLAGS = $(poppler_cpp_CFLAGS) $(unac_CFLAGS) $(libpcre_CFLAGS) $(cov_CFLAGS)
+pdfgrep_LDADD = $(poppler_cpp_LIBS) $(unac_LIBS) $(libpcre_LIBS) $(cov_LDFLAGS) $(LIBGCRYPT_LIBS)
+AM_CPPFLAGS = $(poppler_cpp_CFLAGS) $(unac_CFLAGS) $(libpcre_CFLAGS) $(cov_CFLAGS) $(LIBGCRYPT_CFLAGS)
diff --git a/src/Makefile.in b/src/Makefile.in
index 72dd9f7..a09634d 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -86,6 +86,8 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
bin_PROGRAMS = pdfgrep$(EXEEXT)
subdir = src
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -101,11 +103,13 @@ CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS)
am_pdfgrep_OBJECTS = pdfgrep.$(OBJEXT) output.$(OBJEXT) \
- exclude.$(OBJEXT) regengine.$(OBJEXT)
+ exclude.$(OBJEXT) regengine.$(OBJEXT) search.$(OBJEXT) \
+ cache.$(OBJEXT)
pdfgrep_OBJECTS = $(am_pdfgrep_OBJECTS)
am__DEPENDENCIES_1 =
pdfgrep_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
@@ -193,7 +197,6 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
-DEJAGNU = @DEJAGNU@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
@@ -204,14 +207,16 @@ GREP = @GREP@
HAVE_A2X = @HAVE_A2X@
HAVE_CXX11 = @HAVE_CXX11@
HAVE_GCOV = @HAVE_GCOV@
-HAVE_GENHTML = @HAVE_GENHTML@
-HAVE_LCOV = @HAVE_LCOV@
+HAVE_GCOVR = @HAVE_GCOVR@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
+LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
+LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
+LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
@@ -246,7 +251,11 @@ am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
+build = @build@
build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
builddir = @builddir@
cov_CFLAGS = @cov_CFLAGS@
cov_LDFLAGS = @cov_LDFLAGS@
@@ -255,7 +264,11 @@ datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
+host = @host@
host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
@@ -285,9 +298,9 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
unac_CFLAGS = @unac_CFLAGS@
unac_LIBS = @unac_LIBS@
-pdfgrep_SOURCES = pdfgrep.h pdfgrep.cc output.cc output.h exclude.cc exclude.h regengine.h regengine.cc
-pdfgrep_LDADD = $(poppler_cpp_LIBS) $(unac_LIBS) $(libpcre_LIBS) $(cov_LDFLAGS)
-AM_CPPFLAGS = $(poppler_cpp_CFLAGS) $(unac_CFLAGS) $(libpcre_CFLAGS) $(cov_CFLAGS)
+pdfgrep_SOURCES = pdfgrep.h pdfgrep.cc output.cc output.h exclude.cc exclude.h regengine.h regengine.cc search.h search.cc cache.h cache.cc
+pdfgrep_LDADD = $(poppler_cpp_LIBS) $(unac_LIBS) $(libpcre_LIBS) $(cov_LDFLAGS) $(LIBGCRYPT_LIBS)
+AM_CPPFLAGS = $(poppler_cpp_CFLAGS) $(unac_CFLAGS) $(libpcre_CFLAGS) $(cov_CFLAGS) $(LIBGCRYPT_CFLAGS)
all: all-am
.SUFFIXES:
@@ -374,10 +387,12 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cache.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exclude.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/output.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdfgrep.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regengine.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/search.Po@am__quote@
.cc.o:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
diff --git a/src/cache.cc b/src/cache.cc
new file mode 100644
index 0000000..4d028b6
--- /dev/null
+++ b/src/cache.cc
@@ -0,0 +1,164 @@
+/***************************************************************************
+ * Copyright (C) 2017 by Christian Dietrich *
+ * stettberger@dokucode.de *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA. *
+ ***************************************************************************/
+
+#include "cache.h"
+#include "output.h"
+
+#include <fstream>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <iostream>
+#include <cstdlib>
+#include <unistd.h>
+#include <pwd.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <string.h>
+
+using namespace std;
+
+Cache::Cache(string cache_file)
+ : cache_file(cache_file), valid(false) {
+ // Open the cache file
+ ifstream fd(cache_file);
+ if (!fd) return;
+
+ unsigned char indicator;
+ fd >> indicator;
+ if (indicator != 'G') return;
+ for (std::string page; std::getline(fd, page, '\0'); ) {
+ pages.push_back(page);
+ }
+ valid = true;
+}
+
+void Cache::set_page(unsigned pagenum, const string &text) {
+ pages.resize(max(pagenum, (unsigned)pages.size()));
+ pages[pagenum-1] = text;
+}
+
+bool Cache::get_page(unsigned pagenum, string &text) {
+ if (!valid) return false;
+ if (pagenum-1 < pages.size()) {
+ text = pages[pagenum-1];
+ return true;
+ }
+ return false;
+}
+
+void Cache::dump() {
+ ofstream fd(cache_file);
+ if (!fd) return;
+ // The first byte of the cache file is an indicator byte, which
+ // can be written atomically. Initial it is \0, after all pages
+ // have been flushed, the indicator byte is written to 'G' (for
+ // good).
+ fd << '\0';
+ for (const string &page : pages) {
+ fd << page;
+ fd << '\0';
+ }
+ fd.flush();
+ fd.seekp(0, ios_base::beg);
+ fd << 'G';
+ fd.close();
+}
+
+// I feel so bad...
+static const char *cache_directory;
+static int agesort(const struct dirent ** a, const struct dirent **b) {
+ std::string A = string(cache_directory) + "/" + (*a)->d_name;
+ std::string B = string(cache_directory) + "/" + (*b)->d_name;
+
+ struct stat bufa, bufb;
+ if (stat(A.c_str(), &bufa) != 0) return 0;
+ if (stat(B.c_str(), &bufb) != 0) return 0;
+
+ return bufb.st_mtime - bufa.st_mtime;
+}
+
+static int agefilter(const struct dirent * a) {
+ if (a->d_name[0] == '.') return false;
+ std::string A = string(cache_directory) + "/" + a->d_name;
+ struct stat bufa;
+ if (stat(A.c_str(), &bufa) != 0) return false;
+
+ // Filter all files that are younger than one day
+ return (time(NULL) - bufa.st_mtime) > 24 * 60 * 60;
+}
+
+void limit_cachesize(const char *cache, int entries) {
+ struct dirent **namelist;
+ cache_directory = cache;
+ int n = scandir(cache, &namelist, agefilter, agesort);
+ if (n < 0) {
+ return;
+ } else {
+ while (entries--, n--) {
+ // Skip the first N cache entries
+ if (entries >= 0) continue;
+
+ string path(cache + string("/") + namelist[n]->d_name);
+ unlink(path.c_str());
+ free(namelist[n]);
+ }
+ free(namelist);
+ }
+}
+
+int find_cache_directory(std::string &dir)
+{
+ const char *cache_base = getenv("XDG_CACHE_HOME");
+
+ dir = "";
+ if (cache_base != NULL && cache_base[0] != '\0') {
+ dir += cache_base;
+ } else {
+ char *home = getenv("HOME");
+ if (home == NULL) {
+ struct passwd *passwd;
+ passwd = getpwuid(getuid());
+ if (passwd != NULL) {
+ home = passwd->pw_dir;
+ } else {
+ return -1;
+ }
+ }
+ dir += home;
+ dir += "/.cache";
+ }
+ // according to xdg spec, all directories should be created as 0700.
+ if (mkdir(dir.c_str(), 0700) && errno != EEXIST) {
+ char *msg = strerror(errno);
+ err() << "mkdir(" << dir << "): " << msg << endl;
+ return -1;
+ }
+
+ dir += "/pdfgrep/";
+
+ if (mkdir(dir.c_str(), 0700) && errno != EEXIST) {
+ char *msg = strerror(errno);
+ err() << "mkdir(" << dir << "): " << msg << endl;
+ return -1;
+ }
+ return 0;
+}
diff --git a/src/cache.h b/src/cache.h
new file mode 100644
index 0000000..33e9719
--- /dev/null
+++ b/src/cache.h
@@ -0,0 +1,48 @@
+/***************************************************************************
+ * Copyright (C) 2017 by Christian Dietrich *
+ * stettberger@dokucode.de *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA. *
+ ***************************************************************************/
+
+#ifndef CACHE_H
+#define CACHE_H
+
+#include <vector>
+#include <string>
+
+class Cache {
+ std::vector<std::string> pages;
+ std::string cache_file;
+ bool valid;
+public:
+ explicit Cache(std::string cache_file);
+
+ bool get_page(unsigned pagenum, std::string &text);
+ void set_page(unsigned pagenum, const std::string &text);
+
+ void dump();
+};
+
+void limit_cachesize(const char *cache, int entries);
+
+/** Write cache directory to dir.
+ *
+ * Returns -1 on failure and 0 on success
+ */
+int find_cache_directory(std::string &dir);
+
+#endif
diff --git a/src/exclude.cc b/src/exclude.cc
index ac48062..be9d646 100644
--- a/src/exclude.cc
+++ b/src/exclude.cc
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2015 by Hans-Peter Deifel *
+ * Copyright (C) 2017 by Hans-Peter Deifel *
* hpd@hpdeifel.de *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -24,6 +24,8 @@
#include <fnmatch.h>
+using namespace std;
+
void exclude_add(ExcludeList &list, const char *name)
{
list.push_front(name);
@@ -42,7 +44,7 @@ bool is_excluded(const ExcludeList &list, const char *name)
return false;
}
-bool is_excluded(const ExcludeList &list, const std::string &name)
+bool is_excluded(const ExcludeList &list, const string &name)
{
return is_excluded(list, name.c_str());
}
diff --git a/src/exclude.h b/src/exclude.h
index e250852..5f1c4ae 100644
--- a/src/exclude.h
+++ b/src/exclude.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2015 by Hans-Peter Deifel *
+ * Copyright (C) 2017 by Hans-Peter Deifel *
* hpd@hpdeifel.de *
* *
* This program is free software; you can redistribute it and/or modify *
diff --git a/src/output.cc b/src/output.cc
index d85f6d8..7f0d4d1 100644
--- a/src/output.cc
+++ b/src/output.cc
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2015 by Hans-Peter Deifel *
+ * Copyright (C) 2017 by Hans-Peter Deifel *
* hpd@hpdeifel.de *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -23,21 +23,24 @@
#include <stdio.h>
#include <string.h>
#include <ctype.h>
+#include <iostream>
-bool is_valid_color(const char* colorcode) {
+using namespace std;
+
+static bool is_valid_color(const char* colorcode) {
return colorcode && strcmp(colorcode, "");
}
-void start_color(bool use_colors, const char *colorcode)
+static void start_color(bool use_colors, const char *colorcode)
{
if (use_colors && is_valid_color(colorcode))
- printf("\33[%sm\33[K", colorcode);
+ cout << "\33[" << colorcode << "m\33[K";
}
-void end_color(bool use_colors, const char *colorcode)
+static void end_color(bool use_colors, const char *colorcode)
{
if (use_colors && is_valid_color(colorcode))
- printf("\33[m\33[K");
+ cout << "\33[m\33[K";
}
#define with_color(use_colors, color, code) \
@@ -49,157 +52,205 @@ void end_color(bool use_colors, const char *colorcode)
end_color(use_colors, color); \
} while (0);
-void print_line_prefix(const struct outconf *conf, const char *filename, const int pagenum)
+static void putsn(const string &str, int from, int to)
{
- if (filename && conf->filename) {
- with_color(conf->color, conf->colors.filename,
- printf("%s", filename););
- // Here, --null takes precedence over --match-prefix-separator
- // in the sense, that if --null is given, the null byte is
- // always printed after the filename instead of the separator.
- if (conf->null_byte_sep) {
- putchar('\0');
- } else {
- with_color(conf->color, conf->colors.separator,
- printf("%s", conf->prefix_sep.c_str()););
- }
- }
- if (pagenum >= 0 && conf->pagenum) {
- with_color(conf->color, conf->colors.pagenum,
- printf("%d", pagenum););
- with_color(conf->color, conf->colors.separator,
- printf("%s", conf->prefix_sep.c_str()););
- }
+ for (; from < to; from++)
+ cout << (str[from]);
}
-void putsn(char *string, int from, int to)
+void print_only_match(const struct context &context, const struct match &match)
{
- for (; from < to; from++)
- putchar(string[from]);
+ line_prefix(context.out, context.filename, false, context.pagenum);
+
+ with_color(context.out.color, context.out.colors.highlight,
+ putsn(match.string, match.start, match.end);
+ );
+
+ cout << endl;
+}
+
+ostream& err() {
+ return cerr << "pdfgrep: ";
}
+std::ostream& line_prefix(const Outconf& outconf, const std::string& filename,
+ bool in_context, size_t page) {
+ line_prefix(outconf, filename, in_context);
-int next_word_left(char *string, int index)
-{
- int i = 0;
- int in_whitespace;
+ if (outconf.pagenum) {
+ with_color(outconf.color, outconf.colors.pagenum,
+ cout << page;);
+ with_color(outconf.color, outconf.colors.separator,
+ cout << (in_context ? "-" : outconf.prefix_sep););
+ }
- if (index < 0 || string[index] == '\n')
- return -1;
+ return cout;
+}
- in_whitespace = isspace(string[index]);
- while (index >= 0 && string[index] != '\n') {
- if (in_whitespace) {
- if (!isspace(string[index]))
- in_whitespace = 0;
+std::ostream& line_prefix(const Outconf& outconf, const std::string& filename,
+ bool in_context) {
+ if (outconf.filename) {
+ with_color(outconf.color, outconf.colors.filename,
+ cout << filename;);
+ // Here, --null takes precedence over --match-prefix-separator
+ // in the sense, that if --null is given, the null byte is
+ // always printed after the filename instead of the separator.
+ if (outconf.null_byte_sep) {
+ cout << '\0';
} else {
- if (isspace(string[index]))
- break;
+ with_color(outconf.color, outconf.colors.separator,
+ cout << (in_context ? "-" : outconf.prefix_sep ););
}
- i++;
- index--;
}
- return i;
+ return cout;
}
-int next_word_right(char *string, int index, int buflen)
-{
- int i = 0;
- int in_whitespace;
+// Invariant: matches can't be empty
+void print_matches(const context& context, const std::vector<match>& matches) {
+ const match& first_match = matches.front();
+ const match& last_match = matches.back();
- if (index >= buflen || string[index] == '\n')
- return -1;
+ auto str = first_match.string;
- in_whitespace = isspace(string[index]);
- while (index < buflen && string[index] != '\n') {
- if (in_whitespace) {
- if (!isspace(string[index]))
- in_whitespace = 0;
- } else {
- if (isspace(string[index]))
- break;
- }
- i++;
- index++;
+ auto a = str.rfind('\n', first_match.start);
+ auto b = str.find('\n', last_match.end);
+
+ // If a == -1, a gets 0 (beginning of string) and if it's a valid index
+ // to a newline, it now points to the character after that.
+ a++;
+
+ if (b == string::npos)
+ b = str.size();
+
+ line_prefix(context.out, context.filename, false, context.pagenum);
+
+ int previous_end = a;
+ for (auto match : matches) {
+ putsn(str, previous_end, match.start);
+
+ with_color(context.out.color, context.out.colors.highlight,
+ putsn(str, match.start, match.end);
+ );
+
+ previous_end = match.end;
}
- return i;
+ putsn(str, previous_end, b);
+
+ cout << endl;
}
-void print_context_chars(const struct context *context, const struct match *match)
-{
- int a = match->start;
- int b = match->end;
- int chars_left = context->before;
+void print_context_before(const context& context, const match& match, int lines) {
+ if (!context.out.context_mode)
+ return;
- int left = next_word_left(match->string, a-1);
- int right = next_word_right(match->string, b, match->strlen);
+ if (lines < 0)
+ lines = context.out.context_before;
- while (true) {
- if ((left < 0 || left > chars_left)
- && (right < 0 || right > chars_left))
- break;
+ auto str = match.string;
+ auto line_begin = str.rfind('\n', match.start);
- if (right < 0 || right > chars_left ||
- (left > 0 && left <= chars_left
- && (match->start - a) + left
- < (b - match->end) + right)) {
- a -= left;
- chars_left -= left;
- left = next_word_left(match->string,a-1);
- } else {
- b += right;
- chars_left -= right;
- right = next_word_right(match->string, b, match->strlen);
- }
- }
+ // we are at the first line
+ if (line_begin == string::npos)
+ return;
- print_line_prefix(context->out, context->filename, context->pagenum);
+ vector<string> lines_to_output;
- putsn(match->string, a, match->start);
+ auto pos = line_begin;
+ while (lines --> 0) {
+ if (pos == 0) {
+ lines_to_output.push_back("");
+ break;
+ }
+ auto newpos = str.rfind('\n', pos-1);
- with_color(context->out->color, context->out->colors.highlight,
- putsn(match->string, match->start, match->end);
- );
+ auto start_pos = newpos == string::npos ? 0 : newpos + 1;
+ lines_to_output.push_back(str.substr(start_pos, pos-start_pos));
- putsn(match->string, match->end, b);
+ if (newpos == string::npos)
+ break;
+ else
+ pos = newpos;
+ }
- printf("\n");
+ for (auto l = lines_to_output.rbegin(); l != lines_to_output.rend(); ++l) {
+ line_prefix(context.out, context.filename, true, context.pagenum) << *l << endl;
+ }
}
-void print_context_line(const struct context *context, const struct match *match)
-{
- int a = match->start;
- int b = match->end;
+void print_context_after(const context& context, const match& match, int lines) {
+ if (!context.out.context_mode)
+ return;
- while (a >= 0 && match->string[a] != '\n')
- a--;
- a++;
+ if (lines < 0)
+ lines = context.out.context_after;
- while (b < match->strlen && match->string[b] != '\n')
- b++;
+ auto str = match.string;
+ auto line_end = str.find('\n', match.end);
- print_line_prefix(context->out, context->filename, context->pagenum);
+ // we are at the first line
+ if (line_end == string::npos)
+ return;
- putsn(match->string, a, match->start);
+ auto pos = line_end;
+ while (lines --> 0) {
+ if (pos == str.size()-1) {
+ break;
+ }
+ auto newpos = str.find('\n', pos+1);
- with_color(context->out->color, context->out->colors.highlight,
- putsn(match->string, match->start, match->end);
- );
+ auto end_pos = newpos == string::npos ? str.size() : newpos;
+ line_prefix(context.out, context.filename, true, context.pagenum)
+ << str.substr(pos+1, end_pos-pos-1) << endl;
- putsn(match->string, match->end, b);
+ if (newpos == string::npos)
+ break;
+ else
+ pos = newpos;
+ }
- printf("\n");
}
-void print_only_match(const struct context *context, const struct match *match)
-{
- print_line_prefix(context->out, context->filename, context->pagenum);
+void print_context_between(const context& context, const match& match1, const match& match2) {
+ if (!context.out.context_mode) {
+ return;
+ }
- with_color(context->out->color, context->out->colors.highlight,
- putsn(match->string, match->start, match->end);
- );
+ auto str = match1.string;
+
+ auto pos_right = str.find('\n', match1.end);
+ auto pos_left = str.rfind('\n', match2.start);
+
+ // count the lines that we have to the right of match1
+ int lines_right = 0;
+ while (pos_right != string::npos && lines_right < context.out.context_after
+ && pos_right < pos_left) {
+ lines_right++;
+ pos_right = str.find('\n', pos_right+1);
+ }
+
+ // count the lines that we have to the left of match2
+ int lines_left = 0;
+ while (pos_left != string::npos && lines_left < context.out.context_before
+ && pos_left > pos_right) {
+ lines_left++;
+ if (pos_left == 0) {
+ pos_left = string::npos;
+ break;
+ }
+ pos_left = str.rfind('\n', pos_left-1);
+ }
+
+ print_context_after(context, match1, lines_right);
+ if (pos_left > pos_right)
+ print_context_separator(context.out);
+ print_context_before(context, match2, lines_left);
+}
+
+void print_context_separator(const Outconf &out) {
+ // TODO Add color here
- printf("\n");
+ if (out.context_mode)
+ cout << "--" << endl;
}
diff --git a/src/output.h b/src/output.h
index ab18391..3369ed8 100644
--- a/src/output.h
+++ b/src/output.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2015 by Hans-Peter Deifel *
+ * Copyright (C) 2017 by Hans-Peter Deifel *
* hpd@hpdeifel.de *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -23,61 +23,48 @@
#include <sys/types.h>
#include <string>
-
-
-struct colorconf {
- char *filename;
- char *pagenum;
- char *highlight;
- char *separator;
-};
-
-
-struct outconf {
- int filename;
- int pagenum;
- /* FIXME this distinction doesn't belong here */
- /* controls output of color escape sequences
- * 0: no color
- * 1: color if stdout is a tty
- * 2: color (regardless of stdout)
- */
- int color;
- bool only_matching;
- bool null_byte_sep;
- std::string prefix_sep;
-
- struct colorconf colors;
-};
+#include "pdfgrep.h"
struct context {
- int before;
- int after;
+ const std::string &filename;
+ size_t pagenum;
- char *filename;
- int pagenum;
-
- struct outconf *out;
+ const Outconf &out;
};
struct match {
- char *string;
- size_t strlen;
- int start;
- int end;
+ const std::string string;
+ size_t start;
+ size_t end;
};
-/* print filename:pagenum:
+/* print the line prefix followed only by the match */
+void print_only_match(const struct context &context, const struct match &match);
+
+/** print a line with prefix and highlighting for matches.
*
- * depending on `conf', filename and/or pagenum can be omitted.
- * `filename' is also omitted if it is NULL
- * `pagenum' is also omitted if it is < 0
+ * 'matches' must not be empty and all entries must begin and end in the same
+ * line.
*/
-void print_line_prefix(const struct outconf *conf, const char *filename, const int pagenum);
-void print_context_chars(const struct context *context, const struct match *match);
-void print_context_line(const struct context *context, const struct match *match);
+void print_matches(const context& context, const std::vector<match>& matches);
-/* print the line prefix followed only by the match */
-void print_only_match(const struct context *context, const struct match *match);
+// Print `lines` lines of context before the match. If lines is smaller than 0,
+// use the value from context.outconf.
+void print_context_before(const context& context, const match& match, int lines = -1);
+// Print `lines` lines of context before the match. If lines is smaller than 0,
+// use the value from context.outconf.
+void print_context_after(const context& context, const match& match, int lines = -1);
+void print_context_between(const context& context, const match& match1, const match& match2);
+void print_context_separator(const Outconf &out);
+
+// C++ interface:
+
+// Print to stderr, with "pdfgrep: " as prefix;
+std::ostream& err();
+
+std::ostream& line_prefix(const Outconf& outconf, const std::string& filename,
+ bool in_context, size_t page);
+std::ostream& line_prefix(const Outconf& outconf, const std::string& filename,
+ bool in_context);
#endif
diff --git a/src/pdfgrep.cc b/src/pdfgrep.cc
index 3b08412..0a7b739 100644
--- a/src/pdfgrep.cc
+++ b/src/pdfgrep.cc
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2015 by Hans-Peter Deifel *
+ * Copyright (C) 2017 by Hans-Peter Deifel *
* hpd@hpdeifel.de *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -29,13 +29,18 @@
#include <stdarg.h>
#include <unistd.h>
#include <math.h>
-#include <sys/ioctl.h>
#include <fnmatch.h>
#include <errno.h>
#include <dirent.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <limits.h>
#include <vector>
+#include <iostream>
+#include <sstream>
+#include <fstream>
+#include <locale>
+#include <gcrypt.h>
#include <cpp/poppler-document.h>
#include <cpp/poppler-page.h>
@@ -46,53 +51,22 @@
#include <unac.h>
#endif
-#ifdef HAVE_TERMIOS_H
-/* for TIOCGWINSZ on some platforms */
-#include <termios.h>
-#endif
-
#include <memory>
#include "pdfgrep.h"
#include "output.h"
#include "exclude.h"
#include "regengine.h"
+#include "search.h"
+#include "cache.h"
+using namespace std;
/* set this to 1 if any match was found. Used for the exit status */
int found_something = 0;
-/* default options */
-
-int ignore_case = 0;
-int f_recursive_search = 0;
-int follow_symlinks = 1;
-/* characters of context to put around each match.
- * -1 means: print whole line
- * -2 means: try to fit context into terminal */
-int context = -2;
-int line_width = 80;
-int count = 0;
-int pagecount = 0;
-int quiet = 0;
-// vector of all passwords to try on any pdf
-std::vector<std::string> passwords;
-int max_count = 0;
-int debug = 0;
-bool warn_empty = false;
-
-#ifdef HAVE_UNAC
-int use_unac = 0;
-#endif
-struct outconf outconf = {
- -1, /* filename */
- 0, /* pagenum */
- 1, /* color */
- false, /* only_matching */
- false, /* null byte separator */
- ":", /* prefix separator */
-};
+// Options
enum {
HELP_OPTION,
@@ -104,6 +78,7 @@ enum {
PREFIX_SEP_OPTION,
WARN_EMPTY_OPTION,
UNAC_OPTION,
+ CACHE_OPTION,
};
struct option long_options[] =
@@ -115,7 +90,6 @@ struct option long_options[] =
{"no-filename", 0, 0, 'h'},
{"count", 0, 0, 'c'},
{"color", 1, 0, COLOR_OPTION},
- {"context", 1, 0, 'C'},
{"recursive", 0, 0, 'r'},
{"dereference-recursive", 0, 0, 'R'},
{"exclude", 1, 0, EXCLUDE_OPTION},
@@ -133,18 +107,18 @@ struct option long_options[] =
{"warn-empty", 0, 0, WARN_EMPTY_OPTION},
{"unac", 0, 0, UNAC_OPTION},
{"fixed-strings", 0, 0, 'F'},
+ {"cache", 0, 0, CACHE_OPTION},
+ {"after-context", 1, 0, 'A'},
+ {"before-context", 1, 0, 'B'},
+ {"context", 1, 0, 'C'},
{0, 0, 0, 0}
};
-ExcludeList excludes;
-ExcludeList includes;
-
#ifdef HAVE_UNAC
-/* convenience layer over libunac. The result has to be freed with
- * simple_unac_free */
-char *simple_unac(char *string)
+/* convenience layer over libunac. */
+static char *simple_unac(const Options &opts, char *string)
{
- if (!use_unac)
+ if (!opts.use_unac)
return string;
char *res = NULL;
@@ -157,137 +131,10 @@ char *simple_unac(char *string)
return res;
}
-
-void simple_unac_free(char *string)
-{
- if (use_unac)
- free(string);
-}
-#endif
-
-int search_in_document(poppler::document *doc, const std::string &filename, Regengine &re)
-{
- int count_matches = 0;
- int page_matches = 0;
- int length = 0;
- struct context cntxt = {context, 0, (char*)filename.c_str(), 0, &outconf};
-
- bool max_count_reached = false;
-
- // Tracks if there is text on any of the pages
- bool document_empty = true;
-
- for (int i = 1; i <= doc->pages() && !max_count_reached; i++) {
- std::unique_ptr<poppler::page> doc_page(doc->create_page(i - 1));
- if (!doc_page.get()) {
- if (!quiet) {
- fprintf(stderr, "pdfgrep: Could not search in page %d of %s\n", i, filename.c_str());
- }
- continue;
- }
-
- cntxt.pagenum = i;
-
- // page not empty, set document_empty to false
- if (doc_page->text().empty() == false) {
- document_empty = false;
- }
-
-
- poppler::byte_array str = doc_page->text().to_utf8();
- str.resize(str.size() + 1, '\0');
- size_t str_len = str.size() - 1;
-#ifdef HAVE_UNAC
- char *unac_str = simple_unac(&str[0]);
- char *str_start = unac_str;
-#else
- char *str_start = &str[0];
#endif
- size_t index = 0;
- struct match mt = { .string = str_start, .strlen = str_len };
-
- while (!max_count_reached && !re.exec(str_start, index, &mt)) {
- count_matches++;
- if (max_count > 0 && count_matches >= max_count)
- {
- max_count_reached = true;
- }
- if (quiet) {
-#ifdef HAVE_UNAC
- simple_unac_free(unac_str);
-#endif
- goto clean;
- } else if (!count && !pagecount && outconf.only_matching) {
- print_only_match(&cntxt, &mt);
- } else if (!count && !pagecount) {
- switch (context) {
- /* print whole line */
- case -1:
- print_context_line(&cntxt, &mt);
- break;
- /* try to guess the terminal width */
- case -2:
- /* Calculate the length of the line prefix:
- * filename:linenumber: */
- length = 0;
-
- if (outconf.filename)
- length += 1 + filename.size();
- if (outconf.pagenum)
- length += 1 + (int)log10((double)i);
-
- length += mt.end - mt.start;
-
- cntxt.before = line_width - length;
-
- print_context_chars(&cntxt, &mt);
- break;
- /* print a fixed context */
- default:
- print_context_chars(&cntxt, &mt);
- break;
- }
- }
-
- found_something = 1;
-
- index = mt.end;
-
- // prevent loop if match is empty
- if (mt.start == mt.end) {
- index++;
- }
-
- if(index >= str_len)
- break;
- }
-
-#ifdef HAVE_UNAC
- simple_unac_free(unac_str);
-#endif
- if(!quiet && pagecount && count_matches > page_matches) {
- print_line_prefix(&outconf, filename.c_str(), i);
- printf("%d\n", count_matches-page_matches);
- page_matches = count_matches;
- }
- }
-
- if (count && !quiet) {
- print_line_prefix(&outconf, filename.c_str(), -1);
- printf("%d\n", count_matches);
- }
-
- if (warn_empty && document_empty) {
- fprintf(stderr, "pdfgrep: File does not contain text: %s\n",
- filename.c_str());
- }
-
-clean:
- return count_matches;
-}
/* parses a color pair like "foo=bar" to "foo" and "bar" */
-void parse_env_color_pair(char* pair, char** name, char** value)
+static void parse_env_color_pair(char* pair, char** name, char** value)
{
*name = pair;
int i = 0;
@@ -309,7 +156,7 @@ void parse_env_color_pair(char* pair, char** name, char** value)
/* set colors of output according to content of environment-varaible env_var.
the content of env_var has to be like the GREP_COLORS variable for grep
see man 1 grep for further details of GREP_COLORS */
-void read_colors_from_env(const char* env_var)
+static void read_colors_from_env(Colorconf &colors, const char* env_var)
{
/* create a copy of var to edit it with strtok */
if (!getenv(env_var)) {
@@ -340,12 +187,12 @@ void read_colors_from_env(const char* env_var)
}
/* now check for known settings and set global colors */
- PARSE_COLOR("mt", outconf.colors.highlight)
- else PARSE_COLOR("ms", outconf.colors.highlight)
- else PARSE_COLOR("mc", outconf.colors.highlight)
- else PARSE_COLOR("fn", outconf.colors.filename)
- else PARSE_COLOR("ln", outconf.colors.pagenum)
- else PARSE_COLOR("se", outconf.colors.separator)
+ PARSE_COLOR("mt", colors.highlight)
+ else PARSE_COLOR("ms", colors.highlight)
+ else PARSE_COLOR("mc", colors.highlight)
+ else PARSE_COLOR("fn", colors.filename)
+ else PARSE_COLOR("ln", colors.pagenum)
+ else PARSE_COLOR("se", colors.separator)
#undef PARSE_COLOR
@@ -354,160 +201,160 @@ void read_colors_from_env(const char* env_var)
free(colors_list);
}
-void set_default_colors()
+static void set_default_colors(Colorconf &colors)
{
// The grep(1) manpage documents the default value of GREP_COLORS to be
// ms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36
// which corresponds to these values below:
- outconf.colors.filename = strdup("35");
- outconf.colors.pagenum = strdup("32");
- outconf.colors.highlight = strdup("01;31");
- outconf.colors.separator = strdup("36");
-}
-
-void free_colors()
-{
- free(outconf.colors.filename);
- free(outconf.colors.pagenum);
- free(outconf.colors.highlight);
- free(outconf.colors.separator);
-}
-
-void init_colors()
-{
- set_default_colors();
- /* free colors, when programm exits */
- atexit(free_colors);
+ colors.filename = strdup("35");
+ colors.pagenum = strdup("32");
+ colors.highlight = strdup("01;31");
+ colors.separator = strdup("36");
}
-/* return the terminal line width or line_width
- * if the former is not available */
-int get_line_width()
+static void init_colors(Colorconf &colors)
{
- const char *v = getenv("COLUMNS");
- int width = line_width;
-
- if (v && *v)
- width = atoi(v);
-
- struct winsize ws;
-
- if (ioctl (STDOUT_FILENO, TIOCGWINSZ, &ws) != -1 && 0 < ws.ws_col)
- width = ws.ws_col;
-
- if (width > 0)
- return width;
-
-
- return line_width;
+ set_default_colors(colors);
}
-void print_usage(char *self)
+static void print_usage(char *self)
{
- printf("Usage: %s [OPTION]... PATTERN FILE...\n", self);
- printf("\nSee '%s --help' for more information\n", self);
+ cout << "Usage: " << self << " [OPTION]... PATTERN FILE..." << endl;
+ cout << endl << "See '" << self << " --help' for more information" << endl;
}
-void print_help(char *self)
+static void print_help(char *self)
{
- printf("Usage: %s [OPTION]... PATTERN FILE...\n"
-"\nSearch for PATTERN in each FILE.\n"
-"PATTERN is, by default, an extended regular expression.\n\n"
-
-"Options:\n"
-" -i, --ignore-case\t\tIgnore case distinctions\n"
-" -P, --pcre\t\t\tUse Perl compatible regular expressions (PCRE)\n"
-" -H, --with-filename\t\tPrint the file name for each match\n"
-" -h, --no-filename\t\tSuppress the prefixing of file name on output\n"
-" -n, --page-number\t\tPrint page number with output lines\n"
-" -c, --count\t\t\tPrint only a count of matches per file\n"
-" -C, --context NUM\t\tPrint at most NUM chars of context\n"
-" --color WHEN\t\tUse colors for highlighting;\n"
-"\t\t\t\tWHEN can be `always', `never' or `auto'\n"
-" -p, --page-count\t\tPrint only a count of matches per page\n"
-" -m, --max-count NUM\t\tStop reading after NUM matching lines (per file)\n"
-" -q, --quiet\t\t\tSuppress normal output\n"
-" -r, --recursive\t\tSearch directories recursively\n"
-" -R, --dereference-recursive\tLikewise, but follow all symlinks\n"
-" --help\t\t\tPrint this help\n"
-" -V, --version\t\t\tShow version information\n", self);
+ cout << "Usage: " << self << " [OPTION]... PATTERN FILE..." << endl << endl
+ << "Search for PATTERN in each FILE." << endl
+ << "PATTERN is, by default, an extended regular expression." << endl
+ << endl
+ << "Options:" << endl
+ << " -i, --ignore-case\t\tIgnore case distinctions" << endl
+ << " -P, --pcre\t\t\tUse Perl compatible regular expressions (PCRE)" << endl
+ << " -H, --with-filename\t\tPrint the file name for each match" << endl
+ << " -h, --no-filename\t\tSuppress the prefixing of file name on output" << endl
+ << " -n, --page-number\t\tPrint page number with output lines" << endl
+ << " -c, --count\t\t\tPrint only a count of matches per file" << endl
+ << " --color WHEN\t\tUse colors for highlighting;" << endl
+ << "\t\t\t\tWHEN can be `always', `never' or `auto'" << endl
+ << " -p, --page-count\t\tPrint only a count of matches per page" << endl
+ << " -m, --max-count NUM\t\tStop reading after NUM matching lines (per file)" << endl
+ << " -q, --quiet\t\t\tSuppress normal output" << endl
+ << " -r, --recursive\t\tSearch directories recursively" << endl
+ << " -R, --dereference-recursive\tLikewise, but follow all symlinks" << endl
+ << " --cache\t\tUse cache for faster operation" << endl
+ << " --help\t\t\tPrint this help" << endl
+ << " -V, --version\t\t\tShow version information" << endl;
}
-void print_version()
+static void print_version()
{
- printf("This is %s version %s.\n", PACKAGE, VERSION);
- printf("\nUsing poppler version %s\n", poppler::version_string().c_str());
+ cout << "This is " << PACKAGE << " version " << VERSION << "." << endl << endl;
+ cout << "Using poppler version " << poppler::version_string().c_str() << endl;
#ifdef HAVE_UNAC
- printf("Using unac version %s\n", unac_version());
+ cout << "Using unac version " << unac_version() << endl;
#endif
#ifdef HAVE_LIBPCRE
- printf("Using libpcre version %s\n", pcre_version());
+ cout << "Using libpcre version " << pcre_version() << endl;
#endif
#ifdef PDFGREP_GIT_HEAD
- printf("Built from git-commit %s\n", PDFGREP_GIT_HEAD);
+ cout << "Built from git-commit " << PDFGREP_GIT_HEAD << endl;
#endif
}
-int is_dir(const std::string &filename)
+static bool is_dir(const string &filename)
{
struct stat st;
- if (stat(filename.c_str(), &st) == 0 && S_ISDIR(st.st_mode))
- return 1;
- else
- return 0;
+ return stat(filename.c_str(), &st) == 0 && S_ISDIR(st.st_mode);
}
-int do_search_in_document(const std::string &path, const std::string &filename,
- Regengine &re, bool check_excludes = true)
+static int sha1_file(const std::string &filename, unsigned char *sha1out)
+{
+ std::ifstream file(filename);
+ std::stringstream content;
+ if (!(content << file.rdbuf())) {
+ return -1;
+ }
+ std::string str(content.str());
+
+ gcry_md_hash_buffer( GCRY_MD_SHA1, sha1out, str.c_str(), str.size());
+ return 0;
+}
+
+static int do_search_in_document(const Options &opts, const string &path, const string &filename,
+ Regengine &re, bool check_excludes = true)
{
if (check_excludes &&
- (!is_excluded(includes, filename) || is_excluded(excludes, filename)))
+ (!is_excluded(opts.includes, filename) || is_excluded(opts.excludes, filename)))
return 0;
- std::shared_ptr<poppler::document> doc;
+ unique_ptr<Cache> cache;
- if (passwords.empty()) {
- fprintf(stderr, "pdfgrep: Internal error, password vector empty!\n");
+ if (opts.use_cache) {
+ unsigned char sha1sum[20];
+ std::string cache_file(opts.cache_directory);
+ if (sha1_file(filename, sha1sum) != 0) {
+ err() << "Could not compute checksum for " << path << endl;
+ return 1;
+ }
+ char translate[] = "0123456789abcdef";
+ for (unsigned i = 0; i < 20; ++i) {
+ cache_file += translate[sha1sum[i] & 0xf];
+ cache_file += translate[(sha1sum[i] >> 4 ) & 0xf];
+ }
+
+ cache = unique_ptr<Cache>(new Cache(cache_file));
+ }
+
+ unique_ptr<poppler::document> doc;
+
+ if (opts.passwords.empty()) {
+ err() << "Internal error, password vector empty!" << endl;
abort();
}
- for (std::string password : passwords) {
- doc = std::shared_ptr<poppler::document>(
- poppler::document::load_from_file(path, std::string(password),
- std::string(password))
+ for (string password : opts.passwords) {
+ // FIXME This logic doesn't seem to make sens. What if only the
+ // first password is correct?
+ doc = unique_ptr<poppler::document>(
+ poppler::document::load_from_file(path, string(password),
+ string(password))
);
}
if (!doc.get() || doc->is_locked()) {
- fprintf(stderr, "pdfgrep: Could not open %s\n",
- path.c_str());
+ err() << "Could not open " << path.c_str() << endl;
return 1;
}
- if (search_in_document(doc.get(), path, re) && quiet) {
- exit(EXIT_SUCCESS);
+ int matches = search_document(opts, move(doc), move(cache), path, re);
+ if (matches > 0) {
+ found_something = 1;
+ if (opts.quiet) {
+ exit(EXIT_SUCCESS); // FIXME: Handle this with return value
+ }
}
return 0;
}
-int do_search_in_directory(const std::string &filename, Regengine &re)
+static int do_search_in_directory(const Options &opts, const string &filename, Regengine &re)
{
DIR *ptrDir = NULL;
ptrDir = opendir(filename.c_str());
if (!ptrDir) {
- fprintf(stderr, "pdfgrep: %s: %s\n", filename.c_str(),
- strerror(errno));
+ err() << filename.c_str() << ": " << strerror(errno) << endl;
return 1;
}
while(1) {
- std::string path(filename);
+ string path(filename);
errno = 0;
- struct dirent *ptrDirent = ptrDirent = readdir(ptrDir); //not sorted, in order as `ls -f`
+ struct dirent *ptrDirent = readdir(ptrDir); //not sorted, in order as `ls -f`
if (!ptrDirent)
break;
@@ -520,12 +367,13 @@ int do_search_in_directory(const std::string &filename, Regengine &re)
struct stat st;
int statret;
- if (follow_symlinks) statret = stat(path.c_str(), &st);
- else statret = lstat(path.c_str(), &st);
+ if (opts.recursive == Recursion::FOLLOW_SYMLINKS)
+ statret = stat(path.c_str(), &st);
+ else
+ statret = lstat(path.c_str(), &st);
if (statret) {
- fprintf(stderr, "pdfgrep: %s: %s\n", filename.c_str(),
- strerror(errno));
+ err() << filename.c_str() << ": " << strerror(errno) << endl;
continue;
}
@@ -533,9 +381,9 @@ int do_search_in_directory(const std::string &filename, Regengine &re)
continue;
if (S_ISDIR(st.st_mode)) {
- do_search_in_directory(path, re);
+ do_search_in_directory(opts, path, re);
} else {
- do_search_in_document(path, ptrDirent->d_name, re);
+ do_search_in_document(opts, path, ptrDirent->d_name, re);
}
}
@@ -544,7 +392,7 @@ int do_search_in_directory(const std::string &filename, Regengine &re)
return 0;
}
-bool parse_int(const char *str, int *i)
+static bool parse_int(const char *str, int *i)
{
char *endptr;
errno = 0;
@@ -559,17 +407,24 @@ bool parse_int(const char *str, int *i)
}
#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 29
-void handle_poppler_errors(const std::string &msg, void *)
+static void handle_poppler_errors(const string &msg, void *_opts)
{
- if (debug) {
- fprintf(stderr, "pdfgrep: %s\n", msg.c_str());
+ Options *opts = static_cast<Options*>(_opts);
+ if (opts->debug) {
+ err() << msg << endl;
}
}
#endif
int main(int argc, char** argv)
{
- init_colors();
+ Options options;
+ init_colors(options.outconf.colors);
+
+ // Set locale to user-preference. If this locale is an UTF-8 locale, the
+ // regex-functions regcomp/regexec become unicode aware, which means
+ // e.g. that '.' will match a unicode character, not a single byte.
+ locale::global(locale(""));
enum re_engine_type {
RE_POSIX = 0,
@@ -579,8 +434,17 @@ int main(int argc, char** argv)
int re_engine = RE_POSIX;
+ // either -H or -h was set
+ bool explicit_filename_option = false;
+
+ enum {
+ COLOR_ALWAYS,
+ COLOR_AUTO,
+ COLOR_NEVER
+ } use_colors = COLOR_AUTO;
+
while (1) {
- int c = getopt_long(argc, argv, "icC:nrRhHVPpqm:FoZ",
+ int c = getopt_long(argc, argv, "icA:B:C:nrRhHVPpqm:FoZ",
long_options, NULL);
if (c == -1)
@@ -594,120 +458,145 @@ int main(int argc, char** argv)
print_version();
exit(EXIT_SUCCESS);
case 'n':
- outconf.pagenum = 1;
+ options.outconf.pagenum = true;
break;
case 'r':
- follow_symlinks = 0;
+ options.recursive = Recursion::DONT_FOLLOW_SYMLINKS;
+ break;
case 'R':
- f_recursive_search = 1;
+ options.recursive = Recursion::FOLLOW_SYMLINKS;
break;
case 'h':
- outconf.filename = 0;
+ options.outconf.filename = false;
+ explicit_filename_option = true;
break;
case 'H':
- outconf.filename = 1;
+ options.outconf.filename = true;
+ explicit_filename_option = true;
break;
case 'i':
- ignore_case = 1;
+ options.ignore_case = true;
break;
case 'c':
- count = 1;
+ options.count = true;
break;
case COLOR_OPTION:
if (!strcmp("always", optarg)) {
- outconf.color = 2;
+ use_colors = COLOR_ALWAYS;
} else if (!strcmp("never", optarg)) {
- outconf.color = 0;
+ use_colors = COLOR_NEVER;
} else if (!strcmp("auto", optarg)) {
- outconf.color = 1;
+ use_colors = COLOR_AUTO;
} else {
- fprintf(stderr, "pdfgrep: Invalid argument '%s' for --color. "
- "Candidates are: always, never or auto\n", optarg);
- exit(EXIT_ERROR);
- }
- break;
- case 'C':
- if (!strcmp(optarg, "line")) {
- context = -1;
- break;
- }
- if (!parse_int(optarg, &context)) {
- fprintf(stderr, "pdfgrep: Could not parse number: %s.\n",
- optarg);
- exit(EXIT_ERROR);
- } else if (context <= 0) {
- fprintf(stderr, "pdfgrep: --context must be positive.\n");
+ err() << "Invalid argument '" << optarg << "' for --color. "
+ << "Candidates are: always, never or auto" << endl;
exit(EXIT_ERROR);
}
break;
case EXCLUDE_OPTION:
- exclude_add(excludes, optarg);
+ exclude_add(options.excludes, optarg);
break;
case INCLUDE_OPTION:
- exclude_add(includes, optarg);
+ exclude_add(options.includes, optarg);
break;
case 'P':
#ifndef HAVE_LIBPCRE
- fprintf(stderr, "pdfgrep: PCRE support disabled at compile time!\n");
+ err() << "PCRE support disabled at compile time!" << endl;
exit(EXIT_ERROR);
#else
re_engine |= RE_PCRE;
#endif
break;
case 'p':
- pagecount = 1;
- outconf.pagenum = 1;
+ options.pagecount = true;
+ options.outconf.pagenum = true;
break;
case 'q':
- quiet = 1;
+ options.quiet = true;
break;
case PASSWORD:
- passwords.push_back(std::string(optarg));
+ options.passwords.push_back(string(optarg));
break;
case 'm':
- if (!parse_int(optarg, &max_count)) {
- fprintf(stderr, "pdfgrep: Could not parse number: %s.\n",
- optarg);
+ if (!parse_int(optarg, &options.max_count)) {
+ err() << "Could not parse number: " << optarg << "." << endl;
exit(EXIT_ERROR);
- } else if (max_count <= 0) {
- fprintf(stderr, "pdfgrep: --max-count must be positive.\n");
+ } else if (options.max_count <= 0) {
+ err() << "--max-count must be positive." << endl;
exit(EXIT_ERROR);
}
break;
case DEBUG_OPTION:
- debug = 1;
+ options.debug = true;
break;
case UNAC_OPTION:
#ifndef HAVE_UNAC
- fprintf(stderr, "pdfgrep: UNAC support disabled at compile time!\n");
+ err() << "UNAC support disabled at compile time!" << endl;
exit(EXIT_ERROR);
#else
- use_unac = 1;
+ options.use_unac = true;
#endif
break;
case 'F':
re_engine |= RE_FIXED;
break;
+ case CACHE_OPTION:
+ options.use_cache = true;
+ break;
+
case 'o':
- outconf.only_matching = true;
+ options.outconf.only_matching = true;
break;
- case 'Z':
- // --null
- outconf.null_byte_sep = true;
+ case 'Z': // --null
+ options.outconf.null_byte_sep = true;
break;
case PREFIX_SEP_OPTION:
- outconf.prefix_sep = std::string(optarg);
+ options.outconf.prefix_sep = string(optarg);
break;
case WARN_EMPTY_OPTION:
- warn_empty = true;
+ options.warn_empty = true;
+ break;
+
+ case 'A':
+ if (!parse_int(optarg, &options.outconf.context_after)) {
+ err() << "Could not parse number: " << optarg << "." << endl;
+ exit(EXIT_ERROR);
+ } else if (options.outconf.context_after < 0) {
+ err() << "--after-context must be positive." << endl;
+ exit(EXIT_ERROR);
+ }
+ options.outconf.context_mode = true;
+ break;
+
+ case 'B':
+ if (!parse_int(optarg, &options.outconf.context_before)) {
+ err() << "Could not parse number: " << optarg << "." << endl;
+ exit(EXIT_ERROR);
+ } else if (options.outconf.context_before < 0) {
+ err() << "--before-context must be positive." << endl;
+ exit(EXIT_ERROR);
+ }
+ options.outconf.context_mode = true;
+ break;
+
+ case 'C':
+ if (!parse_int(optarg, &options.outconf.context_after)) {
+ err() << "Could not parse number: " << optarg << "." << endl;
+ exit(EXIT_ERROR);
+ } else if (options.outconf.context_after < 0) {
+ err() << "--after-context must be positive." << endl;
+ exit(EXIT_ERROR);
+ }
+ options.outconf.context_before = options.outconf.context_after;
+ options.outconf.context_mode = true;
break;
/* In these two cases, getopt already prints an
@@ -722,94 +611,106 @@ int main(int argc, char** argv)
}
}
- if (argc == optind || (argc - optind < 2 && !f_recursive_search)) {
+ if (argc == optind || (argc - optind < 2 && options.recursive == Recursion::NONE)) {
print_usage(argv[0]);
exit(EXIT_ERROR);
}
char *pattern = argv[optind++];
#ifdef HAVE_UNAC
- pattern = simple_unac(pattern);
+ pattern = simple_unac(options, pattern);
#endif
- Regengine *re = NULL;
+ unique_ptr<Regengine> re;
if (re_engine == (RE_FIXED | RE_PCRE)) {
- fprintf(stderr, "pdfgrep: --pcre and --fixed cannot be used together\n");
+ err() << "--pcre and --fixed cannot be used together" << endl;
exit(EXIT_ERROR);
}
#ifdef HAVE_LIBPCRE
if (re_engine == RE_PCRE) {
- re = new PCRERegex(pattern, ignore_case);
+ re.reset(new PCRERegex(pattern, options.ignore_case));
} else
#endif // HAVE_LIBPCRE
if (re_engine == RE_FIXED) {
- re = new FixedString(pattern, ignore_case);
+ re.reset(new FixedString(pattern, options.ignore_case));
} else {
- re = new PosixRegex(pattern, ignore_case);
+ re.reset(new PosixRegex(pattern, options.ignore_case));
}
#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 29
// set poppler error output function
- poppler::set_debug_error_function(handle_poppler_errors, NULL);
+ poppler::set_debug_error_function(handle_poppler_errors, &options);
#endif
bool color_tty = isatty(STDOUT_FILENO) && getenv("TERM") &&
strcmp(getenv("TERM"), "dumb");
- if (outconf.color == 1 && !color_tty) {
- outconf.color = 0;
- }
- if (outconf.color) read_colors_from_env("GREP_COLORS");
+ options.outconf.color =
+ use_colors == COLOR_ALWAYS
+ || (use_colors == COLOR_AUTO && color_tty);
- if (outconf.filename < 0) {
+ if (options.outconf.color)
+ read_colors_from_env(options.outconf.colors, "GREP_COLORS");
+
+ if (explicit_filename_option == false) {
if ((argc - optind) == 1 && !is_dir(argv[optind])) {
- outconf.filename = 0;
+ options.outconf.filename = false;
} else
- outconf.filename = 1;
+ options.outconf.filename = true;
}
- if (isatty(STDOUT_FILENO)) {
- line_width = get_line_width();
- } else if (context == -2) {
- // on non-terminals, always print the whole line
- context = -1;
+ if (options.outconf.only_matching && (options.outconf.context_before > 0
+ || options.outconf.context_after > 0)) {
+ err() << "warning: --only-matching and context options can't be used together."
+ << " Ignoring context option." << endl;
+
+ options.outconf.context_mode = false;
}
- if (excludes_empty(includes))
- exclude_add(includes, "*.pdf");
+ if (excludes_empty(options.includes))
+ exclude_add(options.includes, "*.pdf");
// If no password has been specified on the command line, insert the
// empty string aka "no password" into the passwords array.
- if (passwords.empty()) {
- passwords.push_back("");
+ if (options.passwords.empty()) {
+ options.passwords.push_back("");
+ }
+
+ if (options.use_cache) {
+ if (find_cache_directory(options.cache_directory) != 0) {
+ err() << "warning: Failed to initialize cache directory."
+ << " no cache is used!" << endl;
+ options.use_cache = false;
+ } else {
+ char *limitstr = getenv("PDFGREP_CACHE_LIMIT");
+ unsigned int limit = limitstr ? strtoul(limitstr, NULL, 10) : 200;
+ limit_cachesize(options.cache_directory.c_str(), limit);
+ }
}
int error = 0;
for (int i = optind; i < argc; i++) {
- const std::string filename(argv[i]);
+ const string filename(argv[i]);
if (!is_dir(filename)) {
- if (do_search_in_document(filename, filename, *re, false)) {
+ if (do_search_in_document(options, filename, filename, *re, false)) {
error = 1;
}
- } else if (f_recursive_search) {
- if (do_search_in_directory(filename, *re)) {
+ } else if (options.recursive != Recursion::NONE) {
+ if (do_search_in_directory(options, filename, *re)) {
error = 1;
}
} else {
- fprintf(stderr, "pdfgrep: %s is a directory\n", filename.c_str());
+ err() << filename << " is a directory" << endl;
error = 1;
}
}
- if (argc == optind && f_recursive_search) {
- do_search_in_directory(".", *re);
+ if (argc == optind && options.recursive != Recursion::NONE) {
+ do_search_in_directory(options, ".", *re);
}
- // Free up some stuff
- delete re;
-
if (error) {
exit(EXIT_ERROR);
} else if (found_something) {
diff --git a/src/pdfgrep.h b/src/pdfgrep.h
index a6b4960..6a7731d 100644
--- a/src/pdfgrep.h
+++ b/src/pdfgrep.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2015 by Hans-Peter Deifel *
+ * Copyright (C) 2017 by Hans-Peter Deifel *
* hpd@hpdeifel.de *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -21,6 +21,12 @@
#ifndef PDFGREP_H
#define PDFGREP_H
+#include "config.h"
+#include "exclude.h"
+
+#include <vector>
+#include <string>
+
/* Exit codes. */
enum {
/* EXIT_SUCCESS = 0 */
@@ -31,4 +37,56 @@ enum {
EXIT_ERROR = 2,
};
+enum class Recursion {
+ NONE,
+ FOLLOW_SYMLINKS,
+ DONT_FOLLOW_SYMLINKS
+};
+
+struct Colorconf {
+ char *filename;
+ char *pagenum;
+ char *highlight;
+ char *separator;
+};
+
+// Controls, what to print
+struct Outconf {
+ bool filename = false;
+ bool pagenum = false;
+ bool color = false;
+ bool only_matching = false;
+ bool null_byte_sep = false;
+ std::string prefix_sep = ":";
+
+ // true, if we need to print context separators between lines
+ bool context_mode = false;
+ int context_before = 0;
+ int context_after = 0;
+
+ Colorconf colors;
+};
+
+
+struct Options {
+ bool ignore_case = false;
+ Recursion recursive = Recursion::NONE;
+ bool count = false;
+ bool pagecount = false;
+ bool quiet = false;
+ // vector of all passwords to try on any pdf
+ std::vector<std::string> passwords;
+ int max_count = 0;
+ bool debug = 0;
+ bool warn_empty = false;
+#ifdef HAVE_UNAC
+ bool use_unac = false;
+#endif
+ Outconf outconf;
+ ExcludeList excludes;
+ ExcludeList includes;
+ bool use_cache = false;
+ std::string cache_directory;
+};
+
#endif /* PDFGREP_H */
diff --git a/src/regengine.cc b/src/regengine.cc
index 87015d4..f2f0e5e 100644
--- a/src/regengine.cc
+++ b/src/regengine.cc
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2015 by Hans-Peter Deifel *
+ * Copyright (C) 2017 by Hans-Peter Deifel *
* hpd@hpdeifel.de *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -24,40 +24,59 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <iostream>
+#include <iomanip>
+#include <string>
+#include <sstream>
#include "output.h"
#include "pdfgrep.h"
// regex(3)
-PosixRegex::PosixRegex(const char *pattern, bool case_insensitive)
+using namespace std;
+
+PosixRegex::PosixRegex(const string &pattern, bool case_insensitive)
{
int regex_flags = REG_EXTENDED | (case_insensitive ? REG_ICASE : 0);
- int err = regcomp(&this->regex, pattern, regex_flags);
- if(err) {
+ // The regcomp/regexec implementation of OpenBSD doesn't like empty
+ // patterns. Thus we just replace empty patterns by "()", which does
+ // have the same semantics.
+ const char *c_str_pattern;
+ if (pattern == "") {
+ c_str_pattern = "()";
+ } else {
+ c_str_pattern = pattern.c_str();
+ }
+
+ int ret = regcomp(&this->regex, c_str_pattern, regex_flags);
+ if(ret) {
char err_msg[256];
- regerror(err, &this->regex, err_msg, 256);
- fprintf(stderr, "pdfgrep: %s\n", err_msg);
+ regerror(ret, &this->regex, err_msg, 256);
+ err() << err_msg << endl;
exit(EXIT_ERROR);
}
}
-int PosixRegex::exec(const char *str, size_t offset, struct match *m)
+bool PosixRegex::exec(const string &str, size_t offset, struct match &m) const
{
regmatch_t match[] = {{0, 0}};
const int nmatch = 1;
- int ret = regexec(&this->regex, str + offset, nmatch, match, 0);
+ // If we aren't at the beginning of the page, ^ should not match.
+ int flags = offset == 0 ? 0 : REG_NOTBOL;
+
+ int ret = regexec(&this->regex, &str[offset], nmatch, match, flags);
if(ret) {
- return ret;
+ return false;
}
- m->start = offset + match[0].rm_so;
- m->end = offset + match[0].rm_eo;
+ m.start = offset + match[0].rm_so;
+ m.end = offset + match[0].rm_eo;
- return 0;
+ return true;
}
PosixRegex::~PosixRegex()
@@ -70,19 +89,19 @@ PosixRegex::~PosixRegex()
#ifdef HAVE_LIBPCRE
-PCRERegex::PCRERegex(const char *pattern, bool case_insensitive)
+PCRERegex::PCRERegex(const string &pattern, bool case_insensitive)
{
const char *pcre_err;
int pcre_err_ofs;
- const int pcre_options = case_insensitive ? PCRE_CASELESS : 0;
+ const int pcre_options = PCRE_UTF8 | (case_insensitive ? PCRE_CASELESS : 0);
- this->regex = pcre_compile(pattern, pcre_options,
+ this->regex = pcre_compile(pattern.c_str(), pcre_options,
&pcre_err, &pcre_err_ofs, NULL);
if (this->regex == NULL) {
- fprintf(stderr, "pdfgrep: %s\n", pattern);
- fprintf(stderr, "pdfgrep: %*s\n", pcre_err_ofs + 1, "^");
- fprintf(stderr, "pdfgrep: Error compiling PCRE pattern: %s\n", pcre_err);
+ err() << pattern << endl;
+ err() << setw(pcre_err_ofs+1) << "^" << endl;
+ err() << "Error compiling PCRE pattern: " << pcre_err << endl;
exit(EXIT_ERROR);
}
}
@@ -92,59 +111,78 @@ PCRERegex::~PCRERegex()
pcre_free(this->regex);
}
-int PCRERegex::exec(const char *str, size_t offset, struct match *m)
+bool PCRERegex::exec(const string &str, size_t offset, struct match &m) const
{
- const size_t len = strlen(str);
+ const size_t len = str.size();
int ov[3];
- const int ret = pcre_exec(this->regex, NULL, str, len, offset, 0, ov, 3);
+ const int ret = pcre_exec(this->regex, NULL, str.c_str(), len, offset, 0, ov, 3);
// TODO: Print human readable error
if(ret < 0)
- return 1;
+ return false;
- m->start = ov[0];
- m->end = ov[1];
+ m.start = ov[0];
+ m.end = ov[1];
- return 0;
+ return true;
}
#endif // HAVE_LIBPCRE
-FixedString::FixedString(char *pattern, bool case_insensitive)
+FixedString::FixedString(const string &pattern, bool case_insensitive)
: case_insensitive(case_insensitive)
{
- // split pattern at newlines
- const char *token = strtok(pattern, "\n");
- if (token == NULL) {
+ istringstream str { pattern };
+ string line;
+
+ if (pattern.empty()) {
// special case for the empty pattern. In this case we _do_ want
- // matches, but strtok returns NULL leaving our patterns array
+ // matches, but getline returns false leaving our patterns array
// empty. Thus we add the whole pattern explicitly.
patterns.push_back(pattern);
- } else while (token != NULL) {
- patterns.push_back(token);
- token = strtok(NULL, "\n");
+ return;
+ }
+
+ // split pattern at newlines
+ while (getline(str, line)) {
+ patterns.push_back(line);
}
}
-int FixedString::exec(const char *str, size_t offset, struct match *m)
+bool FixedString::exec(const string &str, size_t offset, struct match &m) const
{
- for (const char* pattern : patterns) {
+ // We use C-style strings here, because of strcasestr
+ const char *str_begin = &str[offset];
+
+ // FIXME Searching for multiple patterns is very inefficient, because we
+ // search the same thing over and over, until it becomes the next match.
+ // We should introduce some kind of caching here
+
+ const char *min_result = NULL;
+ const string *min_pattern;
+
+ for (const string pattern : patterns) {
const char *result;
if (this->case_insensitive) {
- result = strcasestr(str+offset, pattern);
+ result = strcasestr(str_begin, pattern.c_str());
} else {
- result = strstr(str+offset, pattern);
+ result = strstr(str_begin, pattern.c_str());
}
- if (result == NULL) {
- continue;
+ if (result != NULL) {
+ if (min_result == NULL || result < min_result) {
+ min_result = result;
+ min_pattern = &pattern;
+ }
}
+ }
- m->start = offset + (result - (str + offset));
- m->end = m->start + strlen(pattern);
- return 0;
+ if (min_result != NULL) {
+ m.start = offset + (min_result - str_begin);
+ m.end = m.start + (*min_pattern).size();
+ return true;
}
- return 1;
+ return false;
}
diff --git a/src/regengine.h b/src/regengine.h
index 6db97db..bac3661 100644
--- a/src/regengine.h
+++ b/src/regengine.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2015 by Hans-Peter Deifel *
+ * Copyright (C) 2017 by Hans-Peter Deifel *
* hpd@hpdeifel.de *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -30,6 +30,7 @@
#include <pcre.h>
#endif
#include <vector>
+#include <string>
struct match;
@@ -37,16 +38,17 @@ struct match;
class Regengine
{
public:
- virtual int exec(const char *str, size_t offset, struct match *m) = 0;
+ // writes the match data to m. Returns true on success and false on failure
+ virtual bool exec(const std::string &str, size_t offset, struct match &m) const = 0;
virtual ~Regengine() {}
};
class PosixRegex : public Regengine
{
public:
- PosixRegex(const char *pattern, bool case_insensitive);
+ PosixRegex(const std::string &pattern, bool case_insensitive);
~PosixRegex();
- int exec(const char *str, size_t offset, struct match *m);
+ bool exec(const std::string &str, size_t offset, struct match &m) const override;
private:
regex_t regex;
};
@@ -55,9 +57,9 @@ private:
class PCRERegex : public Regengine
{
public:
- PCRERegex(const char *pattern, bool case_insensitive);
+ PCRERegex(const std::string &pattern, bool case_insensitive);
~PCRERegex();
- int exec(const char *str, size_t offset, struct match *m);
+ bool exec(const std::string &str, size_t offset, struct match &m) const override;
private:
pcre *regex;
};
@@ -66,10 +68,10 @@ private:
class FixedString : public Regengine
{
public:
- FixedString(char *pattern, bool case_insensitive);
- int exec(const char *str, size_t offset, struct match *m);
+ FixedString(const std::string &pattern, bool case_insensitive);
+ bool exec(const std::string &str, size_t offset, struct match &m) const override;
private:
- std::vector<const char*> patterns;
+ std::vector<std::string> patterns;
bool case_insensitive;
};
diff --git a/src/search.cc b/src/search.cc
new file mode 100644
index 0000000..ffea9f6
--- /dev/null
+++ b/src/search.cc
@@ -0,0 +1,270 @@
+/***************************************************************************
+ * Copyright (C) 2017 by Hans-Peter Deifel *
+ * hpd@hpdeifel.de *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA. *
+ ***************************************************************************/
+
+#include "search.h"
+#include "output.h"
+
+#include <iostream>
+#include <math.h>
+#include <string.h>
+
+#ifdef HAVE_UNAC
+#include <unac.h>
+#endif
+#include <cpp/poppler-page.h>
+
+
+using namespace std;
+
+struct SearchState {
+ bool document_empty = true;
+ // Total match count in the current PDF
+ int total_count = 0;
+};
+
+// Returns the number of matches found
+static int search_page(const Options &opts, const string &text, size_t pagenum,
+ const string &filename, const Regengine &re,
+ SearchState &state);
+
+#ifdef HAVE_UNAC
+/* convenience layer over libunac */
+static string simple_unac(const Options &opts, string str);
+#endif
+static string maybe_unac(const Options &opts, string std);
+static void handle_match(const Options &opts, const string &filename, size_t page,
+ vector<match> &line, vector<match> &last_line, const match &mt,
+ bool previous_matches);
+static void flush_line_matches(const Options &opts, const string &filename, size_t page,
+ vector<match> &line, vector<match> &last_line,
+ bool previous_matches);
+
+static string page_text(poppler::page &page) {
+ poppler::byte_array arr = page.text(page.page_rect(poppler::media_box)).to_utf8();
+ char *c_str = &arr[0];
+ return string(c_str, arr.size());
+}
+
+int search_document(const Options &opts, unique_ptr<poppler::document> doc,
+ unique_ptr<Cache> cache, const string &filename,
+ const Regengine &re) {
+
+ SearchState state;
+
+ // doc->pages() returns an int, although it should be a size_t
+ size_t doc_pages = static_cast<size_t>(doc->pages());
+
+ for (size_t pagenum = 1; pagenum <= doc_pages; pagenum++) {
+ string text;
+ if (!opts.use_cache || !cache->get_page(pagenum, text)) {
+ unique_ptr<poppler::page> page(doc->create_page(pagenum-1));
+
+ if (!page) {
+ if (!opts.quiet) {
+ err() << "Could not search in page " << pagenum
+ << " of " << filename << endl;
+ }
+ continue;
+ }
+
+ if (!page->text(page->page_rect(poppler::media_box)).empty()) {
+ // there is text on this page, document can't be empty
+ state.document_empty = false;
+ }
+
+ text = page_text(*page);
+ // Update the rendering cache
+ if (opts.use_cache)
+ cache->set_page(pagenum, text);
+ }
+
+ int page_count = search_page(opts, text, pagenum,
+ filename, re, state);
+
+ if (page_count > 0 && opts.pagecount && !opts.quiet) {
+ line_prefix(opts.outconf, filename, false, pagenum) << page_count << endl;
+ }
+
+ if (opts.max_count > 0 && state.total_count >= opts.max_count) {
+ break;
+ }
+ }
+
+ if (opts.count && !opts.quiet) {
+ line_prefix(opts.outconf, filename, false) << state.total_count << endl;
+ }
+
+ if (opts.warn_empty && state.document_empty) {
+ err() << "File does not contain text: " << filename << endl;
+ }
+
+ // Save the cache for a later use
+ if (opts.use_cache)
+ cache->dump();
+
+ return state.total_count;
+}
+
+static int search_page(const Options &opts, const string &page_text,
+ size_t pagenum, const string &filename,
+ const Regengine &re, SearchState &state)
+{
+ // Count of matches just on this page
+ int page_count = 0;
+
+ // We need that in flush_line_matches to know if we need to print a
+ // context separator.
+ bool previous_matches = state.total_count > 0;
+
+ string text = maybe_unac(opts, page_text);
+
+ size_t index = 0;
+ struct match mt = { text, 0, 0 };
+
+ // matches found in current line
+ vector<match> current;
+
+ // last line that contained matches. We only have to store at most one
+ // match, but the ability to store 0 matches is crucial for the initial
+ // state.
+ vector<match> last_line;
+
+ while (re.exec(text.c_str(), index, mt)) {
+ state.total_count++;
+ page_count++;
+
+ if (opts.quiet) {
+ return page_count;
+ }
+
+ handle_match(opts, filename, pagenum, current, last_line, mt, previous_matches);
+
+ if (opts.max_count > 0 && state.total_count >= opts.max_count) {
+ flush_line_matches(opts, filename, pagenum, current, last_line, previous_matches);
+ if (!last_line.empty() && !opts.count && !opts.pagecount) {
+ // Print final context after last match
+ struct context cntxt = {filename, pagenum, opts.outconf};
+ print_context_after(cntxt, *last_line.rbegin());
+ }
+ return page_count;
+ }
+
+ index = mt.end;
+
+ // prevent loop if match is empty
+ if (mt.start == mt.end) {
+ index++;
+ }
+
+ if(index >= text.size()) {
+ break;
+ }
+ }
+
+ flush_line_matches(opts, filename, pagenum, current, last_line, previous_matches);
+
+ if (!last_line.empty() && !opts.count && !opts.pagecount) {
+ // Print final context after last match
+ struct context cntxt = {filename, pagenum, opts.outconf};
+ print_context_after(cntxt, *last_line.rbegin());
+ }
+
+ return page_count;
+}
+
+static void flush_line_matches(const Options &opts, const string &filename, size_t page,
+ vector<match> &line, vector<match> &last_line, bool previous_matches){
+
+ struct context cntxt = {filename, page, opts.outconf};
+
+ // We don't want any output:
+ if (line.empty() || opts.count || opts.pagecount)
+ goto out;
+
+ // context printing
+ if (last_line.empty()) {
+ // There was no previous match
+
+ if (previous_matches) {
+ print_context_separator(opts.outconf);
+ }
+ // (see document_empty)
+ print_context_before(cntxt, *line.begin());
+ } else {
+ print_context_between(cntxt, *last_line.rbegin(), *line.begin());
+ }
+
+ if (opts.outconf.only_matching) {
+ for (auto mt : line) {
+ print_only_match(cntxt, mt);
+ }
+ } else {
+ print_matches(cntxt, line);
+ }
+
+out:
+ line.swap(last_line);
+ line.clear();
+}
+
+static void handle_match(const Options &opts, const string &filename, size_t page,
+ vector<match> &line, vector<match> &last_line, const match &mt,
+ bool previous_matches) {
+ if (line.empty()) {
+ line.push_back(mt);
+ return;
+ }
+ size_t end_last = line.back().end;
+ // TODO: Don't search whole string, just up to mt.start
+ auto next_newline = mt.string.find('\n', end_last);
+ if (next_newline == string::npos || next_newline > mt.start) {
+ line.push_back(mt);
+ } else {
+ flush_line_matches(opts, filename, page, line, last_line, previous_matches);
+ line.push_back(mt);
+ }
+}
+
+#ifdef HAVE_UNAC
+static string simple_unac(const Options &opts, string str)
+{
+ if (!opts.use_unac)
+ return str;
+
+ char *res = NULL;
+ size_t reslen = 0;
+
+ if (unac_string("UTF-8", str.c_str(), str.size(), &res, &reslen)) {
+ perror("pdfgrep: Failed to remove accents: ");
+ return str;
+ }
+
+ return res;
+}
+#endif
+
+static string maybe_unac(const Options &opts, string str) {
+#ifdef HAVE_UNAC
+ return simple_unac(opts, str);
+#else
+ (void) opts;
+ return str;
+#endif
+}
diff --git a/src/search.h b/src/search.h
new file mode 100644
index 0000000..f3fa82c
--- /dev/null
+++ b/src/search.h
@@ -0,0 +1,37 @@
+/***************************************************************************
+ * Copyright (C) 2017 by Hans-Peter Deifel *
+ * hpd@hpdeifel.de *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA. *
+ ***************************************************************************/
+
+#ifndef SEARCH_H
+#define SEARCH_H
+
+#include <memory>
+#include <cpp/poppler-document.h>
+
+#include "pdfgrep.h"
+#include "regengine.h"
+#include "cache.h"
+
+// Returns the number of matches found in this document
+int search_document(const Options &opts, std::unique_ptr<poppler::document> doc,
+ std::unique_ptr<Cache> cache, const std::string &filename,
+ const Regengine &re);
+
+
+#endif /* SEARCH_H */
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index 3b3a2fe..47ba9f8 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -1,10 +1,8 @@
# Include 'make check' target for running tests
AUTOMAKE_OPTIONS = dejagnu
-export DEJAGNU
-
DEJATOOL = pdfgrep
-EXTRA_DIST = global-conf.exp README.md
+EXTRA_DIST = README.md
SUBDIRS = config lib pdfgrep.tests
diff --git a/testsuite/Makefile.in b/testsuite/Makefile.in
index 39cc9b6..298bbdb 100644
--- a/testsuite/Makefile.in
+++ b/testsuite/Makefile.in
@@ -85,6 +85,8 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
subdir = testsuite
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \
@@ -199,7 +201,6 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
-DEJAGNU = @DEJAGNU@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
@@ -210,14 +211,16 @@ GREP = @GREP@
HAVE_A2X = @HAVE_A2X@
HAVE_CXX11 = @HAVE_CXX11@
HAVE_GCOV = @HAVE_GCOV@
-HAVE_GENHTML = @HAVE_GENHTML@
-HAVE_LCOV = @HAVE_LCOV@
+HAVE_GCOVR = @HAVE_GCOVR@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
+LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
+LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
+LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
@@ -252,7 +255,11 @@ am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
+build = @build@
build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
builddir = @builddir@
cov_CFLAGS = @cov_CFLAGS@
cov_LDFLAGS = @cov_LDFLAGS@
@@ -261,7 +268,11 @@ datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
+host = @host@
host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
@@ -295,7 +306,7 @@ unac_LIBS = @unac_LIBS@
# Include 'make check' target for running tests
AUTOMAKE_OPTIONS = dejagnu
DEJATOOL = pdfgrep
-EXTRA_DIST = global-conf.exp README.md
+EXTRA_DIST = README.md
SUBDIRS = config lib pdfgrep.tests
all: all-recursive
@@ -447,6 +458,10 @@ site.exp: Makefile $(EXTRA_DEJAGNU_SITE_CONFIG)
@echo '# edit the last section' >>site.tmp
@echo 'set srcdir "$(srcdir)"' >>site.tmp
@echo "set objdir `pwd`" >>site.tmp
+ @echo 'set build_alias "$(build_alias)"' >>site.tmp
+ @echo 'set build_triplet $(build_triplet)' >>site.tmp
+ @echo 'set host_alias "$(host_alias)"' >>site.tmp
+ @echo 'set host_triplet $(host_triplet)' >>site.tmp
@list='$(EXTRA_DEJAGNU_SITE_CONFIG)'; for f in $$list; do \
echo "## Begin content included from file $$f. Do not modify. ##" \
&& cat `test -f "$$f" || echo '$(srcdir)/'`$$f \
@@ -643,8 +658,6 @@ uninstall-am:
.PRECIOUS: Makefile
-export DEJAGNU
-
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
diff --git a/testsuite/README.md b/testsuite/README.md
index 07a9c89..7bbebfa 100644
--- a/testsuite/README.md
+++ b/testsuite/README.md
@@ -12,9 +12,14 @@ The tests depend on the following packages:
To run the tests, execute `make check` from the toplevel source
directory.
+The testsuite might output some harmless messages like "WARNING:
+Couldn't find the global config file.". What's really important are
+any lines beginning with "FAIL:".
+
## Coverage
-To get test coverage, run configure with the following arguments:
+To get a test coverage report, install `gcovr` and run configure with
+the following arguments:
./configure CXXFLAGS="-O0" --enable-coverage
@@ -23,8 +28,8 @@ and then run:
make clean
make coverage
-This will write a coverage report as HTML to the new directory
-`coverage_report`.
+This will print a test coverage report to stdout. To get an HTML
+report with lcov, run `make cov-report-html`.
## Configuration
@@ -32,7 +37,7 @@ The test runs can be configured by editing `testsuite/site.exp`. The
following variables can be set:
- `disable_poppler_version_check`: Don't mark tests as unsupported if
- the poppler version is not recent enought. (This is useful, if you
+ the poppler version is not recent enough. (This is useful if you
have backported a patch from a later version to your current one).
## Writing new tests
diff --git a/testsuite/config/Makefile.in b/testsuite/config/Makefile.in
index ffe5f8c..9d4f384 100644
--- a/testsuite/config/Makefile.in
+++ b/testsuite/config/Makefile.in
@@ -85,6 +85,8 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
subdir = testsuite/config
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \
@@ -136,7 +138,6 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
-DEJAGNU = @DEJAGNU@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
@@ -147,14 +148,16 @@ GREP = @GREP@
HAVE_A2X = @HAVE_A2X@
HAVE_CXX11 = @HAVE_CXX11@
HAVE_GCOV = @HAVE_GCOV@
-HAVE_GENHTML = @HAVE_GENHTML@
-HAVE_LCOV = @HAVE_LCOV@
+HAVE_GCOVR = @HAVE_GCOVR@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
+LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
+LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
+LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
@@ -189,7 +192,11 @@ am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
+build = @build@
build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
builddir = @builddir@
cov_CFLAGS = @cov_CFLAGS@
cov_LDFLAGS = @cov_LDFLAGS@
@@ -198,7 +205,11 @@ datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
+host = @host@
host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
diff --git a/testsuite/global-conf.exp b/testsuite/global-conf.exp
deleted file mode 100644
index 37c4ed7..0000000
--- a/testsuite/global-conf.exp
+++ /dev/null
@@ -1,5 +0,0 @@
-# Increase this to get more diagnostics
-set verbose 0
-
-# Set this to 1, to see all passed tests
-set all_flag 0
diff --git a/testsuite/lib/Makefile.in b/testsuite/lib/Makefile.in
index 4ad47f4..36f89b4 100644
--- a/testsuite/lib/Makefile.in
+++ b/testsuite/lib/Makefile.in
@@ -85,6 +85,8 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
subdir = testsuite/lib
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \
@@ -136,7 +138,6 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
-DEJAGNU = @DEJAGNU@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
@@ -147,14 +148,16 @@ GREP = @GREP@
HAVE_A2X = @HAVE_A2X@
HAVE_CXX11 = @HAVE_CXX11@
HAVE_GCOV = @HAVE_GCOV@
-HAVE_GENHTML = @HAVE_GENHTML@
-HAVE_LCOV = @HAVE_LCOV@
+HAVE_GCOVR = @HAVE_GCOVR@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
+LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
+LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
+LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
@@ -189,7 +192,11 @@ am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
+build = @build@
build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
builddir = @builddir@
cov_CFLAGS = @cov_CFLAGS@
cov_LDFLAGS = @cov_LDFLAGS@
@@ -198,7 +205,11 @@ datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
+host = @host@
host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
diff --git a/testsuite/lib/pdfgrep.exp b/testsuite/lib/pdfgrep.exp
index a318daf..5e3f051 100644
--- a/testsuite/lib/pdfgrep.exp
+++ b/testsuite/lib/pdfgrep.exp
@@ -11,15 +11,16 @@
# unless explicitly told so. And then we want to be able to test for them.
remove_nulls -d 0
+set pdfgrep_path [file normalize ../src/pdfgrep]
# Just spawns pdfgrep with the given arguments
proc pdfgrep args {
- global spawn_id
- spawn ../src/pdfgrep {*}$args
+ global spawn_id pdfgrep_path
+ spawn $pdfgrep_path {*}$args
}
-# Spawns pdfgrep and fail is pdfgrep prints something on stderr.
+# Spawns pdfgrep and fail if pdfgrep prints something on stderr.
proc pdfgrep_noerr args {
global spawn_id test
pdfgrep {*}$args
@@ -70,15 +71,26 @@ set requires_pcre_support false
# pattern is a regular expression that _completely_ matches the output. I.e it
# pdfgrep_expect encloses it int ^$.
proc pdfgrep_expect args {
- pdfgrep_expect_internal 0 {*}$args
+ pdfgrep_expect_internal 0 0 {*}$args
}
# Same as above, but expect the test to fail
proc pdfgrep_expect_x args {
- pdfgrep_expect_internal 1 {*}$args
+ pdfgrep_expect_internal 1 0 {*}$args
}
-proc pdfgrep_expect_internal {expected_failure args} {
+# Same as pdfgrep_expect, but don't immediately fail if pdfgrep prints to
+# stderr.
+proc pdfgrep_expect_with_err args {
+ pdfgrep_expect_internal 0 1 {*}$args
+}
+
+# Same as before, but expect the test to fail
+proc pdfgrep_expect_with_err_x args {
+ pdfgrep_expect_internal 1 1 {*}$args
+}
+
+proc pdfgrep_expect_internal {expected_failure allow_errors args} {
global spawn_id test required_poppler_version
set output [lindex $args end]
@@ -90,7 +102,11 @@ proc pdfgrep_expect_internal {expected_failure args} {
# --color=never is necessary because we dont want to have escape sequences
# in the output.
- pdfgrep_noerr --color=never {*}$args
+ if {$allow_errors} {
+ pdfgrep --color=never {*}$args
+ } else {
+ pdfgrep_noerr --color=never {*}$args
+ }
expect {
# The final newline is only optionally matched, because some client code
# may include it
@@ -138,7 +154,7 @@ proc expect_exit_status {expected} {
set wait_status [wait]
if {[lindex $wait_status 3] != $expected} {
- send_user "Exit status is [lindex $wait_status 3], but expected $expected\n"
+ send_log "Exit status is [lindex $wait_status 3], but expected $expected\n"
pfail "$test \[exit status\]"
} else {
ppass "$test \[exit status\]"
@@ -212,8 +228,11 @@ proc reset_configuration {} {
# The directory where the PDFs will be generated.
-# NOTE This will frequently be removed, so don't put important data there
-set pdfdir [exec mktemp --tmpdir -d pdfgrep_tests.XXXXXXXXXX]
+# NOTE This will frequently be # removed, so don't put important data there
+# TODO On Linux, the -t option for mktemp is marked as deprecated and the
+# --tmpdir option should be used. Unfortunately, this option is not available on
+# the BSDs.
+set pdfdir [exec mktemp -t -d pdfgrep_tests.XXXXXXXXXX]
# Delete $pdfdir recursively and create it anew
@@ -266,7 +285,8 @@ proc mkpdf {name content} {
# The following functions are called by dejagnu
proc pdfgrep_version {} {
+ global pdfgrep_path
puts ""
- note [exec ../src/pdfgrep --version]
+ note [exec $pdfgrep_path --version]
puts ""
}
diff --git a/testsuite/pdfgrep.tests/Makefile.am b/testsuite/pdfgrep.tests/Makefile.am
index 03d17d0..2cc3af4 100644
--- a/testsuite/pdfgrep.tests/Makefile.am
+++ b/testsuite/pdfgrep.tests/Makefile.am
@@ -6,5 +6,7 @@ EXTRA_DIST =color.exp \
page_numbers.exp \
recursive.exp \
regex.exp \
- usage.exp
+ usage.exp \
+ context.exp \
+ cache.exp
diff --git a/testsuite/pdfgrep.tests/Makefile.in b/testsuite/pdfgrep.tests/Makefile.in
index 74b7127..b750a18 100644
--- a/testsuite/pdfgrep.tests/Makefile.in
+++ b/testsuite/pdfgrep.tests/Makefile.in
@@ -85,6 +85,8 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
subdir = testsuite/pdfgrep.tests
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \
@@ -136,7 +138,6 @@ CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
-DEJAGNU = @DEJAGNU@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
@@ -147,14 +148,16 @@ GREP = @GREP@
HAVE_A2X = @HAVE_A2X@
HAVE_CXX11 = @HAVE_CXX11@
HAVE_GCOV = @HAVE_GCOV@
-HAVE_GENHTML = @HAVE_GENHTML@
-HAVE_LCOV = @HAVE_LCOV@
+HAVE_GCOVR = @HAVE_GCOVR@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
+LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
+LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
+LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
@@ -189,7 +192,11 @@ am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
+build = @build@
build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
builddir = @builddir@
cov_CFLAGS = @cov_CFLAGS@
cov_LDFLAGS = @cov_LDFLAGS@
@@ -198,7 +205,11 @@ datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
+host = @host@
host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
@@ -236,7 +247,9 @@ EXTRA_DIST = color.exp \
page_numbers.exp \
recursive.exp \
regex.exp \
- usage.exp
+ usage.exp \
+ context.exp \
+ cache.exp
all: all-am
diff --git a/testsuite/pdfgrep.tests/cache.exp b/testsuite/pdfgrep.tests/cache.exp
new file mode 100644
index 0000000..e4462e2
--- /dev/null
+++ b/testsuite/pdfgrep.tests/cache.exp
@@ -0,0 +1,149 @@
+setenv XDG_CACHE_HOME "$pdfdir"
+
+set cachedir "$pdfdir/pdfgrep/"
+
+proc count_cache_files num {
+ global cachedir test
+ set len [llength [glob $cachedir/*]]
+ if {$len == $num} {
+ ppass $test
+ } else {
+ pfail "$test -- file count: $len"
+ }
+}
+
+######################################################################
+
+set test "cache creates file"
+
+clear_pdfdir
+set pdf [mkpdf pdf {
+ this is a test.
+}]
+
+pdfgrep --cache test $pdf
+expect eof
+count_cache_files 1
+
+######################################################################
+
+set test "cache creates another file"
+
+set pdf2 [mkpdf pdf2 {
+ this is another test.
+}]
+
+pdfgrep --cache test $pdf2
+expect eof
+count_cache_files 2
+
+######################################################################
+
+set test "cache doesn't create new file for same content"
+
+file copy $pdf2 $pdfdir/pdf3.pdf
+
+pdfgrep --cache test $pdfdir/pdf3.pdf
+expect eof
+count_cache_files 2
+
+######################################################################
+
+set test "cached call returns the same as original"
+
+# See poppler bug 91644
+# https://bugs.freedesktop.org/show_bug.cgi?id=91644
+set required_poppler_version {0 36 0}
+
+clear_pdfdir
+set pdf [mkpdf pdf {
+ this is a test
+}]
+
+pdfgrep --cache test $pdf
+expect eof
+
+pdfgrep_expect --cache test $pdf "this is a test"
+
+######################################################################
+
+set test "cached limit works"
+
+clear_pdfdir
+file mkdir $cachedir
+for {set i 0} {$i < 10} {incr i} {
+ exec touch -t 199001010101 "$cachedir/foo$i"
+}
+
+set pdf [mkpdf pdf {
+ this is a test.
+}]
+
+setenv PDFGREP_CACHE_LIMIT 5
+
+pdfgrep --cache test $pdf
+expect eof
+
+# 5 old ones and the one from the pdf
+count_cache_files 6
+
+######################################################################
+
+set test "cache works when XDG_CACHE_HOME is not set"
+
+unsetenv XDG_CACHE_HOME
+set homedir $env(HOME)
+setenv HOME "$pdfdir"
+set cachedir "$pdfdir/.cache/pdfgrep"
+
+clear_pdfdir
+set pdf [mkpdf pdf {
+ this is a test.
+}]
+
+pdfgrep --cache test $pdf
+expect eof
+count_cache_files 1
+
+setenv HOME $homedir
+
+######################################################################
+
+set test "warning if XDG_CACHE_HOME cannot be created"
+
+# See poppler bug 91644
+# https://bugs.freedesktop.org/show_bug.cgi?id=91644
+set required_poppler_version {0 36 0}
+
+setenv XDG_CACHE_HOME "$pdfdir/testdir/cache"
+
+clear_pdfdir
+
+set pdf [mkpdf pdf {
+ this is a test
+}]
+
+pdfgrep_expect_with_err --cache test $pdf \
+".*pdfgrep: warning: .*
+this is a test"
+
+######################################################################
+
+set test "warning if XDG_CACHE_HOME/pdfgrep cannot be created"
+
+# See poppler bug 91644
+# https://bugs.freedesktop.org/show_bug.cgi?id=91644
+set required_poppler_version {0 36 0}
+
+setenv XDG_CACHE_HOME "$pdfdir/cache"
+
+# Create /cache as file instead of directory to make mkdir return EEXIST but
+# prevent the creation of subdirs. Creating a readonly directory does not work
+# in case tests are executed as root (relevant in containers).
+exec touch "$pdfdir/cache"
+
+pdfgrep_expect_with_err --cache test $pdf \
+".*pdfgrep: warning: .*
+this is a test"
+
+# TODO Find a way to test cache size limit without creating too many files
diff --git a/testsuite/pdfgrep.tests/color.exp b/testsuite/pdfgrep.tests/color.exp
index 5979edf..b81d232 100644
--- a/testsuite/pdfgrep.tests/color.exp
+++ b/testsuite/pdfgrep.tests/color.exp
@@ -8,6 +8,7 @@ expect {
default { pfail $test }
}
+expect eof
expect_exit_status 2
diff --git a/testsuite/pdfgrep.tests/context.exp b/testsuite/pdfgrep.tests/context.exp
new file mode 100644
index 0000000..32959f9
--- /dev/null
+++ b/testsuite/pdfgrep.tests/context.exp
@@ -0,0 +1,413 @@
+# These are tests for the context system (i.e the options -A, -B and -C).
+
+######################################################################
+####### Context after ###############################################
+######################################################################
+
+set test "Context after"
+
+# See poppler bug 91644
+# https://bugs.freedesktop.org/show_bug.cgi?id=91644
+set required_poppler_version {0 36 0}
+
+clear_pdfdir
+set pdf [mkpdf lines {
+ line one\\
+ line two\\
+ line three\\
+ line four\\
+ line five\\
+ line six
+}]
+
+pdfgrep_expect -A1 "one\|five" $pdf \
+"line one
+line two
+--
+line five
+line six"
+
+######################################################################
+
+set test "Context after -- edge case"
+
+# See poppler bug 91644
+# https://bugs.freedesktop.org/show_bug.cgi?id=91644
+set required_poppler_version {0 36 0}
+
+pdfgrep_expect -A1 "six" $pdf \
+"line six"
+
+######################################################################
+
+set test "Context after -- continuous"
+
+pdfgrep_expect -A1 "one\|two" $pdf \
+"line one
+line two
+line three"
+
+######################################################################
+
+set test "Context after -- line numbers"
+
+# See poppler bug 91644
+# https://bugs.freedesktop.org/show_bug.cgi?id=91644
+set required_poppler_version {0 36 0}
+
+pdfgrep_expect -nA1 "one\|five" $pdf \
+"1:line one
+1-line two
+--
+1:line five
+1-line six"
+
+######################################################################
+
+set test "Context after -- line numbers and filename"
+
+# See poppler bug 91644
+# https://bugs.freedesktop.org/show_bug.cgi?id=91644
+set required_poppler_version {0 36 0}
+
+pdfgrep_expect -nHA1 "one\|five" $pdf \
+"$pdf:1:line one
+$pdf-1-line two
+--
+$pdf:1:line five
+$pdf-1-line six"
+
+######################################################################
+
+set test "Context after -- zero context lines"
+
+pdfgrep_expect -nHA0 "one\|five" $pdf \
+"$pdf:1:line one
+--
+$pdf:1:line five"
+
+######################################################################
+
+set test "Context after -- only matching"
+
+pdfgrep_expect_with_err -oA1 "one\|five" $pdf \
+"pdfgrep: warning: .*
+one
+five"
+
+######################################################################
+
+set test "Context after -- page breaks"
+
+# See poppler bug 91644
+# https://bugs.freedesktop.org/show_bug.cgi?id=91644
+set required_poppler_version {0 36 0}
+
+set pages [mkpdf pages {
+ page one
+ \newpage
+ page two
+}]
+
+pdfgrep_expect -nA2 "page" $pages \
+"1:page one
+--
+2:page two"
+
+######################################################################
+
+set test "Context after -- max-count"
+
+pdfgrep_expect -A1 -m2 "line" $pdf \
+"line one
+line two
+line three"
+
+######################################################################
+
+set test "Context after -- count"
+
+pdfgrep_expect -A1 -c "one" $pdf \
+"1"
+
+######################################################################
+
+set test "Context after -- page count"
+
+pdfgrep_expect -A1 --page-count "one" $pdf \
+"1:1"
+
+######################################################################
+####### Context before ##############################################
+######################################################################
+
+set test "Context before"
+
+# See poppler bug 91644
+# https://bugs.freedesktop.org/show_bug.cgi?id=91644
+set required_poppler_version {0 36 0}
+
+pdfgrep_expect -B1 "two\|six" $pdf \
+"line one
+line two
+--
+line five
+line six"
+
+######################################################################
+
+set test "Context before -- edge case"
+
+pdfgrep_expect -B1 "one" $pdf \
+"line one"
+
+######################################################################
+
+set test "Context before -- continuous"
+
+pdfgrep_expect -B1 "two\|three" $pdf \
+"line one
+line two
+line three"
+
+######################################################################
+
+set test "Context before -- line numbers"
+
+# See poppler bug 91644
+# https://bugs.freedesktop.org/show_bug.cgi?id=91644
+set required_poppler_version {0 36 0}
+
+pdfgrep_expect -nB1 "two\|six" $pdf \
+"1-line one
+1:line two
+--
+1-line five
+1:line six"
+
+######################################################################
+
+set test "Context before -- line numbers and filename"
+
+# See poppler bug 91644
+# https://bugs.freedesktop.org/show_bug.cgi?id=91644
+set required_poppler_version {0 36 0}
+
+pdfgrep_expect -nHB1 "two\|six" $pdf \
+"$pdf-1-line one
+$pdf:1:line two
+--
+$pdf-1-line five
+$pdf:1:line six"
+
+######################################################################
+
+set test "Context before -- zero context lines"
+
+# See poppler bug 91644
+# https://bugs.freedesktop.org/show_bug.cgi?id=91644
+set required_poppler_version {0 36 0}
+
+pdfgrep_expect -nHB0 "two\|six" $pdf \
+"$pdf:1:line two
+--
+$pdf:1:line six"
+
+######################################################################
+
+set test "Context before -- only matching"
+
+pdfgrep_expect_with_err -oB2 "two\|six" $pdf \
+"pdfgrep: warning: .*
+two
+six"
+
+######################################################################
+
+set test "Context before -- page breaks"
+
+# See poppler bug 91644
+# https://bugs.freedesktop.org/show_bug.cgi?id=91644
+set required_poppler_version {0 36 0}
+
+pdfgrep_expect -nB2 "page" $pages \
+"1:page one
+--
+2:page two"
+
+######################################################################
+
+set test "Context before -- max-count"
+
+pdfgrep_expect -B1 -m2 "two\|three\|four" $pdf \
+"line one
+line two
+line three"
+
+######################################################################
+
+set test "Context before -- count"
+
+pdfgrep_expect -B1 -c "one" $pdf \
+"1"
+
+######################################################################
+
+set test "Context before -- page count"
+
+pdfgrep_expect -B1 --page-count "one" $pdf \
+"1:1"
+
+######################################################################
+####### Context around ##############################################
+######################################################################
+
+set test "Context"
+
+# See poppler bug 91644
+# https://bugs.freedesktop.org/show_bug.cgi?id=91644
+set required_poppler_version {0 36 0}
+
+pdfgrep_expect -C1 "one\|five" $pdf \
+"line one
+line two
+--
+line four
+line five
+line six"
+
+######################################################################
+
+set test "Context -- edge case 1"
+
+pdfgrep_expect -C1 "one" $pdf \
+"line one
+line two"
+
+######################################################################
+
+set test "Context -- edge case 2"
+
+# See poppler bug 91644
+# https://bugs.freedesktop.org/show_bug.cgi?id=91644
+set required_poppler_version {0 36 0}
+
+pdfgrep_expect -C1 "six" $pdf \
+"line five
+line six"
+
+######################################################################
+
+set test "Context -- continuous"
+
+pdfgrep_expect -C1 "two\|four" $pdf \
+"line one
+line two
+line three
+line four
+line five"
+
+######################################################################
+
+set test "Context -- line numbers"
+
+# See poppler bug 91644
+# https://bugs.freedesktop.org/show_bug.cgi?id=91644
+set required_poppler_version {0 36 0}
+
+pdfgrep_expect -nC1 "one\|six" $pdf \
+"1:line one
+1-line two
+--
+1-line five
+1:line six"
+
+######################################################################
+
+set test "Context -- line numbers and filename"
+
+# See poppler bug 91644
+# https://bugs.freedesktop.org/show_bug.cgi?id=91644
+set required_poppler_version {0 36 0}
+
+pdfgrep_expect -nHC1 "one\|six" $pdf \
+"$pdf:1:line one
+$pdf-1-line two
+--
+$pdf-1-line five
+$pdf:1:line six"
+
+######################################################################
+
+set test "Context -- zero context lines"
+
+# See poppler bug 91644
+# https://bugs.freedesktop.org/show_bug.cgi?id=91644
+set required_poppler_version {0 36 0}
+
+pdfgrep_expect -nHC0 "two\|six" $pdf \
+"$pdf:1:line two
+--
+$pdf:1:line six"
+
+######################################################################
+
+set test "Context -- only matching"
+
+pdfgrep_expect_with_err -oC2 "two\|six" $pdf \
+"pdfgrep: warning: .*
+two
+six"
+
+######################################################################
+
+set test "Context -- page breaks"
+
+# See poppler bug 91644
+# https://bugs.freedesktop.org/show_bug.cgi?id=91644
+set required_poppler_version {0 36 0}
+
+pdfgrep_expect -nC1 "page" $pages \
+"1:page one
+--
+2:page two"
+
+######################################################################
+
+set test "Context -- max-count"
+
+pdfgrep_expect -C1 -m2 "two\|three\|five" $pdf \
+"line one
+line two
+line three
+line four"
+
+######################################################################
+
+set test "Context -- count"
+
+pdfgrep_expect -C1 -c "one" $pdf \
+"1"
+
+######################################################################
+
+set test "Context -- page count"
+
+pdfgrep_expect -C1 --page-count "one" $pdf \
+"1:1"
+
+######################################################################
+
+set test "Context -- exact meeting"
+
+# See poppler bug 91644
+# https://bugs.freedesktop.org/show_bug.cgi?id=91644
+set required_poppler_version {0 36 0}
+
+pdfgrep_expect -A1 -B2 "one\|five" $pdf \
+"line one
+line two
+line three
+line four
+line five
+line six"
diff --git a/testsuite/pdfgrep.tests/exit_status.exp b/testsuite/pdfgrep.tests/exit_status.exp
index 85411d7..6f8e794 100644
--- a/testsuite/pdfgrep.tests/exit_status.exp
+++ b/testsuite/pdfgrep.tests/exit_status.exp
@@ -8,7 +8,7 @@ clear_pdfdir
set pdf [mkpdf exit-status "foobar"]
pdfgrep foobar $pdf
-
+expect eof
expect_exit_status 0
########################################
@@ -21,6 +21,7 @@ set required_poppler_version {0 36 0}
pdfgrep --quiet foobar $pdf
+expect eof
expect_exit_status 0
@@ -30,6 +31,7 @@ set test "Exit status is 1 when nothing is found"
pdfgrep not-there $pdf
+expect eof
expect_exit_status 1
########################################
@@ -40,5 +42,5 @@ clear_pdfdir
# $pdf doesn't exist anymore
pdfgrep foobar $pdf
-
+expect eof
expect_exit_status 2
diff --git a/testsuite/pdfgrep.tests/misc.exp b/testsuite/pdfgrep.tests/misc.exp
index ef71a55..67fafba 100644
--- a/testsuite/pdfgrep.tests/misc.exp
+++ b/testsuite/pdfgrep.tests/misc.exp
@@ -55,3 +55,63 @@ set pdf [mkpdf pdf {this is a long line}]
pdfgrep_expect --only-matching long $pdf \
"long"
+
+######################################################################
+
+set test "without arguments and no -r"
+
+set savedir [pwd]
+cd $pdfdir
+
+pdfgrep_expect foo \
+ "Usage.*"
+
+expect_exit_status 2
+
+######################################################################
+
+set test "without arguments and -r"
+
+# See poppler bug 91644
+# https://bugs.freedesktop.org/show_bug.cgi?id=91644
+set required_poppler_version {0 36 0}
+
+pdfgrep_expect -r long \
+ "./pdf.pdf:this is a long line"
+
+######################################################################
+
+set test "without arguments and -R"
+
+# See poppler bug 91644
+# https://bugs.freedesktop.org/show_bug.cgi?id=91644
+set required_poppler_version {0 36 0}
+
+pdfgrep_expect -R long \
+ "./pdf.pdf:this is a long line"
+
+cd $savedir
+
+######################################################################
+
+set test "text in MediaBox and not in CropBox"
+
+# a pdf can have multiple boundary boxes. By default, poppler-cpp uses the
+# CropBox which can be smaller as the guaranteed largest MediaBox. But pdfgrep
+# should also find text that's in in the MediaBox and not in the CropBox.
+
+# See poppler bug 91644
+# https://bugs.freedesktop.org/show_bug.cgi?id=91644
+set required_poppler_version {0 36 0}
+
+clear_pdfdir
+set pdf [mkpdf pdf {
+ \pdfpageattr{
+ % This is smaller than the default mediabox
+ /CropBox [0 300 595.28 841.89]
+ }
+ test
+}]
+
+pdfgrep_expect ".*" $pdf \
+ "test"
diff --git a/testsuite/pdfgrep.tests/regex.exp b/testsuite/pdfgrep.tests/regex.exp
index 51cca0d..6a3b4f3 100644
--- a/testsuite/pdfgrep.tests/regex.exp
+++ b/testsuite/pdfgrep.tests/regex.exp
@@ -1,14 +1,5 @@
set test "Match line after double match"
-# pdfgrep currently prints a line with two matches twice. This is of course not
-# grep compatible and should be changed in the future.
-
-# Nevertheless, right now it's the documented behaviour and should be tested
-# for.
-
-# This case tests specifically for a bug where a line after a double match would
-# not be printed.
-
# See poppler bug 91644
# https://bugs.freedesktop.org/show_bug.cgi?id=91644
set required_poppler_version {0 36 0}
@@ -21,7 +12,6 @@ set pdf [mkpdf regex {
pdfgrep_expect foo $pdf \
"foofoo
-foofoo
foo test"
set test "Match line after double match -- fixed string"
@@ -32,7 +22,6 @@ set required_poppler_version {0 36 0}
pdfgrep_expect -F foo $pdf \
"foofoo
-foofoo
foo test"
set test "Match line after double match -- PCRE"
@@ -45,7 +34,6 @@ set requires_pcre_support true
pdfgrep_expect -P foo $pdf \
"foofoo
-foofoo
foo test"
######################################################################
@@ -65,9 +53,7 @@ set empty [mkpdf empty {
set timeout 2
pdfgrep_expect "" $empty \
-"abc
-abc
-abc"
+"abc"
set test "Empty pattern -- fixed string"
@@ -77,9 +63,7 @@ set required_poppler_version {0 36 0}
set timeout 2
pdfgrep_expect -F "" $empty \
-"abc
-abc
-abc"
+"abc"
set test "Empty pattern -- PCRE"
@@ -91,9 +75,7 @@ set required_poppler_version {0 36 0}
set timeout 2
pdfgrep_expect -P "" $empty \
-"abc
-abc
-abc"
+"abc"
######################################################################
@@ -139,11 +121,7 @@ pdfgrep_expect -Pi "foobar" $pdf \
######################################################################
-# These test cases are expected to fail, because pdfgrep currently cannot do
-# this. The pattern is always matched on the whole text of a page instead of
-# line-wise. The question is whether this would be worthwile.
-
-set test "Matching line beginning and end"
+set test "Multiple fixed strings"
clear_pdfdir
set pdf [mkpdf lines {
@@ -152,29 +130,30 @@ set pdf [mkpdf lines {
line three
}]
-pdfgrep_expect_x "^line two$" $pdf \
- "line two"
-
-
-set test "Matching line beginning and end -- PCRE"
-
-set requires_pcre_support true
+# See poppler bug 91644
+# https://bugs.freedesktop.org/show_bug.cgi?id=91644
+set required_poppler_version {0 36 0}
-pdfgrep_expect_x "^line two$" $pdf \
- "line two"
+pdfgrep_expect -F "one\ntwo\nthree" $pdf \
+"line one
+line two
+line three"
######################################################################
-set test "Multiple fixed strings"
+set test "Multiple fixed strings in wrong order"
# See poppler bug 91644
# https://bugs.freedesktop.org/show_bug.cgi?id=91644
set required_poppler_version {0 36 0}
-pdfgrep_expect -F "one\ntwo\nthree" $pdf \
-"line one
-line two
-line three"
+set multifixed [mkpdf multifixed {
+ one two
+}]
+
+pdfgrep_expect -o -F "two\none" $multifixed \
+"one
+two"
######################################################################
@@ -198,3 +177,63 @@ set multiline [mkpdf multiline {
pdfgrep_expect -P "one\nline" $multiline \
"line one
line two"
+
+######################################################################
+
+set test "Empty page"
+
+clear_pdfdir
+set pdf [mkpdf empty {
+page1\\\\
+still page 1
+\newpage\mbox{}\newpage
+page2
+}]
+
+pdfgrep_expect -n "^$" $pdf \
+ "2:"
+
+######################################################################
+
+set test "Empty page -- PCRE"
+
+set requires_pcre_support true
+
+pdfgrep_expect -P -n "^$" $pdf \
+ "2:"
+
+######################################################################
+
+set test "Page beginning is actually page beginning"
+
+pdfgrep_expect -n --only-match "p|^age" $pdf \
+"1:p
+1:p
+3:p"
+
+######################################################################
+
+set test "Page beginning is actually page beginning -- PCRE"
+
+set requires_pcre_support true
+
+pdfgrep_expect -P -n --only-match "p|^age" $pdf \
+"1:p
+1:p
+3:p"
+
+######################################################################
+
+set test "Invalid regex"
+
+pdfgrep_expect_error -r "(" .
+
+expect_exit_status 2
+
+######################################################################
+
+set test "Invalid regex -- PCRE"
+
+pdfgrep_expect_error -Pr "(" .
+
+expect_exit_status 2
diff --git a/testsuite/pdfgrep.tests/usage.exp b/testsuite/pdfgrep.tests/usage.exp
index 5e7d0d6..5ab8738 100644
--- a/testsuite/pdfgrep.tests/usage.exp
+++ b/testsuite/pdfgrep.tests/usage.exp
@@ -5,7 +5,7 @@ expect {
-re "^Usage: .*" { pass $test }
default { fail $test }
}
-
+expect eof
expect_exit_status 2
# Also look that nothing is written to stdout