diff -Nru unpaper-0.3/aclocal.m4 unpaper-0.4.2/aclocal.m4 --- unpaper-0.3/aclocal.m4 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/aclocal.m4 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,968 @@ +# generated automatically by aclocal 1.12.1 -*- Autoconf -*- + +# Copyright (C) 1996-2012 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. + +# This program 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. + +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, +[m4_warning([this file was generated for autoconf 2.69. +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'.])]) + +# Copyright (C) 2002-2012 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 8 + +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +# (This private macro should not be called outside this file.) +AC_DEFUN([AM_AUTOMAKE_VERSION], +[am__api_version='1.12' +dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to +dnl require some minimum version. Point them to the right macro. +m4_if([$1], [1.12.1], [], + [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl +]) + +# _AM_AUTOCONF_VERSION(VERSION) +# ----------------------------- +# aclocal traces this macro to find the Autoconf version. +# This is a private macro too. Using m4_define simplifies +# the logic in aclocal, which can simply ignore this definition. +m4_define([_AM_AUTOCONF_VERSION], []) + +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. +# This function is AC_REQUIREd by AM_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], +[AM_AUTOMAKE_VERSION([1.12.1])dnl +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) + +# AM_AUX_DIR_EXPAND -*- Autoconf -*- + +# Copyright (C) 2001-2012 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 2 + +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to +# '$srcdir', '$srcdir/..', or '$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is '.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. + +AC_DEFUN([AM_AUX_DIR_EXPAND], +[dnl Rely on autoconf to set up CDPATH properly. +AC_PREREQ([2.50])dnl +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` +]) + +# AM_CONDITIONAL -*- Autoconf -*- + +# Copyright (C) 1997-2012 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 10 + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ([2.52])dnl + m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE])dnl +AC_SUBST([$1_FALSE])dnl +_AM_SUBST_NOTMAKE([$1_TRUE])dnl +_AM_SUBST_NOTMAKE([$1_FALSE])dnl +m4_define([_AM_COND_VALUE_$1], [$2])dnl +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([[conditional "$1" was never defined. +Usually this means the macro was only invoked conditionally.]]) +fi])]) + +# Copyright (C) 1999-2012 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 17 + +# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + +# _AM_DEPENDENCIES(NAME) +# ---------------------- +# See how the compiler implements dependency checking. +# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". +# We try a few techniques and use that to set a single cache variable. +# +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular +# dependency, and given that the user is not expected to run this macro, +# just rely on AC_PROG_CC. +AC_DEFUN([_AM_DEPENDENCIES], +[AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl +AC_REQUIRE([AM_MAKE_INCLUDE])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl + +m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], + [$1], [CXX], [depcc="$CXX" am_compiler_list=], + [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], + [$1], [UPC], [depcc="$UPC" am_compiler_list=], + [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) + +AC_CACHE_CHECK([dependency style of $depcc], + [am_cv_$1_dependencies_compiler_type], +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named 'D' -- because '-MD' means "put the output + # in D". + rm -rf conftest.dir + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_$1_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` + fi + am__universal=false + m4_case([$1], [CC], + [case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac], + [CXX], + [case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac]) + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with + # Solaris 10 /bin/sh. + echo '/* dummy */' > sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with '-c' and '-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle '-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs. + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # After this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested. + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvc7 | msvc7msys | msvisualcpp | msvcmsys) + # This compiler won't grok '-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_$1_dependencies_compiler_type=none +fi +]) +AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) +AM_CONDITIONAL([am__fastdep$1], [ + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) +]) + + +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES. +AC_DEFUN([AM_SET_DEPDIR], +[AC_REQUIRE([AM_SET_LEADING_DOT])dnl +AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl +]) + + +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE([dependency-tracking], [dnl +AS_HELP_STRING( + [--enable-dependency-tracking], + [do not reject slow dependency extractors]) +AS_HELP_STRING( + [--disable-dependency-tracking], + [speeds up one-time build])]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' + am__nodep='_no' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +AC_SUBST([AMDEPBACKSLASH])dnl +_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl +AC_SUBST([am__nodep])dnl +_AM_SUBST_NOTMAKE([am__nodep])dnl +]) + +# Generate code to set up dependency tracking. -*- Autoconf -*- + +# Copyright (C) 1999-2012 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 6 + +# _AM_OUTPUT_DEPENDENCY_COMMANDS +# ------------------------------ +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], +[{ + # Autoconf 2.62 quotes --file arguments for eval, but not when files + # are listed without --file. Let's play safe and only enable the eval + # if we detect the quoting. + case $CONFIG_FILES in + *\'*) eval set x "$CONFIG_FILES" ;; + *) set x $CONFIG_FILES ;; + esac + shift + for mf + do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named 'Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`AS_DIRNAME("$mf")` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running 'make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`AS_DIRNAME(["$file"])` + AS_MKDIR_P([$dirpart/$fdir]) + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done + done +} +])# _AM_OUTPUT_DEPENDENCY_COMMANDS + + +# AM_OUTPUT_DEPENDENCY_COMMANDS +# ----------------------------- +# This macro should only be invoked once -- use via AC_REQUIRE. +# +# This code is only required when automatic dependency tracking +# is enabled. FIXME. This creates each '.P' file that we will +# need in order to bootstrap the dependency handling code. +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], +[AC_CONFIG_COMMANDS([depfiles], + [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], + [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) +]) + +# Do all the work for Automake. -*- Autoconf -*- + +# Copyright (C) 1996-2012 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 19 + +# This macro actually does too much. Some checks are only needed if +# your package does certain things. But this isn't really a big deal. + +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) +# AM_INIT_AUTOMAKE([OPTIONS]) +# ----------------------------------------------- +# The call with PACKAGE and VERSION arguments is the old style +# call (pre autoconf-2.50), which is being phased out. PACKAGE +# and VERSION should now be passed to AC_INIT and removed from +# the call to AM_INIT_AUTOMAKE. +# We support both call styles for the transition. After +# the next Automake release, Autoconf can make the AC_INIT +# arguments mandatory, and then we can depend on a new Autoconf +# release and drop the old call support. +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_PREREQ([2.62])dnl +dnl Autoconf wants to disallow AM_ names. We explicitly allow +dnl the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL])dnl +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi +AC_SUBST([CYGPATH_W]) + +# Define the identity of the package. +dnl Distinguish between old-style and new-style calls. +m4_ifval([$2], +[AC_DIAGNOSE([obsolete], +[$0: two- and three-arguments forms are deprecated. For more info, see: +http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_INIT_AUTOMAKE-invocation]) +m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl + AC_SUBST([PACKAGE], [$1])dnl + AC_SUBST([VERSION], [$2])], +[_AM_SET_OPTIONS([$1])dnl +dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. +m4_if( + m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), + [ok:ok],, + [m4_fatal([AC_INIT should be called with package and version arguments])])dnl + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl + +_AM_IF_OPTION([no-define],, +[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) + AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) +AM_MISSING_PROG([AUTOCONF], [autoconf]) +AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) +AM_MISSING_PROG([AUTOHEADER], [autoheader]) +AM_MISSING_PROG([MAKEINFO], [makeinfo]) +AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl +AC_REQUIRE([AC_PROG_MKDIR_P])dnl +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_SET_LEADING_DOT])dnl +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], + [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], + [_AM_PROG_TAR([v7])])]) +_AM_IF_OPTION([no-dependencies],, +[AC_PROVIDE_IFELSE([AC_PROG_CC], + [_AM_DEPENDENCIES([CC])], + [m4_define([AC_PROG_CC], + m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES([CXX])], + [m4_define([AC_PROG_CXX], + m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJC], + [_AM_DEPENDENCIES([OBJC])], + [m4_define([AC_PROG_OBJC], + m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl +dnl Support for Objective C++ was only introduced in Autoconf 2.65, +dnl but we still cater to Autoconf 2.62. +m4_ifdef([AC_PROG_OBJCXX], +[AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], + [_AM_DEPENDENCIES([OBJCXX])], + [m4_define([AC_PROG_OBJCXX], + m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])])dnl +]) +_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl +dnl The 'parallel-tests' driver may need to know about EXEEXT, so add the +dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro +dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. +AC_CONFIG_COMMANDS_PRE(dnl +[m4_provide_if([_AM_COMPILER_EXEEXT], + [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl +]) + +dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not +dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further +dnl mangled by Autoconf and run in a shell conditional statement. +m4_define([_AC_COMPILER_EXEEXT], +m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) + + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. The stamp files are numbered to have different names. + +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the +# loop where config.status creates the headers, so we can generate +# our stamp files there. +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], +[# Compute $1's index in $config_headers. +_am_arg=$1 +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) + +# Copyright (C) 2001-2012 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 8 + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +if test x"${install_sh}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; + *) + install_sh="\${SHELL} $am_aux_dir/install-sh" + esac +fi +AC_SUBST([install_sh])]) + +# Copyright (C) 2003-2012 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 2 + +# Check whether the underlying file-system supports filenames +# with a leading dot. For instance MS-DOS doesn't. +AC_DEFUN([AM_SET_LEADING_DOT], +[rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null +AC_SUBST([am__leading_dot])]) + +# Check to see how 'make' treats includes. -*- Autoconf -*- + +# Copyright (C) 2001-2012 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 5 + +# AM_MAKE_INCLUDE() +# ----------------- +# Check to see how make treats includes. +AC_DEFUN([AM_MAKE_INCLUDE], +[am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo this is the am__doit target +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +AC_MSG_CHECKING([for style of include used by $am_make]) +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# Ignore all kinds of additional output from 'make'. +case `$am_make -s -f confmf 2> /dev/null` in #( +*the\ am__doit\ target*) + am__include=include + am__quote= + _am_result=GNU + ;; +esac +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + case `$am_make -s -f confmf 2> /dev/null` in #( + *the\ am__doit\ target*) + am__include=.include + am__quote="\"" + _am_result=BSD + ;; + esac +fi +AC_SUBST([am__include]) +AC_SUBST([am__quote]) +AC_MSG_RESULT([$_am_result]) +rm -f confinc confmf +]) + +# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- + +# Copyright (C) 1997-2012 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 7 + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([missing])dnl +if test x"${MISSING+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; + *) + MISSING="\${SHELL} $am_aux_dir/missing" ;; + esac +fi +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + AC_MSG_WARN(['missing' script is too old or missing]) +fi +]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001-2012 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 6 + +# _AM_MANGLE_OPTION(NAME) +# ----------------------- +AC_DEFUN([_AM_MANGLE_OPTION], +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) + +# _AM_SET_OPTION(NAME) +# -------------------- +# Set option NAME. Presently that only means defining a flag for this option. +AC_DEFUN([_AM_SET_OPTION], +[m4_define(_AM_MANGLE_OPTION([$1]), [1])]) + +# _AM_SET_OPTIONS(OPTIONS) +# ------------------------ +# OPTIONS is a space-separated list of Automake options. +AC_DEFUN([_AM_SET_OPTIONS], +[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) + +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) +# ------------------------------------------- +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +AC_DEFUN([_AM_IF_OPTION], +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +# Check to make sure that the build environment is sane. -*- Autoconf -*- + +# Copyright (C) 1996-2012 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 9 + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Reject unsafe characters in $srcdir or the absolute working directory +# name. Accept space and tab only in the latter. +am_lf=' +' +case `pwd` in + *[[\\\"\#\$\&\'\`$am_lf]]*) + AC_MSG_ERROR([unsafe absolute working directory name]);; +esac +case $srcdir in + *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) + AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; +esac + +# Do 'set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + am_has_slept=no + for am_try in 1 2; do + echo "timestamp, slept: $am_has_slept" > conftest.file + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken + alias in your environment]) + fi + if test "$[2]" = conftest.file || test $am_try -eq 2; then + break + fi + # Just in case. + sleep 1 + am_has_slept=yes + done + test "$[2]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT([yes]) +# If we didn't sleep, we still need to ensure time stamps of config.status and +# generated files are strictly newer. +am_sleep_pid= +if grep 'slept: no' conftest.file >/dev/null 2>&1; then + ( sleep 1 ) & + am_sleep_pid=$! +fi +AC_CONFIG_COMMANDS_PRE( + [AC_MSG_CHECKING([that generated files are newer than configure]) + if test -n "$am_sleep_pid"; then + # Hide warnings about reused PIDs. + wait $am_sleep_pid 2>/dev/null + fi + AC_MSG_RESULT([done])]) +rm -f conftest.file +]) + +# Copyright (C) 2001-2012 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 2 + +# AM_PROG_INSTALL_STRIP +# --------------------- +# One issue with vendor 'install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in "make install-strip", and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using 'strip' when the user +# run "make install-strip". However 'strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the 'STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# Copyright (C) 2006-2012 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_SUBST_NOTMAKE(VARIABLE) +# --------------------------- +# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. +# This macro is traced by Automake. +AC_DEFUN([_AM_SUBST_NOTMAKE]) + +# AM_SUBST_NOTMAKE(VARIABLE) +# -------------------------- +# Public sister of _AM_SUBST_NOTMAKE. +AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) + +# Check how to create a tarball. -*- Autoconf -*- + +# Copyright (C) 2004-2012 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_PROG_TAR(FORMAT) +# -------------------- +# Check how to create a tarball in format FORMAT. +# FORMAT should be one of 'v7', 'ustar', or 'pax'. +# +# Substitute a variable $(am__tar) that is a command +# writing to stdout a FORMAT-tarball containing the directory +# $tardir. +# tardir=directory && $(am__tar) > result.tar +# +# Substitute a variable $(am__untar) that extract such +# a tarball read from stdin. +# $(am__untar) < result.tar +AC_DEFUN([_AM_PROG_TAR], +[# Always define AMTAR for backward compatibility. Yes, it's still used +# in the wild :-( We should find a proper way to deprecate it ... +AC_SUBST([AMTAR], ['$${TAR-tar}']) +m4_if([$1], [v7], + [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], + [m4_case([$1], [ustar],, [pax],, + [m4_fatal([Unknown tar format])]) +AC_MSG_CHECKING([how to create a $1 tar archive]) +# Loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' +_am_tools=${am_cv_prog_tar_$1-$_am_tools} +# Do not fold the above two line into one, because Tru64 sh and +# Solaris sh will not grok spaces in the rhs of '-'. +for _am_tool in $_am_tools +do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; + do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi +done +rm -rf conftest.dir + +AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) +AC_MSG_RESULT([$am_cv_prog_tar_$1])]) +AC_SUBST([am__tar]) +AC_SUBST([am__untar]) +]) # _AM_PROG_TAR + diff -Nru unpaper-0.3/AUTHORS unpaper-0.4.2/AUTHORS --- unpaper-0.3/AUTHORS 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/AUTHORS 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,5 @@ +Jens Gulden 2005-2009 +Original author and maintainer + +Diego Elio Pettenò 2011- +Build system cleanup and code improvements diff -Nru unpaper-0.3/CHANGELOG unpaper-0.4.2/CHANGELOG --- unpaper-0.3/CHANGELOG 2007-12-31 00:10:05.000000000 +0000 +++ unpaper-0.4.2/CHANGELOG 1970-01-01 00:00:00.000000000 +0000 @@ -1,123 +0,0 @@ -Release 0.3, 2007-12-31: -- Moved history-information to CHANGELOG-file. -- Two distribution archives become part of the release, one source-only - variant, and one binary-distribution for i386/Linux. Archive - unpaper-bin-0.3.tar.gz contains everything in unpaper-0.3.tar.gz, plus a - binary executable file in folder bin/. -- The final distribution packages are now created with a standard-tar via - shell execution. Older versions were tarred and gzipped by ANT 1.6.5's tar- - task, which had shown incompatibities on some systems. -- Included a simple makefile make.sh. It runs with minimum requirements to the - compiler, while being configurable for particular optimizations via $CFLAGS. -- Common style distribution package naming and content-layout, following the - conventional patterns 'unpaper-0.x.tar.gz' for the archive file, which - contains a root folder 'unpaper-0.x' and files 'unpaper-0.x/*' (request/bug - #10793). -- Added --sheet-background option. -- Added --pre-shift and --post-shift options. -- Removed modes 'single-rotated' and 'double-rotated' for parameter --layout. - (The documentation was ambiguous and the functionaity can better be achieved - using --pre-rotate in combination with --layout single or --layout double.) - The default layout mode is 'single' now, the old behaviour, when no --layout - option was specified, can be achieved using --layout none. -- Corrected some language flaws in the docmentation. Thanks to Martin Collins. -- Renamed Readme.txt and License.txt to more common README and LICENSE. -- Fixed bug #11294: leading zeros in width/height values of pnm-files no longer - cause problems. -- Fixed bug #9495: resizing/stretching of color-images now works. -- Fixed bug #7882: --pre-mirror h,v now correct when vertical resolution is odd - -Release 0.2, 2006-05-09: -- Version number fallback to 0.2 (instead of counting up to 1.2). This better - reflects the current development status and appears more suitable in an - open-source context. -- User documentation with several explaining diagrams added, see file - 'doc/index.html'. -- Color support added. Files of type PPM can be read, processed and written - now. By default, unpaper uses the same image format for the output file as - has been read from an input file, i.e. if your input is PPM, the output will - be PPM automatically, if the input is PGM, the output will be PGM etc. Use - parameter --type pbm|pgm|ppm to force an output file format independently - from the input file format. -- Better image rotation implementation. Auto-rotation of pages is now done - much faster. -- The --cache option became obsolete (due to new image rotation - implementation). -- The compiler-switch -DNOSINCOS became obsolete (due to new image rotation - implementation). It is no longer needed for compilation on some platforms. -- Changed to gcc version 4.1 for creating the Linux binary included in the - distribution archive. gcc 4.1's executable appears to be about 20% faster - than the one created with gcc 3.3.6. -- Added '-fomit-frame-pointer' and '-ftree-vectorize' to compiler options. - (Thanks to Olaf Marzocchi for the hint about -ftree-vectorize.) -- Fix: the first pixel of an image is now correctly read (was read wrong in - previous versions). -- Minor fixes. - -Release 1.1, 2005-08-27: -- Single-page input sheets can now be joined to make 2-page output sheets. - See options --input-pages [1|2] and --output-pages [1|2]. -- Multiple input and output filename patterns can now be specified using the - options --input-file-sequence and --output-file-sequence. -- Blank pages or sheets can be inserted into the sequence of input sheets - using --insert-blank and/or --replace-blanks, -- Zooming and stretching are now supported, see --stretch, --zoom and - --post-stretch, --post-zoom. -- The sheet size can be set while keeping the content's aspect ratio (and - centering it with best-fitting on the sheet) using --size and --post-size. - For changing the sheet size without performing any stretching/zooming of - content use --sheet-size. -- Faster rotation when deskewing images. The rotating algorithm has been - optimized to run up to 4 times faster than before. Additional speedup - may be achieved by caching intermediate results of trigonometric calculations - when processing multiple page. This caching uses a lot of memory, it - can be enabled using the --cache switch. -- Rotation detection can now be configured to start at individual edges - of the area to process. The parameter --deskew-scan-direction no longer - takes v[ertical],h[orizontal] as values, but now l[eft],t[op],r[ight], - b[ottom]. The default is 'l,r', which matches the previous version's - default 'horizontal'. -- The behaviour of the 'double' template, used with the --layout parameter - by specifying "--layout double", has been changed slightly. The input - images are no longer assumed to be rotated by 90 degrees, as they would - be when scanned from paper with a usual ADF-scanner. - That means, "--layout double" no longer implies "--pre-rotate 90" and - "--post-rotate 90". To get the layout-template behaving as in earlier - versions, use "--layout double-rotated", this behaves like the old - "--layout double". -- --border-align --border-margin allow to align page content heading towards - one edge, but keeping a specified distance margin. -- Using the new parameter --blackfilter-scan-exclude [l,t,r,b], areas can - be specified on which the blackfilter will not work. This is useful to - exclude the blackfilter from working on inner page content, e.g. to - protect images with larger dark parts from deletion. - Note that the --layout option may preset some blackfilter-scan-exclude - masks. -- The speed of the noisefilter has been optimized a bit. -- The default --mask-scan-step value has been changed from 10 to 5, which - should sometimes lead to better mask-area detection. -- The default --deskew-scan-depth value has been changed from 0.66 to 0.5, - should sometimes lead to better rotation detection. -- The default --black-treshold value has been changed from 0.5 to 0.33, - which should give a better looking, more saturated result when converting - grayscale images to black-and-white mode. -- Existing output files will no longer be overwritten by default. If an - output file to be written already exists, the program terminates with an - error instead. Overwriting can be allowed using the --overwrite switch. -- Fix: Setting the parameter --pre-rotate or --post-rotate to 0 will no - longer issue a useless warning message. -- Tested on MacOS X, additional compilation instructions for MacOS have been - added to the documentation. -- Tested on SPARC Solaris. -- Compiler switch -DNOSINCOS disables use of the sincos() function, which - preserves compatibility with math libraries that do not provide this - function. - -Release 1.0.1, 2005-03-14: -- Syntax cleanups, better ANSI-C compatibility to solve some compiler issues. - Using the -pedantic compiler switch, only warnings with intended origin are - still issued. -- Minor changes to the usage-info. - -Release 1.0, 2005-03-01: -- Initial release. diff -Nru unpaper-0.3/configure unpaper-0.4.2/configure --- unpaper-0.3/configure 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/configure 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,5846 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.69 for unpaper 0.4.2. +# +# +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. +# +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, +$0: including any error possibly output before this +$0: message. Then install a modern shell, or manually run +$0: the script under such a shell if you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +test -n "$DJDIR" || exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME='unpaper' +PACKAGE_TARNAME='unpaper' +PACKAGE_VERSION='0.4.2' +PACKAGE_STRING='unpaper 0.4.2' +PACKAGE_BUGREPORT='' +PACKAGE_URL='' + +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='am__EXEEXT_FALSE +am__EXEEXT_TRUE +LTLIBOBJS +LIBOBJS +XSLTPROC +PNMTOPNG +PNGTOPNM +EGREP +GREP +CPP +am__fastdepCC_FALSE +am__fastdepCC_TRUE +CCDEPMODE +am__nodep +AMDEPBACKSLASH +AMDEP_FALSE +AMDEP_TRUE +am__quote +am__include +DEPDIR +am__untar +am__tar +AMTAR +am__leading_dot +SET_MAKE +AWK +INSTALL_STRIP_PROGRAM +STRIP +install_sh +MAKEINFO +AUTOHEADER +AUTOMAKE +AUTOCONF +ACLOCAL +VERSION +PACKAGE +CYGPATH_W +am__isrc +INSTALL_DATA +INSTALL_SCRIPT +INSTALL_PROGRAM +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +MKDIR_P +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +enable_dependency_tracking +' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP +XSLTPROC' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error $? "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error $? "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error $? "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +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 unpaper 0.4.2 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking ...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/unpaper] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +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 +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of unpaper 0.4.2:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-option-checking ignore unrecognized --enable/--with options + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-dependency-tracking + do not reject slow dependency extractors + --disable-dependency-tracking + speeds up one-time build + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor + XSLTPROC A libxslt-compatible XSLT processor command + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to the package provider. +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +unpaper configure 0.4.2 +generated by GNU Autoconf 2.69 + +Copyright (C) 2012 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if eval \${$3+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_mongrel + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_compile + +# ac_fn_c_check_type LINENO TYPE VAR INCLUDES +# ------------------------------------------- +# Tests whether TYPE exists after having included INCLUDES, setting cache +# variable VAR accordingly. +ac_fn_c_check_type () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof ($2)) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof (($2))) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + eval "$3=yes" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_type + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link +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 unpaper $as_me 0.4.2, which was +generated by GNU Autoconf 2.69. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +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 || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + $as_echo "## ---------------- ## +## Cache variables. ## +## ---------------- ##" + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + $as_echo "## ----------------- ## +## Output variables. ## +## ----------------- ##" + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + $as_echo "## ------------------- ## +## File substitutions. ## +## ------------------- ##" + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + $as_echo "## ----------- ## +## confdefs.h. ## +## ----------- ##" + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +ac_aux_dir= +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 +$as_echo_n "checking for a thread-safe mkdir -p... " >&6; } +if test -z "$MKDIR_P"; then + if ${ac_cv_path_mkdir+:} false; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in mkdir gmkdir; do + for ac_exec_ext in '' $ac_executable_extensions; do + as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue + case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( + 'mkdir (GNU coreutils) '* | \ + 'mkdir (coreutils) '* | \ + 'mkdir (fileutils) '4.1*) + ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext + break 3;; + esac + done + done + done +IFS=$as_save_IFS + +fi + + test -d ./--version && rmdir ./--version + if test "${ac_cv_path_mkdir+set}" = set; then + MKDIR_P="$ac_cv_path_mkdir -p" + else + # As a last resort, use the slow shell script. Don't cache a + # value for MKDIR_P within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + MKDIR_P="$ac_install_sh -d" + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 +$as_echo "$MKDIR_P" >&6; } + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; 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_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # 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_CC="${ac_tool_prefix}gcc" + $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 + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; 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_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # 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_ac_ct_CC="gcc" + $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 + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; 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_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # 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_CC="${ac_tool_prefix}cc" + $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 + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; 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_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +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 + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $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 + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; 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_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # 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_CC="$ac_tool_prefix$ac_prog" + $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 + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; 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_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # 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_ac_ct_CC="$ac_prog" + $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 + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if ${ac_cv_objext+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +struct stat; +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C99" >&5 +$as_echo_n "checking for $CC option to accept ISO C99... " >&6; } +if ${ac_cv_prog_cc_c99+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c99=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include +#include + +// Check varargs macros. These examples are taken from C99 6.10.3.5. +#define debug(...) fprintf (stderr, __VA_ARGS__) +#define showlist(...) puts (#__VA_ARGS__) +#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) +static void +test_varargs_macros (void) +{ + int x = 1234; + int y = 5678; + debug ("Flag"); + debug ("X = %d\n", x); + showlist (The first, second, and third items.); + report (x>y, "x is %d but y is %d", x, y); +} + +// Check long long types. +#define BIG64 18446744073709551615ull +#define BIG32 4294967295ul +#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) +#if !BIG_OK + your preprocessor is broken; +#endif +#if BIG_OK +#else + your preprocessor is broken; +#endif +static long long int bignum = -9223372036854775807LL; +static unsigned long long int ubignum = BIG64; + +struct incomplete_array +{ + int datasize; + double data[]; +}; + +struct named_init { + int number; + const wchar_t *name; + double average; +}; + +typedef const char *ccp; + +static inline int +test_restrict (ccp restrict text) +{ + // See if C++-style comments work. + // Iterate through items via the restricted pointer. + // Also check for declarations in for loops. + for (unsigned int i = 0; *(text+i) != '\0'; ++i) + continue; + return 0; +} + +// Check varargs and va_copy. +static void +test_varargs (const char *format, ...) +{ + va_list args; + va_start (args, format); + va_list args_copy; + va_copy (args_copy, args); + + const char *str; + int number; + float fnumber; + + while (*format) + { + switch (*format++) + { + case 's': // string + str = va_arg (args_copy, const char *); + break; + case 'd': // int + number = va_arg (args_copy, int); + break; + case 'f': // float + fnumber = va_arg (args_copy, double); + break; + default: + break; + } + } + va_end (args_copy); + va_end (args); +} + +int +main () +{ + + // Check bool. + _Bool success = false; + + // Check restrict. + if (test_restrict ("String literal") == 0) + success = true; + char *restrict newvar = "Another string"; + + // Check varargs. + test_varargs ("s, d' f .", "string", 65, 34.234); + test_varargs_macros (); + + // Check flexible array members. + struct incomplete_array *ia = + malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); + ia->datasize = 10; + for (int i = 0; i < ia->datasize; ++i) + ia->data[i] = i * 1.234; + + // Check named initializers. + struct named_init ni = { + .number = 34, + .name = L"Test wide string", + .average = 543.34343, + }; + + ni.number = 58; + + int dynamic_array[ni.number]; + dynamic_array[ni.number - 1] = 543; + + // work around unused variable warnings + return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x' + || dynamic_array[ni.number - 1] != 543); + + ; + return 0; +} +_ACEOF +for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc99 +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c99=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c99" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c99" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c99" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 +$as_echo "$ac_cv_prog_cc_c99" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c99" != xno; then : + +fi + + + +am__api_version='1.12' + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +# Reject install programs that cannot install multiple files. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } +if test -z "$INSTALL"; then +if ${ac_cv_path_install+:} false; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in #(( + ./ | .// | /[cC]/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + fi + done + done + ;; +esac + + done +IFS=$as_save_IFS + +rm -rf conftest.one conftest.two conftest.dir + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 +$as_echo_n "checking whether build environment is sane... " >&6; } +# Reject unsafe characters in $srcdir or the absolute working directory +# name. Accept space and tab only in the latter. +am_lf=' +' +case `pwd` in + *[\\\"\#\$\&\'\`$am_lf]*) + as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; +esac +case $srcdir in + *[\\\"\#\$\&\'\`$am_lf\ \ ]*) + as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; +esac + +# Do 'set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + am_has_slept=no + for am_try in 1 2; do + echo "timestamp, slept: $am_has_slept" > conftest.file + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + as_fn_error $? "ls -t appears to fail. Make sure there is not a broken + alias in your environment" "$LINENO" 5 + fi + if test "$2" = conftest.file || test $am_try -eq 2; then + break + fi + # Just in case. + sleep 1 + am_has_slept=yes + done + test "$2" = conftest.file + ) +then + # Ok. + : +else + as_fn_error $? "newly created file is older than distributed files! +Check your system clock" "$LINENO" 5 +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +# If we didn't sleep, we still need to ensure time stamps of config.status and +# generated files are strictly newer. +am_sleep_pid= +if grep 'slept: no' conftest.file >/dev/null 2>&1; then + ( sleep 1 ) & + am_sleep_pid=$! +fi + +rm -f conftest.file + +test "$program_prefix" != NONE && + program_transform_name="s&^&$program_prefix&;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s&\$&$program_suffix&;$program_transform_name" +# Double any \ or $. +# By default was `s,x,x', remove it if useless. +ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' +program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` + +if test x"${MISSING+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; + *) + MISSING="\${SHELL} $am_aux_dir/missing" ;; + esac +fi +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 +$as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} +fi + +if test x"${install_sh}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; + *) + install_sh="\${SHELL} $am_aux_dir/install-sh" + esac +fi + +# Installed binaries are usually stripped using 'strip' when the user +# run "make install-strip". However 'strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the 'STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; 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_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # 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_STRIP="${ac_tool_prefix}strip" + $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 + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +$as_echo "$STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; 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_ac_ct_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # 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_ac_ct_STRIP="strip" + $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 + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 +$as_echo "$ac_ct_STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; 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_AWK+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # 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_AWK="$ac_prog" + $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 + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 +$as_echo "$AWK" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$AWK" && break +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SET_MAKE= +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + +DEPDIR="${am__leading_dot}deps" + +ac_config_commands="$ac_config_commands depfiles" + + +am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo this is the am__doit target +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 +$as_echo_n "checking for style of include used by $am_make... " >&6; } +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# Ignore all kinds of additional output from 'make'. +case `$am_make -s -f confmf 2> /dev/null` in #( +*the\ am__doit\ target*) + am__include=include + am__quote= + _am_result=GNU + ;; +esac +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + case `$am_make -s -f confmf 2> /dev/null` in #( + *the\ am__doit\ target*) + am__include=.include + am__quote="\"" + _am_result=BSD + ;; + esac +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 +$as_echo "$_am_result" >&6; } +rm -f confinc confmf + +# Check whether --enable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then : + enableval=$enable_dependency_tracking; +fi + +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' + am__nodep='_no' +fi + if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + am__isrc=' -I$(srcdir)' + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi + + +# Define the identity of the package. + PACKAGE='unpaper' + VERSION='0.4.2' + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE "$PACKAGE" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$VERSION" +_ACEOF + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +# Always define AMTAR for backward compatibility. Yes, it's still used +# in the wild :-( We should find a proper way to deprecate it ... +AMTAR='$${TAR-tar}' + +am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' + + + + +depcc="$CC" am_compiler_list= + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if ${am_cv_CC_dependencies_compiler_type+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named 'D' -- because '-MD' means "put the output + # in D". + rm -rf conftest.dir + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + am__universal=false + case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with + # Solaris 10 /bin/sh. + echo '/* dummy */' > sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with '-c' and '-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle '-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs. + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # After this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested. + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvc7 | msvc7msys | msvisualcpp | msvcmsys) + # This compiler won't grok '-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_GREP" || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_EGREP" || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default" +if test "x$ac_cv_header_minix_config_h" = xyes; then : + MINIX=yes +else + MINIX= +fi + + + if test "$MINIX" = yes; then + +$as_echo "#define _POSIX_SOURCE 1" >>confdefs.h + + +$as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h + + +$as_echo "#define _MINIX 1" >>confdefs.h + + fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 +$as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } +if ${ac_cv_safe_to_define___extensions__+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +# define __EXTENSIONS__ 1 + $ac_includes_default +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_safe_to_define___extensions__=yes +else + ac_cv_safe_to_define___extensions__=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5 +$as_echo "$ac_cv_safe_to_define___extensions__" >&6; } + test $ac_cv_safe_to_define___extensions__ = yes && + $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h + + $as_echo "#define _ALL_SOURCE 1" >>confdefs.h + + $as_echo "#define _GNU_SOURCE 1" >>confdefs.h + + $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h + + $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5 +$as_echo_n "checking for stdbool.h that conforms to C99... " >&6; } +if ${ac_cv_header_stdbool_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + #ifndef bool + "error: bool is not defined" + #endif + #ifndef false + "error: false is not defined" + #endif + #if false + "error: false is not 0" + #endif + #ifndef true + "error: true is not defined" + #endif + #if true != 1 + "error: true is not 1" + #endif + #ifndef __bool_true_false_are_defined + "error: __bool_true_false_are_defined is not defined" + #endif + + struct s { _Bool s: 1; _Bool t; } s; + + char a[true == 1 ? 1 : -1]; + char b[false == 0 ? 1 : -1]; + char c[__bool_true_false_are_defined == 1 ? 1 : -1]; + char d[(bool) 0.5 == true ? 1 : -1]; + /* See body of main program for 'e'. */ + char f[(_Bool) 0.0 == false ? 1 : -1]; + char g[true]; + char h[sizeof (_Bool)]; + char i[sizeof s.t]; + enum { j = false, k = true, l = false * true, m = true * 256 }; + /* The following fails for + HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ + _Bool n[m]; + char o[sizeof n == m * sizeof n[0] ? 1 : -1]; + char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; + /* Catch a bug in an HP-UX C compiler. See + http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html + http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html + */ + _Bool q = true; + _Bool *pq = &q; + +int +main () +{ + + bool e = &s; + *pq |= q; + *pq |= ! q; + /* Refer to every declared value, to avoid compiler optimizations. */ + return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + + !m + !n + !o + !p + !q + !pq); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdbool_h=yes +else + ac_cv_header_stdbool_h=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5 +$as_echo "$ac_cv_header_stdbool_h" >&6; } + ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default" +if test "x$ac_cv_type__Bool" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE__BOOL 1 +_ACEOF + + +fi + + +if test $ac_cv_header_stdbool_h = yes; then + +$as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sqrt" >&5 +$as_echo_n "checking for library containing sqrt... " >&6; } +if ${ac_cv_search_sqrt+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char sqrt (); +int +main () +{ +return sqrt (); + ; + return 0; +} +_ACEOF +for ac_lib in '' m; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_sqrt=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_sqrt+:} false; then : + break +fi +done +if ${ac_cv_search_sqrt+:} false; then : + +else + ac_cv_search_sqrt=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_sqrt" >&5 +$as_echo "$ac_cv_search_sqrt" >&6; } +ac_res=$ac_cv_search_sqrt +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + + +# Extract the first word of "pngtopnm", so it can be a program name with args. +set dummy pngtopnm; 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_PNGTOPNM+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $PNGTOPNM in + [\\/]* | ?:[\\/]*) + ac_cv_path_PNGTOPNM="$PNGTOPNM" # 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_PNGTOPNM="$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_PNGTOPNM" && ac_cv_path_PNGTOPNM="false" + ;; +esac +fi +PNGTOPNM=$ac_cv_path_PNGTOPNM +if test -n "$PNGTOPNM"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PNGTOPNM" >&5 +$as_echo "$PNGTOPNM" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +# Extract the first word of "pnmtopng", so it can be a program name with args. +set dummy pnmtopng; 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_PNMTOPNG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $PNMTOPNG in + [\\/]* | ?:[\\/]*) + ac_cv_path_PNMTOPNG="$PNMTOPNG" # 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_PNMTOPNG="$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_PNMTOPNG" && ac_cv_path_PNMTOPNG="false" + ;; +esac +fi +PNMTOPNG=$ac_cv_path_PNMTOPNG +if test -n "$PNMTOPNG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PNMTOPNG" >&5 +$as_echo "$PNMTOPNG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + +if test "x$XSLTPROC" = "x"; then : + + for ac_prog in xsltproc +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; 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_XSLTPROC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$XSLTPROC"; then + ac_cv_prog_XSLTPROC="$XSLTPROC" # 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_XSLTPROC="$ac_prog" + $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 + +fi +fi +XSLTPROC=$ac_cv_prog_XSLTPROC +if test -n "$XSLTPROC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XSLTPROC" >&5 +$as_echo "$XSLTPROC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$XSLTPROC" && break +done + + if test "x$XSLTPROC" = "x"; then : + + as_fn_error $? "unable to find xsltproc, you need this to build man pages" "$LINENO" 5 + +fi + +fi + +ac_config_files="$ac_config_files Makefile tests/prologue.sh" + + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + if test "x$cache_file" != "x/dev/null"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +# +# If the first sed substitution is executed (which looks for macros that +# take arguments), then branch to the quote section. Otherwise, +# look for a macro that doesn't take arguments. +ac_script=' +:mline +/\\$/{ + N + s,\\\n,, + b mline +} +t clear +:clear +s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g +t quote +s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g +t quote +b any +:quote +s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g +s/\[/\\&/g +s/\]/\\&/g +s/\$/$$/g +H +:any +${ + g + s/^\n// + s/\n/ /g + p +} +' +DEFS=`sed -n "$ac_script" confdefs.h` + + +ac_libobjs= +ac_ltlibobjs= +U= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 +$as_echo_n "checking that generated files are newer than configure... " >&6; } + if test -n "$am_sleep_pid"; then + # Hide warnings about reused PIDs. + wait $am_sleep_pid 2>/dev/null + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 +$as_echo "done" >&6; } +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + as_fn_error $? "conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +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 -n "$EXEEXT"; then + am__EXEEXT_TRUE= + am__EXEEXT_FALSE='#' +else + am__EXEEXT_TRUE='#' + am__EXEEXT_FALSE= +fi + + +: "${CONFIG_STATUS=./config.status}" +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by unpaper $as_me 0.4.2, which was +generated by GNU Autoconf 2.69. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" +config_commands="$ac_config_commands" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + +Configuration files: +$config_files + +Configuration commands: +$config_commands + +Report bugs to the package provider." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" +ac_cs_version="\\ +unpaper config.status 0.4.2 +configured by $0, generated by GNU Autoconf 2.69, + with options \\"\$ac_cs_config\\" + +Copyright (C) 2012 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +MKDIR_P='$MKDIR_P' +AWK='$AWK' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h | --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# +# INIT-COMMANDS +# +AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "tests/prologue.sh") CONFIG_FILES="$CONFIG_FILES tests/prologue.sh" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\)..*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\)..*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + + +eval set X " :F $CONFIG_FILES :C $CONFIG_COMMANDS" +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac + ac_MKDIR_P=$MKDIR_P + case $MKDIR_P in + [\\/$]* | ?:[\\/]* ) ;; + */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +s&@MKDIR_P@&$ac_MKDIR_P&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$ac_tmp/stdin" + case $ac_file in + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + + + :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 +$as_echo "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "depfiles":C) test x"$AMDEP_TRUE" != x"" || { + # Autoconf 2.62 quotes --file arguments for eval, but not when files + # are listed without --file. Let's play safe and only enable the eval + # if we detect the quoting. + case $CONFIG_FILES in + *\'*) eval set x "$CONFIG_FILES" ;; + *) set x $CONFIG_FILES ;; + esac + shift + for mf + do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named 'Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`$as_dirname -- "$mf" || +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$mf" : 'X\(//\)[^/]' \| \ + X"$mf" : 'X\(//\)$' \| \ + X"$mf" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running 'make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`$as_dirname -- "$file" || +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$file" : 'X\(//\)[^/]' \| \ + X"$file" : 'X\(//\)$' \| \ + X"$file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir=$dirpart/$fdir; as_fn_mkdir_p + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done + done +} + ;; + + esac +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit 1 +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + diff -Nru unpaper-0.3/configure.ac unpaper-0.4.2/configure.ac --- unpaper-0.3/configure.ac 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/configure.ac 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,27 @@ +AC_PREREQ(2.68) + +AC_INIT([unpaper], [0.4.2]) + +AC_PROG_MKDIR_P +AC_PROG_CC_C99 + +AM_INIT_AUTOMAKE([dist-xz no-dist-gzip foreign parallel-tests]) +AC_USE_SYSTEM_EXTENSIONS + +AC_HEADER_STDBOOL +AC_SEARCH_LIBS([sqrt], [m]) + +AC_PATH_PROG([PNGTOPNM], [pngtopnm], [false]) +AC_PATH_PROG([PNMTOPNG], [pnmtopng], [false]) + +AC_ARG_VAR([XSLTPROC], [A libxslt-compatible XSLT processor command]) +AS_IF([test "x$XSLTPROC" = "x"], [ + AC_CHECK_PROGS([XSLTPROC], [xsltproc]) + AS_IF([test "x$XSLTPROC" = "x"], [ + AC_MSG_ERROR([unable to find xsltproc, you need this to build man pages]) + ]) +]) + +AC_CONFIG_FILES([Makefile tests/prologue.sh]) + +AC_OUTPUT diff -Nru unpaper-0.3/COPYING unpaper-0.4.2/COPYING --- unpaper-0.3/COPYING 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/COPYING 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + (signature of Ty Coon), 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. \ No newline at end of file diff -Nru unpaper-0.3/debian/changelog unpaper-0.4.2/debian/changelog --- unpaper-0.3/debian/changelog 2012-06-25 04:24:28.000000000 +0000 +++ unpaper-0.4.2/debian/changelog 2012-06-24 14:53:42.000000000 +0000 @@ -1,8 +1,24 @@ -unpaper (0.3-1ubuntu1) oneiric; urgency=low +unpaper (0.4.2-1) unstable; urgency=low - * Reorder libs in command to resolve FTBFS with gcc-4.6. (LP: #832854) + * add debian/watch file + * install with dh_install* + * fix lintian warnings + * debian/copyright: new upstream, machine readable + * use minimal debian/rules + * update debhelper version and debian/compat (9) + * updated policy version (3.9.3) + * Changed maintainer to me (with blessing from jblache, thx) + * add VCS-* fields for new Git repo + * set debian/source/format to "3.0 (quilt)" + * manpage now provided by upstream, remove debian's manpage + * new upstream version (Closes: #656768) + - Changed to new upstream Diego Elio Pettenò, with blessing + from original author Jens Gulden + - Major code and build system cleanup and optimizations + - rewritten option parsing, --input-sequence and + --output-sequence removed - -- Daniel T Chen Sat, 27 Aug 2011 00:14:46 -0400 + -- Thomas Koch Sat, 24 Jun 2012 16:49:20 +0200 unpaper (0.3-1) unstable; urgency=low diff -Nru unpaper-0.3/debian/clean unpaper-0.4.2/debian/clean --- unpaper-0.3/debian/clean 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/debian/clean 2012-06-23 04:13:02.000000000 +0000 @@ -0,0 +1 @@ +results*.txt diff -Nru unpaper-0.3/debian/compat unpaper-0.4.2/debian/compat --- unpaper-0.3/debian/compat 2012-06-25 04:24:28.000000000 +0000 +++ unpaper-0.4.2/debian/compat 2012-06-23 04:13:02.000000000 +0000 @@ -1 +1 @@ -5 +9 diff -Nru unpaper-0.3/debian/control unpaper-0.4.2/debian/control --- unpaper-0.3/debian/control 2012-06-25 04:24:28.000000000 +0000 +++ unpaper-0.4.2/debian/control 2012-06-23 04:13:02.000000000 +0000 @@ -1,10 +1,12 @@ Source: unpaper Section: graphics Priority: optional -Maintainer: Ubuntu Developers -XSBC-Original-Maintainer: Julien BLACHE -Build-Depends: debhelper (>= 5.0.0) -Standards-Version: 3.7.3 +Maintainer: Thomas Koch +Build-Depends: debhelper (>= 9), netpbm, xsltproc +Standards-Version: 3.9.3 +Homepage: http://www.flameeyes.eu/projects/unpaper +Vcs-Browser: http://anonscm.debian.org/gitweb/?p=collab-maint/unpaper.git +Vcs-Git: git://anonscm.debian.org/collab-maint/unpaper.git Package: unpaper Architecture: any diff -Nru unpaper-0.3/debian/copyright unpaper-0.4.2/debian/copyright --- unpaper-0.3/debian/copyright 2012-06-25 04:24:28.000000000 +0000 +++ unpaper-0.4.2/debian/copyright 2012-06-23 04:13:02.000000000 +0000 @@ -1,13 +1,24 @@ -This package was debianized by Julien BLACHE on -Sun, 14 May 2006 20:51:43 +0200. +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: unpaper +Upstream-Contact: Diego Elio Pettenò +Source: https://github.com/Flameeyes/unpaper -It was downloaded from: http://unpaper.berlios.de/ - -Copyright Holder: Copyright (C) 2005-2006 Jens Gulden - -License: - -Licensed under the GNU General Public License, this comes with no warranty. - -On Debian systems, the complete text of the GNU General Public License can be -found in the /usr/share/common-licenses/GPL file. +Files: * +Copyright: 2005-2006 Jens Gulden + 2011 Diego Elio Pettenò +License: GPL-2 + Unpaper 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, version 2 of the License. + . + Unpaper 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 . + . + On Debian systems, the full text of the GNU General Public + License version 2 can be found in the file + `/usr/share/common-licenses/GPL-2'. diff -Nru unpaper-0.3/debian/dirs unpaper-0.4.2/debian/dirs --- unpaper-0.3/debian/dirs 2012-06-25 04:24:28.000000000 +0000 +++ unpaper-0.4.2/debian/dirs 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -usr/bin diff -Nru unpaper-0.3/debian/docs unpaper-0.4.2/debian/docs --- unpaper-0.3/debian/docs 2012-06-25 04:24:28.000000000 +0000 +++ unpaper-0.4.2/debian/docs 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -README -doc/ - diff -Nru unpaper-0.3/debian/rules unpaper-0.4.2/debian/rules --- unpaper-0.3/debian/rules 2012-06-25 04:24:28.000000000 +0000 +++ unpaper-0.4.2/debian/rules 2012-06-24 06:13:53.000000000 +0000 @@ -1,73 +1,14 @@ #!/usr/bin/make -f # -*- makefile -*- -# Sample debian/rules that uses debhelper. -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. -# Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 -CFLAGS = -Wall -g +# export MANPAGE_XSL=/usr/share/xml/docbook/stylesheet/docbook-xsl/manpages/docbook.xsl -ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) - CFLAGS += -O0 -else - CFLAGS += -O2 -endif +%: + dh $@ -build: build-stamp -build-stamp: - dh_testdir +override_dh_auto_install: - # Add here commands to compile the package. - gcc $(CFLAGS) -o unpaper src/unpaper.c -lm - - touch build-stamp - -clean: - dh_testdir - dh_testroot - rm -f build-stamp - - # Add here commands to clean up after the build process. - rm -f $(CURDIR)/unpaper - - dh_clean - -install: build - dh_testdir - dh_testroot - dh_clean -k - dh_installdirs - - # Add here commands to install the package into debian/unpaper. - cp $(CURDIR)/unpaper $(CURDIR)/debian/unpaper/usr/bin - - -# Build architecture-independent files here. -binary-indep: build install -# We have nothing to do by default. - -# Build architecture-dependent files here. -binary-arch: build install - dh_testdir - dh_testroot - dh_installchangelogs CHANGELOG - dh_installdocs -# dh_installexamples -# dh_install - dh_installman debian/unpaper.1 - dh_link - dh_strip - dh_compress - dh_fixperms - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install configure +override_dh_installchangelogs: + dh_installchangelogs NEWS \ No newline at end of file diff -Nru unpaper-0.3/debian/source/format unpaper-0.4.2/debian/source/format --- unpaper-0.3/debian/source/format 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/debian/source/format 2012-06-25 04:24:28.000000000 +0000 @@ -0,0 +1 @@ +3.0 (quilt) diff -Nru unpaper-0.3/debian/source/include-binaries unpaper-0.4.2/debian/source/include-binaries --- unpaper-0.3/debian/source/include-binaries 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/debian/source/include-binaries 2012-06-24 14:55:21.000000000 +0000 @@ -0,0 +1,2 @@ +debian/upstream_gpg_signatures/unpaper_0.4.2.orig.tar.xz.sig + diff -Nru unpaper-0.3/debian/unpaper.1 unpaper-0.4.2/debian/unpaper.1 --- unpaper-0.3/debian/unpaper.1 2012-06-25 04:24:28.000000000 +0000 +++ unpaper-0.4.2/debian/unpaper.1 1970-01-01 00:00:00.000000000 +0000 @@ -1,609 +0,0 @@ -.\" Hey, EMACS: -*- nroff -*- -.TH UNPAPER 1 "December 31, 2007" -.\" Please adjust this date whenever revising the manpage. -.\" -.\" Some roff macros, for reference: -.\" .nh disable hyphenation -.\" .hy enable hyphenation -.\" .ad l left justify -.\" .ad b justify to both left and right margins -.\" .nf disable filling -.\" .fi enable filling -.\" .br insert line break -.\" .sp insert n+1 empty lines -.\" for manpage-specific macros, see man(7) -.SH NAME -unpaper \- post-processing tool for scanned pages - -.SH SYNOPSIS -.B unpaper -.RI [options] " input-file(s) output-file(s) - -.SH DESCRIPTION - -\fBunpaper\fP is a post-processing tool for scanned sheets of paper, -especially for book pages that have been scanned from previously -created photocopies. - -The main purpose is to make scanned book pages better readable on -screen after conversion to PDF. Additionally, unpaper might be useful -to enhance the quality of scanned pages before performing optical -character recognition (OCR). - -.SH OPTIONS - -Filenames may contain a formatting placeholder starting with \fI%\fP to insert a -page counter for multi-page processing. E.g.: \fIscan%03d.pbm\fP to process files -\fBscan001.pbm\fP, \fBscan002.pbm\fP, \fBscan003.pbm\fP etc. - -.TP -.B \-l, \-\-layout \fIsingle\fP|\fIdouble\fP|\fInone\fP -Set default layout options for a sheet: -.sp 1 -\fIsingle\fP: One page per sheet. -.sp 1 -\fIdouble\fP: Two pages per sheet, landscape orientation (one -page on the left half, one page on the right half). -.sp 1 -\fInone\fP: No auto-layout, mask-scan-points may individually be -specified. -.sp 1 -Using \fIsingle\fP or \fIdouble\fP automatically sets corresponding -\fB\-\-mask\-scan\-points\fP. The default is \fIsingle\fP. - -.TP -.B \-start, \-\-start\-sheet \fI\fP -Number of first sheet to process in multi-sheet mode. (default: \fI1\fP) - -.TP -.B \-end, \-\-end\-sheet \fI\fP -Number of last sheet to process in multi-sheet mode. \fI-1\fP indicates -processing until no more input file with the corresponding page number -is available. (default: \fI-1\fP) - -.TP -.B \-#, \-\-sheet \fI\fP{\fI,\fP[\fI-\fP]} -Optionally specifies which sheets to process in the range between -\fBstart\-sheet\fP and \fBend\-sheet\fP. - -.TP -.B \-x, \-\-exclude \fI\fP{\fI,\fP[\fI-\fP]} -Excludes sheets from processing in the range between -\fBstart\-sheet\fP and \fBend-sheet\fP. - -.TP -.B \-\-pre\-rotate \fI\-90\fP|\fI90\fP -Rotates the whole image clockwise (\fI90\fP) or counter-clockwise -(\fI-90\fP) before any other processing. - -.TP -.B \-\-post\-rotate \fI-90\fP|\fI90\fP -Rotates the whole image clockwise (\fI90\fP) or counter-clockwise -(\fI-90\fP) after any other processing. - -.TP -.B \-M, \-\-pre\-mirror [\fIv\fP[\fIertical\fP]][\fI,\fP][\fIh\fP[\fIorizontal\fP]] -Mirror the image, after possible pre-rotation. Either \fIv\fP (for -vertical mirroring), \fIh\fP (for horizontal mirroring) or \fIv,h\fP -(for both) can be specified. - -.TP -.B \-\-post\-mirror [\fIv\fP[\fIertical\fP]][\fI,\fP][\fIh\fP[\fIorizontal\fP]] -Mirror the image, after any other processing except possible -post-rotation. - -.TP -.B \-\-pre\-shift \fI,\fP -Shift the image before further processing. Values for \fIh\fP (horizontal -shift) and \fIv\fP (vertical shift) can either be positive or negative. - -.TP -.B \-\-post\-shift \fI,\fP -Shift the image after other processing. Values for \fIh\fP (horizontal -shift) and \fIv\fP (vertical shift) can either be positive or negative. - -.TP -.B \-\-pre\-wipe \fI,,,\fP -Manually wipe out an area before further processing. Any pixel in a -wiped area will be set to white. Multiple areas to be wiped may be -specified by multiple occurrences of this options. - -.TP -.B \-\-post\-wipe \fI,,,\fP -Manually wipe out an area after processing. Any pixel in a wiped area -will be set to white. Multiple areas to be wiped may be specified by -multiple occurrences of this options. - -.TP -.B \-\-pre\-border \fI,,,\fP -Clear the border-area of the sheet before further processing. Any -pixel in the border area will be set to white. - -.TP -.B \-\-post\-border \fI,,,\fP -Clear the border-area after processing. Any pixel in the border area -will be set to white. - -.TP -.B \-\-pre\-mask \fI,,,\fP -Specify masks to apply before any other processing. Any pixel outside -a mask will be set to white, unless another mask includes this pixel. -Only pixels inside a mask will remain. Multiple masks may be -specified. No deskewing will be applied to the masks specified by -\fB\-\-pre\-mask\fP. - -.TP -.B \-s, \-\-size \fI,\fP|\fI\fP -Change the sheet size before other processing is applied. Content on -the sheet gets zoomed to fit to the appropriate size, but the aspect -ratio is preserved. Instead, if the sheet's aspect ratio changes, the -zoomed content gets centered on the sheet. Size-name can also be a -standard name as \fIa4\fP, \fIletter\fP, etc. -Possible size names are: -.sp 1 -\fIa5\fP -.br -\fIa4\fP -.br -\fIa3\fP -.br -\fIletter\fP -.br -\fIlegal\fP -.sp 1 -All size names can also be applied in -rotated landscape orientation, use -\fIa4\-landscape\fP, \fIletter\-landscape\fP etc. - -.TP -.B \-\-post\-size \fI,\fP|\fI\fP -Change the sheet size preserving the content's aspect ratio after -other processing steps are applied. - -.TP -.B \-\-stretch \fI,\fP|\fI\fP -Change the sheet size before other processing is applied. Content on -the sheet gets stretched to the specified size, possibly changing the -aspect ratio. - -.TP -.B \-\-post\-stretch \fI,\fP|\fI\fP -Change the sheet size after other processing is applied. Content on -the sheet gets stretched to the specified size, possibly changing the -aspect ratio. - -.TP -.B \-z, \-\-zoom \fI\fP -Change the sheet size according to the given factor before other -processing is done. - -.TP -.B \-\-post\-zoom \fI\fP -Change the sheet size according to the given factor after processing -is done. - -.TP -.B \-bn, \-\-blackfilter\-scan\-direction [\fIv\fP[\fIertical\fP]][\fI,\fP][\fIh\fP[\fIorizontal\fP]] -Directions in which to search for solidly black areas. Either \fIv\fP -(for vertical scanning), \fIh\fP (for horizontal scanning) or -\fIv,h\fP (for both) can be specified. (default: \fIv,h\fP) - -.TP -.B \-bs, \-\-blackfilter\-scan\-size \fI\fP|\fI,\fP -Width of virtual bar used for mask detection. Two values may be -specified to individually set horizontal and vertical size. (default: -\fI20,20\fP) - -.TP -.B \-bd, \-\-blackfilter\-scan\-depth \fI\fP|\fI\fP -Size of virtual bar used for black area detection. (default: -\fI500,500\fP) - -.TP -.B \-bp, \-\-blackfilter\-scan\-step \fI\fP|\fI\fP -Steps to move virtual bar for black area detection. (default: \fI5,5\fP) - -.TP -.B \-bt, \-\-blackfilter\-scan\-threshold \fI\fP -Ratio of dark pixels above which a black area gets detected. (default: -\fI0.95\fP) - -.TP -.B \-bx, \-\-blackfilter\-scan\-exclude \fI,,,\fP -Area on which the blackfilter should not operate. This can be useful -to prevent the blackfilter from working on inner page content. May be -specified multiple times to set more than one area. - -.TP -.B \-bi, \-\-blackfilter-intensity \fI\fP -Intensity with which to delete black areas. Larger values will leave -less noise-pixels around former black areas, but may delete page -content. (default: \fI20\fP) - -.TP -.B \-ni, \-\-noisefilter\-intensity \fI\fP -Intensity with which to delete individual pixels or tiny clusters of -pixels. Any cluster which only contains n dark pixels together will be -deleted. (default: \fI4\fP) - -.TP -.B \-ls, \-\-blurfilter\-size \fI\fP|\fI,\fP -Size of blurfilter area to search for 'lonely' clusters of -pixels. (default: \fI100,100\fP) - -.TP -.B \-lp, \-\-blurfilter\-step \fI\fP|\fI,\fP -Size of 'blurring' steps in each direction. (default: \fI50,50\fP) - -.TP -.B \-li, \-\-blurfilter\-intensity \fI\fP -Relative intensity with which to delete tiny clusters of pixels. Any -blurred area which contains at most the ratio of dark pixels will be -cleared. (default: \fI0.01\fP) - -.TP -.B \-gs, \-\-grayfilter\-size \fI\fP|\fI,\fP -Size of grayfilter mask to search for 'gray-only' areas of -pixels. (default: \fI50,50\fP) - -.TP -.B \-gp, \-\-grayfilter\-step \fI\fP|\fI,\fP -Size of steps moving the grayfilter mask in each direction. (default: -\fI20,20\fP) - -.TP -.B \-gt, \-\-grayfilter\-threshold \fI\fP -Relative intensity of grayness which is accepted before clearing the -grayfilter mask in cases where no black pixel is found in the -mask. (default: \fI0.5\fP) - -.TP -.B \-p, \-\-mask\-scan\-point \fI,\fP -Manually set starting point for mask-detection. Multiple -\fB\-\-mask\-scan\-point\fP options may be specified to detect -multiple masks. - -.TP -.B \-m, \-\-mask \fI,,,\fP -Manually add a mask, in addition to masks automatically detected -around the \fB\-\-mask\-scan\-point\fP coordinates (unless -\fB\-\-no\-mask\-scan\fP is specified). Any pixel outside a mask will -be set to white, unless another mask covers this pixel. - -.TP -.B \-mn, \-\-mask\-scan\-direction [\fIv\fP[\fIertical\fP]][\fI,\fP][\fIh\fP[\fIorizontal\fP]] -Directions in which to search for mask borders, starting from -\fB\-\-mask\-scan\-point\fP coordinates. Either \fIv\fP (for vertical -scanning), \fIh\fP (for horizontal scanning) or \fIv,h\fP (for both) -can be specified. (default: \fIh\fP (\fIv\fP may cut text-paragraphs -on single-page sheets)) - -.TP -.B \-ms, \-\-mask\-scan\-size \fI\fP|\fI\fP -Width of the virtual bar used for mask detection. Two values may be -specified to individually set horizontal and vertical size. (default: -\fI50,50\fP) - -.TP -.B \-md, \-\-mask\-scan\-depth \fI\fP|\fI\fP -Height of the virtual bar used for mask detection. (default: -\fI-1,-1\fP, using the total width or height of the sheet) - -.TP -.B \-mp, \-\-mask\-scan\-step \fI\fP|\fI\fP -Steps to move the virtual bar for mask detection. (default: \fI5,5\fP) - -.TP -.B \-mt, \-\-mask\-scan\-threshold \fI\fP|\fI\fP -Ratio of dark pixels below which an edge gets detected, relative to -max. blackness when counting from the start coordinate heading towards -one edge. (default: \fI0.1\fP) - -.TP -.B \-mm, \-\-mask\-scan\-minimum \fI,\fP -Minimum allowed size of an auto-detected mask. Masks detected below -this size will be ignored and set to the size specified by -mask-scan-maximum. (default: \fI100,100\fP) - -.TP -.B \-mM, \-\-mask\-scan\-maximum \fI,\fP -Maximum allowed size of an auto-detected mask. Masks detected above -this size will be shrunk to the maximum value, each direction -individually. (default: sheet size, or page size derived from -\fB\-\-layout\fP option) - -.TP -.B \-mc, \-\-mask\-color \fI\fP -Color value with which to wipe out pixels not covered by any -mask. Maybe useful for testing in order to visualize the effect of -masking. (Note that an RGB-value is expected: R*65536 + G*256 + B) - -.TP -.B \-dn, \-\-deskew\-scan\-direction \fI,,,\fP -Edges from which to scan for rotation. Each edge of a mask can be used -to detect the mask's rotation. If multiple edges are specified, the -average value will be used, unless the statistical deviation exceeds -\fB\-\-deskew\-scan\-deviation\fP. Use \fIleft\fP for scanning from -the left edge, \fItop\fP for scanning from the top edge, \fIright\fP -for scanning from the right edge, \fIbottom\fP for scanning from the -bottom. Multiple directions can be separated by commas. (default: -\fIleft,right\fP) - -.TP -.B \-ds, \-\-deskew\-scan\-size \fI\fP -Size of virtual line for rotation detection. (default: \fI1500\fP) - -.TP -.B \-dd, \-\-deskew\-scan\-depth \fI\fP -Amount of dark pixels to accumulate until scanning is stopped, -relative to scan-bar size. (default: \fI0.5\fP) - -.TP -.B \-dr, \-\-deskew\-scan\-range \fI\fP -Range in which to search for rotation, from \fI-degrees\fP to -\fI+degrees\fP rotation. (default: \fI5.0\fP) - -.TP -.B \-dp, \-\-deskew\-scan\-step \fI\fP -Steps between single rotation-angle detections. Lower numbers lead to -better results but slow down processing. (default: \fI0.1\fP) - -.TP -.B \-dv, \-\-deskew\-scan\-deviation \fI\fP -Maximum statistical deviation allowed among the results from detected -edges. No rotation if exceeded. (default: \fI1.0\fP) - -.TP -.B \-W, \-\-wipe \fI,,,\fP -Manually wipe out an area. Any pixel in a wiped area will be set to -white. Multiple \fB\-\-wipe\fP areas may be specified. This is applied -after deskewing and before automatic border-scan. - -.TP -.B \-mw, \-\-middle\-wipe \fI\fP|\fI,\fP -If \fB\-\-layout\fP is set to \fIdouble\fP, this may specify the size -of a middle area to wipe out between the two pages on the sheet. This -may be useful if the blackfilter fails to remove some black areas -(e.g. resulting from photo-copying in the middle between two pages). - -.TP -.B \-B, \-\-border \fI,,,\fP -Manually add a border. Any pixel in the border area will be set to white. This is -applied after deskewing and before automatic border-scan. - -.TP -.B \-Bn, \-\-border\-scan\-direction [\fIv\fP[\fIertical\fP]][,][\fIh\fP[\fIorizontal\fP]] -Directions in which to search for outer border. Either \fIv\fP (for -vertical scanning), \fIh\fP (for horizontal scanning) or \fIv,h\fP -(for both) can be specified. (default: \fIv\fP) - -.TP -.B \-Bs, \-\-border\-scan\-size \fI\fP|\fI\fP -Width of virtual bar used for border detection. Two values may be -specified to individually set horizontal and vertical size. (default: -\fI5,5\fP) - -.TP -.B \-Bp, \-\-border\-scan\-step \fI\fP|\fI\fP -Steps to move virtual bar for border detection. (default: \fI5,5\fP) - -.TP -.B \-Bt, \-\-border\-scan\-threshold \fI\fP -Absolute number of dark pixels covered by the border-scan mask above -which a border is detected. (default: \fI5\fP) - -.TP -.B \-Ba, \-\-border\-align \fI,,,\fP -Direction where to shift the detected border-area. Use -\fB\-\-border\-margin to specify horizontal and vertical distances to -be kept from the sheet-edge. (default: \fInone\fP) - -.TP -.B \-Bm, \-\-border\-margin \fI,\fP -Distance to keep from the sheet edge when aligning a border area. May -use measurement suffices such as \fIcm\fP, \fIin\fP. - -.TP -.B \-w, \-\-white\-threshold \fI\fP -Brightness ratio above which a pixel is considered white. (default: -\fI0.9\fP) - -.TP -.B \-b, \-\-black\-threshold \fI -Brightness ratio below which a pixel is considered black -(non-gray). This is used by the gray-filter. This value is also used -when converting a grayscale image to black-and-white mode (default: -\fI0.33\fP) - -.TP -.B \-ip, \-\-input\-pages \fI1\fP|\fI2\fP -If \fI2\fP is specified, read two input images instead of one and -internally combine them to a doubled-layout sheet before further -processing. Before internally combining, \fB\-\-pre\-rotation\fP is -optionally applied individually to both input images as the very first -processing steps. - -.TP -.B \-op, \-\-output\-pages \fI1\fP|\fI2\fP -If \fI2\fP is specified, write two output images instead of one, as a -result of splitting a doubled-layout sheet after processing. After -splitting the sheet, \fB\-\-post\-rotation\fP is optionally applied -individually to both output images as the very last processing step. - -.TP -.B \-S, \-\-sheet\-size \fI,\fP|\fI\fP -Force a fix sheet size. Usually, the sheet size is determined by the -input image size (if \fBinput\-pages\fP=\fI1\fP), or by the double -size of the first page in a two-page input set (if -\fBinput\-pages\fP=\fI2\fP). If the input image is smaller than the -size specified here, it will appear centered and surrounded with a -white border on the sheet. If the input image is bigger, it will be -centered and the edges will be cropped. This option may also be -helpful to get regular sized output images if the input image sizes -differ. Standard size-names like \fIa4\-landscape\fP, \fIletter\fP, -etc. may be used (see \fB\-\-size\fP). (default: as in input file) - -.TP -.B \-\-sheet\-background \fIblack\fP|\fIwhite\fP -Sets a color with which the sheet is filled before any image is loaded -and placed onto it. This can be useful when the sheet size and the -image size differ. - -.TP -.B \-\-no\-blackfilter \fI\fP{\fI,\fP[\fI\-\fP]} -Disables black area scan. Individual sheet indices can be specified. - -.TP -.B \-\-no\-noisefilter \fI\fP{\fI,\fP[\fI\-\fP]} -Disables the noise filter. Individual sheet indices can be specified. - -.TP -.B \-\-no\-blurfilter \fI\fP{\fI,\fP[\fI\-\fP]} -Disables the blur filter. Individual sheet indices can be specified. - -.TP -.B \-\-no\-grayfilter \fI\fP{\fI,\fP[\fI\-\fP]} -Disables the gray filter. Individual sheet indices can be specified. - -.TP -.B \-\-no\-mask\-scan \fI\fP{\fI,\fP[\fI\-\fP]} -Disables mask-detection. Masks explicitly set by \fB\-\-mask\fP will -still have effect. Individual sheet indices can be specified. - -.TP -.B \-\-no\-mask\-center \fI\fP{\fI,\fP[\fI\-\fP]} -Disables auto-centering of each mask. Auto-centering is performed by -default if the \fB\-\-layout\fP option has been set. Individual sheet -indices can be specified. - -.TP -.B \-\-no\-deskew \fI\fP{\fI,\fP[\fI\-\fP]} -Disables deskewing. Individual sheet indices can be specified. - -.TP -.B \-\-no\-wipe \fI\fP{\fI,\fP[\fI\-\fP]} -Disables explicit wipe-areas. This means the effect of parameter -\fB\-\-wipe\fP can be disabled individually per sheet. - -.TP -.B \-\-no\-border \fI\fP{\fI,\fP[\fI\-\fP]} -Disables explicitly set borders. This means the effect of parameter -\fB\-\-border\fP can be disabled individually per sheet. - -.TP -.B \-\-no\-border\-scan \fI\fP{\fI,\fP[\fI\-\fP]} -Disables border-scanning from the edges of the sheet. Individual sheet -indices can be specified. - -.TP -.B \-\-no\-border\-align \fI\fP{\fI,\fP[\fI\-\fP]} -Disables aligning of the area detected by border-scanning (see -\fB\-\-border\-align\fP). Individual sheet indices can be specified. - -.TP -.B \-n, \-\-no\-processing \fI\fP{\fI,\fP[\fI\-\fP]} -Do not perform any processing on a sheet except pre/post rotating and -mirroring, and file-depth conversions on saving. This option has the -same effect as setting all \fB\-\-no\-xxx\fP options -together. Individual sheet indices can be specified. - -.TP -.B \-\-no\-qpixels -Disable qpixel-mode for deskewing (do not internally use a 4x bigger -image when rotating). - -.TP -.B \-\-no\-multi\-pages -Disable multi-page processing even if the input filename contains a -'%' (usually indicating the start of a placeholder for the page -counter). - -.TP -.B \-\-dpi \fI\fP -Dots per inch used for conversion of measured size values, like -e.g. \fI21cm,27.9cm\fP. Note that this parameter should occur before -specifying any size value with measurement suffix. (default: -\fI300\fP) - -.TP -.B \-t, \-\-type \fIpbm\fP|\fIpgm\fP -Output file type. (default: as input) - -.TP -.B \-d, \-\-depth \fI\fP -Output pixel depth. (default: as input) - -.TP -.B \-T, \-\-test\-only -Do not write any output. May be useful in combination with -\fB\-\-verbose\fP to get information about the input. - -.TP -.B \-in, \-\-input\-file\-sequence \fI\fP -Sequence of input filename patterns which is repeatedly traversed -while resolving input filenames. Specifying a single entry is -equivalent to the first filename argument after the options-list. - -.TP -.B \-out, \-\-output\-file\-sequence \fI\fP -Sequence of output filename patterns which is repeatedly traversed -while resolving output filenames. Specifying a single entry is -equivalent to the second filename argument after the options-list. - -.TP -.B \-si, \-\-start\-input \fI\fP -Set the first page number to substitute for \fI%d\fP in input -filenames. Every time the input file sequence is repeated, this number -gets increased by 1. (default: (startsheet-1)*inputpages+1) - -.TP -.B \-so, \-\-start\-output \fI\fP -Set the first page number to substitute for \fI%d\fP in output -filenames. Every time the output file sequence is repeated, this -number gets increased by 1. (default: (startsheet-1)*outputpages+1) - -.TP -.B \-\-insert\-blank \fI\fP{\fI,\fP[\fI-\fP]} -Use blank input instead of an input file from the input file sequence -at the specified index-positions. The input file sequence will be -interrupted temporarily and will continue with the next input file -afterwards. This can be useful to insert blank content into a sequence -of input images. - -.TP -.B \-\-replace\-blank \fI\fP{\fI,\fP[\fI-\fP]} -Like \fB\-\-insert\-blank\fP, but the input images at the specified -index positions get replaced with blank content and thus will be -ignored. - -.TP -.B \-\-overwrite -Allow overwriting existing files. Otherwise the program terminates -with an error if an output-file to be written already exists. - -.TP -.B \-q, \-\-quiet -Quiet mode, no output at all. - -.TP -.B \-v, \-\-verbose -Verbose output, more info messages. - -.TP -.B \-vv -Even more verbose output, show parameter settings before processing. - -.TP -.B \-\-time -Output processing time consumed. - -.TP -.B \-V, \-\-version -Output version and build information. - - -.SH AUTHOR -unpaper was written by Jens Gulden . -.PP -This manual page was written by Julien BLACHE , -for the Debian project (but may be used by others). diff -Nru unpaper-0.3/debian/unpaper.doc-base unpaper-0.4.2/debian/unpaper.doc-base --- unpaper-0.3/debian/unpaper.doc-base 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/debian/unpaper.doc-base 2012-06-23 04:13:02.000000000 +0000 @@ -0,0 +1,9 @@ +Document: unpaper +Title: unpaper +Abstract: postprocess scanned text sheets or books +Section: Text + +Format: HTML +Index: /usr/share/doc/unpaper/doc/index.html +Files: /usr/share/doc/unpaper/doc/*.html + diff -Nru unpaper-0.3/debian/unpaper.docs unpaper-0.4.2/debian/unpaper.docs --- unpaper-0.3/debian/unpaper.docs 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/debian/unpaper.docs 2012-06-24 06:23:06.000000000 +0000 @@ -0,0 +1,2 @@ +doc/ +README diff -Nru unpaper-0.3/debian/unpaper.install unpaper-0.4.2/debian/unpaper.install --- unpaper-0.3/debian/unpaper.install 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/debian/unpaper.install 2012-06-23 04:13:02.000000000 +0000 @@ -0,0 +1 @@ +unpaper /usr/bin \ No newline at end of file diff -Nru unpaper-0.3/debian/unpaper.manpages unpaper-0.4.2/debian/unpaper.manpages --- unpaper-0.3/debian/unpaper.manpages 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/debian/unpaper.manpages 2012-06-23 04:13:02.000000000 +0000 @@ -0,0 +1 @@ +unpaper.1 \ No newline at end of file Binary files /tmp/TbWyLZsGYz/unpaper-0.3/debian/upstream_gpg_signatures/unpaper_0.4.2.orig.tar.xz.sig and /tmp/mW96iyvleP/unpaper-0.4.2/debian/upstream_gpg_signatures/unpaper_0.4.2.orig.tar.xz.sig differ diff -Nru unpaper-0.3/debian/watch unpaper-0.4.2/debian/watch --- unpaper-0.3/debian/watch 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/debian/watch 2012-06-23 04:13:02.000000000 +0000 @@ -0,0 +1,4 @@ +version=3 + +http://www.flameeyes.eu/projects/unpaper \ + /files/unpaper-([\d\.]+).tar.xz \ No newline at end of file diff -Nru unpaper-0.3/depcomp unpaper-0.4.2/depcomp --- unpaper-0.3/depcomp 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/depcomp 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,707 @@ +#! /bin/sh +# depcomp - compile a program generating dependencies as side-effects + +scriptversion=2012-03-27.16; # UTC + +# Copyright (C) 1999-2012 Free Software Foundation, Inc. + +# 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, 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 . + +# 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. + +# Originally written by Alexandre Oliva . + +case $1 in + '') + echo "$0: No command. Try '$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: depcomp [--help] [--version] PROGRAM [ARGS] + +Run PROGRAMS ARGS to compile a file, generating dependencies +as side-effects. + +Environment variables: + depmode Dependency tracking mode. + source Source file read by 'PROGRAMS ARGS'. + object Object file output by 'PROGRAMS ARGS'. + DEPDIR directory where to store dependencies. + depfile Dependency file to output. + tmpdepfile Temporary file to use when outputting dependencies. + libtool Whether libtool is used (yes/no). + +Report bugs to . +EOF + exit $? + ;; + -v | --v*) + echo "depcomp $scriptversion" + exit $? + ;; +esac + +# A tabulation character. +tab=' ' +# A newline character. +nl=' +' + +if test -z "$depmode" || test -z "$source" || test -z "$object"; then + echo "depcomp: Variables source, object and depmode must be set" 1>&2 + exit 1 +fi + +# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. +depfile=${depfile-`echo "$object" | + sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} + +rm -f "$tmpdepfile" + +# Some modes work just like other modes, but use different flags. We +# parameterize here, but still list the modes in the big case below, +# to make depend.m4 easier to write. Note that we *cannot* use a case +# here, because this file can only contain one case statement. +if test "$depmode" = hp; then + # HP compiler uses -M and no extra arg. + gccflag=-M + depmode=gcc +fi + +if test "$depmode" = dashXmstdout; then + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +cygpath_u="cygpath -u -f -" +if test "$depmode" = msvcmsys; then + # This is just like msvisualcpp but w/o cygpath translation. + # Just convert the backslash-escaped backslashes to single forward + # slashes to satisfy depend.m4 + cygpath_u='sed s,\\\\,/,g' + depmode=msvisualcpp +fi + +if test "$depmode" = msvc7msys; then + # This is just like msvc7 but w/o cygpath translation. + # Just convert the backslash-escaped backslashes to single forward + # slashes to satisfy depend.m4 + cygpath_u='sed s,\\\\,/,g' + depmode=msvc7 +fi + +if test "$depmode" = xlc; then + # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations. + gccflag=-qmakedep=gcc,-MF + depmode=gcc +fi + +case "$depmode" in +gcc3) +## gcc 3 implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. +## Unfortunately, FreeBSD c89 acceptance of flags depends upon +## the command line argument order; so add the flags where they +## appear in depend2.am. Note that the slowdown incurred here +## affects only configure: in makefiles, %FASTDEP% shortcuts this. + for arg + do + case $arg in + -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; + *) set fnord "$@" "$arg" ;; + esac + shift # fnord + shift # $arg + done + "$@" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## There are various ways to get dependency output from gcc. Here's +## why we pick this rather obscure method: +## - Don't want to use -MD because we'd like the dependencies to end +## up in a subdir. Having to rename by hand is ugly. +## (We might end up doing this anyway to support other compilers.) +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +## -MM, not -M (despite what the docs say). +## - Using -M directly means running the compiler twice (even worse +## than renaming). + if test -z "$gccflag"; then + gccflag=-MD, + fi + "$@" -Wp,"$gccflag$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz +## The second -e expression handles DOS-style file names with drive letters. + sed -e 's/^[^:]*: / /' \ + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" +## This next piece of magic avoids the "deleted header file" problem. +## The problem is that when a header file which appears in a .P file +## is deleted, the dependency causes make to die (because there is +## typically no way to rebuild the header). We avoid this by adding +## dummy dependencies for each header file. Too bad gcc doesn't do +## this for us directly. + tr ' ' "$nl" < "$tmpdepfile" | +## Some versions of gcc put a space before the ':'. On the theory +## that the space means something, we add a space to the output as +## well. hp depmode also adds that space, but also prefixes the VPATH +## to the object. Take care to not repeat it in the output. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +sgi) + if test "$libtool" = yes; then + "$@" "-Wp,-MDupdate,$tmpdepfile" + else + "$@" -MDupdate "$tmpdepfile" + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files + echo "$object : \\" > "$depfile" + + # Clip off the initial element (the dependent). Don't try to be + # clever and replace this with sed code, as IRIX sed won't handle + # lines with more than a fixed number of characters (4096 in + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; + # the IRIX cc adds comments like '#:fec' to the end of the + # dependency line. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ + tr "$nl" ' ' >> "$depfile" + echo >> "$depfile" + + # The second pass generates a dummy entry for each header file. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> "$depfile" + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +xlc) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +aix) + # The C for AIX Compiler uses -M and outputs the dependencies + # in a .u file. In older versions, this file always lives in the + # current directory. Also, the AIX compiler puts '$object:' at the + # start of each line; $object doesn't have directory information. + # Version 6 uses the directory in both cases. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.u + tmpdepfile2=$base.u + tmpdepfile3=$dir.libs/$base.u + "$@" -Wc,-M + else + tmpdepfile1=$dir$base.u + tmpdepfile2=$dir$base.u + tmpdepfile3=$dir$base.u + "$@" -M + fi + stat=$? + + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + # Each line is of the form 'foo.o: dependent.h'. + # Do two passes, one to just change these to + # '$object: dependent.h' and one to simply 'dependent.h:'. + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +icc) + # Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'. + # However on + # $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c + # ICC 7.0 will fill foo.d with something like + # foo.o: sub/foo.c + # foo.o: sub/foo.h + # which is wrong. We want + # sub/foo.o: sub/foo.c + # sub/foo.o: sub/foo.h + # sub/foo.c: + # sub/foo.h: + # ICC 7.1 will output + # foo.o: sub/foo.c sub/foo.h + # and will wrap long lines using '\': + # foo.o: sub/foo.c ... \ + # sub/foo.h ... \ + # ... + # tcc 0.9.26 (FIXME still under development at the moment of writing) + # will emit a similar output, but also prepend the continuation lines + # with horizontal tabulation characters. + "$@" -MD -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each line is of the form 'foo.o: dependent.h', + # or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'. + # Do two passes, one to just change these to + # '$object: dependent.h' and one to simply 'dependent.h:'. + sed -e "s/^[ $tab][ $tab]*/ /" -e "s,^[^:]*:,$object :," \ + < "$tmpdepfile" > "$depfile" + sed ' + s/[ '"$tab"'][ '"$tab"']*/ /g + s/^ *// + s/ *\\*$// + s/^[^:]*: *// + /^$/d + /:$/d + s/$/ :/ + ' < "$tmpdepfile" >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp2) + # The "hp" stanza above does not work with aCC (C++) and HP's ia64 + # compilers, which have integrated preprocessors. The correct option + # to use with these is +Maked; it writes dependencies to a file named + # 'foo.d', which lands next to the object file, wherever that + # happens to be. + # Much of this is similar to the tru64 case; see comments there. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir.libs/$base.d + "$@" -Wc,+Maked + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + "$@" +Maked + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" + # Add 'dependent.h:' lines. + sed -ne '2,${ + s/^ *// + s/ \\*$// + s/$/:/ + p + }' "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" "$tmpdepfile2" + ;; + +tru64) + # The Tru64 compiler uses -MD to generate dependencies as a side + # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in 'foo.d' instead, so we check for that too. + # Subdirectories are respected. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + + if test "$libtool" = yes; then + # With Tru64 cc, shared objects can also be used to make a + # static library. This mechanism is used in libtool 1.4 series to + # handle both shared and static libraries in a single compilation. + # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. + # + # With libtool 1.5 this exception was removed, and libtool now + # generates 2 separate objects for the 2 libraries. These two + # compilations output dependencies in $dir.libs/$base.o.d and + # in $dir$base.o.d. We have to check for both files, because + # one of the two compilations can be disabled. We should prefer + # $dir$base.o.d over $dir.libs/$base.o.d because the latter is + # automatically cleaned when .libs/ is deleted, while ignoring + # the former would cause a distcleancheck panic. + tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 + tmpdepfile2=$dir$base.o.d # libtool 1.5 + tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 + tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 + "$@" -Wc,-MD + else + tmpdepfile1=$dir$base.o.d + tmpdepfile2=$dir$base.d + tmpdepfile3=$dir$base.d + tmpdepfile4=$dir$base.d + "$@" -MD + fi + + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +msvc7) + if test "$libtool" = yes; then + showIncludes=-Wc,-showIncludes + else + showIncludes=-showIncludes + fi + "$@" $showIncludes > "$tmpdepfile" + stat=$? + grep -v '^Note: including file: ' "$tmpdepfile" + if test "$stat" = 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + # The first sed program below extracts the file names and escapes + # backslashes for cygpath. The second sed program outputs the file + # name when reading, but also accumulates all include files in the + # hold buffer in order to output them again at the end. This only + # works with sed implementations that can handle large buffers. + sed < "$tmpdepfile" -n ' +/^Note: including file: *\(.*\)/ { + s//\1/ + s/\\/\\\\/g + p +}' | $cygpath_u | sort -u | sed -n ' +s/ /\\ /g +s/\(.*\)/'"$tab"'\1 \\/p +s/.\(.*\) \\/\1:/ +H +$ { + s/.*/'"$tab"'/ + G + p +}' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvc7msys) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +#nosideeffect) + # This comment above is used by automake to tell side-effect + # dependency tracking mechanisms from slower ones. + +dashmstdout) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + + # Remove '-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + test -z "$dashmflag" && dashmflag=-M + # Require at least two characters before searching for ':' + # in the target name. This is to cope with DOS-style filenames: + # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. + "$@" $dashmflag | + sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + tr ' ' "$nl" < "$tmpdepfile" | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +dashXmstdout) + # This case only exists to satisfy depend.m4. It is never actually + # run, as this mode is specially recognized in the preamble. + exit 1 + ;; + +makedepend) + "$@" || exit $? + # Remove any Libtool call + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + # X makedepend + shift + cleared=no eat=no + for arg + do + case $cleared in + no) + set ""; shift + cleared=yes ;; + esac + if test $eat = yes; then + eat=no + continue + fi + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift ;; + # Strip any option that makedepend may not understand. Remove + # the object too, otherwise makedepend will parse it as a source file. + -arch) + eat=yes ;; + -*|$object) + ;; + *) + set fnord "$@" "$arg"; shift ;; + esac + done + obj_suffix=`echo "$object" | sed 's/^.*\././'` + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" + rm -f "$depfile" + # makedepend may prepend the VPATH from the source file name to the object. + # No need to regex-escape $object, excess matching of '.' is harmless. + sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" + sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" "$tmpdepfile".bak + ;; + +cpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + + # Remove '-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + "$@" -E | + sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | + sed '$ s: \\$::' > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + cat < "$tmpdepfile" >> "$depfile" + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvisualcpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + + IFS=" " + for arg + do + case "$arg" in + -o) + shift + ;; + $object) + shift + ;; + "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") + set fnord "$@" + shift + shift + ;; + *) + set fnord "$@" "$arg" + shift + shift + ;; + esac + done + "$@" -E 2>/dev/null | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" + echo "$tab" >> "$depfile" + sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvcmsys) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +none) + exec "$@" + ;; + +*) + echo "Unknown depmode $depmode" 1>&2 + exit 1 + ;; +esac + +exit 0 + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff -Nru unpaper-0.3/doc/index.html unpaper-0.4.2/doc/index.html --- unpaper-0.3/doc/index.html 2007-12-31 01:30:35.000000000 +0000 +++ unpaper-0.4.2/doc/index.html 2012-06-23 04:10:45.000000000 +0000 @@ -11,9 +11,7 @@

Licensed under the GNU General Public License (GPL). This software comes with no warranty.
Written by Jens Gulden 2005-2007 -
+

Overview
Download
@@ -631,50 +629,15 @@ processing with unpaper (see user documentation for details).

-

Donation

-
- If you -find this software useful please consider making a donation to the -project, -especially if you apply unpaper in -a professional context where it helps you doing a job you get paid for. -Click the button on the left to donate. For -alternative payment via bank transfer please - contact -the author. -
-Of course you do not have to donate, especially if you don't -have the spare money. The main purpose of this software is to help -everybody -getting better-quality electronic documents from scanned paper -documents. It is -completely acceptable and legal to use unpaper without -donating.

Related Links

Written by Jens Gulden 2005-2007 -
+
Modifications under the GPL are welcome.

-

-Hosted on -

diff -Nru unpaper-0.3/doc/unpaper.html unpaper-0.4.2/doc/unpaper.html --- unpaper-0.3/doc/unpaper.html 2007-12-05 16:29:36.000000000 +0000 +++ unpaper-0.4.2/doc/unpaper.html 2012-06-23 04:10:45.000000000 +0000 @@ -6,7 +6,6 @@ unpaper - User Documentation - @@ -754,9 +753,7 @@ 21, 22, 23, etc. until 28, and 40.

Written by Jens Gulden 2006-2007 -
+
Modifications under the GPL are welcome.

diff -Nru unpaper-0.3/file.c unpaper-0.4.2/file.c --- unpaper-0.3/file.c 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/file.c 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,295 @@ +/* + * This file is part of Unpaper. + * + * Copyright © 2005-2007 Jens Gulden + * Copyright © 2011-2011 Diego Elio Pettenò + * + * Unpaper 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, version 2 of the License. + * + * Unpaper 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 . + */ + +/* --- tool functions for file handling ------------------------------------ */ + +#include +#include +#include +#include + +#include "unpaper.h" +#include "tools.h" //only needed for getPixelGrayscale + +/** + * Loads image data from a file in pnm format. + * + * @param f file to load + * @param image structure to hold loaded image + * @param type returns the type of the loaded image + * @return true on success, false on failure + */ +void loadImage(FILE *f, struct IMAGE* image, int* type) { + int bytesPerLine; + char magic[10]; + char word[255]; + char c; + int maxColorIndex; + int inputSize; + int read; + uint8_t* buffer2; + int lineOffsetInput; + int lineOffsetOutput; + int x; + int y; + int bb; + int off; + int bits; + int bit; + int pixel; + int size; + int pos; + uint8_t* p; + uint8_t r, g, b; + + // read magic number + fread(magic, 1, 2, f); + magic[2] = 0; // terminate + if (strcmp(magic, "P4")==0) { + *type = PBM; + image->bitdepth = 1; + image->color = false; + } else if (strcmp(magic, "P5")==0) { + *type = PGM; + image->bitdepth = 8; + image->color = false; + } else if (strcmp(magic, "P6")==0) { + *type = PPM; + image->bitdepth = 8; + image->color = true; + } else { + printf("*** error: input file format using magic '%s' is unknown.\n", magic); + return; + } + + // get image info: width, height, optionally depth + fgetc(f); // skip \n after magic number + fscanf(f, "%s", word); + while (word[0]=='#') { // skip comment lines + do { + fscanf(f, "%c", &c); + } while ((feof(f)==0)&&(c!='\n')); + fscanf(f, "%s", word); + } + // now reached width/height pair as decimal ascii + sscanf(word, "%d", &image->width); + fscanf(f, "%d", &image->height); + fgetc(f); // skip \n after width/height pair + if (*type == PBM) { + bytesPerLine = (image->width + 7) / 8; + } else { // PGM or PPM + fscanf(f, "%s", word); + while (word[0]=='#') { // skip comment lines + do { + fscanf(f, "%c", &c); + } while ((feof(f) == 0) && (c != '\n')); + fscanf(f, "%s", word); + } + // read max color value + sscanf(word, "%d", &maxColorIndex); + fgetc(f); // skip \n after max color index + if (maxColorIndex > 255) { + printf("*** error: grayscale / color-component bit depths above 8 are not supported.\n"); + return; + } + bytesPerLine = image->width; + if (*type == PPM) { + bytesPerLine *= 3; // 3 color-components per pixel + } + } + + // read binary image data + inputSize = bytesPerLine * image->height; + + image->buffer = (uint8_t*)malloc(inputSize); + read = fread(image->buffer, 1, inputSize, f); + if (read != inputSize) { + printf("*** error: Only %d out of %d could be read.\n", read, inputSize); + return; + } + + if (*type == PBM) { // internally convert b&w to 8-bit for processing + buffer2 = (uint8_t*)malloc(image->width * image->height); + lineOffsetInput = 0; + lineOffsetOutput = 0; + for (y = 0; y < image->height; y++) { + for (x = 0; x < image->width; x++) { + bb = x >> 3; // x / 8; + off = x & 7; // x % 8; + bit = 128>>off; + bits = image->buffer[lineOffsetInput + bb]; + bits &= bit; + if (bits == 0) { // 0: white pixel + pixel = 0xff; + } else { + pixel = 0x00; + } + buffer2[lineOffsetOutput+x] = pixel; // set as whole byte + } + lineOffsetInput += bytesPerLine; + lineOffsetOutput += image->width; + } + free(image->buffer); + image->buffer = buffer2; + } + + if (*type == PPM) { + // init cached values for grayscale, lightness and darknessInverse + size = image->width * image->height; + image->bufferGrayscale = (uint8_t*)malloc(size); + image->bufferLightness = (uint8_t*)malloc(size); + image->bufferDarknessInverse = (uint8_t*)malloc(size); + p = image->buffer; + for (pos = 0; pos < size; pos++) { + r = *p; + p++; + g = *p; + p++; + b = *p; + p++; + image->bufferGrayscale[pos] = pixelGrayscale(r, g, b); + image->bufferLightness[pos] = pixelLightness(r, g, b); + image->bufferDarknessInverse[pos] = pixelDarknessInverse(r, g, b); + } + } else { + image->bufferGrayscale = image->buffer; + image->bufferLightness = image->buffer; + image->bufferDarknessInverse = image->buffer; + } +} + + +/** + * Saves image data to a file in pgm or pbm format. + * + * @param outputFile file to save image to + * @param image image to save + * @param type filetype of the image to save + * @param blackThreshold threshold for grayscale-to-black&white conversion + * @return true on success, false on failure + */ +void saveImage(FILE *outputFile, struct IMAGE* image, int type, float blackThreshold) { + uint8_t* buf; + int bytesPerLine; + int inputSize; + int outputSize; + int lineOffsetOutput; + int offsetInput; + int offsetOutput; + int x; + int y; + int pixel; + int b; + int off; + uint8_t bit; + uint8_t val; + const char* outputMagic; + int blackThresholdAbs; + + if (type == PBM) { // convert to pbm + blackThresholdAbs = WHITE * (1.0 - blackThreshold); + bytesPerLine = (image->width + 7) >> 3; // / 8; + outputSize = bytesPerLine * image->height; + buf = (uint8_t*)malloc(outputSize); + memset(buf, 0, outputSize); + lineOffsetOutput = 0; + for (y = 0; y < image->height; y++) { + for (x = 0; x < image->width; x++) { + pixel = getPixelGrayscale(x, y, image); + b = x >> 3; // / 8; + off = x & 7; // % 8; + bit = 128>>off; + val = buf[lineOffsetOutput + b]; + if (pixel < blackThresholdAbs) { // dark + val |= bit; // set bit to one: black + } else { // bright + val &= (~bit); // set bit to zero: white + } + buf[lineOffsetOutput+b] = val; + } + lineOffsetOutput += bytesPerLine; + } + } else if (type == PPM) { // maybe convert to color + outputSize = image->width * image->height * 3; + if (image->color) { // color already + buf = image->buffer; + } else { // convert to color + buf = (uint8_t*)malloc(outputSize); + inputSize = image->width * image->height; + offsetOutput = 0; + for (offsetInput = 0; offsetInput < inputSize; offsetInput++) { + pixel = image->buffer[offsetInput]; + buf[offsetOutput++] = pixel; + buf[offsetOutput++] = pixel; + buf[offsetOutput++] = pixel; + } + } + } else { // PGM + outputSize = image->width * image->height; + buf = image->buffer; + } + + switch (type) { + case PBM: + outputMagic = "P4"; + break; + case PPM: + outputMagic = "P6"; + break; + default: // PGM + outputMagic = "P5"; + break; + } + + // write to file + fprintf(outputFile, "%s\n", outputMagic); + fprintf(outputFile, "# generated by unpaper\n"); + fprintf(outputFile, "%u %u\n", image->width, image->height); + if ((type == PGM)||(type == PPM)) { + fprintf(outputFile, "255\n"); // maximum color index per color-component + } + fwrite(buf, 1, outputSize, outputFile); + + if (buf != image->buffer) { + free(buf); + } +} + + +/** + * Saves the image if full debugging mode is enabled. + */ +void saveDebug(char* filename, struct IMAGE* image) { + int type; + + if (verbose >= VERBOSE_DEBUG_SAVE) { + FILE *f = fopen(filename, "w"); + + if (image->color) { + type = PPM; + } else if (image->bitdepth == 1) { + type = PBM; + } else { + type = PGM; + } + saveImage(f, image, type, 0.5); // 0.5 is a dummy, not used because PGM depth + + fclose(f); + } +} diff -Nru unpaper-0.3/file.h unpaper-0.4.2/file.h --- unpaper-0.3/file.h 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/file.h 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,26 @@ +/* + * This file is part of Unpaper. + * + * Copyright © 2005-2007 Jens Gulden + * Copyright © 2011-2011 Diego Elio Pettenò + * + * Unpaper 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, version 2 of the License. + * + * Unpaper 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 . + */ + +/* --- tool function for file handling ------------------------------------ */ + +bool loadImage(FILE *f, struct IMAGE* image, int* type); + +bool saveImage(FILE *outputFile, struct IMAGE* image, int type, float blackThreshold); + +void saveDebug(char* filename, struct IMAGE* image); diff -Nru unpaper-0.3/imageprocess.c unpaper-0.4.2/imageprocess.c --- unpaper-0.3/imageprocess.c 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/imageprocess.c 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,1344 @@ +/* + * This file is part of Unpaper. + * + * Copyright © 2005-2007 Jens Gulden + * Copyright © 2011-2011 Diego Elio Pettenò + * + * Unpaper 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, version 2 of the License. + * + * Unpaper 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 . + */ + +/* --- image processing --------------------------------------------------- */ + +#include +#include +#include +#include +#include +//#include + +#include "unpaper.h" +#include "tools.h" +#include "parse.h" //for maksOverlapAny + + +/**************************************************************************** + * image processing functions * + ****************************************************************************/ + + +/* --- deskewing ---------------------------------------------------------- */ + +/** + * Returns the maximum peak value that occurs when shifting a rotated virtual line above the image, + * starting from one edge of an area and moving towards the middle point of the area. + * The peak value is calulated by the absolute difference in the average blackness of pixels that occurs between two single shifting steps. + * + * @param m ascending slope of the virtually shifted (m=tan(angle)). Mind that this is negative for negative radians. + */ +static int detectEdgeRotationPeak(double m, int deskewScanSize, float deskewScanDepth, int shiftX, int shiftY, int left, int top, int right, int bottom, struct IMAGE* image) { + int width; + int height; + int mid; + int half; + int sideOffset; + int outerOffset; + double X; // unrounded coordinates + double Y; + double stepX; + double stepY; + int x[MAX_ROTATION_SCAN_SIZE]; + int y[MAX_ROTATION_SCAN_SIZE]; + int xx; + int yy; + int lineStep; + int dep; + int pixel; + int blackness; + int lastBlackness; + int diff; + int maxDiff; + int maxBlacknessAbs; + int maxDepth; + int accumulatedBlackness; + + width = right-left+1; + height = bottom-top+1; + maxBlacknessAbs = (int) 255 * deskewScanSize * deskewScanDepth; + + if (shiftY==0) { // horizontal detection + if (deskewScanSize == -1) { + deskewScanSize = height; + } + limit(&deskewScanSize, MAX_ROTATION_SCAN_SIZE); + limit(&deskewScanSize, height); + + maxDepth = width/2; + half = deskewScanSize/2; + outerOffset = (int)(abs(m) * half); + mid = height/2; + sideOffset = shiftX > 0 ? left-outerOffset : right+outerOffset; + X = sideOffset + half * m; + Y = top + mid - half; + stepX = -m; + stepY = 1.0; + } else { // vertical detection + if (deskewScanSize == -1) { + deskewScanSize = width; + } + limit(&deskewScanSize, MAX_ROTATION_SCAN_SIZE); + limit(&deskewScanSize, width); + maxDepth = height/2; + half = deskewScanSize/2; + outerOffset = (int)(abs(m) * half); + mid = width/2; + sideOffset = shiftY > 0 ? top-outerOffset : bottom+outerOffset; + X = left + mid - half; + Y = sideOffset - (half * m); + stepX = 1.0; + stepY = -m; // (line goes upwards for negative degrees) + } + + // fill buffer with coordinates for rotated line in first unshifted position + for (lineStep = 0; lineStep < deskewScanSize; lineStep++) { + x[lineStep] = (int)X; + y[lineStep] = (int)Y; + X += stepX; + Y += stepY; + } + + // now scan for edge, modify coordinates in buffer to shift line into search direction (towards the middle point of the area) + // stop either when detectMaxDepth steps are shifted, or when diff falls back to less than detectThreshold*maxDiff + lastBlackness = 0; + diff = 0; + maxDiff = 0; + accumulatedBlackness = 0; + for (dep = 0; (accumulatedBlackness < maxBlacknessAbs) && (dep < maxDepth) ; dep++) { + // calculate blackness of virtual line + blackness = 0; + for (lineStep = 0; lineStep < deskewScanSize; lineStep++) { + xx = x[lineStep]; + x[lineStep] += shiftX; + yy = y[lineStep]; + y[lineStep] += shiftY; + if ((xx >= left) && (xx <= right) && (yy >= top) && (yy <= bottom)) { + pixel = getPixelDarknessInverse(xx, yy, image); + blackness += (255 - pixel); + } + } + diff = blackness - lastBlackness; + lastBlackness = blackness; + if (diff >= maxDiff) { + maxDiff = diff; + } + accumulatedBlackness += blackness; + } + if (dep < maxDepth) { // has not terminated only because middle was reached + return maxDiff; + } else { + return 0; + } +} + + +/** + * Detects rotation at one edge of the area specified by left, top, right, bottom. + * Which of the four edges to take depends on whether shiftX or shiftY is non-zero, + * and what sign this shifting value has. + */ +static double detectEdgeRotation(float deskewScanRange, float deskewScanStep, int deskewScanSize, float deskewScanDepth, int shiftX, int shiftY, int left, int top, int right, int bottom, struct IMAGE* image) { + // either shiftX or shiftY is 0, the other value is -i|+i + // depending on shiftX/shiftY the start edge for shifting is determined + double rangeRad; + double stepRad; + double rotation; + int peak; + int maxPeak; + double detectedRotation; + double m; + + rangeRad = degreesToRadians((double)deskewScanRange); + stepRad = degreesToRadians((double)deskewScanStep); + detectedRotation = 0.0; + maxPeak = 0; + // iteratively increase test angle, alterating between +/- sign while increasing absolute value + for (rotation = 0.0; rotation <= rangeRad; rotation = (rotation>=0.0) ? -(rotation + stepRad) : -rotation ) { + m = tan(rotation); + peak = detectEdgeRotationPeak(m, deskewScanSize, deskewScanDepth, shiftX, shiftY, left, top, right, bottom, image); + if (peak > maxPeak) { + detectedRotation = rotation; + maxPeak = peak; + } + } + return radiansToDegrees(detectedRotation); +} + + +/** + * Detect rotation of a whole area. + * Angles between -deskewScanRange and +deskewScanRange are scanned, at either the + * horizontal or vertical edges of the area specified by left, top, right, bottom. + */ +double detectRotation(int deskewScanEdges, int deskewScanRange, float deskewScanStep, int deskewScanSize, float deskewScanDepth, float deskewScanDeviation, int left, int top, int right, int bottom, struct IMAGE* image) { + double rotation[4]; + int count; + double total; + double average; + double deviation; + int i; + + count = 0; + + if ((deskewScanEdges & 1<= VERBOSE_NORMAL) { + printf("detected rotation left: [%d,%d,%d,%d]: %f\n", left,top,right,bottom, rotation[count]); + } + count++; + } + if ((deskewScanEdges & 1<= VERBOSE_NORMAL) { + printf("detected rotation top: [%d,%d,%d,%d]: %f\n", left,top,right,bottom, rotation[count]); + } + count++; + } + if ((deskewScanEdges & 1<= VERBOSE_NORMAL) { + printf("detected rotation right: [%d,%d,%d,%d]: %f\n", left,top,right,bottom, rotation[count]); + } + count++; + } + if ((deskewScanEdges & 1<= VERBOSE_NORMAL) { + printf("detected rotation bottom: [%d,%d,%d,%d]: %f\n", left,top,right,bottom, rotation[count]); + } + count++; + } + + total = 0.0; + for (i = 0; i < count; i++) { + total += rotation[i]; + } + average = total / count; + total = 0.0; + for (i = 0; i < count; i++) { + total += sqr(rotation[i]-average); + } + deviation = sqrt(total); + if (verbose >= VERBOSE_NORMAL) { + printf("rotation average: %f deviation: %f rotation-scan-deviation (maximum): %f [%d,%d,%d,%d]\n", average, deviation, deskewScanDeviation, left,top,right,bottom); + } + if (deviation <= deskewScanDeviation) { + return average; + } else { + if (verbose >= VERBOSE_NONE) { + printf("out of deviation range - NO ROTATING\n"); + } + return 0.0; + } +} + +/** + * Rotates a whole image buffer by the specified radians, around its middle-point. + * Usually, the buffer should have been converted to a qpixels-representation before, to increase quality. + * (To rotate parts of an image, extract the part with copyBuffer, rotate, and re-paste with copyBuffer.) + */ +//void rotate(double radians, struct IMAGE* source, struct IMAGE* target, double* trigonometryCache, int trigonometryCacheBaseSize) { +void rotate(double radians, struct IMAGE* source, struct IMAGE* target) { + const int w = source->width; + const int h = source->height; + const int halfX = (w-1)/2; + const int halfY = (h-1)/2; + const int midX = w/2; + const int midY = h/2; + const int midMax = max(midX,midY); + + // create 2D rotation matrix + const float sinval = sinf(radians); + const float cosval = cosf(radians); + const float m11 = cosval; + const float m12 = sinval; + const float m21 = -sinval; + const float m22 = cosval; + + // step through all pixels of the target image, + // symmetrically in all four quadrants to reduce trigonometric calculations + int dX; + int dY; + + for (dY = 0; dY <= midMax; dY++) { + + for (dX = 0; dX <= midMax; dX++) { + // matrix multiplication to get rotated pixel pos (as in quadrant I) + const int diffX = dX * m11 + dY * m21; + const int diffY = dX * m12 + dY * m22; + + int x; + int y; + + // quadrant I + x = midX + dX; + y = midY - dY; + if ((x < w) && (y >= 0)) { + const int oldX = midX + diffX; + const int oldY = midY - diffY; + const int pixel = getPixel(oldX, oldY, source); + setPixel(pixel, x, y, target); + } + + // quadrant II + x = halfX - dY; + y = midY - dX; + if ((x >=0) && (y >= 0)) { + const int oldX = halfX - diffY; + const int oldY = midY - diffX; + const int pixel = getPixel(oldX, oldY, source); + setPixel(pixel, x, y, target); + } + + // quadrant III + x = halfX - dX; + y = halfY + dY; + if ((x >=0) && (y < h)) { + const int oldX = halfX - diffX; + const int oldY = halfY + diffY; + const int pixel = getPixel(oldX, oldY, source); + setPixel(pixel, x, y, target); + } + + // quadrant IV + x = midX + dY; + y = halfY + dX; + if ((x < w) && (y < h)) { + const int oldX = midX + diffY; + const int oldY = halfY + diffX; + const int pixel = getPixel(oldX, oldY, source); + setPixel(pixel, x, y, target); + } + } + } +} + + +/** + * Converts an image buffer to a qpixel-representation, i.e. enlarge the whole + * whole image both horizontally and vertically by factor 2 (leading to a + * factor 4 increase in total). + * qpixelBuf must have been allocated before with 4-times amount of memory as + * buf. + */ +void convertToQPixels(struct IMAGE* image, struct IMAGE* qpixelImage) { + int x; + int y; + + for (y = 0; y < image->height; y++) { + const int yy = y*2; + for (x = 0; x < image->width; x++) { + const int xx = x*2; + + const int pixel = getPixel(x, y, image); + + setPixel(pixel, xx, yy, qpixelImage); + setPixel(pixel, xx+1, yy, qpixelImage); + setPixel(pixel, xx, yy+1, qpixelImage); + setPixel(pixel, xx+1, yy+1, qpixelImage); + } + } +} + + +/** + * Converts an image buffer back from a qpixel-representation to normal, i.e. + * shrinks the whole image both horizontally and vertically by factor 2 + * (leading to a factor 4 decrease in total). + * buf must have been allocated before with 1/4-times amount of memory as + * qpixelBuf. + */ +void convertFromQPixels(struct IMAGE* qpixelImage, struct IMAGE* image) { + int x; + int y; + + for (y = 0; y < image->height; y++) { + const int yy = y*2; + for (x = 0; x < image->width; x++) { + const int xx = x*2; + + const int a = getPixel(xx, yy, qpixelImage); + const int b = getPixel(xx+1, yy, qpixelImage); + const int c = getPixel(xx, yy+1, qpixelImage); + const int d = getPixel(xx+1, yy+1, qpixelImage); + + const int r = (red(a) + red(b) + red(c) + red(d)) / 4; + const int g = (green(a) + green(b) + green(c) + green(d)) / 4; + const int bl = (blue(a) + blue(b) + blue(c) + blue(d)) / 4; + + const int pixel = pixelValue(r, g, bl); + + setPixel(pixel, x, y, image); + } + } +} + + +/* --- stretching / resizing / shifting ------------------------------------ */ + +/** + * Stretches the image so that the resulting image has a new size. + * + * @param w the new width to stretch to + * @param h the new height to stretch to + */ +void stretch(int w, int h, struct IMAGE* image) { + struct IMAGE newimage; + int x; + int y; + int matrixX; + int matrixY; + int matrixWidth; + int matrixHeight; + int blockWidth; + int blockHeight; + int blockWidthRest; + int blockHeightRest; + int fillIndexWidth; + int fillIndexHeight; + int fill; + int xx; + int yy; + int sum; + int sumR; + int sumG; + int sumB; + int sumCount; + int pixel; + + if (verbose >= VERBOSE_MORE) { + printf("stretching %dx%d -> %dx%d\n", image->width, image->height, w, h); + } + + // allocate new buffer's memory + initImage(&newimage, w, h, image->bitdepth, image->color, WHITE); + + blockWidth = image->width / w; // (0 if enlarging, i.e. w > image->width) + blockHeight = image->height / h; + + if (w <= image->width) { + blockWidthRest = (image->width) % w; + } else { // modulo-operator doesn't work as expected: (3680 % 7360)==3680 ! (not 7360 as expected) + // shouldn't always be a % b = b if a < b ? + blockWidthRest = w; + } + + if (h <= image->height) { + blockHeightRest = (image->height) % h; + } else { + blockHeightRest = h; + } + + // for each new pixel, get a matrix of pixels from which the new pixel should be derived + // (when enlarging, this matrix is always of size 1x1) + matrixY = 0; + fillIndexHeight = 0; + for (y = 0; y < h; y++) { + fillIndexWidth = 0; + matrixX = 0; + if ( ( (y * blockHeightRest) / h ) == fillIndexHeight ) { // next fill index? + // (If our optimizer is cool, the above "* blockHeightRest / h" will disappear + // when images are enlarged, because in that case blockHeightRest = h has been set before, + // thus we're in a Kripke-branch where blockHeightRest and h are the same variable. + // No idea if gcc's optimizer does this...) (See again below.) + fillIndexHeight++; + fill = 1; + } else { + fill = 0; + } + matrixHeight = blockHeight + fill; + for (x = 0; x < w; x++) { + if ( ( (x * blockWidthRest) / w ) == fillIndexWidth ) { // next fill index? + fillIndexWidth++; + fill = 1; + } else { + fill = 0; + } + matrixWidth = blockWidth + fill; + // if enlarging, map corrdinates directly + if (blockWidth == 0) { // enlarging + matrixX = (x * image->width) / w; + } + if (blockHeight == 0) { // enlarging + matrixY = (y * image->height) / h; + } + + // calculate average pixel value in source matrix + if ((matrixWidth == 1) && (matrixHeight == 1)) { // optimization: quick version + pixel = getPixel(matrixX, matrixY, image); + } else { + sumCount = 0; + if (!image->color) { + sum = 0; + for (yy = 0; yy < matrixHeight; yy++) { + for (xx = 0; xx < matrixWidth; xx++) { + sum += getPixelGrayscale(matrixX + xx, matrixY + yy, image); + sumCount++; + } + } + sum = sum / sumCount; + pixel = pixelGrayscaleValue(sum); + } else { // color + sumR = 0; + sumG = 0; + sumB = 0; + for (yy = 0; yy < matrixHeight; yy++) { + for (xx = 0; xx < matrixWidth; xx++) { + pixel = getPixel(matrixX + xx, matrixY + yy, image); + sumR += (pixel >> 16) & 0xff; + sumG += (pixel >> 8) & 0xff; + sumB += pixel & 0xff; + //sumR += getPixelComponent(matrixX + xx, matrixY + yy, RED, image); + //sumG += getPixelComponent(matrixX + xx, matrixY + yy, GREEN, image); + //sumB += getPixelComponent(matrixX + xx, matrixY + yy, BLUE, image); + sumCount++; + } + } + pixel = pixelValue( sumR/sumCount, sumG/sumCount, sumB/sumCount ); + } + } + setPixel(pixel, x, y, &newimage); + + // pixel may have resulted in a gray value, which will be converted to 1-bit + // when the file gets saved, if .pbm format requested. black-threshold will apply. + + if (blockWidth > 0) { // shrinking + matrixX += matrixWidth; + } + } + if (blockHeight > 0) { // shrinking + matrixY += matrixHeight; + } + } + replaceImage(image, &newimage); +} + +/** + * Resizes the image so that the resulting sheet has a new size and the image + * content is zoomed to fit best into the sheet, while keeping it's aspect ration. + * + * @param w the new width to resize to + * @param h the new height to resize to + */ +void resize(int w, int h, struct IMAGE* image) { + struct IMAGE newimage; + int ww; + int hh; + float wRat; + float hRat; + + if (verbose >= VERBOSE_NORMAL) { + printf("resizing %dx%d -> %dx%d\n", image->width, image->height, w, h); + } + + wRat = (float)w / image->width; + hRat = (float)h / image->height; + if (wRat < hRat) { // horizontally more shrinking/less enlarging is needed: fill width fully, adjust height + ww = w; + hh = image->height * w / image->width; + } else if (hRat < wRat) { + ww = image->width * h / image->height; + hh = h; + } else { // wRat == hRat + ww = w; + hh = h; + } + stretch(ww, hh, image); + initImage(&newimage, w, h, image->bitdepth, image->color, image->background); + centerImage(image, 0, 0, w, h, &newimage); + replaceImage(image, &newimage); +} + + +/** + * Shifts the image. + * + * @param shiftX horizontal shifting + * @param shiftY vertical shifting + */ +void shift(int shiftX, int shiftY, struct IMAGE* image) { + struct IMAGE newimage; + int x; + int y; + int pixel; + + // allocate new buffer's memory + initImage(&newimage, image->width, image->height, image->bitdepth, image->color, image->background); + + for (y = 0; y < image->height; y++) { + for (x = 0; x < image->width; x++) { + pixel = getPixel(x, y, image); + setPixel(pixel, x + shiftX, y + shiftY, &newimage); + } + } + replaceImage(image, &newimage); +} + + +/* --- mask-detection ----------------------------------------------------- */ + +/** + * Finds one edge of non-black pixels headig from one starting point towards edge direction. + * + * @return number of shift-steps until blank edge found + */ +static int detectEdge(int startX, int startY, int shiftX, int shiftY, int maskScanSize, int maskScanDepth, float maskScanThreshold, struct IMAGE* image) { + // either shiftX or shiftY is 0, the other value is -i|+i + int left; + int top; + int right; + int bottom; + + const int half = maskScanSize / 2; + int total = 0; + int count = 0; + + if (shiftY==0) { // vertical border is to be detected, horizontal shifting of scan-bar + if (maskScanDepth == -1) { + maskScanDepth = image->height; + } + const int halfDepth = maskScanDepth / 2; + left = startX - half; + top = startY - halfDepth; + right = startX + half; + bottom = startY + halfDepth; + } else { // horizontal border is to be detected, vertical shifting of scan-bar + if (maskScanDepth == -1) { + maskScanDepth = image->width; + } + const int halfDepth = maskScanDepth / 2; + left = startX - halfDepth; + top = startY - half; + right = startX + halfDepth; + bottom = startY + half; + } + + while (true) { // ! + const int blackness = 255 - brightnessRect(left, top, right, bottom, image); + total += blackness; + count++; + // is blackness below threshold*average? + if ((blackness < ((maskScanThreshold*total)/count))||(blackness==0)) { // this will surely become true when pos reaches the outside of the actual image area and blacknessRect() will deliver 0 because all pixels outside are considered white + return count; // ! return here, return absolute value of shifting difference + } + left += shiftX; + right += shiftX; + top += shiftY; + bottom += shiftY; + } +} + + +/** + * Detects a mask of white borders around a starting point. + * The result is returned via call-by-reference parameters left, top, right, bottom. + * + * @return the detected mask in left, top, right, bottom; or -1, -1, -1, -1 if no mask could be detected + */ +static bool detectMask(int startX, int startY, int maskScanDirections, int maskScanSize[DIRECTIONS_COUNT], int maskScanDepth[DIRECTIONS_COUNT], int maskScanStep[DIRECTIONS_COUNT], float maskScanThreshold[DIRECTIONS_COUNT], int maskScanMinimum[DIMENSIONS_COUNT], int maskScanMaximum[DIMENSIONS_COUNT], int* left, int* top, int* right, int* bottom, struct IMAGE* image) { + int width; + int height; + int half[DIRECTIONS_COUNT]; + bool success; + + half[HORIZONTAL] = maskScanSize[HORIZONTAL] / 2; + half[VERTICAL] = maskScanSize[VERTICAL] / 2; + if ((maskScanDirections & 1<width - 1; + } + if ((maskScanDirections & 1<height - 1; + } + + // if below minimum or above maximum, set to maximum + width = *right - *left; + height = *bottom - *top; + success = true; + if ( ((maskScanMinimum[WIDTH] != -1) && (width < maskScanMinimum[WIDTH])) || ((maskScanMaximum[WIDTH] != -1) && (width > maskScanMaximum[WIDTH])) ) { + width = maskScanMaximum[WIDTH] / 2; + *left = startX - width; + *right = startX + width; + success = false;; + } + if ( ((maskScanMinimum[HEIGHT] != -1) && (height < maskScanMinimum[HEIGHT])) || ((maskScanMaximum[HEIGHT] != -1) && (height > maskScanMaximum[HEIGHT])) ) { + height = maskScanMaximum[HEIGHT] / 2; + *top = startY - height; + *bottom = startY + height; + success = false; + } + return success; +} + + +/** + * Detects masks around the points specified in point[]. + * + * @param mask point to array into which detected masks will be stored + * @return number of masks stored in mask[][] + */ +int detectMasks(int mask[MAX_MASKS][EDGES_COUNT], bool maskValid[MAX_MASKS], int point[MAX_POINTS][COORDINATES_COUNT], int pointCount, int maskScanDirections, int maskScanSize[DIRECTIONS_COUNT], int maskScanDepth[DIRECTIONS_COUNT], int maskScanStep[DIRECTIONS_COUNT], float maskScanThreshold[DIRECTIONS_COUNT], int maskScanMinimum[DIMENSIONS_COUNT], int maskScanMaximum[DIMENSIONS_COUNT], struct IMAGE* image) { + int left; + int top; + int right; + int bottom; + int i; + int maskCount; + + maskCount = 0; + if (maskScanDirections != 0) { + for (i = 0; i < pointCount; i++) { + maskValid[i] = detectMask(point[i][X], point[i][Y], maskScanDirections, maskScanSize, maskScanDepth, maskScanStep, maskScanThreshold, maskScanMinimum, maskScanMaximum, &left, &top, &right, &bottom, image); + if (!(left==-1 || top==-1 || right==-1 || bottom==-1)) { + mask[maskCount][LEFT] = left; + mask[maskCount][TOP] = top; + mask[maskCount][RIGHT] = right; + mask[maskCount][BOTTOM] = bottom; + maskCount++; + if (verbose>=VERBOSE_NORMAL) { + printf("auto-masking (%d,%d): %d,%d,%d,%d", point[i][X], point[i][Y], left, top, right, bottom); + if (maskValid[i] == false) { // (mask had been auto-set to full page size) + printf(" (invalid detection, using full page size)"); + } + printf("\n"); + } + } else { + if (verbose>=VERBOSE_NORMAL) { + printf("auto-masking (%d,%d): NO MASK FOUND\n", point[i][X], point[i][Y]); + } + } + //if (maskValid[i] == false) { // (mask had been auto-set to full page size) + // if (verbose>=VERBOSE_NORMAL) { + // printf("auto-masking (%d,%d): NO MASK DETECTED\n", point[i][X], point[i][Y]); + // } + //} + } + } + return maskCount; +} + + +/** + * Permanently applies image masks. Each pixel which is not covered by at least + * one mask is set to maskColor. + */ +void applyMasks(int mask[MAX_MASKS][EDGES_COUNT], int maskCount, int maskColor, struct IMAGE* image) { + int x; + int y; + int i; + + if (maskCount<=0) { + return; + } + for (y=0; y < image->height; y++) { + for (x=0; x < image->width; x++) { + // in any mask? + bool m = false; + for (i=0; ((m==false) && (i=top && y<=bottom && x>=left && x<=right) { + m = true; + } + } + if (m == false) { + setPixel(maskColor, x, y, image); // delete: set to white + } + } + } +} + + +/* --- wiping ------------------------------------------------------------- */ + +/** + * Permanently wipes out areas of an images. Each pixel covered by a wipe-area + * is set to wipeColor. + */ +void applyWipes(int area[MAX_MASKS][EDGES_COUNT], int areaCount, int wipeColor, struct IMAGE* image) { + int x; + int y; + int i; + + for (i = 0; i < areaCount; i++) { + int count = 0; + for (y = area[i][TOP]; y <= area[i][BOTTOM]; y++) { + for (x = area[i][LEFT]; x <= area[i][RIGHT]; x++) { + if ( setPixel(wipeColor, x, y, image) ) { + count++; + } + } + } + if (verbose >= VERBOSE_MORE) { + printf("wipe [%d,%d,%d,%d]: %d pixels\n", area[i][LEFT], area[i][TOP], area[i][RIGHT], area[i][BOTTOM], count); + } + } +} + + +/* --- mirroring ---------------------------------------------------------- */ + +/** + * Mirrors an image either horizontally, vertically, or both. + */ +void mirror(int directions, struct IMAGE* image) { + int x; + int y; + + const bool horizontal = !!((directions & 1<width - 1) >> 1) : (image->width - 1); // w>>1 == (int)(w-0.5)/2 + int untilY = (vertical==true) ? ((image->height - 1) >> 1) : image->height - 1; + + for (y = 0; y <= untilY; y++) { + const int yy = (vertical==true) ? (image->height - y - 1) : y; + if ((vertical==true) && (horizontal==true) && (y == yy)) { // last middle line in odd-lined image mirrored both h and v + untilX = ((image->width - 1) >> 1); + } + for (x = 0; x <= untilX; x++) { + const int xx = (horizontal==true) ? (image->width - x - 1) : x; + const int pixel1 = getPixel(x, y, image); + const int pixel2 = getPixel(xx, yy, image); + setPixel(pixel2, x, y, image); + setPixel(pixel1, xx, yy, image); + } + } +} + + +/* --- flip-rotating ------------------------------------------------------ */ + +/** + * Rotates an image clockwise or anti-clockwise in 90-degrees. + * + * @param direction either -1 (rotate anti-clockwise) or 1 (rotate clockwise) + */ +void flipRotate(int direction, struct IMAGE* image) { + struct IMAGE newimage; + int x; + int y; + + initImage(&newimage, image->height, image->width, image->bitdepth, image->color, WHITE); // exchanged width and height + for (y = 0; y < image->height; y++) { + const int xx = ((direction > 0) ? image->height - 1 : 0) - y * direction; + for (x = 0; x < image->width; x++) { + const int yy = ((direction < 0) ? image->width - 1 : 0) + x * direction; + const int pixel = getPixel(x, y, image); + setPixel(pixel, xx, yy, &newimage); + } + } + replaceImage(image, &newimage); +} + + +/* --- blackfilter -------------------------------------------------------- */ + +/** + * Filters out solidly black areas scanning to one direction. + * + * @param stepX is 0 if stepY!=0 + * @param stepY is 0 if stepX!=0 + * @see blackfilter() + */ +static void blackfilterScan(int stepX, int stepY, int size, int dep, float threshold, int exclude[MAX_MASKS][EDGES_COUNT], int excludeCount, int intensity, float blackThreshold, struct IMAGE* image) { + int left; + int top; + int right; + int bottom; + int blackness; + int thresholdBlack; + int x; + int y; + int shiftX; + int shiftY; + int l, t, r, b; + int diffX; + int diffY; + int mask[EDGES_COUNT]; + bool alreadyExcludedMessage; + + thresholdBlack = (int)(WHITE * (1.0-blackThreshold)); + if (stepX != 0) { // horizontal scanning + left = 0; + top = 0; + right = size -1; + bottom = dep - 1; + shiftX = 0; + shiftY = dep; + } else { // vertical scanning + left = 0; + top = 0; + right = dep -1; + bottom = size - 1; + shiftX = dep; + shiftY = 0; + } + while ((left < image->width) && (top < image->height)) { // individual scanning "stripes" over the whole sheet + l = left; + t = top; + r = right; + b = bottom; + // make sure last stripe does not reach outside sheet, shift back inside (next +=shift will exit while-loop) + if (r >= image->width || b >= image->height) { + diffX = r-image->width+1; + diffY = b-image->height+1; + l -= diffX; + t -= diffY; + r -= diffX; + b -= diffY; + } + alreadyExcludedMessage = false; + while ((l < image->width) && (t < image->height)) { // single scanning "stripe" + blackness = 255 - darknessInverseRect(l, t, r, b, image); + if (blackness >= 255*threshold) { // found a solidly black area + mask[LEFT] = l; + mask[TOP] = t; + mask[RIGHT] = r; + mask[BOTTOM] = b; + if (! masksOverlapAny(mask, exclude, excludeCount) ) { + if (verbose >= VERBOSE_NORMAL) { + printf("black-area flood-fill: [%d,%d,%d,%d]\n", l, t, r, b); + alreadyExcludedMessage = false; + } + // start flood-fill in this area (on each pixel to make sure we get everything, in most cases first flood-fill from first pixel will delete all other black pixels in the area already) + for (y = t; y <= b; y++) { + for (x = l; x <= r; x++) { + floodFill(x, y, pixelValue(WHITE, WHITE, WHITE), 0, thresholdBlack, intensity, image); + } + } + } else { + if ((verbose >= VERBOSE_NORMAL) && (!alreadyExcludedMessage)) { + printf("black-area EXCLUDED: [%d,%d,%d,%d]\n", l, t, r, b); + alreadyExcludedMessage = true; // do this only once per scan-stripe, otherwise too many mesages + } + } + } + l += stepX; + t += stepY; + r += stepX; + b += stepY; + } + left += shiftX; + top += shiftY; + right += shiftX; + bottom += shiftY; + } +} + + +/** + * Filters out solidly black areas, as appearing on bad photocopies. + * A virtual bar of width 'size' and height 'depth' is horizontally moved + * above the middle of the sheet (or the full sheet, if depth ==-1). + */ +void blackfilter(int blackfilterScanDirections, int blackfilterScanSize[DIRECTIONS_COUNT], int blackfilterScanDepth[DIRECTIONS_COUNT], int blackfilterScanStep[DIRECTIONS_COUNT], float blackfilterScanThreshold, int blackfilterExclude[MAX_MASKS][EDGES_COUNT], int blackfilterExcludeCount, int blackfilterIntensity, float blackThreshold, struct IMAGE* image) { + if ((blackfilterScanDirections & 1<height; y++) { + for (x = 0; x < image->width; x++) { + pixel = getPixelDarknessInverse(x, y, image); + if (pixel < whiteMin) { // one dark pixel found + neighbors = countPixelNeighbors(x, y, intensity, whiteMin, image); // get number of non-light pixels in neighborhood + if (neighbors <= intensity) { // ...not more than 'intensity'? + clearPixelNeighbors(x, y, whiteMin, image); // delete area + count++; + } + } + } + } + return count; +} + + +/* --- blurfilter --------------------------------------------------------- */ + +/** + * Removes noise using a kind of blurfilter, as alternative to the noise + * filter. This algoithm counts pixels while 'shaking' the area to detect, + * and clears the area if the amount of white pixels exceeds whiteTreshold. + */ +int blurfilter(int blurfilterScanSize[DIRECTIONS_COUNT], int blurfilterScanStep[DIRECTIONS_COUNT], float blurfilterIntensity, float whiteThreshold, struct IMAGE* image) { + int whiteMin; + int left; + int top; + int right; + int bottom; + int count; + int maxLeft; + int maxTop; + int blocksPerRow; + int* prevCounts; // Number of dark pixels in previous row + int* curCounts; // Number of dark pixels in current row + int* nextCounts; // Number of dark pixels in next row + int block; // Number of block in row; Counting begins with 1 + int max; + int total; // Number of pixels in a block + int result; + + result = 0; + whiteMin = (int)(WHITE * whiteThreshold); + left = 0; + top = 0; + right = blurfilterScanSize[HORIZONTAL] - 1; + bottom = blurfilterScanSize[VERTICAL] - 1; + maxLeft = image->width - blurfilterScanSize[HORIZONTAL]; + maxTop = image->height - blurfilterScanSize[VERTICAL]; + + blocksPerRow = image->width / blurfilterScanSize[HORIZONTAL]; + // allocate one extra block left and right + prevCounts = calloc(blocksPerRow + 2, sizeof(int)); + curCounts = calloc(blocksPerRow + 2, sizeof(int)); + nextCounts = calloc(blocksPerRow + 2, sizeof(int)); + + total = blurfilterScanSize[HORIZONTAL] * blurfilterScanSize[VERTICAL]; + + block = 1; + for (left = 0; left <= maxLeft; left += blurfilterScanSize[HORIZONTAL]) { + curCounts[block] = countPixelsRect(left, top, right, bottom, 0, whiteMin, false, image); + block++; + right += blurfilterScanSize[HORIZONTAL]; + } + curCounts[0] = total; + curCounts[blocksPerRow] = total; + nextCounts[0] = total; + nextCounts[blocksPerRow] = total; + + // Loop through all blocks. For a block calculate the number of dark pixels in this block, the number of dark pixels in the block in the top-left corner and similarly for the block in the top-right, bottom-left and bottom-right corner. Take the maximum of these values. Clear the block if this number is not large enough compared to the total number of pixels in a block. + for (top = 0; top <= maxTop; top += blurfilterScanSize[HORIZONTAL]) { + left = 0; + right = blurfilterScanSize[HORIZONTAL] - 1; + nextCounts[0] = countPixelsRect(left, top+blurfilterScanStep[VERTICAL], right, bottom+blurfilterScanSize[VERTICAL], 0, whiteMin, false, image); + + block = 1; + for (left = 0; left <= maxLeft; left += blurfilterScanSize[HORIZONTAL]) { + // current block + count = curCounts[block]; + max = count; + // top left + count = prevCounts[block-1]; + if (count > max) { + max = count; + } + // top right + count = prevCounts[block+1]; + if (count > max) { + max = count; + } + // bottom left + count = nextCounts[block-1]; + if (count > max) { + max = count; + } + // bottom right (has still to be calculated) + nextCounts[block+1] = countPixelsRect(left+blurfilterScanSize[HORIZONTAL], top+blurfilterScanStep[VERTICAL], right+blurfilterScanSize[HORIZONTAL], bottom+blurfilterScanSize[VERTICAL], 0, whiteMin, false, image); + if (count > max) { + max = count; + } + if ((((float)max)/total) <= blurfilterIntensity) { // Not enough dark pixels + clearRect(left, top, right, bottom, image, WHITE); + result += curCounts[block]; + curCounts[block] = total; // Update information + } + + right += blurfilterScanSize[HORIZONTAL]; + block++; + } + + bottom += blurfilterScanSize[VERTICAL]; + //Switch Buffers + const int* tmpCounts; + tmpCounts = prevCounts; + prevCounts = curCounts; + curCounts = nextCounts; + nextCounts = (int*)tmpCounts; + } + free(prevCounts); + free(curCounts); + free(nextCounts); + + return result; +} + + +/* --- grayfilter --------------------------------------------------------- */ + +/** + * Clears areas which do not contain any black pixels, but some "gray shade" only. + * Two conditions have to apply before an area gets deleted: first, not a single black pixel may be contained, + * second, a minimum threshold of blackness must not be exceeded. + */ +int grayfilter(int grayfilterScanSize[DIRECTIONS_COUNT], int grayfilterScanStep[DIRECTIONS_COUNT], float grayfilterThreshold, float blackThreshold, struct IMAGE* image) { + int blackMax; + int left; + int top; + int right; + int bottom; + int count; + int lightness; + int thresholdAbs; + int result; + + result = 0; + blackMax = (int)(WHITE * (1.0-blackThreshold)); + thresholdAbs = (int)(WHITE * grayfilterThreshold); + left = 0; + top = 0; + right = grayfilterScanSize[HORIZONTAL] - 1; + bottom = grayfilterScanSize[VERTICAL] - 1; + + while (true) { // ! + count = countPixelsRect(left, top, right, bottom, 0, blackMax, false, image); + if (count == 0) { + lightness = lightnessRect(left, top, right, bottom, image); + if ((WHITE - lightness) < thresholdAbs) { // (lower threshold->more deletion) + result += clearRect(left, top, right, bottom, image, WHITE); + } + } + if (left < image->width) { // not yet at end of row + left += grayfilterScanStep[HORIZONTAL]; + right += grayfilterScanStep[HORIZONTAL]; + } else { // end of row + if (bottom >= image->height) { // has been last row + return result; // exit here + } + // next row: + left = 0; + right = grayfilterScanSize[HORIZONTAL] - 1; + top += grayfilterScanStep[VERTICAL]; + bottom += grayfilterScanStep[VERTICAL]; + } + } +} + + +/* --- border-detection --------------------------------------------------- */ + +/** + * Moves a rectangular area of pixels to be centered above the centerX, centerY coordinates. + */ +void centerMask(int centerX, int centerY, int left, int top, int right, int bottom, struct IMAGE* image) { + struct IMAGE newimage; + + const int width = right - left + 1; + const int height = bottom - top + 1; + const int targetX = centerX - width/2; + const int targetY = centerY - height/2; + if ((targetX >= 0) && (targetY >= 0) && ((targetX+width) <= image->width) && ((targetY+height) <= image->height)) { + if (verbose >= VERBOSE_NORMAL) { + printf("centering mask [%d,%d,%d,%d] (%d,%d): %d, %d\n", left, top, right, bottom, centerX, centerY, targetX-left, targetY-top); + } + initImage(&newimage, width, height, image->bitdepth, image->color, image->background); + copyImageArea(left, top, width, height, image, 0, 0, &newimage); + clearRect(left, top, right, bottom, image, image->background); + copyImageArea(0, 0, width, height, &newimage, targetX, targetY, image); + freeImage(&newimage); + } else { + if (verbose >= VERBOSE_NORMAL) { + printf("centering mask [%d,%d,%d,%d] (%d,%d): %d, %d - NO CENTERING (would shift area outside visible image)\n", left, top, right, bottom, centerX, centerY, targetX-left, targetY-top); + } + } +} + + +/** + * Moves a rectangular area of pixels to be centered inside a specified area coordinates. + */ +void alignMask(int mask[EDGES_COUNT], int outside[EDGES_COUNT], int direction, int margin[DIRECTIONS_COUNT], struct IMAGE* image) { + struct IMAGE newimage; + int targetX; + int targetY; + + const int width = mask[RIGHT] - mask[LEFT] + 1; + const int height = mask[BOTTOM] - mask[TOP] + 1; + if (direction & 1<= VERBOSE_NORMAL) { + printf("aligning mask [%d,%d,%d,%d] (%d,%d): %d, %d\n", mask[LEFT], mask[TOP], mask[RIGHT], mask[BOTTOM], targetX, targetY, targetX - mask[LEFT], targetY - mask[TOP]); + } + initImage(&newimage, width, height, image->bitdepth, image->color, image->background); + copyImageArea(mask[LEFT], mask[TOP], mask[RIGHT], mask[BOTTOM], image, 0, 0, &newimage); + clearRect(mask[LEFT], mask[TOP], mask[RIGHT], mask[BOTTOM], image, image->background); + copyImageArea(0, 0, width, height, &newimage, targetX, targetY, image); + freeImage(&newimage); +} + + +/** + * Find the size of one border edge. + * + * @param x1..y2 area inside of which border is to be detected + */ +static int detectBorderEdge(int outsideMask[EDGES_COUNT], int stepX, int stepY, int size, int threshold, int maxBlack, struct IMAGE* image) { + int left; + int top; + int right; + int bottom; + int max; + int cnt; + int result; + + if (stepY == 0) { // horizontal detection + if (stepX > 0) { + left = outsideMask[LEFT]; + top = outsideMask[TOP]; + right = outsideMask[LEFT] + size; + bottom = outsideMask[BOTTOM]; + } else { + left = outsideMask[RIGHT] - size; + top = outsideMask[TOP]; + right = outsideMask[RIGHT]; + bottom = outsideMask[BOTTOM]; + } + max = (outsideMask[RIGHT] - outsideMask[LEFT]); + } else { // vertical detection + if (stepY > 0) { + left = outsideMask[LEFT]; + top = outsideMask[TOP]; + right = outsideMask[RIGHT]; + bottom = outsideMask[TOP] + size; + } else { + left = outsideMask[LEFT]; + top = outsideMask[BOTTOM] - size; + right = outsideMask[RIGHT]; + bottom = outsideMask[BOTTOM]; + } + max = (outsideMask[BOTTOM] - outsideMask[TOP]); + } + result = 0; + while (result < max) { + cnt = countPixelsRect(left, top, right, bottom, 0, maxBlack, false, image); + if (cnt >= threshold) { + return result; // border has been found: regular exit here + } + left += stepX; + top += stepY; + right += stepX; + bottom += stepY; + result += abs(stepX+stepY); // (either stepX or stepY is 0) + } + return 0; // no border found between 0..max +} + + +/** + * Detects a border of completely non-black pixels around the area outsideBorder[LEFT],outsideBorder[TOP]-outsideBorder[RIGHT],outsideBorder[BOTTOM]. + */ +void detectBorder(int border[EDGES_COUNT], int borderScanDirections, int borderScanSize[DIRECTIONS_COUNT], int borderScanStep[DIRECTIONS_COUNT], int borderScanThreshold[DIRECTIONS_COUNT], float blackThreshold, int outsideMask[EDGES_COUNT], struct IMAGE* image) { + int blackThresholdAbs; + + border[LEFT] = outsideMask[LEFT]; + border[TOP] = outsideMask[TOP]; + border[RIGHT] = image->width - outsideMask[RIGHT]; + border[BOTTOM] = image->height - outsideMask[BOTTOM]; + + blackThresholdAbs = (int)(WHITE * (1.0 - blackThreshold)); + if (borderScanDirections & 1<= VERBOSE_NORMAL) { + printf("border detected: (%d,%d,%d,%d) in [%d,%d,%d,%d]\n", border[LEFT], border[TOP], border[RIGHT], border[BOTTOM], outsideMask[LEFT], outsideMask[TOP], outsideMask[RIGHT], outsideMask[BOTTOM]); + } +} + + +/** + * Converts a border-tuple to a mask-tuple. + */ +void borderToMask(int border[EDGES_COUNT], int mask[EDGES_COUNT], struct IMAGE* image) { + mask[LEFT] = border[LEFT]; + mask[TOP] = border[TOP]; + mask[RIGHT] = image->width - border[RIGHT] - 1; + mask[BOTTOM] = image->height - border[BOTTOM] - 1; + if (verbose >= VERBOSE_DEBUG) { + printf("border [%d,%d,%d,%d] -> mask [%d,%d,%d,%d]\n", border[LEFT], border[TOP], border[RIGHT], border[BOTTOM], mask[LEFT], mask[TOP], mask[RIGHT], mask[BOTTOM]); + } +} + + +/** + * Applies a border to the whole image. All pixels in the border range at the + * edges of the sheet will be cleared. + */ +void applyBorder(int border[EDGES_COUNT], int borderColor, struct IMAGE* image) { + int mask[EDGES_COUNT]; + + if (border[LEFT]!=0 || border[TOP]!=0 || border[RIGHT]!=0 || border[BOTTOM]!=0) { + borderToMask(border, mask, image); + if (verbose >= VERBOSE_NORMAL) { + printf("applying border (%d,%d,%d,%d) [%d,%d,%d,%d]\n", border[LEFT], border[TOP], border[RIGHT], border[BOTTOM], mask[LEFT], mask[TOP], mask[RIGHT], mask[BOTTOM]); + } + applyMasks(&mask, 1, borderColor, image); + } +} diff -Nru unpaper-0.3/imageprocess.h unpaper-0.4.2/imageprocess.h --- unpaper-0.3/imageprocess.h 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/imageprocess.h 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,106 @@ +/* + * This file is part of Unpaper. + * + * Copyright © 2005-2007 Jens Gulden + * Copyright © 2011-2011 Diego Elio Pettenò + * + * Unpaper 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, version 2 of the License. + * + * Unpaper 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 . + */ + +/**************************************************************************** + * image processing functions * + ****************************************************************************/ + + +/* --- deskewing ---------------------------------------------------------- */ + +double detectRotation(int deskewScanEdges, int deskewScanRange, float deskewScanStep, int deskewScanSize, float deskewScanDepth, float deskewScanDeviation, int left, int top, int right, int bottom, struct IMAGE* image); + +void rotate(double radians, struct IMAGE* source, struct IMAGE* target); + +void convertToQPixels(struct IMAGE* image, struct IMAGE* qpixelImage); + +void convertFromQPixels(struct IMAGE* qpixelImage, struct IMAGE* image); + + +/* --- stretching / resizing / shifting ------------------------------------ */ + + +void stretch(int w, int h, struct IMAGE* image); + +void resize(int w, int h, struct IMAGE* image); + +void shift(int shiftX, int shiftY, struct IMAGE* image); + + +/* --- mask-detection ----------------------------------------------------- */ + + +int detectMasks(int mask[MAX_MASKS][EDGES_COUNT], bool maskValid[MAX_MASKS], int point[MAX_POINTS][COORDINATES_COUNT], int pointCount, int maskScanDirections, int maskScanSize[DIRECTIONS_COUNT], int maskScanDepth[DIRECTIONS_COUNT], int maskScanStep[DIRECTIONS_COUNT], float maskScanThreshold[DIRECTIONS_COUNT], int maskScanMinimum[DIMENSIONS_COUNT], int maskScanMaximum[DIMENSIONS_COUNT], struct IMAGE* image); + +void applyMasks(int mask[MAX_MASKS][EDGES_COUNT], int maskCount, int maskColor, struct IMAGE* image); + + +/* --- wiping ------------------------------------------------------------- */ + + +void applyWipes(int area[MAX_MASKS][EDGES_COUNT], int areaCount, int wipeColor, struct IMAGE* image); + + +/* --- mirroring ---------------------------------------------------------- */ + + +void mirror(int directions, struct IMAGE* image); + + +/* --- flip-rotating ------------------------------------------------------ */ + + +void flipRotate(int direction, struct IMAGE* image); + + +/* --- blackfilter -------------------------------------------------------- */ + + +void blackfilter(int blackfilterScanDirections, int blackfilterScanSize[DIRECTIONS_COUNT], int blackfilterScanDepth[DIRECTIONS_COUNT], int blackfilterScanStep[DIRECTIONS_COUNT], float blackfilterScanThreshold, int blackfilterExclude[MAX_MASKS][EDGES_COUNT], int blackfilterExcludeCount, int blackfilterIntensity, float blackThreshold, struct IMAGE* image); + + +/* --- noisefilter -------------------------------------------------------- */ + + +int noisefilter(int intensity, float whiteThreshold, struct IMAGE* image); + + +/* --- blurfilter --------------------------------------------------------- */ + +int blurfilter(int blurfilterScanSize[DIRECTIONS_COUNT], int blurfilterScanStep[DIRECTIONS_COUNT], float blurfilterIntensity, float whiteThreshold, struct IMAGE* image); + + +/* --- grayfilter --------------------------------------------------------- */ + + +int grayfilter(int grayfilterScanSize[DIRECTIONS_COUNT], int grayfilterScanStep[DIRECTIONS_COUNT], float grayfilterThreshold, float blackThreshold, struct IMAGE* image); + + +/* --- border-detection --------------------------------------------------- */ + + +void centerMask(int centerX, int centerY, int left, int top, int right, int bottom, struct IMAGE* image); + +void alignMask(int mask[EDGES_COUNT], int outside[EDGES_COUNT], int direction, int margin[DIRECTIONS_COUNT], struct IMAGE* image); + +void detectBorder(int border[EDGES_COUNT], int borderScanDirections, int borderScanSize[DIRECTIONS_COUNT], int borderScanStep[DIRECTIONS_COUNT], int borderScanThreshold[DIRECTIONS_COUNT], float blackThreshold, int outsideMask[EDGES_COUNT], struct IMAGE* image); + +void borderToMask(int border[EDGES_COUNT], int mask[EDGES_COUNT], struct IMAGE* image); + +void applyBorder(int border[EDGES_COUNT], int borderColor, struct IMAGE* image); diff -Nru unpaper-0.3/INSTALL unpaper-0.4.2/INSTALL --- unpaper-0.3/INSTALL 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/INSTALL 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,365 @@ +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006, 2007, 2008, 2009 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. This file is offered as-is, +without warranty of any kind. + +Basic Installation +================== + + Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. Some packages provide this +`INSTALL' file but do not implement all of the features documented +below. The lack of an optional feature in a given package is not +necessarily a bug. More recommendations for GNU packages can be found +in *note Makefile Conventions: (standards)Makefile Conventions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. + + The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. + + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package, generally using the just-built uninstalled binaries. + + 4. Type `make install' to install the programs and any data files and + documentation. When installing into a prefix owned by root, it is + recommended that the package be configured and built as a regular + user, and only the `make install' phase executed with root + privileges. + + 5. Optionally, type `make installcheck' to repeat any self-tests, but + this time using the binaries in their final installed location. + This target does not install anything. Running this target as a + regular user, particularly if the prior `make install' required + root privileges, verifies that the installation completed + correctly. + + 6. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + + 7. Often, you can also type `make uninstall' to remove the installed + files again. In practice, not all packages have tested that + uninstallation works correctly, even though it is required by the + GNU Coding Standards. + + 8. Some packages, particularly those that use Automake, provide `make + distcheck', which can by used by developers to test that all other + targets like `make install' and `make uninstall' work correctly. + This target is generally not run by end users. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. Run `./configure --help' +for details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you can use GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. This +is known as a "VPATH" build. + + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. + + On MacOS X 10.5 and later systems, you can create libraries and +executables that work on multiple system types--known as "fat" or +"universal" binaries--by specifying multiple `-arch' options to the +compiler but only a single `-arch' option to the preprocessor. Like +this: + + ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CPP="gcc -E" CXXCPP="g++ -E" + + This is not guaranteed to produce working output in all cases, you +may have to build one architecture at a time and combine the results +using the `lipo' tool if you have problems. + +Installation Names +================== + + By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX', where PREFIX must be an +absolute file name. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. In general, the +default for these options is expressed in terms of `${prefix}', so that +specifying just `--prefix' will affect all of the other directory +specifications that were not explicitly provided. + + The most portable way to affect installation locations is to pass the +correct locations to `configure'; however, many packages provide one or +both of the following shortcuts of passing variable assignments to the +`make install' command line to change installation locations without +having to reconfigure or recompile. + + The first method involves providing an override variable for each +affected directory. For example, `make install +prefix=/alternate/directory' will choose an alternate location for all +directory configuration variables that were expressed in terms of +`${prefix}'. Any directories that were specified during `configure', +but not in terms of `${prefix}', must each be overridden at install +time for the entire installation to be relocated. The approach of +makefile variable overrides for each directory variable is required by +the GNU Coding Standards, and ideally causes no recompilation. +However, some platforms have known limitations with the semantics of +shared libraries that end up requiring recompilation when using this +method, particularly noticeable in packages that use GNU Libtool. + + The second method involves providing the `DESTDIR' variable. For +example, `make install DESTDIR=/alternate/directory' will prepend +`/alternate/directory' before all installation names. The approach of +`DESTDIR' overrides is not required by the GNU Coding Standards, and +does not work on platforms that have drive letters. On the other hand, +it does better at avoiding recompilation issues, and works well even +when some directory options were not specified in terms of `${prefix}' +at `configure' time. + +Optional Features +================= + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + + Some packages offer the ability to configure how verbose the +execution of `make' will be. For these packages, running `./configure +--enable-silent-rules' sets the default to minimal output, which can be +overridden with `make V=1'; while running `./configure +--disable-silent-rules' sets the default to verbose, which can be +overridden with `make V=0'. + +Particular systems +================== + + On HP-UX, the default C compiler is not ANSI C compatible. If GNU +CC is not installed, it is recommended to use the following options in +order to use an ANSI C compiler: + + ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" + +and if that doesn't work, install pre-built binaries of GCC for HP-UX. + + On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot +parse its `' header file. The option `-nodtk' can be used as +a workaround. If GNU CC is not installed, it is therefore recommended +to try + + ./configure CC="cc" + +and if that doesn't work, try + + ./configure CC="cc -nodtk" + + On Solaris, don't put `/usr/ucb' early in your `PATH'. This +directory contains several dysfunctional programs; working variants of +these programs are available in `/usr/bin'. So, if you need `/usr/ucb' +in your `PATH', put it _after_ `/usr/bin'. + + On Haiku, software installed for all users goes in `/boot/common', +not `/usr/local'. It is recommended to use the following options: + + ./configure --prefix=/boot/common + +Specifying the System Type +========================== + + There may be some features `configure' cannot figure out +automatically, but needs to determine by the type of machine the package +will run on. Usually, assuming the package is built to be run on the +_same_ architectures, `configure' can figure that out, but if it prints +a message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS + KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + + Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf bug. Until the bug is fixed you can use this workaround: + + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash + +`configure' Invocation +====================== + + `configure' recognizes the following options to control how it +operates. + +`--help' +`-h' + Print a summary of all of the options to `configure', and exit. + +`--help=short' +`--help=recursive' + Print a summary of the options unique to this package's + `configure', and exit. The `short' variant lists options used + only in the top level, while the `recursive' variant lists options + also present in any nested packages. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--prefix=DIR' + Use DIR as the installation prefix. *note Installation Names:: + for more details, including other options available for fine-tuning + the installation locations. + +`--no-create' +`-n' + Run the configure checks, but stop before creating any output + files. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff -Nru unpaper-0.3/install-sh unpaper-0.4.2/install-sh --- unpaper-0.3/install-sh 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/install-sh 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,527 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2011-11-20.07; # UTC + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# 'make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. + +nl=' +' +IFS=" "" $nl" + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit=${DOITPROG-} +if test -z "$doit"; then + doit_exec=exec +else + doit_exec=$doit +fi + +# Put in absolute file names if you don't have them in your path; +# or use environment vars. + +chgrpprog=${CHGRPPROG-chgrp} +chmodprog=${CHMODPROG-chmod} +chownprog=${CHOWNPROG-chown} +cmpprog=${CMPPROG-cmp} +cpprog=${CPPROG-cp} +mkdirprog=${MKDIRPROG-mkdir} +mvprog=${MVPROG-mv} +rmprog=${RMPROG-rm} +stripprog=${STRIPPROG-strip} + +posix_glob='?' +initialize_posix_glob=' + test "$posix_glob" != "?" || { + if (set -f) 2>/dev/null; then + posix_glob= + else + posix_glob=: + fi + } +' + +posix_mkdir= + +# Desired mode of installed file. +mode=0755 + +chgrpcmd= +chmodcmd=$chmodprog +chowncmd= +mvcmd=$mvprog +rmcmd="$rmprog -f" +stripcmd= + +src= +dst= +dir_arg= +dst_arg= + +copy_on_change=false +no_target_directory= + +usage="\ +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: + --help display this help and exit. + --version display version info and exit. + + -c (ignored) + -C install only if different (preserve the last data modification time) + -d create directories instead of installing files. + -g GROUP $chgrpprog installed files to GROUP. + -m MODE $chmodprog installed files to MODE. + -o USER $chownprog installed files to USER. + -s $stripprog installed files. + -t DIRECTORY install into DIRECTORY. + -T report an error if DSTFILE is a directory. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG + RMPROG STRIPPROG +" + +while test $# -ne 0; do + case $1 in + -c) ;; + + -C) copy_on_change=true;; + + -d) dir_arg=true;; + + -g) chgrpcmd="$chgrpprog $2" + shift;; + + --help) echo "$usage"; exit $?;; + + -m) mode=$2 + case $mode in + *' '* | *' '* | *' +'* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; + + -o) chowncmd="$chownprog $2" + shift;; + + -s) stripcmd=$stripprog;; + + -t) dst_arg=$2 + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + shift;; + + -T) no_target_directory=true;; + + --version) echo "$0 $scriptversion"; exit $?;; + + --) shift + break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; + esac + shift +done + +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + done +fi + +if test $# -eq 0; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call 'install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +if test -z "$dir_arg"; then + do_exit='(exit $ret); exit $ret' + trap "ret=129; $do_exit" 1 + trap "ret=130; $do_exit" 2 + trap "ret=141; $do_exit" 13 + trap "ret=143; $do_exit" 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi + +for src +do + # Protect names problematic for 'test' and other utilities. + case $src in + -* | [=\(\)!]) src=./$src;; + esac + + if test -n "$dir_arg"; then + dst=$src + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? + else + + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dst_arg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + dst=$dst_arg + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test -n "$no_target_directory"; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 + fi + dstdir=$dst + dst=$dstdir/`basename "$src"` + dstdir_status=0 + else + # Prefer dirname, but fall back on a substitute if dirname fails. + dstdir=` + (dirname "$dst") 2>/dev/null || + expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$dst" : 'X\(//\)[^/]' \| \ + X"$dst" : 'X\(//\)$' \| \ + X"$dst" : 'X\(/\)' \| . 2>/dev/null || + echo X"$dst" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q' + ` + + test -d "$dstdir" + dstdir_status=$? + fi + fi + + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 + + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; + esac + + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else + + # The umask is ridiculous, or mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix='/';; + [-=\(\)!]*) prefix='./';; + *) prefix='';; + esac + + eval "$initialize_posix_glob" + + oIFS=$IFS + IFS=/ + $posix_glob set -f + set fnord $dstdir + shift + $posix_glob set +f + IFS=$oIFS + + prefixes= + + for d + do + test X"$d" = X && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true + fi + fi + fi + + if test -n "$dir_arg"; then + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + else + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + + # Copy the file name to the temp name. + (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + + eval "$initialize_posix_glob" && + $posix_glob set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + $posix_glob set +f && + + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || + + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 + + trap '' 0 + fi +done + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff -Nru unpaper-0.3/LICENSE unpaper-0.4.2/LICENSE --- unpaper-0.3/LICENSE 2006-05-09 03:17:51.000000000 +0000 +++ unpaper-0.4.2/LICENSE 1970-01-01 00:00:00.000000000 +0000 @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - (signature of Ty Coon), 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. \ No newline at end of file diff -Nru unpaper-0.3/Makefile.am unpaper-0.4.2/Makefile.am --- unpaper-0.3/Makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/Makefile.am 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,76 @@ +bin_PROGRAMS = unpaper +MANPAGE_XSL ?= http://docbook.sourceforge.net/release/xsl-ns/current/manpages/docbook.xsl + +unpaper_SOURCES = \ + file.c file.h \ + imageprocess.c imageprocess.h \ + parse.c parse.h \ + tools.c tools.h \ + unpaper.c unpaper.h + +dist_doc_DATA = NEWS COPYING README AUTHORS TODO +dist_man_MANS = unpaper.1 + +dist_html_DATA = doc/unpaper.html doc/index.html +imgdir = $(htmldir)/img +dist_img_DATA = doc/img/_after.png doc/img/_arrow.png \ + doc/img/_before.png doc/img/blackfilter-detail.png \ + doc/img/blackfilter.png doc/img/blurfilter-detail.png \ + doc/img/blurfilter.png doc/img/border-align.png \ + doc/img/border-scan.png doc/img/deskew-detail1.png \ + doc/img/deskew-detail2.png doc/img/deskew.png \ + doc/img/documentation.odg doc/img/input-pages.png \ + doc/img/layout-templates.png doc/img/mask-center.png \ + doc/img/mask-scan-detail1.png \ + doc/img/mask-scan-detail2.png doc/img/mask-scan.png \ + doc/img/multiple-input-files.png \ + doc/img/multiple-output-files.png \ + doc/img/noisefilter.png doc/img/nospam.js \ + doc/img/output-pages.png doc/img/processing-order.png \ + doc/img/sheetspages.png \ + doc/img/standard-deviation.png doc/img/style.css \ + doc/img/x-click-but04.gif + +TESTS = tests/runtestA1.sh tests/runtestB1.sh tests/runtestB2.sh \ + tests/runtestB3.sh tests/runtestC1.sh tests/runtestC2.sh \ + tests/runtestC3.sh tests/runtestD1.sh tests/runtestD2.sh \ + tests/runtestD3.sh tests/runtestE1.sh tests/runtestE2.sh \ + tests/runtestE3.sh + +EXTRA_DIST = $(TESTS) tests/imgsrc001.png tests/imgsrc002.png \ + tests/imgsrc003.png tests/imgsrc004.png \ + tests/imgsrc005.png tests/imgsrcE001.png \ + tests/imgsrcE002.png tests/imgsrcE003.png + +check_DATA = tests/imgsrc001.pbm tests/imgsrc002.pbm \ + tests/imgsrc003.ppm tests/imgsrc004.pgm \ + tests/imgsrc005.pbm tests/imgsrcE001.pbm \ + tests/imgsrcE002.pbm tests/imgsrcE003.pbm + +CLEANFILES = $(check_DATA) tests/.dirstamp tests/resultsA1.pbm \ + tests/resultsB1.ppm tests/resultsB2.ppm \ + tests/resultsB3.ppm tests/resultsC1.pbm \ + tests/resultsC2.pbm tests/resultsC3.pbm \ + tests/resultsD1.ppm tests/resultsD2.ppm \ + tests/resultsD3.ppm tests/resultsE001.pbm \ + tests/resultsE002.pbm tests/resultsE003.pbm \ + tests/resultsE004.pbm tests/resultsE005.pbm \ + tests/resultsE006.pbm tests/resultsE201.pbm \ + tests/resultsE202.pbm tests/resultsE301.pbm \ + tests/resultsE302.pbm + +tests/.dirstamp: + $(MKDIR_P) tests + touch tests/.dirstamp + +tests/imgsrc%.pbm tests/imgsrc%.ppm tests/imgsrc%.pgm: tests/imgsrc%.png tests/.dirstamp + $(PNGTOPNM) $< > $@ + +tests/results%.png: tests/results%.pbm tests/.dirstamp + $(PNMTOPNG) $< > $@ + +%.1: %.1.xml + $(AM_V_GEN)$(XSLTPROC) \ + --stringparam man.copyright.section.enable 0 \ + --stringparam man.authors.section.enabled 0 \ + $(MANPAGE_XSL) $< diff -Nru unpaper-0.3/Makefile.in unpaper-0.4.2/Makefile.in --- unpaper-0.3/Makefile.in 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/Makefile.in 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,1312 @@ +# Makefile.in generated by automake 1.12.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2012 Free Software Foundation, Inc. + +# This Makefile.in 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. + +# This program 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. + +@SET_MAKE@ + + +VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +bin_PROGRAMS = unpaper$(EXEEXT) +subdir = . +DIST_COMMON = README $(am__configure_deps) $(dist_doc_DATA) \ + $(dist_html_DATA) $(dist_img_DATA) $(dist_man_MANS) \ + $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/configure $(top_srcdir)/tests/prologue.sh.in \ + AUTHORS COPYING INSTALL NEWS TODO depcomp install-sh missing \ + test-driver +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno config.status.lineno +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = tests/prologue.sh +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" \ + "$(DESTDIR)$(docdir)" "$(DESTDIR)$(htmldir)" \ + "$(DESTDIR)$(imgdir)" +PROGRAMS = $(bin_PROGRAMS) +am_unpaper_OBJECTS = file.$(OBJEXT) imageprocess.$(OBJEXT) \ + parse.$(OBJEXT) tools.$(OBJEXT) unpaper.$(OBJEXT) +unpaper_OBJECTS = $(am_unpaper_OBJECTS) +unpaper_LDADD = $(LDADD) +DEFAULT_INCLUDES = -I.@am__isrc@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(unpaper_SOURCES) +DIST_SOURCES = $(unpaper_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +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; }; \ + } +man1dir = $(mandir)/man1 +NROFF = nroff +MANS = $(dist_man_MANS) +DATA = $(dist_doc_DATA) $(dist_html_DATA) $(dist_img_DATA) +ETAGS = etags +CTAGS = ctags +CSCOPE = cscope +AM_RECURSIVE_TARGETS = cscope check recheck +am__tty_colors_dummy = \ + mgn= red= grn= lgn= blu= brg= std=; \ + am__color_tests=no +am__tty_colors = $(am__tty_colors_dummy) +am__recheck_rx = ^[ ]*:recheck:[ ]* +am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* +am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* +# A command that, given a newline-separated list of test names on the +# standard input, print the name of the tests that are to be re-run +# upon "make recheck". +am__list_recheck_tests = $(AWK) '{ \ + recheck = 1; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + { \ + if ((getline line2 < ($$0 ".log")) < 0) \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ + { \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ + { \ + break; \ + } \ + }; \ + if (recheck) \ + print $$0; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# A command that, given a newline-separated list of test names on the +# standard input, create the global log from their .trs and .log files. +am__create_global_log = $(AWK) ' \ +function fatal(msg) \ +{ \ + print "fatal: making $@: " msg | "cat >&2"; \ + exit 1; \ +} \ +function rst_section(header) \ +{ \ + print header; \ + len = length(header); \ + for (i = 1; i <= len; i = i + 1) \ + printf "="; \ + printf "\n\n"; \ +} \ +{ \ + copy_in_global_log = 1; \ + global_test_result = "RUN"; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".trs"); \ + if (line ~ /$(am__global_test_result_rx)/) \ + { \ + sub("$(am__global_test_result_rx)", "", line); \ + sub("[ ]*$$", "", line); \ + global_test_result = line; \ + } \ + else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ + copy_in_global_log = 0; \ + }; \ + if (copy_in_global_log) \ + { \ + rst_section(global_test_result ": " $$0); \ + while ((rc = (getline line < ($$0 ".log"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".log"); \ + print line; \ + }; \ + printf "\n"; \ + }; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# Restructured Text title. +am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } +# Solaris 10 'make', and several other traditional 'make' implementations, +# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it +# by disabling -e (using the XSI extension "set +e") if it's set. +am__sh_e_setup = case $$- in *e*) set +e;; esac +# Default flags passed to test drivers. +am__common_driver_flags = \ + --color-tests "$$am__color_tests" \ + --enable-hard-errors "$$am__enable_hard_errors" \ + --expect-failure "$$am__expect_failure" +# To be inserted before the command running the test. Creates the +# directory for the log if needed. Stores in $dir the directory +# containing $f, in $tst the test, in $log the log. Executes the +# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and +# passes TESTS_ENVIRONMENT. Set up options for the wrapper that +# will run the test scripts (or their associated LOG_COMPILER, if +# thy have one). +am__check_pre = \ +$(am__sh_e_setup); \ +$(am__vpath_adj_setup) $(am__vpath_adj) \ +$(am__tty_colors); \ +srcdir=$(srcdir); export srcdir; \ +case "$@" in \ + */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ + *) am__odir=.;; \ +esac; \ +test "x$$am__odir" = x"." || test -d "$$am__odir" \ + || $(MKDIR_P) "$$am__odir" || exit $$?; \ +if test -f "./$$f"; then dir=./; \ +elif test -f "$$f"; then dir=; \ +else dir="$(srcdir)/"; fi; \ +tst=$$dir$$f; log='$@'; \ +if test -n '$(DISABLE_HARD_ERRORS)'; then \ + am__enable_hard_errors=no; \ +else \ + am__enable_hard_errors=yes; \ +fi; \ +case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ + am__expect_failure=yes;; \ + *) \ + am__expect_failure=no;; \ +esac; \ +$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) +# A shell command to get the names of the tests scripts with any registered +# extension removed (i.e., equivalently, the names of the test logs, with +# the '.log' extension removed). The result is saved in the shell variable +# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, +# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", +# since that might cause problem with VPATH rewrites for suffix-less tests. +# See also 'test-harness-vpath-rewrite.test' and 'test-trs-basic.test'. +am__set_TESTS_bases = \ + bases='$(TEST_LOGS)'; \ + bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ + bases=`echo $$bases` +RECHECK_LOGS = $(TEST_LOGS) +TEST_SUITE_LOG = test-suite.log +TEST_EXTENSIONS = @EXEEXT@ .test +LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver +LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) +am__set_b = \ + case '$@' in \ + */*) \ + case '$*' in \ + */*) b='$*';; \ + *) b=`echo '$@' | sed 's/\.log$$//'`; \ + esac;; \ + *) \ + b='$*';; \ + esac +am__test_logs1 = $(TESTS:=.log) +am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) +TEST_LOGS = $(am__test_logs2:.test.log=.log) +TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver +TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ + $(TEST_LOG_FLAGS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + if test -d "$(distdir)"; then \ + find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -rf "$(distdir)" \ + || { sleep 5 && rm -rf "$(distdir)"; }; \ + else :; fi +am__post_remove_distdir = $(am__remove_distdir) +GZIP_ENV = --best +DIST_ARCHIVES = $(distdir).tar.xz +DIST_TARGETS = dist-xz +distuninstallcheck_listfiles = find . -type f -print +am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ + | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' +distcleancheck_listfiles = find . -type f -print +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PNGTOPNM = @PNGTOPNM@ +PNMTOPNG = @PNMTOPNG@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +XSLTPROC = @XSLTPROC@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host_alias = @host_alias@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +unpaper_SOURCES = \ + file.c file.h \ + imageprocess.c imageprocess.h \ + parse.c parse.h \ + tools.c tools.h \ + unpaper.c unpaper.h + +dist_doc_DATA = NEWS COPYING README AUTHORS TODO +dist_man_MANS = unpaper.1 +dist_html_DATA = doc/unpaper.html doc/index.html +imgdir = $(htmldir)/img +dist_img_DATA = doc/img/_after.png doc/img/_arrow.png \ + doc/img/_before.png doc/img/blackfilter-detail.png \ + doc/img/blackfilter.png doc/img/blurfilter-detail.png \ + doc/img/blurfilter.png doc/img/border-align.png \ + doc/img/border-scan.png doc/img/deskew-detail1.png \ + doc/img/deskew-detail2.png doc/img/deskew.png \ + doc/img/documentation.odg doc/img/input-pages.png \ + doc/img/layout-templates.png doc/img/mask-center.png \ + doc/img/mask-scan-detail1.png \ + doc/img/mask-scan-detail2.png doc/img/mask-scan.png \ + doc/img/multiple-input-files.png \ + doc/img/multiple-output-files.png \ + doc/img/noisefilter.png doc/img/nospam.js \ + doc/img/output-pages.png doc/img/processing-order.png \ + doc/img/sheetspages.png \ + doc/img/standard-deviation.png doc/img/style.css \ + doc/img/x-click-but04.gif + +TESTS = tests/runtestA1.sh tests/runtestB1.sh tests/runtestB2.sh \ + tests/runtestB3.sh tests/runtestC1.sh tests/runtestC2.sh \ + tests/runtestC3.sh tests/runtestD1.sh tests/runtestD2.sh \ + tests/runtestD3.sh tests/runtestE1.sh tests/runtestE2.sh \ + tests/runtestE3.sh + +EXTRA_DIST = $(TESTS) tests/imgsrc001.png tests/imgsrc002.png \ + tests/imgsrc003.png tests/imgsrc004.png \ + tests/imgsrc005.png tests/imgsrcE001.png \ + tests/imgsrcE002.png tests/imgsrcE003.png + +check_DATA = tests/imgsrc001.pbm tests/imgsrc002.pbm \ + tests/imgsrc003.ppm tests/imgsrc004.pgm \ + tests/imgsrc005.pbm tests/imgsrcE001.pbm \ + tests/imgsrcE002.pbm tests/imgsrcE003.pbm + +CLEANFILES = $(check_DATA) tests/.dirstamp tests/resultsA1.pbm \ + tests/resultsB1.ppm tests/resultsB2.ppm \ + tests/resultsB3.ppm tests/resultsC1.pbm \ + tests/resultsC2.pbm tests/resultsC3.pbm \ + tests/resultsD1.ppm tests/resultsD2.ppm \ + tests/resultsD3.ppm tests/resultsE001.pbm \ + tests/resultsE002.pbm tests/resultsE003.pbm \ + tests/resultsE004.pbm tests/resultsE005.pbm \ + tests/resultsE006.pbm tests/resultsE201.pbm \ + tests/resultsE202.pbm tests/resultsE301.pbm \ + tests/resultsE302.pbm + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .log .o .obj .test .test$(EXEEXT) .trs +am--refresh: Makefile + @: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ + $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: $(am__configure_deps) + $(am__cd) $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +$(am__aclocal_m4_deps): +tests/prologue.sh: $(top_builddir)/config.status $(top_srcdir)/tests/prologue.sh.in + cd $(top_builddir) && $(SHELL) ./config.status $@ +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +unpaper$(EXEEXT): $(unpaper_OBJECTS) $(unpaper_DEPENDENCIES) $(EXTRA_unpaper_DEPENDENCIES) + @rm -f unpaper$(EXEEXT) + $(LINK) $(unpaper_OBJECTS) $(unpaper_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imageprocess.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tools.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unpaper.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +install-man1: $(dist_man_MANS) + @$(NORMAL_INSTALL) + @list1=''; \ + list2='$(dist_man_MANS)'; \ + test -n "$(man1dir)" \ + && test -n "`echo $$list1$$list2`" \ + || exit 0; \ + echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \ + { for i in $$list1; do echo "$$i"; done; \ + if test -n "$$list2"; then \ + for i in $$list2; do echo "$$i"; done \ + | sed -n '/\.1[a-z]*$$/p'; \ + fi; \ + } | while read p; do \ + if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; echo "$$p"; \ + done | \ + sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ + sed 'N;N;s,\n, ,g' | { \ + list=; while read file base inst; do \ + if test "$$base" = "$$inst"; then list="$$list $$file"; else \ + echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ + fi; \ + done; \ + for i in $$list; do echo "$$i"; done | $(am__base_list) | \ + while read files; do \ + test -z "$$files" || { \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ + done; } + +uninstall-man1: + @$(NORMAL_UNINSTALL) + @list=''; test -n "$(man1dir)" || exit 0; \ + files=`{ for i in $$list; do echo "$$i"; done; \ + l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \ + sed -n '/\.1[a-z]*$$/p'; \ + } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ + dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir) +install-dist_docDATA: $(dist_doc_DATA) + @$(NORMAL_INSTALL) + @list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(docdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(docdir)" || 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)$(docdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(docdir)" || exit $$?; \ + done + +uninstall-dist_docDATA: + @$(NORMAL_UNINSTALL) + @list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(docdir)'; $(am__uninstall_files_from_dir) +install-dist_htmlDATA: $(dist_html_DATA) + @$(NORMAL_INSTALL) + @list='$(dist_html_DATA)'; test -n "$(htmldir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(htmldir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(htmldir)" || 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)$(htmldir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(htmldir)" || exit $$?; \ + done + +uninstall-dist_htmlDATA: + @$(NORMAL_UNINSTALL) + @list='$(dist_html_DATA)'; test -n "$(htmldir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(htmldir)'; $(am__uninstall_files_from_dir) +install-dist_imgDATA: $(dist_img_DATA) + @$(NORMAL_INSTALL) + @list='$(dist_img_DATA)'; test -n "$(imgdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(imgdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(imgdir)" || 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)$(imgdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(imgdir)" || exit $$?; \ + done + +uninstall-dist_imgDATA: + @$(NORMAL_UNINSTALL) + @list='$(dist_img_DATA)'; test -n "$(imgdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(imgdir)'; $(am__uninstall_files_from_dir) + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +cscope: cscope.files + test ! -s cscope.files \ + || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) + +clean-cscope: + -rm -f cscope.files + +cscope.files: clean-cscope cscopelist + +cscopelist: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + -rm -f cscope.out cscope.in.out cscope.po.out cscope.files + +# Recover from deleted '.trs' file; this should ensure that +# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create +# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells +# to avoid problems with "make -n". +.log.trs: + rm -f $< $@ + $(MAKE) $(AM_MAKEFLAGS) $< + +$(TEST_SUITE_LOG): $(TEST_LOGS) + @$(am__set_TESTS_bases); \ + am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ + redo_bases=`for i in $$bases; do \ + am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ + done`; \ + if test -n "$$redo_bases"; then \ + redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ + redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ + if $(am__make_dryrun); then :; else \ + rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ + fi; \ + fi; \ + if test -n "$$am__remaking_logs"; then \ + echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ + "recursion detected" >&2; \ + else \ + am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ + fi; \ + if $(am__make_dryrun); then :; else \ + st=0; \ + errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ + for i in $$redo_bases; do \ + test -f $$i.trs && test -r $$i.trs \ + || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ + test -f $$i.log && test -r $$i.log \ + || { echo "$$errmsg $$i.log" >&2; st=1; }; \ + done; \ + test $$st -eq 0 || exit 1; \ + fi + @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ + ws='[ ]'; \ + results=`for b in $$bases; do echo $$b.trs; done`; \ + test -n "$$results" || results=/dev/null; \ + all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ + pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ + fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ + skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ + xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ + xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ + error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ + if test `expr $$fail + $$xpass + $$error` -eq 0; then \ + success=true; \ + else \ + success=false; \ + fi; \ + br='==================='; br=$$br$$br$$br$$br; \ + result_count () \ + { \ + if test x"$$1" = x"--maybe-color"; then \ + maybe_colorize=yes; \ + elif test x"$$1" = x"--no-color"; then \ + maybe_colorize=no; \ + else \ + echo "$@: invalid 'result_count' usage" >&2; exit 4; \ + fi; \ + shift; \ + desc=$$1 count=$$2; \ + if test $$maybe_colorize = yes && test $$count -gt 0; then \ + color_start=$$3 color_end=$$std; \ + else \ + color_start= color_end=; \ + fi; \ + echo "$${color_start}# $$desc $$count$${color_end}"; \ + }; \ + create_testsuite_report () \ + { \ + result_count $$1 "TOTAL:" $$all "$$brg"; \ + result_count $$1 "PASS: " $$pass "$$grn"; \ + result_count $$1 "SKIP: " $$skip "$$blu"; \ + result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ + result_count $$1 "FAIL: " $$fail "$$red"; \ + result_count $$1 "XPASS:" $$xpass "$$red"; \ + result_count $$1 "ERROR:" $$error "$$mgn"; \ + }; \ + { \ + echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ + $(am__rst_title); \ + create_testsuite_report --no-color; \ + echo; \ + echo ".. contents:: :depth: 2"; \ + echo; \ + for b in $$bases; do echo $$b; done \ + | $(am__create_global_log); \ + } >$(TEST_SUITE_LOG).tmp || exit 1; \ + mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ + if $$success; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ + fi; \ + echo "$${col}$$br$${std}"; \ + echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ + echo "$${col}$$br$${std}"; \ + create_testsuite_report --maybe-color; \ + echo "$$col$$br$$std"; \ + if $$success; then :; else \ + echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ + if test -n "$(PACKAGE_BUGREPORT)"; then \ + echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ + fi; \ + echo "$$col$$br$$std"; \ + fi; \ + $$success || exit 1 + +check-TESTS recheck: + @if test $@ != recheck; then \ + list='$(RECHECK_LOGS)'; \ + test -z "$$list" || rm -f $$list; \ + fi + @if test $@ != recheck; then \ + list='$(RECHECK_LOGS:.log=.trs)'; \ + test -z "$$list" || rm -f $$list; \ + fi + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @$(am__set_TESTS_bases); \ + if test $@ = recheck; then \ + bases=`for i in $$bases; do echo $$i; done \ + | $(am__list_recheck_tests)` || exit 1; \ + fi; \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + trs_list=`for i in $$bases; do echo $$i.trs; done`; \ + log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ + if test $@ != recheck || $(am__make_dryrun); then :; else \ + test -z "$$log_list" || rm -f $$log_list; \ + test -z "$$trs_list" || rm -f $$trs_list; \ + fi; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list" +recheck: all $(check_DATA) +tests/runtestA1.sh.log: tests/runtestA1.sh + @p='tests/runtestA1.sh'; \ + b='tests/runtestA1.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/runtestB1.sh.log: tests/runtestB1.sh + @p='tests/runtestB1.sh'; \ + b='tests/runtestB1.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/runtestB2.sh.log: tests/runtestB2.sh + @p='tests/runtestB2.sh'; \ + b='tests/runtestB2.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/runtestB3.sh.log: tests/runtestB3.sh + @p='tests/runtestB3.sh'; \ + b='tests/runtestB3.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/runtestC1.sh.log: tests/runtestC1.sh + @p='tests/runtestC1.sh'; \ + b='tests/runtestC1.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/runtestC2.sh.log: tests/runtestC2.sh + @p='tests/runtestC2.sh'; \ + b='tests/runtestC2.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/runtestC3.sh.log: tests/runtestC3.sh + @p='tests/runtestC3.sh'; \ + b='tests/runtestC3.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/runtestD1.sh.log: tests/runtestD1.sh + @p='tests/runtestD1.sh'; \ + b='tests/runtestD1.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/runtestD2.sh.log: tests/runtestD2.sh + @p='tests/runtestD2.sh'; \ + b='tests/runtestD2.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/runtestD3.sh.log: tests/runtestD3.sh + @p='tests/runtestD3.sh'; \ + b='tests/runtestD3.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/runtestE1.sh.log: tests/runtestE1.sh + @p='tests/runtestE1.sh'; \ + b='tests/runtestE1.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/runtestE2.sh.log: tests/runtestE2.sh + @p='tests/runtestE2.sh'; \ + b='tests/runtestE2.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/runtestE3.sh.log: tests/runtestE3.sh + @p='tests/runtestE3.sh'; \ + b='tests/runtestE3.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +.test.log: + @p='$<'; \ + $(am__set_b); \ + $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +@am__EXEEXT_TRUE@.test$(EXEEXT).log: +@am__EXEEXT_TRUE@ @p='$<'; \ +@am__EXEEXT_TRUE@ $(am__set_b); \ +@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ +@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ +@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ +@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) + +distdir: $(DISTFILES) + @list='$(MANS)'; if test -n "$$list"; then \ + list=`for p in $$list; do \ + if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ + if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \ + if test -n "$$list" && \ + grep 'ab help2man is required to generate this page' $$list >/dev/null; then \ + echo "error: found man pages containing the 'missing help2man' replacement text:" >&2; \ + grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \ + echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \ + echo " typically 'make maintainer-clean' will remove them" >&2; \ + exit 1; \ + else :; fi; \ + else :; fi + $(am__remove_distdir) + test -d "$(distdir)" || mkdir "$(distdir)" + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + -test -n "$(am__skip_mode_fix)" \ + || find "$(distdir)" -type d ! -perm -755 \ + -exec chmod u+rwx,go+rx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -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 + $(am__post_remove_distdir) + +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 + $(am__post_remove_distdir) + +dist-lzip: distdir + tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz + $(am__post_remove_distdir) +dist-xz: distdir + tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz + $(am__post_remove_distdir) + +dist-tarZ: distdir + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__post_remove_distdir) + +dist-shar: distdir + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + $(am__post_remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__post_remove_distdir) + +dist dist-all: + $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' + $(am__post_remove_distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + case '$(DIST_ARCHIVES)' in \ + *.tar.gz*) \ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ + *.tar.bz2*) \ + bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.lz*) \ + lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ + *.tar.xz*) \ + xz -dc $(distdir).tar.xz | $(am__untar) ;;\ + *.tar.Z*) \ + uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ + *.shar.gz*) \ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ + *.zip*) \ + unzip $(distdir).zip ;;\ + esac + chmod -R a-w $(distdir); chmod a+w $(distdir) + mkdir $(distdir)/_build + mkdir $(distdir)/_inst + chmod a-w $(distdir) + test -d $(distdir)/_build || exit 0; \ + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ + && am__cwd=`pwd` \ + && $(am__cd) $(distdir)/_build \ + && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + $(AM_DISTCHECK_CONFIGURE_FLAGS) \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ + distuninstallcheck \ + && chmod -R a-w "$$dc_install_base" \ + && ({ \ + (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ + distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ + } || { rm -rf "$$dc_destdir"; exit 1; }) \ + && rm -rf "$$dc_destdir" \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && rm -rf $(DIST_ARCHIVES) \ + && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ + && cd "$$am__cwd" \ + || exit 1 + $(am__post_remove_distdir) + @(echo "$(distdir) archives ready for distribution: "; \ + list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ + sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' +distuninstallcheck: + @test -n '$(distuninstallcheck_dir)' || { \ + echo 'ERROR: trying to run $@ with an empty' \ + '$$(distuninstallcheck_dir)' >&2; \ + exit 1; \ + }; \ + $(am__cd) '$(distuninstallcheck_dir)' || { \ + echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ + exit 1; \ + }; \ + test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left after uninstall:" ; \ + if test -n "$(DESTDIR)"; then \ + echo " (check DESTDIR support)"; \ + fi ; \ + $(distuninstallcheck_listfiles) ; \ + exit 1; } >&2 +distcleancheck: distclean + @if test '$(srcdir)' = . ; then \ + echo "ERROR: distcleancheck can only run from a VPATH build" ; \ + exit 1 ; \ + fi + @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left in build directory after distclean:" ; \ + $(distcleancheck_listfiles) ; \ + exit 1; } >&2 +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_DATA) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile $(PROGRAMS) $(MANS) $(DATA) +installdirs: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(docdir)" "$(DESTDIR)$(htmldir)" "$(DESTDIR)$(imgdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) + -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) + -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-dist_docDATA install-dist_htmlDATA \ + install-dist_imgDATA install-man + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: install-man1 + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-dist_docDATA \ + uninstall-dist_htmlDATA uninstall-dist_imgDATA uninstall-man + +uninstall-man: uninstall-man1 + +.MAKE: check-am install-am install-strip + +.PHONY: CTAGS GTAGS all all-am am--refresh check check-TESTS check-am \ + clean clean-binPROGRAMS clean-cscope clean-generic cscope \ + cscopelist ctags dist dist-all dist-bzip2 dist-gzip dist-lzip \ + dist-shar dist-tarZ dist-xz dist-zip distcheck distclean \ + distclean-compile distclean-generic distclean-tags \ + distcleancheck distdir distuninstallcheck dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + install-data install-data-am install-dist_docDATA \ + install-dist_htmlDATA install-dist_imgDATA install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-man1 install-pdf install-pdf-am install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \ + ps ps-am recheck tags uninstall uninstall-am \ + uninstall-binPROGRAMS uninstall-dist_docDATA \ + uninstall-dist_htmlDATA uninstall-dist_imgDATA uninstall-man \ + uninstall-man1 + +MANPAGE_XSL ?= http://docbook.sourceforge.net/release/xsl-ns/current/manpages/docbook.xsl + +tests/.dirstamp: + $(MKDIR_P) tests + touch tests/.dirstamp + +tests/imgsrc%.pbm tests/imgsrc%.ppm tests/imgsrc%.pgm: tests/imgsrc%.png tests/.dirstamp + $(PNGTOPNM) $< > $@ + +tests/results%.png: tests/results%.pbm tests/.dirstamp + $(PNMTOPNG) $< > $@ + +%.1: %.1.xml + $(AM_V_GEN)$(XSLTPROC) \ + --stringparam man.copyright.section.enable 0 \ + --stringparam man.authors.section.enabled 0 \ + $(MANPAGE_XSL) $< + +# 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 -Nru unpaper-0.3/make.sh unpaper-0.4.2/make.sh --- unpaper-0.3/make.sh 2007-12-05 23:06:27.000000000 +0000 +++ unpaper-0.4.2/make.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -# Simple makefile to build/install unpaper. -# -# Usage: make.sh [install] - -INST_DIR=/usr/local/bin - -if [[ "$1" == "install" ]]; then - # must be root here - if [[ "`whoami`" != "root" ]]; then - echo "You should be root to copy 'unpaper' to '$INST_DIR'. Or try manually if you know what you are doing." - exit - fi - if [[ ! -x unpaper ]]; then - # not compiled yet - ./make.sh - fi - echo "installing to $INST_DIR/unpaper" - cp -v unpaper $INST_DIR - exit -fi - -# $CFLAGS may contain specific processor architecture information -# or optimization flags, e.g.: -# "-O3 -funroll-all-loops -fomit-frame-pointer -ftree-vectorize". - -# -lm is required to link the math-libary which provides sin(), cos() etc. - -echo "compiling" -gcc ${CFLAGS} -lm -o unpaper src/unpaper.c diff -Nru unpaper-0.3/missing unpaper-0.4.2/missing --- unpaper-0.3/missing 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/missing 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,330 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. + +scriptversion=2012-01-06.18; # UTC + +# Copyright (C) 1996-2012 Free Software Foundation, Inc. +# Originally by Fran,cois Pinard , 1996. + +# 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, 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 . + +# 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. + +if test $# -eq 0; then + echo 1>&2 "Try '$0 --help' for more information" + exit 1 +fi + +run=: +sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' +sed_minuso='s/.* -o \([^ ]*\).*/\1/p' + +# In the cases where this matters, 'missing' is being run in the +# srcdir already. +if test -f configure.ac; then + configure_ac=configure.ac +else + configure_ac=configure.in +fi + +msg="missing on your system" + +case $1 in +--run) + # Try to run requested program, and just exit if it succeeds. + run= + shift + "$@" && exit 0 + # Exit code 63 means version mismatch. This often happens + # when the user try to use an ancient version of a tool on + # a file that requires a minimum version. In this case we + # we should proceed has if the program had been absent, or + # if --run hadn't been passed. + if test $? = 63; then + run=: + msg="probably too old" + fi + ;; + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle 'PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + --run try to run the given command, and emulate it if it fails + +Supported PROGRAM values: + aclocal touch file 'aclocal.m4' + autoconf touch file 'configure' + autoheader touch file 'config.h.in' + autom4te touch the output file, or create a stub one + automake touch all 'Makefile.in' files + bison create 'y.tab.[ch]', if possible, from existing .[ch] + flex create 'lex.yy.c', if possible, from existing .c + help2man touch the output file + lex create 'lex.yy.c', if possible, from existing .c + makeinfo touch the output file + yacc create 'y.tab.[ch]', if possible, from existing .[ch] + +Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and +'g' are ignored when checking the name. + +Send bug reports to ." + exit $? + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing $scriptversion (GNU Automake)" + exit $? + ;; + + -*) + echo 1>&2 "$0: Unknown '$1' option" + echo 1>&2 "Try '$0 --help' for more information" + exit 1 + ;; + +esac + +# normalize program name to check for. +program=`echo "$1" | sed ' + s/^gnu-//; t + s/^gnu//; t + s/^g//; t'` + +# Now exit if we have it, but it failed. Also exit now if we +# don't have it and --version was passed (most likely to detect +# the program). This is about non-GNU programs, so use $1 not +# $program. +case $1 in + lex*|yacc*) + # Not GNU programs, they don't have --version. + ;; + + *) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + # Could not run --version or --help. This is probably someone + # running '$TOOL --version' or '$TOOL --help' to check whether + # $TOOL exists and not knowing $TOOL uses missing. + exit 1 + fi + ;; +esac + +# If it does not exist, or fails to run (possibly an outdated version), +# try to emulate it. +case $program in + aclocal*) + echo 1>&2 "\ +WARNING: '$1' is $msg. You should only need it if + you modified 'acinclude.m4' or '${configure_ac}'. You might want + to install the Automake and Perl packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf*) + echo 1>&2 "\ +WARNING: '$1' is $msg. You should only need it if + you modified '${configure_ac}'. You might want to install the + Autoconf and GNU m4 packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader*) + echo 1>&2 "\ +WARNING: '$1' is $msg. You should only need it if + you modified 'acconfig.h' or '${configure_ac}'. You might want + to install the Autoconf and GNU m4 packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case $f in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake*) + echo 1>&2 "\ +WARNING: '$1' is $msg. You should only need it if + you modified 'Makefile.am', 'acinclude.m4' or '${configure_ac}'. + You might want to install the Automake and Perl packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + autom4te*) + echo 1>&2 "\ +WARNING: '$1' is needed, but is $msg. + You might have modified some files without having the + proper tools for further handling them. + You can get '$1' as part of Autoconf from any GNU + archive site." + + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo "#! /bin/sh" + echo "# Created by GNU Automake missing as a replacement of" + echo "# $ $@" + echo "exit 0" + chmod +x $file + exit 1 + fi + ;; + + bison*|yacc*) + echo 1>&2 "\ +WARNING: '$1' $msg. You should only need it if + you modified a '.y' file. You may need the Bison package + in order for those modifications to take effect. You can get + Bison from any GNU archive site." + rm -f y.tab.c y.tab.h + if test $# -ne 1; then + eval LASTARG=\${$#} + case $LASTARG in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if test ! -f y.tab.h; then + echo >y.tab.h + fi + if test ! -f y.tab.c; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex*|flex*) + echo 1>&2 "\ +WARNING: '$1' is $msg. You should only need it if + you modified a '.l' file. You may need the Flex package + in order for those modifications to take effect. You can get + Flex from any GNU archive site." + rm -f lex.yy.c + if test $# -ne 1; then + eval LASTARG=\${$#} + case $LASTARG in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if test ! -f lex.yy.c; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + help2man*) + echo 1>&2 "\ +WARNING: '$1' is $msg. You should only need it if + you modified a dependency of a manual page. You may need the + Help2man package in order for those modifications to take + effect. You can get Help2man from any GNU archive site." + + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo ".ab help2man is required to generate this page" + exit $? + fi + ;; + + makeinfo*) + echo 1>&2 "\ +WARNING: '$1' is $msg. You should only need it if + you modified a '.texi' or '.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy 'make' (AIX, + DU, IRIX). You might want to install the Texinfo package or + the GNU make package. Grab either from any GNU archive site." + # The file to touch is that specified with -o ... + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -z "$file"; then + # ... or it is the one specified with @setfilename ... + infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n ' + /^@setfilename/{ + s/.* \([^ ]*\) *$/\1/ + p + q + }' $infile` + # ... or it is derived from the source name (dir/f.texi becomes f.info) + test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info + fi + # If the file does not exist, the user really needs makeinfo; + # let's fail without touching anything. + test -f $file || exit 1 + touch $file + ;; + + *) + echo 1>&2 "\ +WARNING: '$1' is needed, and is $msg. + You might have modified some files without having the + proper tools for further handling them. Check the 'README' file, + it often tells you about the needed prerequisites for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing '$1' program." + exit 1 + ;; +esac + +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff -Nru unpaper-0.3/NEWS unpaper-0.4.2/NEWS --- unpaper-0.3/NEWS 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/NEWS 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,146 @@ +Release 0.4.2, 2012-06-22 + - Fix regressions from 0.4.1 on multi-page processing. + - Add tests to make sure that multi-page processing works. + +Release 0.4.1, 2012-06-20 + - Source code split in multiple units to make it more manageable. + - Options parsing is now performed through getopt_long_only(); this + makes it compatible with the old parameters, while avoiding the + long-winded original parser. + - The --input-sequence and --output-sequence parameters have been + removed for ease of porting; man page describes the new input + and output file matching. + - Tests are executed with the new parallel harness for speed. + - Improved blurfilter by Felix Janda. + +Release 0.4, 2011-10-08: + - New buildsystem, based on standard GNU autotools. + - Optimisation of source code to produce slimmer, faster binaries. + - The sources now compile using C99, and support GCC, Pathscale and + Clang compilers. + - Options are now documented in the unpaper(1) man page, rather than + in the code. + +Release 0.3, 2007-12-31: +- Moved history-information to CHANGELOG-file. +- Two distribution archives become part of the release, one source-only + variant, and one binary-distribution for i386/Linux. Archive + unpaper-bin-0.3.tar.gz contains everything in unpaper-0.3.tar.gz, plus a + binary executable file in folder bin/. +- The final distribution packages are now created with a standard-tar via + shell execution. Older versions were tarred and gzipped by ANT 1.6.5's tar- + task, which had shown incompatibities on some systems. +- Included a simple makefile make.sh. It runs with minimum requirements to the + compiler, while being configurable for particular optimizations via $CFLAGS. +- Common style distribution package naming and content-layout, following the + conventional patterns 'unpaper-0.x.tar.gz' for the archive file, which + contains a root folder 'unpaper-0.x' and files 'unpaper-0.x/*' (request/bug + #10793). +- Added --sheet-background option. +- Added --pre-shift and --post-shift options. +- Removed modes 'single-rotated' and 'double-rotated' for parameter --layout. + (The documentation was ambiguous and the functionaity can better be achieved + using --pre-rotate in combination with --layout single or --layout double.) + The default layout mode is 'single' now, the old behaviour, when no --layout + option was specified, can be achieved using --layout none. +- Corrected some language flaws in the docmentation. Thanks to Martin Collins. +- Renamed Readme.txt and License.txt to more common README and LICENSE. +- Fixed bug #11294: leading zeros in width/height values of pnm-files no longer + cause problems. +- Fixed bug #9495: resizing/stretching of color-images now works. +- Fixed bug #7882: --pre-mirror h,v now correct when vertical resolution is odd + +Release 0.2, 2006-05-09: +- Version number fallback to 0.2 (instead of counting up to 1.2). This better + reflects the current development status and appears more suitable in an + open-source context. +- User documentation with several explaining diagrams added, see file + 'doc/index.html'. +- Color support added. Files of type PPM can be read, processed and written + now. By default, unpaper uses the same image format for the output file as + has been read from an input file, i.e. if your input is PPM, the output will + be PPM automatically, if the input is PGM, the output will be PGM etc. Use + parameter --type pbm|pgm|ppm to force an output file format independently + from the input file format. +- Better image rotation implementation. Auto-rotation of pages is now done + much faster. +- The --cache option became obsolete (due to new image rotation + implementation). +- The compiler-switch -DNOSINCOS became obsolete (due to new image rotation + implementation). It is no longer needed for compilation on some platforms. +- Changed to gcc version 4.1 for creating the Linux binary included in the + distribution archive. gcc 4.1's executable appears to be about 20% faster + than the one created with gcc 3.3.6. +- Added '-fomit-frame-pointer' and '-ftree-vectorize' to compiler options. + (Thanks to Olaf Marzocchi for the hint about -ftree-vectorize.) +- Fix: the first pixel of an image is now correctly read (was read wrong in + previous versions). +- Minor fixes. + +Release 1.1, 2005-08-27: +- Single-page input sheets can now be joined to make 2-page output sheets. + See options --input-pages [1|2] and --output-pages [1|2]. +- Multiple input and output filename patterns can now be specified using the + options --input-file-sequence and --output-file-sequence. +- Blank pages or sheets can be inserted into the sequence of input sheets + using --insert-blank and/or --replace-blanks, +- Zooming and stretching are now supported, see --stretch, --zoom and + --post-stretch, --post-zoom. +- The sheet size can be set while keeping the content's aspect ratio (and + centering it with best-fitting on the sheet) using --size and --post-size. + For changing the sheet size without performing any stretching/zooming of + content use --sheet-size. +- Faster rotation when deskewing images. The rotating algorithm has been + optimized to run up to 4 times faster than before. Additional speedup + may be achieved by caching intermediate results of trigonometric calculations + when processing multiple page. This caching uses a lot of memory, it + can be enabled using the --cache switch. +- Rotation detection can now be configured to start at individual edges + of the area to process. The parameter --deskew-scan-direction no longer + takes v[ertical],h[orizontal] as values, but now l[eft],t[op],r[ight], + b[ottom]. The default is 'l,r', which matches the previous version's + default 'horizontal'. +- The behaviour of the 'double' template, used with the --layout parameter + by specifying "--layout double", has been changed slightly. The input + images are no longer assumed to be rotated by 90 degrees, as they would + be when scanned from paper with a usual ADF-scanner. + That means, "--layout double" no longer implies "--pre-rotate 90" and + "--post-rotate 90". To get the layout-template behaving as in earlier + versions, use "--layout double-rotated", this behaves like the old + "--layout double". +- --border-align --border-margin allow to align page content heading towards + one edge, but keeping a specified distance margin. +- Using the new parameter --blackfilter-scan-exclude [l,t,r,b], areas can + be specified on which the blackfilter will not work. This is useful to + exclude the blackfilter from working on inner page content, e.g. to + protect images with larger dark parts from deletion. + Note that the --layout option may preset some blackfilter-scan-exclude + masks. +- The speed of the noisefilter has been optimized a bit. +- The default --mask-scan-step value has been changed from 10 to 5, which + should sometimes lead to better mask-area detection. +- The default --deskew-scan-depth value has been changed from 0.66 to 0.5, + should sometimes lead to better rotation detection. +- The default --black-treshold value has been changed from 0.5 to 0.33, + which should give a better looking, more saturated result when converting + grayscale images to black-and-white mode. +- Existing output files will no longer be overwritten by default. If an + output file to be written already exists, the program terminates with an + error instead. Overwriting can be allowed using the --overwrite switch. +- Fix: Setting the parameter --pre-rotate or --post-rotate to 0 will no + longer issue a useless warning message. +- Tested on MacOS X, additional compilation instructions for MacOS have been + added to the documentation. +- Tested on SPARC Solaris. +- Compiler switch -DNOSINCOS disables use of the sincos() function, which + preserves compatibility with math libraries that do not provide this + function. + +Release 1.0.1, 2005-03-14: +- Syntax cleanups, better ANSI-C compatibility to solve some compiler issues. + Using the -pedantic compiler switch, only warnings with intended origin are + still issued. +- Minor changes to the usage-info. + +Release 1.0, 2005-03-01: +- Initial release. diff -Nru unpaper-0.3/parse.c unpaper-0.4.2/parse.c --- unpaper-0.3/parse.c 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/parse.c 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,447 @@ +/* + * This file is part of Unpaper. + * + * Copyright © 2005-2007 Jens Gulden + * Copyright © 2011-2011 Diego Elio Pettenò + * + * Unpaper 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, version 2 of the License. + * + * Unpaper 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 . + */ + +/* --- tool functions for parameter parsing and verbose output ------------ */ + +#include +#include +#include +#include +#include + +#include "unpaper.h" + +/* --- constants ---------------------------------------------------------- */ + +// factors for conversion to inches +#define CM2IN 0.393700787 +#define MM2IN CM2IN/10.0 + +#define MEASUREMENTS_COUNT 3 +static const struct { + char unit[4]; + float factor; +} MEASUREMENTS[MEASUREMENTS_COUNT] = { + { "in", 1.0 }, + { "cm", CM2IN }, + { "mm", MM2IN } +}; + +// papersize alias names +#define PAPERSIZES_COUNT 10 +static const struct { + char name[24]; + float width; + float height; +} PAPERSIZES[PAPERSIZES_COUNT] = { + { "a5", + 14.8 * CM2IN, + 21.0 * CM2IN }, + { "a5-landscape", + 21.0 * CM2IN, + 14.8 * CM2IN }, + { "a4", + 21.0 * CM2IN, + 29.7 * CM2IN }, + { "a4-landscape", + 29.7 * CM2IN, + 21.0 * CM2IN }, + { "a3", + 29.7 * CM2IN, + 42.0 * CM2IN }, + { "a3-landscape", + 42.0 * CM2IN, + 29.7 * CM2IN }, + { "letter", + 8.5, 11.0 }, + { "letter-landscape", + 11.0, 8.5 }, + { "legal", + 8.5, 14.0 }, + { "legal-landscape", + 14.0, 8.5 } +}; + + + +/** + * Parses a parameter string on occurrences of 'vertical', 'horizontal' or both. + */ +int parseDirections(char* s) { + int dir = 0; + if (strchr(s, 'h') != 0) { // (there is no 'h' in 'vertical'...) + dir = 1< 0) { + if (s[0] != NULL) { + strcpy(buf, s[0]); + } else { + strcpy(buf, BLANK_TEXT); + } + for (i = 1; i < cnt; i++) { + if (s[i] != NULL) { + sprintf(buf + strlen(buf), ", %s", s[i]); + } else { + sprintf(buf + strlen(buf), ", %s", BLANK_TEXT); + } + } + } else { + buf[0] = 0; //strcpy(buf, ""); + } + return buf; +} + +/** + * Parses a string consisting of comma-concatenated integers. The + * string may also be of a different format, in which case + * *multiIndexCount is set to -1. + * + * @see isInMultiIndex(..) + */ +void parseMultiIndex(const char *optarg, int multiIndex[], int* multiIndexCount) { + char s1[MAX_MULTI_INDEX * 5]; // buffer + char s2[MAX_MULTI_INDEX * 5]; // buffer + char c; + int index; + int j; + + *multiIndexCount = 0; + strcpy(s1, optarg); // argv[*i] -> s1 + do { + index = -1; + s2[0] = (char)0; // = "" + sscanf(s1, "%d%c%s", &index, &c, s2); + if (index != -1) { + multiIndex[(*multiIndexCount)++] = index; + if (c=='-') { // range is specified: get range end + strcpy(s1, s2); // s2 -> s1 + sscanf(s1, "%d,%s", &index, s2); + for (j = multiIndex[(*multiIndexCount)-1]+1; j <= index; j++) { + multiIndex[(*multiIndexCount)++] = j; + } + } + } else { + // string is not correctly parseable: break without inreasing *i (string may be e.g. input-filename) + *multiIndexCount = -1; // disable all + return; // exit here + } + strcpy(s1, s2); // s2 -> s1 + } while ((*multiIndexCount < MAX_MULTI_INDEX) && (strlen(s1) > 0)); +} + + +/** + * Tests whether an integer is included in the array of integers given as multiIndex. + * If multiIndexCount is -1, each possible integer is considered to be in the + * multiIndex list. + * + * @see parseMultiIndex(..) + */ +bool isInMultiIndex(int index, int multiIndex[MAX_MULTI_INDEX], int multiIndexCount) { + int i; + + if (multiIndexCount == -1) { + return true; // all + } else { + for (i = 0; i < multiIndexCount; i++) { + if (index == multiIndex[i]) { + return true; // found in list + } + } + return false; // not found in list + } +} + + +/** + * Tests whether 'index' is either part of multiIndex or excludeIndex. + * (Throughout the application, excludeIndex generalizes several individual + * multi-indices: if an entry is part of excludeIndex, it is treated as being + * an entry of all other multiIndices, too.) + */ +bool isExcluded(int index, int multiIndex[MAX_MULTI_INDEX], int multiIndexCount, int excludeIndex[MAX_MULTI_INDEX], int excludeIndexCount) { + return ( (isInMultiIndex(index, excludeIndex, excludeIndexCount) == true) || (isInMultiIndex(index, multiIndex, multiIndexCount) == true) ); +} + + +/** + * Outputs all entries in an array of integer to the console. + */ +void printMultiIndex(int multiIndex[MAX_MULTI_INDEX], int multiIndexCount) { + int i; + + if (multiIndexCount == -1) { + printf("all"); + } else if (multiIndexCount == 0) { + printf("none"); + } else { + for (i = 0; i < multiIndexCount; i++) { + printf("%d", multiIndex[i]); + if (i < multiIndexCount-1) { + printf(","); + } + } + } + printf("\n"); +} + + +/** + * Tests if a point is covered by a mask. + */ +static bool inMask(int x, int y, int mask[EDGES_COUNT]) { + if ( (x >= mask[LEFT]) && (x <= mask[RIGHT]) && (y >= mask[TOP]) && (y <= mask[BOTTOM]) ) { + return true; + } else { + return false; + } +} + + +/** + * Tests if masks a and b overlap. + */ +static bool masksOverlap(int a[EDGES_COUNT], int b[EDGES_COUNT]) { + return ( inMask(a[LEFT], a[TOP], b) || inMask(a[RIGHT], a[BOTTOM], b) ); +} + + +/** + * Tests if at least one mask in masks overlaps with m. + */ +bool masksOverlapAny(int m[EDGES_COUNT], int masks[MAX_MASKS][EDGES_COUNT], int masksCount) { + int i; + + for ( i = 0; i < masksCount; i++ ) { + if ( masksOverlap(m, masks[i]) ) { + return true; + } + } + return false; +} diff -Nru unpaper-0.3/parse.h unpaper-0.4.2/parse.h --- unpaper-0.3/parse.h 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/parse.h 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,53 @@ +/* + * This file is part of Unpaper. + * + * Copyright © 2005-2007 Jens Gulden + * Copyright © 2011-2011 Diego Elio Pettenò + * + * Unpaper 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, version 2 of the License. + * + * Unpaper 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 . + */ + +/* --- tool functions for parameter parsing and verbose output ------------ */ + + +int parseDirections(char* s); + +void printDirections(int d); + +int parseEdges(char* s); + +void printEdges(int d); + +void parseInts(char* s, int i[2]); + +void parseSize(char* s, int i[2], int dpi); + +int parseColor(char* s); + +void printInts(int i[2]); + +void parseFloats(char* s, float f[2]); + +void printFloats(float f[2]); + +char* implode(char* buf, const char* s[], int cnt); + +void parseMultiIndex(const char *optarg, int multiIndex[], int* multiIndexCount); + +bool isInMultiIndex(int index, int multiIndex[MAX_MULTI_INDEX], int multiIndexCount); + +bool isExcluded(int index, int multiIndex[MAX_MULTI_INDEX], int multiIndexCount, int excludeIndex[MAX_MULTI_INDEX], int excludeIndexCount); + +void printMultiIndex(int multiIndex[MAX_MULTI_INDEX], int multiIndexCount); + +bool masksOverlapAny(int m[EDGES_COUNT], int masks[MAX_MASKS][EDGES_COUNT], int masksCount); diff -Nru unpaper-0.3/README unpaper-0.4.2/README --- unpaper-0.3/README 2007-12-31 01:30:35.000000000 +0000 +++ unpaper-0.4.2/README 2012-06-23 04:10:45.000000000 +0000 @@ -1,8 +1,6 @@ ------------------------------------------------------------------------------- -unpaper 0.3 - written by Jens Gulden 2005-2007 -Licensed under the GNU General Public License (GPL), see file LICENSE. +unpaper 0.4 - written by Jens Gulden 2005-2007 +Licensed under the GNU General Public License (GPL), see file COPYING. This software comes with no warranty. ------------------------------------------------------------------------------- Overview ------------------------------------------------------------------------------ @@ -17,7 +15,7 @@ through scanning or copying on areas outside the actual page content (e.g. dark areas between the left-hand-side and the right-hand-side of a double- sided book-page scan). -The program also tries to detect disaligned centering and rotation of pages +The program also tries to detect misaligned centering and rotation of pages and will automatically straighten each page by rotating it to the correct angle. This process is called "deskewing". Note that the automatic processing will sometimes fail. It is always a good @@ -25,562 +23,8 @@ settings according to the requirements of the input. Each processing step can also be disabled individually for each sheet. -Input and output files can be in either .pbm , .pgm or .ppm format, thus +Input and output files can be in either .pbm, .pgm or .ppm format, thus generally in .pnm format, as also used by the Linux scanning tools scanimage and scanadf. Conversion to PDF can e.g. be achieved with the Linux tools pgm2tiff, tiffcp and tiff2pdf. - -Installation ------------------------------------------------------------------------------- -On i386-Linux systems, the pre-compiled binary included in the distribution -archive can be used. Execute as root: - -cp bin/unpaper /usr/local/bin/ - -Alternative ways to install are running - -./make.sh -./make.sh install - -Or compile manually and copy the resulting executable to a directory in the -search path. - -Compilation ------------------------------------------------------------------------------- -The easiest way to manually compile unpaper is running: - -gcc -lm -o unpaper unpaper.c - -You can also perform this step by invoking the script make. In this case, -optional compilation parameters set via the gobal environment variable $CFLAGS -will also take effect. - -unpaper has been tested to be compilable on several hardware platforms and -operating systems, including Linux/Intel, Macintosh/G4, Macintosh/68k, -Solaris/Sparc and Windows/Intel. The following list gives hint on how to -optimally compile unpaper on different systems. This may or may not work -in other environments: - -Linux/Intel -The binary executable included in the distribution archive has been compiled -using gcc version 4.1: -gcc -D TIMESTAMP="" -lm -O3 -funroll-all-loops -fomit-frame-pointer -ftree-vectorize -o unpaper unpaper.c - -Compilation hints for other environments have been provided by users. Note -that the following compiler invocations might work only with specific versions -of the compilers or specific environments: - -Macintosh -gcc -O4 -fast -mcpu=7450 -pipe -fomit-frame-pointer -ftree-vectorize -o unpaper unpaper.c -(People with G5 should simply omit the -mcpu=7450 option. Thanks to Olaf Marzocchi.) - -In case you use cc as compiler, it may be necessary to increase the stack size -by adding -Wl,-stack_size -Wl,1000000 (tested on Macintosh/68k). - -Windows -gcc.exe unpaper.c -o unpaper.exe -I "C:\programme\Dev-Cpp\include" -L "C:\programme\Dev-Cpp\lib" -(Thanks to Uwe Dierolf.) - - -Usage ------------------------------------------------------------------------------- -Usage: unpaper [options] - -Filenames may contain a formatting placeholder starting with '%' to insert a -page counter for multi-page processing. E.g.: 'scan%03d.pbm' to process files -scan001.pbm, scan002.pbm, scan003.pbm etc. - --l --layout single Set default layout options for a sheet: - |double 'single': One page per sheet. - |none 'double': Two pages per sheet, landscape - orientation (one page on the left - half, one page on the right half). - 'none': No auto-layout, mask-scan-points - may individually be specified. - Using 'single' or 'double' automatically - sets corresponding --mask-scan-points. - The default is 'single'. - --start --start-sheet Number of first sheet to process in multi- - sheet mode. (default: 1) - --end --end-sheet Number of last sheet to process in multi- - sheet mode. -1 indicates processing until - no more input file with the corresponding - page number is available (default: -1) - --# --sheet Optionally specifies which sheets to - {,[-]} process in the range between start-sheet - and end sheet. - --x --exclude Excludes sheets from processing in the - {,[-]} range between start-sheet and end-sheet. - ---pre-rotate -90|90 Rotates the whole image clockwise (90) or - or anti-clockwise (-90) before any other - processing. - ---post-rotate -90|90 Rotates the whole image clockwise (90) or - or anti-clockwise (-90) after any other - processing. - --M --pre-mirror Mirror the image, after possible pre- - [v[ertical]][,][h[orizontal]] rotation. Either 'v' (for vertical - mirroring), 'h' (for horizontal mirroring) - or 'v,h' (for both) can be specified. - ---post-mirror Mirror the image, after any other - [v[ertical]][,][h[orizontal]] processing except possible post- - rotation. - ---pre-shift , Shift the image before further processing. - Values for 'h' (horizontal shift) and 'v' - (vertical shift) can either be positive - or negative. - ---post-shift , Shift the image after other processing. - Values for 'h' (horizontal shift) and 'v' - (vertical shift) can either be positive - or negative. - ---pre-wipe Manually wipe out an area before further - ,,, processing. Any pixel in a wiped area - will be set to white. Multiple areas to - be wiped may be specified by multiple - occurrences of this options. - ---post-wipe Manually wipe out an area after - ,,, processing. Any pixel in a wiped area - will be set to white. Multiple areas to - be wiped may be specified by multiple - occurrences of this options. - ---pre-border Clear the border-area of the sheet before - ,,, further processing. Any pixel in the - border area will be set to white. - ---post-border Clear the border-area after processing. - ,,, Any pixel in the border area will be set - to white. - ---pre-mask ,,, Specify masks to apply before any other - processing. Any pixel outside a mask - will be set to white, unless another mask - includes this pixel. - Only pixels inside a mask will remain. - Multiple masks may be specified. No - deskewing will be applied to the masks - specified by --pre-mask. - --s --size , Change the sheet size before other pro- - | cessing is applied. Content on the sheet - gets zoomed to fit to the appropriate - size, but the aspect ratio is preserved. - Instead, if the sheet's aspect ratio - changes, the zoomed content gets centered - on the sheet. Size-name can also be a - standard name as 'a4', 'letter', etc. - Possible size names are: - a5 - a4 - a3 - letter - legal. - All size names can also be applied in - rotated landscape orientation, use - 'a4-landscape', 'letter-landscape' etc. - ---post-size ,| Change the sheet size preserving the - content's aspect ratio after other - processing steps are applied. - ---stretch ,| Change the sheet size before other - processing is applied. Content on the - sheet gets stretched to the specified - size, possibly changing the aspect ratio. - ---post-stretch , Change the sheet size after other - | processing is applied. Content on the - sheet gets stretched to the specified - size, possibly changing the aspect ratio. - --z --zoom Change the sheet size according to the - given factor before other processing is - done. - ---post-zoom Change the sheet size according to the - given factor after processing is done. - --bn --blackfilter-scan-direction Directions in which to search for solidly - [v[ertical]][,][h[orizontal]] black areas. Either 'v' (for vertical - scanning), 'h' (for horizontal scanning) - of 'v,h' (for both) can be specified. - (default: 'v,h') - --bs --blackfilter-scan-size Width of virtual bar used for mask - |, detection. Two values may be specified - to individually set horizontal and - vertical size. (default: 20,20) - --bd --blackfilter-scan-depth Size of virtual bar used for black area - | detection. (default: 500,500) - --bp --blackfilter-scan-step Steps to move virtual bar for black area - | detection. (default: 5,5) - --bt --blackfilter-scan-threshold Ratio of dark pixels above which a black - area gets detected. (default: 0.95). - --bx --blackfilter-scan-exclude Area on which the blackfilter should not - ,,, operate. This can be useful to prevent - the blackfilter from working on inner - page content. May be specified multiple - times to set more than one area. - --bi --blackfilter-intensity Intensity with which to delete black - areas. Larger values will leave less - noise-pixels around former black areas, - but may delete page content. (default: - 20) - --ni --noisefilter-intensity Intensity with which to delete individual - pixels or tiny clusters of pixels. Any - cluster which only contains n dark pixels - together will be deleted. (default: 4) - --ls --blurfilter-size Size of blurfilter area to search for - |, 'lonely' clusters of pixels. - (default: 100,100) - --lp --blurfilter-step Size of 'blurring' steps in each - |, direction. (default: 50,50) - --li --blurfilter-intensity Relative intensity with which to delete - tiny clusters of pixels. Any blurred area - which contains at most the ratio of dark - pixels will be cleared. (default: 0.01) - --gs --grayfilter-size Size of grayfilter mask to search for - |, 'gray-only' areas of pixels. - (default: 50,50) - --gp --grayfilter-step Size of steps moving the grayfilter mask - |, in each direction. (default: 20,20) - --gt --grayfilter-threshold Relative intensity of grayness which is - accepted before clearing the grayfilter - mask in cases where no black pixel is - found in the mask. (default: 0.5) - --p --mask-scan-point , Manually set starting point for mask- - detection. Multiple --mask-scan-point - options may be specified to detect - multiple masks. - --m --mask ,,, Manually add a mask, in addition to masks - automatically detected around the --mask- - scan-point coordinates (unless --no-mask- - scan is specified). - Any pixel outside a mask will be - set to white, unless another mask - covers this pixel. - --mn --mask-scan-direction Directions in which to search for mask - [v[ertical]][,][h[orizontal]] borders, starting from --mask-scan-point - coordinates. Either 'v' (for vertical - scanning), 'h' (for horizontal scanning) - of 'v,h' (for both) can be specified. - (default: 'h' ('v' may cut text- - paragraphs on single-page sheets)) - --ms --mask-scan-size | Width of the virtual bar used for mask - detection. Two values may be specified - to individually set horizontal and - vertical size. (default: 50,50) - --md --mask-scan-depth | Height of the virtual bar used for mask - detection. (default: -1,-1, using the - total width or height of the sheet) - --mp --mask-scan-step | Steps to move the virtual bar for mask - detection. (default: 5,5) - --mt --mask-scan-threshold | Ratio of dark pixels below which an edge - gets detected, relative to max. blackness - when counting from the start coordinate - heading towards one edge. (default: 0.1) - --mm --mask-scan-minimum , Minimum allowed size of an auto-detected - mask. Masks detected below this size will - be ignored and set to the size specified - by mask-scan-maximum. (default: 100,100) - --mM --mask-scan-maximum , Maximum allowed size of an auto-detected - mask. Masks detected above this size will - be shrunk to the maximum value, each - direction individually. (default: - sheet size, or page size derived from - --layout option. - --mc --mask-color Color value with which to wipe out pixels - not covered by any mask. Maybe useful for - testing in order to visualize the effect - of masking. (Note that an RGB-value is - expected: R*65536 + G*256 + B.) - --dn --deskew-scan-direction Edges from which to scan for rotation. - [left],[top],[right],[bottom] Each edge of a mask can be used to detect - the mask's rotation. If multiple edges - are specified, the average value will be - used, unless the statistical deviation - exceeds --deskew-scan-deviation. Use - 'left' for scanning from the left edge, - 'top' for scanning from the top edge, - 'right' for scanning from the right edge, - 'bottom' for scanning from the bottom. - Multiple directions can be separated by - commas. (default: 'left,right') - --ds --deskew-scan-size Size of virtual line for rotation - detection. (default: 1500) - --dd --deskew-scan-depth Amount of dark pixels to accumulate until - scanning is stopped, relative to scan-bar - size. (default: 0.5) - --dr --deskew-scan-range Range in which to search for rotation, - from -degrees to +degrees rotation. - (default: 5.0) - --dp --deskew-scan-step Steps between single rotation-angle - detections. - Lower numbers lead to better results but - slow down processing. (default: 0.1) - --dv --deskew-scan-deviation Maximum statistical deviation allowed - among the results from detected edges. - No rotation if exceeded. (default: 1.0) - --W --wipe Manually wipe out an area. Any pixel in - ,,, a wiped area will be set to white. - Multiple --wipe areas may be specified. - This is applied after deskewing and - before automatic border-scan. - --mw --middle-wipe If --layout is set to 'double', this - |, may specify the size of a middle area to - wipe out between the two pages on the - sheet. This may be useful if the - blackfilter fails to remove some black - areas (e.g. resulting from photo-copying - in the middle between two pages). - --B --border Manually add a border. Any pixel in the - ,,, border area will be set to white. This is - applied after deskewing and before - automatic border-scan. - --Bn --border-scan-direction Directions in which to search for outer - [v[ertical]][,][h[orizontal]] border. Either 'v' (for vertical - scanning), 'h' (for horizontal scanning) - of 'v,h' (for both) can be specified. - (default: 'v') - --Bs --border-scan-size | Width of virtual bar used for border - detection. Two values may be specified - to individually set horizontal and - vertical size. (default: 5,5) - --Bp --border-scan-step | Steps to move virtual bar for border - detection. (default: 5,5) - --Bt --border-scan-threshold Absolute number of dark pixels covered by - the border-scan mask above which a border - is detected. (default: 5) - --Ba --border-align Direction where to shift the detected - [left],[top],[right],[bottom] border-area. Use --border-margin to - specify horizontal and vertical distances - to be kept from the sheet-edge. - (default: none) - --Bm --border-margin Distance to keep from the sheet edge when - , aligning a border area. May use - measurement suffices such as cm, in. - --w --white-threshold Brightness ratio above which a pixel is - considered white. - (default: 0.9) - --b --black-threshold Brightness ratio below which a pixel is - considered black (non-gray). This is used - by the gray-filter. This value is also - used when converting a grayscale image to - black-and-white mode (default: 0.33) - --ip --input-pages 1|2 If '2' is specified, read two input - images instead of one and internally - combine them to a doubled-layout sheet - before further processing. - Before internally combining, --pre- - rotation is optionally applied - individually to both input images as the - very first processing steps. - --op --output-pages 1|2 If '2' is specified, write two output - images instead of one, as a result of - splitting a doubled-layout sheet after - processing. After splitting the sheet, - --post-rotation is optionally applied - individually to both output images as the - very last processing step. - --S --sheet-size , Force a fix sheet size. Usually, the - | sheet size is determined by the input - image size (if input-pages=1), or by the - double size of the first page in a - two-page input set (if input-pages=2). - If the input image is smaller than the - size specified here, it will appear - centered and surrounded with a white - border on the sheet. If the input image is - bigger, it will be centered and the edges - will be cropped. This option may also be - helpful to get regular sized output - images if the input image sizes differ. - Standard size-names like 'a4-landscape', - 'letter', etc. may be used (see --size). - (default: as in input file) - ---sheet-background black|white Sets a color with which the sheet is - filled before any image is loaded and - placed onto it. This can be useful when - the sheet size and the image size differ. - ---no-blackfilter Disables black area scan. Individual sheet - {,[-]} indices can be specified. - ---no-noisefilter Disables the noisefilter. Individual sheet - {,[-]} indices can be specified. - ---no-blurfilter Disables the blurfilter. Individual sheet - {,[-]} indices can be specified. - ---no-grayfilter Disables the grayfilter. Individual sheet - {,[-]} indices can be specified. - ---no-mask-scan Disables mask-detection. Masks explicitly - {,[-]} set by --mask will still have effect. In- - dividual sheet indices can be specified. - ---no-mask-center Disables auto-centering of each mask. - {,[-]} Auto-centering is performed by default - if the --layout option has been set. In- - dividual sheet indices can be specified. - ---no-deskew Disables deskewing. Individual sheet - {,[-]} indices can be specified. - ---no-wipe Disables explicit wipe-areas. - {,[-]} This means the effect of parameter - --wipe can be disabled individually per - sheet. - ---no-border Disables explicitly set borders. - {,[-]} This means the effect of parameter - --border can be disabled individually per - sheet. - ---no-border-scan Disables border-scanning from the - {,[-]} edges of the sheet. Individual sheet - indices can be specified. - ---no-border-align Disables aligning of the area detected by - {,[-]} border-scanning (see --border-align). In- - dividual sheet indices can be specified. - --n --no-processing Do not perform any processing on a sheet - {,[-]} except pre/post rotating and mirroring, - and file-depth conversions on saving. - This option has the same effect as setting - all --no-xxx options together. Individual - sheet indices can be specified. - ---no-qpixels Disable qpixel-mode for deskewing (do not - internally use a 4x bigger image when - rotating). - ---no-multi-pages Disable multi-page processing even if the - input filename contains a '%' (usually - indicating the start of a placeholder for - the page counter). - ---dpi Dots per inch used for conversion of - measured size values, like e.g.'21cm, - 27.9cm'. Mind that this parameter should - occur before specifying any size value - with measurement suffix. (default: 300) - --t --type pbm|pgm Output file type. (default: as input) - --d --depth Output pixel depth. (default: as input) - --T --test-only Do not write any output. May be useful in - combination with --verbose to get informa- - tion about the input. - --in --input-file-sequence Sequence of input filename patterns which - is repeatedly traversed while resolving - input filenames. Specifying a single - entry is equivalent to the first filename - argument after the options-list. - --out --output-file-sequence Sequence of output filename patterns - which is repeatedly traversed while - resolving output filenames. Specifying a - single entry is equivalent to the second - filename argument after the options-list. - --si --start-input Set the first page number to substitute - for '%d' in input filenames. Every time - the input file sequence is repeated, this - number gets increased by 1. (default: - (startsheet-1)*inputpages+1) - --so --start-output Set the first page number to substitute - for '%d' in output filenames. Every time - the output file sequence is repeated, - this number gets increased by 1. - (default: (startsheet-1)*outputpages+1) - ---insert-blank {,[-]} Use blank input instead of an input file - from the input file sequence at the - specified index-positions. The input file - sequence will be interrupted temporarily - and will continue with the next input - file afterwards. This can be useful to - insert blank content into a sequence of - input images. - ---replace-blank {,[-]} Like --insert-blank, but the input images - at the specified index positions get - replaced with blank content and thus will - be ignored. - ---overwrite Allow overwriting existing files. - Otherwise the program terminates with an - error if an output-file to be written - already exists. - --q --quiet Quiet mode, no output at all. - --v --verbose Verbose output, more info messages. - --vv Even more verbose output, show parameter - settings before processing. - ---time Output processing time consumed. - --V --version Output version and build information. - diff -Nru unpaper-0.3/src/unpaper.c unpaper-0.4.2/src/unpaper.c --- unpaper-0.3/src/unpaper.c 2007-12-30 23:09:41.000000000 +0000 +++ unpaper-0.4.2/src/unpaper.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,5532 +0,0 @@ -/* --------------------------------------------------------------------------- -unpaper - written by Jens Gulden 2005-2007 */ - -const char* VERSION = "0.3"; - -const char* README = -"unpaper is a post-processing tool for scanned sheets of paper, especially for\n" -"book pages that have been scanned from previously created photocopies.\n" -"The main purpose is to make scanned book pages better readable on screen\n" -"after conversion to PDF. Additionally, unpaper might be useful to enhance\n" -"the quality of scanned pages before performing optical character recognition\n" -"(OCR).\n\n" - -"unpaper tries to clean scanned images by removing dark edges that appeared\n" -"through scanning or copying on areas outside the actual page content (e.g.\n" -"dark areas between the left-hand-side and the right-hand-side of a double-\n" -"sided book-page scan).\n" -"The program also tries to detect disaligned centering and rotation of pages\n" -"and will automatically straighten each page by rotating it to the correct\n" -"angle. This process is called \"deskewing\".\n" -"Note that the automatic processing will sometimes fail. It is always a good\n" -"idea to manually control the results of unpaper and adjust the parameter\n" -"settings according to the requirements of the input. Each processing step can\n" -"also be disabled individually for each sheet.\n\n" - -"Input and output files can be in either .pbm , .pgm or .ppm format, thus\n" -"generally in .pnm format, as also used by the Linux scanning tools scanimage\n" -"and scanadf.\n" -"Conversion to PDF can e.g. be achieved with the Linux tools pgm2tiff, tiffcp\n" -"and tiff2pdf."; - -const char* COMPILE = -"gcc -D TIMESTAMP=\"\" -lm -O3 -funroll-all-loops -fomit-frame-pointer -ftree-vectorize -o unpaper unpaper.c\n"; - -/* ------------------------------------------------------------------------ */ - -#include -#include -#include -#include -#include - -#ifdef TIMESTAMP -const char* BUILD = TIMESTAMP; -#else -const char* BUILD = NULL; -#endif - -const char* WELCOME = -"unpaper %s - written by Jens Gulden 2005-2007.\n" -"Licensed under the GNU General Public License, this comes with no warranty.\n"; - -const char* USAGE = -"Usage: unpaper [options] \n\n" -"Filenames may contain a formatting placeholder starting with '%%' to insert a\n" -"page counter for multi-page processing. E.g.: 'scan%%03d.pbm' to process files\n" -"scan001.pbm, scan002.pbm, scan003.pbm etc.\n"; - -const char* OPTIONS = -"-l --layout single Set default layout options for a sheet:\n" -" |double 'single': One page per sheet.\n" -" |none 'double': Two pages per sheet, landscape\n" -" orientation (one page on the left\n" -" half, one page on the right half).\n" -" 'none': No auto-layout, mask-scan-points\n" -" may individually be specified.\n" -" Using 'single' or 'double' automatically\n" -" sets corresponding --mask-scan-points.\n" -" The default is 'single'.\n\n" - -"-start --start-sheet Number of first sheet to process in multi-\n" -" sheet mode. (default: 1)\n\n" - -"-end --end-sheet Number of last sheet to process in multi-\n" -" sheet mode. -1 indicates processing until\n" -" no more input file with the corresponding\n" -" page number is available (default: -1)\n\n" - -"-# --sheet Optionally specifies which sheets to\n" -" {,[-]} process in the range between start-sheet\n" -" and end sheet.\n\n" - -"-x --exclude Excludes sheets from processing in the\n" -" {,[-]} range between start-sheet and end-sheet.\n\n" - -"--pre-rotate -90|90 Rotates the whole image clockwise (90) or\n" -" or anti-clockwise (-90) before any other\n" -" processing.\n\n" - -"--post-rotate -90|90 Rotates the whole image clockwise (90) or\n" -" or anti-clockwise (-90) after any other\n" -" processing.\n\n" - -"-M --pre-mirror Mirror the image, after possible pre-\n" -" [v[ertical]][,][h[orizontal]] rotation. Either 'v' (for vertical\n" -" mirroring), 'h' (for horizontal mirroring)\n" -" or 'v,h' (for both) can be specified.\n\n" - -"--post-mirror Mirror the image, after any other\n" -" [v[ertical]][,][h[orizontal]] processing except possible post-\n" -" rotation.\n\n" - -"--pre-shift , Shift the image before further processing.\n" -" Values for 'h' (horizontal shift) and 'v'\n" -" (vertical shift) can either be positive\n" -" or negative.\n\n" - -"--post-shift , Shift the image after other processing.\n" -" Values for 'h' (horizontal shift) and 'v'\n" -" (vertical shift) can either be positive\n" -" or negative.\n\n" - -"--pre-wipe Manually wipe out an area before further\n" -" ,,, processing. Any pixel in a wiped area\n" -" will be set to white. Multiple areas to\n" -" be wiped may be specified by multiple\n" -" occurrences of this options.\n\n" - -"--post-wipe Manually wipe out an area after\n" -" ,,, processing. Any pixel in a wiped area\n" -" will be set to white. Multiple areas to\n" -" be wiped may be specified by multiple\n" -" occurrences of this options.\n\n" - -"--pre-border Clear the border-area of the sheet before\n" -" ,,, further processing. Any pixel in the\n" -" border area will be set to white.\n\n" - -"--post-border Clear the border-area after processing.\n" -" ,,, Any pixel in the border area will be set\n" -" to white.\n\n" - -"--pre-mask ,,, Specify masks to apply before any other\n" -" processing. Any pixel outside a mask\n" -" will be set to white, unless another mask\n" -" includes this pixel.\n" -" Only pixels inside a mask will remain.\n" -" Multiple masks may be specified. No\n" -" deskewing will be applied to the masks\n" -" specified by --pre-mask.\n\n" - -"-s --size , Change the sheet size before other pro-\n" -" | cessing is applied. Content on the sheet\n" -" gets zoomed to fit to the appropriate\n" -" size, but the aspect ratio is preserved.\n" -" Instead, if the sheet\'s aspect ratio\n" -" changes, the zoomed content gets centered\n" -" on the sheet. Size-name can also be a\n" -" standard name as 'a4', 'letter', etc.\n" -" Possible size names are:\n" -" a5\n" -" a4\n" -" a3\n" -" letter\n" -" legal.\n" -" All size names can also be applied in\n" -" rotated landscape orientation, use\n" -" 'a4-landscape', 'letter-landscape' etc.\n\n" - -"--post-size ,| Change the sheet size preserving the\n" -" content's aspect ratio after other\n" -" processing steps are applied.\n\n" - -"--stretch ,| Change the sheet size before other\n" -" processing is applied. Content on the\n" -" sheet gets stretched to the specified\n" -" size, possibly changing the aspect ratio.\n\n" - -"--post-stretch , Change the sheet size after other\n" -" | processing is applied. Content on the\n" -" sheet gets stretched to the specified\n" -" size, possibly changing the aspect ratio.\n\n" - -"-z --zoom Change the sheet size according to the\n" -" given factor before other processing is\n" -" done.\n\n" - -"--post-zoom Change the sheet size according to the\n" -" given factor after processing is done.\n\n" - -"-bn --blackfilter-scan-direction Directions in which to search for solidly\n" -" [v[ertical]][,][h[orizontal]] black areas. Either 'v' (for vertical\n" -" scanning), 'h' (for horizontal scanning)\n" -" of 'v,h' (for both) can be specified.\n" -" (default: 'v,h')\n\n" - -"-bs --blackfilter-scan-size Width of virtual bar used for mask\n" -" |, detection. Two values may be specified\n" -" to individually set horizontal and\n" -" vertical size. (default: 20,20)\n\n" - -"-bd --blackfilter-scan-depth Size of virtual bar used for black area\n" -" | detection. (default: 500,500)\n\n" - -"-bp --blackfilter-scan-step Steps to move virtual bar for black area\n" -" | detection. (default: 5,5)\n\n" - -"-bt --blackfilter-scan-threshold Ratio of dark pixels above which a black\n" -" area gets detected. (default: 0.95).\n\n" - -"-bx --blackfilter-scan-exclude Area on which the blackfilter should not\n" -" ,,, operate. This can be useful to prevent\n" -" the blackfilter from working on inner\n" -" page content. May be specified multiple\n" -" times to set more than one area.\n\n" - -"-bi --blackfilter-intensity Intensity with which to delete black\n" -" areas. Larger values will leave less\n" -" noise-pixels around former black areas,\n" -" but may delete page content. (default:\n" -" 20)\n\n" - -"-ni --noisefilter-intensity Intensity with which to delete individual\n" -" pixels or tiny clusters of pixels. Any\n" -" cluster which only contains n dark pixels\n" -" together will be deleted. (default: 4)\n\n" - -"-ls --blurfilter-size Size of blurfilter area to search for\n" -" |, 'lonely' clusters of pixels.\n" -" (default: 100,100)\n\n" - -"-lp --blurfilter-step Size of 'blurring' steps in each\n" -" |, direction. (default: 50,50)\n\n" - -"-li --blurfilter-intensity Relative intensity with which to delete\n" -" tiny clusters of pixels. Any blurred area\n" -" which contains at most the ratio of dark\n" -" pixels will be cleared. (default: 0.01)\n\n" - -"-gs --grayfilter-size Size of grayfilter mask to search for\n" -" |, 'gray-only' areas of pixels.\n" -" (default: 50,50)\n\n" - -"-gp --grayfilter-step Size of steps moving the grayfilter mask\n" -" |, in each direction. (default: 20,20)\n\n" - -"-gt --grayfilter-threshold Relative intensity of grayness which is\n" -" accepted before clearing the grayfilter\n" -" mask in cases where no black pixel is\n" -" found in the mask. (default: 0.5)\n\n" - -"-p --mask-scan-point , Manually set starting point for mask-\n" -" detection. Multiple --mask-scan-point\n" -" options may be specified to detect\n" -" multiple masks.\n\n" - -"-m --mask ,,, Manually add a mask, in addition to masks\n" -" automatically detected around the --mask-\n" -" scan-point coordinates (unless --no-mask-\n" -" scan is specified).\n" -" Any pixel outside a mask will be\n" -" set to white, unless another mask\n" -" covers this pixel.\n\n" - -"-mn --mask-scan-direction Directions in which to search for mask\n" -" [v[ertical]][,][h[orizontal]] borders, starting from --mask-scan-point\n" -" coordinates. Either 'v' (for vertical\n" -" scanning), 'h' (for horizontal scanning)\n" -" of 'v,h' (for both) can be specified.\n" -" (default: 'h' ('v' may cut text-\n" -" paragraphs on single-page sheets))\n\n" - -"-ms --mask-scan-size | Width of the virtual bar used for mask\n" -" detection. Two values may be specified\n" -" to individually set horizontal and\n" -" vertical size. (default: 50,50)\n\n" - -"-md --mask-scan-depth | Height of the virtual bar used for mask\n" -" detection. (default: -1,-1, using the\n" -" total width or height of the sheet)\n\n" - -"-mp --mask-scan-step | Steps to move the virtual bar for mask\n" -" detection. (default: 5,5)\n\n" - -"-mt --mask-scan-threshold | Ratio of dark pixels below which an edge\n" -" gets detected, relative to max. blackness\n" -" when counting from the start coordinate\n" -" heading towards one edge. (default: 0.1)\n\n" - -"-mm --mask-scan-minimum , Minimum allowed size of an auto-detected\n" -" mask. Masks detected below this size will\n" -" be ignored and set to the size specified\n" -" by mask-scan-maximum. (default: 100,100)\n\n" - -"-mM --mask-scan-maximum , Maximum allowed size of an auto-detected\n" -" mask. Masks detected above this size will\n" -" be shrunk to the maximum value, each\n" -" direction individually. (default:\n" -" sheet size, or page size derived from\n" -" --layout option.\n\n" - -"-mc --mask-color Color value with which to wipe out pixels\n" -" not covered by any mask. Maybe useful for\n" -" testing in order to visualize the effect\n" -" of masking. (Note that an RGB-value is\n" -" expected: R*65536 + G*256 + B.)\n\n" - -"-dn --deskew-scan-direction Edges from which to scan for rotation.\n" -" [left],[top],[right],[bottom] Each edge of a mask can be used to detect\n" -" the mask's rotation. If multiple edges\n" -" are specified, the average value will be\n" -" used, unless the statistical deviation\n" -" exceeds --deskew-scan-deviation. Use\n" -" 'left' for scanning from the left edge,\n" -" 'top' for scanning from the top edge,\n" -" 'right' for scanning from the right edge,\n" -" 'bottom' for scanning from the bottom.\n" -" Multiple directions can be separated by\n" -" commas. (default: 'left,right')\n\n" - -"-ds --deskew-scan-size Size of virtual line for rotation\n" -" detection. (default: 1500)\n\n" - -"-dd --deskew-scan-depth Amount of dark pixels to accumulate until\n" -" scanning is stopped, relative to scan-bar\n" -" size. (default: 0.5)\n\n" - -"-dr --deskew-scan-range Range in which to search for rotation,\n" -" from -degrees to +degrees rotation.\n" -" (default: 5.0)\n\n" - -"-dp --deskew-scan-step Steps between single rotation-angle\n" -" detections.\n" -" Lower numbers lead to better results but\n" -" slow down processing. (default: 0.1)\n\n" - -"-dv --deskew-scan-deviation Maximum statistical deviation allowed\n" -" among the results from detected edges.\n" -" No rotation if exceeded. (default: 1.0)\n\n" - -"-W --wipe Manually wipe out an area. Any pixel in\n" -" ,,, a wiped area will be set to white.\n" -" Multiple --wipe areas may be specified.\n" -" This is applied after deskewing and\n" -" before automatic border-scan.\n\n" - -"-mw --middle-wipe If --layout is set to 'double', this\n" -" |, may specify the size of a middle area to\n" -" wipe out between the two pages on the\n" -" sheet. This may be useful if the\n" -" blackfilter fails to remove some black\n" -" areas (e.g. resulting from photo-copying\n" -" in the middle between two pages).\n\n" - -"-B --border Manually add a border. Any pixel in the\n" -" ,,, border area will be set to white. This is\n" -" applied after deskewing and before\n" -" automatic border-scan.\n\n" - -"-Bn --border-scan-direction Directions in which to search for outer\n" -" [v[ertical]][,][h[orizontal]] border. Either 'v' (for vertical\n" -" scanning), 'h' (for horizontal scanning)\n" -" of 'v,h' (for both) can be specified.\n" -" (default: 'v')\n\n" - -"-Bs --border-scan-size | Width of virtual bar used for border\n" -" detection. Two values may be specified\n" -" to individually set horizontal and\n" -" vertical size. (default: 5,5)\n\n" - -"-Bp --border-scan-step | Steps to move virtual bar for border\n" -" detection. (default: 5,5)\n\n" - -"-Bt --border-scan-threshold Absolute number of dark pixels covered by\n" -" the border-scan mask above which a border\n" -" is detected. (default: 5)\n\n" - -"-Ba --border-align Direction where to shift the detected\n" -" [left],[top],[right],[bottom] border-area. Use --border-margin to\n" -" specify horizontal and vertical distances\n" -" to be kept from the sheet-edge.\n" -" (default: none)\n\n" - -"-Bm --border-margin Distance to keep from the sheet edge when\n" -" , aligning a border area. May use\n" -" measurement suffices such as cm, in.\n\n" - -"-w --white-threshold Brightness ratio above which a pixel is\n" -" considered white.\n" -" (default: 0.9)\n\n" - -"-b --black-threshold Brightness ratio below which a pixel is\n" -" considered black (non-gray). This is used\n" -" by the gray-filter. This value is also\n" -" used when converting a grayscale image to\n" -" black-and-white mode (default: 0.33)\n\n" - -"-ip --input-pages 1|2 If '2' is specified, read two input\n" -" images instead of one and internally\n" -" combine them to a doubled-layout sheet\n" -" before further processing.\n" -" Before internally combining, --pre-\n" -" rotation is optionally applied\n" -" individually to both input images as the\n" -" very first processing steps.\n\n" - -"-op --output-pages 1|2 If '2' is specified, write two output\n" -" images instead of one, as a result of\n" -" splitting a doubled-layout sheet after\n" -" processing. After splitting the sheet,\n" -" --post-rotation is optionally applied\n" -" individually to both output images as the\n" -" very last processing step.\n\n" - -"-S --sheet-size , Force a fix sheet size. Usually, the\n" -" | sheet size is determined by the input\n" -" image size (if input-pages=1), or by the\n" -" double size of the first page in a\n" -" two-page input set (if input-pages=2).\n" -" If the input image is smaller than the\n" -" size specified here, it will appear\n" -" centered and surrounded with a white\n" -" border on the sheet. If the input image is\n" -" bigger, it will be centered and the edges\n" -" will be cropped. This option may also be\n" -" helpful to get regular sized output\n" -" images if the input image sizes differ.\n" -" Standard size-names like 'a4-landscape',\n" -" 'letter', etc. may be used (see --size).\n" -" (default: as in input file)\n\n" - -"--sheet-background black|white Sets a color with which the sheet is\n" -" filled before any image is loaded and\n" -" placed onto it. This can be useful when\n" -" the sheet size and the image size differ.\n\n" - -"--no-blackfilter Disables black area scan. Individual sheet\n" -" {,[-]} indices can be specified.\n\n" - -"--no-noisefilter Disables the noisefilter. Individual sheet\n" -" {,[-]} indices can be specified.\n\n" - -"--no-blurfilter Disables the blurfilter. Individual sheet\n" -" {,[-]} indices can be specified.\n\n" - -"--no-grayfilter Disables the grayfilter. Individual sheet\n" -" {,[-]} indices can be specified.\n\n" - -"--no-mask-scan Disables mask-detection. Masks explicitly\n" -" {,[-]} set by --mask will still have effect. In-\n" -" dividual sheet indices can be specified.\n\n" - -"--no-mask-center Disables auto-centering of each mask.\n" -" {,[-]} Auto-centering is performed by default\n" -" if the --layout option has been set. In-\n" -" dividual sheet indices can be specified.\n\n" - -"--no-deskew Disables deskewing. Individual sheet\n" -" {,[-]} indices can be specified.\n\n" - -"--no-wipe Disables explicit wipe-areas.\n" -" {,[-]} This means the effect of parameter\n" -" --wipe can be disabled individually per\n" -" sheet.\n\n" - -"--no-border Disables explicitly set borders.\n" -" {,[-]} This means the effect of parameter\n" -" --border can be disabled individually per\n" -" sheet.\n\n" - -"--no-border-scan Disables border-scanning from the\n" -" {,[-]} edges of the sheet. Individual sheet\n" -" indices can be specified.\n\n" - -"--no-border-align Disables aligning of the area detected by\n" -" {,[-]} border-scanning (see --border-align). In-\n" -" dividual sheet indices can be specified.\n\n" - -"-n --no-processing Do not perform any processing on a sheet\n" -" {,[-]} except pre/post rotating and mirroring,\n" -" and file-depth conversions on saving.\n" -" This option has the same effect as setting\n" -" all --no-xxx options together. Individual\n" -" sheet indices can be specified.\n\n" - -"--no-qpixels Disable qpixel-mode for deskewing (do not\n" -" internally use a 4x bigger image when\n" -" rotating).\n\n" - -"--no-multi-pages Disable multi-page processing even if the\n" -" input filename contains a '%%' (usually\n" -" indicating the start of a placeholder for\n" -" the page counter).\n\n" - -"--dpi Dots per inch used for conversion of\n" -" measured size values, like e.g.'21cm,\n" -" 27.9cm'. Mind that this parameter should\n" -" occur before specifying any size value\n" -" with measurement suffix. (default: 300)\n\n" - -"-t --type pbm|pgm Output file type. (default: as input)\n\n" - -"-d --depth Output pixel depth. (default: as input)\n\n" - -"-T --test-only Do not write any output. May be useful in\n" -" combination with --verbose to get informa-\n" -" tion about the input.\n\n" - -"-in --input-file-sequence Sequence of input filename patterns which\n" -" is repeatedly traversed while resolving\n" -" input filenames. Specifying a single\n" -" entry is equivalent to the first filename\n" -" argument after the options-list.\n\n" - -"-out --output-file-sequence Sequence of output filename patterns\n" -" which is repeatedly traversed while\n" -" resolving output filenames. Specifying a\n" -" single entry is equivalent to the second\n" -" filename argument after the options-list.\n\n" - -"-si --start-input Set the first page number to substitute\n" -" for '%%d' in input filenames. Every time\n" -" the input file sequence is repeated, this\n" -" number gets increased by 1. (default:\n" -" (startsheet-1)*inputpages+1)\n\n" - -"-so --start-output Set the first page number to substitute\n" -" for '%%d' in output filenames. Every time\n" -" the output file sequence is repeated,\n" -" this number gets increased by 1.\n" -" (default: (startsheet-1)*outputpages+1)\n\n" - -"--insert-blank {,[-]} Use blank input instead of an input file\n" -" from the input file sequence at the\n" -" specified index-positions. The input file\n" -" sequence will be interrupted temporarily\n" -" and will continue with the next input\n" -" file afterwards. This can be useful to\n" -" insert blank content into a sequence of\n" -" input images.\n\n" - -"--replace-blank {,[-]} Like --insert-blank, but the input images\n" -" at the specified index positions get\n" -" replaced with blank content and thus will\n" -" be ignored.\n\n" - -"--overwrite Allow overwriting existing files.\n" -" Otherwise the program terminates with an\n" -" error if an output-file to be written\n" -" already exists.\n\n" - -"-q --quiet Quiet mode, no output at all.\n\n" - -"-v --verbose Verbose output, more info messages.\n\n" - -"-vv Even more verbose output, show parameter\n" -" settings before processing.\n\n" - -"--time Output processing time consumed.\n\n" - -"-V --version Output version and build information.\n\n"; - -//-vvv --debug Undocumented. -//-vvvv --debug-save Undocumented. -//--help-options Undocumented. -//--help-usage Undocumented. -//--help-readme Undocumented. -//--help-compile Undocumented. - - -const char* HELP = -"Run 'unpaper --help' for usage information.\n"; - - -/* --- preprocessor macros ------------------------------------------------ */ - -#define abs(value) ( (value) >=0 ? (value) : -(value) ) -#define max(a, b) ( (a >= b) ? (a) : (b) ) -#define pluralS(i) ( (i > 1) ? "s" : "" ) -#define pixelValue(r, g, b) ( (r)<<16 | (g)<<8 | (b) ) -#define pixelGrayscaleValue(g) ( (g)<<16 | (g)<<8 | (g) ) -#define pixelGrayscale(r, g, b) ( ( ( r == g ) && ( r == b ) ) ? r : ( ( r + g + b ) / 3 ) ) // average (optimized for already gray values) -#define pixelLightness(r, g, b) ( r < g ? ( r < b ? r : b ) : ( g < b ? g : b ) ) // minimum -#define pixelDarknessInverse(r, g, b) ( r > g ? ( r > b ? r : b ) : ( g > b ? g : b ) ) // maximum -#define red(pixel) ( (pixel >> 16) & 0xff ) -#define green(pixel) ( (pixel >> 8) & 0xff ) -#define blue(pixel) ( pixel & 0xff ) - - -/* --- preprocessor constants ---------------------------------------------- */ - -#define MAX_MULTI_INDEX 10000 // maximum pixel count of virtual line to detect rotation with -#define MAX_ROTATION_SCAN_SIZE 10000 // maximum pixel count of virtual line to detect rotation with -#define MAX_MASKS 100 -#define MAX_POINTS 100 -#define MAX_FILES 100 -#define MAX_PAGES 2 -#define WHITE 255 -#define GRAY 127 -#define BLACK 0 -#define BLANK_TEXT "" - - -/* --- typedefs ----------------------------------------------------------- */ - -typedef enum { - FALSE, - TRUE -} BOOLEAN; - -typedef enum { - VERBOSE_QUIET = -1, - VERBOSE_NONE = 0, - VERBOSE_NORMAL = 1, - VERBOSE_MORE = 2, - VERBOSE_DEBUG = 3, - VERBOSE_DEBUG_SAVE = 4 -} VERBOSE_LEVEL; - -typedef enum { - X, - Y, - COORDINATES_COUNT -} COORDINATES; - -typedef enum { - WIDTH, - HEIGHT, - DIMENSIONS_COUNT -} DIMENSIONS; - -typedef enum { - HORIZONTAL, - VERTICAL, - DIRECTIONS_COUNT -} DIRECTIONS; - -typedef enum { - LEFT, - TOP, - RIGHT, - BOTTOM, - EDGES_COUNT -} EDGES; - -typedef enum { - LAYOUT_NONE, - LAYOUT_SINGLE, - LAYOUT_DOUBLE, - LAYOUTS_COUNT -} LAYOUTS; - -typedef enum { - BRIGHT, - DARK, - SHADINGS_COUNT -} SHADINGS; - -typedef enum { - RED, - GREEN, - BLUE, - COLORCOMPONENTS_COUNT -} COLORCOMPONENTS; - -typedef enum { - PBM, - PGM, - PPM, - FILETYPES_COUNT -} FILETYPES; - - -/* --- struct ------------------------------------------------------------- */ - -struct IMAGE { - unsigned char* buffer; - unsigned char* bufferGrayscale; - unsigned char* bufferLightness; - unsigned char* bufferDarknessInverse; - int width; - int height; - int bitdepth; - BOOLEAN color; - int background; -}; - - -/* --- constants ---------------------------------------------------------- */ - -// file type names (see typedef FILETYPES) -const char FILETYPE_NAMES[FILETYPES_COUNT][5] = { - "pbm", - "pgm", - "ppm" -}; - -// factors for conversion to inches -#define MEASUREMENTS_COUNT 3 -const char MEASUREMENTS[MEASUREMENTS_COUNT][2][15] = { - { "in", "1.0" }, - { "cm", "0.393700787" }, - { "mm", "0.0393700787" } -}; - -// papersize alias names -#define PAPERSIZES_COUNT 10 -const char PAPERSIZES[PAPERSIZES_COUNT][2][50] = { - { "a5", "14.8cm,21cm" }, - { "a5-landscape", "21cm,14.8cm" }, - { "a4", "21cm,29.7cm" }, - { "a4-landscape", "29.7cm,21cm" }, - { "a3", "29.7cm,42cm" }, - { "a3-landscape", "42cm,29.7cm" }, - { "letter", "8.5in,11in" }, - { "letter-landscape", "11in,8.5in" }, - { "legal", "8.5in,14in" }, - { "legal-landscape", "14in,8.5in" } -}; - - -// color alias names -#define COLORS_COUNT 2 -const char COLORS[COLORS_COUNT][2][50] = { - { "black", "#000000" }, - { "white", "#ffffff" } -}; - - -/* --- global variable ---------------------------------------------------- */ - -VERBOSE_LEVEL verbose; - - - -/**************************************************************************** - * tool functions * - ****************************************************************************/ - - -/* --- arithmetic tool functions ------------------------------------------ */ - -/** - * Returns the quadratic square of a number. - */ -double sqr(double d) { - return d*d; -} - - -/** - * Converts degrees to radians. - */ -double degreesToRadians(double d) { - return d * M_PI / 180.0; -} - - -/** - * Converts radians to degrees. - */ -double radiansToDegrees(double r) { - return r * 180.0 / M_PI; -} - - -/** - * Limits an integer value to a maximum. - */ -void limit(int* i, int max) { - if (*i > max) { - *i = max; - } -} - - -/* --- tool functions for parameter parsing and verbose output ------------ */ - -/** - * Parses a parameter string on occurrences of 'vertical', 'horizontal' or both. - */ -int parseDirections(char* s, int* exitCode) { - int dir = 0; - if (strchr(s, 'h') != 0) { // (there is no 'h' in 'vertical'...) - dir = 1< 0) { - if (s[0] != NULL) { - strcpy(buf, s[0]); - } else { - strcpy(buf, BLANK_TEXT); - } - for (i = 1; i < cnt; i++) { - if (s[i] != NULL) { - sprintf(buf, "%s, %s", buf, s[i]); - } else { - sprintf(buf, "%s, %s", buf, BLANK_TEXT); - } - } - } else { - buf[0] = 0; //strcpy(buf, ""); - } - return buf; -} - -/** - * Parses a string at argv[*i] argument consisting of comma-concatenated - * integers. The string may also be of a different format, in which case - * *i remains unchanged and *multiIndexCount is set to -1. - * - * @see isInMultiIndex(..) - */ -void parseMultiIndex(int* i, char* argv[], int multiIndex[], int* multiIndexCount) { - char s1[MAX_MULTI_INDEX * 5]; // buffer - char s2[MAX_MULTI_INDEX * 5]; // buffer - char c; - int index; - int j; - - (*i)++; - *multiIndexCount = 0; - if (argv[*i][0] != '-') { // not another option directly following - strcpy(s1, argv[*i]); // argv[*i] -> s1 - do { - index = -1; - s2[0] = (char)0; // = "" - sscanf(s1, "%d%c%s", &index, &c, s2); - if (index != -1) { - multiIndex[(*multiIndexCount)++] = index; - if (c=='-') { // range is specified: get range end - strcpy(s1, s2); // s2 -> s1 - sscanf(s1, "%d,%s", &index, s2); - for (j = multiIndex[(*multiIndexCount)-1]+1; j <= index; j++) { - multiIndex[(*multiIndexCount)++] = j; - } - } - } else { - // string is not correctly parseable: break without inreasing *i (string may be e.g. input-filename) - *multiIndexCount = -1; // disable all - (*i)--; - return; // exit here - } - strcpy(s1, s2); // s2 -> s1 - } while ((*multiIndexCount < MAX_MULTI_INDEX) && (strlen(s1) > 0)); - } else { // no explicit list of sheet-numbers given - *multiIndexCount = -1; // disable all - (*i)--; - return; - } -} - - -/** - * Tests whether an integer is included in the array of integers given as multiIndex. - * If multiIndexCount is -1, each possible integer is considered to be in the - * multiIndex list. - * - * @see parseMultiIndex(..) - */ -BOOLEAN isInMultiIndex(int index, int multiIndex[MAX_MULTI_INDEX], int multiIndexCount) { - int i; - - if (multiIndexCount == -1) { - return TRUE; // all - } else { - for (i = 0; i < multiIndexCount; i++) { - if (index == multiIndex[i]) { - return TRUE; // found in list - } - } - return FALSE; // not found in list - } -} - - -/** - * Tests whether 'index' is either part of multiIndex or excludeIndex. - * (Throughout the application, excludeIndex generalizes several individual - * multi-indices: if an entry is part of excludeIndex, it is treated as being - * an entry of all other multiIndices, too.) - */ -BOOLEAN isExcluded(int index, int multiIndex[MAX_MULTI_INDEX], int multiIndexCount, int excludeIndex[MAX_MULTI_INDEX], int excludeIndexCount) { - return ( (isInMultiIndex(index, excludeIndex, excludeIndexCount) == TRUE) || (isInMultiIndex(index, multiIndex, multiIndexCount) == TRUE) ); -} - - -/** - * Outputs all entries in an array of integer to the console. - */ -void printMultiIndex(int multiIndex[MAX_MULTI_INDEX], int multiIndexCount) { - int i; - - if (multiIndexCount == -1) { - printf("all"); - } else if (multiIndexCount == 0) { - printf("none"); - } else { - for (i = 0; i < multiIndexCount; i++) { - printf("%d", multiIndex[i]); - if (i < multiIndexCount-1) { - printf(","); - } - } - } - printf("\n"); -} - - -/** - * Tests if a point is covered by a mask. - */ -BOOLEAN inMask(int x, int y, int mask[EDGES_COUNT]) { - if ( (x >= mask[LEFT]) && (x <= mask[RIGHT]) && (y >= mask[TOP]) && (y <= mask[BOTTOM]) ) { - return TRUE; - } else { - return FALSE; - } -} - - -/** - * Tests if masks a and b overlap. - */ -BOOLEAN masksOverlap(int a[EDGES_COUNT], int b[EDGES_COUNT]) { - return ( inMask(a[LEFT], a[TOP], b) || inMask(a[RIGHT], a[BOTTOM], b) ); -} - - -/** - * Tests if at least one mask in masks overlaps with m. - */ -BOOLEAN masksOverlapAny(int m[EDGES_COUNT], int masks[MAX_MASKS][EDGES_COUNT], int masksCount) { - int i; - - for ( i = 0; i < masksCount; i++ ) { - if ( masksOverlap(m, masks[i]) ) { - return TRUE; - } - } - return FALSE; -} - - -/* --- tool functions for image handling ---------------------------------- */ - -/** - * Allocates a memory block for storing image data and fills the IMAGE-struct - * with the specified values. - */ -void initImage(struct IMAGE* image, int width, int height, int bitdepth, BOOLEAN color, int background) { - int size; - - size = width * height; - if ( color ) { - image->bufferGrayscale = (unsigned char*)malloc(size); - image->bufferLightness = (unsigned char*)malloc(size); - image->bufferDarknessInverse = (unsigned char*)malloc(size); - memset(image->bufferGrayscale, background, size); - memset(image->bufferLightness, background, size); - memset(image->bufferDarknessInverse, background, size); - size *= 3; - } - image->buffer = (unsigned char*)malloc(size); - memset(image->buffer, background, size); - if ( ! color ) { - image->bufferGrayscale = image->buffer; - image->bufferLightness = image->buffer; - image->bufferDarknessInverse = image->buffer; - } - image->width = width; - image->height = height; - image->bitdepth = bitdepth; - image->color = color; - image->background = background; -} - - -/** - * Frees an image. - */ -void freeImage(struct IMAGE* image) { - free(image->buffer); - if (image->color) { - free(image->bufferGrayscale); - free(image->bufferLightness); - free(image->bufferDarknessInverse); - } -} - - -/** - * Replaces one image with another. - */ -void replaceImage(struct IMAGE* image, struct IMAGE* newimage) { - freeImage(image); - // pass-back new image - *image = *newimage; // copy whole struct -} - - -/** - * Sets the color/grayscale value of a single pixel. - * - * @return TRUE if the pixel has been changed, FALSE if the original color was the one to set - */ -BOOLEAN setPixel(int pixel, int x, int y, struct IMAGE* image) { - unsigned char* p; - int w, h; - int pos; - BOOLEAN result; - unsigned char r, g, b; - - w = image->width; - h = image->height; - if ( (x < 0) || (x >= w) || (y < 0) || (y >= h) ) { - return FALSE; //nop - } else { - pos = (y * w) + x; - r = (pixel >> 16) & 0xff; - g = (pixel >> 8) & 0xff; - b = pixel & 0xff; - if ( ! image->color ) { - p = &image->buffer[pos]; - if ((r == g) && (r == b)) { // optimization (avoid division by 3) - pixel = r; - } else { - pixel = pixelGrayscale(r, g, b); // convert to gray (will already be in most cases, but we can't be sure) - } - if (*p != (unsigned char)pixel) { - *p = (unsigned char)pixel; - return TRUE; - } else { - return FALSE; - } - } else { // color - result = FALSE; - p = &image->buffer[pos*3]; - if (*p != r) { - *p = r; - result = TRUE; - } - p++; - if (*p != g) { - *p = g; - result = TRUE; - } - p++; - if (*p != b) { - *p = b; - result = TRUE; - } - if ( result ) { // modified: update cached grayscale, lightness and brightnessInverse values - image->bufferGrayscale[pos] = pixelGrayscale(r, g, b); - image->bufferLightness[pos] = pixelLightness(r, g, b); - image->bufferDarknessInverse[pos] = pixelDarknessInverse(r, g, b); - } - return result; - } - } -} - - -/** - * Returns the color or grayscale value of a single pixel. - * Always returns a color-compatible value (which may be interpreted as 8-bit grayscale) - * - * @return color or grayscale-value of the requested pixel, or WHITE if the coordinates are outside the image - */ -int getPixel(int x, int y, struct IMAGE* image) { - int w, h; - int pos; - int pix; - unsigned char r, g, b; - - w = image->width; - h = image->height; - if ( (x < 0) || (x >= w) || (y < 0) || (y >= h) ) { - return pixelValue(WHITE, WHITE, WHITE); - } else { - pos = (y * w) + x; - if ( ! image->color ) { - pix = (unsigned char)image->buffer[pos]; - return pixelValue(pix, pix, pix); - } else { // color - pos *= 3; - r = (unsigned char)image->buffer[pos++]; - g = (unsigned char)image->buffer[pos++]; - b = (unsigned char)image->buffer[pos]; - return pixelValue(r, g, b); - } - } -} - - -/** - * Returns a color component of a single pixel (0-255). - * - * @param colorComponent either RED, GREEN or BLUE - * @return color or grayscale-value of the requested pixel, or WHITE if the coordinates are outside the image - */ - /* (currently not used) -int getPixelComponent(int x, int y, int colorComponent, struct IMAGE* image) { - int w, h; - int pos; - - w = image->width; - h = image->height; - if ( (x < 0) || (x >= w) || (y < 0) || (y >= h) ) { - return WHITE; - } else { - pos = (y * w) + x; - if ( ! image->color ) { - return (unsigned char)image->buffer[pos]; - } else { // color - return (unsigned char)image->buffer[(pos * 3) + colorComponent]; - } - } -} -*/ - -/** - * Returns the grayscale (=brightness) value of a single pixel. - * - * @return grayscale-value of the requested pixel, or WHITE if the coordinates are outside the image - */ -int getPixelGrayscale(int x, int y, struct IMAGE* image) { - int w, h; - int pos; - - w = image->width; - h = image->height; - if ( (x < 0) || (x >= w) || (y < 0) || (y >= h) ) { - return WHITE; - } else { - pos = (y * w) + x; - return image->bufferGrayscale[pos]; - } -} - - -/** - * Returns the 'lightness' value of a single pixel. For color images, this - * value denotes the minimum brightness of a single color-component in the - * total color, which means that any color is considered 'dark' which has - * either the red, the green or the blue component (or, of course, several - * of them) set to a high value. In some way, this is a measure how close a - * color is to white. - * For grayscale images, this value is equal to the pixel brightness. - * - * @return lightness-value (the higher, the lighter) of the requested pixel, or WHITE if the coordinates are outside the image - */ -int getPixelLightness(int x, int y, struct IMAGE* image) { - int w, h; - int pos; - - w = image->width; - h = image->height; - if ( (x < 0) || (x >= w) || (y < 0) || (y >= h) ) { - return WHITE; - } else { - pos = (y * w) + x; - return image->bufferLightness[pos]; - } -} - - -/** - * Returns the 'inverse-darkness' value of a single pixel. For color images, this - * value denotes the maximum brightness of a single color-component in the - * total color, which means that any color is considered 'light' which has - * either the red, the green or the blue component (or, of course, several - * of them) set to a high value. In some way, this is a measure how far away a - * color is to black. - * For grayscale images, this value is equal to the pixel brightness. - * - * @return inverse-darkness-value (the LOWER, the darker) of the requested pixel, or WHITE if the coordinates are outside the image - */ -int getPixelDarknessInverse(int x, int y, struct IMAGE* image) { - int w, h; - int pos; - - w = image->width; - h = image->height; - if ( (x < 0) || (x >= w) || (y < 0) || (y >= h) ) { - return WHITE; - } else { - pos = (y * w) + x; - return image->bufferDarknessInverse[pos]; - } -} - - -/** - * Sets the color/grayscale value of a single pixel to either black or white. - * - * @return TRUE if the pixel has been changed, FALSE if the original color was the one to set - */ -BOOLEAN setPixelBW(int x, int y, struct IMAGE* image, int blackwhite) { - unsigned char* p; - int w, h; - int pos; - BOOLEAN result; - - w = image->width; - h = image->height; - if ( (x < 0) || (x >= w) || (y < 0) || (y >= h) ) { - return FALSE; //nop - } else { - pos = (y * w) + x; - if ( ! image->color ) { - p = &image->buffer[pos]; - if (*p != blackwhite) { - *p = blackwhite; - return TRUE; - } else { - return FALSE; - } - } else { // color - p = &image->buffer[pos * 3]; - result = FALSE; - if (*p != blackwhite) { - *p = blackwhite; - result = TRUE; - } - p++; - if (*p != blackwhite) { - *p = blackwhite; - result = TRUE; - } - p++; - if (*p != blackwhite) { - *p = blackwhite; - result = TRUE; - } - return result; - } - } -} - - -/** - * Sets the color/grayscale value of a single pixel to white. - * - * @return TRUE if the pixel has been changed, FALSE if the original color was the one to set - */ -BOOLEAN clearPixel(int x, int y, struct IMAGE* image) { - return setPixelBW(x, y, image, WHITE); -} - - -/** - * Clears a rectangular area of pixels with either black or white. - * @return The number of pixels actually changed from black (dark) to white. - */ -int clearRect(int left, int top, int right, int bottom, struct IMAGE* image, int blackwhite) { - int x; - int y; - int count; - - count = 0; - for (y = top; y <= bottom; y++) { - for (x = left; x <= right; x++) { - if (setPixelBW(x, y, image, blackwhite)) { - count++; - } - } - } - return count; -} - - -/** - * Copies one area of an image into another. - */ -void copyImageArea(int x, int y, int width, int height, struct IMAGE* source, int toX, int toY, struct IMAGE* target) { - int row; - int col; - int pixel; - // naive but generic implementation - for (row = 0; row < height; row++) { - for (col = 0; col < width; col++) { - pixel = getPixel(x+col, y+row, source); - setPixel(pixel, toX+col, toY+row, target); - } - } -} - - -/** - * Copies a whole image into another. - */ -void copyImage(struct IMAGE* source, int toX, int toY, struct IMAGE* target) { - copyImageArea(0, 0, source->width, source->height, source, toX, toY, target); -} - - -/** - * Centers one area of an image inside an area of another image. - * If the source area is smaller than the target area, is is equally - * surrounded by a white border, if it is bigger, it gets equally cropped - * at the edges. - */ -void centerImageArea(int x, int y, int w, int h, struct IMAGE* source, int toX, int toY, int ww, int hh, struct IMAGE* target) { - if ((w < ww) || (h < hh)) { // white rest-border will remain, so clear first - clearRect(toX, toY, toX + ww - 1, toY + hh - 1, target, target->background); - } - if (w < ww) { - toX += (ww - w) / 2; - } - if (h < hh) { - toY += (hh - h) / 2; - } - if (w > ww) { - x += (w - ww) / 2; - w = ww; - } - if (h > hh) { - y += (h - hh) / 2; - h = hh; - } - copyImageArea(x, y, w, h, source, toX, toY, target); -} - - -/** - * Centers a whole image inside an area of another image. - */ -void centerImage(struct IMAGE* source, int toX, int toY, int ww, int hh, struct IMAGE* target) { - centerImageArea(0, 0, source->width, source->height, source, toX, toY, ww, hh, target); -} - - -/** - * Returns the average brightness of a rectagular area. - */ -int brightnessRect(int x1, int y1, int x2, int y2, struct IMAGE* image) { - int x; - int y; - int pixel; - int total; - int count; - total = 0; - count = (x2-x1+1)*(y2-y1+1); - for (x = x1; x <= x2; x++) { - for (y = y1; y <= y2; y++) { - pixel = getPixelGrayscale(x, y, image); - total += pixel; - } - } - return total / count; -} - - -/** - * Returns the average lightness of a rectagular area. - */ -int lightnessRect(int x1, int y1, int x2, int y2, struct IMAGE* image) { - int x; - int y; - int pixel; - int total; - int count; - total = 0; - count = (x2-x1+1)*(y2-y1+1); - for (x = x1; x <= x2; x++) { - for (y = y1; y <= y2; y++) { - pixel = getPixelLightness(x, y, image); - total += pixel; - } - } - return total / count; -} - - -/** - * Returns the average darkness of a rectagular area. - */ -int darknessInverseRect(int x1, int y1, int x2, int y2, struct IMAGE* image) { - int x; - int y; - int pixel; - int total; - int count; - total = 0; - count = (x2-x1+1)*(y2-y1+1); - for (x = x1; x <= x2; x++) { - for (y = y1; y <= y2; y++) { - pixel = getPixelDarknessInverse(x, y, image); - total += pixel; - } - } - return total / count; -} - - -/** - * Counts the number of pixels in a rectangular area whose grayscale - * values ranges between minColor and maxBrightness. Optionally, the area can get - * cleared with white color while counting. - */ -int countPixelsRect(int left, int top, int right, int bottom, int minColor, int maxBrightness, BOOLEAN clear, struct IMAGE* image) { - int x; - int y; - int pixel; - int count; - - count = 0; - for (y = top; y <= bottom; y++) { - for (x = left; x <= right; x++) { - pixel = getPixelGrayscale(x, y, image); - if ((pixel>=minColor) && (pixel <= maxBrightness)) { - if (clear==TRUE) { - clearPixel(x, y, image); - } - count++; - } - } - } - return count; -} - - -/** - * Counts the number of dark pixels around the pixel at (x,y), who have a - * square-metric distance of 'level' to the (x,y) (thus, testing the values - * of 9 pixels if level==1, 16 pixels if level==2 and so on). - * Optionally, the pixels can get cleared after counting. - */ -int countPixelNeighborsLevel(int x, int y, BOOLEAN clear, int level, int whiteMin, struct IMAGE* image) { - int xx; - int yy; - int count; - int pixel; - - count = 0; - // upper and lower rows - for (xx = x - level; xx <= x + level; xx++) { - // upper row - pixel = getPixelLightness(xx, y - level, image); - if (pixel < whiteMin) { // non-light pixel found - if (clear == TRUE) { - clearPixel(xx, y - level, image); - } - count++; - } - // lower row - pixel = getPixelLightness(xx, y + level, image); - if (pixel < whiteMin) { - if (clear == TRUE) { - clearPixel(xx, y + level, image); - } - count++; - } - } - // middle rows - for (yy = y-(level-1); yy <= y+(level-1); yy++) { - // first col - pixel = getPixelLightness(x - level, yy, image); - if (pixel < whiteMin) { - if (clear == TRUE) { - clearPixel(x - level, yy, image); - } - count++; - } - // last col - pixel = getPixelLightness(x + level, yy, image); - if (pixel < whiteMin) { - if (clear == TRUE) { - clearPixel(x + level, yy, image); - } - count++; - } - } - /* old version, not optimized: - for (yy = y-level; yy <= y+level; yy++) { - for (xx = x-level; xx <= x+level; xx++) { - if (abs(xx-x)==level || abs(yy-y)==level) { - pixel = getPixelLightness(xx, yy, image); - if (pixel < whiteMin) { - if (clear==TRUE) { - clearPixel(xx, yy, image); - } - count++; - } - } - } - }*/ - return count; -} - - -/** - * Count all dark pixels in the distance 0..intensity that are directly - * reachable from the dark pixel at (x,y), without having to cross bright - * pixels. - */ -int countPixelNeighbors(int x, int y, int intensity, int whiteMin, struct IMAGE* image) { - int level; - int count; - int lCount; - - count = 1; // assume self as set - lCount = -1; - for (level = 1; (lCount != 0) && (level <= intensity); level++) { // can finish when one level is completely zero - lCount = countPixelNeighborsLevel(x, y, FALSE, level, whiteMin, image); - count += lCount; - } - return count; -} - - -/** - * Clears all dark pixels that are directly reachable from the dark pixel at - * (x,y). This should be called only if it has previously been detected that - * the amount of pixels to clear will be reasonable small. - */ -void clearPixelNeighbors(int x, int y, int whiteMin, struct IMAGE* image) { - int level; - int lCount; - - clearPixel(x, y, image); - lCount = -1; - for (level = 1; lCount != 0; level++) { // lCount will become 0, otherwise countPixelNeighbors() would previously have delivered a bigger value (and this here would not have been called) - lCount = countPixelNeighborsLevel(x, y, TRUE, level, whiteMin, image); - } -} - - -/** - * Flood-fill an area of pixels. - * (Declaration of header for indirect recursive calls.) - */ -void floodFill(int x, int y, int color, int maskMin, int maskMax, int intensity, struct IMAGE* image); - - -/** - * Solidly fills a line of pixels heading towards a specified direction - * until color-changes in the pixels to overwrite exceed the 'intensity' - * parameter. - * - * @param stepX either -1 or 1, if stepY is 0, else 0 - * @param stepY either -1 or 1, if stepX is 0, else 0 - */ -int fillLine(int x, int y, int stepX, int stepY, int color, int maskMin, int maskMax, int intensity, struct IMAGE* image) { - int pixel; - int distance; - int intensityCount; - int w, h; - - w = image->width; - h = image->height; - distance = 0; - intensityCount = 1; // first pixel must match, otherwise directly exit - while (1==1) { // ! - x += stepX; - y += stepY; - pixel = getPixelGrayscale(x, y, image); - if ((pixel>=maskMin) && (pixel<=maskMax)) { - intensityCount = intensity; // reset counter - } else { - intensityCount--; // allow maximum of 'intensity' pixels to be bright, until stop - } - if ((intensityCount > 0) && (x>=0) && (x=0) && (y=maskMin) && (pixel<=maskMax)) { - // first, fill a 'cross' (both vertical, horizontal line) - setPixel(color, x, y, image); - left = fillLine(x, y, -1, 0, color, maskMin, maskMax, intensity, image); - top = fillLine(x, y, 0, -1, color, maskMin, maskMax, intensity, image); - right = fillLine(x, y, 1, 0, color, maskMin, maskMax, intensity, image); - bottom = fillLine(x, y, 0, 1, color, maskMin, maskMax, intensity, image); - // now recurse on each neighborhood-pixel of the cross (most recursions will immediately return) - floodFillAroundLine(x, y, -1, 0, left, color, maskMin, maskMax, intensity, image); - floodFillAroundLine(x, y, 0, -1, top, color, maskMin, maskMax, intensity, image); - floodFillAroundLine(x, y, 1, 0, right, color, maskMin, maskMax, intensity, image); - floodFillAroundLine(x, y, 0, 1, bottom, color, maskMin, maskMax, intensity, image); - } -} - - - -/* --- tool function for file handling ------------------------------------ */ - -/** - * Tests if a file exists. - */ -BOOLEAN fileExists(char* filename) { - FILE *f; - f = fopen(filename,"r"); - if (f == NULL) { - return FALSE; - } else { - fclose(f); - return TRUE; - } -} - - -/** - * Loads image data from a file in pnm format. - * - * @param filename name of file to load - * @param image structure to hold loaded image - * @param type returns the type of the loaded image - * @return TRUE on success, FALSE on failure - */ -BOOLEAN loadImage(char* filename, struct IMAGE* image, int* type) { - FILE *f; - int fileSize; - int bytesPerLine; - char magic[10]; - char word[255]; - char c; - int maxColorIndex; - int inputSize; - int inputSizeFile; - int read; - unsigned char* buffer2; - int lineOffsetInput; - int lineOffsetOutput; - int x; - int y; - int bb; - int off; - int bits; - int bit; - int pixel; - int size; - int pos; - unsigned char* p; - unsigned char r, g, b; - - if (verbose>=VERBOSE_MORE) { - printf("loading file %s.\n", filename); - } - - // open input file - f = fopen(filename, "rb"); - if (f == NULL) { - printf("*** error: Unable to open file %s.\n", filename); - return FALSE; - } - - // get file size - fseek(f, 0, SEEK_END); // to end - fileSize = ftell(f); - rewind(f); // back to start - - // read magic number - fread(magic, 1, 2, f); - magic[2] = 0; // terminate - if (strcmp(magic, "P4")==0) { - *type = PBM; - image->bitdepth = 1; - image->color = FALSE; - } else if (strcmp(magic, "P5")==0) { - *type = PGM; - image->bitdepth = 8; - image->color = FALSE; - } else if (strcmp(magic, "P6")==0) { - *type = PPM; - image->bitdepth = 8; - image->color = TRUE; - } else { - printf("*** error: input file format using magic '%s' is unknown.\n", magic); - return FALSE; - } - - // get image info: width, height, optionally depth - fgetc(f); // skip \n after magic number - fscanf(f, "%s", word); - while (word[0]=='#') { // skip comment lines - do { - fscanf(f, "%c", &c); - } while ((feof(f)==0)&&(c!='\n')); - fscanf(f, "%s", word); - } - // now reached width/height pair as decimal ascii - sscanf(word, "%d", &image->width); - fscanf(f, "%d", &image->height); - fgetc(f); // skip \n after width/height pair - if (*type == PBM) { - bytesPerLine = (image->width + 7) / 8; - } else { // PGM or PPM - fscanf(f, "%s", word); - while (word[0]=='#') { // skip comment lines - do { - fscanf(f, "%c", &c); - } while ((feof(f) == 0) && (c != '\n')); - fscanf(f, "%s", word); - } - // read max color value - sscanf(word, "%d", &maxColorIndex); - fgetc(f); // skip \n after max color index - if (maxColorIndex > 255) { - printf("*** error: grayscale / color-component bit depths above 8 are not supported.\n"); - return FALSE; - } - bytesPerLine = image->width; - if (*type == PPM) { - bytesPerLine *= 3; // 3 color-components per pixel - } - } - - // read binary image data - inputSizeFile = fileSize - ftell(f); - inputSize = bytesPerLine * image->height; - - image->buffer = (unsigned char*)malloc(inputSize); - read = fread(image->buffer, 1, inputSize, f); - if (read != inputSize) { - printf("*** error: Only %d out of %d could be read.\n", read, inputSize); - return FALSE; - } - - if (*type == PBM) { // internally convert b&w to 8-bit for processing - buffer2 = (unsigned char*)malloc(image->width * image->height); - lineOffsetInput = 0; - lineOffsetOutput = 0; - for (y = 0; y < image->height; y++) { - for (x = 0; x < image->width; x++) { - bb = x >> 3; // x / 8; - off = x & 7; // x % 8; - bit = 128>>off; - bits = image->buffer[lineOffsetInput + bb]; - bits &= bit; - if (bits == 0) { // 0: white pixel - pixel = 0xff; - } else { - pixel = 0x00; - } - buffer2[lineOffsetOutput+x] = pixel; // set as whole byte - } - lineOffsetInput += bytesPerLine; - lineOffsetOutput += image->width; - } - free(image->buffer); - image->buffer = buffer2; - } - fclose(f); - - if (*type == PPM) { - // init cached values for grayscale, lightness and darknessInverse - size = image->width * image->height; - image->bufferGrayscale = (unsigned char*)malloc(size); - image->bufferLightness = (unsigned char*)malloc(size); - image->bufferDarknessInverse = (unsigned char*)malloc(size); - p = image->buffer; - for (pos = 0; pos < size; pos++) { - r = *p; - p++; - g = *p; - p++; - b = *p; - p++; - image->bufferGrayscale[pos] = pixelGrayscale(r, g, b); - image->bufferLightness[pos] = pixelLightness(r, g, b); - image->bufferDarknessInverse[pos] = pixelDarknessInverse(r, g, b); - } - } else { - image->bufferGrayscale = image->buffer; - image->bufferLightness = image->buffer; - image->bufferDarknessInverse = image->buffer; - } - - return TRUE; -} - - -/** - * Saves image data to a file in pgm or pbm format. - * - * @param filename name of file to save - * @param image image to save - * @param type filetype of the image to save - * @param overwrite allow overwriting existing files - * @param blackThreshold threshold for grayscale-to-black&white conversion - * @return TRUE on success, FALSE on failure - */ -BOOLEAN saveImage(char* filename, struct IMAGE* image, int type, BOOLEAN overwrite, float blackThreshold) { - unsigned char* buf; - int bytesPerLine; - int inputSize; - int outputSize; - int lineOffsetOutput; - int offsetInput; - int offsetOutput; - int x; - int y; - int pixel; - int b; - int off; - unsigned char bit; - unsigned char val; - char* outputMagic; - FILE* outputFile; - int blackThresholdAbs; - BOOLEAN result; - - if (verbose>=VERBOSE_MORE) { - printf("saving file %s.\n", filename); - } - - result = TRUE; - if (type == PBM) { // convert to pbm - blackThresholdAbs = WHITE * (1.0 - blackThreshold); - bytesPerLine = (image->width + 7) >> 3; // / 8; - outputSize = bytesPerLine * image->height; - buf = (unsigned char*)malloc(outputSize); - memset(buf, 0, outputSize); - lineOffsetOutput = 0; - for (y = 0; y < image->height; y++) { - for (x = 0; x < image->width; x++) { - pixel = getPixelGrayscale(x, y, image); - b = x >> 3; // / 8; - off = x & 7; // % 8; - bit = 128>>off; - val = buf[lineOffsetOutput + b]; - if (pixel < blackThresholdAbs) { // dark - val |= bit; // set bit to one: black - } else { // bright - val &= (~bit); // set bit to zero: white - } - buf[lineOffsetOutput+b] = val; - } - lineOffsetOutput += bytesPerLine; - } - } else if (type == PPM) { // maybe convert to color - outputSize = image->width * image->height * 3; - if (image->color) { // color already - buf = image->buffer; - } else { // convert to color - buf = (unsigned char*)malloc(outputSize); - inputSize = image->width * image->height; - offsetOutput = 0; - for (offsetInput = 0; offsetInput < inputSize; offsetInput++) { - pixel = image->buffer[offsetInput]; - buf[offsetOutput++] = pixel; - buf[offsetOutput++] = pixel; - buf[offsetOutput++] = pixel; - } - } - } else { // PGM - outputSize = image->width * image->height; - buf = image->buffer; - } - - switch (type) { - case PBM: - outputMagic = "P4"; - break; - case PPM: - outputMagic = "P6"; - break; - default: // PGM - outputMagic = "P5"; - break; - } - - // write to file - if ( overwrite || ( ! fileExists( filename ) ) ) { - outputFile = fopen(filename, "wb"); - if (outputFile != 0) { - fprintf(outputFile, "%s\n", outputMagic); - fprintf(outputFile, "# generated by unpaper\n"); - fprintf(outputFile, "%u %u\n", image->width, image->height); - if ((type == PGM)||(type == PPM)) { - fprintf(outputFile, "255\n"); // maximum color index per color-component - } - fwrite(buf, 1, outputSize, outputFile); - fclose(outputFile); - } else { - printf("*** error: Cannot open output file '%s'.\n", filename); - result = FALSE; - } - } else { - printf("file %s already exists (use --overwrite to replace).\n", filename); - result = FALSE; - } - if (buf != image->buffer) { - free(buf); - } - return result; -} - - -/** - * Saves the image if full debugging mode is enabled. - */ -void saveDebug(char* filename, struct IMAGE* image) { - int type; - - if (verbose >= VERBOSE_DEBUG_SAVE) { - if (image->color) { - type = PPM; - } else if (image->bitdepth == 1) { - type = PBM; - } else { - type = PGM; - } - saveImage(filename, image, type, TRUE, 0.5); // 0.5 is a dummy, not used because PGM depth - } -} - - - -/**************************************************************************** - * image processing functions * - ****************************************************************************/ - - -/* --- deskewing ---------------------------------------------------------- */ - -/** - * Returns the maximum peak value that occurs when shifting a rotated virtual line above the image, - * starting from one edge of an area and moving towards the middle point of the area. - * The peak value is calulated by the absolute difference in the average blackness of pixels that occurs between two single shifting steps. - * - * @param m ascending slope of the virtually shifted (m=tan(angle)). Mind that this is negative for negative radians. - */ -int detectEdgeRotationPeak(double m, int deskewScanSize, float deskewScanDepth, int shiftX, int shiftY, int left, int top, int right, int bottom, struct IMAGE* image) { - int width; - int height; - int mid; - int half; - int sideOffset; - int outerOffset; - double X; // unrounded coordinates - double Y; - double stepX; - double stepY; - int x[MAX_ROTATION_SCAN_SIZE]; - int y[MAX_ROTATION_SCAN_SIZE]; - int xx; - int yy; - int lineStep; - int dep; - int pixel; - int blackness; - int lastBlackness; - int diff; - int maxDiff; - int maxBlacknessAbs; - int maxDepth; - int accumulatedBlackness; - - width = right-left+1; - height = bottom-top+1; - maxBlacknessAbs = (int) 255 * deskewScanSize * deskewScanDepth; - - if (shiftY==0) { // horizontal detection - if (deskewScanSize == -1) { - deskewScanSize = height; - } - limit(&deskewScanSize, MAX_ROTATION_SCAN_SIZE); - limit(&deskewScanSize, height); - - maxDepth = width/2; - half = deskewScanSize/2; - outerOffset = (int)(abs(m) * half); - mid = height/2; - sideOffset = shiftX > 0 ? left-outerOffset : right+outerOffset; - X = sideOffset + half * m; - Y = top + mid - half; - stepX = -m; - stepY = 1.0; - } else { // vertical detection - if (deskewScanSize == -1) { - deskewScanSize = width; - } - limit(&deskewScanSize, MAX_ROTATION_SCAN_SIZE); - limit(&deskewScanSize, width); - maxDepth = height/2; - half = deskewScanSize/2; - outerOffset = (int)(abs(m) * half); - mid = width/2; - sideOffset = shiftY > 0 ? top-outerOffset : bottom+outerOffset; - X = left + mid - half; - Y = sideOffset - (half * m); - stepX = 1.0; - stepY = -m; // (line goes upwards for negative degrees) - } - - // fill buffer with coordinates for rotated line in first unshifted position - for (lineStep = 0; lineStep < deskewScanSize; lineStep++) { - x[lineStep] = (int)X; - y[lineStep] = (int)Y; - X += stepX; - Y += stepY; - } - - // now scan for edge, modify coordinates in buffer to shift line into search direction (towards the middle point of the area) - // stop either when detectMaxDepth steps are shifted, or when diff falls back to less than detectThreshold*maxDiff - lastBlackness = 0; - diff = 0; - maxDiff = 0; - accumulatedBlackness = 0; - for (dep = 0; (accumulatedBlackness < maxBlacknessAbs) && (dep < maxDepth) ; dep++) { - // calculate blackness of virtual line - blackness = 0; - for (lineStep = 0; lineStep < deskewScanSize; lineStep++) { - xx = x[lineStep]; - x[lineStep] += shiftX; - yy = y[lineStep]; - y[lineStep] += shiftY; - if ((xx >= left) && (xx <= right) && (yy >= top) && (yy <= bottom)) { - pixel = getPixelDarknessInverse(xx, yy, image); - blackness += (255 - pixel); - } - } - diff = blackness - lastBlackness; - lastBlackness = blackness; - if (diff >= maxDiff) { - maxDiff = diff; - } - accumulatedBlackness += blackness; - } - if (dep < maxDepth) { // has not terminated only because middle was reached - return maxDiff; - } else { - return 0; - } -} - - -/** - * Detects rotation at one edge of the area specified by left, top, right, bottom. - * Which of the four edges to take depends on whether shiftX or shiftY is non-zero, - * and what sign this shifting value has. - */ -double detectEdgeRotation(float deskewScanRange, float deskewScanStep, int deskewScanSize, float deskewScanDepth, int shiftX, int shiftY, int left, int top, int right, int bottom, struct IMAGE* image) { - // either shiftX or shiftY is 0, the other value is -i|+i - // depending on shiftX/shiftY the start edge for shifting is determined - double rangeRad; - double stepRad; - double rotation; - int peak; - int maxPeak; - double detectedRotation; - double m; - - rangeRad = degreesToRadians((double)deskewScanRange); - stepRad = degreesToRadians((double)deskewScanStep); - detectedRotation = 0.0; - maxPeak = 0; - // iteratively increase test angle, alterating between +/- sign while increasing absolute value - for (rotation = 0.0; rotation <= rangeRad; rotation = (rotation>=0.0) ? -(rotation + stepRad) : -rotation ) { - m = tan(rotation); - peak = detectEdgeRotationPeak(m, deskewScanSize, deskewScanDepth, shiftX, shiftY, left, top, right, bottom, image); - if (peak > maxPeak) { - detectedRotation = rotation; - maxPeak = peak; - } - } - return radiansToDegrees(detectedRotation); -} - - -/** - * Detect rotation of a whole area. - * Angles between -deskewScanRange and +deskewScanRange are scanned, at either the - * horizontal or vertical edges of the area specified by left, top, right, bottom. - */ -double detectRotation(int deskewScanEdges, int deskewScanRange, float deskewScanStep, int deskewScanSize, float deskewScanDepth, float deskewScanDeviation, int left, int top, int right, int bottom, struct IMAGE* image) { - double rotation[4]; - int count; - double total; - double average; - double deviation; - int i; - - count = 0; - - if ((deskewScanEdges & 1<= VERBOSE_NORMAL) { - printf("detected rotation left: [%d,%d,%d,%d]: %f\n", left,top,right,bottom, rotation[count]); - } - count++; - } - if ((deskewScanEdges & 1<= VERBOSE_NORMAL) { - printf("detected rotation top: [%d,%d,%d,%d]: %f\n", left,top,right,bottom, rotation[count]); - } - count++; - } - if ((deskewScanEdges & 1<= VERBOSE_NORMAL) { - printf("detected rotation right: [%d,%d,%d,%d]: %f\n", left,top,right,bottom, rotation[count]); - } - count++; - } - if ((deskewScanEdges & 1<= VERBOSE_NORMAL) { - printf("detected rotation bottom: [%d,%d,%d,%d]: %f\n", left,top,right,bottom, rotation[count]); - } - count++; - } - - total = 0.0; - for (i = 0; i < count; i++) { - total += rotation[i]; - } - average = total / count; - total = 0.0; - for (i = 0; i < count; i++) { - total += sqr(rotation[i]-average); - } - deviation = sqrt(total); - if (verbose >= VERBOSE_NORMAL) { - printf("rotation average: %f deviation: %f rotation-scan-deviation (maximum): %f [%d,%d,%d,%d]\n", average, deviation, deskewScanDeviation, left,top,right,bottom); - } - if (deviation <= deskewScanDeviation) { - return average; - } else { - if (verbose >= VERBOSE_NONE) { - printf("out of deviation range - NO ROTATING\n"); - } - return 0.0; - } -} - - -/** - * Rotates a whole image buffer by the specified radians, around its middle-point. - * Usually, the buffer should have been converted to a qpixels-representation before, to increase quality. - * (To rotate parts of an image, extract the part with copyBuffer, rotate, and re-paste with copyBuffer.) - */ -//void rotate(double radians, struct IMAGE* source, struct IMAGE* target, double* trigonometryCache, int trigonometryCacheBaseSize) { -void rotate(double radians, struct IMAGE* source, struct IMAGE* target) { - int x; - int y; - int midX; - int midY; - int midMax; - int halfX; - int halfY; - int dX; - int dY; - float m11; - float m12; - float m21; - float m22; - int diffX; - int diffY; - int oldX; - int oldY; - int pixel; - float sinval; - float cosval; - int w, h; - - w = source->width; - h = source->height; - halfX = (w-1)/2; - halfY = (h-1)/2; - midX = w/2; - midY = h/2; - midMax = max(midX, midY); - - // create 2D rotation matrix - sinval = sin(radians); // no use of sincos()-function for compatibility, no performace bottleneck anymore anyway - cosval = cos(radians); - m11 = cosval; - m12 = sinval; - m21 = -sinval; - m22 = cosval; - - // step through all pixels of the target image, - // symmetrically in all four quadrants to reduce trigonometric calculations - - for (dY = 0; dY <= midMax; dY++) { - - for (dX = 0; dX <= midMax; dX++) { - - // matrix multiplication to get rotated pixel pos (as in quadrant I) - diffX = dX * m11 + dY * m21; - diffY = dX * m12 + dY * m22; - - // quadrant I - x = midX + dX; - y = midY - dY; - if ((x < w) && (y >= 0)) { - oldX = midX + diffX; - oldY = midY - diffY; - pixel = getPixel(oldX, oldY, source); - setPixel(pixel, x, y, target); - } - - // quadrant II - x = halfX - dY; - y = midY - dX; - if ((x >=0) && (y >= 0)) { - oldX = halfX - diffY; - oldY = midY - diffX; - pixel = getPixel(oldX, oldY, source); - setPixel(pixel, x, y, target); - } - - // quadrant III - x = halfX - dX; - y = halfY + dY; - if ((x >=0) && (y < h)) { - oldX = halfX - diffX; - oldY = halfY + diffY; - pixel = getPixel(oldX, oldY, source); - setPixel(pixel, x, y, target); - } - - // quadrant IV - x = midX + dY; - y = halfY + dX; - if ((x < w) && (y < h)) { - oldX = midX + diffY; - oldY = halfY + diffX; - pixel = getPixel(oldX, oldY, source); - setPixel(pixel, x, y, target); - } - } - } -} - - -/** - * Converts an image buffer to a qpixel-representation, i.e. enlarge the whole - * whole image both horizontally and vertically by factor 2 (leading to a - * factor 4 increase in total). - * qpixelBuf must have been allocated before with 4-times amount of memory as - * buf. - */ -void convertToQPixels(struct IMAGE* image, struct IMAGE* qpixelImage) { - int x; - int y; - int xx; - int yy; - int pixel; - - yy = 0; - for (y = 0; y < image->height; y++) { - xx = 0; - for (x = 0; x < image->width; x++) { - pixel = getPixel(x, y, image); - setPixel(pixel, xx, yy, qpixelImage); - setPixel(pixel, xx+1, yy, qpixelImage); - setPixel(pixel, xx, yy+1, qpixelImage); - setPixel(pixel, xx+1, yy+1, qpixelImage); - xx += 2; - } - yy += 2; - } -} - - -/** - * Converts an image buffer back from a qpixel-representation to normal, i.e. - * shrinks the whole image both horizontally and vertically by factor 2 - * (leading to a factor 4 decrease in total). - * buf must have been allocated before with 1/4-times amount of memory as - * qpixelBuf. - */ -void convertFromQPixels(struct IMAGE* qpixelImage, struct IMAGE* image) { - int x; - int y; - int xx; - int yy; - int pixel; - int a,b,c,d; - int r, g, bl; - - yy = 0; - for (y = 0; y < image->height; y++) { - xx = 0; - for (x = 0; x < image->width; x++) { - a = getPixel(xx, yy, qpixelImage); - b = getPixel(xx+1, yy, qpixelImage); - c = getPixel(xx, yy+1, qpixelImage); - d = getPixel(xx+1, yy+1, qpixelImage); - r = (red(a) + red(b) + red(c) + red(d)) / 4; - g = (green(a) + green(b) + green(c) + green(d)) / 4; - bl = (blue(a) + blue(b) + blue(c) + blue(d)) / 4; - pixel = pixelValue(r, g, bl); - setPixel(pixel, x, y, image); - xx += 2; - } - yy += 2; - } -} - - -/* --- stretching / resizing / shifting ------------------------------------ */ - -/** - * Stretches the image so that the resulting image has a new size. - * - * @param w the new width to stretch to - * @param h the new height to stretch to - */ -void stretch(int w, int h, struct IMAGE* image) { - struct IMAGE newimage; - int x; - int y; - int matrixX; - int matrixY; - int matrixWidth; - int matrixHeight; - int blockWidth; - int blockHeight; - int blockWidthRest; - int blockHeightRest; - int fillIndexWidth; - int fillIndexHeight; - int fill; - int xx; - int yy; - int sum; - int sumR; - int sumG; - int sumB; - int sumCount; - int pixel; - - if (verbose >= VERBOSE_MORE) { - printf("stretching %dx%d -> %dx%d\n", image->width, image->height, w, h); - } - - // allocate new buffer's memory - initImage(&newimage, w, h, image->bitdepth, image->color, WHITE); - - blockWidth = image->width / w; // (0 if enlarging, i.e. w > image->width) - blockHeight = image->height / h; - - if (w <= image->width) { - blockWidthRest = (image->width) % w; - } else { // modulo-operator doesn't work as expected: (3680 % 7360)==3680 ! (not 7360 as expected) - // shouldn't always be a % b = b if a < b ? - blockWidthRest = w; - } - - if (h <= image->height) { - blockHeightRest = (image->height) % h; - } else { - blockHeightRest = h; - } - - // for each new pixel, get a matrix of pixels from which the new pixel should be derived - // (when enlarging, this matrix is always of size 1x1) - matrixY = 0; - fillIndexHeight = 0; - for (y = 0; y < h; y++) { - fillIndexWidth = 0; - matrixX = 0; - if ( ( (y * blockHeightRest) / h ) == fillIndexHeight ) { // next fill index? - // (If our optimizer is cool, the above "* blockHeightRest / h" will disappear - // when images are enlarged, because in that case blockHeightRest = h has been set before, - // thus we're in a Kripke-branch where blockHeightRest and h are the same variable. - // No idea if gcc's optimizer does this...) (See again below.) - fillIndexHeight++; - fill = 1; - } else { - fill = 0; - } - matrixHeight = blockHeight + fill; - for (x = 0; x < w; x++) { - if ( ( (x * blockWidthRest) / w ) == fillIndexWidth ) { // next fill index? - fillIndexWidth++; - fill = 1; - } else { - fill = 0; - } - matrixWidth = blockWidth + fill; - // if enlarging, map corrdinates directly - if (blockWidth == 0) { // enlarging - matrixX = (x * image->width) / w; - } - if (blockHeight == 0) { // enlarging - matrixY = (y * image->height) / h; - } - - // calculate average pixel value in source matrix - if ((matrixWidth == 1) && (matrixHeight == 1)) { // optimization: quick version - pixel = getPixel(matrixX, matrixY, image); - } else { - sumCount = 0; - if (!image->color) { - sum = 0; - for (yy = 0; yy < matrixHeight; yy++) { - for (xx = 0; xx < matrixWidth; xx++) { - sum += getPixelGrayscale(matrixX + xx, matrixY + yy, image); - sumCount++; - } - } - sum = sum / sumCount; - pixel = pixelGrayscaleValue(sum); - } else { // color - sumR = 0; - sumG = 0; - sumB = 0; - for (yy = 0; yy < matrixHeight; yy++) { - for (xx = 0; xx < matrixWidth; xx++) { - pixel = getPixel(matrixX + xx, matrixY + yy, image); - sumR += (pixel >> 16) & 0xff; - sumG += (pixel >> 8) & 0xff; - sumB += pixel & 0xff; - //sumR += getPixelComponent(matrixX + xx, matrixY + yy, RED, image); - //sumG += getPixelComponent(matrixX + xx, matrixY + yy, GREEN, image); - //sumB += getPixelComponent(matrixX + xx, matrixY + yy, BLUE, image); - sumCount++; - } - } - pixel = pixelValue( sumR/sumCount, sumG/sumCount, sumB/sumCount ); - } - } - setPixel(pixel, x, y, &newimage); - - // pixel may have resulted in a gray value, which will be converted to 1-bit - // when the file gets saved, if .pbm format requested. black-threshold will apply. - - if (blockWidth > 0) { // shrinking - matrixX += matrixWidth; - } - } - if (blockHeight > 0) { // shrinking - matrixY += matrixHeight; - } - } - replaceImage(image, &newimage); -} - -/** - * Resizes the image so that the resulting sheet has a new size and the image - * content is zoomed to fit best into the sheet, while keeping it's aspect ration. - * - * @param w the new width to resize to - * @param h the new height to resize to - */ -void resize(int w, int h, struct IMAGE* image) { - struct IMAGE newimage; - int ww; - int hh; - float wRat; - float hRat; - - if (verbose >= VERBOSE_NORMAL) { - printf("resizing %dx%d -> %dx%d\n", image->width, image->height, w, h); - } - - wRat = (float)w / image->width; - hRat = (float)h / image->height; - if (wRat < hRat) { // horizontally more shrinking/less enlarging is needed: fill width fully, adjust height - ww = w; - hh = image->height * w / image->width; - } else if (hRat < wRat) { - ww = image->width * h / image->height; - hh = h; - } else { // wRat == hRat - ww = w; - hh = h; - } - stretch(ww, hh, image); - initImage(&newimage, w, h, image->bitdepth, image->color, image->background); - centerImage(image, 0, 0, w, h, &newimage); - replaceImage(image, &newimage); -} - - -/** - * Shifts the image. - * - * @param shiftX horizontal shifting - * @param shiftY vertical shifting - */ -void shift(int shiftX, int shiftY, struct IMAGE* image) { - struct IMAGE newimage; - int x; - int y; - int pixel; - - // allocate new buffer's memory - initImage(&newimage, image->width, image->height, image->bitdepth, image->color, image->background); - - for (y = 0; y < image->height; y++) { - for (x = 0; x < image->width; x++) { - pixel = getPixel(x, y, image); - setPixel(pixel, x + shiftX, y + shiftY, &newimage); - } - } - replaceImage(image, &newimage); -} - - -/* --- mask-detection ----------------------------------------------------- */ - -/** - * Finds one edge of non-black pixels headig from one starting point towards edge direction. - * - * @return number of shift-steps until blank edge found - */ -int detectEdge(int startX, int startY, int shiftX, int shiftY, int maskScanSize, int maskScanDepth, float maskScanThreshold, struct IMAGE* image) { - // either shiftX or shiftY is 0, the other value is -i|+i - int left; - int top; - int right; - int bottom; - int half; - int halfDepth; - int blackness; - int total; - int count; - - half = maskScanSize / 2; - total = 0; - count = 0; - if (shiftY==0) { // vertical border is to be detected, horizontal shifting of scan-bar - if (maskScanDepth == -1) { - maskScanDepth = image->height; - } - halfDepth = maskScanDepth / 2; - left = startX - half; - top = startY - halfDepth; - right = startX + half; - bottom = startY + halfDepth; - } else { // horizontal border is to be detected, vertical shifting of scan-bar - if (maskScanDepth == -1) { - maskScanDepth = image->width; - } - halfDepth = maskScanDepth / 2; - left = startX - halfDepth; - top = startY - half; - right = startX + halfDepth; - bottom = startY + half; - } - - while (TRUE) { // ! - blackness = 255 - brightnessRect(left, top, right, bottom, image); - total += blackness; - count++; - // is blackness below threshold*average? - if ((blackness < ((maskScanThreshold*total)/count))||(blackness==0)) { // this will surely become true when pos reaches the outside of the actual image area and blacknessRect() will deliver 0 because all pixels outside are considered white - return count; // ! return here, return absolute value of shifting difference - } - left += shiftX; - right += shiftX; - top += shiftY; - bottom += shiftY; - } -} - - -/** - * Detects a mask of white borders around a starting point. - * The result is returned via call-by-reference parameters left, top, right, bottom. - * - * @return the detected mask in left, top, right, bottom; or -1, -1, -1, -1 if no mask could be detected - */ -BOOLEAN detectMask(int startX, int startY, int maskScanDirections, int maskScanSize[DIRECTIONS_COUNT], int maskScanDepth[DIRECTIONS_COUNT], int maskScanStep[DIRECTIONS_COUNT], float maskScanThreshold[DIRECTIONS_COUNT], int maskScanMinimum[DIMENSIONS_COUNT], int maskScanMaximum[DIMENSIONS_COUNT], int* left, int* top, int* right, int* bottom, struct IMAGE* image) { - int width; - int height; - int half[DIRECTIONS_COUNT]; - BOOLEAN success; - - half[HORIZONTAL] = maskScanSize[HORIZONTAL] / 2; - half[VERTICAL] = maskScanSize[VERTICAL] / 2; - if ((maskScanDirections & 1<width - 1; - } - if ((maskScanDirections & 1<height - 1; - } - - // if below minimum or above maximum, set to maximum - width = *right - *left; - height = *bottom - *top; - success = TRUE; - if ( ((maskScanMinimum[WIDTH] != -1) && (width < maskScanMinimum[WIDTH])) || ((maskScanMaximum[WIDTH] != -1) && (width > maskScanMaximum[WIDTH])) ) { - width = maskScanMaximum[WIDTH] / 2; - *left = startX - width; - *right = startX + width; - success = FALSE;; - } - if ( ((maskScanMinimum[HEIGHT] != -1) && (height < maskScanMinimum[HEIGHT])) || ((maskScanMaximum[HEIGHT] != -1) && (height > maskScanMaximum[HEIGHT])) ) { - height = maskScanMaximum[HEIGHT] / 2; - *top = startY - height; - *bottom = startY + height; - success = FALSE; - } - return success; -} - - -/** - * Detects masks around the points specified in point[]. - * - * @param mask point to array into which detected masks will be stored - * @return number of masks stored in mask[][] - */ -int detectMasks(int mask[MAX_MASKS][EDGES_COUNT], BOOLEAN maskValid[MAX_MASKS], int point[MAX_POINTS][COORDINATES_COUNT], int pointCount, int maskScanDirections, int maskScanSize[DIRECTIONS_COUNT], int maskScanDepth[DIRECTIONS_COUNT], int maskScanStep[DIRECTIONS_COUNT], float maskScanThreshold[DIRECTIONS_COUNT], int maskScanMinimum[DIMENSIONS_COUNT], int maskScanMaximum[DIMENSIONS_COUNT], struct IMAGE* image) { - int left; - int top; - int right; - int bottom; - int i; - int maskCount; - - maskCount = 0; - if (maskScanDirections != 0) { - for (i = 0; i < pointCount; i++) { - maskValid[i] = detectMask(point[i][X], point[i][Y], maskScanDirections, maskScanSize, maskScanDepth, maskScanStep, maskScanThreshold, maskScanMinimum, maskScanMaximum, &left, &top, &right, &bottom, image); - if (!(left==-1 || top==-1 || right==-1 || bottom==-1)) { - mask[maskCount][LEFT] = left; - mask[maskCount][TOP] = top; - mask[maskCount][RIGHT] = right; - mask[maskCount][BOTTOM] = bottom; - maskCount++; - if (verbose>=VERBOSE_NORMAL) { - printf("auto-masking (%d,%d): %d,%d,%d,%d", point[i][X], point[i][Y], left, top, right, bottom); - if (maskValid[i] == FALSE) { // (mask had been auto-set to full page size) - printf(" (invalid detection, using full page size)"); - } - printf("\n"); - } - } else { - if (verbose>=VERBOSE_NORMAL) { - printf("auto-masking (%d,%d): NO MASK FOUND\n", point[i][X], point[i][Y]); - } - } - //if (maskValid[i] == FALSE) { // (mask had been auto-set to full page size) - // if (verbose>=VERBOSE_NORMAL) { - // printf("auto-masking (%d,%d): NO MASK DETECTED\n", point[i][X], point[i][Y]); - // } - //} - } - } - return maskCount; -} - - -/** - * Permanently applies image masks. Each pixel which is not covered by at least - * one mask is set to maskColor. - */ -void applyMasks(int mask[MAX_MASKS][EDGES_COUNT], int maskCount, int maskColor, struct IMAGE* image) { - int x; - int y; - int i; - int left, top, right, bottom; - BOOLEAN m; - - if (maskCount<=0) { - return; - } - for (y=0; y < image->height; y++) { - for (x=0; x < image->width; x++) { - // in any mask? - m = FALSE; - for (i=0; ((m==FALSE) && (i=top && y<=bottom && x>=left && x<=right) { - m = TRUE; - } - } - if (m == FALSE) { - setPixel(maskColor, x, y, image); // delete: set to white - } - } - } -} - - -/* --- wiping ------------------------------------------------------------- */ - -/** - * Permanently wipes out areas of an images. Each pixel covered by a wipe-area - * is set to wipeColor. - */ -void applyWipes(int area[MAX_MASKS][EDGES_COUNT], int areaCount, int wipeColor, struct IMAGE* image) { - int x; - int y; - int i; - int count; - - for (i = 0; i < areaCount; i++) { - count = 0; - for (y = area[i][TOP]; y <= area[i][BOTTOM]; y++) { - for (x = area[i][LEFT]; x <= area[i][RIGHT]; x++) { - if ( setPixel(wipeColor, x, y, image) ) { - count++; - } - } - } - if (verbose >= VERBOSE_MORE) { - printf("wipe [%d,%d,%d,%d]: %d pixels\n", area[i][LEFT], area[i][TOP], area[i][RIGHT], area[i][BOTTOM], count); - } - } -} - - -/* --- mirroring ---------------------------------------------------------- */ - -/** - * Mirrors an image either horizontally, vertically, or both. - */ -void mirror(int directions, struct IMAGE* image) { - int x; - int y; - int xx; - int yy; - int pixel1; - int pixel2; - BOOLEAN horizontal; - BOOLEAN vertical; - int untilX; - int untilY; - - horizontal = ((directions & 1<width - 1) >> 1) : (image->width - 1); // w>>1 == (int)(w-0.5)/2 - untilY = (vertical==TRUE) ? ((image->height - 1) >> 1) : image->height - 1; - for (y = 0; y <= untilY; y++) { - yy = (vertical==TRUE) ? (image->height - y - 1) : y; - if ((vertical==TRUE) && (horizontal==TRUE) && (y == yy)) { // last middle line in odd-lined image mirrored both h and v - untilX = ((image->width - 1) >> 1); - } - for (x = 0; x <= untilX; x++) { - xx = (horizontal==TRUE) ? (image->width - x - 1) : x; - pixel1 = getPixel(x, y, image); - pixel2 = getPixel(xx, yy, image); - setPixel(pixel2, x, y, image); - setPixel(pixel1, xx, yy, image); - } - } -} - - -/* --- flip-rotating ------------------------------------------------------ */ - -/** - * Rotates an image clockwise or anti-clockwise in 90-degrees. - * - * @param direction either -1 (rotate anti-clockwise) or 1 (rotate clockwise) - */ -void flipRotate(int direction, struct IMAGE* image) { - struct IMAGE newimage; - int x; - int y; - int xx; - int yy; - int pixel; - - initImage(&newimage, image->height, image->width, image->bitdepth, image->color, WHITE); // exchanged width and height - for (y = 0; y < image->height; y++) { - xx = ((direction > 0) ? image->height - 1 : 0) - y * direction; - for (x = 0; x < image->width; x++) { - yy = ((direction < 0) ? image->width - 1 : 0) + x*direction; - pixel = getPixel(x, y, image); - setPixel(pixel, xx, yy, &newimage); - } - } - replaceImage(image, &newimage); -} - - -/* --- blackfilter -------------------------------------------------------- */ - -/** - * Filters out solidly black areas scanning to one direction. - * - * @param stepX is 0 if stepY!=0 - * @param stepY is 0 if stepX!=0 - * @see blackfilter() - */ -void blackfilterScan(int stepX, int stepY, int size, int dep, float threshold, int exclude[MAX_MASKS][EDGES_COUNT], int excludeCount, int intensity, float blackThreshold, struct IMAGE* image) { - int left; - int top; - int right; - int bottom; - int blackness; - int thresholdBlack; - int x; - int y; - int shiftX; - int shiftY; - int l, t, r, b; - int total; - int diffX; - int diffY; - int mask[EDGES_COUNT]; - BOOLEAN alreadyExcludedMessage; - - thresholdBlack = (int)(WHITE * (1.0-blackThreshold)); - total = size * dep; - if (stepX != 0) { // horizontal scanning - left = 0; - top = 0; - right = size -1; - bottom = dep - 1; - shiftX = 0; - shiftY = dep; - } else { // vertical scanning - left = 0; - top = 0; - right = dep -1; - bottom = size - 1; - shiftX = dep; - shiftY = 0; - } - while ((left < image->width) && (top < image->height)) { // individual scanning "stripes" over the whole sheet - l = left; - t = top; - r = right; - b = bottom; - // make sure last stripe does not reach outside sheet, shift back inside (next +=shift will exit while-loop) - if (r >= image->width || b >= image->height) { - diffX = r-image->width+1; - diffY = b-image->height+1; - l -= diffX; - t -= diffY; - r -= diffX; - b -= diffY; - } - alreadyExcludedMessage = FALSE; - while ((l < image->width) && (t < image->height)) { // single scanning "stripe" - blackness = 255 - darknessInverseRect(l, t, r, b, image); - if (blackness >= 255*threshold) { // found a solidly black area - mask[LEFT] = l; - mask[TOP] = t; - mask[RIGHT] = r; - mask[BOTTOM] = b; - if (! masksOverlapAny(mask, exclude, excludeCount) ) { - if (verbose >= VERBOSE_NORMAL) { - printf("black-area flood-fill: [%d,%d,%d,%d]\n", l, t, r, b); - alreadyExcludedMessage = FALSE; - } - // start flood-fill in this area (on each pixel to make sure we get everything, in most cases first flood-fill from first pixel will delete all other black pixels in the area already) - for (y = t; y <= b; y++) { - for (x = l; x <= r; x++) { - floodFill(x, y, pixelValue(WHITE, WHITE, WHITE), 0, thresholdBlack, intensity, image); - } - } - } else { - if ((verbose >= VERBOSE_NORMAL) && (!alreadyExcludedMessage)) { - printf("black-area EXCLUDED: [%d,%d,%d,%d]\n", l, t, r, b); - alreadyExcludedMessage = TRUE; // do this only once per scan-stripe, otherwise too many mesages - } - } - } - l += stepX; - t += stepY; - r += stepX; - b += stepY; - } - left += shiftX; - top += shiftY; - right += shiftX; - bottom += shiftY; - } -} - - -/** - * Filters out solidly black areas, as appearing on bad photocopies. - * A virtual bar of width 'size' and height 'depth' is horizontally moved - * above the middle of the sheet (or the full sheet, if depth ==-1). - */ -void blackfilter(int blackfilterScanDirections, int blackfilterScanSize[DIRECTIONS_COUNT], int blackfilterScanDepth[DIRECTIONS_COUNT], int blackfilterScanStep[DIRECTIONS_COUNT], float blackfilterScanThreshold, int blackfilterExclude[MAX_MASKS][EDGES_COUNT], int blackfilterExcludeCount, int blackfilterIntensity, float blackThreshold, struct IMAGE* image) { - if ((blackfilterScanDirections & 1<height; y++) { - for (x = 0; x < image->width; x++) { - pixel = getPixelDarknessInverse(x, y, image); - if (pixel < whiteMin) { // one dark pixel found - neighbors = countPixelNeighbors(x, y, intensity, whiteMin, image); // get number of non-light pixels in neighborhood - if (neighbors <= intensity) { // ...not more than 'intensity'? - clearPixelNeighbors(x, y, whiteMin, image); // delete area - count++; - } - } - } - } - return count; -} - - -/* --- blurfilter --------------------------------------------------------- */ - -/** - * Removes noise using a kind of blurfilter, as alternative to the noise - * filter. This algoithm counts pixels while 'shaking' the area to detect, - * and clears the area if the amount of white pixels exceeds whiteTreshold. - */ -int blurfilter(int blurfilterScanSize[DIRECTIONS_COUNT], int blurfilterScanStep[DIRECTIONS_COUNT], float blurfilterIntensity, float whiteThreshold, struct IMAGE* image) { - int whiteMin; - int left; - int top; - int right; - int bottom; - int count; - int max; - int total; - int result; - - result = 0; - whiteMin = (int)(WHITE * whiteThreshold); - left = 0; - top = 0; - right = blurfilterScanSize[HORIZONTAL] - 1; - bottom = blurfilterScanSize[VERTICAL] - 1; - total = blurfilterScanSize[HORIZONTAL] * blurfilterScanSize[VERTICAL]; - - while (TRUE) { // ! - max = 0; - count = countPixelsRect(left, top, right, bottom, 0, whiteMin, FALSE, image); - if (count > max) { - max = count; - } - count = countPixelsRect(left-blurfilterScanStep[HORIZONTAL], top-blurfilterScanStep[VERTICAL], right-blurfilterScanStep[HORIZONTAL], bottom-blurfilterScanStep[VERTICAL], 0, whiteMin, FALSE, image); - if (count > max) { - max = count; - } - count = countPixelsRect(left+blurfilterScanStep[HORIZONTAL], top-blurfilterScanStep[VERTICAL], right+blurfilterScanStep[HORIZONTAL], bottom-blurfilterScanStep[VERTICAL], 0, whiteMin, FALSE, image); - if (count > max) { - max = count; - } - count = countPixelsRect(left-blurfilterScanStep[HORIZONTAL], top+blurfilterScanStep[VERTICAL], right-blurfilterScanStep[HORIZONTAL], bottom+blurfilterScanStep[VERTICAL], 0, whiteMin, FALSE, image); - if (count > max) { - max = count; - } - count = countPixelsRect(left+blurfilterScanStep[HORIZONTAL], top+blurfilterScanStep[VERTICAL], right+blurfilterScanStep[HORIZONTAL], bottom+blurfilterScanStep[VERTICAL], 0, whiteMin, FALSE, image); - if (count > max) { - max = count; - } - if ((((float)max)/total) <= blurfilterIntensity) { - result += countPixelsRect(left, top, right, bottom, 0, whiteMin, TRUE, image); // also clear - } - if (right < image->width) { // not yet at end of row - left += blurfilterScanStep[HORIZONTAL]; - right += blurfilterScanStep[HORIZONTAL]; - } else { // end of row - if (bottom >= image->height) { // has been last row - return result; // exit here - } - // next row: - left = 0; - right = blurfilterScanSize[HORIZONTAL] - 1; - top += blurfilterScanStep[VERTICAL]; - bottom += blurfilterScanStep[VERTICAL]; - } - } -} - - -/* --- grayfilter --------------------------------------------------------- */ - -/** - * Clears areas which do not contain any black pixels, but some "gray shade" only. - * Two conditions have to apply before an area gets deleted: first, not a single black pixel may be contained, - * second, a minimum threshold of blackness must not be exceeded. - */ -int grayfilter(int grayfilterScanSize[DIRECTIONS_COUNT], int grayfilterScanStep[DIRECTIONS_COUNT], float grayfilterThreshold, float blackThreshold, struct IMAGE* image) { - int blackMax; - int left; - int top; - int right; - int bottom; - int count; - int lightness; - int thresholdAbs; - int total; - int result; - - result = 0; - blackMax = (int)(WHITE * (1.0-blackThreshold)); - thresholdAbs = (int)(WHITE * grayfilterThreshold); - left = 0; - top = 0; - right = grayfilterScanSize[HORIZONTAL] - 1; - bottom = grayfilterScanSize[VERTICAL] - 1; - total = grayfilterScanSize[HORIZONTAL] * grayfilterScanSize[VERTICAL]; - - while (TRUE) { // ! - count = countPixelsRect(left, top, right, bottom, 0, blackMax, FALSE, image); - if (count == 0) { - lightness = lightnessRect(left, top, right, bottom, image); - if ((WHITE - lightness) < thresholdAbs) { // (lower threshold->more deletion) - result += clearRect(left, top, right, bottom, image, WHITE); - } - } - if (left < image->width) { // not yet at end of row - left += grayfilterScanStep[HORIZONTAL]; - right += grayfilterScanStep[HORIZONTAL]; - } else { // end of row - if (bottom >= image->height) { // has been last row - return result; // exit here - } - // next row: - left = 0; - right = grayfilterScanSize[HORIZONTAL] - 1; - top += grayfilterScanStep[VERTICAL]; - bottom += grayfilterScanStep[VERTICAL]; - } - } -} - - -/* --- border-detection --------------------------------------------------- */ - -/** - * Moves a rectangular area of pixels to be centered above the centerX, centerY coordinates. - */ -void centerMask(int centerX, int centerY, int left, int top, int right, int bottom, struct IMAGE* image) { - struct IMAGE newimage; - int width; - int height; - int targetX; - int targetY; - - width = right - left + 1; - height = bottom - top + 1; - targetX = centerX - width/2; - targetY = centerY - height/2; - if ((targetX >= 0) && (targetY >= 0) && ((targetX+width) <= image->width) && ((targetY+height) <= image->height)) { - if (verbose >= VERBOSE_NORMAL) { - printf("centering mask [%d,%d,%d,%d] (%d,%d): %d, %d\n", left, top, right, bottom, centerX, centerY, targetX-left, targetY-top); - } - initImage(&newimage, width, height, image->bitdepth, image->color, image->background); - copyImageArea(left, top, width, height, image, 0, 0, &newimage); - clearRect(left, top, right, bottom, image, image->background); - copyImageArea(0, 0, width, height, &newimage, targetX, targetY, image); - freeImage(&newimage); - } else { - if (verbose >= VERBOSE_NORMAL) { - printf("centering mask [%d,%d,%d,%d] (%d,%d): %d, %d - NO CENTERING (would shift area outside visible image)\n", left, top, right, bottom, centerX, centerY, targetX-left, targetY-top); - } - } -} - - -/** - * Moves a rectangular area of pixels to be centered inside a specified area coordinates. - */ -void alignMask(int mask[EDGES_COUNT], int outside[EDGES_COUNT], int direction, int margin[DIRECTIONS_COUNT], struct IMAGE* image) { - struct IMAGE newimage; - int width; - int height; - int targetX; - int targetY; - - width = mask[RIGHT] - mask[LEFT] + 1; - height = mask[BOTTOM] - mask[TOP] + 1; - if (direction & 1<= VERBOSE_NORMAL) { - printf("aligning mask [%d,%d,%d,%d] (%d,%d): %d, %d\n", mask[LEFT], mask[TOP], mask[RIGHT], mask[BOTTOM], targetX, targetY, targetX - mask[LEFT], targetY - mask[TOP]); - } - initImage(&newimage, width, height, image->bitdepth, image->color, image->background); - copyImageArea(mask[LEFT], mask[TOP], mask[RIGHT], mask[BOTTOM], image, 0, 0, &newimage); - clearRect(mask[LEFT], mask[TOP], mask[RIGHT], mask[BOTTOM], image, image->background); - copyImageArea(0, 0, width, height, &newimage, targetX, targetY, image); - freeImage(&newimage); -} - - -/** - * Moves a rectangular area of pixels to be centered inside a specified area coordinates. - */ -void centerMaskInsideMask(int mask[EDGES_COUNT], int outside[EDGES_COUNT], struct IMAGE* image) { - alignMask(mask, outside, 0, NULL, image); -} - - -/** - * Find the size of one border edge. - * - * @param x1..y2 area inside of which border is to be detected - */ -int detectBorderEdge(int outsideMask[EDGES_COUNT], int stepX, int stepY, int size, int threshold, int maxBlack, struct IMAGE* image) { - int left; - int top; - int right; - int bottom; - int max; - int cnt; - int result; - - if (stepY == 0) { // horizontal detection - if (stepX > 0) { - left = outsideMask[LEFT]; - top = outsideMask[TOP]; - right = outsideMask[LEFT] + size; - bottom = outsideMask[BOTTOM]; - } else { - left = outsideMask[RIGHT] - size; - top = outsideMask[TOP]; - right = outsideMask[RIGHT]; - bottom = outsideMask[BOTTOM]; - } - max = (outsideMask[RIGHT] - outsideMask[LEFT]); - } else { // vertical detection - if (stepY > 0) { - left = outsideMask[LEFT]; - top = outsideMask[TOP]; - right = outsideMask[RIGHT]; - bottom = outsideMask[TOP] + size; - } else { - left = outsideMask[LEFT]; - top = outsideMask[BOTTOM] - size; - right = outsideMask[RIGHT]; - bottom = outsideMask[BOTTOM]; - } - max = (outsideMask[BOTTOM] - outsideMask[TOP]); - } - result = 0; - while (result < max) { - cnt = countPixelsRect(left, top, right, bottom, 0, maxBlack, FALSE, image); - if (cnt >= threshold) { - return result; // border has been found: regular exit here - } - left += stepX; - top += stepY; - right += stepX; - bottom += stepY; - result += abs(stepX+stepY); // (either stepX or stepY is 0) - } - return 0; // no border found between 0..max -} - - -/** - * Detects a border of completely non-black pixels around the area outsideBorder[LEFT],outsideBorder[TOP]-outsideBorder[RIGHT],outsideBorder[BOTTOM]. - */ -void detectBorder(int border[EDGES_COUNT], int borderScanDirections, int borderScanSize[DIRECTIONS_COUNT], int borderScanStep[DIRECTIONS_COUNT], int borderScanThreshold[DIRECTIONS_COUNT], float blackThreshold, int outsideMask[EDGES_COUNT], struct IMAGE* image) { - int blackThresholdAbs; - - border[LEFT] = outsideMask[LEFT]; - border[TOP] = outsideMask[TOP]; - border[RIGHT] = image->width - outsideMask[RIGHT]; - border[BOTTOM] = image->height - outsideMask[BOTTOM]; - - blackThresholdAbs = (int)(WHITE * (1.0 - blackThreshold)); - if (borderScanDirections & 1<= VERBOSE_NORMAL) { - printf("border detected: (%d,%d,%d,%d) in [%d,%d,%d,%d]\n", border[LEFT], border[TOP], border[RIGHT], border[BOTTOM], outsideMask[LEFT], outsideMask[TOP], outsideMask[RIGHT], outsideMask[BOTTOM]); - } -} - - -/** - * Converts a border-tuple to a mask-tuple. - */ -void borderToMask(int border[EDGES_COUNT], int mask[EDGES_COUNT], struct IMAGE* image) { - mask[LEFT] = border[LEFT]; - mask[TOP] = border[TOP]; - mask[RIGHT] = image->width - border[RIGHT] - 1; - mask[BOTTOM] = image->height - border[BOTTOM] - 1; - if (verbose >= VERBOSE_DEBUG) { - printf("border [%d,%d,%d,%d] -> mask [%d,%d,%d,%d]\n", border[LEFT], border[TOP], border[RIGHT], border[BOTTOM], mask[LEFT], mask[TOP], mask[RIGHT], mask[BOTTOM]); - } -} - - -/** - * Applies a border to the whole image. All pixels in the border range at the - * edges of the sheet will be cleared. - */ -void applyBorder(int border[EDGES_COUNT], int borderColor, struct IMAGE* image) { - int mask[EDGES_COUNT]; - - if (border[LEFT]!=0 || border[TOP]!=0 || border[RIGHT]!=0 || border[BOTTOM]!=0) { - borderToMask(border, mask, image); - if (verbose >= VERBOSE_NORMAL) { - printf("applying border (%d,%d,%d,%d) [%d,%d,%d,%d]\n", border[LEFT], border[TOP], border[RIGHT], border[BOTTOM], mask[LEFT], mask[TOP], mask[RIGHT], mask[BOTTOM]); - } - applyMasks(&mask, 1, borderColor, image); - } -} - - -/**************************************************************************** - * MAIN() * - ****************************************************************************/ - -/** - * The main program. - */ -int main(int argc, char* argv[]) { - - // --- parameter variables --- - int layout; - int startSheet; - int endSheet; - int startInput; - int startOutput; - int inputCount; - int outputCount; - char* inputFileSequence[MAX_FILES]; - int inputFileSequenceCount; - char* outputFileSequence[MAX_FILES]; - int outputFileSequenceCount; - int sheetSize[DIMENSIONS_COUNT]; - int sheetBackground; - int preRotate; - int postRotate; - int preMirror; - int postMirror; - int preShift[DIRECTIONS_COUNT]; - int postShift[DIRECTIONS_COUNT]; - int size[DIRECTIONS_COUNT]; - int postSize[DIRECTIONS_COUNT]; - int stretchSize[DIRECTIONS_COUNT]; - int postStretchSize[DIRECTIONS_COUNT]; - float zoomFactor; - float postZoomFactor; - int pointCount; - int point[MAX_POINTS][COORDINATES_COUNT]; - int maskCount; - int mask[MAX_MASKS][EDGES_COUNT]; - int wipeCount; - int wipe[MAX_MASKS][EDGES_COUNT]; - int middleWipe[2]; - int preWipeCount; - int preWipe[MAX_MASKS][EDGES_COUNT]; - int postWipeCount; - int postWipe[MAX_MASKS][EDGES_COUNT]; - int preBorder[EDGES_COUNT]; - int postBorder[EDGES_COUNT]; - int border[EDGES_COUNT]; - BOOLEAN maskValid[MAX_MASKS]; - int preMaskCount; - int preMask[MAX_MASKS][EDGES_COUNT]; - int blackfilterScanDirections; - int blackfilterScanSize[DIRECTIONS_COUNT]; - int blackfilterScanDepth[DIRECTIONS_COUNT]; - int blackfilterScanStep[DIRECTIONS_COUNT]; - float blackfilterScanThreshold; - int blackfilterExcludeCount; - int blackfilterExclude[MAX_MASKS][EDGES_COUNT]; - int blackfilterIntensity; - int noisefilterIntensity; - int blurfilterScanSize[DIRECTIONS_COUNT]; - int blurfilterScanStep[DIRECTIONS_COUNT]; - float blurfilterIntensity; - int grayfilterScanSize[DIRECTIONS_COUNT]; - int grayfilterScanStep[DIRECTIONS_COUNT]; - float grayfilterThreshold; - int maskScanDirections; - int maskScanSize[DIRECTIONS_COUNT]; - int maskScanDepth[DIRECTIONS_COUNT]; - int maskScanStep[DIRECTIONS_COUNT]; - float maskScanThreshold[DIRECTIONS_COUNT]; - int maskScanMinimum[DIMENSIONS_COUNT]; - int maskScanMaximum[DIMENSIONS_COUNT]; - int maskColor; - int deskewScanEdges; - int deskewScanSize; - float deskewScanDepth; - float deskewScanRange; - float deskewScanStep; - float deskewScanDeviation; - int borderScanDirections; - int borderScanSize[DIRECTIONS_COUNT]; - int borderScanStep[DIRECTIONS_COUNT]; - int borderScanThreshold[DIRECTIONS_COUNT]; - int borderAlign; - int borderAlignMargin[DIRECTIONS_COUNT]; - int outsideBorderscanMask[MAX_PAGES][EDGES_COUNT]; // set by --layout - int outsideBorderscanMaskCount; - float whiteThreshold; - float blackThreshold; - BOOLEAN writeoutput; - BOOLEAN qpixels; - BOOLEAN multisheets; - char* outputTypeName; - int noBlackfilterMultiIndex[MAX_MULTI_INDEX]; - int noBlackfilterMultiIndexCount; - int noNoisefilterMultiIndex[MAX_MULTI_INDEX]; - int noNoisefilterMultiIndexCount; - int noBlurfilterMultiIndex[MAX_MULTI_INDEX]; - int noBlurfilterMultiIndexCount; - int noGrayfilterMultiIndex[MAX_MULTI_INDEX]; - int noGrayfilterMultiIndexCount; - int noMaskScanMultiIndex[MAX_MULTI_INDEX]; - int noMaskScanMultiIndexCount; - int noMaskCenterMultiIndex[MAX_MULTI_INDEX]; - int noMaskCenterMultiIndexCount; - int noDeskewMultiIndex[MAX_MULTI_INDEX]; - int noDeskewMultiIndexCount; - int noWipeMultiIndex[MAX_MULTI_INDEX]; - int noWipeMultiIndexCount; - int noBorderMultiIndex[MAX_MULTI_INDEX]; - int noBorderMultiIndexCount; - int noBorderScanMultiIndex[MAX_MULTI_INDEX]; - int noBorderScanMultiIndexCount; - int noBorderAlignMultiIndex[MAX_MULTI_INDEX]; - int noBorderAlignMultiIndexCount; - int sheetMultiIndex[MAX_MULTI_INDEX]; - int sheetMultiIndexCount; - int excludeMultiIndex[MAX_MULTI_INDEX]; - int excludeMultiIndexCount; - int ignoreMultiIndex[MAX_MULTI_INDEX]; - int ignoreMultiIndexCount; - int autoborder[MAX_MASKS][EDGES_COUNT]; - int autoborderMask[MAX_MASKS][EDGES_COUNT]; - int insertBlank[MAX_MULTI_INDEX]; - int insertBlankCount; - int replaceBlank[MAX_MULTI_INDEX]; - int replaceBlankCount; - BOOLEAN overwrite; - BOOLEAN showTime; - int dpi; - - // --- local variables --- - int x; - int y; - int w; - int h; - int left; - int top; - int right; - int bottom; - int i; - int j; - int previousWidth; - int previousHeight; - int previousBitdepth; - BOOLEAN previousColor; - int inputFileSequencePos; // index 'looping' through input-file-seq (without additionally inserted blank images) - int outputFileSequencePos; // index 'looping' through output-file-seq - int inputFileSequencePosTotal; // index 'looping' through input-file-seq (with additional blank images) - char inputFilenamesResolvedBuffer[MAX_PAGES][255]; // count: inputCount - char outputFilenamesResolvedBuffer[MAX_PAGES][255]; // count: outputCount; - char* inputFilenamesResolved[MAX_PAGES]; - char* outputFilenamesResolved[MAX_PAGES]; - char s1[1023]; // buffers for result of implode() - char s2[1023]; - char debugFilename[100]; - struct IMAGE sheet; - struct IMAGE sheetBackup; - struct IMAGE originalSheet; - struct IMAGE qpixelSheet; - struct IMAGE page; - char* layoutStr; - char* inputTypeName; - char* inputTypeNames[MAX_PAGES]; - int inputType; - int filterResult; - double rotation; - int q; - struct IMAGE rect; - struct IMAGE rectTarget; - int outputType; - int outputDepth; - int bd; - BOOLEAN col; - BOOLEAN success; - BOOLEAN done; - BOOLEAN anyWildcards; - BOOLEAN allInputFilesMissing; - int nr; - int inputNr; - int outputNr; - BOOLEAN first; - clock_t startTime; - clock_t endTime; - clock_t time; - unsigned long int totalTime; - int totalCount; - BOOLEAN ins; - BOOLEAN repl; - int blankCount; - int exitCode; - - sheet.buffer = NULL; - page.buffer = NULL; - exitCode = 0; // error code to return - bd = 1; // default bitdepth if not resolvable (i.e. usually empty input, so bd=1 is good choice) - col = FALSE; // default no color if not resolvable - - // explicitly un-initialize variables that are sometimes not used to avoid compiler warnings - qpixelSheet.buffer = NULL; // used optionally, deactivated by --no-qpixels - startTime = 0; // used optionally in debug mode -vv or with --time - endTime = 0; // used optionally in debug mode -vv or with --time - inputNr = -1; // will be initialized in first run of main-loop - outputNr = -1; // will be initialized in first run of main-loop - - - // ----------------------------------------------------------------------- - // --- process all sheets --- - // ----------------------------------------------------------------------- - - // count from start sheet to end sheet - startSheet = 1; // defaults, may be changed in first run of for-loop - endSheet = -1; - startInput = -1; - startOutput = -1; - totalTime = 0; - totalCount = 0; - inputFileSequencePos = 0; - outputFileSequencePos = 0; - inputFileSequencePosTotal = 0; - previousWidth = previousHeight = previousBitdepth = -1; - previousColor = FALSE; - first = TRUE; - - for (nr = startSheet; (endSheet == -1) || (nr <= endSheet); nr++) { - - // --- default values --- - w = h = -1; - layout = LAYOUT_SINGLE; - layoutStr = "single"; - preRotate = 0; - postRotate = 0; - preMirror = 0; - postMirror = 0; - preShift[WIDTH] = preShift[HEIGHT] = 0; - postShift[WIDTH] = postShift[HEIGHT] = 0; - size[WIDTH] = size[HEIGHT] = -1; - postSize[WIDTH] = postSize[HEIGHT] = -1; - stretchSize[WIDTH] = stretchSize[HEIGHT] = -1; - postStretchSize[WIDTH] = postStretchSize[HEIGHT] = -1; - zoomFactor = 1.0; - postZoomFactor = 1.0; - outputTypeName = NULL; // default derived from input - outputDepth = -1; // default derived from input - pointCount = 0; - maskCount = 0; - preMaskCount = 0; - wipeCount = 0; - preWipeCount = 0; - postWipeCount = 0; - middleWipe[0] = middleWipe[1] = 0; // left/right - border[LEFT] = border[TOP] = border[RIGHT] = border[BOTTOM] = 0; - preBorder[LEFT] = preBorder[TOP] = preBorder[RIGHT] = preBorder[BOTTOM] = 0; - postBorder[LEFT] = postBorder[TOP] = postBorder[RIGHT] = postBorder[BOTTOM] = 0; - blackfilterScanDirections = (1< 0) { - if (startSheet > sheetMultiIndex[0]) { // allow 0 as start sheet, might be overwritten by --start-sheet again - startSheet = sheetMultiIndex[0]; - } - } - - // --start-sheet - } else if ((strcmp(argv[i], "-start")==0)||(strcmp(argv[i], "--start-sheet")==0)) { - sscanf(argv[++i],"%d", &startSheet); - if (nr < startSheet) { - nr = startSheet; - } - - // --end-sheet - } else if ((strcmp(argv[i], "-end")==0)||(strcmp(argv[i], "--end-sheet")==0)) { - sscanf(argv[++i],"%d", &endSheet); - - // --start-input - } else if ((strcmp(argv[i], "-si")==0)||(strcmp(argv[i], "--start-input")==0)) { - sscanf(argv[++i],"%d", &startInput); - - // --start-output - } else if ((strcmp(argv[i], "-so")==0)||(strcmp(argv[i], "--start-output")==0)) { - sscanf(argv[++i],"%d", &startOutput); - - // --sheet-size - } else if ((strcmp(argv[i], "-S")==0)||(strcmp(argv[i], "--sheet-size")==0)) { - parseSize(argv[++i], sheetSize, dpi, &exitCode); - - // --sheet-background - } else if (strcmp(argv[i], "--sheet-background")==0) { - sheetBackground = parseColor(argv[++i], &exitCode); - - // --exclude -x - } else if (strcmp(argv[i], "-x")==0 || strcmp(argv[i], "--exclude")==0) { - parseMultiIndex(&i, argv, excludeMultiIndex, &excludeMultiIndexCount); - if (excludeMultiIndexCount == -1) { - excludeMultiIndexCount = 0; // 'exclude all' makes no sence - } - - // --no-processing -n - } else if (strcmp(argv[i], "-n")==0 || strcmp(argv[i], "--no-processing")==0) { - parseMultiIndex(&i, argv, ignoreMultiIndex, &ignoreMultiIndexCount); - - - - // --pre-rotate - } else if (strcmp(argv[i], "--pre-rotate")==0) { - sscanf(argv[++i],"%d", &preRotate); - if ((preRotate != 0) && (abs(preRotate) != 90)) { - printf("Cannot set --pre-rotate value other than -90 or 90, ignoring.\n"); - preRotate = 0; - } - - // --post-rotate - } else if (strcmp(argv[i], "--post-rotate")==0) { - sscanf(argv[++i],"%d", &postRotate); - if ((postRotate != 0) && (abs(postRotate) != 90)) { - printf("Cannot set --post-rotate value other than -90 or 90, ignoring.\n"); - postRotate = 0; - } - - // --pre-mirror -M - } else if (strcmp(argv[i], "-M")==0 || strcmp(argv[i], "--pre-mirror")==0) { - preMirror = parseDirections(argv[++i], &exitCode); // s = "v", "v,h", "vertical,horizontal", ... - - // --post-mirror - } else if (strcmp(argv[i], "--post-mirror")==0) { - postMirror = parseDirections(argv[++i], &exitCode); - - - // --pre-shift - } else if (strcmp(argv[i], "--pre-shift")==0) { - parseSize(argv[++i], preShift, dpi, &exitCode); - - // --post-shift - } else if (strcmp(argv[i], "--post-shift")==0) { - parseSize(argv[++i], postShift, dpi, &exitCode); - - - // --pre-mask - } else if ( strcmp(argv[i], "--pre-mask")==0 && (preMaskCount= 1 && inputCount <= 2 ) ) { - printf("Cannot set --input-pages value other than 1 or 2, ignoring.\n"); - inputCount = 1; - } - - // --output-pages - } else if (strcmp(argv[i], "-op")==0 || strcmp(argv[i], "--output-pages")==0) { - sscanf(argv[++i],"%d", &outputCount); - if ( ! (outputCount >= 1 && outputCount <= 2 ) ) { - printf("Cannot set --output-pages value other than 1 or 2, ignoring.\n"); - outputCount = 1; - } - - - // --input-file-sequence - } else if (strcmp(argv[i], "-if")==0 || strcmp(argv[i], "--input-file-sequence")==0) { - inputFileSequenceCount = 0; - i++; - done = FALSE; - while ( (i < argc) && (!done) ) { - inputFileSequence[inputFileSequenceCount] = argv[i]; - if (inputFileSequence[inputFileSequenceCount][0] == '-') { // is next option - done = TRUE; - i--; - } else { // continue collecting filenames - i++; - inputFileSequenceCount++; - } - } - - // --output-file-sequence - } else if (strcmp(argv[i], "-of")==0 || strcmp(argv[i], "--output-file-sequence")==0) { - outputFileSequenceCount = 0; - i++; - done = FALSE; - while ( (i < argc) && (!done) ) { - outputFileSequence[outputFileSequenceCount] = argv[i]; - if (outputFileSequence[outputFileSequenceCount][0] == '-') { // is next option - done = TRUE; - i--; - } else { // continue collecting filenames - i++; - outputFileSequenceCount++; - } - } - - // --insert-blank - } else if (strcmp(argv[i], "--insert-blank")==0) { - parseMultiIndex(&i, argv, insertBlank, &insertBlankCount); - - // --replace-blank - } else if (strcmp(argv[i], "--replace-blank")==0) { - parseMultiIndex(&i, argv, replaceBlank, &replaceBlankCount); - - - // --test-only -T - } else if (strcmp(argv[i], "-T")==0 || strcmp(argv[i], "--test-only")==0) { - writeoutput = FALSE; - - // --no-qpixels - } else if (strcmp(argv[i], "--no-qpixels")==0) { - qpixels = FALSE; - - // --no-multi-pages - } else if (strcmp(argv[i], "--no-multi-pages")==0) { - multisheets = FALSE; - - // --dpi - } else if (strcmp(argv[i], "--dpi")==0) { - sscanf(argv[++i],"%d", &dpi); - - // --type -t - } else if (strcmp(argv[i], "-t")==0 || strcmp(argv[i], "--type")==0) { - outputTypeName = argv[++i]; - - // --depth -d - } else if (strcmp(argv[i], "-d")==0 || strcmp(argv[i], "--depth")==0) { - sscanf(argv[++i], "%d", &outputDepth); - - // --quiet -q - } else if (strcmp(argv[i], "-q")==0 || strcmp(argv[i], "--quiet")==0) { - verbose = VERBOSE_QUIET; - - // --overwrite - } else if (strcmp(argv[i], "--overwrite")==0) { - overwrite = TRUE; - - // --time - } else if (strcmp(argv[i], "--time")==0) { - showTime = TRUE; - - // --verbose -v - } else if (strcmp(argv[i], "-v")==0 || strcmp(argv[i], "--verbose")==0) { - verbose = VERBOSE_NORMAL; - - // -vv - } else if (strcmp(argv[i], "-vv")==0) { - verbose = VERBOSE_MORE; - - // --debug -vvv (undocumented) - } else if (strcmp(argv[i], "-vvv")==0 || strcmp(argv[i], "--debug")==0) { - verbose = VERBOSE_DEBUG; - - // --debug-save -vvvv (undocumented) - } else if (strcmp(argv[i], "-vvvv")==0 || strcmp(argv[i], "--debug-save")==0) { - verbose = VERBOSE_DEBUG_SAVE; - - // unkown parameter - } else { - printf("*** error: Unknown parameter '%s'.\n", argv[i]); - exitCode = 1; - } - - if (exitCode != 0) { - printf("Try 'unpaper --help' for options.\n"); - return exitCode; - } - i++; - } - - - // ------------------------------------------------------------------- - // --- begin processing --- - // ------------------------------------------------------------------- - - if (first) { - if (startSheet < nr) { // startSheet==0 - nr = startSheet; - } - first = FALSE; - } - - if ( nr == startSheet ) { - if ( verbose >= VERBOSE_NORMAL ) { - printf(WELCOME, VERSION); // welcome message - } - - if (startInput == -1) { - startInput = (startSheet - 1) * inputCount + 1; - } - if (startOutput == -1) { - startOutput = (startSheet - 1) * outputCount + 1; - } - - inputNr = startInput; - outputNr = startOutput; - } - - showTime |= (verbose >= VERBOSE_DEBUG); // always show processing time in verbose-debug mode - - // get filenames - if (inputFileSequenceCount == 0) { // not yet set via option --input-file-sequence - if (i < argc) { - inputFileSequence[0] = argv[i++]; - inputFileSequenceCount = 1; - } else { - printf("*** error: Missing input filename.\n"); - printf(HELP); - return 1; - } - } - if (outputFileSequenceCount == 0) { // not yet set via option --output-file-sequence - if (i < argc) { - outputFileSequence[0] = argv[i++]; - outputFileSequenceCount = 1; - } else { - printf("*** error: Missing output filename.\n"); - printf(HELP); - return 1; - } - } - - // resolve filenames for current sheet - anyWildcards = FALSE; - allInputFilesMissing = TRUE; - blankCount = 0; - for (j = 0; j < inputCount; j++) { - if ( (!anyWildcards) && (strchr(inputFileSequence[inputFileSequencePos], '%') != 0) ) { - anyWildcards = TRUE; - } - ins = isInMultiIndex(inputFileSequencePosTotal+1, insertBlank, insertBlankCount); - repl = isInMultiIndex(inputFileSequencePosTotal+1, replaceBlank, replaceBlankCount); - if (!(ins || repl)) { - sprintf(inputFilenamesResolvedBuffer[j], inputFileSequence[inputFileSequencePos++], inputNr); - inputFilenamesResolved[j] = inputFilenamesResolvedBuffer[j]; - if ( allInputFilesMissing && ( fileExists(inputFilenamesResolved[j]) ) ) { - allInputFilesMissing = FALSE; - } - } else { // use blank input - inputFilenamesResolved[j] = NULL; - blankCount++; - //allInputFilesMissing = FALSE; - if (repl) { // but skip input file sequence pos if replace-mode - inputFileSequencePos++; - } - } - if ( inputFileSequencePos >= inputFileSequenceCount ) { // next 'loop' in input-file-seq - inputFileSequencePos = 0; - inputNr++; - } - inputFileSequencePosTotal++; - } - if (blankCount == inputCount) { - allInputFilesMissing = FALSE; - } - - // multi-(input-)sheets? - if ( multisheets && anyWildcards ) { // might already have been disabled by option (multisheets==FALSE) - //nop, multisheets remains TRUE - } else { - multisheets = FALSE; - endSheet = startSheet; - } - - for (j = 0; j < outputCount; j++) { - if ( (!anyWildcards) && (strchr(outputFileSequence[outputFileSequencePos], '%') != 0) ) { - anyWildcards = TRUE; - } - sprintf(outputFilenamesResolvedBuffer[j], outputFileSequence[outputFileSequencePos++], outputNr); - outputFilenamesResolved[j] = outputFilenamesResolvedBuffer[j]; - if ( outputFileSequencePos >= outputFileSequenceCount ) { // next 'loop' in output-file-seq - outputFileSequencePos = 0; - outputNr++; - } - } - - // test if (at least one) input file exists - if ( multisheets && ( allInputFilesMissing ) ) { - if (nr == startSheet) { // only an error if first file not found, otherwise regular end of multisheet processing - printf("*** error: Input file(s) %s not found.\n", implode(s1, inputFilenamesResolved, inputCount)); - } - endSheet = nr - 1; // exit for-loop - - } else { // at least one input page file exists - - - // --------------------------------------------------------------- - // --- process single sheet --- - // --------------------------------------------------------------- - - if (isInMultiIndex(nr, sheetMultiIndex, sheetMultiIndexCount) && (!isInMultiIndex(nr, excludeMultiIndex, excludeMultiIndexCount))) { - - if (verbose >= VERBOSE_NORMAL) { - printf("\n-------------------------------------------------------------------------------\n"); - } - if (verbose > VERBOSE_QUIET) { - if (multisheets) { - printf("Processing sheet #%d: %s -> %s\n", nr, implode(s1, inputFilenamesResolved, inputCount), implode(s2, outputFilenamesResolved, outputCount)); - } else { - printf("Processing sheet: %s -> %s\n", implode(s1, inputFilenamesResolved, inputCount), implode(s2, outputFilenamesResolved, outputCount)); - } - } - - // load input image(s) - success = TRUE; - for ( j = 0; (success) && (j < inputCount); j++) { - - if ( (inputFilenamesResolved[j] == NULL) || fileExists(inputFilenamesResolved[j]) ) { - - if (inputFilenamesResolved[j] != NULL) { // may be null if --insert-blank or --replace-blank - - success = loadImage(inputFilenamesResolved[j], &page, &inputType); - inputTypeName = (char*)FILETYPE_NAMES[inputType]; - inputTypeNames[j] = inputTypeName; - sprintf(debugFilename, "_loaded_%d.pnm", inputNr-inputCount+j); - saveDebug(debugFilename, &page); - - if (!success) { - printf("*** error: Cannot load image %s.\n", inputFilenamesResolved[j]); - exitCode = 2; - } else { - // pre-rotate - if (preRotate != 0) { - if (verbose>=VERBOSE_NORMAL) { - printf("pre-rotating %d degrees.\n", preRotate); - } - if (preRotate == 90) { - flipRotate(1, &page); - } else if (preRotate == -90) { - flipRotate(-1, &page); - } - } - - // if sheet-size is not known yet (and not forced by --sheet-size), set now based on size of (first) input image - if ( w == -1 ) { - if ( sheetSize[WIDTH] != -1 ) { - w = sheetSize[WIDTH]; - } else { - w = page.width * inputCount; - } - } - if ( h == -1 ) { - if ( sheetSize[HEIGHT] != -1 ) { - h = sheetSize[HEIGHT]; - } else { - h = page.height; - } - } - } - } else { // inputFilenamesResolved[j] == NULL - page.buffer = NULL; - inputTypeNames[j] = ""; - } - - // place image into sheet buffer - if ( (inputCount == 1) && (page.buffer != NULL) && (page.width == w) && (page.height == h) ) { // quick case: single input file == whole sheet - sheet.buffer = page.buffer; - sheet.bufferGrayscale = page.bufferGrayscale; - sheet.bufferLightness = page.bufferLightness; - sheet.bufferDarknessInverse = page.bufferDarknessInverse; - sheet.width = page.width; - sheet.height = page.height; - sheet.bitdepth = page.bitdepth; - sheet.color = page.color; - sheet.background = sheetBackground; - } else { // generic case: place image onto sheet by copying - // allocate sheet-buffer if not done yet - if ((sheet.buffer == NULL) && (w != -1) && (h != -1)) { - if ((page.buffer != NULL) && (page.bitdepth != 0)) { - bd = page.bitdepth; - col = page.color; - } else { - if (outputDepth != -1) { // set via --depth - bd = outputDepth; - } else { - // bd remains default - } - } - initImage(&sheet, w, h, bd, col, sheetBackground); - - } else if ((page.buffer != NULL) && ((page.bitdepth > sheet.bitdepth) || ( (!sheet.color) && page.color ))) { // make sure current sheet buffer has enough bitdepth and color-mode - sheetBackup = sheet; - // re-allocate sheet - bd = page.bitdepth; - col = page.color; - initImage(&sheet, w, h, bd, col, sheetBackground); - // copy old one - copyImage(&sheetBackup, 0, 0, &sheet); - freeImage(&sheetBackup); - } - if (page.buffer != NULL) { - if (verbose >= VERBOSE_DEBUG_SAVE) { - sprintf(debugFilename, "_page%d.pnm", inputNr-inputCount+j); - saveDebug(debugFilename, &page); - sprintf(debugFilename, "_before_center_page%d.pnm", inputNr-inputCount+j); - saveDebug(debugFilename, &sheet); - } - - centerImage(&page, (w * j / inputCount), 0, (w / inputCount), h, &sheet); - - if (verbose >= VERBOSE_DEBUG_SAVE) { - sprintf(debugFilename, "_after_center_page%d.pnm", inputNr-inputCount+j); - saveDebug(debugFilename, &sheet); - } - freeImage(&page); - } - } - - } else { - // allow missing page file (existance of at least one has been made sure before) - } - - } - - // the only case that buffer is not yet initialized is if all blank pages have been inserted - if (sheet.buffer == NULL) { - // last chance: try to get previous (unstretched/not zoomed) sheet size - w = previousWidth; - h = previousHeight; - bd = previousBitdepth; - col = previousColor; - if (verbose >= VERBOSE_NORMAL) { - printf("need to guess sheet size from previous sheet: %dx%d\n", w, h); - } - if ((w == -1) || (h == -1)) { - printf("*** error: sheet size unknown, use at least one input file per sheet, or force using --sheet-size.\n"); - return 2; - } else { - initImage(&sheet, w, h, bd, col, sheetBackground); - } - } - - if (success) { // sheet loaded successfully, size is known - - previousWidth = w; - previousHeight = h; - previousBitdepth = bd; - previousColor = col; - // handle file types - if (outputTypeName == NULL) { // auto-set output type according to sheet format, if not explicitly set by user - if (sheet.color) { - outputType = PPM; - } else { - if (sheet.bitdepth == 1) { - outputType = PBM; - } else { - outputType = PGM; - } - } - outputTypeName = (char*)FILETYPE_NAMES[outputType]; - } else { // parse user-setting - outputType = -1; - for (i = 0; (outputType == -1) && (i < FILETYPES_COUNT); i++) { - if (strcmp(outputTypeName, FILETYPE_NAMES[i])==0) { - outputType = i; - } - } - if (outputType == -1) { - printf("*** error: output file format '%s' is not known.\n", outputTypeName); - return 2; - } - } - if (outputDepth == -1) { // set output depth to be as input depth, if not explicitly set by user - outputDepth = sheet.bitdepth; - } - - if (showTime) { - startTime = clock(); - } - - // pre-mirroring - if (preMirror != 0) { - if (verbose >= VERBOSE_NORMAL) { - printf("pre-mirroring "); - printDirections(preMirror); - } - mirror(preMirror, &sheet); - } - - // pre-shifting - if ((preShift[WIDTH] != 0) || ((preShift[HEIGHT] != 0))) { - if (verbose >= VERBOSE_NORMAL) { - printf("pre-shifting [%d,%d]\n", preShift[WIDTH], preShift[HEIGHT]); - } - shift(preShift[WIDTH], preShift[HEIGHT], &sheet); - } - - // pre-masking - if (preMaskCount > 0) { - if (verbose >= VERBOSE_NORMAL) { - printf("pre-masking\n "); - } - applyMasks(preMask, preMaskCount, maskColor, &sheet); - } - - - // -------------------------------------------------------------- - // --- verbose parameter output, --- - // -------------------------------------------------------------- - - // parameters and size are known now - - if (verbose >= VERBOSE_MORE) { - if (layout != LAYOUT_NONE) { - if (layout == LAYOUT_SINGLE) { - layoutStr = "single"; - } else if (layout == LAYOUT_DOUBLE) { - layoutStr = "double"; - } - printf("layout: %s\n", layoutStr); - } - - if (preRotate != 0) { - printf("pre-rotate: %d\n", preRotate); - } - if (preMirror != 0) { - printf("pre-mirror: "); - printDirections(preMirror); - } - if ((preShift[WIDTH] != 0) || ((preShift[HEIGHT] != 0))) { - printf("pre-shift: "); - printInts(preShift); - } - if (preWipeCount > 0) { - printf("pre-wipe: "); - for (i = 0; i < preWipeCount; i++) { - printf("[%d,%d,%d,%d] ",preWipe[i][LEFT],preWipe[i][TOP],preWipe[i][RIGHT],preWipe[i][BOTTOM]); - } - printf("\n"); - } - if (preBorder[LEFT]!=0 || preBorder[TOP]!=0 || preBorder[RIGHT]!=0 || preBorder[BOTTOM]!=0) { - printf("pre-border: [%d,%d,%d,%d]\n", preBorder[LEFT], preBorder[TOP], preBorder[RIGHT], preBorder[BOTTOM]); - } - if (preMaskCount > 0) { - printf("pre-masking: "); - for (i = 0; i < preMaskCount; i++) { - printf("[%d,%d,%d,%d] ",preMask[i][LEFT],preMask[i][TOP],preMask[i][RIGHT],preMask[i][BOTTOM]); - } - printf("\n"); - } - if ((stretchSize[WIDTH] != -1) || (stretchSize[HEIGHT] != -1)) { - printf("stretch to: %dx%d\n", stretchSize[WIDTH], stretchSize[HEIGHT]); - } - if ((postStretchSize[WIDTH] != -1) || (postStretchSize[HEIGHT] != -1)) { - printf("post-stretch to: %dx%d\n", postStretchSize[WIDTH], postStretchSize[HEIGHT]); - } - if (zoomFactor != 1.0) { - printf("zoom: %f\n", zoomFactor); - } - if (postZoomFactor != 1.0) { - printf("post-zoom: %f\n", postZoomFactor); - } - if (noBlackfilterMultiIndexCount != -1) { - printf("blackfilter-scan-direction: "); - printDirections(blackfilterScanDirections); - printf("blackfilter-scan-size: "); - printInts(blackfilterScanSize); - printf("blackfilter-scan-depth: "); - printInts(blackfilterScanDepth); - printf("blackfilter-scan-step: "); - printInts(blackfilterScanStep); - printf("blackfilter-scan-threshold: %f\n", blackfilterScanThreshold); - if (blackfilterExcludeCount > 0) { - printf("blackfilter-scan-exclude: "); - for (i = 0; i < blackfilterExcludeCount; i++) { - printf("[%d,%d,%d,%d] ",blackfilterExclude[i][LEFT],blackfilterExclude[i][TOP],blackfilterExclude[i][RIGHT],blackfilterExclude[i][BOTTOM]); - } - printf("\n"); - } - printf("blackfilter-intensity: %d\n", blackfilterIntensity); - if (noBlackfilterMultiIndexCount > 0) { - printf("blackfilter DISABLED for sheets: "); - printMultiIndex(noBlackfilterMultiIndex, noBlackfilterMultiIndexCount); - } - } else { - printf("blackfilter DISABLED for all sheets.\n"); - } - if (noNoisefilterMultiIndexCount != -1) { - printf("noisefilter-intensity: %d\n", noisefilterIntensity); - if (noNoisefilterMultiIndexCount > 0) { - printf("noisefilter DISABLED for sheets: "); - printMultiIndex(noNoisefilterMultiIndex, noNoisefilterMultiIndexCount); - } - } else { - printf("noisefilter DISABLED for all sheets.\n"); - } - if (noBlurfilterMultiIndexCount != -1) { - printf("blurfilter-size: "); - printInts(blurfilterScanSize); - printf("blurfilter-step: "); - printInts(blurfilterScanStep); - printf("blurfilter-intensity: %f\n", blurfilterIntensity); - if (noBlurfilterMultiIndexCount > 0) { - printf("blurfilter DISABLED for sheets: "); - printMultiIndex(noBlurfilterMultiIndex, noBlurfilterMultiIndexCount); - } - } else { - printf("blurfilter DISABLED for all sheets.\n"); - } - if (noGrayfilterMultiIndexCount != -1) { - printf("grayfilter-size: "); - printInts(grayfilterScanSize); - printf("grayfilter-step: "); - printInts(grayfilterScanStep); - printf("grayfilter-threshold: %f\n", grayfilterThreshold); - if (noGrayfilterMultiIndexCount > 0) { - printf("grayfilter DISABLED for sheets: "); - printMultiIndex(noGrayfilterMultiIndex, noGrayfilterMultiIndexCount); - } - } else { - printf("grayfilter DISABLED for all sheets.\n"); - } - if (noMaskScanMultiIndexCount != -1) { - printf("mask points: "); - for (i = 0; i < pointCount; i++) { - printf("(%d,%d) ",point[i][X],point[i][Y]); - } - printf("\n"); - printf("mask-scan-direction: "); - printDirections(maskScanDirections); - printf("mask-scan-size: "); - printInts(maskScanSize); - printf("mask-scan-depth: "); - printInts(maskScanDepth); - printf("mask-scan-step: "); - printInts(maskScanStep); - printf("mask-scan-threshold: ");//%f\n", maskScanThreshold); - printFloats(maskScanThreshold); - printf("mask-scan-minimum: [%d,%d]\n", maskScanMinimum[WIDTH], maskScanMinimum[HEIGHT]); - printf("mask-scan-maximum: [%d,%d]\n", maskScanMaximum[WIDTH], maskScanMaximum[HEIGHT]); - printf("mask-color: %d\n", maskColor); - if (noMaskScanMultiIndexCount > 0) { - printf("mask-scan DISABLED for sheets: "); - printMultiIndex(noMaskScanMultiIndex, noMaskScanMultiIndexCount); - } - } else { - printf("mask-scan DISABLED for all sheets.\n"); - } - if (noDeskewMultiIndexCount != -1) { - printf("deskew-scan-direction: "); - printEdges(deskewScanEdges); - printf("deskew-scan-size: %d\n", deskewScanSize); - printf("deskew-scan-depth: %f\n", deskewScanDepth); - printf("deskew-scan-range: %f\n", deskewScanRange); - printf("deskew-scan-step: %f\n", deskewScanStep); - printf("deskew-scan-deviation: %f\n", deskewScanDeviation); - if (qpixels==FALSE) { - printf("qpixel-coding DISABLED.\n"); - } - if (noDeskewMultiIndexCount > 0) { - printf("deskew-scan DISABLED for sheets: "); - printMultiIndex(noDeskewMultiIndex, noDeskewMultiIndexCount); - } - } else { - printf("deskew-scan DISABLED for all sheets.\n"); - } - if (noWipeMultiIndexCount != -1) { - if (wipeCount > 0) { - printf("wipe areas: "); - for (i = 0; i < wipeCount; i++) { - printf("[%d,%d,%d,%d] ", wipe[i][LEFT], wipe[i][TOP], wipe[i][RIGHT], wipe[i][BOTTOM]); - } - printf("\n"); - } - } else { - printf("wipe DISABLED for all sheets.\n"); - } - if (middleWipe[0] > 0 || middleWipe[1] > 0) { - printf("middle-wipe (l,r): %d,%d\n", middleWipe[0], middleWipe[1]); - } - if (noBorderMultiIndexCount != -1) { - if (border[LEFT]!=0 || border[TOP]!=0 || border[RIGHT]!=0 || border[BOTTOM]!=0) { - printf("explicit border: [%d,%d,%d,%d]\n", border[LEFT], border[TOP], border[RIGHT], border[BOTTOM]); - } - } else { - printf("border DISABLED for all sheets.\n"); - } - if (noBorderScanMultiIndexCount != -1) { - printf("border-scan-direction: "); - printDirections(borderScanDirections); - printf("border-scan-size: "); - printInts(borderScanSize); - printf("border-scan-step: "); - printInts(borderScanStep); - printf("border-scan-threshold: ");//%f\n", maskScanThreshold); - printInts(borderScanThreshold); - if (noBorderScanMultiIndexCount > 0) { - printf("border-scan DISABLED for sheets: "); - printMultiIndex(noBorderScanMultiIndex, noBorderScanMultiIndexCount); - } - printf("border-align: "); - printEdges(borderAlign); - printf("border-margin: "); - printInts(borderAlignMargin); - } else { - printf("border-scan DISABLED for all sheets.\n"); - } - if (postWipeCount > 0) { - printf("post-wipe: "); - for (i = 0; i < postWipeCount; i++) { - printf("[%d,%d,%d,%d] ",postWipe[i][LEFT],postWipe[i][TOP],postWipe[i][RIGHT],postWipe[i][BOTTOM]); - } - printf("\n"); - } - if (postBorder[LEFT]!=0 || postBorder[TOP]!=0 || postBorder[RIGHT]!=0 || postBorder[BOTTOM]!=0) { - printf("post-border: [%d,%d,%d,%d]\n", postBorder[LEFT], postBorder[TOP], postBorder[RIGHT], postBorder[BOTTOM]); - } - if (postMirror != 0) { - printf("post-mirror: "); - printDirections(postMirror); - } - if ((postShift[WIDTH] != 0) || ((postShift[HEIGHT] != 0))) { - printf("post-shift: "); - printInts(postShift); - } - if (postRotate != 0) { - printf("post-rotate: %d\n", postRotate); - } - //if (ignoreMultiIndexCount > 0) { - // printf("EXCLUDE sheets: "); - // printMultiIndex(ignoreMultiIndex, ignoreMultiIndexCount); - //} - printf("white-threshold: %f\n", whiteThreshold); - printf("black-threshold: %f\n", blackThreshold); - printf("sheet-background: %s\n", ((sheetBackground == BLACK) ? "black" : "white") ); - printf("dpi: %d\n", dpi); - printf("input-files per sheet: %d\n", inputCount); - printf("output-files per sheet: %d\n", outputCount); - if ((sheetSize[WIDTH] != -1) || (sheetSize[HEIGHT] != -1)) { - printf("sheet size forced to: %d x %d pixels\n", sheetSize[WIDTH], sheetSize[HEIGHT]); - } - printf("input-file-sequence: %s\n", implode(s1, inputFileSequence, inputFileSequenceCount)); - printf("output-file-sequence: %s\n", implode(s1, outputFileSequence, outputFileSequenceCount)); - if (overwrite) { - printf("OVERWRITING EXISTING FILES\n"); - } - printf("\n"); - } - if (verbose >= VERBOSE_NORMAL) { - printf("input-file%s for sheet %d: %s (type%s %s)\n", pluralS(inputCount), nr, implode(s1, inputFilenamesResolved, inputCount), pluralS(inputCount), implode(s2, inputTypeNames, inputCount)); - printf("output-file%s for sheet %d: %s (type %s)\n", pluralS(outputCount), nr, implode(s1, outputFilenamesResolved, outputCount), outputTypeName); - printf("sheet size: %dx%d\n", sheet.width, sheet.height); - printf("...\n"); - } - - - // ------------------------------------------------------- - // --- process image data --- - // ------------------------------------------------------- - - // stretch - if ((stretchSize[WIDTH] != -1) || (stretchSize[HEIGHT] != -1)) { - if (stretchSize[WIDTH] != -1) { - w = stretchSize[WIDTH]; - } else { - w = sheet.width; - } - if (stretchSize[HEIGHT] != -1) { - h = stretchSize[HEIGHT]; - } else { - h = sheet.height; - } - saveDebug("./_before-stretch.pnm", &sheet); - stretch(w, h, &sheet); - saveDebug("./_after-stretch.pnm", &sheet); - } - - // zoom - if (zoomFactor != 1.0) { - w = sheet.width * zoomFactor; - h = sheet.height * zoomFactor; - stretch(w, h, &sheet); - } - - // size - if ((size[WIDTH] != -1) || (size[HEIGHT] != -1)) { - if (size[WIDTH] != -1) { - w = size[WIDTH]; - } else { - w = sheet.width; - } - if (size[HEIGHT] != -1) { - h = size[HEIGHT]; - } else { - h = sheet.height; - } - saveDebug("./_before-resize.pnm", &sheet); - resize(w, h, &sheet); - saveDebug("./_after-resize.pnm", &sheet); - } - - - // handle sheet layout - - // LAYOUT_SINGLE - if (layout == LAYOUT_SINGLE) { - // set middle of sheet as single starting point for mask detection - if (pointCount == 0) { // no manual settings, use auto-values - point[pointCount][X] = sheet.width / 2; - point[pointCount][Y] = sheet.height / 2; - pointCount++; - } - if (maskScanMaximum[WIDTH] == -1) { - maskScanMaximum[WIDTH] = sheet.width; - } - if (maskScanMaximum[HEIGHT] == -1) { - maskScanMaximum[HEIGHT] = sheet.height; - } - // avoid inner half of the sheet to be blackfilter-detectable - if (blackfilterExcludeCount == 0) { // no manual settings, use auto-values - blackfilterExclude[blackfilterExcludeCount][LEFT] = sheet.width / 4; - blackfilterExclude[blackfilterExcludeCount][TOP] = sheet.height / 4; - blackfilterExclude[blackfilterExcludeCount][RIGHT] = sheet.width / 2 + sheet.width / 4; - blackfilterExclude[blackfilterExcludeCount][BOTTOM] = sheet.height / 2 + sheet.height / 4; - blackfilterExcludeCount++; - } - // set single outside border to start scanning for final border-scan - if (outsideBorderscanMaskCount == 0) { // no manual settings, use auto-values - outsideBorderscanMaskCount = 1; - outsideBorderscanMask[0][LEFT] = 0; - outsideBorderscanMask[0][RIGHT] = sheet.width - 1; - outsideBorderscanMask[0][TOP] = 0; - outsideBorderscanMask[0][BOTTOM] = sheet.height - 1; - } - - // LAYOUT_DOUBLE - } else if (layout == LAYOUT_DOUBLE) { - // set two middle of left/right side of sheet as starting points for mask detection - if (pointCount == 0) { // no manual settings, use auto-values - point[pointCount][X] = sheet.width / 4; - point[pointCount][Y] = sheet.height / 2; - pointCount++; - point[pointCount][X] = sheet.width - sheet.width / 4; - point[pointCount][Y] = sheet.height / 2; - pointCount++; - } - if (maskScanMaximum[WIDTH] == -1) { - maskScanMaximum[WIDTH] = sheet.width / 2; - } - if (maskScanMaximum[HEIGHT] == -1) { - maskScanMaximum[HEIGHT] = sheet.height; - } - if (middleWipe[0] > 0 || middleWipe[1] > 0) { // left, right - wipe[wipeCount][LEFT] = sheet.width / 2 - middleWipe[0]; - wipe[wipeCount][TOP] = 0; - wipe[wipeCount][RIGHT] = sheet.width / 2 + middleWipe[1]; - wipe[wipeCount][BOTTOM] = sheet.height - 1; - wipeCount++; - } - // avoid inner half of each page to be blackfilter-detectable - if (blackfilterExcludeCount == 0) { // no manual settings, use auto-values - blackfilterExclude[blackfilterExcludeCount][LEFT] = sheet.width / 8; - blackfilterExclude[blackfilterExcludeCount][TOP] = sheet.height / 4; - blackfilterExclude[blackfilterExcludeCount][RIGHT] = sheet.width / 4 + sheet.width / 8; - blackfilterExclude[blackfilterExcludeCount][BOTTOM] = sheet.height / 2 + sheet.height / 4; - blackfilterExcludeCount++; - blackfilterExclude[blackfilterExcludeCount][LEFT] = sheet.width / 2 + sheet.width / 8; - blackfilterExclude[blackfilterExcludeCount][TOP] = sheet.height / 4; - blackfilterExclude[blackfilterExcludeCount][RIGHT] = sheet.width / 2 + sheet.width / 4 + sheet.width / 8; - blackfilterExclude[blackfilterExcludeCount][BOTTOM] = sheet.height / 2 + sheet.height / 4; - blackfilterExcludeCount++; - } - // set two outside borders to start scanning for final border-scan - if (outsideBorderscanMaskCount == 0) { // no manual settings, use auto-values - outsideBorderscanMaskCount = 2; - outsideBorderscanMask[0][LEFT] = 0; - outsideBorderscanMask[0][RIGHT] = sheet.width / 2; - outsideBorderscanMask[0][TOP] = 0; - outsideBorderscanMask[0][BOTTOM] = sheet.height - 1; - outsideBorderscanMask[1][LEFT] = sheet.width / 2; - outsideBorderscanMask[1][RIGHT] = sheet.width - 1; - outsideBorderscanMask[1][TOP] = 0; - outsideBorderscanMask[1][BOTTOM] = sheet.height - 1; - } - } - // if maskScanMaximum still unset (no --layout specified), set to full sheet size now - if (maskScanMinimum[WIDTH] == -1) { - maskScanMaximum[WIDTH] = sheet.width; - } - if (maskScanMinimum[HEIGHT] == -1) { - maskScanMaximum[HEIGHT] = sheet.height; - } - - - // pre-wipe - if (!isExcluded(nr, noWipeMultiIndex, noWipeMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { - applyWipes(preWipe, preWipeCount, maskColor, &sheet); - } - - // pre-border - if (!isExcluded(nr, noBorderMultiIndex, noBorderMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { - applyBorder(preBorder, maskColor, &sheet); - } - - // black area filter - if (!isExcluded(nr, noBlackfilterMultiIndex, noBlackfilterMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { - saveDebug("./_before-blackfilter.pnm", &sheet); - blackfilter(blackfilterScanDirections, blackfilterScanSize, blackfilterScanDepth, blackfilterScanStep, blackfilterScanThreshold, blackfilterExclude, blackfilterExcludeCount, blackfilterIntensity, blackThreshold, &sheet); - saveDebug("./_after-blackfilter.pnm", &sheet); - } else { - if (verbose >= VERBOSE_MORE) { - printf("+ blackfilter DISABLED for sheet %d\n", nr); - } - } - - // noise filter - if (!isExcluded(nr, noNoisefilterMultiIndex, noNoisefilterMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { - if (verbose >= VERBOSE_NORMAL) { - printf("noise-filter ..."); - } - saveDebug("./_before-noisefilter.pnm", &sheet); - filterResult = noisefilter(noisefilterIntensity, whiteThreshold, &sheet); - saveDebug("./_after-noisefilter.pnm", &sheet); - if (verbose >= VERBOSE_NORMAL) { - printf(" deleted %d clusters.\n", filterResult); - } - } else { - if (verbose >= VERBOSE_MORE) { - printf("+ noisefilter DISABLED for sheet %d\n", nr); - } - } - - // blur filter - if (!isExcluded(nr, noBlurfilterMultiIndex, noBlurfilterMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { - if (verbose >= VERBOSE_NORMAL) { - printf("blur-filter..."); - } - saveDebug("./_before-blurfilter.pnm", &sheet); - filterResult = blurfilter(blurfilterScanSize, blurfilterScanStep, blurfilterIntensity, whiteThreshold, &sheet); - saveDebug("./_after-blurfilter.pnm", &sheet); - if (verbose >= VERBOSE_NORMAL) { - printf(" deleted %d pixels.\n", filterResult); - } - } else { - if (verbose >= VERBOSE_MORE) { - printf("+ blurfilter DISABLED for sheet %d\n", nr); - } - } - - // mask-detection - if (!isExcluded(nr, noMaskScanMultiIndex, noMaskScanMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { - maskCount = detectMasks(mask, maskValid, point, pointCount, maskScanDirections, maskScanSize, maskScanDepth, maskScanStep, maskScanThreshold, maskScanMinimum, maskScanMaximum, &sheet); - } else { - if (verbose >= VERBOSE_MORE) { - printf("+ mask-scan DISABLED for sheet %d\n", nr); - } - } - - // permamently apply masks - if (maskCount > 0) { - saveDebug("./_before-masking.pnm", &sheet); - applyMasks(mask, maskCount, maskColor, &sheet); - saveDebug("./_after-masking.pnm", &sheet); - } - - // gray filter - if (!isExcluded(nr, noGrayfilterMultiIndex, noGrayfilterMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { - if (verbose >= VERBOSE_NORMAL) { - printf("gray-filter..."); - } - saveDebug("./_before-grayfilter.pnm", &sheet); - filterResult = grayfilter(grayfilterScanSize, grayfilterScanStep, grayfilterThreshold, blackThreshold, &sheet); - saveDebug("./_after-grayfilter.pnm", &sheet); - if (verbose >= VERBOSE_NORMAL) { - printf(" deleted %d pixels.\n", filterResult); - } - } else { - if (verbose >= VERBOSE_MORE) { - printf("+ grayfilter DISABLED for sheet %d\n", nr); - } - } - - // rotation-detection - if ((!isExcluded(nr, noDeskewMultiIndex, noDeskewMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount))) { - saveDebug("./_before-deskew.pnm", &sheet); - originalSheet = sheet; // copy struct entries ('clone') - // convert to qpixels - if (qpixels==TRUE) { - if (verbose>=VERBOSE_NORMAL) { - printf("converting to qpixels.\n"); - } - initImage(&qpixelSheet, sheet.width * 2, sheet.height * 2, sheet.bitdepth, sheet.color, sheetBackground); - convertToQPixels(&sheet, &qpixelSheet); - sheet = qpixelSheet; - q = 2; // qpixel-factor for coordinates in both directions - } else { - q = 1; - } - - // detect masks again, we may get more precise results now after first masking and grayfilter - if (!isExcluded(nr, noMaskScanMultiIndex, noMaskScanMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { - maskCount = detectMasks(mask, maskValid, point, pointCount, maskScanDirections, maskScanSize, maskScanDepth, maskScanStep, maskScanThreshold, maskScanMinimum, maskScanMaximum, &originalSheet); - } else { - if (verbose >= VERBOSE_MORE) { - printf("(mask-scan before deskewing disabled)\n"); - } - } - - // auto-deskew each mask - for (i = 0; i < maskCount; i++) { - - // if ( maskValid[i] == TRUE ) { // point may have been invalidated if mask has not been auto-detected - - // for rotation detection, original buffer is used (not qpixels) - saveDebug("./_before-deskew-detect.pnm", &originalSheet); - rotation = - detectRotation(deskewScanEdges, deskewScanRange, deskewScanStep, deskewScanSize, deskewScanDepth, deskewScanDeviation, mask[i][LEFT], mask[i][TOP], mask[i][RIGHT], mask[i][BOTTOM], &originalSheet); - saveDebug("./_after-deskew-detect.pnm", &originalSheet); - - if (rotation != 0.0) { - if (verbose>=VERBOSE_NORMAL) { - printf("rotate (%d,%d): %f\n", point[i][X], point[i][Y], rotation); - } - initImage(&rect, (mask[i][RIGHT]-mask[i][LEFT]+1)*q, (mask[i][BOTTOM]-mask[i][TOP]+1)*q, sheet.bitdepth, sheet.color, sheetBackground); - initImage(&rectTarget, rect.width, rect.height, sheet.bitdepth, sheet.color, sheetBackground); - - // copy area to rotate into rSource - copyImageArea(mask[i][LEFT]*q, mask[i][TOP]*q, rect.width, rect.height, &sheet, 0, 0, &rect); - - // rotate - rotate(degreesToRadians(rotation), &rect, &rectTarget); - - // copy result back into whole image - copyImageArea(0, 0, rectTarget.width, rectTarget.height, &rectTarget, mask[i][LEFT]*q, mask[i][TOP]*q, &sheet); - - freeImage(&rect); - freeImage(&rectTarget); - } else { - if (verbose >= VERBOSE_NORMAL) { - printf("rotate (%d,%d): -\n", point[i][X], point[i][Y]); - } - } - - // } - } - - // convert back from qpixels - if (qpixels == TRUE) { - if (verbose >= VERBOSE_NORMAL) { - printf("converting back from qpixels.\n"); - } - convertFromQPixels(&qpixelSheet, &originalSheet); - freeImage(&qpixelSheet); - sheet = originalSheet; - } - saveDebug("./_after-deskew.pnm", &sheet); - } else { - if (verbose >= VERBOSE_MORE) { - printf("+ deskewing DISABLED for sheet %d\n", nr); - } - } - - // auto-center masks on either single-page or double-page layout - if ( (!isExcluded(nr, noMaskCenterMultiIndex, noMaskCenterMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) && (layout != LAYOUT_NONE) && (maskCount == pointCount) ) { // (maskCount==pointCount to make sure all masks had correctly been detected) - // perform auto-masking again to get more precise masks after rotation - if (!isExcluded(nr, noMaskScanMultiIndex, noMaskScanMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { - maskCount = detectMasks(mask, maskValid, point, pointCount, maskScanDirections, maskScanSize, maskScanDepth, maskScanStep, maskScanThreshold, maskScanMinimum, maskScanMaximum, &sheet); - } else { - if (verbose >= VERBOSE_MORE) { - printf("(mask-scan before centering disabled)\n"); - } - } - - saveDebug("./_before-centering.pnm", &sheet); - // center masks on the sheet, according to their page position - for (i = 0; i < maskCount; i++) { - centerMask(point[i][X], point[i][Y], mask[i][LEFT], mask[i][TOP], mask[i][RIGHT], mask[i][BOTTOM], &sheet); - } - saveDebug("./_after-centering.pnm", &sheet); - } else { - if (verbose >= VERBOSE_MORE) { - printf("+ auto-centering DISABLED for sheet %d\n", nr); - } - } - - // explicit wipe - if (!isExcluded(nr, noWipeMultiIndex, noWipeMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { - applyWipes(wipe, wipeCount, maskColor, &sheet); - } else { - if (verbose >= VERBOSE_MORE) { - printf("+ wipe DISABLED for sheet %d\n", nr); - } - } - - // explicit border - if (!isExcluded(nr, noBorderMultiIndex, noBorderMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { - applyBorder(border, maskColor, &sheet); - } else { - if (verbose >= VERBOSE_MORE) { - printf("+ border DISABLED for sheet %d\n", nr); - } - } - - // border-detection - if (!isExcluded(nr, noBorderScanMultiIndex, noBorderScanMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { - saveDebug("./_before-border.pnm", &sheet); - for (i = 0; i < outsideBorderscanMaskCount; i++) { - detectBorder(autoborder[i], borderScanDirections, borderScanSize, borderScanStep, borderScanThreshold, blackThreshold, outsideBorderscanMask[i], &sheet); - borderToMask(autoborder[i], autoborderMask[i], &sheet); - } - applyMasks(autoborderMask, outsideBorderscanMaskCount, maskColor, &sheet); - for (i = 0; i < outsideBorderscanMaskCount; i++) { - // border-centering - if (!isExcluded(nr, noBorderAlignMultiIndex, noBorderAlignMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { - alignMask(autoborderMask[i], outsideBorderscanMask[i], borderAlign, borderAlignMargin, &sheet); - } else { - if (verbose >= VERBOSE_MORE) { - printf("+ border-centering DISABLED for sheet %d\n", nr); - } - } - } - saveDebug("./_after-border.pnm", &sheet); - } else { - if (verbose >= VERBOSE_MORE) { - printf("+ border-scan DISABLED for sheet %d\n", nr); - } - } - - // post-wipe - if (!isExcluded(nr, noWipeMultiIndex, noWipeMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { - applyWipes(postWipe, postWipeCount, maskColor, &sheet); - } - - // post-border - if (!isExcluded(nr, noBorderMultiIndex, noBorderMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { - applyBorder(postBorder, maskColor, &sheet); - } - - // post-mirroring - if (postMirror != 0) { - if (verbose >= VERBOSE_NORMAL) { - printf("post-mirroring "); - printDirections(postMirror); - } - mirror(postMirror, &sheet); - } - - // post-shifting - if ((postShift[WIDTH] != 0) || ((postShift[HEIGHT] != 0))) { - if (verbose >= VERBOSE_NORMAL) { - printf("post-shifting [%d,%d]\n", postShift[WIDTH], postShift[HEIGHT]); - } - shift(postShift[WIDTH], postShift[HEIGHT], &sheet); - } - - // post-rotating - if (postRotate != 0) { - if (verbose >= VERBOSE_NORMAL) { - printf("post-rotating %d degrees.\n", postRotate); - } - if (postRotate == 90) { - flipRotate(1, &sheet); - } else if (postRotate == -90) { - flipRotate(-1, &sheet); - } - } - - // post-stretch - if ((postStretchSize[WIDTH] != -1) || (postStretchSize[HEIGHT] != -1)) { - if (postStretchSize[WIDTH] != -1) { - w = postStretchSize[WIDTH]; - } else { - w = sheet.width; - } - if (postStretchSize[HEIGHT] != -1) { - h = postStretchSize[HEIGHT]; - } else { - h = sheet.height; - } - stretch(w, h, &sheet); - } - - // post-zoom - if (postZoomFactor != 1.0) { - w = sheet.width * postZoomFactor; - h = sheet.height * postZoomFactor; - stretch(w, h, &sheet); - } - - // post-size - if ((postSize[WIDTH] != -1) || (postSize[HEIGHT] != -1)) { - if (postSize[WIDTH] != -1) { - w = postSize[WIDTH]; - } else { - w = sheet.width; - } - if (postSize[HEIGHT] != -1) { - h = postSize[HEIGHT]; - } else { - h = sheet.height; - } - resize(w, h, &sheet); - } - - if (showTime) { - endTime = clock(); - } - - // --- write output file --- - - // write split pages output - - if (writeoutput == TRUE) { - if (verbose >= VERBOSE_NORMAL) { - printf("writing output.\n"); - } - // write files - saveDebug("./_before-save.pnm", &sheet); - success = TRUE; - page.width = sheet.width / outputCount; - page.height = sheet.height; - page.bitdepth = sheet.bitdepth; - page.color = sheet.color; - for ( j = 0; success && (j < outputCount); j++) { - // get pagebuffer - if ( outputCount == 1 ) { - page.buffer = sheet.buffer; - page.bufferGrayscale = sheet.bufferGrayscale; - page.bufferLightness = sheet.bufferLightness; - page.bufferDarknessInverse = sheet.bufferDarknessInverse; - } else { // generic case: copy page-part of sheet into own buffer - if (page.color) { - page.buffer = (unsigned char*)malloc( page.width * page.height * 3 ); - page.bufferGrayscale = (unsigned char*)malloc( page.width * page.height ); - page.bufferLightness = (unsigned char*)malloc( page.width * page.height ); - page.bufferDarknessInverse = (unsigned char*)malloc( page.width * page.height ); - } else { - page.buffer = (unsigned char*)malloc( page.width * page.height ); - page.bufferGrayscale = page.buffer; - page.bufferLightness = page.buffer; - page.bufferDarknessInverse = page.buffer; - } - copyImageArea(page.width * j, 0, page.width, page.height, &sheet, 0, 0, &page); - } - - success = saveImage(outputFilenamesResolved[j], &page, outputType, overwrite, blackThreshold); - - if ( outputCount > 1 ) { - freeImage(&page); - } - if (success == FALSE) { - printf("*** error: Could not save image data to file %s.\n", outputFilenamesResolved[j]); - exitCode = 2; - } - } - } - - freeImage(&sheet); - sheet.buffer = NULL; - - if (showTime) { - if (startTime > endTime) { // clock overflow - endTime -= startTime; // "re-underflow" value again - startTime = 0; - } - time = endTime - startTime; - totalTime += time; - totalCount++; - printf("- processing time: %f s\n", (float)time/CLOCKS_PER_SEC); - } - } - } - } - } - if ( showTime && (totalCount > 1) ) { - printf("- total processing time of all %d sheets: %f s (average: %f s)\n", totalCount, (double)totalTime/CLOCKS_PER_SEC, (double)totalTime/totalCount/CLOCKS_PER_SEC); - } - return exitCode; -} diff -Nru unpaper-0.3/test-driver unpaper-0.4.2/test-driver --- unpaper-0.3/test-driver 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/test-driver 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,127 @@ +#! /bin/sh +# test-driver - basic driver script for the `parallel-tests' mode. + +scriptversion=2011-08-17.14; # UTC + +# Copyright (C) 2011-2012 Free Software Foundation, Inc. +# +# 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, 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 . + +# 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 file is maintained in Automake, please report +# bugs to or send patches to +# . + +# Make unconditional expansion of undefined variables an error. This +# helps a lot in preventing typo-related bugs. +set -u + +usage_error () +{ + echo "$0: $*" >&2 + print_usage >&2 + exit 2 +} + +print_usage () +{ + cat <$log_file 2>&1 +estatus=$? +if test $enable_hard_errors = no && test $estatus -eq 99; then + estatus=1 +fi + +case $estatus:$expect_failure in + 0:yes) col=$red res=XPASS recheck=yes gcopy=yes;; + 0:*) col=$grn res=PASS recheck=no gcopy=no;; + 77:*) col=$blu res=SKIP recheck=no gcopy=yes;; + 99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;; + *:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;; + *:*) col=$red res=FAIL recheck=yes gcopy=yes;; +esac + +# Report outcome to console. +echo "${col}${res}${std}: $test_name" + +# Register the test result, and other relevant metadata. +echo ":test-result: $res" > $trs_file +echo ":global-test-result: $res" >> $trs_file +echo ":recheck: $recheck" >> $trs_file +echo ":copy-in-global-log: $gcopy" >> $trs_file + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: Binary files /tmp/TbWyLZsGYz/unpaper-0.3/tests/imgsrc001.png and /tmp/mW96iyvleP/unpaper-0.4.2/tests/imgsrc001.png differ Binary files /tmp/TbWyLZsGYz/unpaper-0.3/tests/imgsrc002.png and /tmp/mW96iyvleP/unpaper-0.4.2/tests/imgsrc002.png differ Binary files /tmp/TbWyLZsGYz/unpaper-0.3/tests/imgsrc003.png and /tmp/mW96iyvleP/unpaper-0.4.2/tests/imgsrc003.png differ Binary files /tmp/TbWyLZsGYz/unpaper-0.3/tests/imgsrc004.png and /tmp/mW96iyvleP/unpaper-0.4.2/tests/imgsrc004.png differ Binary files /tmp/TbWyLZsGYz/unpaper-0.3/tests/imgsrc005.png and /tmp/mW96iyvleP/unpaper-0.4.2/tests/imgsrc005.png differ Binary files /tmp/TbWyLZsGYz/unpaper-0.3/tests/imgsrcE001.png and /tmp/mW96iyvleP/unpaper-0.4.2/tests/imgsrcE001.png differ Binary files /tmp/TbWyLZsGYz/unpaper-0.3/tests/imgsrcE002.png and /tmp/mW96iyvleP/unpaper-0.4.2/tests/imgsrcE002.png differ Binary files /tmp/TbWyLZsGYz/unpaper-0.3/tests/imgsrcE003.png and /tmp/mW96iyvleP/unpaper-0.4.2/tests/imgsrcE003.png differ diff -Nru unpaper-0.3/tests/prologue.sh.in unpaper-0.4.2/tests/prologue.sh.in --- unpaper-0.3/tests/prologue.sh.in 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/tests/prologue.sh.in 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,6 @@ +set -e +set -x + +UNPAPER=@abs_top_builddir@/unpaper +PNGTOPNM=@PNGTOPNM@ +PNMTOPNG=@PNMTOPNG@ diff -Nru unpaper-0.3/tests/runtestA1.sh unpaper-0.4.2/tests/runtestA1.sh --- unpaper-0.3/tests/runtestA1.sh 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/tests/runtestA1.sh 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,10 @@ +#!/bin/sh + +echo "[A1] Single-Page Template Layout, Black+White, Full Processing." + +. tests/prologue.sh + +rm -f tests/resultsA1.pbm +$UNPAPER -v --overwrite tests/imgsrc001.pbm tests/resultsA1.pbm + +[ -f tests/resultsA1.pbm ] diff -Nru unpaper-0.3/tests/runtestB1.sh unpaper-0.4.2/tests/runtestB1.sh --- unpaper-0.3/tests/runtestB1.sh 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/tests/runtestB1.sh 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,10 @@ +#!/bin/sh + +echo "[B1] Combined Color/Gray, No Processing." + +. tests/prologue.sh + +rm -f tests/resultsB1.ppm +$UNPAPER -v --overwrite -n --input-pages 2 tests/imgsrc003.ppm tests/imgsrc004.pgm tests/resultsB1.ppm + +[ -f tests/resultsB1.ppm ] diff -Nru unpaper-0.3/tests/runtestB2.sh unpaper-0.4.2/tests/runtestB2.sh --- unpaper-0.3/tests/runtestB2.sh 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/tests/runtestB2.sh 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,10 @@ +#!/bin/sh + +echo "[B2] Combined Color/Black+White, No Processing." + +. tests/prologue.sh + +rm -f tests/resultsB2.ppm +$UNPAPER -v --overwrite -n --input-pages 2 tests/imgsrc003.ppm tests/imgsrc005.pbm tests/resultsB2.ppm + +[ -f tests/resultsB2.ppm ] diff -Nru unpaper-0.3/tests/runtestB3.sh unpaper-0.4.2/tests/runtestB3.sh --- unpaper-0.3/tests/runtestB3.sh 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/tests/runtestB3.sh 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,10 @@ +#!/bin/sh + +echo "[B3] Combined Gray/Black+White, No Processing." + +. tests/prologue.sh + +rm -f tests/resultsB3.ppm +$UNPAPER -v --overwrite -n --input-pages 2 tests/imgsrc004.pgm tests/imgsrc005.pbm tests/resultsB3.ppm + +[ -f tests/resultsB3.ppm ] diff -Nru unpaper-0.3/tests/runtestC1.sh unpaper-0.4.2/tests/runtestC1.sh --- unpaper-0.3/tests/runtestC1.sh 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/tests/runtestC1.sh 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,10 @@ +#!/bin/sh + +echo "[C1] Black sheet background color." + +. tests/prologue.sh + +rm -f tests/resultsC1.pbm +$UNPAPER -v --overwrite -n --sheet-size a4 --sheet-background black tests/imgsrc002.pbm tests/resultsC1.pbm + +[ -f tests/resultsC1.pbm ] diff -Nru unpaper-0.3/tests/runtestC2.sh unpaper-0.4.2/tests/runtestC2.sh --- unpaper-0.3/tests/runtestC2.sh 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/tests/runtestC2.sh 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,10 @@ +#!/bin/sh + +echo "[C2] Explicit shifting." + +. tests/prologue.sh + +rm -f tests/resultsC2.pbm +$UNPAPER -v --overwrite -n --sheet-size a4 --pre-shift -5cm,9cm tests/imgsrc002.pbm tests/resultsC2.pbm + +[ -f tests/resultsC2.pbm ] diff -Nru unpaper-0.3/tests/runtestC3.sh unpaper-0.4.2/tests/runtestC3.sh --- unpaper-0.3/tests/runtestC3.sh 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/tests/runtestC3.sh 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,10 @@ +#!/bin/sh + +echo "[C3] Explicit -1 size shifting." + +. tests/prologue.sh + +rm -f tests/resultsC3.pbm +$UNPAPER -v --overwrite -n --sheet-size a4 --pre-shift -1cm tests/imgsrc002.pbm tests/resultsC3.pbm + +[ -f tests/resultsC3.pbm ] diff -Nru unpaper-0.3/tests/runtestD1.sh unpaper-0.4.2/tests/runtestD1.sh --- unpaper-0.3/tests/runtestD1.sh 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/tests/runtestD1.sh 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,10 @@ +#!/bin/sh + +echo "[D1] Crop to sheet size." + +. tests/prologue.sh + +rm -f tests/resultsD1.ppm +$UNPAPER -v --overwrite -n --sheet-size 20cm,10cm tests/imgsrc003.ppm tests/resultsD1.ppm + +[ -f tests/resultsD1.ppm ] diff -Nru unpaper-0.3/tests/runtestD2.sh unpaper-0.4.2/tests/runtestD2.sh --- unpaper-0.3/tests/runtestD2.sh 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/tests/runtestD2.sh 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,10 @@ +#!/bin/sh + +echo "[D2] Fit to sheet size." + +. tests/prologue.sh + +rm -f tests/resultsD2.ppm +$UNPAPER -v --overwrite -n --size 20cm,10cm tests/imgsrc003.ppm tests/resultsD2.ppm + +[ -f tests/resultsD2.ppm ] diff -Nru unpaper-0.3/tests/runtestD3.sh unpaper-0.4.2/tests/runtestD3.sh --- unpaper-0.3/tests/runtestD3.sh 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/tests/runtestD3.sh 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,10 @@ +#!/bin/sh + +echo "[D3] Stretch to sheet size." + +. tests/prologue.sh + +rm -f tests/resultsD3.ppm +$UNPAPER -v --overwrite -n --stretch 20cm,10cm tests/imgsrc003.ppm tests/resultsD3.ppm + +[ -f tests/resultsD3.ppm ] diff -Nru unpaper-0.3/tests/runtestE1.sh unpaper-0.4.2/tests/runtestE1.sh --- unpaper-0.3/tests/runtestE1.sh 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/tests/runtestE1.sh 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,14 @@ +#!/bin/sh + +echo "[E1] Splitting 2-page layout into seperate output pages." + +. tests/prologue.sh + +for i in 1 2 3 4 5 6; do + rm -f tests/resultsE00$i.pbm +done +$UNPAPER -v --overwrite --layout double --output-pages 2 tests/imgsrcE%03d.pbm tests/resultsE%03d.pbm + +for i in 1 2 3 4 5 6; do + [ -f tests/resultsE00$i.pbm ] +done diff -Nru unpaper-0.3/tests/runtestE2.sh unpaper-0.4.2/tests/runtestE2.sh --- unpaper-0.3/tests/runtestE2.sh 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/tests/runtestE2.sh 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,14 @@ +#!/bin/sh + +echo "[E1] Splitting 2-page layout into seperate output pages." + +. tests/prologue.sh + +for i in 1 2; do + rm -f tests/resultsE20$i.pbm +done +$UNPAPER -v --overwrite --layout double --output-pages 2 tests/imgsrcE001.pbm tests/resultsE2%02d.pbm + +for i in 1 2; do + [ -f tests/resultsE20$i.pbm ] +done diff -Nru unpaper-0.3/tests/runtestE3.sh unpaper-0.4.2/tests/runtestE3.sh --- unpaper-0.3/tests/runtestE3.sh 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/tests/runtestE3.sh 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,14 @@ +#!/bin/sh + +echo "[E1] Splitting 2-page layout into seperate output pages." + +. tests/prologue.sh + +for i in 1 2; do + rm -f tests/resultsE30$i.pbm +done +$UNPAPER -v --overwrite --layout double --output-pages 2 tests/imgsrcE001.pbm tests/resultsE301.pbm tests/resultsE302.pbm + +for i in 1 2; do + [ -f tests/resultsE30$i.pbm ] +done diff -Nru unpaper-0.3/TODO unpaper-0.4.2/TODO --- unpaper-0.3/TODO 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/TODO 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,2 @@ + * Allocations need to be verified to not overflow, as they are almost + always generated by multiplication. diff -Nru unpaper-0.3/tools.c unpaper-0.4.2/tools.c --- unpaper-0.3/tools.c 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/tools.c 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,718 @@ +/* + * This file is part of Unpaper. + * + * Copyright © 2005-2007 Jens Gulden + * Copyright © 2011-2011 Diego Elio Pettenò + * + * Unpaper 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, version 2 of the License. + * + * Unpaper 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 . + */ + +#include +#include +#include +#include + +#include "unpaper.h" + +/**************************************************************************** + * tool functions * + * - arithmetic tool functions * + * - tool functions for image handling * + ****************************************************************************/ + + +/* --- arithmetic tool functions ------------------------------------------ */ + +/** + * Returns the quadratic square of a number. + */ +double sqr(double d) { + return d*d; +} + + +/** + * Converts degrees to radians. + */ +double degreesToRadians(double d) { + return d * M_PI / 180.0; +} + + +/** + * Converts radians to degrees. + */ +double radiansToDegrees(double r) { + return r * 180.0 / M_PI; +} + + +/** + * Limits an integer value to a maximum. + */ +void limit(int* i, int max) { + if (*i > max) { + *i = max; + } +} + + +/* --- tool functions for image handling ---------------------------------- */ + +/** + * Allocates a memory block for storing image data and fills the IMAGE-struct + * with the specified values. + */ +void initImage(struct IMAGE* image, int width, int height, int bitdepth, bool color, int background) { + int size; + + size = width * height; + if ( color ) { + image->bufferGrayscale = (uint8_t*)malloc(size); + image->bufferLightness = (uint8_t*)malloc(size); + image->bufferDarknessInverse = (uint8_t*)malloc(size); + memset(image->bufferGrayscale, background, size); + memset(image->bufferLightness, background, size); + memset(image->bufferDarknessInverse, background, size); + size *= 3; + } + image->buffer = (uint8_t*)malloc(size); + memset(image->buffer, background, size); + if ( ! color ) { + image->bufferGrayscale = image->buffer; + image->bufferLightness = image->buffer; + image->bufferDarknessInverse = image->buffer; + } + image->width = width; + image->height = height; + image->bitdepth = bitdepth; + image->color = color; + image->background = background; +} + + +/** + * Frees an image. + */ +void freeImage(struct IMAGE* image) { + free(image->buffer); + if (image->color) { + free(image->bufferGrayscale); + free(image->bufferLightness); + free(image->bufferDarknessInverse); + } +} + + +/** + * Replaces one image with another. + */ +void replaceImage(struct IMAGE* image, struct IMAGE* newimage) { + freeImage(image); + // pass-back new image + *image = *newimage; // copy whole struct +} + + +/** + * Sets the color/grayscale value of a single pixel. + * + * @return true if the pixel has been changed, false if the original color was the one to set + */ +bool setPixel(int pixel, int x, int y, struct IMAGE* image) { + uint8_t* p; + int w, h; + int pos; + bool result; + uint8_t r, g, b; + + w = image->width; + h = image->height; + if ( (x < 0) || (x >= w) || (y < 0) || (y >= h) ) { + return false; //nop + } else { + pos = (y * w) + x; + r = (pixel >> 16) & 0xff; + g = (pixel >> 8) & 0xff; + b = pixel & 0xff; + if ( ! image->color ) { + p = &image->buffer[pos]; + if ((r == g) && (r == b)) { // optimization (avoid division by 3) + pixel = r; + } else { + pixel = pixelGrayscale(r, g, b); // convert to gray (will already be in most cases, but we can't be sure) + } + if (*p != (uint8_t)pixel) { + *p = (uint8_t)pixel; + return true; + } else { + return false; + } + } else { // color + result = false; + p = &image->buffer[pos*3]; + if (*p != r) { + *p = r; + result = true; + } + p++; + if (*p != g) { + *p = g; + result = true; + } + p++; + if (*p != b) { + *p = b; + result = true; + } + if ( result ) { // modified: update cached grayscale, lightness and brightnessInverse values + image->bufferGrayscale[pos] = pixelGrayscale(r, g, b); + image->bufferLightness[pos] = pixelLightness(r, g, b); + image->bufferDarknessInverse[pos] = pixelDarknessInverse(r, g, b); + } + return result; + } + } +} + + +/** + * Returns the color or grayscale value of a single pixel. + * Always returns a color-compatible value (which may be interpreted as 8-bit grayscale) + * + * @return color or grayscale-value of the requested pixel, or WHITE if the coordinates are outside the image + */ +int getPixel(int x, int y, struct IMAGE* image) { + const int w = image->width; + const int h = image->height; + if ( (x < 0) || (x >= w) || (y < 0) || (y >= h) ) { + return pixelValue(WHITE, WHITE, WHITE); + } else { + int pos = (y * w) + x; + if ( ! image->color ) { + const int pix = (uint8_t)image->buffer[pos]; + return pixelValue(pix, pix, pix); + } else { // color + pos *= 3; + const uint8_t r = (uint8_t)image->buffer[pos++]; + const uint8_t g = (uint8_t)image->buffer[pos++]; + const uint8_t b = (uint8_t)image->buffer[pos]; + return pixelValue(r, g, b); + } + } +} + + +/** + * Returns a color component of a single pixel (0-255). + * + * @param colorComponent either RED, GREEN or BLUE + * @return color or grayscale-value of the requested pixel, or WHITE if the coordinates are outside the image + */ + /* (currently not used) +int getPixelComponent(int x, int y, int colorComponent, struct IMAGE* image) { + int w, h; + int pos; + + w = image->width; + h = image->height; + if ( (x < 0) || (x >= w) || (y < 0) || (y >= h) ) { + return WHITE; + } else { + pos = (y * w) + x; + if ( ! image->color ) { + return (uint8_t)image->buffer[pos]; + } else { // color + return (uint8_t)image->buffer[(pos * 3) + colorComponent]; + } + } +} +*/ + +/** + * Returns the grayscale (=brightness) value of a single pixel. + * + * @return grayscale-value of the requested pixel, or WHITE if the coordinates are outside the image + */ +int getPixelGrayscale(int x, int y, struct IMAGE* image) { + const int w = image->width; + const int h = image->height; + const int pos = (y * w) + x; + + if ( (x < 0) || (x >= w) || (y < 0) || (y >= h) ) { + return WHITE; + } else { + return image->bufferGrayscale[pos]; + } +} + + +/** + * Returns the 'lightness' value of a single pixel. For color images, this + * value denotes the minimum brightness of a single color-component in the + * total color, which means that any color is considered 'dark' which has + * either the red, the green or the blue component (or, of course, several + * of them) set to a high value. In some way, this is a measure how close a + * color is to white. + * For grayscale images, this value is equal to the pixel brightness. + * + * @return lightness-value (the higher, the lighter) of the requested pixel, or WHITE if the coordinates are outside the image + */ +static int getPixelLightness(int x, int y, struct IMAGE* image) { + const int w = image->width; + const int h = image->height; + const int pos = (y * w) + x; + + if ( (x < 0) || (x >= w) || (y < 0) || (y >= h) ) { + return WHITE; + } else { + return image->bufferLightness[pos]; + } +} + + +/** + * Returns the 'inverse-darkness' value of a single pixel. For color images, this + * value denotes the maximum brightness of a single color-component in the + * total color, which means that any color is considered 'light' which has + * either the red, the green or the blue component (or, of course, several + * of them) set to a high value. In some way, this is a measure how far away a + * color is to black. + * For grayscale images, this value is equal to the pixel brightness. + * + * @return inverse-darkness-value (the LOWER, the darker) of the requested pixel, or WHITE if the coordinates are outside the image + */ +int getPixelDarknessInverse(int x, int y, struct IMAGE* image) { + const int w = image->width; + const int h = image->height; + const int pos = (y * w) + x; + + if ( (x < 0) || (x >= w) || (y < 0) || (y >= h) ) { + return WHITE; + } else { + return image->bufferDarknessInverse[pos]; + } +} + + +/** + * Sets the color/grayscale value of a single pixel to either black or white. + * + * @return true if the pixel has been changed, false if the original color was the one to set + */ +static bool setPixelBW(int x, int y, struct IMAGE* image, int blackwhite) { + const int w = image->width; + const int h = image->height; + const int pos = (y * w) + x; + + if ( (x < 0) || (x >= w) || (y < 0) || (y >= h) ) { + return false; //nop + } else { + if ( ! image->color ) { + uint8_t *p = &image->buffer[pos]; + if (*p != blackwhite) { + *p = blackwhite; + return true; + } else { + return false; + } + } else { // color + uint8_t *p = &image->buffer[pos * 3]; + bool result = false; + + if (*p != blackwhite) { + *p = blackwhite; + result = true; + } + p++; + if (*p != blackwhite) { + *p = blackwhite; + result = true; + } + p++; + if (*p != blackwhite) { + *p = blackwhite; + result = true; + } + return result; + } + } +} + + +/** + * Sets the color/grayscale value of a single pixel to white. + * + * @return true if the pixel has been changed, false if the original color was the one to set + */ +static bool clearPixel(int x, int y, struct IMAGE* image) { + return setPixelBW(x, y, image, WHITE); +} + + +/** + * Clears a rectangular area of pixels with either black or white. + * @return The number of pixels actually changed from black (dark) to white. + */ +int clearRect(int left, int top, int right, int bottom, struct IMAGE* image, int blackwhite) { + int x; + int y; + int count = 0; + + for (y = top; y <= bottom; y++) { + for (x = left; x <= right; x++) { + if (setPixelBW(x, y, image, blackwhite)) { + count++; + } + } + } + return count; +} + + +/** + * Copies one area of an image into another. + */ +void copyImageArea(int x, int y, int width, int height, struct IMAGE* source, int toX, int toY, struct IMAGE* target) { + int row; + int col; + + // naive but generic implementation + for (row = 0; row < height; row++) { + for (col = 0; col < width; col++) { + const int pixel = getPixel(x+col, y+row, source); + setPixel(pixel, toX+col, toY+row, target); + } + } +} + + +/** + * Copies a whole image into another. + */ +void copyImage(struct IMAGE* source, int toX, int toY, struct IMAGE* target) { + copyImageArea(0, 0, source->width, source->height, source, toX, toY, target); +} + + +/** + * Centers one area of an image inside an area of another image. + * If the source area is smaller than the target area, is is equally + * surrounded by a white border, if it is bigger, it gets equally cropped + * at the edges. + */ +static void centerImageArea(int x, int y, int w, int h, struct IMAGE* source, int toX, int toY, int ww, int hh, struct IMAGE* target) { + if ((w < ww) || (h < hh)) { // white rest-border will remain, so clear first + clearRect(toX, toY, toX + ww - 1, toY + hh - 1, target, target->background); + } + if (w < ww) { + toX += (ww - w) / 2; + } + if (h < hh) { + toY += (hh - h) / 2; + } + if (w > ww) { + x += (w - ww) / 2; + w = ww; + } + if (h > hh) { + y += (h - hh) / 2; + h = hh; + } + copyImageArea(x, y, w, h, source, toX, toY, target); +} + + +/** + * Centers a whole image inside an area of another image. + */ +void centerImage(struct IMAGE* source, int toX, int toY, int ww, int hh, struct IMAGE* target) { + centerImageArea(0, 0, source->width, source->height, source, toX, toY, ww, hh, target); +} + + +/** + * Returns the average brightness of a rectagular area. + */ +int brightnessRect(int x1, int y1, int x2, int y2, struct IMAGE* image) { + int x; + int y; + int total = 0; + const int count = (x2-x1+1)*(y2-y1+1); + + for (x = x1; x <= x2; x++) { + for (y = y1; y <= y2; y++) { + const int pixel = getPixelGrayscale(x, y, image); + total += pixel; + } + } + return total / count; +} + + +/** + * Returns the average lightness of a rectagular area. + */ +int lightnessRect(int x1, int y1, int x2, int y2, struct IMAGE* image) { + int x; + int y; + int total = 0; + const int count = (x2-x1+1)*(y2-y1+1); + + for (x = x1; x <= x2; x++) { + for (y = y1; y <= y2; y++) { + const int pixel = getPixelLightness(x, y, image); + total += pixel; + } + } + return total / count; +} + + +/** + * Returns the average darkness of a rectagular area. + */ +int darknessInverseRect(int x1, int y1, int x2, int y2, struct IMAGE* image) { + int x; + int y; + int total = 0; + const int count = (x2-x1+1)*(y2-y1+1); + + for (x = x1; x <= x2; x++) { + for (y = y1; y <= y2; y++) { + const int pixel = getPixelDarknessInverse(x, y, image); + total += pixel; + } + } + return total / count; +} + + +/** + * Counts the number of pixels in a rectangular area whose grayscale + * values ranges between minColor and maxBrightness. Optionally, the area can get + * cleared with white color while counting. + */ +int countPixelsRect(int left, int top, int right, int bottom, int minColor, int maxBrightness, bool clear, struct IMAGE* image) { + int x; + int y; + int count = 0; + + for (y = top; y <= bottom; y++) { + for (x = left; x <= right; x++) { + const int pixel = getPixelGrayscale(x, y, image); + if ((pixel>=minColor) && (pixel <= maxBrightness)) { + if (clear==true) { + clearPixel(x, y, image); + } + count++; + } + } + } + return count; +} + + +/** + * Counts the number of dark pixels around the pixel at (x,y), who have a + * square-metric distance of 'level' to the (x,y) (thus, testing the values + * of 9 pixels if level==1, 16 pixels if level==2 and so on). + * Optionally, the pixels can get cleared after counting. + */ +static int countPixelNeighborsLevel(int x, int y, bool clear, int level, int whiteMin, struct IMAGE* image) { + int xx; + int yy; + int count = 0; + int pixel; + + // upper and lower rows + for (xx = x - level; xx <= x + level; xx++) { + // upper row + pixel = getPixelLightness(xx, y - level, image); + if (pixel < whiteMin) { // non-light pixel found + if (clear == true) { + clearPixel(xx, y - level, image); + } + count++; + } + // lower row + pixel = getPixelLightness(xx, y + level, image); + if (pixel < whiteMin) { + if (clear == true) { + clearPixel(xx, y + level, image); + } + count++; + } + } + // middle rows + for (yy = y-(level-1); yy <= y+(level-1); yy++) { + // first col + pixel = getPixelLightness(x - level, yy, image); + if (pixel < whiteMin) { + if (clear == true) { + clearPixel(x - level, yy, image); + } + count++; + } + // last col + pixel = getPixelLightness(x + level, yy, image); + if (pixel < whiteMin) { + if (clear == true) { + clearPixel(x + level, yy, image); + } + count++; + } + } + /* old version, not optimized: + for (yy = y-level; yy <= y+level; yy++) { + for (xx = x-level; xx <= x+level; xx++) { + if (abs(xx-x)==level || abs(yy-y)==level) { + pixel = getPixelLightness(xx, yy, image); + if (pixel < whiteMin) { + if (clear==true) { + clearPixel(xx, yy, image); + } + count++; + } + } + } + }*/ + return count; +} + + +/** + * Count all dark pixels in the distance 0..intensity that are directly + * reachable from the dark pixel at (x,y), without having to cross bright + * pixels. + */ +int countPixelNeighbors(int x, int y, int intensity, int whiteMin, struct IMAGE* image) { + int level; + int count = 1; // assume self as set + int lCount = -1; + + for (level = 1; (lCount != 0) && (level <= intensity); level++) { // can finish when one level is completely zero + lCount = countPixelNeighborsLevel(x, y, false, level, whiteMin, image); + count += lCount; + } + return count; +} + + +/** + * Clears all dark pixels that are directly reachable from the dark pixel at + * (x,y). This should be called only if it has previously been detected that + * the amount of pixels to clear will be reasonable small. + */ +void clearPixelNeighbors(int x, int y, int whiteMin, struct IMAGE* image) { + int level; + int lCount = -1; + + clearPixel(x, y, image); + + for (level = 1; lCount != 0; level++) { // lCount will become 0, otherwise countPixelNeighbors() would previously have delivered a bigger value (and this here would not have been called) + lCount = countPixelNeighborsLevel(x, y, true, level, whiteMin, image); + } +} + + +/** + * Flood-fill an area of pixels. + * (Declaration of header for indirect recursive calls.) + */ +void floodFill(int x, int y, int color, int maskMin, int maskMax, int intensity, struct IMAGE* image); + + +/** + * Solidly fills a line of pixels heading towards a specified direction + * until color-changes in the pixels to overwrite exceed the 'intensity' + * parameter. + * + * @param stepX either -1 or 1, if stepY is 0, else 0 + * @param stepY either -1 or 1, if stepX is 0, else 0 + */ +static int fillLine(int x, int y, int stepX, int stepY, int color, int maskMin, int maskMax, int intensity, struct IMAGE* image) { + int distance = 0; + int intensityCount = 1; // first pixel must match, otherwise directly exit + const int w = image->width; + const int h = image->height; + + while (true) { + int pixel; + + x += stepX; + y += stepY; + pixel = getPixelGrayscale(x, y, image); + if ((pixel>=maskMin) && (pixel<=maskMax)) { + intensityCount = intensity; // reset counter + } else { + intensityCount--; // allow maximum of 'intensity' pixels to be bright, until stop + } + if ((intensityCount > 0) && (x>=0) && (x=0) && (y=maskMin) && (pixel<=maskMax)) { + // first, fill a 'cross' (both vertical, horizontal line) + setPixel(color, x, y, image); + const int left = fillLine(x, y, -1, 0, color, maskMin, maskMax, intensity, image); + const int top = fillLine(x, y, 0, -1, color, maskMin, maskMax, intensity, image); + const int right = fillLine(x, y, 1, 0, color, maskMin, maskMax, intensity, image); + const int bottom = fillLine(x, y, 0, 1, color, maskMin, maskMax, intensity, image); + // now recurse on each neighborhood-pixel of the cross (most recursions will immediately return) + floodFillAroundLine(x, y, -1, 0, left, color, maskMin, maskMax, intensity, image); + floodFillAroundLine(x, y, 0, -1, top, color, maskMin, maskMax, intensity, image); + floodFillAroundLine(x, y, 1, 0, right, color, maskMin, maskMax, intensity, image); + floodFillAroundLine(x, y, 0, 1, bottom, color, maskMin, maskMax, intensity, image); + } +} diff -Nru unpaper-0.3/tools.h unpaper-0.4.2/tools.h --- unpaper-0.3/tools.h 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/tools.h 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,69 @@ +/* + * This file is part of Unpaper. + * + * Copyright © 2005-2007 Jens Gulden + * Copyright © 2011-2011 Diego Elio Pettenò + * + * Unpaper 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, version 2 of the License. + * + * Unpaper 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 . + */ + +/* --- arithmetic tool functions ------------------------------------------ */ + + +double sqr(double d); + +double degreesToRadians(double d); + +double radiansToDegrees(double r); + +void limit(int* i, int max); + + +/* --- tool functions for image handling ---------------------------------- */ + + +void initImage(struct IMAGE* image, int width, int height, int bitdepth, bool color, int background); + +void freeImage(struct IMAGE* image); + +void replaceImage(struct IMAGE* image, struct IMAGE* newimage); + +bool setPixel(int pixel, int x, int y, struct IMAGE* image); + +int getPixel(int x, int y, struct IMAGE* image); + +int getPixelGrayscale(int x, int y, struct IMAGE* image); + +int getPixelDarknessInverse(int x, int y, struct IMAGE* image); + +int clearRect(int left, int top, int right, int bottom, struct IMAGE* image, int blackwhite); + +void copyImageArea(int x, int y, int width, int height, struct IMAGE* source, int toX, int toY, struct IMAGE* target); + +void copyImage(struct IMAGE* source, int toX, int toY, struct IMAGE* target); + +void centerImage(struct IMAGE* source, int toX, int toY, int ww, int hh, struct IMAGE* target); + +int brightnessRect(int x1, int y1, int x2, int y2, struct IMAGE* image); + +int lightnessRect(int x1, int y1, int x2, int y2, struct IMAGE* image); + +int darknessInverseRect(int x1, int y1, int x2, int y2, struct IMAGE* image); + +int countPixelsRect(int left, int top, int right, int bottom, int minColor, int maxBrightness, bool clear, struct IMAGE* image); + +int countPixelNeighbors(int x, int y, int intensity, int whiteMin, struct IMAGE* image); + +void clearPixelNeighbors(int x, int y, int whiteMin, struct IMAGE* image); + +void floodFill(int x, int y, int color, int maskMin, int maskMax, int intensity, struct IMAGE* image); diff -Nru unpaper-0.3/unpaper.1 unpaper-0.4.2/unpaper.1 --- unpaper-0.3/unpaper.1 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/unpaper.1 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,732 @@ +'\" t +.\" Title: unpaper +.\" Author: +.\" Generator: DocBook XSL-NS Stylesheets v1.77.0 +.\" Date: September 2011 +.\" Manual: Reference +.\" Source: unpaper +.\" Language: English +.\" +.TH "UNPAPER" "1" "September 2011" "unpaper" "Reference" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +unpaper \- Post\-processing tool for scanned sheets of paper\&. +.SH "SYNOPSIS" +.HP \w'\fBunpaper\fR\ 'u +\fBunpaper\fR [\fIoptions\fR] {\fIinput\-pattern\ \fR\fIoutput\-pattern\fR | \fIinput\-file(s)\fR\ \fIoutput\-file(s)\fR} +.SH "OVERVIEW" +.PP +unpaper is a post\-processing tool for scanned sheets of paper, especially for book pages that have been scanned from previously created photocopies\&. The main purpose is to make scanned book pages better readable on screen after conversion to PDF\&. Additionally, unpaper might be useful to enhance the quality of scanned pages before performing optical character recognition (OCR)\&. +.PP +unpaper tries to clean scanned images by removing dark edges that appeared through scanning or copying on areas outside the actual page content (e\&.g\&. dark areas between the left\-hand\-side and the right\-hand\-side of a double\- sided book\-page scan)\&. The program also tries to detect disaligned centering and rotation of pages and will automatically straighten each page by rotating it to the correct angle\&. This process is called "deskewing"\&. Note that the automatic processing will sometimes fail\&. It is always a good idea to manually control the results of unpaper and adjust the parameter settings according to the requirements of the input\&. Each processing step can also be disabled individually for each sheet\&. +.PP +Input and output files can be in either +\&.pbm, +\&.pgm +or +\&.ppm +format, thus generally in +\&.pnm +format, as also used by the Linux scanning tools +\fBscanimage\fR +and +\fBscanadf\fR\&. Conversion to PDF can e\&.g\&. be achieved with the Linux tools +\fBpgm2tiff\fR, +\fBtiffcp\fR +and +\fBtiff2pdf\fR\&. +.SH "INPUT AND OUTPUT FILES" +.PP +Input and output files need to be designed either by using patterns or an ordered list of input and output files; if patterns are used, such as +%04d, then they are substituted for the input and output sheet number before opening the file for input or output\&. +.PP +If you\*(Aqre not using patterns, then the program expects one or two input files depending on what is passed as +\fB\-\-input\-pages\fR +and one or two output files depending on what is passed as +\fB\-\-output\-pages\fR, in order\&. +.PP +Missing output file names are fatal and will stop processing; missing initial input file names are fatal, and so is any missing input file if a range of sheets is defined through +\fB\-\-sheet\fR +or +\fB\-\-end\-sheet\fR\&. +.PP + +\fBunpaper\fR +accepts files in PNM format, which means they might be in +\&.pbm, +\&.pgm, +\&.ppm +or +\&.pnm +format, which is what is produced by Linux command line scanning tools such as +\fBscanimage\fR +and +\fBscanadf\fR\&. +.SH "OPTIONS" +.PP +\fB\-l\fR { \fBsingle\fR | \fBdouble\fR | \fBnone\fR }, \fB\-\-layout\fR { \fBsingle\fR | \fBdouble\fR | \fBnone\fR } +.RS 4 +Set default layout options for a sheet: +.PP +\fBsingle\fR +.RS 4 +One page per sheet\&. +.RE +.PP +\fBdouble\fR +.RS 4 +Two pages per sheet, landscape orientation (one page on the left half, one page on the right half)\&. +.RE +.PP +\fBnone\fR +.RS 4 +No auto\-layout, mask\-scan\-points may individually be specified\&. +.RE +.sp +Using +\fBsingle\fR +or +\fBdouble\fR +automatically sets corresponding +\fB\-\-mask\-scan\-points\fR\&. The default is +\fBsingle\fR\&. +.RE +.PP +\fB\-start\fR \fIsheet\fR, \fB\-\-start\-sheet\fR \fIstart\-sheet\fR +.RS 4 +Number of first sheet to process in multi\-sheet mode\&. (default: 1) +.RE +.PP +\fB\-end\fR \fIsheet\fR, \fB\-\-end\-sheet\fR \fIsheet\fR +.RS 4 +Number of last sheet to process in multi\-sheet mode\&. \-1 indicates processing until no more input file with the corresponding page number is available (default: \-1) +.RE +.PP +\fB\-#\fR \fIsheet\-range\fR, \fB\-\-sheet\fR \fIsheet\-range\fR +.RS 4 +Optionally specifies which sheets to process in the range between start\-sheet and end\-sheet\&. +.RE +.PP +\fB\-x\fR \fIsheet\-range\fR, \fB\-\-exclude\fR \fIsheet\-range\fR +.RS 4 +Excludes sheets from processing in the range between start\-sheet and end\-sheet\&. +.RE +.PP +\fB\-\-pre\-rotate\fR { \fB\-90\fR | \fB90\fR } +.RS 4 +Rotates the whole image clockwise (\fB90\fR) or anti\-clockwise (\fB\-90\fR) before any other processing\&. +.RE +.PP +\fB\-\-post\-rotate\fR { \fB\-90\fR | \fB90\fR } +.RS 4 +Rotates the whole image clockwise (\fB90\fR) or anti\-clockwise (\fB\-90\fR) after any other processing\&. +.RE +.PP +\fB\-M\fR { \fBv\fR | \fBh\fR | \fBv,h\fR }, \fB\-\-pre\-mirror\fR { \fBv\fR | \fBh\fR | \fBv,h\fR } +.RS 4 +Mirror the image, after possible pre\-rotation\&. Either +\fBv\fR +(for vertical mirroring), +\fBh\fR +(for horizontal mirroring) or +\fBv,h\fR +(for both) can be specified\&. +.RE +.PP +\fB\-\-post\-mirror\fR { \fBv\fR | \fBh\fR | \fBv,h\fR } +.RS 4 +Mirror the image, after any other processing except possible post\-rotation\&. Either +\fBv\fR +(for vertical mirroring), +\fBh\fR +(for horizontal mirroring) or +\fBv,h\fR +(for both) can be specified\&. +.RE +.PP +\fB\-\-pre\-shift\fR \fIh\fR\fB,\fR\fIv\fR +.RS 4 +Shift the image before further processing\&. Values for +\fIh\fR +(horizontal shift) and +\fIv\fR +(vertical shift) can either be positive or negative\&. +.RE +.PP +\fB\-\-post\-shift\fR \fIh\fR\fB,\fR\fIv\fR +.RS 4 +Shift the image after other processing\&. Values for +\fIh\fR +(horizontal shift) and +\fIv\fR +(vertical shift) can either be positive or negative\&. +.RE +.PP +\fB\-\-pre\-wipe\fR \fIleft\fR\fB,\fR\fItop\fR\fB,\fR\fIright\fR\fB,\fR\fIbottom\fR +.RS 4 +Manually wipe out an area before further processing\&. Any pixel in a wiped area will be set to white\&. Multiple areas to be wiped may be specified by multiple occurrences of this options\&. +.RE +.PP +\fB\-\-post\-wipe\fR \fIleft\fR\fB,\fR\fItop\fR\fB,\fR\fIright\fR\fB,\fR\fIbottom\fR +.RS 4 +Manually wipe out an area after processing\&. Any pixel in a wiped area will be set to white\&. Multiple areas to be wiped may be specified by multiple occurrences of this options\&. +.RE +.PP +\fB\-\-pre\-border\fR \fIleft\fR\fB,\fR\fItop\fR\fB,\fR\fIright\fR\fB,\fR\fIbottom\fR +.RS 4 +Clear the border\-area of the sheet before further processing\&. Any pixel in the border area will be set to white\&. +.RE +.PP +\fB\-\-post\-border\fR \fIleft\fR\fB,\fR\fItop\fR\fB,\fR\fIright\fR\fB,\fR\fIbottom\fR +.RS 4 +Clear the border\-area of the sheet after other processing\&. Any pixel in the border area will be set to white\&. +.RE +.PP +\fB\-\-pre\-mask\fR \fIx1\fR\fB,\fR\fIy1\fR\fB,\fR\fIx2\fR\fB,\fR\fIy2\fR +.RS 4 +Specify masks to apply before any other processing\&. Any pixel outside a mask will be set to white, unless another mask includes this pixel\&. +.sp +Only pixels inside a mask will remain\&. Multiple masks may be specified\&. No deskewing will be applied to the masks specified by +\fB\-\-pre\-mask\fR\&. +.RE +.PP +\fB\-s\fR { \fIwidth\fR\fB,\fR\fIheight\fR | \fIsize\-name\fR }, \fB\-\-size\fR { \fIwidth\fR\fB,\fR\fIheight\fR | \fIsize\-name\fR } +.RS 4 +Change the sheet size before other processing is applied\&. Content on the sheet gets zoomed to fit to the appropriate size, but the aspect ratio is preserved\&. Instead, if the sheet\*(Aqs aspect ratio changes, the zoomed content gets centered on the sheet\&. +.sp +Possible values for +\fIsize\-name\fR +are: +\fBa5\fR, +\fBa4\fR, +\fBa3\fR, +\fBletter\fR, +\fBlegal\fR\&. All size names can also be applied in rotated landscape orientation, use +\fBa4\-landscape\fR, +\fBletter\-landscape\fR +etc\&. +.RE +.PP +\fB\-\-post\-size\fR { \fIwidth\fR\fB,\fR\fIheight\fR | \fIsize\-name\fR } +.RS 4 +Change the sheet size preserving the content\*(Aqs aspect ratio after other processing steps are applied\&. +.RE +.PP +\fB\-\-stretch\fR { \fIwidth\fR\fB,\fR\fIheight\fR | \fIsize\-name\fR } +.RS 4 +Change the sheet size before other processing is applied\&. Content on the sheet gets stretched to the specified size, possibly changing the aspect ratio\&. +.RE +.PP +\fB\-\-post\-stretch\fR { \fIwidth\fR\fB,\fR\fIheight\fR | \fIsize\-name\fR } +.RS 4 +Change the sheet size after other processing is applied\&. Content on the sheet gets stretched to the specified size, possibly changing the aspect ratio\&. +.RE +.PP +\fB\-z\fR \fIfactor\fR, \fB\-\-zoom\fR \fIfactor\fR +.RS 4 +Change the sheet size according to the given factor before other processing is done\&. +.RE +.PP +\fB\-\-post\-zoom\fR \fIfactor\fR +.RS 4 +Change the sheet size according to the given factor after processing is done\&. +.RE +.PP +\fB\-bn\fR { \fBv\fR | \fBh\fR | \fBv,h\fR }, \fB\-\-blackfilter\-scan\-direction\fR { \fBv\fR | \fBh\fR | \fBv,h\fR } +.RS 4 +Directions in which to search for solidly black areas\&. Either +\fBv\fR +(for vertical mirroring), +\fBh\fR +(for horizontal mirroring) or +\fBv,h\fR +(for both) can be specified\&. +.RE +.PP +\fB\-bs\fR { \fIsize\fR | \fIh\-size\fR\fB,\fR\fIv\-size\fR }, \fB\-\-blackfilter\-scan\-size\fR { \fIsize\fR | \fIh\-size\fR\fB,\fR\fIv\-size\fR } +.RS 4 +Width of virtual bar used for mask detection\&. Two values may be specified to individually set horizontal and vertical size\&. (default: +\fB20,20\fR) +.RE +.PP +\fB\-bd\fR { \fIdepth\fR | \fIh\-depth\fR\fB,\fR\fIv\-depth\fR }, \fB\-\-blackfilter\-scan\-depth\fR { \fIdepth\fR | \fIh\-depth\fR\fB,\fR\fIv\-depth\fR } +.RS 4 +Size of virtual bar used for black area detection\&. (default: +\fB500,500\fR) +.RE +.PP +\fB\-bp\fR { \fIstep\fR | \fIh\-step\fR\fB,\fR\fIv\-step\fR }, \fB\-\-blackfilter\-scan\-step\fR { \fIstep\fR | \fIh\-step\fR\fB,\fR\fIv\-step\fR } +.RS 4 +Steps to move virtual bar for black area detection\&. (default: +\fB5,5\fR) +.RE +.PP +\fB\-bt\fR \fIthreshold\fR, \fB\-\-blackfilter\-scan\-threshold\fR \fIthreshold\fR +.RS 4 +Ratio of dark pixels above which a black area gets detected\&. (default: +\fB0\&.95\fR)\&. +.RE +.PP +\fB\-bx\fR \fIleft\fR\fB,\fR\fItop\fR\fB,\fR\fIright\fR\fB,\fR\fIbottom\fR, \fB\-\-blackfilter\-scan\-exclude\fR \fIleft\fR\fB,\fR\fItop\fR\fB,\fR\fIright\fR\fB,\fR\fIbottom\fR +.RS 4 +Area on which the blackfilter should not operate\&. This can be useful to prevent the blackfilter from working on inner page content\&. May be specified multiple times to set more than one area\&. +.RE +.PP +\fB\-bi\fR \fIintensity\fR, \fB\-\-blackfilter\-intensity\fR \fIintensity\fR +.RS 4 +Intensity with which to delete black areas\&. Larger values will leave less noise\-pixels around former black areas, but may delete page content\&. (default: +\fB20\fR) +.RE +.PP +\fB\-ni\fR \fIintensity\fR, \fB\-noisefilter\-intensity\fR \fIintensity\fR +.RS 4 +Intensity with which to delete individual pixels or tiny clusters of pixels\&. Any cluster which only contains +\fIintensity\fR +dark pixels together will be deleted\&. (default: +\fB4\fR) +.RE +.PP +\fB\-ls\fR { \fIsize\fR | \fIh\-size\fR\fB,\fR\fIv\-size\fR }, \fB\-\-blurfilter\-size\fR { \fIsize\fR | \fIh\-size\fR\fB,\fR\fIv\-size\fR } +.RS 4 +Size of blurfilter area to search for "lonely" clusters of pixels\&. (default: +\fB100,100\fR) +.RE +.PP +\fB\-lp\fR { \fIstep\fR | \fIh\-step\fR\fB,\fR\fIv\-step\fR }, \fB\-\-blurfilter\-step\fR { \fIstep\fR | \fIh\-step\fR\fB,\fR\fIv\-step\fR } +.RS 4 +Size of "blurring" steps in each direction\&. (default: +\fB50,50\fR) +.RE +.PP +\fB\-li\fR \fIratio\fR, \fB\-\-blurfilter\-intensity\fR \fIratio\fR +.RS 4 +Relative intensity with which to delete tiny clusters of pixels\&. Any blurred area which contains at most the +\fIratio\fR +of dark pixels will be cleared\&. (default: +\fB0\&.01\fR) +.RE +.PP +\fB\-gs\fR { \fIsize\fR | \fIh\-size\fR\fB,\fR\fIv\-size\fR }, \fB\-\-grayfilter\-size\fR { \fIsize\fR | \fIh\-size\fR\fB,\fR\fIv\-size\fR } +.RS 4 +Size of grayfilter mask to search for "gray\-only" areas of pixels\&. (default: +\fB50,50\fR) +.RE +.PP +\fB\-gp\fR { \fIstep\fR | \fIh\-step\fR\fB,\fR\fIv\-step\fR }, \fB\-\-grayfilter\-step\fR { \fIstep\fR | \fIh\-step\fR\fB,\fR\fIv\-step\fR } +.RS 4 +Size of steps moving the grayfilter mask in each direction\&. (default: +\fB20,20\fR) +.RE +.PP +\fB\-gt\fR \fIratio\fR, \fB\-\-grayfilter\-threshold\fR \fIratio\fR +.RS 4 +Relative intensity of grayness which is accepted before clearing the grayfilter mask in cases where no black pixel is found in the mask\&. (default: +\fB0\&.5\fR) +.RE +.PP +\fB\-p\fR \fIx\fR\fB,\fR\fIy\fR, \fB\-\-mask\-scan\-point\fR \fIx\fR\fB,\fR\fIy\fR +.RS 4 +Manually set starting point for mask\-detection\&. Multiple +\fB\-\-mask\-scan\-point\fR +options may be specified to detect multiple masks\&. +.RE +.PP +\fB\-m\fR \fIx1\fR\fB,\fR\fIy1\fR\fB,\fR\fIx2\fR\fB,\fR\fIy2\fR, \fB\-\-mask\fR \fIx1\fR\fB,\fR\fIy1\fR\fB,\fR\fIx2\fR\fB,\fR\fIy2\fR +.RS 4 +Manually add a mask, in addition to masks automatically detected around the +\fB\-\-mask\-scan\-point\fR +coordinates (unless +\fB\-\-no\-mask\-scan\fR +is specified)\&. +.sp +Any pixel outside a mask will be set to white, unless another mask covers this pixel\&. +.RE +.PP +\fB\-mn\fR { \fBv\fR | \fBh\fR | \fBv,h\fR }, \fB\-\-mask\-scan\-direction\fR { \fBv\fR | \fBh\fR | \fBv,h\fR } +.RS 4 +Directions in which to search for mask borders, starting from \-\-mask\-scan\-point coordinates\&. Either +\fBv\fR +(for vertical mirroring), +\fBh\fR +(for horizontal mirroring) or +\fBv,h\fR +(for both) can be specified\&. (default: +\fBh\fR, as +\fBv\fR +may cut text\- paragraphs on single\-page sheets) +.RE +.PP +\fB\-ms\fR { \fIsize\fR | \fIh\-size\fR\fB,\fR\fIv\-size\fR }, \fB\-\-mask\-scan\-size\fR { \fIsize\fR | \fIh\-size\fR\fB,\fR\fIv\-size\fR } +.RS 4 +Width of the virtual bar used for mask detection\&. Two values may be specified to individually set horizontal and vertical size\&. (default: +\fB50,50\fR) +.RE +.PP +\fB\-md\fR { \fIdepth\fR | \fIh\-depth\fR\fB,\fR\fIv\-depth\fR }, \fB\-\-mask\-scan\-depth\fR { \fIdepth\fR | \fIh\-depth\fR\fB,\fR\fIv\-depth\fR } +.RS 4 +Height of the virtual bar used for mask detection\&. (default: +\fB\-1,\-1\fR, using the total width or height of the sheet) +.RE +.PP +\fB\-mp\fR { \fIstep\fR | \fIh\-step\fR\fB,\fR\fIv\-step\fR }, \fB\-\-mask\-scan\-step\fR { \fIstep\fR | \fIh\-step\fR\fB,\fR\fIv\-step\fR } +.RS 4 +Steps to move the virtual bar for mask detection\&. (default: +\fB5,5\fR) +.RE +.PP +\fB\-mt\fR { \fIthreshold\fR | \fIh\-threshold\fR\fB,\fR\fIv\-threshold\fR }, \fB\-\-mask\-scan\-threshold\fR { \fIthreshold\fR | \fIh\-threshold\fR\fB,\fR\fIv\-threshold\fR } +.RS 4 +Ratio of dark pixels below which an edge gets detected, relative to maximum blackness when counting from the start coordinate heading towards one edge\&. (default: +\fB0\&.1\fR) +.RE +.PP +\fB\-mm\fR \fIw\fR\fB,\fR\fIh\fR, \fB\-\-mask\-scan\-minimum\fR \fIw\fR\fB,\fR\fIh\fR +.RS 4 +Minimum allowed size of an auto\-detected mask\&. Masks detected below this size will be ignored and set to the size specified by mask\-scan\-maximum\&. (default: +\fB100,100\fR) +.RE +.PP +\fB\-mM\fR \fIw\fR\fB,\fR\fIh\fR, \fB\-\-mask\-scan\-maximum\fR \fIw\fR\fB,\fR\fIh\fR +.RS 4 +Maximum allowed size of an auto\-detected mask\&. Masks detected above this size will be shrunk to the maximum value, each direction individually\&. (default: sheet size, or page size derived from +\fB\-\-layout\fR +option) +.RE +.PP +\fB\-mc\fR \fIcolor\fR, \fB\-\-mask\-color\fR \fIcolor\fR +.RS 4 +Color value with which to wipe out pixels not covered by any mask\&. Maybe useful for testing in order to visualize the effect of masking\&. (Note that an RGB\-value is expected: R*65536 + G*256 + B\&.) +.RE +.PP +\fB\-dn\fR { \fBleft\fR | \fBtop\fR | \fBright\fR | \fBbottom\fR }\fB,\fR\&.\&.\&., \fB\-\-deskew\-scan\-direction\fR { \fBleft\fR | \fBtop\fR | \fBright\fR | \fBbottom\fR }\fB,\fR\&.\&.\&. +.RS 4 +Edges from which to scan for rotation\&. Each edge of a mask can be used to detect the mask\*(Aqs rotation\&. If multiple edges are specified, the average value will be used, unless the statistical deviation exceeds +\fB\-\-deskew\-scan\-deviation\fR\&. Use +\fBleft\fR +for scanning from the left edge, +\fBtop\fR +for scanning from the top edge, +\fBright\fR +for scanning from the right edge, +\fBbottom\fR +for scanning from the bottom\&. Multiple directions can be separated by commas\&. (default: +\fBleft,right\fR) +.RE +.PP +\fB\-ds\fR \fIpixels\fR, \fB\-\-deskew\-scan\-size\fR \fIpixels\fR +.RS 4 +Size of virtual line for rotation detection\&. (default: +\fB1500\fR) +.RE +.PP +\fB\-dd\fR \fIratio\fR, \fB\-\-deskew\-scan\-depth\fR \fIratio\fR +.RS 4 +Amount of dark pixels to accumulate until scanning is stopped, relative to scan\-bar size\&. (default: +\fB0\&.5\fR) +.RE +.PP +\fB\-dr\fR \fIdegrees\fR, \fB\-\-deskew\-scan\-range\fR \fIdegrees\fR +.RS 4 +Range in which to search for rotation, from \-\fIdegrees\fR +to +\fIdegrees\fR +rotation\&. (default: +\fB5\&.0\fR) +.RE +.PP +\fB\-dp\fR \fIdegrees\fR, \fB\-\-deskew\-scan\-step\fR \fIdegrees\fR +.RS 4 +Steps between single rotation\-angle detections\&. Lower numbers lead to better results but slow down processing\&. (default: +\fB0\&.1\fR) +.RE +.PP +\fB\-dv\fR \fIdeviation\fR, \fB\-\-deskew\-scan\-deviation\fR \fIdeviation\fR +.RS 4 +Maximum statistical deviation allowed among the results from detected edges\&. No rotation if exceeded\&. (default: +\fB1\&.0\fR) +.RE +.PP +\fB\-W\fR \fIleft\fR\fB,\fR\fItop\fR\fB,\fR\fIright\fR\fB,\fR\fIbottom\fR, \fB\-\-wipe\fR \fIleft\fR\fB,\fR\fItop\fR\fB,\fR\fIright\fR\fB,\fR\fIbottom\fR +.RS 4 +Manually wipe out an area\&. Any pixel in a wiped area will be set to white\&. Multiple +\fB\-\-wipe\fR +areas may be specified\&. This is applied after deskewing and before automatic border\-scan\&. +.RE +.PP +\fB\-mw\fR { \fIsize\fR | \fIleft\fR\fB,\fR\fIright\fR }, \fB\-\-middle\-wipe\fR { \fIsize\fR | \fIleft\fR\fB,\fR\fIright\fR } +.RS 4 +If +\fB\-\-layout\fR +is set to +\fBdouble\fR, this may specify the size of a middle area to wipe out between the two pages on the sheet\&. This may be useful if the blackfilter fails to remove some black areas (e\&.g\&. resulting from photo\-copying in the middle between two pages)\&. +.RE +.PP +\fB\-B\fR \fIleft\fR\fB,\fR\fItop\fR\fB,\fR\fIright\fR\fB,\fR\fIbottom\fR, \fB\-\-border\fR \fIleft\fR\fB,\fR\fItop\fR\fB,\fR\fIright\fR\fB,\fR\fIbottom\fR +.RS 4 +Manually add a border\&. Any pixel in the border area will be set to white\&. This is applied after deskewing and before automatic border\-scan\&. +.RE +.PP +\fB\-Bn\fR { \fBv\fR | \fBh\fR | \fBv,h\fR }, \fB\-\-border\-scan\-direction\fR { \fBv\fR | \fBh\fR | \fBv,h\fR } +.RS 4 +Directions in which to search for outer border\&. Either +\fBv\fR +(for vertical mirroring), +\fBh\fR +(for horizontal mirroring) or +\fBv,h\fR +(for both) can be specified\&. (default: +\fBv\fR) +.RE +.PP +\fB\-Bs\fR { \fIsize\fR | \fIh\-size\fR\fB,\fR\fIv\-size\fR }, \fB\-\-border\-scan\-size\fR { \fIsize\fR | \fIh\-size\fR\fB,\fR\fIv\-size\fR } +.RS 4 +Width of virtual bar used for border detection\&. Two values may be specified to individually set horizontal and vertical size\&. (default: +\fB5,5\fR) +.RE +.PP +\fB\-Bp\fR { \fIstep\fR | \fIh\-step\fR\fB,\fR\fIv\-step\fR }, \fB\-\-border\-scan\-step\fR { \fIstep\fR | \fIh\-step\fR\fB,\fR\fIv\-step\fR } +.RS 4 +Steps to move virtual bar for border detection\&. (default: +\fB5,5\fR) +.RE +.PP +\fB\-Bt\fR \fIthreshold\fR, \fB\-\-border\-scan\-threshold\fR \fIthreshold\fR +.RS 4 +Absolute number of dark pixels covered by the border\-scan mask above which a border is detected\&. (default: +\fB5\fR) +.RE +.PP +\fB\-Ba\fR { \fBleft\fR | \fBtop\fR | \fBright\fR | \fBbottom\fR }, \fB\-\-border\-align\fR { \fBleft\fR | \fBtop\fR | \fBright\fR | \fBbottom\fR } +.RS 4 +Direction where to shift the detected border\-area\&. Use +\fB\-\-border\-margin\fR +to specify horizontal and vertical distances to be kept from the sheet\-edge\&. (default: +\fBnone\fR) +.RE +.PP +\fB\-Bm\fR \fIvertical\fR\fB,\fR\fIhorizontal\fR, \fB\-\-border\-margin\fR \fIvertical\fR\fB,\fR\fIhorizontal\fR +.RS 4 +Distance to keep from the sheet edge when aligning a border area\&. May use measurement suffices such as cm, in\&. +.RE +.PP +\fB\-w\fR \fIthreshold\fR, \fB\-\-white\-threshold\fR \fIthreshold\fR +.RS 4 +Brightness ratio above which a pixel is considered white\&. (default: +\fB0\&.9\fR) +.RE +.PP +\fB\-b\fR \fIthreshold\fR, \fB\-\-black\-threshold\fR \fIthreshold\fR +.RS 4 +Brightness ratio below which a pixel is considered black (non\-gray)\&. This is used by the gray\-filter\&. This value is also used when converting a grayscale image to black\-and\-white mode (default: +\fB0\&.33\fR) +.RE +.PP +\fB\-ip\fR { \fB1\fR | \fB2\fR }, \fB\-\-input\-pages\fR { \fB1\fR | \fB2\fR } +.RS 4 +If +\fB2\fR +is specified, read two input images instead of one and internally combine them to a doubled\-layout sheet before further processing\&. Before internally combining, +\fB\-\-pre\-rotation\fR +is optionally applied individually to both input images as the very first processing steps\&. +.RE +.PP +\fB\-op\fR { \fB1\fR | \fB2\fR }, \fB\-\-output\-pages\fR { \fB1\fR | \fB2\fR } +.RS 4 +If +\fB2\fR +is specified, write two output images instead of one, as a result of splitting a doubled\-layout sheet after processing\&. After splitting the sheet, +\fB\-\-post\-rotation\fR +is optionally applied individually to both output images as the very last processing step\&. +.RE +.PP +\fB\-S\fR { \fIwidth\fR\fB,\fR\fIheight\fR | \fIsize\-name\fR }, \fB\-\-sheet\-size\fR { \fIwidth\fR\fB,\fR\fIheight\fR | \fIsize\-name\fR } +.RS 4 +Force a fix sheet size\&. Usually, the sheet size is determined by the input image size (if +\fBinput\-pages=1\fR), or by the double size of the first page in a two\-page input set (if +\fBinput\-pages=2\fR)\&. If the input image is smaller than the size specified here, it will appear centered and surrounded with a white border on the sheet\&. If the input image is bigger, it will be centered and the edges will be cropped\&. This option may also be helpful to get regular sized output images if the input image sizes differ\&. Standard size\-names like +\fBa4\-landscape\fR, +\fBletter\fR, etc\&. may be used (see +\fB\-\-size\fR)\&. (default: as in input file) +.RE +.PP +\fB\-\-sheet\-background\fR { \fBblack\fR | \fBwhite\fR } +.RS 4 +Sets a color with which the sheet is filled before any image is loaded and placed onto it\&. This can be useful when the sheet size and the image size differ\&. +.RE +.PP +\fB\-\-no\-blackfilter\fR \fIsheet\-range\fR +.RS 4 +Disables black area scan\&. Individual sheet indices can be specified\&. +.RE +.PP +\fB\-\-no\-noisefilter\fR \fIsheet\-range\fR +.RS 4 +Disables the noisefilter\&. Individual sheet indices can be specified\&. +.RE +.PP +\fB\-\-no\-blurfilter\fR \fIsheet\-range\fR +.RS 4 +Disables the blurfilter\&. Individual sheet indices can be specified\&. +.RE +.PP +\fB\-\-no\-grayfilter\fR \fIsheet\-range\fR +.RS 4 +Disables the grayfilter\&. Individual sheet indices can be specified\&. +.RE +.PP +\fB\-\-no\-mask\-scan\fR \fIsheet\-range\fR +.RS 4 +Disables mask\-detection\&. Masks explicitly set by +\fB\-\-mask\fR +will still have effect\&. Individual sheet indices can be specified\&. +.RE +.PP +\fB\-\-no\-mask\-center\fR \fIsheet\-range\fR +.RS 4 +Disables auto\-centering of each mask\&. Auto\-centering is performed by default if the +\fB\-\-layout\fR +option has been set\&. Individual sheet indices can be specified\&. +.RE +.PP +\fB\-\-no\-deskew\fR \fIsheet\-range\fR +.RS 4 +Disables deskewing\&. Individual sheet indices can be specified\&. +.RE +.PP +\fB\-\-no\-wipe\fR \fIsheet\-range\fR +.RS 4 +Disables explicit wipe\-areas\&. This means the effect of parameter +\fB\-\-wipe\fR +can be disabled individually per sheet\&. +.RE +.PP +\fB\-\-no\-border\fR \fIsheet\-range\fR +.RS 4 +Disables explicitly set borders\&. This means the effect of parameter +\fB\-\-border\fR +can be disabled individually per sheet\&. +.RE +.PP +\fB\-\-no\-border\-scan\fR \fIsheet\-range\fR +.RS 4 +Disables border\-scanning from the edges of the sheet\&. Individual sheet indices can be specified\&. +.RE +.PP +\fB\-\-no\-border\-align\fR \fIsheet\-range\fR +.RS 4 +Disables aligning of the area detected by border\-scanning (see +\fB\-\-border\-align\fR)\&. Individual sheet indices can be specified\&. +.RE +.PP +\fB\-n\fR \fIsheet\-range\fR, \fB\-\-no\-processing\fR \fIsheet\-range\fR +.RS 4 +Do not perform any processing on a sheet except pre/post rotating and mirroring, and file\-depth conversions on saving\&. This option has the same effect as setting all +\fB\-\-no\-xxx\fR +options together\&. Individual sheet indices can be specified\&. +.RE +.PP +\fB\-\-no\-qpixels\fR +.RS 4 +Disable qpixel\-mode for deskewing (do not internally use a 4x bigger image when rotating)\&. +.RE +.PP +\fB\-\-no\-multi\-pages\fR +.RS 4 +Disable multi\-page processing even if the input filename contains a +% +(usually indicating the start of a placeholder for the page counter)\&. +.RE +.PP +\fB\-\-dpi\fR \fIdpi\fR +.RS 4 +Dots per inch used for conversion of measured size values, like e\&.g\&. +\fB21cm,27\&.9cm\fR\&. Mind that this parameter should occur before specifying any size value with measurement suffix\&. (default: +\fB300\fR) +.RE +.PP +\fB\-t\fR { \fBpbm\fR | \fBpgm\fR }, \fB\-\-type\fR { \fBpbm\fR | \fBpgm\fR } +.RS 4 +Output file type\&. (default: as input) +.RE +.PP +\fB\-d\fR \fIbits\fR, \fB\-\-depth\fR \fIbits\fR +.RS 4 +Output pixel depth\&. (default: as input) +.RE +.PP +\fB\-T\fR, \fB\-\-test\-only\fR +.RS 4 +Do not write any output\&. May be useful in combination with +\fB\-\-verbose\fR +to get information about the input\&. +.RE +.PP +\fB\-si\fR \fInr\fR, \fB\-\-start\-input\fR \fInr\fR +.RS 4 +Set the first page number to substitute for \*(Aq%d\*(Aq in input filenames\&. Every time the input file sequence is repeated, this number gets increased by 1\&. (default: (startsheet\-1)*inputpages+1) +.RE +.PP +\fB\-so\fR \fInr\fR, \fB\-\-start\-output\fR \fInr\fR +.RS 4 +Set the first page number to substitute for \*(Aq%d\*(Aq in output filenames\&. Every time the output file sequence is repeated, this number gets increased by 1\&. (default: (startsheet\-1)*outputpages+1) +.RE +.PP +\fB\-\-insert\-blank\fR \fInr\fR [\fB,\fR\fInr\fR\&.\&.\&.] +.RS 4 +Use blank input instead of an input file from the input file sequence at the specified index\-positions\&. The input file sequence will be interrupted temporarily and will continue with the next input file afterwards\&. This can be useful to insert blank content into a sequence of input images\&. +.RE +.PP +\fB\-\-replace\-blank\fR \fInr\fR [\fB,\fR\fInr\fR\&.\&.\&.] +.RS 4 +Like +\fB\-\-insert\-blank\fR, but the input images at the specified index positions get replaced with blank content and thus will be ignored\&. +.RE +.PP +\fB\-\-overwrite\fR +.RS 4 +Allow overwriting existing files\&. Otherwise the program terminates with an error if an output file to be written already exists\&. +.RE +.PP +\fB\-q\fR, \fB\-\-quiet\fR +.RS 4 +Quiet mode, no output at all\&. +.RE +.PP +\fB\-v\fR, \fB\-\-verbose\fR +.RS 4 +Verbose output, more info messages\&. +.RE +.PP +\fB\-vv\fR +.RS 4 +Even more verbose output, show parameter settings before processing\&. +.RE +.PP +\fB\-\-time\fR +.RS 4 +Output processing time consumed\&. +.RE +.PP +\fB\-V\fR, \fB\-\-version\fR +.RS 4 +Output version and build information\&. +.RE +.SH "COPYRIGHT" +.br diff -Nru unpaper-0.3/unpaper.c unpaper-0.4.2/unpaper.c --- unpaper-0.3/unpaper.c 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/unpaper.c 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,2203 @@ +/* + * This file is part of Unpaper. + * + * Copyright © 2005-2007 Jens Gulden + * Copyright © 2011-2011 Diego Elio Pettenò + * + * Unpaper 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, version 2 of the License. + * + * Unpaper 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 . + */ + +/* --- The main program -------------------------------------------------- */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "unpaper.h" +#include "imageprocess.h" +#include "tools.h" +#include "file.h" +#include "parse.h" + +#define WELCOME \ + "unpaper " VERSION " - written by Jens Gulden 2005-2007.\n" \ + "Licensed under the GNU General Public License, this comes with no warranty.\n" + +#define USAGE \ + WELCOME "\n" \ + "Usage: unpaper [options] \n\n" \ + "Filenames may contain a formatting placeholder starting with '%%' to insert a\n" \ + "page counter for multi-page processing. E.g.: 'scan%%03d.pbm' to process files\n" \ + "scan001.pbm, scan002.pbm, scan003.pbm etc.\n\n" \ + "See 'man unpaper' for options details" + +/* --- constants ---------------------------------------------------------- */ + +// file type names (see typedef FILETYPES) +static const char FILETYPE_NAMES[FILETYPES_COUNT][4] = { + "pbm", + "pgm", + "ppm" +}; + +/* --- global variable ---------------------------------------------------- */ + +VERBOSE_LEVEL verbose; + + +/** + * Print an error and exit process + */ +void errOutput(const char *fmt, ...) { + va_list vl; + + fprintf(stderr, "unpaper: error: "); + + va_start(vl, fmt); + vfprintf(stderr, fmt, vl); + va_end(vl); + + fprintf(stderr, "\nTry 'man unpaper' for more information.\n"); + + exit(1); +} + +/**************************************************************************** + * MAIN() * + ****************************************************************************/ + +/** + * The main program. + */ +int main(int argc, char* argv[]) { + + // --- parameter variables --- + int layout; + int startSheet; + int endSheet; + int startInput; + int startOutput; + int inputCount; + int outputCount; + int sheetSize[DIMENSIONS_COUNT]; + int sheetBackground; + int preRotate; + int postRotate; + int preMirror; + int postMirror; + int preShift[DIRECTIONS_COUNT]; + int postShift[DIRECTIONS_COUNT]; + int size[DIRECTIONS_COUNT]; + int postSize[DIRECTIONS_COUNT]; + int stretchSize[DIRECTIONS_COUNT]; + int postStretchSize[DIRECTIONS_COUNT]; + float zoomFactor; + float postZoomFactor; + int pointCount; + int point[MAX_POINTS][COORDINATES_COUNT]; + int maskCount; + int mask[MAX_MASKS][EDGES_COUNT]; + int wipeCount; + int wipe[MAX_MASKS][EDGES_COUNT]; + int middleWipe[2]; + int preWipeCount; + int preWipe[MAX_MASKS][EDGES_COUNT]; + int postWipeCount; + int postWipe[MAX_MASKS][EDGES_COUNT]; + int preBorder[EDGES_COUNT]; + int postBorder[EDGES_COUNT]; + int border[EDGES_COUNT]; + bool maskValid[MAX_MASKS]; + int preMaskCount; + int preMask[MAX_MASKS][EDGES_COUNT]; + int blackfilterScanDirections; + int blackfilterScanSize[DIRECTIONS_COUNT]; + int blackfilterScanDepth[DIRECTIONS_COUNT]; + int blackfilterScanStep[DIRECTIONS_COUNT]; + float blackfilterScanThreshold; + int blackfilterExcludeCount; + int blackfilterExclude[MAX_MASKS][EDGES_COUNT]; + int blackfilterIntensity; + int noisefilterIntensity; + int blurfilterScanSize[DIRECTIONS_COUNT]; + int blurfilterScanStep[DIRECTIONS_COUNT]; + float blurfilterIntensity; + int grayfilterScanSize[DIRECTIONS_COUNT]; + int grayfilterScanStep[DIRECTIONS_COUNT]; + float grayfilterThreshold; + int maskScanDirections; + int maskScanSize[DIRECTIONS_COUNT]; + int maskScanDepth[DIRECTIONS_COUNT]; + int maskScanStep[DIRECTIONS_COUNT]; + float maskScanThreshold[DIRECTIONS_COUNT]; + int maskScanMinimum[DIMENSIONS_COUNT]; + int maskScanMaximum[DIMENSIONS_COUNT]; + int maskColor; + int deskewScanEdges; + int deskewScanSize; + float deskewScanDepth; + float deskewScanRange; + float deskewScanStep; + float deskewScanDeviation; + int borderScanDirections; + int borderScanSize[DIRECTIONS_COUNT]; + int borderScanStep[DIRECTIONS_COUNT]; + int borderScanThreshold[DIRECTIONS_COUNT]; + int borderAlign; + int borderAlignMargin[DIRECTIONS_COUNT]; + int outsideBorderscanMask[MAX_PAGES][EDGES_COUNT]; // set by --layout + int outsideBorderscanMaskCount; + float whiteThreshold; + float blackThreshold; + bool writeoutput; + bool qpixels; + bool multisheets; + const char* outputTypeName; + int noBlackfilterMultiIndex[MAX_MULTI_INDEX]; + int noBlackfilterMultiIndexCount; + int noNoisefilterMultiIndex[MAX_MULTI_INDEX]; + int noNoisefilterMultiIndexCount; + int noBlurfilterMultiIndex[MAX_MULTI_INDEX]; + int noBlurfilterMultiIndexCount; + int noGrayfilterMultiIndex[MAX_MULTI_INDEX]; + int noGrayfilterMultiIndexCount; + int noMaskScanMultiIndex[MAX_MULTI_INDEX]; + int noMaskScanMultiIndexCount; + int noMaskCenterMultiIndex[MAX_MULTI_INDEX]; + int noMaskCenterMultiIndexCount; + int noDeskewMultiIndex[MAX_MULTI_INDEX]; + int noDeskewMultiIndexCount; + int noWipeMultiIndex[MAX_MULTI_INDEX]; + int noWipeMultiIndexCount; + int noBorderMultiIndex[MAX_MULTI_INDEX]; + int noBorderMultiIndexCount; + int noBorderScanMultiIndex[MAX_MULTI_INDEX]; + int noBorderScanMultiIndexCount; + int noBorderAlignMultiIndex[MAX_MULTI_INDEX]; + int noBorderAlignMultiIndexCount; + int sheetMultiIndex[MAX_MULTI_INDEX]; + int sheetMultiIndexCount; + int excludeMultiIndex[MAX_MULTI_INDEX]; + int excludeMultiIndexCount; + int ignoreMultiIndex[MAX_MULTI_INDEX]; + int ignoreMultiIndexCount; + int autoborder[MAX_MASKS][EDGES_COUNT]; + int autoborderMask[MAX_MASKS][EDGES_COUNT]; + int insertBlank[MAX_MULTI_INDEX]; + int insertBlankCount; + int replaceBlank[MAX_MULTI_INDEX]; + int replaceBlankCount; + bool overwrite; + bool showTime; + int dpi; + + // --- local variables --- + int x; + int y; + int w; + int h; + int left; + int top; + int right; + int bottom; + int j; + int previousWidth; + int previousHeight; + int previousBitdepth; + bool previousColor; + char s1[1023]; // buffers for result of implode() + char s2[1023]; + char debugFilename[100]; + struct IMAGE sheet; + struct IMAGE sheetBackup; + struct IMAGE originalSheet; + struct IMAGE qpixelSheet; + struct IMAGE page; + const char* layoutStr; + const char* inputTypeName; + const char* inputTypeNames[MAX_PAGES]; + int inputType; + int filterResult; + double rotation; + int q; + struct IMAGE rect; + struct IMAGE rectTarget; + int outputType; + int outputDepth; + int bd; + bool col; + int nr; + int inputNr; + int outputNr; + clock_t startTime; + clock_t endTime; + clock_t time; + unsigned long int totalTime; + int totalCount; + int option_index = 0; + + sheet.buffer = NULL; + page.buffer = NULL; + bd = 1; // default bitdepth if not resolvable (i.e. usually empty input, so bd=1 is good choice) + col = false; // default no color if not resolvable + + // explicitly un-initialize variables that are sometimes not used to avoid compiler warnings + qpixelSheet.buffer = NULL; // used optionally, deactivated by --no-qpixels + startTime = 0; // used optionally in debug mode -vv or with --time + endTime = 0; // used optionally in debug mode -vv or with --time + + + // ----------------------------------------------------------------------- + // --- process all sheets --- + // ----------------------------------------------------------------------- + + // count from start sheet to end sheet + startSheet = 1; // defaults, may be changed in first run of for-loop + endSheet = -1; + startInput = -1; + startOutput = -1; + totalTime = 0; + totalCount = 0; + previousWidth = previousHeight = previousBitdepth = -1; + previousColor = false; + + // --- default values --- + w = h = -1; + layout = LAYOUT_SINGLE; + layoutStr = "single"; + preRotate = 0; + postRotate = 0; + preMirror = 0; + postMirror = 0; + preShift[WIDTH] = preShift[HEIGHT] = 0; + postShift[WIDTH] = postShift[HEIGHT] = 0; + size[WIDTH] = size[HEIGHT] = -1; + postSize[WIDTH] = postSize[HEIGHT] = -1; + stretchSize[WIDTH] = stretchSize[HEIGHT] = -1; + postStretchSize[WIDTH] = postStretchSize[HEIGHT] = -1; + zoomFactor = 1.0; + postZoomFactor = 1.0; + outputTypeName = NULL; // default derived from input + outputDepth = -1; // default derived from input + pointCount = 0; + maskCount = 0; + preMaskCount = 0; + wipeCount = 0; + preWipeCount = 0; + postWipeCount = 0; + middleWipe[0] = middleWipe[1] = 0; // left/right + border[LEFT] = border[TOP] = border[RIGHT] = border[BOTTOM] = 0; + preBorder[LEFT] = preBorder[TOP] = preBorder[RIGHT] = preBorder[BOTTOM] = 0; + postBorder[LEFT] = postBorder[TOP] = postBorder[RIGHT] = postBorder[BOTTOM] = 0; + blackfilterScanDirections = (1< 0 && startSheet > sheetMultiIndex[0] ) + startSheet = sheetMultiIndex[0]; + } + break; + + case 0x7f: + sscanf(optarg,"%d", &startSheet); + break; + + case 0x7e: + sscanf(optarg,"%d", &endSheet); + break; + + case 0x80: + sscanf(optarg,"%d", &startInput); + break; + + case 0x81: + sscanf(optarg,"%d", &startOutput); + break; + + case 'S': + parseSize(optarg, sheetSize, dpi); + break; + + case 0x82: + sheetBackground = parseColor(optarg); + break; + + case 'x': + if ( optarg != NULL ) + parseMultiIndex(optarg, excludeMultiIndex, &excludeMultiIndexCount); + if (excludeMultiIndexCount == -1) + excludeMultiIndexCount = 0; // 'exclude all' makes no sense + break; + + case 'n': + if ( optarg == NULL ) + ignoreMultiIndexCount = -1; + else + parseMultiIndex(optarg, ignoreMultiIndex, &ignoreMultiIndexCount); + break; + + case 0x83: + sscanf(optarg, "%d", &preRotate); + if ((preRotate != 0) && (abs(preRotate) != 90)) { + fprintf(stderr, "cannot set --pre-rotate value other than -90 or 90, ignoring.\n"); + preRotate = 0; + } + break; + + case 0x84: + sscanf(optarg,"%d", &postRotate); + if ((postRotate != 0) && (abs(postRotate) != 90)) { + fprintf(stderr, "cannot set --post-rotate value other than -90 or 90, ignoring.\n"); + postRotate = 0; + } + break; + + case 'M': + preMirror = parseDirections(optarg); // s = "v", "v,h", "vertical,horizontal", ... + break; + + case 0x85: + postMirror = parseDirections(optarg); + break; + + case 0x86: + parseSize(optarg, preShift, dpi); + break; + + case 0x87: + parseSize(optarg, postShift, dpi); + break; + + case 0x88: + if ( preMaskCount < MAX_MASKS ) { + left = -1; + top = -1; + right = -1; + bottom = -1; + sscanf(optarg,"%d,%d,%d,%d", &left, &top, &right, &bottom); // x1, y1, x2, y2 + preMask[preMaskCount][LEFT] = left; + preMask[preMaskCount][TOP] = top; + preMask[preMaskCount][RIGHT] = right; + preMask[preMaskCount][BOTTOM] = bottom; + preMaskCount++; + } else { + fprintf(stderr, "maximum number of masks (%d) exceeded, ignoring mask %s\n", + MAX_MASKS, optarg); + } + break; + + case 's': + parseSize(optarg, size, dpi); + break; + + case 0x89: + parseSize(optarg, postSize, dpi); + break; + + case 0x8a: + parseSize(optarg, stretchSize, dpi); + break; + + case 0x8b: + parseSize(optarg, postStretchSize, dpi); + break; + + case 'z': + sscanf(optarg,"%f", &zoomFactor); + break; + + case 0x8c: + sscanf(optarg,"%f", &postZoomFactor); + break; + + case 'p': + if ( pointCount < MAX_POINTS ) { + x = -1; + y = -1; + sscanf(optarg,"%d,%d", &x, &y); + point[pointCount][X] = x; + point[pointCount][Y] = y; + pointCount++; + } else { + fprintf(stderr, "maximum number of scan points (%d) exceeded, ignoring scan point %s\n", + MAX_POINTS, optarg); + } + break; + + case 'm': + if ( maskCount < MAX_MASKS ) { + left = -1; + top = -1; + right = -1; + bottom = -1; + sscanf(optarg,"%d,%d,%d,%d", &left, &top, &right, &bottom); // x1, y1, x2, y2 + mask[maskCount][LEFT] = left; + mask[maskCount][TOP] = top; + mask[maskCount][RIGHT] = right; + mask[maskCount][BOTTOM] = bottom; + maskValid[maskCount] = true; + maskCount++; + } else { + fprintf(stderr, "maximum number of masks (%d) exceeded, ignoring mask %s\n", + MAX_MASKS, optarg); + } + break; + + case 'W': + if ( wipeCount < MAX_MASKS ) { + left = -1; + top = -1; + right = -1; + bottom = -1; + sscanf(optarg,"%d,%d,%d,%d", &left, &top, &right, &bottom); // x1, y1, x2, y2 + wipe[wipeCount][LEFT] = left; + wipe[wipeCount][TOP] = top; + wipe[wipeCount][RIGHT] = right; + wipe[wipeCount][BOTTOM] = bottom; + wipeCount++; + } else { + fprintf(stderr, "maximum number of wipes (%d) exceeded, ignoring mask %s\n", + MAX_MASKS, optarg); + } + break; + + case 0x8d: + if ( preWipeCount < MAX_MASKS ) { + left = -1; + top = -1; + right = -1; + bottom = -1; + sscanf(optarg,"%d,%d,%d,%d", &left, &top, &right, &bottom); // x1, y1, x2, y2 + preWipe[preWipeCount][LEFT] = left; + preWipe[preWipeCount][TOP] = top; + preWipe[preWipeCount][RIGHT] = right; + preWipe[preWipeCount][BOTTOM] = bottom; + preWipeCount++; + } else { + fprintf(stderr, "maximum number of pre-wipes (%d) exceeded, ignoring mask %s\n", + MAX_MASKS, optarg); + } + break; + + case 0x8e: + if ( postWipeCount < MAX_MASKS ) { + left = -1; + top = -1; + right = -1; + bottom = -1; + sscanf(optarg,"%d,%d,%d,%d", &left, &top, &right, &bottom); // x1, y1, x2, y2 + postWipe[postWipeCount][LEFT] = left; + postWipe[postWipeCount][TOP] = top; + postWipe[postWipeCount][RIGHT] = right; + postWipe[postWipeCount][BOTTOM] = bottom; + postWipeCount++; + } else { + fprintf(stderr, "maximum number of post-wipes (%d) exceeded, ignoring mask %s\n", + MAX_MASKS, optarg); + } + break; + + case 0x8f: + parseInts(optarg, middleWipe); + break; + + case 'B': + sscanf(optarg,"%d,%d,%d,%d", &border[LEFT], &border[TOP], &border[RIGHT], &border[BOTTOM]); + break; + + case 0x90: + sscanf(optarg,"%d,%d,%d,%d", &preBorder[LEFT], &preBorder[TOP], &preBorder[RIGHT], &preBorder[BOTTOM]); + break; + + case 0x91: + sscanf(optarg,"%d,%d,%d,%d", &postBorder[LEFT], &postBorder[TOP], &postBorder[RIGHT], &postBorder[BOTTOM]); + break; + + case 0x92: + if ( optarg == NULL ) + noBlackfilterMultiIndexCount = -1; + else + parseMultiIndex(optarg, noBlackfilterMultiIndex, &noBlackfilterMultiIndexCount); + break; + + case 0x93: + blackfilterScanDirections = parseDirections(optarg); + break; + + case 0x94: + parseInts(optarg, blackfilterScanSize); + break; + + case 0x95: + parseInts(optarg, blackfilterScanDepth); + break; + + case 0x96: + parseInts(optarg, blackfilterScanStep); + break; + + case 0x97: + sscanf(optarg, "%f", &blackfilterScanThreshold); + break; + + case 0x98: + if ( blackfilterExcludeCount < MAX_MASKS ) { + left = -1; + top = -1; + right = -1; + bottom = -1; + sscanf(optarg,"%d,%d,%d,%d", &left, &top, &right, &bottom); // x1, y1, x2, y2 + blackfilterExclude[blackfilterExcludeCount][LEFT] = left; + blackfilterExclude[blackfilterExcludeCount][TOP] = top; + blackfilterExclude[blackfilterExcludeCount][RIGHT] = right; + blackfilterExclude[blackfilterExcludeCount][BOTTOM] = bottom; + blackfilterExcludeCount++; + } else { + fprintf(stderr, "maximum number of blackfilter exclusion (%d) exceeded, ignoring mask %s\n", + MAX_MASKS, optarg); + } + break; + + case 0x99: + sscanf(optarg, "%d", &blackfilterIntensity); + break; + + case 0x9a: + if ( optarg == NULL ) + noNoisefilterMultiIndexCount = -1; + else + parseMultiIndex(optarg, noNoisefilterMultiIndex, &noNoisefilterMultiIndexCount); + break; + + case 0x9b: + sscanf(optarg, "%d", &noisefilterIntensity); + break; + + case 0x9c: + if ( optarg == NULL ) + noBlurfilterMultiIndexCount = -1; + else + parseMultiIndex(optarg, noBlurfilterMultiIndex, &noBlurfilterMultiIndexCount); + break; + + case 0x9d: + parseInts(optarg, blurfilterScanSize); + break; + + case 0x9e: + parseInts(optarg, blurfilterScanStep); + break; + + case 0x9f: + sscanf(optarg, "%f", &blurfilterIntensity); + break; + + case 0xa0: + if ( optarg == NULL ) + noGrayfilterMultiIndexCount = -1; + else + parseMultiIndex(optarg, noGrayfilterMultiIndex, &noGrayfilterMultiIndexCount); + break; + + case 0xa1: + parseInts(optarg, grayfilterScanSize); + break; + + case 0xa2: + parseInts(optarg, grayfilterScanStep); + break; + + case 0xa3: + sscanf(optarg, "%f", &grayfilterThreshold); + break; + + case 0xa4: + if ( optarg == NULL ) + noMaskScanMultiIndexCount = -1; + else + parseMultiIndex(optarg, noMaskScanMultiIndex, &noMaskScanMultiIndexCount); + break; + + case 0xa5: + maskScanDirections = parseDirections(optarg); + break; + + case 0xa6: + parseInts(optarg, maskScanSize); + break; + + case 0xa7: + parseInts(optarg, maskScanDepth); + break; + + case 0xa8: + parseInts(optarg, maskScanStep); + break; + + case 0xa9: + parseFloats(optarg, maskScanThreshold); + break; + + case 0xaa: + sscanf(optarg,"%d,%d", &maskScanMinimum[WIDTH], &maskScanMinimum[HEIGHT]); + break; + + case 0xab: + sscanf(optarg,"%d,%d", &maskScanMaximum[WIDTH], &maskScanMaximum[HEIGHT]); + break; + + case 0xac: + sscanf(optarg,"%d", &maskColor); + break; + + case 0xad: + if ( optarg == NULL ) + noMaskCenterMultiIndexCount = -1; + else + parseMultiIndex(optarg, noMaskCenterMultiIndex, &noMaskCenterMultiIndexCount); + break; + + case 0xae: + if ( optarg == NULL ) + noDeskewMultiIndexCount = -1; + else + parseMultiIndex(optarg, noDeskewMultiIndex, &noDeskewMultiIndexCount); + break; + + case 0xaf: + deskewScanEdges = parseEdges(optarg); + break; + + case 0xb0: + sscanf(optarg,"%d", &deskewScanSize); + break; + + case 0xb1: + sscanf(optarg,"%f", &deskewScanDepth); + break; + + case 0xb2: + sscanf(optarg,"%f", &deskewScanRange); + break; + + case 0xb3: + sscanf(optarg,"%f", &deskewScanStep); + break; + + case 0xb4: + sscanf(optarg,"%f", &deskewScanDeviation); + break; + + case 0xb5: + if ( optarg == NULL ) + noBorderScanMultiIndexCount = -1; + else + parseMultiIndex(optarg, noBorderScanMultiIndex, &noBorderScanMultiIndexCount); + break; + + case 0xb6: + borderScanDirections = parseDirections(optarg); + break; + + case 0xb7: + parseInts(optarg, borderScanSize); + break; + + case 0xb8: + parseInts(optarg, borderScanStep); + break; + + case 0xb9: + parseInts(optarg, borderScanThreshold); + break; + + case 0xba: + borderAlign = parseEdges(optarg); + break; + + case 0xbb: + parseSize(optarg, borderAlignMargin, dpi); + break; + + case 0xbc: + if ( optarg == NULL ) + noBorderAlignMultiIndexCount = -1; + else + parseMultiIndex(optarg, noBorderAlignMultiIndex, &noBorderAlignMultiIndexCount); + break; + + case 0xbd: + if ( optarg == NULL ) + noWipeMultiIndexCount = -1; + else + parseMultiIndex(optarg, noWipeMultiIndex, &noWipeMultiIndexCount); + break; + + case 0xbe: + if ( optarg == NULL ) + noBorderMultiIndexCount = -1; + else + parseMultiIndex(optarg, noBorderMultiIndex, &noBorderMultiIndexCount); + break; + + case 'w': + sscanf(optarg,"%f", &whiteThreshold); + break; + + case 'b': + sscanf(optarg,"%f", &blackThreshold); + break; + + case 0xbf: + sscanf(optarg,"%d", &inputCount); + if ( ! (inputCount >= 1 && inputCount <= 2 ) ) { + fprintf(stderr, "cannot set --input-pages value other than 1 or 2, ignoring.\n"); + inputCount = 1; + } + + break; + + case 0xc0: + sscanf(optarg,"%d", &outputCount); + if ( ! (outputCount >= 1 && outputCount <= 2 ) ) { + fprintf(stderr, "cannot set --output-pages value other than 1 or 2, ignoring.\n"); + outputCount = 1; + } + + break; + + case 0xc1: + case 0xc2: + errOutput("--input-file-sequence and --output-file sequence are deprecated and unimplemented.\n" + "Please pass input output pairs as arguments to unpaper instead."); + break; + + case 0xc3: + parseMultiIndex(optarg, insertBlank, &insertBlankCount); + break; + + case 0xc4: + parseMultiIndex(optarg, replaceBlank, &replaceBlankCount); + break; + + case 'T': + writeoutput = false; + break; + + case 0xc5: + qpixels = false; + break; + + case 0xc6: + multisheets = false; + break; + + case 0xc7: + sscanf(optarg,"%d", &dpi); + break; + + case 't': + outputTypeName = optarg; + break; + + case 'd': + sscanf(optarg, "%d", &outputDepth); + break; + + case 'q': + verbose = VERBOSE_QUIET; + break; + + case 0xc8: + overwrite = true; + break; + + case 0xc9: + showTime = true; + break; + + case 'v': + verbose = VERBOSE_NORMAL; + break; + + case 0xca: + verbose = VERBOSE_MORE; + break; + + case 0xcb: + verbose = VERBOSE_DEBUG; + break; + + case 0xcc: + verbose = VERBOSE_DEBUG_SAVE; + break; + } + } + + showTime |= (verbose >= VERBOSE_DEBUG); // always show processing time in verbose-debug mode + + /* make sure we have at least two arguments after the options, as + that's the minimum amount of paramenters we need (one input and + one output, or a wildcard of inputs and a wildcard of + outputs. + */ + if ( optind + 2 > argc ) + errOutput("no input or output files given.\n"); + + if ( verbose >= VERBOSE_NORMAL ) + printf(WELCOME); // welcome message + + if (startInput == -1) + startInput = (startSheet - 1) * inputCount + 1; + if (startOutput == -1) + startOutput = (startSheet - 1) * outputCount + 1; + + inputNr = startInput; + outputNr = startOutput; + + if ( ! multisheets && endSheet == -1) + endSheet = startSheet; + + for (nr = startSheet; (endSheet == -1) || (nr <= endSheet); nr++) { + int i; + char inputFilesBuffer[2][255]; + char outputFilesBuffer[2][255]; + char *inputFileNames[2]; + char *outputFileNames[2]; + FILE *inputFiles[2] = { NULL, NULL }; + FILE *outputFiles[2] = { NULL, NULL }; + + // ------------------------------------------------------------------- + // --- begin processing --- + // ------------------------------------------------------------------- + + bool inputWildcard = multisheets && (strchr(argv[optind], '%') != NULL); + for(i = 0; i < inputCount; i++) { + bool ins = isInMultiIndex(inputNr, insertBlank, insertBlankCount); + bool repl = isInMultiIndex(inputNr, replaceBlank, replaceBlankCount); + + if ( repl ) { + inputFileNames[i] = NULL; + inputFiles[i] = NULL; + inputNr++; /* replace */ + } else if ( ins ) { + inputFileNames[i] = NULL; /* insert */ + inputFiles[i] = NULL; + } else if ( inputWildcard ) { + sprintf(inputFilesBuffer[i], argv[optind], inputNr++); + inputFileNames[i] = inputFilesBuffer[i]; + } else if ( optind >= argc ) { + if ( endSheet == -1 ) { + endSheet = nr-1; + goto sheet_end; + } else { + errOutput("not enough input files given."); + } + } else { + inputFileNames[i] = argv[optind++]; + } + + if ( inputFileNames[i] != NULL ) + if ( (inputFiles[i] = fopen(inputFileNames[i], "rb")) == NULL ) { + if ( endSheet == -1 ) { + endSheet = nr-1; + goto sheet_end; + } else { + errOutput("unable to open file %s.", + inputFileNames[i]); + } + } + } + if ( inputWildcard ) + optind++; + + bool outputWildcard = multisheets && (strchr(argv[optind], '%') != NULL); + for(i = 0; i < outputCount; i++) { + if ( outputWildcard ) { + sprintf(outputFilesBuffer[i], argv[optind], outputNr++); + outputFileNames[i] = outputFilesBuffer[i]; + } else if ( optind >= argc ) { + errOutput("not enough output files given."); + return -1; + } else { + outputFileNames[i] = argv[optind++]; + } + + if ( ! overwrite ) { + struct stat statbuf; + if ( stat(outputFileNames[i], &statbuf) == 0 ) { + errOutput("output file '%s' already present.\n", + outputFileNames[i]); + } + } + + if ( (outputFiles[i] = fopen(outputFileNames[i], "w")) == NULL ) { + errOutput("unable to open output file %s.\n", + outputFileNames[i]); + } + } + if ( outputWildcard ) + optind++; + + // --------------------------------------------------------------- + // --- process single sheet --- + // --------------------------------------------------------------- + + if (isInMultiIndex(nr, sheetMultiIndex, sheetMultiIndexCount) && (!isInMultiIndex(nr, excludeMultiIndex, excludeMultiIndexCount))) { + + if (verbose >= VERBOSE_NORMAL) { + printf("\n-------------------------------------------------------------------------------\n"); + } + if (verbose > VERBOSE_QUIET) { + if (multisheets) { + printf("Processing sheet #%d: %s -> %s\n", nr, implode(s1, (const char **)inputFileNames, inputCount), implode(s2, (const char **)outputFileNames, outputCount)); + } else { + printf("Processing sheet: %s -> %s\n", implode(s1, (const char **)inputFileNames, inputCount), implode(s2, (const char **)outputFileNames, outputCount)); + } + } + + // load input image(s) + for ( j = 0; j < inputCount; j++) { + if (inputFiles[j] != NULL) { // may be null if --insert-blank or --replace-blank + if (verbose >= VERBOSE_MORE) + printf("loading file %s.\n", inputFileNames[j]); + + loadImage(inputFiles[j], &page, &inputType); + inputTypeName = FILETYPE_NAMES[inputType]; + inputTypeNames[j] = inputTypeName; + sprintf(debugFilename, "_loaded_%d.pnm", inputNr-inputCount+j); + saveDebug(debugFilename, &page); + + // pre-rotate + if (preRotate != 0) { + if (verbose>=VERBOSE_NORMAL) { + printf("pre-rotating %d degrees.\n", preRotate); + } + if (preRotate == 90) { + flipRotate(1, &page); + } else if (preRotate == -90) { + flipRotate(-1, &page); + } + } + + // if sheet-size is not known yet (and not forced by --sheet-size), set now based on size of (first) input image + if ( w == -1 ) { + if ( sheetSize[WIDTH] != -1 ) { + w = sheetSize[WIDTH]; + } else { + w = page.width * inputCount; + } + } + if ( h == -1 ) { + if ( sheetSize[HEIGHT] != -1 ) { + h = sheetSize[HEIGHT]; + } else { + h = page.height; + } + } + } else { // inputFiles[j] == NULL + page.buffer = NULL; + inputTypeNames[j] = ""; + } + + // place image into sheet buffer + if ( (inputCount == 1) && (page.buffer != NULL) && (page.width == w) && (page.height == h) ) { // quick case: single input file == whole sheet + sheet.buffer = page.buffer; + sheet.bufferGrayscale = page.bufferGrayscale; + sheet.bufferLightness = page.bufferLightness; + sheet.bufferDarknessInverse = page.bufferDarknessInverse; + sheet.width = page.width; + sheet.height = page.height; + sheet.bitdepth = page.bitdepth; + sheet.color = page.color; + sheet.background = sheetBackground; + } else { // generic case: place image onto sheet by copying + // allocate sheet-buffer if not done yet + if ((sheet.buffer == NULL) && (w != -1) && (h != -1)) { + if ((page.buffer != NULL) && (page.bitdepth != 0)) { + bd = page.bitdepth; + col = page.color; + } else { + if (outputDepth != -1) { // set via --depth + bd = outputDepth; + } else { + // bd remains default + } + } + initImage(&sheet, w, h, bd, col, sheetBackground); + + } else if ((page.buffer != NULL) && ((page.bitdepth > sheet.bitdepth) || ( (!sheet.color) && page.color ))) { // make sure current sheet buffer has enough bitdepth and color-mode + sheetBackup = sheet; + // re-allocate sheet + bd = page.bitdepth; + col = page.color; + initImage(&sheet, w, h, bd, col, sheetBackground); + // copy old one + copyImage(&sheetBackup, 0, 0, &sheet); + freeImage(&sheetBackup); + } + if (page.buffer != NULL) { + if (verbose >= VERBOSE_DEBUG_SAVE) { + sprintf(debugFilename, "_page%d.pnm", inputNr-inputCount+j); + saveDebug(debugFilename, &page); + sprintf(debugFilename, "_before_center_page%d.pnm", inputNr-inputCount+j); + saveDebug(debugFilename, &sheet); + } + + centerImage(&page, (w * j / inputCount), 0, (w / inputCount), h, &sheet); + + if (verbose >= VERBOSE_DEBUG_SAVE) { + sprintf(debugFilename, "_after_center_page%d.pnm", inputNr-inputCount+j); + saveDebug(debugFilename, &sheet); + } + freeImage(&page); + } + } + } + + // the only case that buffer is not yet initialized is if all blank pages have been inserted + if (sheet.buffer == NULL) { + // last chance: try to get previous (unstretched/not zoomed) sheet size + w = previousWidth; + h = previousHeight; + bd = previousBitdepth; + col = previousColor; + if (verbose >= VERBOSE_NORMAL) { + printf("need to guess sheet size from previous sheet: %dx%d\n", w, h); + } + if ((w == -1) || (h == -1)) { + errOutput("sheet size unknown, use at least one input file per sheet, or force using --sheet-size."); + } else { + initImage(&sheet, w, h, bd, col, sheetBackground); + } + } + + previousWidth = w; + previousHeight = h; + previousBitdepth = bd; + previousColor = col; + // handle file types + if (outputTypeName == NULL) { // auto-set output type according to sheet format, if not explicitly set by user + if (sheet.color) { + outputType = PPM; + } else { + if (sheet.bitdepth == 1) { + outputType = PBM; + } else { + outputType = PGM; + } + } + outputTypeName = FILETYPE_NAMES[outputType]; + } else { // parse user-setting + int i; + outputType = -1; + for (i = 0; (outputType == -1) && (i < FILETYPES_COUNT); i++) { + if (strcmp(outputTypeName, FILETYPE_NAMES[i])==0) { + outputType = i; + } + } + if (outputType == -1) + errOutput("output file format '%s' is not known.", outputTypeName); + } + if (outputDepth == -1) { // set output depth to be as input depth, if not explicitly set by user + outputDepth = sheet.bitdepth; + } + + if (showTime) { + startTime = clock(); + } + + // pre-mirroring + if (preMirror != 0) { + if (verbose >= VERBOSE_NORMAL) { + printf("pre-mirroring "); + printDirections(preMirror); + } + mirror(preMirror, &sheet); + } + + // pre-shifting + if ((preShift[WIDTH] != 0) || ((preShift[HEIGHT] != 0))) { + if (verbose >= VERBOSE_NORMAL) { + printf("pre-shifting [%d,%d]\n", preShift[WIDTH], preShift[HEIGHT]); + } + shift(preShift[WIDTH], preShift[HEIGHT], &sheet); + } + + // pre-masking + if (preMaskCount > 0) { + if (verbose >= VERBOSE_NORMAL) { + printf("pre-masking\n "); + } + applyMasks(preMask, preMaskCount, maskColor, &sheet); + } + + + // -------------------------------------------------------------- + // --- verbose parameter output, --- + // -------------------------------------------------------------- + + // parameters and size are known now + + if (verbose >= VERBOSE_MORE) { + if (layout != LAYOUT_NONE) { + if (layout == LAYOUT_SINGLE) { + layoutStr = "single"; + } else if (layout == LAYOUT_DOUBLE) { + layoutStr = "double"; + } + printf("layout: %s\n", layoutStr); + } + + if (preRotate != 0) { + printf("pre-rotate: %d\n", preRotate); + } + if (preMirror != 0) { + printf("pre-mirror: "); + printDirections(preMirror); + } + if ((preShift[WIDTH] != 0) || ((preShift[HEIGHT] != 0))) { + printf("pre-shift: "); + printInts(preShift); + } + if (preWipeCount > 0) { + int i; + + printf("pre-wipe: "); + for (i = 0; i < preWipeCount; i++) { + printf("[%d,%d,%d,%d] ",preWipe[i][LEFT],preWipe[i][TOP],preWipe[i][RIGHT],preWipe[i][BOTTOM]); + } + printf("\n"); + } + if (preBorder[LEFT]!=0 || preBorder[TOP]!=0 || preBorder[RIGHT]!=0 || preBorder[BOTTOM]!=0) { + printf("pre-border: [%d,%d,%d,%d]\n", preBorder[LEFT], preBorder[TOP], preBorder[RIGHT], preBorder[BOTTOM]); + } + if (preMaskCount > 0) { + int i; + + printf("pre-masking: "); + for (i = 0; i < preMaskCount; i++) { + printf("[%d,%d,%d,%d] ",preMask[i][LEFT],preMask[i][TOP],preMask[i][RIGHT],preMask[i][BOTTOM]); + } + printf("\n"); + } + if ((stretchSize[WIDTH] != -1) || (stretchSize[HEIGHT] != -1)) { + printf("stretch to: %dx%d\n", stretchSize[WIDTH], stretchSize[HEIGHT]); + } + if ((postStretchSize[WIDTH] != -1) || (postStretchSize[HEIGHT] != -1)) { + printf("post-stretch to: %dx%d\n", postStretchSize[WIDTH], postStretchSize[HEIGHT]); + } + if (zoomFactor != 1.0) { + printf("zoom: %f\n", zoomFactor); + } + if (postZoomFactor != 1.0) { + printf("post-zoom: %f\n", postZoomFactor); + } + if (noBlackfilterMultiIndexCount != -1) { + printf("blackfilter-scan-direction: "); + printDirections(blackfilterScanDirections); + printf("blackfilter-scan-size: "); + printInts(blackfilterScanSize); + printf("blackfilter-scan-depth: "); + printInts(blackfilterScanDepth); + printf("blackfilter-scan-step: "); + printInts(blackfilterScanStep); + printf("blackfilter-scan-threshold: %f\n", blackfilterScanThreshold); + if (blackfilterExcludeCount > 0) { + int i; + + printf("blackfilter-scan-exclude: "); + for (i = 0; i < blackfilterExcludeCount; i++) { + printf("[%d,%d,%d,%d] ",blackfilterExclude[i][LEFT],blackfilterExclude[i][TOP],blackfilterExclude[i][RIGHT],blackfilterExclude[i][BOTTOM]); + } + printf("\n"); + } + printf("blackfilter-intensity: %d\n", blackfilterIntensity); + if (noBlackfilterMultiIndexCount > 0) { + printf("blackfilter DISABLED for sheets: "); + printMultiIndex(noBlackfilterMultiIndex, noBlackfilterMultiIndexCount); + } + } else { + printf("blackfilter DISABLED for all sheets.\n"); + } + if (noNoisefilterMultiIndexCount != -1) { + printf("noisefilter-intensity: %d\n", noisefilterIntensity); + if (noNoisefilterMultiIndexCount > 0) { + printf("noisefilter DISABLED for sheets: "); + printMultiIndex(noNoisefilterMultiIndex, noNoisefilterMultiIndexCount); + } + } else { + printf("noisefilter DISABLED for all sheets.\n"); + } + if (noBlurfilterMultiIndexCount != -1) { + printf("blurfilter-size: "); + printInts(blurfilterScanSize); + printf("blurfilter-step: "); + printInts(blurfilterScanStep); + printf("blurfilter-intensity: %f\n", blurfilterIntensity); + if (noBlurfilterMultiIndexCount > 0) { + printf("blurfilter DISABLED for sheets: "); + printMultiIndex(noBlurfilterMultiIndex, noBlurfilterMultiIndexCount); + } + } else { + printf("blurfilter DISABLED for all sheets.\n"); + } + if (noGrayfilterMultiIndexCount != -1) { + printf("grayfilter-size: "); + printInts(grayfilterScanSize); + printf("grayfilter-step: "); + printInts(grayfilterScanStep); + printf("grayfilter-threshold: %f\n", grayfilterThreshold); + if (noGrayfilterMultiIndexCount > 0) { + printf("grayfilter DISABLED for sheets: "); + printMultiIndex(noGrayfilterMultiIndex, noGrayfilterMultiIndexCount); + } + } else { + printf("grayfilter DISABLED for all sheets.\n"); + } + if (noMaskScanMultiIndexCount != -1) { + int i; + + printf("mask points: "); + for (i = 0; i < pointCount; i++) { + printf("(%d,%d) ",point[i][X],point[i][Y]); + } + printf("\n"); + printf("mask-scan-direction: "); + printDirections(maskScanDirections); + printf("mask-scan-size: "); + printInts(maskScanSize); + printf("mask-scan-depth: "); + printInts(maskScanDepth); + printf("mask-scan-step: "); + printInts(maskScanStep); + printf("mask-scan-threshold: ");//%f\n", maskScanThreshold); + printFloats(maskScanThreshold); + printf("mask-scan-minimum: [%d,%d]\n", maskScanMinimum[WIDTH], maskScanMinimum[HEIGHT]); + printf("mask-scan-maximum: [%d,%d]\n", maskScanMaximum[WIDTH], maskScanMaximum[HEIGHT]); + printf("mask-color: %d\n", maskColor); + if (noMaskScanMultiIndexCount > 0) { + printf("mask-scan DISABLED for sheets: "); + printMultiIndex(noMaskScanMultiIndex, noMaskScanMultiIndexCount); + } + } else { + printf("mask-scan DISABLED for all sheets.\n"); + } + if (noDeskewMultiIndexCount != -1) { + printf("deskew-scan-direction: "); + printEdges(deskewScanEdges); + printf("deskew-scan-size: %d\n", deskewScanSize); + printf("deskew-scan-depth: %f\n", deskewScanDepth); + printf("deskew-scan-range: %f\n", deskewScanRange); + printf("deskew-scan-step: %f\n", deskewScanStep); + printf("deskew-scan-deviation: %f\n", deskewScanDeviation); + if (qpixels==false) { + printf("qpixel-coding DISABLED.\n"); + } + if (noDeskewMultiIndexCount > 0) { + printf("deskew-scan DISABLED for sheets: "); + printMultiIndex(noDeskewMultiIndex, noDeskewMultiIndexCount); + } + } else { + printf("deskew-scan DISABLED for all sheets.\n"); + } + if (noWipeMultiIndexCount != -1) { + if (wipeCount > 0) { + int i; + printf("wipe areas: "); + for (i = 0; i < wipeCount; i++) { + printf("[%d,%d,%d,%d] ", wipe[i][LEFT], wipe[i][TOP], wipe[i][RIGHT], wipe[i][BOTTOM]); + } + printf("\n"); + } + } else { + printf("wipe DISABLED for all sheets.\n"); + } + if (middleWipe[0] > 0 || middleWipe[1] > 0) { + printf("middle-wipe (l,r): %d,%d\n", middleWipe[0], middleWipe[1]); + } + if (noBorderMultiIndexCount != -1) { + if (border[LEFT]!=0 || border[TOP]!=0 || border[RIGHT]!=0 || border[BOTTOM]!=0) { + printf("explicit border: [%d,%d,%d,%d]\n", border[LEFT], border[TOP], border[RIGHT], border[BOTTOM]); + } + } else { + printf("border DISABLED for all sheets.\n"); + } + if (noBorderScanMultiIndexCount != -1) { + printf("border-scan-direction: "); + printDirections(borderScanDirections); + printf("border-scan-size: "); + printInts(borderScanSize); + printf("border-scan-step: "); + printInts(borderScanStep); + printf("border-scan-threshold: ");//%f\n", maskScanThreshold); + printInts(borderScanThreshold); + if (noBorderScanMultiIndexCount > 0) { + printf("border-scan DISABLED for sheets: "); + printMultiIndex(noBorderScanMultiIndex, noBorderScanMultiIndexCount); + } + printf("border-align: "); + printEdges(borderAlign); + printf("border-margin: "); + printInts(borderAlignMargin); + } else { + printf("border-scan DISABLED for all sheets.\n"); + } + if (postWipeCount > 0) { + printf("post-wipe: "); + int i; + for (i = 0; i < postWipeCount; i++) { + printf("[%d,%d,%d,%d] ",postWipe[i][LEFT],postWipe[i][TOP],postWipe[i][RIGHT],postWipe[i][BOTTOM]); + } + printf("\n"); + } + if (postBorder[LEFT]!=0 || postBorder[TOP]!=0 || postBorder[RIGHT]!=0 || postBorder[BOTTOM]!=0) { + printf("post-border: [%d,%d,%d,%d]\n", postBorder[LEFT], postBorder[TOP], postBorder[RIGHT], postBorder[BOTTOM]); + } + if (postMirror != 0) { + printf("post-mirror: "); + printDirections(postMirror); + } + if ((postShift[WIDTH] != 0) || ((postShift[HEIGHT] != 0))) { + printf("post-shift: "); + printInts(postShift); + } + if (postRotate != 0) { + printf("post-rotate: %d\n", postRotate); + } + //if (ignoreMultiIndexCount > 0) { + // printf("EXCLUDE sheets: "); + // printMultiIndex(ignoreMultiIndex, ignoreMultiIndexCount); + //} + printf("white-threshold: %f\n", whiteThreshold); + printf("black-threshold: %f\n", blackThreshold); + printf("sheet-background: %s\n", ((sheetBackground == BLACK) ? "black" : "white") ); + printf("dpi: %d\n", dpi); + printf("input-files per sheet: %d\n", inputCount); + printf("output-files per sheet: %d\n", outputCount); + if ((sheetSize[WIDTH] != -1) || (sheetSize[HEIGHT] != -1)) { + printf("sheet size forced to: %d x %d pixels\n", sheetSize[WIDTH], sheetSize[HEIGHT]); + } + printf("input-file-sequence: %s\n", implode(s1, (const char **)inputFileNames, inputCount)); + printf("output-file-sequence: %s\n", implode(s1, (const char **)outputFileNames, outputCount)); + if (overwrite) { + printf("OVERWRITING EXISTING FILES\n"); + } + printf("\n"); + } + if (verbose >= VERBOSE_NORMAL) { + printf("input-file%s for sheet %d: %s (type%s %s)\n", pluralS(inputCount), nr, implode(s1, (const char **)inputFileNames, inputCount), pluralS(inputCount), implode(s2, inputTypeNames, inputCount)); + printf("output-file%s for sheet %d: %s (type %s)\n", pluralS(outputCount), nr, implode(s1, (const char **)outputFileNames, outputCount), outputTypeName); + printf("sheet size: %dx%d\n", sheet.width, sheet.height); + printf("...\n"); + } + + + // ------------------------------------------------------- + // --- process image data --- + // ------------------------------------------------------- + + // stretch + if ((stretchSize[WIDTH] != -1) || (stretchSize[HEIGHT] != -1)) { + if (stretchSize[WIDTH] != -1) { + w = stretchSize[WIDTH]; + } else { + w = sheet.width; + } + if (stretchSize[HEIGHT] != -1) { + h = stretchSize[HEIGHT]; + } else { + h = sheet.height; + } + saveDebug("./_before-stretch.pnm", &sheet); + stretch(w, h, &sheet); + saveDebug("./_after-stretch.pnm", &sheet); + } + + // zoom + if (zoomFactor != 1.0) { + w = sheet.width * zoomFactor; + h = sheet.height * zoomFactor; + stretch(w, h, &sheet); + } + + // size + if ((size[WIDTH] != -1) || (size[HEIGHT] != -1)) { + if (size[WIDTH] != -1) { + w = size[WIDTH]; + } else { + w = sheet.width; + } + if (size[HEIGHT] != -1) { + h = size[HEIGHT]; + } else { + h = sheet.height; + } + saveDebug("./_before-resize.pnm", &sheet); + resize(w, h, &sheet); + saveDebug("./_after-resize.pnm", &sheet); + } + + + // handle sheet layout + + // LAYOUT_SINGLE + if (layout == LAYOUT_SINGLE) { + // set middle of sheet as single starting point for mask detection + if (pointCount == 0) { // no manual settings, use auto-values + point[pointCount][X] = sheet.width / 2; + point[pointCount][Y] = sheet.height / 2; + pointCount++; + } + if (maskScanMaximum[WIDTH] == -1) { + maskScanMaximum[WIDTH] = sheet.width; + } + if (maskScanMaximum[HEIGHT] == -1) { + maskScanMaximum[HEIGHT] = sheet.height; + } + // avoid inner half of the sheet to be blackfilter-detectable + if (blackfilterExcludeCount == 0) { // no manual settings, use auto-values + blackfilterExclude[blackfilterExcludeCount][LEFT] = sheet.width / 4; + blackfilterExclude[blackfilterExcludeCount][TOP] = sheet.height / 4; + blackfilterExclude[blackfilterExcludeCount][RIGHT] = sheet.width / 2 + sheet.width / 4; + blackfilterExclude[blackfilterExcludeCount][BOTTOM] = sheet.height / 2 + sheet.height / 4; + blackfilterExcludeCount++; + } + // set single outside border to start scanning for final border-scan + if (outsideBorderscanMaskCount == 0) { // no manual settings, use auto-values + outsideBorderscanMaskCount = 1; + outsideBorderscanMask[0][LEFT] = 0; + outsideBorderscanMask[0][RIGHT] = sheet.width - 1; + outsideBorderscanMask[0][TOP] = 0; + outsideBorderscanMask[0][BOTTOM] = sheet.height - 1; + } + + // LAYOUT_DOUBLE + } else if (layout == LAYOUT_DOUBLE) { + // set two middle of left/right side of sheet as starting points for mask detection + if (pointCount == 0) { // no manual settings, use auto-values + point[pointCount][X] = sheet.width / 4; + point[pointCount][Y] = sheet.height / 2; + pointCount++; + point[pointCount][X] = sheet.width - sheet.width / 4; + point[pointCount][Y] = sheet.height / 2; + pointCount++; + } + if (maskScanMaximum[WIDTH] == -1) { + maskScanMaximum[WIDTH] = sheet.width / 2; + } + if (maskScanMaximum[HEIGHT] == -1) { + maskScanMaximum[HEIGHT] = sheet.height; + } + if (middleWipe[0] > 0 || middleWipe[1] > 0) { // left, right + wipe[wipeCount][LEFT] = sheet.width / 2 - middleWipe[0]; + wipe[wipeCount][TOP] = 0; + wipe[wipeCount][RIGHT] = sheet.width / 2 + middleWipe[1]; + wipe[wipeCount][BOTTOM] = sheet.height - 1; + wipeCount++; + } + // avoid inner half of each page to be blackfilter-detectable + if (blackfilterExcludeCount == 0) { // no manual settings, use auto-values + blackfilterExclude[blackfilterExcludeCount][LEFT] = sheet.width / 8; + blackfilterExclude[blackfilterExcludeCount][TOP] = sheet.height / 4; + blackfilterExclude[blackfilterExcludeCount][RIGHT] = sheet.width / 4 + sheet.width / 8; + blackfilterExclude[blackfilterExcludeCount][BOTTOM] = sheet.height / 2 + sheet.height / 4; + blackfilterExcludeCount++; + blackfilterExclude[blackfilterExcludeCount][LEFT] = sheet.width / 2 + sheet.width / 8; + blackfilterExclude[blackfilterExcludeCount][TOP] = sheet.height / 4; + blackfilterExclude[blackfilterExcludeCount][RIGHT] = sheet.width / 2 + sheet.width / 4 + sheet.width / 8; + blackfilterExclude[blackfilterExcludeCount][BOTTOM] = sheet.height / 2 + sheet.height / 4; + blackfilterExcludeCount++; + } + // set two outside borders to start scanning for final border-scan + if (outsideBorderscanMaskCount == 0) { // no manual settings, use auto-values + outsideBorderscanMaskCount = 2; + outsideBorderscanMask[0][LEFT] = 0; + outsideBorderscanMask[0][RIGHT] = sheet.width / 2; + outsideBorderscanMask[0][TOP] = 0; + outsideBorderscanMask[0][BOTTOM] = sheet.height - 1; + outsideBorderscanMask[1][LEFT] = sheet.width / 2; + outsideBorderscanMask[1][RIGHT] = sheet.width - 1; + outsideBorderscanMask[1][TOP] = 0; + outsideBorderscanMask[1][BOTTOM] = sheet.height - 1; + } + } + // if maskScanMaximum still unset (no --layout specified), set to full sheet size now + if (maskScanMinimum[WIDTH] == -1) { + maskScanMaximum[WIDTH] = sheet.width; + } + if (maskScanMinimum[HEIGHT] == -1) { + maskScanMaximum[HEIGHT] = sheet.height; + } + + + // pre-wipe + if (!isExcluded(nr, noWipeMultiIndex, noWipeMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { + applyWipes(preWipe, preWipeCount, maskColor, &sheet); + } + + // pre-border + if (!isExcluded(nr, noBorderMultiIndex, noBorderMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { + applyBorder(preBorder, maskColor, &sheet); + } + + // black area filter + if (!isExcluded(nr, noBlackfilterMultiIndex, noBlackfilterMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { + saveDebug("./_before-blackfilter.pnm", &sheet); + blackfilter(blackfilterScanDirections, blackfilterScanSize, blackfilterScanDepth, blackfilterScanStep, blackfilterScanThreshold, blackfilterExclude, blackfilterExcludeCount, blackfilterIntensity, blackThreshold, &sheet); + saveDebug("./_after-blackfilter.pnm", &sheet); + } else { + if (verbose >= VERBOSE_MORE) { + printf("+ blackfilter DISABLED for sheet %d\n", nr); + } + } + + // noise filter + if (!isExcluded(nr, noNoisefilterMultiIndex, noNoisefilterMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { + if (verbose >= VERBOSE_NORMAL) { + printf("noise-filter ..."); + } + saveDebug("./_before-noisefilter.pnm", &sheet); + filterResult = noisefilter(noisefilterIntensity, whiteThreshold, &sheet); + saveDebug("./_after-noisefilter.pnm", &sheet); + if (verbose >= VERBOSE_NORMAL) { + printf(" deleted %d clusters.\n", filterResult); + } + } else { + if (verbose >= VERBOSE_MORE) { + printf("+ noisefilter DISABLED for sheet %d\n", nr); + } + } + + // blur filter + if (!isExcluded(nr, noBlurfilterMultiIndex, noBlurfilterMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { + if (verbose >= VERBOSE_NORMAL) { + printf("blur-filter..."); + } + saveDebug("./_before-blurfilter.pnm", &sheet); + filterResult = blurfilter(blurfilterScanSize, blurfilterScanStep, blurfilterIntensity, whiteThreshold, &sheet); + saveDebug("./_after-blurfilter.pnm", &sheet); + if (verbose >= VERBOSE_NORMAL) { + printf(" deleted %d pixels.\n", filterResult); + } + } else { + if (verbose >= VERBOSE_MORE) { + printf("+ blurfilter DISABLED for sheet %d\n", nr); + } + } + + // mask-detection + if (!isExcluded(nr, noMaskScanMultiIndex, noMaskScanMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { + maskCount = detectMasks(mask, maskValid, point, pointCount, maskScanDirections, maskScanSize, maskScanDepth, maskScanStep, maskScanThreshold, maskScanMinimum, maskScanMaximum, &sheet); + } else { + if (verbose >= VERBOSE_MORE) { + printf("+ mask-scan DISABLED for sheet %d\n", nr); + } + } + + // permamently apply masks + if (maskCount > 0) { + saveDebug("./_before-masking.pnm", &sheet); + applyMasks(mask, maskCount, maskColor, &sheet); + saveDebug("./_after-masking.pnm", &sheet); + } + + // gray filter + if (!isExcluded(nr, noGrayfilterMultiIndex, noGrayfilterMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { + if (verbose >= VERBOSE_NORMAL) { + printf("gray-filter..."); + } + saveDebug("./_before-grayfilter.pnm", &sheet); + filterResult = grayfilter(grayfilterScanSize, grayfilterScanStep, grayfilterThreshold, blackThreshold, &sheet); + saveDebug("./_after-grayfilter.pnm", &sheet); + if (verbose >= VERBOSE_NORMAL) { + printf(" deleted %d pixels.\n", filterResult); + } + } else { + if (verbose >= VERBOSE_MORE) { + printf("+ grayfilter DISABLED for sheet %d\n", nr); + } + } + + // rotation-detection + if ((!isExcluded(nr, noDeskewMultiIndex, noDeskewMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount))) { + int i; + + saveDebug("./_before-deskew.pnm", &sheet); + originalSheet = sheet; // copy struct entries ('clone') + // convert to qpixels + if (qpixels==true) { + if (verbose>=VERBOSE_NORMAL) { + printf("converting to qpixels.\n"); + } + initImage(&qpixelSheet, sheet.width * 2, sheet.height * 2, sheet.bitdepth, sheet.color, sheetBackground); + convertToQPixels(&sheet, &qpixelSheet); + sheet = qpixelSheet; + q = 2; // qpixel-factor for coordinates in both directions + } else { + q = 1; + } + + // detect masks again, we may get more precise results now after first masking and grayfilter + if (!isExcluded(nr, noMaskScanMultiIndex, noMaskScanMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { + maskCount = detectMasks(mask, maskValid, point, pointCount, maskScanDirections, maskScanSize, maskScanDepth, maskScanStep, maskScanThreshold, maskScanMinimum, maskScanMaximum, &originalSheet); + } else { + if (verbose >= VERBOSE_MORE) { + printf("(mask-scan before deskewing disabled)\n"); + } + } + + // auto-deskew each mask + for (i = 0; i < maskCount; i++) { + + // if ( maskValid[i] == true ) { // point may have been invalidated if mask has not been auto-detected + + // for rotation detection, original buffer is used (not qpixels) + saveDebug("./_before-deskew-detect.pnm", &originalSheet); + rotation = - detectRotation(deskewScanEdges, deskewScanRange, deskewScanStep, deskewScanSize, deskewScanDepth, deskewScanDeviation, mask[i][LEFT], mask[i][TOP], mask[i][RIGHT], mask[i][BOTTOM], &originalSheet); + saveDebug("./_after-deskew-detect.pnm", &originalSheet); + + if (rotation != 0.0) { + if (verbose>=VERBOSE_NORMAL) { + printf("rotate (%d,%d): %f\n", point[i][X], point[i][Y], rotation); + } + initImage(&rect, (mask[i][RIGHT]-mask[i][LEFT]+1)*q, (mask[i][BOTTOM]-mask[i][TOP]+1)*q, sheet.bitdepth, sheet.color, sheetBackground); + initImage(&rectTarget, rect.width, rect.height, sheet.bitdepth, sheet.color, sheetBackground); + + // copy area to rotate into rSource + copyImageArea(mask[i][LEFT]*q, mask[i][TOP]*q, rect.width, rect.height, &sheet, 0, 0, &rect); + + // rotate + rotate(degreesToRadians(rotation), &rect, &rectTarget); + + // copy result back into whole image + copyImageArea(0, 0, rectTarget.width, rectTarget.height, &rectTarget, mask[i][LEFT]*q, mask[i][TOP]*q, &sheet); + + freeImage(&rect); + freeImage(&rectTarget); + } else { + if (verbose >= VERBOSE_NORMAL) { + printf("rotate (%d,%d): -\n", point[i][X], point[i][Y]); + } + } + + // } + } + + // convert back from qpixels + if (qpixels == true) { + if (verbose >= VERBOSE_NORMAL) { + printf("converting back from qpixels.\n"); + } + convertFromQPixels(&qpixelSheet, &originalSheet); + freeImage(&qpixelSheet); + sheet = originalSheet; + } + saveDebug("./_after-deskew.pnm", &sheet); + } else { + if (verbose >= VERBOSE_MORE) { + printf("+ deskewing DISABLED for sheet %d\n", nr); + } + } + + // auto-center masks on either single-page or double-page layout + if ( (!isExcluded(nr, noMaskCenterMultiIndex, noMaskCenterMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) && (layout != LAYOUT_NONE) && (maskCount == pointCount) ) { // (maskCount==pointCount to make sure all masks had correctly been detected) + int i; + + // perform auto-masking again to get more precise masks after rotation + if (!isExcluded(nr, noMaskScanMultiIndex, noMaskScanMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { + maskCount = detectMasks(mask, maskValid, point, pointCount, maskScanDirections, maskScanSize, maskScanDepth, maskScanStep, maskScanThreshold, maskScanMinimum, maskScanMaximum, &sheet); + } else { + if (verbose >= VERBOSE_MORE) { + printf("(mask-scan before centering disabled)\n"); + } + } + + saveDebug("./_before-centering.pnm", &sheet); + // center masks on the sheet, according to their page position + for (i = 0; i < maskCount; i++) { + centerMask(point[i][X], point[i][Y], mask[i][LEFT], mask[i][TOP], mask[i][RIGHT], mask[i][BOTTOM], &sheet); + } + saveDebug("./_after-centering.pnm", &sheet); + } else { + if (verbose >= VERBOSE_MORE) { + printf("+ auto-centering DISABLED for sheet %d\n", nr); + } + } + + // explicit wipe + if (!isExcluded(nr, noWipeMultiIndex, noWipeMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { + applyWipes(wipe, wipeCount, maskColor, &sheet); + } else { + if (verbose >= VERBOSE_MORE) { + printf("+ wipe DISABLED for sheet %d\n", nr); + } + } + + // explicit border + if (!isExcluded(nr, noBorderMultiIndex, noBorderMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { + applyBorder(border, maskColor, &sheet); + } else { + if (verbose >= VERBOSE_MORE) { + printf("+ border DISABLED for sheet %d\n", nr); + } + } + + // border-detection + if (!isExcluded(nr, noBorderScanMultiIndex, noBorderScanMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { + int i; + saveDebug("./_before-border.pnm", &sheet); + for (i = 0; i < outsideBorderscanMaskCount; i++) { + detectBorder(autoborder[i], borderScanDirections, borderScanSize, borderScanStep, borderScanThreshold, blackThreshold, outsideBorderscanMask[i], &sheet); + borderToMask(autoborder[i], autoborderMask[i], &sheet); + } + applyMasks(autoborderMask, outsideBorderscanMaskCount, maskColor, &sheet); + for (i = 0; i < outsideBorderscanMaskCount; i++) { + // border-centering + if (!isExcluded(nr, noBorderAlignMultiIndex, noBorderAlignMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { + alignMask(autoborderMask[i], outsideBorderscanMask[i], borderAlign, borderAlignMargin, &sheet); + } else { + if (verbose >= VERBOSE_MORE) { + printf("+ border-centering DISABLED for sheet %d\n", nr); + } + } + } + saveDebug("./_after-border.pnm", &sheet); + } else { + if (verbose >= VERBOSE_MORE) { + printf("+ border-scan DISABLED for sheet %d\n", nr); + } + } + + // post-wipe + if (!isExcluded(nr, noWipeMultiIndex, noWipeMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { + applyWipes(postWipe, postWipeCount, maskColor, &sheet); + } + + // post-border + if (!isExcluded(nr, noBorderMultiIndex, noBorderMultiIndexCount, ignoreMultiIndex, ignoreMultiIndexCount)) { + applyBorder(postBorder, maskColor, &sheet); + } + + // post-mirroring + if (postMirror != 0) { + if (verbose >= VERBOSE_NORMAL) { + printf("post-mirroring "); + printDirections(postMirror); + } + mirror(postMirror, &sheet); + } + + // post-shifting + if ((postShift[WIDTH] != 0) || ((postShift[HEIGHT] != 0))) { + if (verbose >= VERBOSE_NORMAL) { + printf("post-shifting [%d,%d]\n", postShift[WIDTH], postShift[HEIGHT]); + } + shift(postShift[WIDTH], postShift[HEIGHT], &sheet); + } + + // post-rotating + if (postRotate != 0) { + if (verbose >= VERBOSE_NORMAL) { + printf("post-rotating %d degrees.\n", postRotate); + } + if (postRotate == 90) { + flipRotate(1, &sheet); + } else if (postRotate == -90) { + flipRotate(-1, &sheet); + } + } + + // post-stretch + if ((postStretchSize[WIDTH] != -1) || (postStretchSize[HEIGHT] != -1)) { + if (postStretchSize[WIDTH] != -1) { + w = postStretchSize[WIDTH]; + } else { + w = sheet.width; + } + if (postStretchSize[HEIGHT] != -1) { + h = postStretchSize[HEIGHT]; + } else { + h = sheet.height; + } + stretch(w, h, &sheet); + } + + // post-zoom + if (postZoomFactor != 1.0) { + w = sheet.width * postZoomFactor; + h = sheet.height * postZoomFactor; + stretch(w, h, &sheet); + } + + // post-size + if ((postSize[WIDTH] != -1) || (postSize[HEIGHT] != -1)) { + if (postSize[WIDTH] != -1) { + w = postSize[WIDTH]; + } else { + w = sheet.width; + } + if (postSize[HEIGHT] != -1) { + h = postSize[HEIGHT]; + } else { + h = sheet.height; + } + resize(w, h, &sheet); + } + + if (showTime) { + endTime = clock(); + } + + // --- write output file --- + + // write split pages output + + if (writeoutput == true) { + if (verbose >= VERBOSE_NORMAL) { + printf("writing output.\n"); + } + // write files + saveDebug("./_before-save.pnm", &sheet); + page.width = sheet.width / outputCount; + page.height = sheet.height; + page.bitdepth = sheet.bitdepth; + page.color = sheet.color; + for ( j = 0; j < outputCount; j++) { + // get pagebuffer + if ( outputCount == 1 ) { + page.buffer = sheet.buffer; + page.bufferGrayscale = sheet.bufferGrayscale; + page.bufferLightness = sheet.bufferLightness; + page.bufferDarknessInverse = sheet.bufferDarknessInverse; + } else { // generic case: copy page-part of sheet into own buffer + if (page.color) { + page.buffer = (uint8_t*)malloc( page.width * page.height * 3 ); + page.bufferGrayscale = (uint8_t*)malloc( page.width * page.height ); + page.bufferLightness = (uint8_t*)malloc( page.width * page.height ); + page.bufferDarknessInverse = (uint8_t*)malloc( page.width * page.height ); + } else { + page.buffer = (uint8_t*)malloc( page.width * page.height ); + page.bufferGrayscale = page.buffer; + page.bufferLightness = page.buffer; + page.bufferDarknessInverse = page.buffer; + } + copyImageArea(page.width * j, 0, page.width, page.height, &sheet, 0, 0, &page); + } + + if (verbose >= VERBOSE_MORE) { + printf("saving file %s.\n", outputFileNames[j]); + } + + saveImage(outputFiles[j], &page, outputType, blackThreshold); + + if ( outputCount > 1 ) { + freeImage(&page); + } + } + + freeImage(&sheet); + sheet.buffer = NULL; + + if (showTime) { + if (startTime > endTime) { // clock overflow + endTime -= startTime; // "re-underflow" value again + startTime = 0; + } + time = endTime - startTime; + totalTime += time; + totalCount++; + printf("- processing time: %f s\n", (float)time/CLOCKS_PER_SEC); + } + } + } + + sheet_end: + for(i = 0; i < inputCount; i++) { + if ( inputFiles[i] != NULL ) + fclose(inputFiles[i]); + } + + for(i = 0; i < outputCount; i++) { + if ( outputFiles[i] != NULL ) + fclose(outputFiles[i]); + } + + /* if we're not given an input wildcard, and we finished the + * arguments, we don't want to keep looping. + */ + if ( optind >= argc && !inputWildcard ) + break; + else if ( inputWildcard && outputWildcard ) + optind -= 2; + } + + if ( showTime && (totalCount > 1) ) { + printf("- total processing time of all %d sheets: %f s (average: %f s)\n", totalCount, (double)totalTime/CLOCKS_PER_SEC, (double)totalTime/totalCount/CLOCKS_PER_SEC); + } + return 0; +} diff -Nru unpaper-0.3/unpaper.h unpaper-0.4.2/unpaper.h --- unpaper-0.3/unpaper.h 1970-01-01 00:00:00.000000000 +0000 +++ unpaper-0.4.2/unpaper.h 2012-06-23 04:10:45.000000000 +0000 @@ -0,0 +1,149 @@ +/* + * This file is part of Unpaper. + * + * Copyright © 2005-2007 Jens Gulden + * Copyright © 2011-2011 Diego Elio Pettenò + * + * Unpaper 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, version 2 of the License. + * + * Unpaper 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 . + */ + +/* --- global declarations ------------------------------------------------ */ + + +#if HAVE_STDBOOL_H +# include +#else + typedef enum { + FALSE, + TRUE + } BOOLEAN; + +# define bool BOOLEAN +# define false FALSE +# define true TRUE +#endif + +/* --- preprocessor macros ------------------------------------------------ */ + +#define max(a, b) ( (a >= b) ? (a) : (b) ) +#define pluralS(i) ( (i > 1) ? "s" : "" ) +#define pixelValue(r, g, b) ( (r)<<16 | (g)<<8 | (b) ) +#define pixelGrayscaleValue(g) ( (g)<<16 | (g)<<8 | (g) ) +#define pixelGrayscale(r, g, b) ( ( ( r == g ) && ( r == b ) ) ? r : ( ( r + g + b ) / 3 ) ) // average (optimized for already gray values) +#define pixelLightness(r, g, b) ( r < g ? ( r < b ? r : b ) : ( g < b ? g : b ) ) // minimum +#define pixelDarknessInverse(r, g, b) ( r > g ? ( r > b ? r : b ) : ( g > b ? g : b ) ) // maximum +#define red(pixel) ( (pixel >> 16) & 0xff ) +#define green(pixel) ( (pixel >> 8) & 0xff ) +#define blue(pixel) ( pixel & 0xff ) + + +/* --- preprocessor constants ---------------------------------------------- */ + +#define MAX_MULTI_INDEX 10000 // maximum pixel count of virtual line to detect rotation with +#define MAX_ROTATION_SCAN_SIZE 10000 // maximum pixel count of virtual line to detect rotation with +#define MAX_MASKS 100 +#define MAX_POINTS 100 +#define MAX_FILES 100 +#define MAX_PAGES 2 +#define WHITE 255 +#define GRAY 127 +#define BLACK 0 +#define BLANK_TEXT "" + + +/* --- typedefs ----------------------------------------------------------- */ + +typedef enum { + VERBOSE_QUIET = -1, + VERBOSE_NONE = 0, + VERBOSE_NORMAL = 1, + VERBOSE_MORE = 2, + VERBOSE_DEBUG = 3, + VERBOSE_DEBUG_SAVE = 4 +} VERBOSE_LEVEL; + +typedef enum { + X, + Y, + COORDINATES_COUNT +} COORDINATES; + +typedef enum { + WIDTH, + HEIGHT, + DIMENSIONS_COUNT +} DIMENSIONS; + +typedef enum { + HORIZONTAL, + VERTICAL, + DIRECTIONS_COUNT +} DIRECTIONS; + +typedef enum { + LEFT, + TOP, + RIGHT, + BOTTOM, + EDGES_COUNT +} EDGES; + +typedef enum { + LAYOUT_NONE, + LAYOUT_SINGLE, + LAYOUT_DOUBLE, + LAYOUTS_COUNT +} LAYOUTS; + +typedef enum { + BRIGHT, + DARK, + SHADINGS_COUNT +} SHADINGS; + +typedef enum { + RED, + GREEN, + BLUE, + COLORCOMPONENTS_COUNT +} COLORCOMPONENTS; + +typedef enum { + PBM, + PGM, + PPM, + FILETYPES_COUNT +} FILETYPES; + + +/* --- struct ------------------------------------------------------------- */ + +struct IMAGE { + uint8_t *buffer; + uint8_t *bufferGrayscale; + uint8_t *bufferLightness; + uint8_t *bufferDarknessInverse; + int width; + int height; + int bitdepth; + int background; + bool color; +}; + +void errOutput(const char *fmt, ...) + __attribute__((format(printf, 1, 2))) + __attribute__((noreturn)); + +/* --- global variable ---------------------------------------------------- */ + +extern VERBOSE_LEVEL verbose;