diff options
author | Christoph Egger <christoph@christoph-egger.org> | 2015-02-23 14:09:31 +0100 |
---|---|---|
committer | Christoph Egger <christoph@christoph-egger.org> | 2015-02-23 14:09:31 +0100 |
commit | cb541b16a276194926bb8bab665216fefc2d4f90 (patch) | |
tree | 145eb9c4d16b5862ac488e750a40ddd2e692ee8b | |
parent | a29ea1e5ee54002606583a3e7333a9380bb87d06 (diff) |
Imported Upstream version 1.3.2
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | Makefile.in | 2 | ||||
-rw-r--r-- | NEWS | 39 | ||||
-rw-r--r-- | README | 4 | ||||
-rw-r--r-- | aclocal.m4 | 40 | ||||
-rw-r--r-- | completion/Makefile.am | 21 | ||||
-rw-r--r-- | completion/Makefile.in | 162 | ||||
-rw-r--r-- | completion/_pdfgrep | 1 | ||||
-rw-r--r-- | completion/pdfgrep | 75 | ||||
-rwxr-xr-x | configure | 111 | ||||
-rw-r--r-- | configure.ac | 33 | ||||
-rw-r--r-- | doc/Makefile.in | 2 | ||||
-rw-r--r-- | doc/pdfgrep.1 | 14 | ||||
-rw-r--r-- | doc/pdfgrep.txt | 4 | ||||
-rw-r--r-- | pdfgrep.cc | 103 |
15 files changed, 549 insertions, 63 deletions
@@ -11,3 +11,4 @@ Other people that have contributed code to the project: Tim Mooney Jascha Knack Thibault Marin + Florian Schmaus diff --git a/Makefile.in b/Makefile.in index 6f8720c..da46a52 100644 --- a/Makefile.in +++ b/Makefile.in @@ -153,6 +153,7 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BASH_COMPL_DIR = @BASH_COMPL_DIR@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ @@ -198,6 +199,7 @@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ +ZSH_COMPL_DIR = @ZSH_COMPL_DIR@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ @@ -1,33 +1,48 @@ -Release 1.3.1 [2014-08-10] +Version 1.3.2 [2015-02-20] +----------------------------- - - INCOMPATIBLE CHANGE: -r doesn't follow symlinks + - 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) + - 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) -Release 1.3.0 [2012-02-14] +Version 1.3.0 [2012-02-14] +----------------------------- - Experimental support for libunac (removing accents and ligatures before search) - - Recursive search [--recursive] (by Mahmut Gundes) + - 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) -Release 1.2 +Version 1.2 +----------- - - 2 small bugfixes ('-h' option and closing open files) + - 2 small bugfixes (+-h+ option and closing open files) - This is probably the last release that supports poppler < 0.14 -Release 1.1 +Version 1.1 +----------- - - Respect the GREP_COLORS environment variable + - 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 -Release 1.0 +Version 1.0 +----------- - First release @@ -1,7 +1,7 @@ * Overview Pdfgrep is a tool to search text in PDF files. It works -similar to `grep'. +similarly to `grep'. * Features @@ -40,6 +40,6 @@ https://gitorious.org/pdfgrep/pdfgrep/ * Contact To send patches, ask questions, report bugs or anything -else there is now a new mailing-list: +else there is the mailing-list: pdfgrep-users@lists.sourceforge.net @@ -329,6 +329,46 @@ AC_PREREQ([2.50])dnl am_aux_dir=`cd $ac_aux_dir && pwd` ]) +# AM_COND_IF -*- Autoconf -*- + +# Copyright (C) 2008, 2010 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 3 + +# _AM_COND_IF +# _AM_COND_ELSE +# _AM_COND_ENDIF +# -------------- +# These macros are only used for tracing. +m4_define([_AM_COND_IF]) +m4_define([_AM_COND_ELSE]) +m4_define([_AM_COND_ENDIF]) + + +# AM_COND_IF(COND, [IF-TRUE], [IF-FALSE]) +# --------------------------------------- +# If the shell condition COND is true, execute IF-TRUE, otherwise execute +# IF-FALSE. Allow automake to learn about conditional instantiating macros +# (the AC_CONFIG_FOOS). +AC_DEFUN([AM_COND_IF], +[m4_ifndef([_AM_COND_VALUE_$1], + [m4_fatal([$0: no such condition "$1"])])dnl +_AM_COND_IF([$1])dnl +if test -z "$$1_TRUE"; then : + m4_n([$2])[]dnl +m4_ifval([$3], +[_AM_COND_ELSE([$1])dnl +else + $3 +])dnl +_AM_COND_ENDIF([$1])dnl +fi[]dnl +]) + # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 diff --git a/completion/Makefile.am b/completion/Makefile.am index 7446f35..c3fc575 100644 --- a/completion/Makefile.am +++ b/completion/Makefile.am @@ -1,2 +1,19 @@ -noinst_DATA = _pdfgrep -EXTRA_DIST = $(noinst_DATA) +# zsh completion + +zshcompldir = $(ZSH_COMPL_DIR) + +if INSTALL_ZSH_COMPLETION +zshcompl_DATA = _pdfgrep +else +dist_zshcompl_DATA = _pdfgrep +endif + +# bash completion + +bashcompldir = $(BASH_COMPL_DIR) + +if INSTALL_BASH_COMPLETION +bashcompl_DATA = pdfgrep +else +dist_bashcompl_DATA = pdfgrep +endif diff --git a/completion/Makefile.in b/completion/Makefile.in index 9e09fee..136b28a 100644 --- a/completion/Makefile.in +++ b/completion/Makefile.in @@ -15,6 +15,8 @@ @SET_MAKE@ +# zsh completion + VPATH = @srcdir@ am__make_dryrun = \ { \ @@ -50,7 +52,9 @@ NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : subdir = completion -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +DIST_COMMON = $(am__dist_bashcompl_DATA_DIST) \ + $(am__dist_zshcompl_DATA_DIST) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ @@ -66,7 +70,40 @@ am__can_run_installinfo = \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac -DATA = $(noinst_DATA) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(bashcompldir)" \ + "$(DESTDIR)$(bashcompldir)" "$(DESTDIR)$(zshcompldir)" \ + "$(DESTDIR)$(zshcompldir)" +am__dist_bashcompl_DATA_DIST = pdfgrep +am__dist_zshcompl_DATA_DIST = _pdfgrep +DATA = $(bashcompl_DATA) $(dist_bashcompl_DATA) $(dist_zshcompl_DATA) \ + $(zshcompl_DATA) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ @@ -74,6 +111,7 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BASH_COMPL_DIR = @BASH_COMPL_DIR@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ @@ -119,6 +157,7 @@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ +ZSH_COMPL_DIR = @ZSH_COMPL_DIR@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ @@ -166,8 +205,14 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ unac_CFLAGS = @unac_CFLAGS@ unac_LIBS = @unac_LIBS@ -noinst_DATA = _pdfgrep -EXTRA_DIST = $(noinst_DATA) +zshcompldir = $(ZSH_COMPL_DIR) +@INSTALL_ZSH_COMPLETION_TRUE@zshcompl_DATA = _pdfgrep +@INSTALL_ZSH_COMPLETION_FALSE@dist_zshcompl_DATA = _pdfgrep + +# bash completion +bashcompldir = $(BASH_COMPL_DIR) +@INSTALL_BASH_COMPLETION_TRUE@bashcompl_DATA = pdfgrep +@INSTALL_BASH_COMPLETION_FALSE@dist_bashcompl_DATA = pdfgrep all: all-am .SUFFIXES: @@ -201,6 +246,90 @@ $(top_srcdir)/configure: $(am__configure_deps) $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): +install-bashcomplDATA: $(bashcompl_DATA) + @$(NORMAL_INSTALL) + @list='$(bashcompl_DATA)'; test -n "$(bashcompldir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bashcompldir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bashcompldir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(bashcompldir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(bashcompldir)" || exit $$?; \ + done + +uninstall-bashcomplDATA: + @$(NORMAL_UNINSTALL) + @list='$(bashcompl_DATA)'; test -n "$(bashcompldir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(bashcompldir)'; $(am__uninstall_files_from_dir) +install-dist_bashcomplDATA: $(dist_bashcompl_DATA) + @$(NORMAL_INSTALL) + @list='$(dist_bashcompl_DATA)'; test -n "$(bashcompldir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bashcompldir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bashcompldir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(bashcompldir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(bashcompldir)" || exit $$?; \ + done + +uninstall-dist_bashcomplDATA: + @$(NORMAL_UNINSTALL) + @list='$(dist_bashcompl_DATA)'; test -n "$(bashcompldir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(bashcompldir)'; $(am__uninstall_files_from_dir) +install-dist_zshcomplDATA: $(dist_zshcompl_DATA) + @$(NORMAL_INSTALL) + @list='$(dist_zshcompl_DATA)'; test -n "$(zshcompldir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(zshcompldir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(zshcompldir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(zshcompldir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(zshcompldir)" || exit $$?; \ + done + +uninstall-dist_zshcomplDATA: + @$(NORMAL_UNINSTALL) + @list='$(dist_zshcompl_DATA)'; test -n "$(zshcompldir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(zshcompldir)'; $(am__uninstall_files_from_dir) +install-zshcomplDATA: $(zshcompl_DATA) + @$(NORMAL_INSTALL) + @list='$(zshcompl_DATA)'; test -n "$(zshcompldir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(zshcompldir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(zshcompldir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(zshcompldir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(zshcompldir)" || exit $$?; \ + done + +uninstall-zshcomplDATA: + @$(NORMAL_UNINSTALL) + @list='$(zshcompl_DATA)'; test -n "$(zshcompldir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(zshcompldir)'; $(am__uninstall_files_from_dir) tags: TAGS TAGS: @@ -242,6 +371,9 @@ check-am: all-am check: check-am all-am: Makefile $(DATA) installdirs: + for dir in "$(DESTDIR)$(bashcompldir)" "$(DESTDIR)$(bashcompldir)" "$(DESTDIR)$(zshcompldir)" "$(DESTDIR)$(zshcompldir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done install: install-am install-exec: install-exec-am install-data: install-data-am @@ -292,7 +424,8 @@ info: info-am info-am: -install-data-am: +install-data-am: install-bashcomplDATA install-dist_bashcomplDATA \ + install-dist_zshcomplDATA install-zshcomplDATA install-dvi: install-dvi-am @@ -336,19 +469,24 @@ ps: ps-am ps-am: -uninstall-am: +uninstall-am: uninstall-bashcomplDATA uninstall-dist_bashcomplDATA \ + uninstall-dist_zshcomplDATA uninstall-zshcomplDATA .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic distclean \ distclean-generic distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ + install install-am install-bashcomplDATA install-data \ + install-data-am install-dist_bashcomplDATA \ + install-dist_zshcomplDATA install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + install-zshcomplDATA installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am + mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am \ + uninstall-bashcomplDATA uninstall-dist_bashcomplDATA \ + uninstall-dist_zshcomplDATA uninstall-zshcomplDATA # Tell versions [3.59,3.63) of GNU make to not export all variables. diff --git a/completion/_pdfgrep b/completion/_pdfgrep index ab0890b..d0542d5 100644 --- a/completion/_pdfgrep +++ b/completion/_pdfgrep @@ -40,6 +40,7 @@ _arguments -s -S \ "(-q --quiet)"{-q,--quiet}"[Suppress all normal output]" \ "(--password)--password=[Password to encrypt file]:Password:" \ "(-m --max-count)"{-m,--max-count=}"[Process at most count matches]:Count:" \ + "(--debug)"--debug"[Enable debug output]" \ "(--unac)--unac[Remove accents and ligatures]" \ ":pdf file:_files -g \"*.pdf\"" \ && return 0 diff --git a/completion/pdfgrep b/completion/pdfgrep new file mode 100644 index 0000000..3d0ae4f --- /dev/null +++ b/completion/pdfgrep @@ -0,0 +1,75 @@ +# Bash completion for pdfgrep +# +# Copyright (C) 2015 by Hans-Peter Deifel (hpdeifel@gmx.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. + +_pdfgrep() +{ + local cur prev opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts=(-n --page-number \ + -i --ignore-case \ + -H --with-filename \ + -h --no-filename \ + -c --count \ + -p --page-count \ + --color \ + -C --context \ + -r -R --recursive \ + --exclude \ + --include \ + --help \ + -V --version \ + -q --quiet \ + --password \ + -m --max-count \ + --debug \ + --unac \ + ) + + case "${prev}" in + --color) + COMPREPLY=( $(compgen -W "always never auto" -- ${cur}) ) + ;; + --context) + COMPREPLY=( $(compgen -W "line" -- ${cur}) ) + ;; + --exclude|--include|--password|-m|--max-count) + COMPREPLY=( ) + ;; + *) + case "${cur}" in + -*) + COMPREPLY=( $(compgen -W "${opts[*]}" -- ${cur}) ) + return 0 + ;; + *) + COMPREPLY=( $(compgen -f -X '!*.pdf' -- ${cur} ) ) + ;; + esac + esac + + return 0 +} + +complete -F _pdfgrep pdfgrep + +# Local Variables: +# mode: shell-script +# End: @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for pdfgrep 1.3.1. +# Generated by GNU Autoconf 2.69 for pdfgrep 1.3.2. # # Report bugs to <pdfgrep-users@lists.sourceforge.net>. # @@ -580,8 +580,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='pdfgrep' PACKAGE_TARNAME='pdfgrep' -PACKAGE_VERSION='1.3.1' -PACKAGE_STRING='pdfgrep 1.3.1' +PACKAGE_VERSION='1.3.2' +PACKAGE_STRING='pdfgrep 1.3.2' PACKAGE_BUGREPORT='pdfgrep-users@lists.sourceforge.net' PACKAGE_URL='' @@ -625,6 +625,12 @@ ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS HAVE_A2X +INSTALL_BASH_COMPLETION_FALSE +INSTALL_BASH_COMPLETION_TRUE +BASH_COMPL_DIR +INSTALL_ZSH_COMPLETION_FALSE +INSTALL_ZSH_COMPLETION_TRUE +ZSH_COMPL_DIR unac_LIBS unac_CFLAGS poppler_cpp_LIBS @@ -725,6 +731,8 @@ ac_user_opts=' enable_option_checking enable_dependency_tracking with_unac +with_zsh_completion +with_bash_completion ' ac_precious_vars='build_alias host_alias @@ -1285,7 +1293,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.3.1 to adapt to many kinds of systems. +\`configure' configures pdfgrep 1.3.2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1351,7 +1359,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of pdfgrep 1.3.1:";; + short | recursive ) echo "Configuration of pdfgrep 1.3.2:";; esac cat <<\_ACEOF @@ -1367,6 +1375,10 @@ Optional Packages: --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-unac enable experimental support for libunac + --with-zsh-completion=DIR + install zsh-completion file in directory DIR + --with-bash-completion=DIR + install bash-completion file in directory DIR Some influential environment variables: CXX C++ compiler command @@ -1457,7 +1469,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -pdfgrep configure 1.3.1 +pdfgrep configure 1.3.2 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1864,7 +1876,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.3.1, which was +It was created by pdfgrep $as_me 1.3.2, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2679,7 +2691,7 @@ fi # Define the identity of the package. PACKAGE='pdfgrep' - VERSION='1.3.1' + VERSION='1.3.2' cat >>confdefs.h <<_ACEOF @@ -4672,12 +4684,16 @@ fi $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 : + cat >>confdefs.h <<_ACEOF #define PDFGREP_GIT_HEAD "$GITHEAD" _ACEOF +fi + @@ -5001,6 +5017,73 @@ $as_echo "#define HAVE_UNAC 1" >>confdefs.h fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking zsh completion" >&5 +$as_echo_n "checking zsh completion... " >&6; } +ZSH_COMPL_DIR="${datadir}/zsh/site-functions" + +# Check whether --with-zsh-completion was given. +if test "${with_zsh_completion+set}" = set; then : + withval=$with_zsh_completion; case ${withval} in #( + "/"*) : + ZSH_COMPL_DIR=$withval ;; #( + no) : + ZSH_COMPL_DIR= ;; #( + *) : + ;; +esac +fi + + + if test "x$ZSH_COMPL_DIR" != "x"; then + INSTALL_ZSH_COMPLETION_TRUE= + INSTALL_ZSH_COMPLETION_FALSE='#' +else + INSTALL_ZSH_COMPLETION_TRUE='#' + INSTALL_ZSH_COMPLETION_FALSE= +fi + +if test -z "$INSTALL_ZSH_COMPLETION_TRUE"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ZSH_COMPL_DIR" >&5 +$as_echo "$ZSH_COMPL_DIR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking bash completion" >&5 +$as_echo_n "checking bash completion... " >&6; } +BASH_COMPL_DIR="${datadir}/bash-completion/completions" + +# Check whether --with-bash-completion was given. +if test "${with_bash_completion+set}" = set; then : + withval=$with_bash_completion; case ${withval} in #( + "/"*) : + BASH_COMPL_DIR=$withval ;; #( + no) : + BASH_COMPL_DIR= ;; #( + *) : + ;; +esac +fi + + + if test "x$BASH_COMPL_DIR" != "x"; then + INSTALL_BASH_COMPLETION_TRUE= + INSTALL_BASH_COMPLETION_FALSE='#' +else + INSTALL_BASH_COMPLETION_TRUE='#' + INSTALL_BASH_COMPLETION_FALSE= +fi + +if test -z "$INSTALL_BASH_COMPLETION_TRUE"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BASH_COMPL_DIR" >&5 +$as_echo "$BASH_COMPL_DIR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + # Extract the first word of "a2x", so it can be a program name with args. set dummy a2x; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 @@ -5171,6 +5254,14 @@ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${INSTALL_ZSH_COMPLETION_TRUE}" && test -z "${INSTALL_ZSH_COMPLETION_FALSE}"; then + as_fn_error $? "conditional \"INSTALL_ZSH_COMPLETION\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${INSTALL_BASH_COMPLETION_TRUE}" && test -z "${INSTALL_BASH_COMPLETION_FALSE}"; then + as_fn_error $? "conditional \"INSTALL_BASH_COMPLETION\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 @@ -5568,7 +5659,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.3.1, which was +This file was extended by pdfgrep $as_me 1.3.2, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -5634,7 +5725,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.3.1 +pdfgrep config.status 1.3.2 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index bafcb61..0cd6d03 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([pdfgrep], [1.3.1], [pdfgrep-users@lists.sourceforge.net]) +AC_INIT([pdfgrep], [1.3.2], [pdfgrep-users@lists.sourceforge.net]) AM_INIT_AUTOMAKE([foreign]) AC_CONFIG_HEADER([config.h]) @@ -26,7 +26,9 @@ else 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 Poppler checking @@ -46,6 +48,35 @@ AS_IF([test "x$with_unac" = "xyes"], [ AC_DEFINE([HAVE_UNAC], [1], [Define to 1 if you have libunac _and_ want to use it]) ]) +AC_MSG_CHECKING([zsh completion]) +AS_VAR_SET([ZSH_COMPL_DIR], ["${datadir}/zsh/site-functions"]) +AC_ARG_WITH([zsh-completion], + [AS_HELP_STRING([--with-zsh-completion=DIR], + [install zsh-completion file in directory DIR])], + [AS_CASE([${withval}], + ["/"*], [AS_VAR_COPY([ZSH_COMPL_DIR], [withval])], + [no], [AS_VAR_SET([ZSH_COMPL_DIR], [])])]) +AC_SUBST(ZSH_COMPL_DIR) +AM_CONDITIONAL([INSTALL_ZSH_COMPLETION], [test "x$ZSH_COMPL_DIR" != "x"]) +AM_COND_IF([INSTALL_ZSH_COMPLETION], + [AC_MSG_RESULT($ZSH_COMPL_DIR)], + [AC_MSG_RESULT(no)]) + +AC_MSG_CHECKING([bash completion]) +AS_VAR_SET([BASH_COMPL_DIR], ["${datadir}/bash-completion/completions"]) +AC_ARG_WITH([bash-completion], + [AS_HELP_STRING([--with-bash-completion=DIR], + [install bash-completion file in directory DIR])], + [AS_CASE([${withval}], + ["/"*], [AS_VAR_COPY([BASH_COMPL_DIR], [withval])], + [no], [AS_VAR_SET([BASH_COMPL_DIR], [])])]) +AC_SUBST(BASH_COMPL_DIR) +AM_CONDITIONAL([INSTALL_BASH_COMPLETION], [test "x$BASH_COMPL_DIR" != "x"]) +AM_COND_IF([INSTALL_BASH_COMPLETION], + [AC_MSG_RESULT($BASH_COMPL_DIR)], + [AC_MSG_RESULT(no)]) + + AC_CHECK_PROG(HAVE_A2X, [a2x], [yes], [no]) AC_CONFIG_FILES([Makefile completion/Makefile doc/Makefile]) diff --git a/doc/Makefile.in b/doc/Makefile.in index 12c95df..0228f87 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -104,6 +104,7 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BASH_COMPL_DIR = @BASH_COMPL_DIR@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ @@ -149,6 +150,7 @@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ +ZSH_COMPL_DIR = @ZSH_COMPL_DIR@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ diff --git a/doc/pdfgrep.1 b/doc/pdfgrep.1 index 190306d..8bfc706 100644 --- a/doc/pdfgrep.1 +++ b/doc/pdfgrep.1 @@ -2,12 +2,12 @@ .\" Title: pdfgrep .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets v1.78.0 <http://docbook.sf.net/> -.\" Date: 08/10/2014 +.\" Date: 02/20/2015 .\" Manual: Pdfgrep Manual -.\" Source: Pdfgrep 1.3.1 +.\" Source: Pdfgrep 1.3.2 .\" Language: English .\" -.TH "PDFGREP" "1" "08/10/2014" "Pdfgrep 1\&.3\&.1" "Pdfgrep Manual" +.TH "PDFGREP" "1" "02/20/2015" "Pdfgrep 1\&.3\&.2" "Pdfgrep Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -155,6 +155,14 @@ matching lines\&. When the \-c or \-\-count option is also used, pdfgrep does no \fINUM\fR\&. .RE .PP +\fB\-\-debug\fR +.RS 4 +Enable debug output\&. +\fBNote\fR: Due to limitations of poppler before version 0\&.30\&.0, some debug output is also printed without +\fB\-\-debug\fR +when using such a poppler version\&. +.RE +.PP \fB\-\-unac\fR .RS 4 Remove accents and ligatures from both the search pattern and the PDF documents\&. This is useful if you want to search for a word containing "ae", but the PDF uses the single character "æ" instead\&. See diff --git a/doc/pdfgrep.txt b/doc/pdfgrep.txt index 7d2264b..ccfcb9c 100644 --- a/doc/pdfgrep.txt +++ b/doc/pdfgrep.txt @@ -82,6 +82,10 @@ OPTIONS lines. When the -c or --count option is also used, pdfgrep does not output a count greater than 'NUM'. +*--debug* :: Enable debug output. *Note*: Due to limitations of + poppler before version 0.30.0, some debug output is also printed + without *--debug* when using such a poppler version. + *--unac* :: Remove accents and ligatures from both the search pattern and the PDF documents. This is useful if you want to search for a word containing "ae", but the PDF uses the single character "æ" @@ -34,9 +34,12 @@ #include <errno.h> #include <dirent.h> #include <sys/stat.h> +#include <limits.h> #include <cpp/poppler-document.h> #include <cpp/poppler-page.h> +#include <cpp/poppler-version.h> + #ifdef HAVE_UNAC #include <unac.h> @@ -70,6 +73,7 @@ int pagecount = 0; int quiet = 0; char *password = (char*)""; int max_count = 0; +int debug = 0; #ifdef HAVE_UNAC int use_unac = 0; @@ -87,6 +91,7 @@ enum { EXCLUDE_OPTION, INCLUDE_OPTION, PASSWORD, + DEBUG_OPTION, #ifdef HAVE_UNAC UNAC_OPTION, #endif @@ -111,6 +116,7 @@ struct option long_options[] = {"quiet", 0, 0, 'q'}, {"password", 1, 0, PASSWORD}, {"max-count", 1, 0, 'm'}, + {"debug", 0, 0, DEBUG_OPTION}, #ifdef HAVE_UNAC {"unac", 0, 0, UNAC_OPTION}, #endif @@ -238,8 +244,8 @@ int search_in_document(poppler::document *doc, const std::string &filename, rege simple_unac_free(unac_str); #endif if(!quiet && pagecount && count_matches > page_matches) { - print_line_prefix(&outconf, filename.c_str(), -1); - printf("%d:%d\n", i, count_matches-page_matches); + print_line_prefix(&outconf, filename.c_str(), i); + printf("%d\n", count_matches-page_matches); page_matches = count_matches; } } @@ -393,13 +399,17 @@ void print_help(char *self) void print_version() { - printf("This is %s version %s\n", PACKAGE, VERSION); - if (strcmp(PDFGREP_GIT_HEAD, "") != 0) { - printf("Built from git-commit %s\n", PDFGREP_GIT_HEAD); - } + printf("This is %s version %s.\n", PACKAGE, VERSION); + printf("\nUsing poppler version %s\n", poppler::version_string().c_str()); +#ifdef HAVE_UNAC + printf("\nUsing unac version %s\n", unac_version()); +#endif +#ifdef PDFGREP_GIT_HEAD + printf("Built from git-commit %s\n", PDFGREP_GIT_HEAD); +#endif } -int is_dir(const std::string filename) +int is_dir(const std::string &filename) { struct stat st; @@ -409,7 +419,7 @@ int is_dir(const std::string filename) return 0; } -int do_search_in_document(const std::string path, const std::string filename, +int do_search_in_document(const std::string &path, const std::string &filename, regex_t *ptrRegex, bool check_excludes = true) { if (check_excludes && @@ -433,7 +443,7 @@ int do_search_in_document(const std::string path, const std::string filename, return 0; } -int do_search_in_directory(const std::string filename, regex_t *ptrRegex) +int do_search_in_directory(const std::string &filename, regex_t *ptrRegex) { DIR *ptrDir = NULL; struct dirent *ptrDirent = NULL; @@ -485,6 +495,29 @@ int do_search_in_directory(const std::string filename, regex_t *ptrRegex) return 0; } +bool parse_int(const char *str, int *i) +{ + char *endptr; + errno = 0; + unsigned long int d = strtoul(str, &endptr, 10); + if (errno != 0 || (long)d > INT_MAX || (long)d < INT_MIN + || *endptr != '\0') { + return false; + } + + *i = d; + return true; +} + +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 29 +void handle_poppler_errors(const std::string &msg, void *) +{ + if (debug) { + fprintf(stderr, "pdfgrep: %s\n", msg.c_str()); + } +} +#endif + int main(int argc, char** argv) { regex_t regex; @@ -536,12 +569,17 @@ int main(int argc, char** argv) } break; case 'C': - if (optarg) { - if (!strcmp(optarg, "line")) { - context = -1; - } else { - context = atoi(optarg); - } + if (!strcmp(optarg, "line")) { + context = -1; + break; + } + if (!parse_int(optarg, &context)) { + fprintf(stderr, "pdfgrep: Could not parse number: %s.\n", + optarg); + exit(2); + } else if (context <= 0) { + fprintf(stderr, "pdfgrep: --context must be positive.\n"); + exit(2); } break; case EXCLUDE_OPTION: @@ -552,8 +590,9 @@ int main(int argc, char** argv) break; case 'p': pagecount = 1; + outconf.pagenum = 1; break; - + case 'q': quiet = 1; break; @@ -563,17 +602,30 @@ int main(int argc, char** argv) break; case 'm': - if (optarg) { - max_count = atoi(optarg); + if (!parse_int(optarg, &max_count)) { + fprintf(stderr, "pdfgrep: Could not parse number: %s.\n", + optarg); + exit(2); + } else if (max_count <= 0) { + fprintf(stderr, "pdfgrep: --max-count must be positive.\n"); + exit(2); } break; + case DEBUG_OPTION: + debug = 1; + break; #ifdef HAVE_UNAC case UNAC_OPTION: use_unac = 1; break; #endif - case '?': - /* TODO: do something here */ + + /* In these two cases, getopt already prints an + * error message + */ + case '?': // unknown option + case ':': // missing argument + exit(2); break; default: break; @@ -598,6 +650,11 @@ int main(int argc, char** argv) exit(2); } +#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 29 + // set poppler error output function + poppler::set_debug_error_function(handle_poppler_errors, NULL); +#endif + bool color_tty = isatty(STDOUT_FILENO) && getenv("TERM") && strcmp(getenv("TERM"), "dumb"); if (outconf.color == 1 && !color_tty) { @@ -613,8 +670,12 @@ int main(int argc, char** argv) outconf.filename = 1; } - if (isatty(STDOUT_FILENO)) + if (isatty(STDOUT_FILENO)) { line_width = get_line_width(); + } else if (context == -2) { + // on non-terminals, always print the whole line + context = -1; + } if (excludes_empty(includes)) exclude_add(includes, "*.pdf"); |