Works on windows

preferencesAboutTextFull
Claudio Valerio 14 years ago
parent d39e0098e6
commit ff7ebdd298
  1. 5
      thirdparty/xpdf/README.txt
  2. 116
      thirdparty/xpdf/xpdf-3.02/aconf.h
  3. 967
      thirdparty/xpdf/xpdf-3.02/config.status
  4. 2
      thirdparty/xpdf/xpdf-3.02/fofi/FoFiType1.cc
  5. 40
      thirdparty/xpdf/xpdf-3.02/goo/gmem.cc
  6. 13
      thirdparty/xpdf/xpdf-3.02/splash/Splash.cc
  7. 23
      thirdparty/xpdf/xpdf-3.02/splash/SplashBitmap.cc
  8. 2
      thirdparty/xpdf/xpdf-3.02/splash/SplashErrorCodes.h
  9. 2
      thirdparty/xpdf/xpdf-3.02/xpdf/Gfx.cc
  10. 366
      thirdparty/xpdf/xpdf-3.02/xpdf/JBIG2Stream.cc
  11. 4
      thirdparty/xpdf/xpdf-3.02/xpdf/JBIG2Stream.h
  12. 2
      thirdparty/xpdf/xpdf-3.02/xpdf/PSOutputDev.cc
  13. 415
      thirdparty/xpdf/xpdf-3.02/xpdf/Stream.cc
  14. 10
      thirdparty/xpdf/xpdf-3.02/xpdf/Stream.h
  15. 18
      thirdparty/xpdf/xpdf-3.02/xpdf/XRef.cc

@ -7,8 +7,9 @@ instructions for version 3.02
- Decompress xpdf-3.02.xx.tar.gz
Windows:
- Copy aconf-win32.h to aconf.h
- undefine unicode API support by adding '#undef UNICODE' aconf.h
- using cywin run ./configure
- run qmake xpdf.pro -r -spec win32-g++
- run make
OSX:
- run ./configure (may need extrea options ?)

@ -1,116 +0,0 @@
/* aconf.h. Generated by configure. */
/*
* aconf.h
*
* Copyright 2002-2003 Glyph & Cog, LLC
*/
#ifndef ACONF_H
#define ACONF_H
#include <aconf2.h>
/*
* Use A4 paper size instead of Letter for PostScript output.
*/
/* #undef A4_PAPER */
/*
* Do not allow text selection.
*/
/* #undef NO_TEXT_SELECT */
/*
* Include support for OPI comments.
*/
/* #undef OPI_SUPPORT */
/*
* Enable multithreading support.
*/
/* #undef MULTITHREADED */
/*
* Enable C++ exceptions.
*/
/* #undef USE_EXCEPTIONS */
/*
* Enable word list support.
*/
/* #undef TEXTOUT_WORD_LIST */
/*
* Use fixed point (instead of floating point) arithmetic.
*/
/* #undef USE_FIXEDPOINT */
/*
* Directory with the Xpdf app-defaults file.
*/
/* #undef APPDEFDIR */
/*
* Full path for the system-wide xpdfrc file.
*/
#define SYSTEM_XPDFRC "/usr/local/etc/xpdfrc"
/*
* Various include files and functions.
*/
#define HAVE_DIRENT_H 1
/* #undef HAVE_SYS_NDIR_H */
/* #undef HAVE_SYS_DIR_H */
/* #undef HAVE_NDIR_H */
/* #undef HAVE_SYS_SELECT_H */
/* #undef HAVE_SYS_BSDTYPES_H */
#define HAVE_STRINGS_H 1
/* #undef HAVE_BSTRING_H */
#define HAVE_POPEN 1
#define HAVE_MKSTEMP 1
#define HAVE_MKSTEMPS 1
/* #undef SELECT_TAKES_INT */
#define HAVE_FSEEKO 1
/* #undef HAVE_FSEEK64 */
#define _FILE_OFFSET_BITS 64
/* #undef _LARGE_FILES */
/* #undef _LARGEFILE_SOURCE */
#define HAVE_XTAPPSETEXITFLAG 1
/*
* This is defined if using libXpm.
*/
#define HAVE_X11_XPM_H 1
/*
* This is defined if using t1lib.
*/
/* #undef HAVE_T1LIB_H */
/*
* One of these is defined if using FreeType 2.
*/
/* #undef HAVE_FREETYPE_H */
/* #undef HAVE_FREETYPE_FREETYPE_H */
/*
* This is defined if using libpaper.
*/
/* #undef HAVE_PAPER_H */
/*
* Enable support for loading plugins.
*/
/* #undef ENABLE_PLUGINS */
/*
* Defined if the Splash library is avaiable.
*/
/* #undef HAVE_SPLASH */
/*
* Enable support for CMYK output.
*/
/* #undef SPLASH_CMYK */
#endif

@ -1,967 +0,0 @@
#! /bin/bash
# Generated by configure.
# 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-/bin/bash}
## --------------------- ##
## M4sh Initialization. ##
## --------------------- ##
# Be Bourne compatible
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
emulate sh
NULLCMD=:
# Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
set -o posix
fi
DUALCASE=1; export DUALCASE # for MKS sh
# Support unset when possible.
if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
as_unset=unset
else
as_unset=false
fi
# Work around bugs in pre-3.0 UWIN ksh.
$as_unset ENV MAIL MAILPATH
PS1='$ '
PS2='> '
PS4='+ '
# NLS nuisances.
for as_var in \
LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
LC_TELEPHONE LC_TIME
do
if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
eval $as_var=C; export $as_var
else
$as_unset $as_var
fi
done
# Required to use basename.
if expr a : '\(a\)' >/dev/null 2>&1; 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
# Name of the executable.
as_me=`$as_basename "$0" ||
$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
X"$0" : 'X\(//\)$' \| \
X"$0" : 'X\(/\)$' \| \
. : '\(.\)' 2>/dev/null ||
echo X/"$0" |
sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
/^X\/\(\/\/\)$/{ s//\1/; q; }
/^X\/\(\/\).*/{ s//\1/; q; }
s/.*/./; q'`
# PATH needs CR, and LINENO needs CR and PATH.
# 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
# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
echo "#! /bin/sh" >conf$$.sh
echo "exit 0" >>conf$$.sh
chmod +x conf$$.sh
if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
PATH_SEPARATOR=';'
else
PATH_SEPARATOR=:
fi
rm -f conf$$.sh
fi
as_lineno_1=$LINENO
as_lineno_2=$LINENO
as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
test "x$as_lineno_1" != "x$as_lineno_2" &&
test "x$as_lineno_3" = "x$as_lineno_2" || {
# Find who we are. Look in the path if we contain no path at all
# relative or not.
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
;;
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
{ { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
{ (exit 1); exit 1; }; }
fi
case $CONFIG_SHELL in
'')
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for as_base in sh bash ksh sh5; do
case $as_dir in
/*)
if ("$as_dir/$as_base" -c '
as_lineno_1=$LINENO
as_lineno_2=$LINENO
as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
test "x$as_lineno_1" != "x$as_lineno_2" &&
test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
$as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
$as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
CONFIG_SHELL=$as_dir/$as_base
export CONFIG_SHELL
exec "$CONFIG_SHELL" "$0" ${1+"$@"}
fi;;
esac
done
done
;;
esac
# Create $as_me.lineno as a copy of $as_myself, but with $LINENO
# uniformly replaced by the line number. The first 'sed' inserts a
# line-number line before each line; the second 'sed' does the real
# work. The second script uses 'N' to pair each line-number line
# with the numbered line, and appends trailing '-' during
# substitution so that $LINENO is not a special case at line end.
# (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
# second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
sed '=' <$as_myself |
sed '
N
s,$,-,
: loop
s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
t loop
s,-$,,
s,^['$as_cr_digits']*\n,,
' >$as_me.lineno &&
chmod +x $as_me.lineno ||
{ { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
{ (exit 1); exit 1; }; }
# 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 sensible to this).
. ./$as_me.lineno
# Exit status is that of the last command.
exit
}
case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
*c*,-n*) ECHO_N= ECHO_C='
' ECHO_T=' ' ;;
*c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
*) ECHO_N= ECHO_C='\c' ECHO_T= ;;
esac
if expr a : '\(a\)' >/dev/null 2>&1; then
as_expr=expr
else
as_expr=false
fi
rm -f conf$$ conf$$.exe conf$$.file
echo >conf$$.file
if ln -s conf$$.file conf$$ 2>/dev/null; then
# We could just check for DJGPP; but this test a) works b) is more generic
# and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
if test -f conf$$.exe; then
# Don't use ln at all; we don't have any links
as_ln_s='cp -p'
else
as_ln_s='ln -s'
fi
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
as_ln_s='cp -p'
fi
rm -f conf$$ conf$$.exe conf$$.file
if mkdir -p . 2>/dev/null; then
as_mkdir_p=:
else
test -d ./-p && rmdir ./-p
as_mkdir_p=false
fi
as_executable_p="test -f"
# 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'"
# IFS
# We need space, tab and new line, in precisely that order.
as_nl='
'
IFS=" $as_nl"
# CDPATH.
$as_unset CDPATH
exec 6>&1
# Open the log real soon, to keep \$[0] and so on meaningful, and to
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. Logging --version etc. is OK.
exec 5>>config.log
{
echo
sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
## Running $as_me. ##
_ASBOX
} >&5
cat >&5 <<_CSEOF
This file was extended by $as_me, which was
generated by GNU Autoconf 2.59. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
CONFIG_HEADERS = $CONFIG_HEADERS
CONFIG_LINKS = $CONFIG_LINKS
CONFIG_COMMANDS = $CONFIG_COMMANDS
$ $0 $@
_CSEOF
echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
echo >&5
config_files=" Makefile goo/Makefile fofi/Makefile splash/Makefile xpdf/Makefile"
config_headers=" aconf.h"
ac_cs_usage="\
\`$as_me' instantiates files from templates according to the
current configuration.
Usage: $0 [OPTIONS] [FILE]...
-h, --help print this help, then exit
-V, --version print version number, then exit
-q, --quiet 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
--header=FILE[:TEMPLATE]
instantiate the configuration header FILE
Configuration files:
$config_files
Configuration headers:
$config_headers
Report bugs to <bug-autoconf@gnu.org>."
ac_cs_version="\
config.status
configured by ./configure, generated by GNU Autoconf 2.59,
with options \"\"
Copyright (C) 2003 Free Software Foundation, Inc.
This config.status script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it."
srcdir=.
INSTALL="/usr/bin/install -c"
# If no file are specified by the user, then we need to provide default
# value. By we need to know if files were specified by the user.
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=$1
ac_optarg=$2
ac_shift=shift
;;
*) # This is not an option, so the user has probably given explicit
# arguments.
ac_option=$1
ac_need_defaults=false;;
esac
case $ac_option in
# Handling of the options.
-recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
ac_cs_recheck=: ;;
--version | --vers* | -V )
echo "$ac_cs_version"; exit 0 ;;
--he | --h)
# Conflict between --help and --header
{ { echo "$as_me:$LINENO: error: ambiguous option: $1
Try \`$0 --help' for more information." >&5
echo "$as_me: error: ambiguous option: $1
Try \`$0 --help' for more information." >&2;}
{ (exit 1); exit 1; }; };;
--help | --hel | -h )
echo "$ac_cs_usage"; exit 0 ;;
--debug | --d* | -d )
debug=: ;;
--file | --fil | --fi | --f )
$ac_shift
CONFIG_FILES="$CONFIG_FILES $ac_optarg"
ac_need_defaults=false;;
--header | --heade | --head | --hea )
$ac_shift
CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
ac_need_defaults=false;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil | --si | --s)
ac_cs_silent=: ;;
# This is an error.
-*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
Try \`$0 --help' for more information." >&5
echo "$as_me: error: unrecognized option: $1
Try \`$0 --help' for more information." >&2;}
{ (exit 1); exit 1; }; } ;;
*) ac_config_targets="$ac_config_targets $1" ;;
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
if $ac_cs_recheck; then
echo "running /bin/bash ./configure " $ac_configure_extra_args " --no-create --no-recursion" >&6
exec /bin/bash ./configure $ac_configure_extra_args --no-create --no-recursion
fi
for ac_config_target in $ac_config_targets
do
case "$ac_config_target" in
# Handling of arguments.
"Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"goo/Makefile" ) CONFIG_FILES="$CONFIG_FILES goo/Makefile" ;;
"fofi/Makefile" ) CONFIG_FILES="$CONFIG_FILES fofi/Makefile" ;;
"splash/Makefile" ) CONFIG_FILES="$CONFIG_FILES splash/Makefile" ;;
"xpdf/Makefile" ) CONFIG_FILES="$CONFIG_FILES xpdf/Makefile" ;;
"aconf.h" ) CONFIG_HEADERS="$CONFIG_HEADERS aconf.h" ;;
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
{ (exit 1); exit 1; }; };;
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_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
fi
# Have a temporary directory for convenience. Make it in the build tree
# simply because there is no reason to put it here, and in addition,
# creating and moving files from /tmp can sometimes cause problems.
# Create a temporary directory, and hook for its removal unless debugging.
$debug ||
{
trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
trap '{ (exit 1); exit 1; }' 1 2 13 15
}
# Create a (secure) tmp directory for tmp files.
{
tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
test -n "$tmp" && test -d "$tmp"
} ||
{
tmp=./confstat$$-$RANDOM
(umask 077 && mkdir $tmp)
} ||
{
echo "$me: cannot create a temporary directory in ." >&2
{ (exit 1); exit 1; }
}
#
# CONFIG_FILES section.
#
# No need to generate the scripts if there are no CONFIG_FILES.
# This happens for instance when ./config.status config.h
if test -n "$CONFIG_FILES"; then
# Protect against being on the right side of a sed subst in config.status.
sed 's/,@/@@/; s/@,/@@/; s/,;t t$/@;t t/; /@;t t$/s/[\\&,]/\\&/g;
s/@@/,@/; s/@@/@,/; s/@;t t$/,;t t/' >$tmp/subs.sed <<\CEOF
s,@SHELL@,/bin/bash,;t t
s,@PATH_SEPARATOR@,:,;t t
s,@PACKAGE_NAME@,,;t t
s,@PACKAGE_TARNAME@,,;t t
s,@PACKAGE_VERSION@,,;t t
s,@PACKAGE_STRING@,,;t t
s,@PACKAGE_BUGREPORT@,,;t t
s,@exec_prefix@,${prefix},;t t
s,@prefix@,/usr/local,;t t
s,@program_transform_name@,s,x,x,,;t t
s,@bindir@,${exec_prefix}/bin,;t t
s,@sbindir@,${exec_prefix}/sbin,;t t
s,@libexecdir@,${exec_prefix}/libexec,;t t
s,@datadir@,${prefix}/share,;t t
s,@sysconfdir@,${prefix}/etc,;t t
s,@sharedstatedir@,${prefix}/com,;t t
s,@localstatedir@,${prefix}/var,;t t
s,@libdir@,${exec_prefix}/lib,;t t
s,@includedir@,${prefix}/include,;t t
s,@oldincludedir@,/usr/include,;t t
s,@infodir@,${prefix}/info,;t t
s,@mandir@,${prefix}/man,;t t
s,@build_alias@,,;t t
s,@host_alias@,,;t t
s,@target_alias@,,;t t
s,@DEFS@,-DHAVE_CONFIG_H,;t t
s,@ECHO_C@,,;t t
s,@ECHO_N@,-n,;t t
s,@ECHO_T@,,;t t
s,@LIBS@,,;t t
s,@CC@,gcc,;t t
s,@CFLAGS@,-g -O2,;t t
s,@LDFLAGS@,,;t t
s,@CPPFLAGS@,,;t t
s,@ac_ct_CC@,gcc,;t t
s,@EXEEXT@,,;t t
s,@OBJEXT@,o,;t t
s,@CXX@,g++,;t t
s,@CXXFLAGS@,-g -O2,;t t
s,@ac_ct_CXX@,g++,;t t
s,@INSTALL_PROGRAM@,${INSTALL},;t t
s,@INSTALL_SCRIPT@,${INSTALL},;t t
s,@INSTALL_DATA@,${INSTALL} -m 644,;t t
s,@RANLIB@,ranlib,;t t
s,@ac_ct_RANLIB@,ranlib,;t t
s,@EXE@,,;t t
s,@LIBPREFIX@,lib,;t t
s,@AR@,ar rc,;t t
s,@UP_DIR@,,;t t
s,@CPP@,gcc -E,;t t
s,@X_CFLAGS@,,;t t
s,@X_PRE_LIBS@, -lSM -lICE,;t t
s,@X_LIBS@,,;t t
s,@X_EXTRA_LIBS@,,;t t
s,@EGREP@,grep -E,;t t
s,@Xpm_LIBS@,-lXpm,;t t
s,@Xpm_CFLAGS@,,;t t
s,@Xext_LIBS@,-lXext,;t t
s,@Xext_CFLAGS@,,;t t
s,@Xp_LIBS@,-lXp,;t t
s,@Xp_CFLAGS@,,;t t
s,@Xt_LIBS@,-lXt,;t t
s,@Xt_CFLAGS@,,;t t
s,@Xm_LIBS@,,;t t
s,@Xm_CFLAGS@,,;t t
s,@Sgm_LIBS@,,;t t
s,@Sgm_CFLAGS@,,;t t
s,@t1_LIBS@,,;t t
s,@t1_CFLAGS@,,;t t
s,@freetype2_LIBS@,,;t t
s,@freetype2_CFLAGS@,,;t t
s,@libpaper_LIBS@,,;t t
s,@libpaper_CFLAGS@,,;t t
s,@X@,#,;t t
s,@XPDF_TARGET@,all-no-x,;t t
s,@LIBOBJS@,,;t t
s,@LTLIBOBJS@,,;t t
CEOF
# Split the substitutions into bite-sized pieces for seds with
# small command number limits, like on Digital OSF/1 and HP-UX.
ac_max_sed_lines=48
ac_sed_frag=1 # Number of current file.
ac_beg=1 # First line for current file.
ac_end=$ac_max_sed_lines # Line after last line for current file.
ac_more_lines=:
ac_sed_cmds=
while $ac_more_lines; do
if test $ac_beg -gt 1; then
sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
else
sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
fi
if test ! -s $tmp/subs.frag; then
ac_more_lines=false
else
# The purpose of the label and of the branching condition is to
# speed up the sed processing (if there are no `@' at all, there
# is no need to browse any of the substitutions).
# These are the two extra sed commands mentioned above.
(echo ':t
/@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
if test -z "$ac_sed_cmds"; then
ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
else
ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
fi
ac_sed_frag=`expr $ac_sed_frag + 1`
ac_beg=$ac_end
ac_end=`expr $ac_end + $ac_max_sed_lines`
fi
done
if test -z "$ac_sed_cmds"; then
ac_sed_cmds=cat
fi
fi # test -n "$CONFIG_FILES"
for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
# Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
case $ac_file in
- | *:- | *:-:* ) # input from stdin
cat >$tmp/stdin
ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
*:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
* ) ac_file_in=$ac_file.in ;;
esac
# Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
ac_dir=`(dirname "$ac_file") 2>/dev/null ||
$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$ac_file" : 'X\(//\)[^/]' \| \
X"$ac_file" : 'X\(//\)$' \| \
X"$ac_file" : 'X\(/\)' \| \
. : '\(.\)' 2>/dev/null ||
echo X"$ac_file" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
/^X\(\/\/\)[^/].*/{ s//\1/; q; }
/^X\(\/\/\)$/{ s//\1/; q; }
/^X\(\/\).*/{ s//\1/; q; }
s/.*/./; q'`
{ if $as_mkdir_p; then
mkdir -p "$ac_dir"
else
as_dir="$ac_dir"
as_dirs=
while test ! -d "$as_dir"; do
as_dirs="$as_dir $as_dirs"
as_dir=`(dirname "$as_dir") 2>/dev/null ||
$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$as_dir" : 'X\(//\)[^/]' \| \
X"$as_dir" : 'X\(//\)$' \| \
X"$as_dir" : 'X\(/\)' \| \
. : '\(.\)' 2>/dev/null ||
echo X"$as_dir" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
/^X\(\/\/\)[^/].*/{ s//\1/; q; }
/^X\(\/\/\)$/{ s//\1/; q; }
/^X\(\/\).*/{ s//\1/; q; }
s/.*/./; q'`
done
test ! -n "$as_dirs" || mkdir $as_dirs
fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
{ (exit 1); exit 1; }; }; }
ac_builddir=.
if test "$ac_dir" != .; then
ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
# A "../" for each directory in $ac_dir_suffix.
ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
else
ac_dir_suffix= ac_top_builddir=
fi
case $srcdir in
.) # No --srcdir option. We are building in place.
ac_srcdir=.
if test -z "$ac_top_builddir"; then
ac_top_srcdir=.
else
ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
fi ;;
[\\/]* | ?:[\\/]* ) # Absolute path.
ac_srcdir=$srcdir$ac_dir_suffix;
ac_top_srcdir=$srcdir ;;
*) # Relative path.
ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
ac_top_srcdir=$ac_top_builddir$srcdir ;;
esac
# Do not use `cd foo && pwd` to compute absolute paths, because
# the directories may not exist.
case `pwd` in
.) ac_abs_builddir="$ac_dir";;
*)
case "$ac_dir" in
.) ac_abs_builddir=`pwd`;;
[\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
*) ac_abs_builddir=`pwd`/"$ac_dir";;
esac;;
esac
case $ac_abs_builddir in
.) ac_abs_top_builddir=${ac_top_builddir}.;;
*)
case ${ac_top_builddir}. in
.) ac_abs_top_builddir=$ac_abs_builddir;;
[\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
*) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
esac;;
esac
case $ac_abs_builddir in
.) ac_abs_srcdir=$ac_srcdir;;
*)
case $ac_srcdir in
.) ac_abs_srcdir=$ac_abs_builddir;;
[\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
*) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
esac;;
esac
case $ac_abs_builddir in
.) ac_abs_top_srcdir=$ac_top_srcdir;;
*)
case $ac_top_srcdir in
.) ac_abs_top_srcdir=$ac_abs_builddir;;
[\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
*) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
esac;;
esac
case $INSTALL in
[\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
*) ac_INSTALL=$ac_top_builddir$INSTALL ;;
esac
if test x"$ac_file" != x-; then
{ echo "$as_me:$LINENO: creating $ac_file" >&5
echo "$as_me: creating $ac_file" >&6;}
rm -f "$ac_file"
fi
# 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. */
if test x"$ac_file" = x-; then
configure_input=
else
configure_input="$ac_file. "
fi
configure_input=$configure_input"Generated from `echo $ac_file_in |
sed 's,.*/,,'` by configure."
# First look for the input files in the build tree, otherwise in the
# src tree.
ac_file_inputs=`IFS=:
for f in $ac_file_in; do
case $f in
-) echo $tmp/stdin ;;
[\\/$]*)
# Absolute (can't be DOS-style, as IFS=:)
test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
echo "$as_me: error: cannot find input file: $f" >&2;}
{ (exit 1); exit 1; }; }
echo "$f";;
*) # Relative
if test -f "$f"; then
# Build tree
echo "$f"
elif test -f "$srcdir/$f"; then
# Source tree
echo "$srcdir/$f"
else
# /dev/null tree
{ { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
echo "$as_me: error: cannot find input file: $f" >&2;}
{ (exit 1); exit 1; }; }
fi;;
esac
done` || { (exit 1); exit 1; }
sed "/^[ ]*VPATH[ ]*=/{
s/:*\$(srcdir):*/:/;
s/:*\${srcdir}:*/:/;
s/:*@srcdir@:*/:/;
s/^\([^=]*=[ ]*\):*/\1/;
s/:*$//;
s/^[^=]*=[ ]*$//;
}
:t
/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
s,@configure_input@,$configure_input,;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,@top_builddir@,$ac_top_builddir,;t t
s,@abs_top_builddir@,$ac_abs_top_builddir,;t t
s,@INSTALL@,$ac_INSTALL,;t t
" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
rm -f $tmp/stdin
if test x"$ac_file" != x-; then
mv $tmp/out $ac_file
else
cat $tmp/out
rm -f $tmp/out
fi
done
#
# CONFIG_HEADER section.
#
# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
# NAME is the cpp macro being defined and VALUE is the value it is being given.
#
# ac_d sets the value in "#define NAME VALUE" lines.
ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)'
ac_dB='[ ].*$,\1#\2'
ac_dC=' '
ac_dD=',;t'
# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
ac_uB='$,\1#\2define\3'
ac_uC=' '
ac_uD=',;t'
for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
# Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
case $ac_file in
- | *:- | *:-:* ) # input from stdin
cat >$tmp/stdin
ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
*:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
* ) ac_file_in=$ac_file.in ;;
esac
test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5
echo "$as_me: creating $ac_file" >&6;}
# First look for the input files in the build tree, otherwise in the
# src tree.
ac_file_inputs=`IFS=:
for f in $ac_file_in; do
case $f in
-) echo $tmp/stdin ;;
[\\/$]*)
# Absolute (can't be DOS-style, as IFS=:)
test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
echo "$as_me: error: cannot find input file: $f" >&2;}
{ (exit 1); exit 1; }; }
# Do quote $f, to prevent DOS paths from being IFS'd.
echo "$f";;
*) # Relative
if test -f "$f"; then
# Build tree
echo "$f"
elif test -f "$srcdir/$f"; then
# Source tree
echo "$srcdir/$f"
else
# /dev/null tree
{ { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
echo "$as_me: error: cannot find input file: $f" >&2;}
{ (exit 1); exit 1; }; }
fi;;
esac
done` || { (exit 1); exit 1; }
# Remove the trailing spaces.
sed 's/[ ]*$//' $ac_file_inputs >$tmp/in
# Handle all the #define templates only if necessary.
if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then
# If there are no defines, we may have an empty if/fi
:
cat >$tmp/defines.sed <<CEOF
/^[ ]*#[ ]*define/!b
t clr
: clr
${ac_dA}PACKAGE_NAME${ac_dB}PACKAGE_NAME${ac_dC}""${ac_dD}
${ac_dA}PACKAGE_TARNAME${ac_dB}PACKAGE_TARNAME${ac_dC}""${ac_dD}
${ac_dA}PACKAGE_VERSION${ac_dB}PACKAGE_VERSION${ac_dC}""${ac_dD}
${ac_dA}PACKAGE_STRING${ac_dB}PACKAGE_STRING${ac_dC}""${ac_dD}
${ac_dA}PACKAGE_BUGREPORT${ac_dB}PACKAGE_BUGREPORT${ac_dC}""${ac_dD}
${ac_dA}SYSTEM_XPDFRC${ac_dB}SYSTEM_XPDFRC${ac_dC}"/usr/local/etc/xpdfrc"${ac_dD}
${ac_dA}HAVE_DIRENT_H${ac_dB}HAVE_DIRENT_H${ac_dC}1${ac_dD}
${ac_dA}HAVE_REWINDDIR${ac_dB}HAVE_REWINDDIR${ac_dC}1${ac_dD}
${ac_dA}HAVE_POPEN${ac_dB}HAVE_POPEN${ac_dC}1${ac_dD}
${ac_dA}HAVE_MKSTEMP${ac_dB}HAVE_MKSTEMP${ac_dC}1${ac_dD}
${ac_dA}HAVE_MKSTEMPS${ac_dB}HAVE_MKSTEMPS${ac_dC}1${ac_dD}
${ac_dA}_FILE_OFFSET_BITS${ac_dB}_FILE_OFFSET_BITS${ac_dC}64${ac_dD}
${ac_dA}HAVE_FSEEKO${ac_dB}HAVE_FSEEKO${ac_dC}1${ac_dD}
${ac_dA}STDC_HEADERS${ac_dB}STDC_HEADERS${ac_dC}1${ac_dD}
${ac_dA}HAVE_SYS_TYPES_H${ac_dB}HAVE_SYS_TYPES_H${ac_dC}1${ac_dD}
${ac_dA}HAVE_SYS_STAT_H${ac_dB}HAVE_SYS_STAT_H${ac_dC}1${ac_dD}
${ac_dA}HAVE_STDLIB_H${ac_dB}HAVE_STDLIB_H${ac_dC}1${ac_dD}
${ac_dA}HAVE_STRING_H${ac_dB}HAVE_STRING_H${ac_dC}1${ac_dD}
${ac_dA}HAVE_MEMORY_H${ac_dB}HAVE_MEMORY_H${ac_dC}1${ac_dD}
${ac_dA}HAVE_STRINGS_H${ac_dB}HAVE_STRINGS_H${ac_dC}1${ac_dD}
${ac_dA}HAVE_INTTYPES_H${ac_dB}HAVE_INTTYPES_H${ac_dC}1${ac_dD}
${ac_dA}HAVE_STDINT_H${ac_dB}HAVE_STDINT_H${ac_dC}1${ac_dD}
${ac_dA}HAVE_UNISTD_H${ac_dB}HAVE_UNISTD_H${ac_dC}1${ac_dD}
${ac_dA}HAVE_X11_XPM_H${ac_dB}HAVE_X11_XPM_H${ac_dC}1${ac_dD}
${ac_dA}HAVE_X11_XLIB_H${ac_dB}HAVE_X11_XLIB_H${ac_dC}1${ac_dD}
${ac_dA}HAVE_X11_EXTENSIONS_PRINT_H${ac_dB}HAVE_X11_EXTENSIONS_PRINT_H${ac_dC}1${ac_dD}
${ac_dA}HAVE_X11_INTRINSIC_H${ac_dB}HAVE_X11_INTRINSIC_H${ac_dC}1${ac_dD}
${ac_dA}HAVE_XTAPPSETEXITFLAG${ac_dB}HAVE_XTAPPSETEXITFLAG${ac_dC}1${ac_dD}
CEOF
sed -f $tmp/defines.sed $tmp/in >$tmp/out
rm -f $tmp/in
mv $tmp/out $tmp/in
fi # grep
# Handle all the #undef templates
cat >$tmp/undefs.sed <<CEOF
/^[ ]*#[ ]*undef/!b
t clr
: clr
${ac_uA}PACKAGE_NAME${ac_uB}PACKAGE_NAME${ac_uC}""${ac_uD}
${ac_uA}PACKAGE_TARNAME${ac_uB}PACKAGE_TARNAME${ac_uC}""${ac_uD}
${ac_uA}PACKAGE_VERSION${ac_uB}PACKAGE_VERSION${ac_uC}""${ac_uD}
${ac_uA}PACKAGE_STRING${ac_uB}PACKAGE_STRING${ac_uC}""${ac_uD}
${ac_uA}PACKAGE_BUGREPORT${ac_uB}PACKAGE_BUGREPORT${ac_uC}""${ac_uD}
${ac_uA}SYSTEM_XPDFRC${ac_uB}SYSTEM_XPDFRC${ac_uC}"/usr/local/etc/xpdfrc"${ac_uD}
${ac_uA}HAVE_DIRENT_H${ac_uB}HAVE_DIRENT_H${ac_uC}1${ac_uD}
${ac_uA}HAVE_REWINDDIR${ac_uB}HAVE_REWINDDIR${ac_uC}1${ac_uD}
${ac_uA}HAVE_POPEN${ac_uB}HAVE_POPEN${ac_uC}1${ac_uD}
${ac_uA}HAVE_MKSTEMP${ac_uB}HAVE_MKSTEMP${ac_uC}1${ac_uD}
${ac_uA}HAVE_MKSTEMPS${ac_uB}HAVE_MKSTEMPS${ac_uC}1${ac_uD}
${ac_uA}_FILE_OFFSET_BITS${ac_uB}_FILE_OFFSET_BITS${ac_uC}64${ac_uD}
${ac_uA}HAVE_FSEEKO${ac_uB}HAVE_FSEEKO${ac_uC}1${ac_uD}
${ac_uA}STDC_HEADERS${ac_uB}STDC_HEADERS${ac_uC}1${ac_uD}
${ac_uA}HAVE_SYS_TYPES_H${ac_uB}HAVE_SYS_TYPES_H${ac_uC}1${ac_uD}
${ac_uA}HAVE_SYS_STAT_H${ac_uB}HAVE_SYS_STAT_H${ac_uC}1${ac_uD}
${ac_uA}HAVE_STDLIB_H${ac_uB}HAVE_STDLIB_H${ac_uC}1${ac_uD}
${ac_uA}HAVE_STRING_H${ac_uB}HAVE_STRING_H${ac_uC}1${ac_uD}
${ac_uA}HAVE_MEMORY_H${ac_uB}HAVE_MEMORY_H${ac_uC}1${ac_uD}
${ac_uA}HAVE_STRINGS_H${ac_uB}HAVE_STRINGS_H${ac_uC}1${ac_uD}
${ac_uA}HAVE_INTTYPES_H${ac_uB}HAVE_INTTYPES_H${ac_uC}1${ac_uD}
${ac_uA}HAVE_STDINT_H${ac_uB}HAVE_STDINT_H${ac_uC}1${ac_uD}
${ac_uA}HAVE_UNISTD_H${ac_uB}HAVE_UNISTD_H${ac_uC}1${ac_uD}
${ac_uA}HAVE_X11_XPM_H${ac_uB}HAVE_X11_XPM_H${ac_uC}1${ac_uD}
${ac_uA}HAVE_X11_XLIB_H${ac_uB}HAVE_X11_XLIB_H${ac_uC}1${ac_uD}
${ac_uA}HAVE_X11_EXTENSIONS_PRINT_H${ac_uB}HAVE_X11_EXTENSIONS_PRINT_H${ac_uC}1${ac_uD}
${ac_uA}HAVE_X11_INTRINSIC_H${ac_uB}HAVE_X11_INTRINSIC_H${ac_uC}1${ac_uD}
${ac_uA}HAVE_XTAPPSETEXITFLAG${ac_uB}HAVE_XTAPPSETEXITFLAG${ac_uC}1${ac_uD}
s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
CEOF
sed -f $tmp/undefs.sed $tmp/in >$tmp/out
rm -f $tmp/in
mv $tmp/out $tmp/in
# 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. */
if test x"$ac_file" = x-; then
echo "/* Generated by configure. */" >$tmp/config.h
else
echo "/* $ac_file. Generated by configure. */" >$tmp/config.h
fi
cat $tmp/in >>$tmp/config.h
rm -f $tmp/in
if test x"$ac_file" != x-; then
if diff $ac_file $tmp/config.h >/dev/null 2>&1; then
{ echo "$as_me:$LINENO: $ac_file is unchanged" >&5
echo "$as_me: $ac_file is unchanged" >&6;}
else
ac_dir=`(dirname "$ac_file") 2>/dev/null ||
$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$ac_file" : 'X\(//\)[^/]' \| \
X"$ac_file" : 'X\(//\)$' \| \
X"$ac_file" : 'X\(/\)' \| \
. : '\(.\)' 2>/dev/null ||
echo X"$ac_file" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
/^X\(\/\/\)[^/].*/{ s//\1/; q; }
/^X\(\/\/\)$/{ s//\1/; q; }
/^X\(\/\).*/{ s//\1/; q; }
s/.*/./; q'`
{ if $as_mkdir_p; then
mkdir -p "$ac_dir"
else
as_dir="$ac_dir"
as_dirs=
while test ! -d "$as_dir"; do
as_dirs="$as_dir $as_dirs"
as_dir=`(dirname "$as_dir") 2>/dev/null ||
$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$as_dir" : 'X\(//\)[^/]' \| \
X"$as_dir" : 'X\(//\)$' \| \
X"$as_dir" : 'X\(/\)' \| \
. : '\(.\)' 2>/dev/null ||
echo X"$as_dir" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
/^X\(\/\/\)[^/].*/{ s//\1/; q; }
/^X\(\/\/\)$/{ s//\1/; q; }
/^X\(\/\).*/{ s//\1/; q; }
s/.*/./; q'`
done
test ! -n "$as_dirs" || mkdir $as_dirs
fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
{ (exit 1); exit 1; }; }; }
rm -f $ac_file
mv $tmp/config.h $ac_file
fi
else
cat $tmp/config.h
rm -f $tmp/config.h
fi
done
{ (exit 0); exit 0; }

@ -224,7 +224,7 @@ void FoFiType1::parse() {
code = code * 8 + (*p2 - '0');
}
}
if (code >= 0 && code < 256) {
if (code < 256) {
for (p = p2; *p == ' ' || *p == '\t'; ++p) ;
if (*p == '/') {
++p;

@ -55,15 +55,7 @@ void *gmalloc(int size) GMEM_EXCEP {
void *data;
unsigned long *trl, *p;
if (size < 0) {
#if USE_EXCEPTIONS
throw GMemException();
#else
fprintf(stderr, "Invalid memory allocation size\n");
exit(1);
#endif
}
if (size == 0) {
if (size <= 0) {
return NULL;
}
size1 = gMemDataSize(size);
@ -99,15 +91,7 @@ void *gmalloc(int size) GMEM_EXCEP {
#else
void *p;
if (size < 0) {
#if USE_EXCEPTIONS
throw GMemException();
#else
fprintf(stderr, "Invalid memory allocation size\n");
exit(1);
#endif
}
if (size == 0) {
if (size <= 0) {
return NULL;
}
if (!(p = malloc(size))) {
@ -128,15 +112,7 @@ void *grealloc(void *p, int size) GMEM_EXCEP {
void *q;
int oldSize;
if (size < 0) {
#if USE_EXCEPTIONS
throw GMemException();
#else
fprintf(stderr, "Invalid memory allocation size\n");
exit(1);
#endif
}
if (size == 0) {
if (size <= 0) {
if (p) {
gfree(p);
}
@ -155,15 +131,7 @@ void *grealloc(void *p, int size) GMEM_EXCEP {
#else
void *q;
if (size < 0) {
#if USE_EXCEPTIONS
throw GMemException();
#else
fprintf(stderr, "Invalid memory allocation size\n");
exit(1);
#endif
}
if (size == 0) {
if (size <= 0) {
if (p) {
free(p);
}

@ -12,7 +12,6 @@
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "gmem.h"
#include "SplashErrorCodes.h"
#include "SplashMath.h"
@ -1913,10 +1912,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData,
xq = w % scaledWidth;
// allocate pixel buffer
if (yp < 0 || yp > INT_MAX - 1) {
return splashErrBadArg;
}
pixBuf = (SplashColorPtr)gmallocn(yp + 1, w);
pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w);
// initialize the pixel pipe
pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha,
@ -2212,12 +2208,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData,
xq = w % scaledWidth;
// allocate pixel buffers
if (yp < 0 || yp > INT_MAX - 1 || w > INT_MAX / nComps) {
return splashErrBadArg;
}
colorBuf = (SplashColorPtr)gmallocn(yp + 1, w * nComps);
colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps);
if (srcAlpha) {
alphaBuf = (Guchar *)gmallocn(yp + 1, w);
alphaBuf = (Guchar *)gmalloc((yp + 1) * w);
} else {
alphaBuf = NULL;
}

@ -11,7 +11,6 @@
#endif
#include <stdio.h>
#include <limits.h>
#include "gmem.h"
#include "SplashErrorCodes.h"
#include "SplashBitmap.h"
@ -28,48 +27,30 @@ SplashBitmap::SplashBitmap(int widthA, int heightA, int rowPad,
mode = modeA;
switch (mode) {
case splashModeMono1:
if (width > 0) {
rowSize = (width + 7) >> 3;
} else {
rowSize = -1;
}
break;
case splashModeMono8:
if (width > 0) {
rowSize = width;
} else {
rowSize = -1;
}
break;
case splashModeRGB8:
case splashModeBGR8:
if (width > 0 && width <= INT_MAX / 3) {
rowSize = width * 3;
} else {
rowSize = -1;
}
break;
#if SPLASH_CMYK
case splashModeCMYK8:
if (width > 0 && width <= INT_MAX / 4) {
rowSize = width * 4;
} else {
rowSize = -1;
}
break;
#endif
}
if (rowSize > 0) {
rowSize += rowPad - 1;
rowSize -= rowSize % rowPad;
}
data = (SplashColorPtr)gmallocn(height, rowSize);
data = (SplashColorPtr)gmalloc(rowSize * height);
if (!topDown) {
data += (height - 1) * rowSize;
rowSize = -rowSize;
}
if (alphaA) {
alpha = (Guchar *)gmallocn(width, height);
alpha = (Guchar *)gmalloc(width * height);
} else {
alpha = NULL;
}

@ -29,6 +29,4 @@
#define splashErrSingularMatrix 8 // matrix is singular
#define splashErrBadArg 9 // bad argument
#endif

@ -461,7 +461,6 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict,
baseMatrix[i] = state->getCTM()[i];
}
formDepth = 0;
parser = NULL;
abortCheckCbk = abortCheckCbkA;
abortCheckCbkData = abortCheckCbkDataA;
@ -501,7 +500,6 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict,
baseMatrix[i] = state->getCTM()[i];
}
formDepth = 0;
parser = NULL;
abortCheckCbk = abortCheckCbkA;
abortCheckCbkData = abortCheckCbkDataA;

@ -422,7 +422,6 @@ void JBIG2HuffmanDecoder::buildTable(JBIG2HuffmanTable *table, Guint len) {
table[i] = table[len];
// assign prefixes
if (table[0].rangeLen != jbig2HuffmanEOT) {
i = 0;
prefix = 0;
table[i++].prefix = prefix++;
@ -430,7 +429,6 @@ void JBIG2HuffmanDecoder::buildTable(JBIG2HuffmanTable *table, Guint len) {
prefix <<= table[i].prefixLen - table[i-1].prefixLen;
table[i].prefix = prefix++;
}
}
}
//------------------------------------------------------------------------
@ -493,7 +491,7 @@ int JBIG2MMRDecoder::get2DCode() {
}
if (p->bits < 0) {
error(str->getPos(), "Bad two dim code in JBIG2 MMR stream");
return EOF;
return 0;
}
bufLen -= p->bits;
return p->n;
@ -509,7 +507,7 @@ int JBIG2MMRDecoder::getWhiteCode() {
++nBytesRead;
}
while (1) {
if (bufLen >= 11 && ((buf >> (bufLen - 7)) & 0x7f) == 0) {
if (bufLen >= 7 && ((buf >> (bufLen - 7)) & 0x7f) == 0) {
if (bufLen <= 12) {
code = buf << (12 - bufLen);
} else {
@ -552,15 +550,14 @@ int JBIG2MMRDecoder::getBlackCode() {
++nBytesRead;
}
while (1) {
if (bufLen >= 10 && ((buf >> (bufLen - 6)) & 0x3f) == 0) {
if (bufLen >= 6 && ((buf >> (bufLen - 6)) & 0x3f) == 0) {
if (bufLen <= 13) {
code = buf << (13 - bufLen);
} else {
code = buf >> (bufLen - 13);
}
p = &blackTab1[code & 0x7f];
} else if (bufLen >= 7 && ((buf >> (bufLen - 4)) & 0x0f) == 0 &&
((buf >> (bufLen - 6)) & 0x03) != 0) {
} else if (bufLen >= 4 && ((buf >> (bufLen - 4)) & 0x0f) == 0) {
if (bufLen <= 12) {
code = buf << (12 - bufLen);
} else {
@ -686,9 +683,8 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA):
h = hA;
line = (wA + 7) >> 3;
if (w <= 0 || h <= 0 || line <= 0 || h >= (INT_MAX - 1) / line) {
// force a call to gmalloc(-1), which will throw an exception
h = -1;
line = 2;
data = NULL;
return;
}
// need to allocate one extra guard byte for use in combine()
data = (Guchar *)gmalloc(h * line + 1);
@ -702,9 +698,8 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap):
h = bitmap->h;
line = bitmap->line;
if (w <= 0 || h <= 0 || line <= 0 || h >= (INT_MAX - 1) / line) {
// force a call to gmalloc(-1), which will throw an exception
h = -1;
line = 2;
data = NULL;
return;
}
// need to allocate one extra guard byte for use in combine()
data = (Guchar *)gmalloc(h * line + 1);
@ -759,8 +754,6 @@ void JBIG2Bitmap::clearToOne() {
inline void JBIG2Bitmap::getPixelPtr(int x, int y, JBIG2BitmapPtr *ptr) {
if (y < 0 || y >= h || x >= w) {
ptr->p = NULL;
ptr->shift = 0; // make gcc happy
ptr->x = 0; // make gcc happy
} else if (x < 0) {
ptr->p = &data[y * line];
ptr->shift = 7;
@ -805,10 +798,6 @@ void JBIG2Bitmap::combine(JBIG2Bitmap *bitmap, int x, int y,
Guint src0, src1, src, dest, s1, s2, m1, m2, m3;
GBool oneByte;
// check for the pathological case where y = -2^31
if (y < -0x7fffffff) {
return;
}
if (y < 0) {
y0 = -y;
} else {
@ -1022,13 +1011,8 @@ private:
JBIG2SymbolDict::JBIG2SymbolDict(Guint segNumA, Guint sizeA):
JBIG2Segment(segNumA)
{
Guint i;
size = sizeA;
bitmaps = (JBIG2Bitmap **)gmallocn(size, sizeof(JBIG2Bitmap *));
for (i = 0; i < size; ++i) {
bitmaps[i] = NULL;
}
genericRegionStats = NULL;
refinementRegionStats = NULL;
}
@ -1037,10 +1021,8 @@ JBIG2SymbolDict::~JBIG2SymbolDict() {
Guint i;
for (i = 0; i < size; ++i) {
if (bitmaps[i]) {
delete bitmaps[i];
}
}
gfree(bitmaps);
if (genericRegionStats) {
delete genericRegionStats;
@ -1314,13 +1296,6 @@ void JBIG2Stream::readSegments() {
goto eofError2;
}
// check for missing page information segment
if (!pageBitmap && ((segType >= 4 && segType <= 7) ||
(segType >= 20 && segType <= 43))) {
error(getPos(), "First JBIG2 segment associated with a page must be a page information segment");
goto syntaxError;
}
// read the segment data
switch (segType) {
case 0:
@ -1436,8 +1411,6 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
Guint i, j, k;
Guchar *p;
symWidths = NULL;
// symbol dictionary flags
if (!readUWord(&flags)) {
goto eofError;
@ -1493,32 +1466,20 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
codeTables = new GList();
numInputSyms = 0;
for (i = 0; i < nRefSegs; ++i) {
if ((seg = findSegment(refSegs[i]))) {
seg = findSegment(refSegs[i]);
if (seg->getType() == jbig2SegSymbolDict) {
j = ((JBIG2SymbolDict *)seg)->getSize();
if (numInputSyms > UINT_MAX - j) {
error(getPos(), "Too many input symbols in JBIG2 symbol dictionary");
delete codeTables;
goto eofError;
}
numInputSyms += j;
numInputSyms += ((JBIG2SymbolDict *)seg)->getSize();
} else if (seg->getType() == jbig2SegCodeTable) {
codeTables->append(seg);
}
}
}
if (numInputSyms > UINT_MAX - numNewSyms) {
error(getPos(), "Too many input symbols in JBIG2 symbol dictionary");
delete codeTables;
goto eofError;
}
// compute symbol code length
symCodeLen = 1;
i = (numInputSyms + numNewSyms) >> 1;
while (i) {
symCodeLen = 0;
i = 1;
while (i < numInputSyms + numNewSyms) {
++symCodeLen;
i >>= 1;
i <<= 1;
}
// get the input symbol bitmaps
@ -1530,7 +1491,7 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
k = 0;
inputSymbolDict = NULL;
for (i = 0; i < nRefSegs; ++i) {
if ((seg = findSegment(refSegs[i]))) {
seg = findSegment(refSegs[i]);
if (seg->getType() == jbig2SegSymbolDict) {
inputSymbolDict = (JBIG2SymbolDict *)seg;
for (j = 0; j < inputSymbolDict->getSize(); ++j) {
@ -1538,7 +1499,6 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
}
}
}
}
// get the Huffman tables
huffDHTable = huffDWTable = NULL; // make gcc happy
@ -1550,9 +1510,6 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
} else if (huffDH == 1) {
huffDHTable = huffTableE;
} else {
if (i >= (Guint)codeTables->getLength()) {
goto codeTableError;
}
huffDHTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
}
if (huffDW == 0) {
@ -1560,26 +1517,17 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
} else if (huffDW == 1) {
huffDWTable = huffTableC;
} else {
if (i >= (Guint)codeTables->getLength()) {
goto codeTableError;
}
huffDWTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
}
if (huffBMSize == 0) {
huffBMSizeTable = huffTableA;
} else {
if (i >= (Guint)codeTables->getLength()) {
goto codeTableError;
}
huffBMSizeTable =
((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
}
if (huffAggInst == 0) {
huffAggInstTable = huffTableA;
} else {
if (i >= (Guint)codeTables->getLength()) {
goto codeTableError;
}
huffAggInstTable =
((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
}
@ -1612,6 +1560,7 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
}
// allocate symbol widths storage
symWidths = NULL;
if (huff && !refAgg) {
symWidths = (Guint *)gmallocn(numNewSyms, sizeof(Guint));
}
@ -1653,10 +1602,6 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
goto syntaxError;
}
symWidth += dw;
if (i >= numNewSyms) {
error(getPos(), "Too many symbols in JBIG2 symbol dictionary");
goto syntaxError;
}
// using a collective bitmap, so don't read a bitmap here
if (huff && !refAgg) {
@ -1693,10 +1638,6 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
arithDecoder->decodeInt(&refDX, iardxStats);
arithDecoder->decodeInt(&refDY, iardyStats);
}
if (symID >= numInputSyms + i) {
error(getPos(), "Invalid symbol ID in JBIG2 symbol dictionary");
goto syntaxError;
}
refBitmap = bitmaps[symID];
bitmaps[numInputSyms + i] =
readGenericRefinementRegion(symWidth, symHeight,
@ -1763,12 +1704,6 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
} else {
arithDecoder->decodeInt(&run, iaexStats);
}
if (i + run > numInputSyms + numNewSyms ||
(ex && j + run > numExSyms)) {
error(getPos(), "Too many exported symbols in JBIG2 symbol dictionary");
delete symbolDict;
goto syntaxError;
}
if (ex) {
for (cnt = 0; cnt < run; ++cnt) {
symbolDict->setBitmap(j++, bitmaps[i++]->copy());
@ -1778,11 +1713,6 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
}
ex = !ex;
}
if (j != numExSyms) {
error(getPos(), "Too few symbols in JBIG2 symbol dictionary");
delete symbolDict;
goto syntaxError;
}
for (i = 0; i < numNewSyms; ++i) {
delete bitmaps[numInputSyms + i];
@ -1805,10 +1735,6 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
return gTrue;
codeTableError:
error(getPos(), "Missing code table in JBIG2 symbol dictionary");
delete codeTables;
syntaxError:
for (i = 0; i < numNewSyms; ++i) {
if (bitmaps[numInputSyms + i]) {
@ -1911,8 +1837,6 @@ void JBIG2Stream::readTextRegionSeg(Guint segNum, GBool imm,
}
} else {
error(getPos(), "Invalid segment reference in JBIG2 text region");
delete codeTables;
return;
}
}
symCodeLen = 0;
@ -1947,9 +1871,6 @@ void JBIG2Stream::readTextRegionSeg(Guint segNum, GBool imm,
} else if (huffFS == 1) {
huffFSTable = huffTableG;
} else {
if (i >= (Guint)codeTables->getLength()) {
goto codeTableError;
}
huffFSTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
}
if (huffDS == 0) {
@ -1959,9 +1880,6 @@ void JBIG2Stream::readTextRegionSeg(Guint segNum, GBool imm,
} else if (huffDS == 2) {
huffDSTable = huffTableJ;
} else {
if (i >= (Guint)codeTables->getLength()) {
goto codeTableError;
}
huffDSTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
}
if (huffDT == 0) {
@ -1971,9 +1889,6 @@ void JBIG2Stream::readTextRegionSeg(Guint segNum, GBool imm,
} else if (huffDT == 2) {
huffDTTable = huffTableM;
} else {
if (i >= (Guint)codeTables->getLength()) {
goto codeTableError;
}
huffDTTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
}
if (huffRDW == 0) {
@ -1981,9 +1896,6 @@ void JBIG2Stream::readTextRegionSeg(Guint segNum, GBool imm,
} else if (huffRDW == 1) {
huffRDWTable = huffTableO;
} else {
if (i >= (Guint)codeTables->getLength()) {
goto codeTableError;
}
huffRDWTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
}
if (huffRDH == 0) {
@ -1991,9 +1903,6 @@ void JBIG2Stream::readTextRegionSeg(Guint segNum, GBool imm,
} else if (huffRDH == 1) {
huffRDHTable = huffTableO;
} else {
if (i >= (Guint)codeTables->getLength()) {
goto codeTableError;
}
huffRDHTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
}
if (huffRDX == 0) {
@ -2001,9 +1910,6 @@ void JBIG2Stream::readTextRegionSeg(Guint segNum, GBool imm,
} else if (huffRDX == 1) {
huffRDXTable = huffTableO;
} else {
if (i >= (Guint)codeTables->getLength()) {
goto codeTableError;
}
huffRDXTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
}
if (huffRDY == 0) {
@ -2011,17 +1917,11 @@ void JBIG2Stream::readTextRegionSeg(Guint segNum, GBool imm,
} else if (huffRDY == 1) {
huffRDYTable = huffTableO;
} else {
if (i >= (Guint)codeTables->getLength()) {
goto codeTableError;
}
huffRDYTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
}
if (huffRSize == 0) {
huffRSizeTable = huffTableA;
} else {
if (i >= (Guint)codeTables->getLength()) {
goto codeTableError;
}
huffRSizeTable =
((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
}
@ -2116,15 +2016,8 @@ void JBIG2Stream::readTextRegionSeg(Guint segNum, GBool imm,
return;
codeTableError:
error(getPos(), "Missing code table in JBIG2 text region");
gfree(codeTables);
delete syms;
return;
eofError:
error(getPos(), "Unexpected EOF in JBIG2 stream");
return;
}
JBIG2Bitmap *JBIG2Stream::readTextRegion(GBool huff, GBool refine,
@ -2431,8 +2324,8 @@ void JBIG2Stream::readHalftoneRegionSeg(Guint segNum, GBool imm,
error(getPos(), "Bad symbol dictionary reference in JBIG2 halftone segment");
return;
}
if (!(seg = findSegment(refSegs[0])) ||
seg->getType() != jbig2SegPatternDict) {
seg = findSegment(refSegs[0]);
if (seg->getType() != jbig2SegPatternDict) {
error(getPos(), "Bad symbol dictionary reference in JBIG2 halftone segment");
return;
}
@ -2590,7 +2483,7 @@ void JBIG2Stream::readGenericRegionSeg(Guint segNum, GBool imm,
// read the bitmap
bitmap = readGenericBitmap(mmr, w, h, templ, tpgdOn, gFalse,
NULL, atx, aty, mmr ? length - 18 : 0);
NULL, atx, aty, mmr ? 0 : length - 18);
// combine the region bitmap into the page bitmap
if (imm) {
@ -2612,43 +2505,6 @@ void JBIG2Stream::readGenericRegionSeg(Guint segNum, GBool imm,
error(getPos(), "Unexpected EOF in JBIG2 stream");
}
inline void JBIG2Stream::mmrAddPixels(int a1, int blackPixels,
int *codingLine, int *a0i, int w) {
if (a1 > codingLine[*a0i]) {
if (a1 > w) {
error(getPos(), "JBIG2 MMR row is wrong length ({0:d})", a1);
a1 = w;
}
if ((*a0i & 1) ^ blackPixels) {
++*a0i;
}
codingLine[*a0i] = a1;
}
}
inline void JBIG2Stream::mmrAddPixelsNeg(int a1, int blackPixels,
int *codingLine, int *a0i, int w) {
if (a1 > codingLine[*a0i]) {
if (a1 > w) {
error(getPos(), "JBIG2 MMR row is wrong length ({0:d})", a1);
a1 = w;
}
if ((*a0i & 1) ^ blackPixels) {
++*a0i;
}
codingLine[*a0i] = a1;
} else if (a1 < codingLine[*a0i]) {
if (a1 < 0) {
error(getPos(), "Invalid JBIG2 MMR code");
a1 = 0;
}
while (*a0i > 0 && a1 <= codingLine[*a0i - 1]) {
--*a0i;
}
codingLine[*a0i] = a1;
}
}
JBIG2Bitmap *JBIG2Stream::readGenericBitmap(GBool mmr, int w, int h,
int templ, GBool tpgdOn,
GBool useSkip, JBIG2Bitmap *skip,
@ -2661,7 +2517,7 @@ JBIG2Bitmap *JBIG2Stream::readGenericBitmap(GBool mmr, int w, int h,
JBIG2BitmapPtr atPtr0, atPtr1, atPtr2, atPtr3;
int *refLine, *codingLine;
int code1, code2, code3;
int x, y, a0i, b1i, blackPixels, pix, i;
int x, y, a0, pix, i, refI, codingI;
bitmap = new JBIG2Bitmap(0, w, h);
bitmap->clearToZero();
@ -2671,18 +2527,9 @@ JBIG2Bitmap *JBIG2Stream::readGenericBitmap(GBool mmr, int w, int h,
if (mmr) {
mmrDecoder->reset();
if (w > INT_MAX - 2) {
error(getPos(), "Bad width in JBIG2 generic bitmap");
// force a call to gmalloc(-1), which will throw an exception
w = -3;
}
// 0 <= codingLine[0] < codingLine[1] < ... < codingLine[n] = w
// ---> max codingLine size = w + 1
// refLine has one extra guard entry at the end
// ---> max refLine size = w + 2
codingLine = (int *)gmallocn(w + 1, sizeof(int));
refLine = (int *)gmallocn(w + 2, sizeof(int));
codingLine[0] = w;
codingLine = (int *)gmallocn(w + 2, sizeof(int));
codingLine[0] = codingLine[1] = w;
for (y = 0; y < h; ++y) {
@ -2690,157 +2537,128 @@ JBIG2Bitmap *JBIG2Stream::readGenericBitmap(GBool mmr, int w, int h,
for (i = 0; codingLine[i] < w; ++i) {
refLine[i] = codingLine[i];
}
refLine[i++] = w;
refLine[i] = w;
refLine[i] = refLine[i + 1] = w;
// decode a line
codingLine[0] = 0;
a0i = 0;
b1i = 0;
blackPixels = 0;
// invariant:
// refLine[b1i-1] <= codingLine[a0i] < refLine[b1i] < refLine[b1i+1] <= w
// exception at left edge:
// codingLine[a0i = 0] = refLine[b1i = 0] = 0 is possible
// exception at right edge:
// refLine[b1i] = refLine[b1i+1] = w is possible
while (codingLine[a0i] < w) {
refI = 0; // b1 = refLine[refI]
codingI = 0; // a1 = codingLine[codingI]
a0 = 0;
do {
code1 = mmrDecoder->get2DCode();
switch (code1) {
case twoDimPass:
mmrAddPixels(refLine[b1i + 1], blackPixels, codingLine, &a0i, w);
if (refLine[b1i + 1] < w) {
b1i += 2;
if (refLine[refI] < w) {
a0 = refLine[refI + 1];
refI += 2;
}
break;
case twoDimHoriz:
code1 = code2 = 0;
if (blackPixels) {
if (codingI & 1) {
code1 = 0;
do {
code1 += code3 = mmrDecoder->getBlackCode();
} while (code3 >= 64);
code2 = 0;
do {
code2 += code3 = mmrDecoder->getWhiteCode();
} while (code3 >= 64);
} else {
code1 = 0;
do {
code1 += code3 = mmrDecoder->getWhiteCode();
} while (code3 >= 64);
code2 = 0;
do {
code2 += code3 = mmrDecoder->getBlackCode();
} while (code3 >= 64);
}
mmrAddPixels(codingLine[a0i] + code1, blackPixels,
codingLine, &a0i, w);
if (codingLine[a0i] < w) {
mmrAddPixels(codingLine[a0i] + code2, blackPixels ^ 1,
codingLine, &a0i, w);
if (code1 > 0 || code2 > 0) {
a0 = codingLine[codingI++] = a0 + code1;
a0 = codingLine[codingI++] = a0 + code2;
while (refLine[refI] <= a0 && refLine[refI] < w) {
refI += 2;
}
while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
b1i += 2;
}
break;
case twoDimVertR3:
mmrAddPixels(refLine[b1i] + 3, blackPixels, codingLine, &a0i, w);
blackPixels ^= 1;
if (codingLine[a0i] < w) {
++b1i;
while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
b1i += 2;
}
case twoDimVert0:
a0 = codingLine[codingI++] = refLine[refI];
if (refLine[refI] < w) {
++refI;
}
break;
case twoDimVertR2:
mmrAddPixels(refLine[b1i] + 2, blackPixels, codingLine, &a0i, w);
blackPixels ^= 1;
if (codingLine[a0i] < w) {
++b1i;
while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
b1i += 2;
case twoDimVertR1:
a0 = codingLine[codingI++] = refLine[refI] + 1;
if (refLine[refI] < w) {
++refI;
while (refLine[refI] <= a0 && refLine[refI] < w) {
refI += 2;
}
}
break;
case twoDimVertR1:
mmrAddPixels(refLine[b1i] + 1, blackPixels, codingLine, &a0i, w);
blackPixels ^= 1;
if (codingLine[a0i] < w) {
++b1i;
while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
b1i += 2;
case twoDimVertR2:
a0 = codingLine[codingI++] = refLine[refI] + 2;
if (refLine[refI] < w) {
++refI;
while (refLine[refI] <= a0 && refLine[refI] < w) {
refI += 2;
}
}
break;
case twoDimVert0:
mmrAddPixels(refLine[b1i], blackPixels, codingLine, &a0i, w);
blackPixels ^= 1;
if (codingLine[a0i] < w) {
++b1i;
while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
b1i += 2;
case twoDimVertR3:
a0 = codingLine[codingI++] = refLine[refI] + 3;
if (refLine[refI] < w) {
++refI;
while (refLine[refI] <= a0 && refLine[refI] < w) {
refI += 2;
}
}
break;
case twoDimVertL3:
mmrAddPixelsNeg(refLine[b1i] - 3, blackPixels, codingLine, &a0i, w);
blackPixels ^= 1;
if (codingLine[a0i] < w) {
if (b1i > 0) {
--b1i;
case twoDimVertL1:
a0 = codingLine[codingI++] = refLine[refI] - 1;
if (refI > 0) {
--refI;
} else {
++b1i;
}
while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
b1i += 2;
++refI;
}
while (refLine[refI] <= a0 && refLine[refI] < w) {
refI += 2;
}
break;
case twoDimVertL2:
mmrAddPixelsNeg(refLine[b1i] - 2, blackPixels, codingLine, &a0i, w);
blackPixels ^= 1;
if (codingLine[a0i] < w) {
if (b1i > 0) {
--b1i;
a0 = codingLine[codingI++] = refLine[refI] - 2;
if (refI > 0) {
--refI;
} else {
++b1i;
}
while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
b1i += 2;
++refI;
}
while (refLine[refI] <= a0 && refLine[refI] < w) {
refI += 2;
}
break;
case twoDimVertL1:
mmrAddPixelsNeg(refLine[b1i] - 1, blackPixels, codingLine, &a0i, w);
blackPixels ^= 1;
if (codingLine[a0i] < w) {
if (b1i > 0) {
--b1i;
case twoDimVertL3:
a0 = codingLine[codingI++] = refLine[refI] - 3;
if (refI > 0) {
--refI;
} else {
++b1i;
++refI;
}
while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
b1i += 2;
while (refLine[refI] <= a0 && refLine[refI] < w) {
refI += 2;
}
}
break;
case EOF:
mmrAddPixels(w, 0, codingLine, &a0i, w);
break;
default:
error(getPos(), "Illegal code in JBIG2 MMR bitmap data");
mmrAddPixels(w, 0, codingLine, &a0i, w);
break;
}
}
} while (a0 < w);
codingLine[codingI++] = w;
// convert the run lengths to a bitmap line
i = 0;
while (1) {
while (codingLine[i] < w) {
for (x = codingLine[i]; x < codingLine[i+1]; ++x) {
bitmap->setPixel(x, y);
}
if (codingLine[i+1] >= w || codingLine[i+2] >= w) {
break;
}
i += 2;
}
}
@ -2888,9 +2706,7 @@ JBIG2Bitmap *JBIG2Stream::readGenericBitmap(GBool mmr, int w, int h,
ltp = !ltp;
}
if (ltp) {
if (y > 0) {
bitmap->duplicateRow(y, y-1);
}
continue;
}
}
@ -3093,8 +2909,8 @@ void JBIG2Stream::readGenericRefinementRegionSeg(Guint segNum, GBool imm,
return;
}
if (nRefSegs == 1) {
if (!(seg = findSegment(refSegs[0])) ||
seg->getType() != jbig2SegBitmap) {
seg = findSegment(refSegs[0]);
if (seg->getType() != jbig2SegBitmap) {
error(getPos(), "Bad bitmap reference in JBIG2 generic refinement segment");
return;
}
@ -3188,10 +3004,6 @@ JBIG2Bitmap *JBIG2Stream::readGenericRefinementRegion(int w, int h,
tpgrCX2 = refBitmap->nextPixel(&tpgrCXPtr2);
tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2);
tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2);
} else {
tpgrCXPtr0.p = tpgrCXPtr1.p = tpgrCXPtr2.p = NULL; // make gcc happy
tpgrCXPtr0.shift = tpgrCXPtr1.shift = tpgrCXPtr2.shift = 0;
tpgrCXPtr0.x = tpgrCXPtr1.x = tpgrCXPtr2.x = 0;
}
for (x = 0; x < w; ++x) {
@ -3263,10 +3075,6 @@ JBIG2Bitmap *JBIG2Stream::readGenericRefinementRegion(int w, int h,
tpgrCX2 = refBitmap->nextPixel(&tpgrCXPtr2);
tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2);
tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2);
} else {
tpgrCXPtr0.p = tpgrCXPtr1.p = tpgrCXPtr2.p = NULL; // make gcc happy
tpgrCXPtr0.shift = tpgrCXPtr1.shift = tpgrCXPtr2.shift = 0;
tpgrCXPtr0.x = tpgrCXPtr1.x = tpgrCXPtr2.x = 0;
}
for (x = 0; x < w; ++x) {

@ -78,10 +78,6 @@ private:
Guint *refSegs, Guint nRefSegs);
void readGenericRegionSeg(Guint segNum, GBool imm,
GBool lossless, Guint length);
void mmrAddPixels(int a1, int blackPixels,
int *codingLine, int *a0i, int w);
void mmrAddPixelsNeg(int a1, int blackPixels,
int *codingLine, int *a0i, int w);
JBIG2Bitmap *readGenericBitmap(GBool mmr, int w, int h,
int templ, GBool tpgdOn,
GBool useSkip, JBIG2Bitmap *skip,

@ -4301,7 +4301,7 @@ void PSOutputDev::doImageL1Sep(GfxImageColorMap *colorMap,
width, -height, height);
// allocate a line buffer
lineBuf = (Guchar *)gmallocn(width, 4);
lineBuf = (Guchar *)gmalloc(4 * width);
// set up to process the data stream
imgStr = new ImageStream(str, width, colorMap->getNumPixelComps(),

@ -323,10 +323,6 @@ ImageStream::ImageStream(Stream *strA, int widthA, int nCompsA, int nBitsA) {
} else {
imgLineSize = nVals;
}
if (width > INT_MAX / nComps) {
// force a call to gmallocn(-1,...), which will throw an exception
imgLineSize = -1;
}
imgLine = (Guchar *)gmallocn(imgLineSize, sizeof(Guchar));
imgIdx = nVals;
}
@ -414,13 +410,15 @@ StreamPredictor::StreamPredictor(Stream *strA, int predictorA,
ok = gFalse;
nVals = width * nComps;
if (width <= 0 || nComps <= 0 || nBits <= 0 ||
nComps >= INT_MAX / nBits ||
width >= INT_MAX / nComps / nBits ||
nVals * nBits + 7 < 0) {
return;
}
pixBytes = (nComps * nBits + 7) >> 3;
rowBytes = ((nVals * nBits + 7) >> 3) + pixBytes;
if (width <= 0 || nComps <= 0 || nBits <= 0 ||
nComps > gfxColorMaxComps ||
nBits > 16 ||
width >= INT_MAX / nComps || // check for overflow in nVals
nVals >= (INT_MAX - 7) / nBits) { // check for overflow in rowBytes
if (rowBytes <= 0) {
return;
}
predLine = (Guchar *)gmalloc(rowBytes);
@ -1247,26 +1245,23 @@ CCITTFaxStream::CCITTFaxStream(Stream *strA, int encodingA, GBool endOfLineA,
columns = columnsA;
if (columns < 1) {
columns = 1;
} else if (columns > INT_MAX - 2) {
columns = INT_MAX - 2;
}
if (columns + 4 <= 0) {
columns = INT_MAX - 4;
}
rows = rowsA;
endOfBlock = endOfBlockA;
black = blackA;
// 0 <= codingLine[0] < codingLine[1] < ... < codingLine[n] = columns
// ---> max codingLine size = columns + 1
// refLine has one extra guard entry at the end
// ---> max refLine size = columns + 2
codingLine = (int *)gmallocn(columns + 1, sizeof(int));
refLine = (int *)gmallocn(columns + 2, sizeof(int));
refLine = (short *)gmallocn(columns + 3, sizeof(short));
codingLine = (short *)gmallocn(columns + 2, sizeof(short));
eof = gFalse;
row = 0;
nextLine2D = encoding < 0;
inputBits = 0;
codingLine[0] = columns;
a0i = 0;
outputBits = 0;
codingLine[0] = 0;
codingLine[1] = refLine[2] = columns;
a0 = 1;
buf = EOF;
}
@ -1285,9 +1280,9 @@ void CCITTFaxStream::reset() {
row = 0;
nextLine2D = encoding < 0;
inputBits = 0;
codingLine[0] = columns;
a0i = 0;
outputBits = 0;
codingLine[0] = 0;
codingLine[1] = columns;
a0 = 1;
buf = EOF;
// skip any initial zero bits and end-of-line marker, and get the 2D
@ -1304,230 +1299,211 @@ void CCITTFaxStream::reset() {
}
}
inline void CCITTFaxStream::addPixels(int a1, int blackPixels) {
if (a1 > codingLine[a0i]) {
if (a1 > columns) {
error(getPos(), "CCITTFax row is wrong length (%d)", a1);
err = gTrue;
a1 = columns;
}
if ((a0i & 1) ^ blackPixels) {
++a0i;
}
codingLine[a0i] = a1;
}
}
inline void CCITTFaxStream::addPixelsNeg(int a1, int blackPixels) {
if (a1 > codingLine[a0i]) {
if (a1 > columns) {
error(getPos(), "CCITTFax row is wrong length (%d)", a1);
err = gTrue;
a1 = columns;
}
if ((a0i & 1) ^ blackPixels) {
++a0i;
}
codingLine[a0i] = a1;
} else if (a1 < codingLine[a0i]) {
if (a1 < 0) {
error(getPos(), "Invalid CCITTFax code");
err = gTrue;
a1 = 0;
}
while (a0i > 0 && a1 <= codingLine[a0i - 1]) {
--a0i;
}
codingLine[a0i] = a1;
}
}
int CCITTFaxStream::lookChar() {
short code1, code2, code3;
int b1i, blackPixels, i, bits;
GBool gotEOL;
if (buf != EOF) {
return buf;
}
// read the next row
if (outputBits == 0) {
int a0New;
GBool err, gotEOL;
int ret;
int bits, i;
// if at eof just return EOF
if (eof) {
if (eof && codingLine[a0] >= columns) {
return EOF;
}
// read the next row
err = gFalse;
if (codingLine[a0] >= columns) {
// 2-D encoding
if (nextLine2D) {
// state:
// a0New = current position in coding line (0 <= a0New <= columns)
// codingLine[a0] = last change in coding line
// (black-to-white if a0 is even,
// white-to-black if a0 is odd)
// refLine[b1] = next change in reference line of opposite color
// to a0
// invariants:
// 0 <= codingLine[a0] <= a0New
// <= refLine[b1] <= refLine[b1+1] <= columns
// 0 <= a0 <= columns+1
// refLine[0] = 0
// refLine[n] = refLine[n+1] = columns
// -- for some 1 <= n <= columns+1
// end condition:
// 0 = codingLine[0] <= codingLine[1] < codingLine[2] < ...
// < codingLine[n-1] < codingLine[n] = columns
// -- where 1 <= n <= columns+1
for (i = 0; codingLine[i] < columns; ++i) {
refLine[i] = codingLine[i];
}
refLine[i++] = columns;
refLine[i] = columns;
codingLine[0] = 0;
a0i = 0;
b1i = 0;
blackPixels = 0;
// invariant:
// refLine[b1i-1] <= codingLine[a0i] < refLine[b1i] < refLine[b1i+1]
// <= columns
// exception at left edge:
// codingLine[a0i = 0] = refLine[b1i = 0] = 0 is possible
// exception at right edge:
// refLine[b1i] = refLine[b1i+1] = columns is possible
while (codingLine[a0i] < columns) {
refLine[i] = refLine[i + 1] = columns;
b1 = 1;
a0New = codingLine[a0 = 0] = 0;
do {
code1 = getTwoDimCode();
switch (code1) {
case twoDimPass:
addPixels(refLine[b1i + 1], blackPixels);
if (refLine[b1i + 1] < columns) {
b1i += 2;
if (refLine[b1] < columns) {
a0New = refLine[b1 + 1];
b1 += 2;
}
break;
case twoDimHoriz:
if ((a0 & 1) == 0) {
code1 = code2 = 0;
if (blackPixels) {
do {
code1 += code3 = getBlackCode();
code1 += code3 = getWhiteCode();
} while (code3 >= 64);
do {
code2 += code3 = getWhiteCode();
code2 += code3 = getBlackCode();
} while (code3 >= 64);
} else {
code1 = code2 = 0;
do {
code1 += code3 = getWhiteCode();
code1 += code3 = getBlackCode();
} while (code3 >= 64);
do {
code2 += code3 = getBlackCode();
code2 += code3 = getWhiteCode();
} while (code3 >= 64);
}
addPixels(codingLine[a0i] + code1, blackPixels);
if (codingLine[a0i] < columns) {
addPixels(codingLine[a0i] + code2, blackPixels ^ 1);
if (code1 > 0 || code2 > 0) {
if (a0New + code1 <= columns) {
codingLine[a0 + 1] = a0New + code1;
} else {
codingLine[a0 + 1] = columns;
}
while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
b1i += 2;
++a0;
if (codingLine[a0] + code2 <= columns) {
codingLine[a0 + 1] = codingLine[a0] + code2;
} else {
codingLine[a0 + 1] = columns;
}
break;
case twoDimVertR3:
addPixels(refLine[b1i] + 3, blackPixels);
blackPixels ^= 1;
if (codingLine[a0i] < columns) {
++b1i;
while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
b1i += 2;
++a0;
a0New = codingLine[a0];
while (refLine[b1] <= a0New && refLine[b1] < columns) {
b1 += 2;
}
}
break;
case twoDimVertR2:
addPixels(refLine[b1i] + 2, blackPixels);
blackPixels ^= 1;
if (codingLine[a0i] < columns) {
++b1i;
while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
b1i += 2;
case twoDimVert0:
if (refLine[b1] < columns) {
a0New = codingLine[++a0] = refLine[b1];
++b1;
while (refLine[b1] <= a0New && refLine[b1] < columns) {
b1 += 2;
}
} else {
a0New = codingLine[++a0] = columns;
}
break;
case twoDimVertR1:
addPixels(refLine[b1i] + 1, blackPixels);
blackPixels ^= 1;
if (codingLine[a0i] < columns) {
++b1i;
while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
b1i += 2;
if (refLine[b1] + 1 < columns) {
a0New = codingLine[++a0] = refLine[b1] + 1;
++b1;
while (refLine[b1] <= a0New && refLine[b1] < columns) {
b1 += 2;
}
} else {
a0New = codingLine[++a0] = columns;
}
break;
case twoDimVert0:
addPixels(refLine[b1i], blackPixels);
blackPixels ^= 1;
if (codingLine[a0i] < columns) {
++b1i;
while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
b1i += 2;
case twoDimVertL1:
if (refLine[b1] - 1 > a0New || (a0 == 0 && refLine[b1] == 1)) {
a0New = codingLine[++a0] = refLine[b1] - 1;
--b1;
while (refLine[b1] <= a0New && refLine[b1] < columns) {
b1 += 2;
}
}
break;
case twoDimVertL3:
addPixelsNeg(refLine[b1i] - 3, blackPixels);
blackPixels ^= 1;
if (codingLine[a0i] < columns) {
if (b1i > 0) {
--b1i;
} else {
++b1i;
}
while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
b1i += 2;
case twoDimVertR2:
if (refLine[b1] + 2 < columns) {
a0New = codingLine[++a0] = refLine[b1] + 2;
++b1;
while (refLine[b1] <= a0New && refLine[b1] < columns) {
b1 += 2;
}
} else {
a0New = codingLine[++a0] = columns;
}
break;
case twoDimVertL2:
addPixelsNeg(refLine[b1i] - 2, blackPixels);
blackPixels ^= 1;
if (codingLine[a0i] < columns) {
if (b1i > 0) {
--b1i;
} else {
++b1i;
}
while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
b1i += 2;
if (refLine[b1] - 2 > a0New || (a0 == 0 && refLine[b1] == 2)) {
a0New = codingLine[++a0] = refLine[b1] - 2;
--b1;
while (refLine[b1] <= a0New && refLine[b1] < columns) {
b1 += 2;
}
}
break;
case twoDimVertL1:
addPixelsNeg(refLine[b1i] - 1, blackPixels);
blackPixels ^= 1;
if (codingLine[a0i] < columns) {
if (b1i > 0) {
--b1i;
case twoDimVertR3:
if (refLine[b1] + 3 < columns) {
a0New = codingLine[++a0] = refLine[b1] + 3;
++b1;
while (refLine[b1] <= a0New && refLine[b1] < columns) {
b1 += 2;
}
} else {
++b1i;
a0New = codingLine[++a0] = columns;
}
while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
b1i += 2;
break;
case twoDimVertL3:
if (refLine[b1] - 3 > a0New || (a0 == 0 && refLine[b1] == 3)) {
a0New = codingLine[++a0] = refLine[b1] - 3;
--b1;
while (refLine[b1] <= a0New && refLine[b1] < columns) {
b1 += 2;
}
}
break;
case EOF:
addPixels(columns, 0);
eof = gTrue;
break;
codingLine[a0 = 0] = columns;
return EOF;
default:
error(getPos(), "Bad 2D code %04x in CCITTFax stream", code1);
addPixels(columns, 0);
err = gTrue;
break;
}
}
} while (codingLine[a0] < columns);
// 1-D encoding
} else {
codingLine[0] = 0;
a0i = 0;
blackPixels = 0;
while (codingLine[a0i] < columns) {
codingLine[a0 = 0] = 0;
while (1) {
code1 = 0;
if (blackPixels) {
do {
code1 += code3 = getBlackCode();
code1 += code3 = getWhiteCode();
} while (code3 >= 64);
} else {
codingLine[a0+1] = codingLine[a0] + code1;
++a0;
if (codingLine[a0] >= columns) {
break;
}
code2 = 0;
do {
code1 += code3 = getWhiteCode();
code2 += code3 = getBlackCode();
} while (code3 >= 64);
codingLine[a0+1] = codingLine[a0] + code2;
++a0;
if (codingLine[a0] >= columns) {
break;
}
addPixels(codingLine[a0i] + code1, blackPixels);
blackPixels ^= 1;
}
}
if (codingLine[a0] != columns) {
error(getPos(), "CCITTFax row is wrong length (%d)", codingLine[a0]);
// force the row to be the correct length
while (codingLine[a0] > columns) {
--a0;
}
codingLine[++a0] = columns;
err = gTrue;
}
// byte-align the row
if (byteAlign) {
inputBits &= ~7;
@ -1586,17 +1562,14 @@ int CCITTFaxStream::lookChar() {
// this if we know the stream contains end-of-line markers because
// the "just plow on" technique tends to work better otherwise
} else if (err && endOfLine) {
while (1) {
code1 = lookBits(13);
do {
if (code1 == EOF) {
eof = gTrue;
return EOF;
}
if ((code1 >> 1) == 0x001) {
break;
}
eatBits(1);
}
code1 = lookBits(13);
} while ((code1 >> 1) != 0x001);
eatBits(12);
if (encoding > 0) {
eatBits(1);
@ -1604,11 +1577,11 @@ int CCITTFaxStream::lookChar() {
}
}
// set up for output
if (codingLine[0] > 0) {
outputBits = codingLine[a0i = 0];
} else {
outputBits = codingLine[a0i = 1];
a0 = 0;
outputBits = codingLine[1] - codingLine[0];
if (outputBits == 0) {
a0 = 1;
outputBits = codingLine[2] - codingLine[1];
}
++row;
@ -1616,43 +1589,39 @@ int CCITTFaxStream::lookChar() {
// get a byte
if (outputBits >= 8) {
buf = (a0i & 1) ? 0x00 : 0xff;
outputBits -= 8;
if (outputBits == 0 && codingLine[a0i] < columns) {
++a0i;
outputBits = codingLine[a0i] - codingLine[a0i - 1];
ret = ((a0 & 1) == 0) ? 0xff : 0x00;
if ((outputBits -= 8) == 0) {
++a0;
if (codingLine[a0] < columns) {
outputBits = codingLine[a0 + 1] - codingLine[a0];
}
}
} else {
bits = 8;
buf = 0;
ret = 0;
do {
if (outputBits > bits) {
buf <<= bits;
if (!(a0i & 1)) {
buf |= 0xff >> (8 - bits);
}
outputBits -= bits;
i = bits;
bits = 0;
} else {
buf <<= outputBits;
if (!(a0i & 1)) {
buf |= 0xff >> (8 - outputBits);
if ((a0 & 1) == 0) {
ret |= 0xff >> (8 - i);
}
outputBits -= i;
} else {
i = outputBits;
bits -= outputBits;
outputBits = 0;
if (codingLine[a0i] < columns) {
++a0i;
outputBits = codingLine[a0i] - codingLine[a0i - 1];
} else if (bits > 0) {
buf <<= bits;
bits = 0;
if ((a0 & 1) == 0) {
ret |= (0xff >> (8 - i)) << bits;
}
outputBits = 0;
++a0;
if (codingLine[a0] < columns) {
outputBits = codingLine[a0 + 1] - codingLine[a0];
}
} while (bits);
}
if (black) {
buf ^= 0xff;
} while (bits > 0 && codingLine[a0] < columns);
}
buf = black ? (ret ^ 0xff) : ret;
return buf;
}
@ -1694,9 +1663,6 @@ short CCITTFaxStream::getWhiteCode() {
code = 0; // make gcc happy
if (endOfBlock) {
code = lookBits(12);
if (code == EOF) {
return 1;
}
if ((code >> 5) == 0) {
p = &whiteTab1[code];
} else {
@ -1709,9 +1675,6 @@ short CCITTFaxStream::getWhiteCode() {
} else {
for (n = 1; n <= 9; ++n) {
code = lookBits(n);
if (code == EOF) {
return 1;
}
if (n < 9) {
code <<= 9 - n;
}
@ -1723,9 +1686,6 @@ short CCITTFaxStream::getWhiteCode() {
}
for (n = 11; n <= 12; ++n) {
code = lookBits(n);
if (code == EOF) {
return 1;
}
if (n < 12) {
code <<= 12 - n;
}
@ -1751,12 +1711,9 @@ short CCITTFaxStream::getBlackCode() {
code = 0; // make gcc happy
if (endOfBlock) {
code = lookBits(13);
if (code == EOF) {
return 1;
}
if ((code >> 7) == 0) {
p = &blackTab1[code];
} else if ((code >> 9) == 0 && (code >> 7) != 0) {
} else if ((code >> 9) == 0) {
p = &blackTab2[(code >> 1) - 64];
} else {
p = &blackTab3[code >> 7];
@ -1768,9 +1725,6 @@ short CCITTFaxStream::getBlackCode() {
} else {
for (n = 2; n <= 6; ++n) {
code = lookBits(n);
if (code == EOF) {
return 1;
}
if (n < 6) {
code <<= 6 - n;
}
@ -1782,9 +1736,6 @@ short CCITTFaxStream::getBlackCode() {
}
for (n = 7; n <= 12; ++n) {
code = lookBits(n);
if (code == EOF) {
return 1;
}
if (n < 12) {
code <<= 12 - n;
}
@ -1798,9 +1749,6 @@ short CCITTFaxStream::getBlackCode() {
}
for (n = 10; n <= 13; ++n) {
code = lookBits(n);
if (code == EOF) {
return 1;
}
if (n < 13) {
code <<= 13 - n;
}
@ -2015,12 +1963,6 @@ void DCTStream::reset() {
// allocate a buffer for the whole image
bufWidth = ((width + mcuWidth - 1) / mcuWidth) * mcuWidth;
bufHeight = ((height + mcuHeight - 1) / mcuHeight) * mcuHeight;
if (bufWidth <= 0 || bufHeight <= 0 ||
bufWidth > INT_MAX / bufWidth / (int)sizeof(int)) {
error(getPos(), "Invalid image size in DCT stream");
y = height;
return;
}
for (i = 0; i < numComps; ++i) {
frameBuf[i] = (int *)gmallocn(bufWidth * bufHeight, sizeof(int));
memset(frameBuf[i], 0, bufWidth * bufHeight * sizeof(int));
@ -3096,11 +3038,6 @@ GBool DCTStream::readScanInfo() {
}
scanInfo.firstCoeff = str->getChar();
scanInfo.lastCoeff = str->getChar();
if (scanInfo.firstCoeff < 0 || scanInfo.lastCoeff > 63 ||
scanInfo.firstCoeff > scanInfo.lastCoeff) {
error(getPos(), "Bad DCT coefficient numbers in scan info block");
return gFalse;
}
c = str->getChar();
scanInfo.ah = (c >> 4) & 0x0f;
scanInfo.al = c & 0x0f;

@ -528,15 +528,13 @@ private:
int row; // current row
int inputBuf; // input buffer
int inputBits; // number of bits in input buffer
int *codingLine; // coding line changing elements
int *refLine; // reference line changing elements
int a0i; // index into codingLine
GBool err; // error on current line
short *refLine; // reference line changing elements
int b1; // index into refLine
short *codingLine; // coding line changing elements
int a0; // index into codingLine
int outputBits; // remaining ouput bits
int buf; // character buffer
void addPixels(int a1, int black);
void addPixelsNeg(int a1, int black);
short getTwoDimCode();
short getWhiteCode();
short getBlackCode();

@ -52,8 +52,6 @@ public:
// generation 0.
ObjectStream(XRef *xref, int objStrNumA);
GBool isOk() { return ok; }
~ObjectStream();
// Return the object number of this object stream.
@ -69,7 +67,6 @@ private:
int nObjects; // number of objects in the stream
Object *objs; // the objects (length = nObjects)
int *objNums; // the object numbers (length = nObjects)
GBool ok;
};
ObjectStream::ObjectStream(XRef *xref, int objStrNumA) {
@ -83,7 +80,6 @@ ObjectStream::ObjectStream(XRef *xref, int objStrNumA) {
nObjects = 0;
objs = NULL;
objNums = NULL;
ok = gFalse;
if (!xref->fetch(objStrNum, 0, &objStr)->isStream()) {
goto err1;
@ -109,13 +105,6 @@ ObjectStream::ObjectStream(XRef *xref, int objStrNumA) {
goto err1;
}
// this is an arbitrary limit to avoid integer overflow problems
// in the 'new Object[nObjects]' call (Acrobat apparently limits
// object streams to 100-200 objects)
if (nObjects > 1000000) {
error(-1, "Too many objects in an object stream");
goto err1;
}
objs = new Object[nObjects];
objNums = (int *)gmallocn(nObjects, sizeof(int));
offsets = (int *)gmallocn(nObjects, sizeof(int));
@ -172,10 +161,10 @@ ObjectStream::ObjectStream(XRef *xref, int objStrNumA) {
}
gfree(offsets);
ok = gTrue;
err1:
objStr.free();
return;
}
ObjectStream::~ObjectStream() {
@ -848,11 +837,6 @@ Object *XRef::fetch(int num, int gen, Object *obj) {
delete objStr;
}
objStr = new ObjectStream(this, e->offset);
if (!objStr->isOk()) {
delete objStr;
objStr = NULL;
goto err;
}
}
objStr->getObject(e->gen, num, obj);
break;

Loading…
Cancel
Save