diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2014-05-17 10:46:00 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2014-05-17 10:46:00 +0000 |
commit | 30186022e2b1ac6111c16238cc0750e3987a2174 (patch) | |
tree | efb8251871857dffed690c1c72d98f8eff7e40b4 /Build/source | |
parent | ef8d8f23a482058167f4aec6a2a771a862a34256 (diff) |
xpdfopen 0.84
git-svn-id: svn://tug.org/texlive/trunk@34078 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
-rwxr-xr-x | Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl | 29 | ||||
-rw-r--r-- | Build/source/utils/README | 2 | ||||
-rw-r--r-- | Build/source/utils/xpdfopen/ChangeLog | 15 | ||||
-rw-r--r-- | Build/source/utils/xpdfopen/Makefile.am | 6 | ||||
-rw-r--r-- | Build/source/utils/xpdfopen/Makefile.am.orig | 6 | ||||
-rw-r--r-- | Build/source/utils/xpdfopen/Makefile.in | 6 | ||||
-rw-r--r-- | Build/source/utils/xpdfopen/README | 34 | ||||
-rwxr-xr-x | Build/source/utils/xpdfopen/configure | 20 | ||||
-rw-r--r-- | Build/source/utils/xpdfopen/configure.ac | 4 | ||||
-rw-r--r-- | Build/source/utils/xpdfopen/externs.h | 24 | ||||
-rw-r--r-- | Build/source/utils/xpdfopen/pdfclose.c | 15 | ||||
-rw-r--r-- | Build/source/utils/xpdfopen/pdfopen-AR-7-and-8.c | 93 | ||||
-rw-r--r-- | Build/source/utils/xpdfopen/pdfopen.1 | 26 | ||||
-rw-r--r-- | Build/source/utils/xpdfopen/pdfopen.c | 189 | ||||
-rw-r--r-- | Build/source/utils/xpdfopen/utils.c | 5 | ||||
-rw-r--r-- | Build/source/utils/xpdfopen/utils.h | 4 | ||||
-rw-r--r-- | Build/source/utils/xpdfopen/xpdfopen.h | 4 |
17 files changed, 273 insertions, 209 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl b/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl index 157c9d960de..9f019d5796d 100755 --- a/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl +++ b/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl @@ -1,12 +1,12 @@ #!/usr/bin/env perl -# $Id: tlmgr.pl 34056 2014-05-16 05:12:27Z preining $ +# $Id: tlmgr.pl 34059 2014-05-16 18:34:14Z karl $ # # Copyright 2008-2014 Norbert Preining # This file is licensed under the GNU General Public License version 2 # or any later version. -my $svnrev = '$Revision: 34056 $'; -my $datrev = '$Date: 2014-05-16 07:12:27 +0200 (Fri, 16 May 2014) $'; +my $svnrev = '$Revision: 34059 $'; +my $datrev = '$Date: 2014-05-16 20:34:14 +0200 (Fri, 16 May 2014) $'; my $tlmgrrevision; my $prg; if ($svnrev =~ m/: ([0-9]+) /) { @@ -286,11 +286,12 @@ sub main { } if ($opts{"help"} || $opts{"h"}) { - # perldoc does ASCII emphasis on the output, so it's nice to use it. - # But not all Unix platforms have it, and on Windows our Config.pm - # can apparently interfere, so always skip it there. + # perldoc does ASCII emphasis on the output, and runs it through + # $PAGER, so people want it. But not all Unix platforms have it, + # and on Windows our Config.pm can apparently interfere, so always + # skip it there. Or if users have NOPERLDOC set in the environment. my @noperldoc = (); - if (win32()) { + if (win32() || $ENV{"NOPERLDOC"}) { @noperldoc = ("-noperldoc", "1"); } else { if (!TeXLive::TLUtils::which("perldoc")) { @@ -309,9 +310,10 @@ sub main { } } } - # in some cases LESSPIPE of less breaks control characters - # and the output of pod2usage is broken. - # We add/set LESS=-R in the environment and unset LESSPIPE to be sure + # less can break control characters and thus the output of pod2usage + # is broken. We add/set LESS=-R in the environment and unset + # LESSPIPE and LESSOPEN to try to help. + # if (defined($ENV{'LESS'})) { $ENV{'LESS'} .= " -R"; } else { @@ -6242,7 +6244,12 @@ revision number for the loaded TeX Live Perl modules are shown, too. =head2 help -Gives this help information (same as C<--help>). +Display this help information and exit (same as C<--help>, and on the +web at L<http://tug.org/texlive/doc/tlmgr.html>). Sometimes the +C<perldoc> and/or C<PAGER> programs on the system have problems, +resulting in control characters being literally output. This can't +always be detected, but you can set the C<NOPERLDOC> environment +variable and C<perldoc> will not be used. =head2 version diff --git a/Build/source/utils/README b/Build/source/utils/README index 28a74401ea9..b2f5e876e28 100644 --- a/Build/source/utils/README +++ b/Build/source/utils/README @@ -32,7 +32,7 @@ vlna 1.5 - checked 10may12 xindy - see just below -xpdfopen 0.83 - checked 10may12 +xpdfopen 0.84 - checked 17may14 http://mirror.ctan.org/support/xpdfopen/ http://cs.acadiau.ca/~jdiamond/xpdfopen/ diff --git a/Build/source/utils/xpdfopen/ChangeLog b/Build/source/utils/xpdfopen/ChangeLog index acca86064b2..65416356847 100644 --- a/Build/source/utils/xpdfopen/ChangeLog +++ b/Build/source/utils/xpdfopen/ChangeLog @@ -1,3 +1,15 @@ +2014-05-16 Jim Diamond <jim.diamond@acadiau.ca> + + * pdfopen.c: add -p option, update for externs.h + * pdfclose.c: update for externs.h + * utils.c: update for externs.h + * externs.h: add this for cleanliness + * pdfopen.1: update man page accordingly. + * xpdfopen.tex: remove from distribution, since it is now redundant + * configure.ac: update for V 0.84. + * README: update for V 0.84. + * Makefile.am update for externs.h, remove archaic pdfopen-AR-7-and-8.c + 2013-07-05 Peter Breitenlohner <peb@mppmu.mpg.de> * Makefile.am: Moved Makefile fragments to ../../am/. @@ -16,6 +28,7 @@ * utils.h: ... to here. 2012-01-28 Jim Diamond <jim.diamond@acadiau.ca> + * sendx.c: fix (kludgily?) reset_focus() so that it actually works. * pdfopen.c: add -r and -reset_focus options. * pdfopen.1: update man page accordingly. @@ -24,6 +37,7 @@ * README: update for V 0.83. 2011-05-28 Jim Diamond <jim.diamond@acadiau.ca> + * pdfopen.c: add -v and --version options. * pdfopen.1: create man page: thanks to Karl Berry for numerous suggestions and improvements. @@ -31,6 +45,7 @@ * configure.ac: update for V 0.82. 2011-05-17 Jim Diamond <jim.diamond@acadiau.ca> + * pdfopen.c: add -h and --help options. Reformat usage information. Add support for evince. diff --git a/Build/source/utils/xpdfopen/Makefile.am b/Build/source/utils/xpdfopen/Makefile.am index 0e1a2e6909a..56c8350f6e7 100644 --- a/Build/source/utils/xpdfopen/Makefile.am +++ b/Build/source/utils/xpdfopen/Makefile.am @@ -1,6 +1,6 @@ ## Makefile.am for the TeX Live subdirectory utils/xpdfopen/ ## -## Copyright (C) 2009-2012 Peter Breitenlohner <tex-live@tug.org> +## Copyright (C) 2009-2014 Peter Breitenlohner <tex-live@tug.org> ## You may freely use, modify and/or distribute this file. ## ACLOCAL_AMFLAGS = -I ../../m4 @@ -12,7 +12,7 @@ LDADD = $(X_LIBS) -lX11 -lXmu $(X_EXTRA_LIBS) bin_PROGRAMS = pdfopen pdfclose -common_sources = sendx.c sendx.h utils.c utils.h xpdfopen.h +common_sources = externs.h sendx.c sendx.h utils.c utils.h xpdfopen.h pdfopen_SOURCES = pdfopen.c $(common_sources) @@ -31,7 +31,5 @@ uninstall-hook: uninstall-man1-links EXTRA_DIST = xpdfopen.pdf xpdfopen.tex -EXTRA_DIST += pdfopen-AR-7-and-8.c - EXTRA_DIST += Makefile.am.orig configure.ac.orig diff --git a/Build/source/utils/xpdfopen/Makefile.am.orig b/Build/source/utils/xpdfopen/Makefile.am.orig index cf371f66516..b41b46db6b7 100644 --- a/Build/source/utils/xpdfopen/Makefile.am.orig +++ b/Build/source/utils/xpdfopen/Makefile.am.orig @@ -9,12 +9,10 @@ AM_CFLAGS += -Wcast-align -Wwrite-strings -Wold-style-definition LDADD = $(X_LIBS) -lX11 -lXmu $(X_EXTRA_LIBS) -EXTRA_DIST = pdfopen-AR-7-and-8.c - bin_PROGRAMS = pdfopen pdfclose -pdfopen_SOURCES = pdfopen.c sendx.c utils.c sendx.h xpdfopen.h utils.h +pdfopen_SOURCES = externs.h pdfopen.c sendx.c utils.c sendx.h xpdfopen.h utils.h -pdfclose_SOURCES = pdfclose.c sendx.c utils.c sendx.h xpdfopen.h utils.h +pdfclose_SOURCES = externs.h pdfclose.c sendx.c utils.c sendx.h xpdfopen.h utils.h diff --git a/Build/source/utils/xpdfopen/Makefile.in b/Build/source/utils/xpdfopen/Makefile.in index a011f0791c3..737efaa7db8 100644 --- a/Build/source/utils/xpdfopen/Makefile.in +++ b/Build/source/utils/xpdfopen/Makefile.in @@ -312,15 +312,15 @@ ACLOCAL_AMFLAGS = -I ../../m4 AM_CPPFLAGS = $(X_CFLAGS) AM_CFLAGS = $(WARNING_CFLAGS) LDADD = $(X_LIBS) -lX11 -lXmu $(X_EXTRA_LIBS) -common_sources = sendx.c sendx.h utils.c utils.h xpdfopen.h +common_sources = externs.h sendx.c sendx.h utils.c utils.h xpdfopen.h pdfopen_SOURCES = pdfopen.c $(common_sources) pdfclose_SOURCES = pdfclose.c $(common_sources) dist_man1_MANS = pdfopen.1 # Symlinks within $(man1dir): FILE:LINK indicates LINK.1->FILE.1 man1_links = pdfopen:pdfclose -EXTRA_DIST = xpdfopen.pdf xpdfopen.tex pdfopen-AR-7-and-8.c \ - Makefile.am.orig configure.ac.orig +EXTRA_DIST = xpdfopen.pdf xpdfopen.tex Makefile.am.orig \ + configure.ac.orig all: all-am .SUFFIXES: diff --git a/Build/source/utils/xpdfopen/README b/Build/source/utils/xpdfopen/README index 6d0e35b29ef..2b25b7782fa 100644 --- a/Build/source/utils/xpdfopen/README +++ b/Build/source/utils/xpdfopen/README @@ -1,5 +1,5 @@ --------------------------------------------------------------------------- -xpdfopen 0.83 - Send open/close commands to Acrobat Reader, xpdf and evince +xpdfopen 0.84 - Send open/close commands to Acrobat Reader, xpdf and evince --------------------------------------------------------------------------- This is a Linux (X11) implementation of Fabrice Popineau's pdfclose/ @@ -9,20 +9,20 @@ The libX code was borrowed from Reinhard Fobbe's Sendx library for Tcl/Tk, and the programs use the same license, copied below. Version 0.3 adds support for Adobe Reader 7.0 for Linux. -(different window titles and key shortcuts) + (different window titles and key shortcuts) Version 0.4 uses autoconf -Version 0.5 fixes an incorrect autoconf variable, supports -building under X11R5, handles pathnames on the command-line, -and fixes a bug where pdfopen did not exit correctly after -(automatically) starting acroread. +Version 0.5 fixes an incorrect autoconf variable, supports building + under X11R5, handles pathnames on the command-line, and + fixes a bug where pdfopen did not exit correctly after + (automatically) starting acroread. Version 0.51 uses the strrchr() function instead of rindex() -to allow compilation on non-BSD derived unix platforms. + to allow compilation on non-BSD derived unix platforms. Version 0.61 attempts to do something useful with Adobe Reader 8, -even though it is impossible to restore the viewport. + even though it is impossible to restore the viewport. Version 0.80 adds an implementation for AR 9 and xpdf. @@ -32,6 +32,9 @@ Version 0.82 adds a man page and -v/--version options for pdfopen. Version 0.83 adds the -r/-reset_focus option for pdfopen. +Version 0.84 adds 'load at given page' support (-p option) for Adobe + Reader 9, evince (at least 3.12, maybe earlier) and xpdf. + The AR command lines do not behave precisely the same as under Windows, because the Linux Reader behaves somewhat differently: it is not @@ -40,7 +43,10 @@ scriptable, but it is possible to 'fake' key-presses. pdfopen has the following call sequence: pdfopen [-r|-reset_focus] \ - [-viewer <ar9|ar9-tab|ar8|ar7|ar5|xpdf|evince>] <pdf file name> + [-viewer <ar9|ar9-tab|ar8|ar7|ar5|xpdf|evince>] \ + [-p <page number>] \ + <pdf file name> + The 'ar9' version uses the '-openInNewInstance' option, the 'ar9-tab' version does not (so if there is already an AR9 window open, a new tab will be opened in that window). @@ -52,7 +58,7 @@ This program closes an existing AR5, AR7, AR8, AR9, xpdf or evince window displaying the given PDF file. -Version 0.83 compiles on Linux (Slackware64 13.37, anyway) with +Version 0.84 compiles on Linux (Slackware64 14.1, anyway) with the following command: gcc -Wall pdfopen.c sendx.c utils.c -o pdfopen -lX11 -s should you not want to go through the process of creating and running @@ -62,8 +68,8 @@ a configure program. Taco Hoekwater <taco@metatex.org> (Version(s) up to 0.61) Dordrecht, The Netherlands, December 2008. -Jim Diamond <jim.diamond@acadiau.ca> (Version 0.80, 0.81, 0.82 and 0.83) -Acadia University, Wolfville, Nova Scotia, Canada; May 2011. +Jim Diamond <jim.diamond@acadiau.ca> (Version 0.80 through 0.84) +Acadia University, Wolfville, Nova Scotia, Canada; May 2014. @@ -92,6 +98,6 @@ POSSIBILITY OF SUCH DAMAGE. THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND -NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" -BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE +NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND +THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. diff --git a/Build/source/utils/xpdfopen/configure b/Build/source/utils/xpdfopen/configure index b27ccaa2d50..55b0867418f 100755 --- a/Build/source/utils/xpdfopen/configure +++ b/Build/source/utils/xpdfopen/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for xpdfopen (TeX Live) 0.83. +# Generated by GNU Autoconf 2.69 for xpdfopen (TeX Live) 0.84. # # Report bugs to <tex-k@tug.org>. # @@ -579,8 +579,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='xpdfopen (TeX Live)' PACKAGE_TARNAME='xpdfopen--tex-live-' -PACKAGE_VERSION='0.83' -PACKAGE_STRING='xpdfopen (TeX Live) 0.83' +PACKAGE_VERSION='0.84' +PACKAGE_STRING='xpdfopen (TeX Live) 0.84' PACKAGE_BUGREPORT='tex-k@tug.org' PACKAGE_URL='' @@ -1240,7 +1240,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures xpdfopen (TeX Live) 0.83 to adapt to many kinds of systems. +\`configure' configures xpdfopen (TeX Live) 0.84 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1311,7 +1311,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of xpdfopen (TeX Live) 0.83:";; + short | recursive ) echo "Configuration of xpdfopen (TeX Live) 0.84:";; esac cat <<\_ACEOF @@ -1414,7 +1414,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -xpdfopen (TeX Live) configure 0.83 +xpdfopen (TeX Live) configure 0.84 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1619,7 +1619,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by xpdfopen (TeX Live) $as_me 0.83, which was +It was created by xpdfopen (TeX Live) $as_me 0.84, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3542,7 +3542,7 @@ fi # Define the identity of the package. PACKAGE='xpdfopen--tex-live-' - VERSION='0.83' + VERSION='0.84' cat >>confdefs.h <<_ACEOF @@ -5868,7 +5868,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by xpdfopen (TeX Live) $as_me 0.83, which was +This file was extended by xpdfopen (TeX Live) $as_me 0.84, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -5925,7 +5925,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -xpdfopen (TeX Live) config.status 0.83 +xpdfopen (TeX Live) config.status 0.84 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/Build/source/utils/xpdfopen/configure.ac b/Build/source/utils/xpdfopen/configure.ac index 5e04706439b..ad638dd35ae 100644 --- a/Build/source/utils/xpdfopen/configure.ac +++ b/Build/source/utils/xpdfopen/configure.ac @@ -1,12 +1,12 @@ dnl Process this file with autoconf to produce a configure script. dnl -dnl Copyright (C) 2009-2013 Peter Breitenlohner <tex-live@tug.org> +dnl Copyright (C) 2009-2014 Peter Breitenlohner <tex-live@tug.org> dnl dnl This file is free software; the copyright holder dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl -AC_INIT([xpdfopen (TeX Live)], [0.83], [tex-k@tug.org]) +AC_INIT([xpdfopen (TeX Live)], [0.84], [tex-k@tug.org]) AC_PREREQ([2.65]) AC_CONFIG_SRCDIR([pdfopen.c]) AC_CONFIG_AUX_DIR([../../build-aux]) diff --git a/Build/source/utils/xpdfopen/externs.h b/Build/source/utils/xpdfopen/externs.h new file mode 100644 index 00000000000..2aff4f858ef --- /dev/null +++ b/Build/source/utils/xpdfopen/externs.h @@ -0,0 +1,24 @@ +/* + * externs.h: This file defines or declares (depending on whether + * DEFINE_EXTERNS is defined) all of the global variables + * and constants used by pdfopen and pdfclose. + * + * Copyright (C) 2014 Jim Diamond <jim.diamond@acadiau.ca> + * You may freely use, modify and/or distribute this file. + * + * This file new in Version 0.84 of pdfopen (2014/05/16). + */ + + +#ifndef EXTERNS_H +#define EXTERNS_H + +#ifdef DEFINE_EXTERNS +#define EXTERN +#else +#define EXTERN extern +#endif + +EXTERN char * progname; + +#endif diff --git a/Build/source/utils/xpdfopen/pdfclose.c b/Build/source/utils/xpdfopen/pdfclose.c index 958f882beb0..1fe905e1e9b 100644 --- a/Build/source/utils/xpdfopen/pdfclose.c +++ b/Build/source/utils/xpdfopen/pdfclose.c @@ -1,14 +1,12 @@ /* - * pdfclose.c + * pdfclose.c: (attempt to) close a PDF viewer displaying argv[1]. * * Modified by Jim Diamond (jim.diamond@acadiau.ca) 2010/04/21 (V 0.80) - * and again 2011/05/17 (V 0.81, V 0.82) + * and again 2011/05/17 (V 0.81 -- 0.84) * and Peter Breitenlohner <tex-live@tug.org> (2009). * * This program does not take a viewer argument, and just tries to close * any known viewer displaying the given file. - * - * V 0.82 */ #include <stdio.h> @@ -20,11 +18,8 @@ #include "xpdfopen.h" #include "utils.h" -#define VERSION "0.83" - -char * progname; /* set in main(); NOT static! */ - - +#define DEFINE_EXTERNS +#include "externs.h" static void usage(void) @@ -64,7 +59,7 @@ main (int argc, char * argv[]) return EXIT_FAILURE; } - if (try_name(argv[1], AR9_WIN_NAME_FMT)) /* both AR8 and AR9 */ + if (try_name(argv[1], AR9_WIN_NAME_FMT)) /* This gets both AR8 & AR9 */ if (try_name(argv[1], XPDF_WIN_NAME_FMT)) if (try_name(argv[1], AR7_WIN_NAME_FMT)) if (try_name(argv[1], AR5_WIN_NAME_FMT)) diff --git a/Build/source/utils/xpdfopen/pdfopen-AR-7-and-8.c b/Build/source/utils/xpdfopen/pdfopen-AR-7-and-8.c deleted file mode 100644 index 3e6900307a9..00000000000 --- a/Build/source/utils/xpdfopen/pdfopen-AR-7-and-8.c +++ /dev/null @@ -1,93 +0,0 @@ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/wait.h> - -/* returns 1 on failure */ -extern int sendx_control_token(char *,char *); -extern int sendx_alt_token(char *,char *); - -void usage (void) { - puts ("pdfopen 0.61: you are mistaking me for an actual program.\n"); - puts(" pdfopen [--file filename.pdf]"); - puts ("\nusing no arguments tells the Reader to 'go back'.\n"); -} - -#define READERFIVE "Acrobat Reader" -#define READERNAME "Adobe Reader" -#define READERWINPREFIX "Adobe Reader - " -#define READERWINPOSTFIX " - Adobe Reader" -#define SUCCESS(a) (!a) - -int main (int argc, char **argv){ - char *newargv[3]; - char *winname, *win8name; - char *filename; - char *basefile; - pid_t reader; - if (argc == 5 && - (strcmp(argv[3],"--page") == 0 - && strcmp(argv[1],"--file") == 0 )) { - argc = 3; - } - if (argc == 3 && strcmp(argv[1],"--file") == 0) { - filename = malloc(strlen(argv[2])+1); - basefile = malloc(strlen(argv[2])+1); - if (filename == NULL || basefile == NULL) { - puts ("out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy(filename,argv[2]); - strcpy(basefile,filename); - if (strrchr(basefile,'/')) - basefile = strrchr(basefile,'/')+1; - - winname = malloc(strlen(basefile)+1+strlen(READERWINPREFIX)); - win8name = malloc(strlen(basefile)+1+strlen(READERWINPOSTFIX)); - if (winname == NULL || win8name == NULL) { - puts ("out of memory\n"); - exit(EXIT_FAILURE); - } - strcpy (winname,READERWINPREFIX); - strcpy ((winname+strlen(READERWINPREFIX)), basefile); - strcpy (win8name,basefile); - strcpy ((win8name+strlen(basefile)), READERWINPOSTFIX); - if (SUCCESS(sendx_control_token("W",winname)) || /* that's seven */ - SUCCESS(sendx_control_token("W",win8name))) { /* that's eight */ - sendx_alt_token("Left",READERNAME); /* seven or eight */ - sendx_control_token("Left",READERNAME); /* that's seven, with artificial five keymaps */ - } else if (SUCCESS(sendx_control_token("W",filename))) { - sendx_control_token("Left",READERFIVE); /* that's five */ - } else if (SUCCESS(sendx_control_token("W",basefile))) { - sendx_control_token("Left",READERFIVE); /* that's five */ - } else { - if((reader = fork()) >= 0) { - if (reader) { - waitpid(reader,NULL,WNOHANG); - } else { - newargv[0] = "acroread"; - newargv[1] = filename; - newargv[2] = NULL; - if(execvp("acroread",newargv)) { - puts ("acroread startup failed\n"); - exit(EXIT_FAILURE); - } - } - } else { - puts ("fork failed\n"); - exit(EXIT_FAILURE); - } - } - } else if (argc != 1) { - usage(); - } else { - sendx_alt_token("Left",READERNAME); - sendx_control_token("Left",READERNAME); /* that's seven */ - sendx_control_token("Left",READERFIVE); - } - exit(EXIT_SUCCESS); -} - diff --git a/Build/source/utils/xpdfopen/pdfopen.1 b/Build/source/utils/xpdfopen/pdfopen.1 index 82239785469..c70cbe9594e 100644 --- a/Build/source/utils/xpdfopen/pdfopen.1 +++ b/Build/source/utils/xpdfopen/pdfopen.1 @@ -1,5 +1,5 @@ .\" This manpage is licensed under the GNU Public License -.TH PDFOPEN 1 2012-01-28 "pdfopen 0.83" "" +.TH PDFOPEN 1 2014-05-16 "pdfopen 0.84" "" . .SH NAME pdfopen, pdfclose \- open or close a PDF file viewer @@ -20,6 +20,11 @@ output help and exit .B -v, --version output the version number and exit .TP +.B -p <n> +when starting the viewer, display page <n> of the document (notes: not +all viewers support this feature, and even in those cases this option +only has effect when the document is initially loaded) +.TP .B -r, --reset_focus after sending commands to the PDF viewer, attempt to reset the input focus to the window which had focus before the commands were sent @@ -69,7 +74,7 @@ document vary from one version of \fBacroread\fP to another; consequently, if you are using a version of \fBacroread\fP other than AR9, you should explicitly specify the viewer program. -Version 0.83 of \fBpdfopen\fP accepts the following viewer options: +Version 0.84 of \fBpdfopen\fP accepts the following viewer options: .br \fIar9\fP, \fIar9-tab\fP, \fIar8\fP, \fIar7\fP, \fIar5\fP, \fIxpdf\fP, and \fIevince\fP. @@ -90,19 +95,7 @@ PDF viewer continues to run, possibly now displaying just a blank window. (This behaviour varies somewhat from one PDF viewer to another.) . .SH PORTABILITY AND AVAILABILITY -Users familiar with the Windows version of -.B pdfopen -might wonder about the lack of a -.B --page -.IR <pagenumber> -option. Unfortunately, to date no GNU/Linux versions of -.B acroread -support this feature. Anyone having a friend at Adobe is encouraged -to ask them to implement a -"\fB-page \fP\fI<pagenumber>\fP" -command line option for \fBacroread\fP. - -These programs have been tested on Slackware64 Version 13.37 and a few +These programs have been tested on Slackware64 Version 14.1 and a few other versions / distributions of GNU/Linux. The code is reasonably generic and should work out of the box using most recent X11 implementations. (Reports to the contrary are welcome, particularly @@ -157,4 +150,5 @@ and upon which these programs were originally based. Taco Hoekwater created the GNU/Linux versions, up to Version 0.61 (including some documentation which inspired parts of this man page). - +Peter Breitenlohner has contributed both code and suggestions to +versions later than 0.61. diff --git a/Build/source/utils/xpdfopen/pdfopen.c b/Build/source/utils/xpdfopen/pdfopen.c index a8d5775bdc8..2575e8d4bbf 100644 --- a/Build/source/utils/xpdfopen/pdfopen.c +++ b/Build/source/utils/xpdfopen/pdfopen.c @@ -2,7 +2,7 @@ * pdfopen.c. * * Heavily modified by Jim Diamond (jim.diamond@acadiau.ca) 2010/04/11 - * to work with AR 9 and xpdf. + * to work with AR 9, xpdf and evince. * (Also some mods by Peter Breitenlohner <tex-live@tug.org> from 2009 * and suggestions from 2010, and some suggestions from Karl Berry * (2011).) @@ -15,6 +15,9 @@ * * Further modified 2010/05/03 to work with ar5, and to include some code * that does *not* work with okular (see note below). + * + * Modified 2014/05/16 (V 0.84) to add capability to open a pdf file + * at a specified page (currently working with AR9, xpdf and evince). * * Note 3: Unlike xpdf and AR[5,7,8,9], okular will not accept X events * from this program unless the okular window has focus. On my system @@ -24,8 +27,6 @@ * please send it to me for inclusion. */ -#define VERSION "0.83" - #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -37,8 +38,15 @@ #include "xpdfopen.h" #include "utils.h" -#define MAX_OPTIONS 10 -#define MAX_RELOAD_CMDS 10 +#define DEFINE_EXTERNS +#include "externs.h" + +#define MAX_RELOAD_CMDS 10 +#define MAX_PRE_PAGE_OPTIONS 2 /* See struct defn below */ +#define MAX_POST_PAGE_OPTIONS 1 /* See struct defn below */ + /* Overkill ... */ +#define MAX_OPTIONS (10 + MAX_PRE_PAGE_OPTIONS \ + + MAX_POST_PAGE_OPTIONS) /* A string unlikely to be used as a real command by a PDF viewer */ #define FORK_EXEC_CMD "*FORK EXEC*" @@ -81,6 +89,20 @@ typedef struct const char * exec_pre_options[MAX_OPTIONS]; /* before filename in cmd */ const char * exec_post_options[MAX_OPTIONS];/* after filename in cmd */ const char * reload_cmds[MAX_RELOAD_CMDS]; /* cmds to reload a file */ + /* + * If the page number goes before the filename, use these options. + * The last one must be a printf format string with a %d and + * no other conversions specs. + * End list with a NULL. + */ + const char * initial_page_pre_options[MAX_PRE_PAGE_OPTIONS + 1]; /* */ + /* + * If the page number goes after the filename, use these options. + * The last one must be a printf format string with a %d and + * no other conversions specs. + * End list with a NULL. + */ + const char * initial_page_post_options[MAX_POST_PAGE_OPTIONS + 1]; /* */ } pdf_viewer_t; @@ -97,33 +119,49 @@ typedef struct /* * The first struct represents the default viewer with the default options. */ +static pdf_viewer_t pdf_viewers[] = { {"ar9", "acroread", USE_SENDX, AR9_WIN_NAME, AR9_WIN_NAME_FMT, {"-openInNewInstance", NULL}, {NULL}, - {"Ctrl-R", NULL}}, + {"Ctrl-R", NULL}, + {"/a", "page=%d", NULL}, + {NULL} + }, {"ar9-tab", "acroread", USE_SENDX, AR9_WIN_NAME, AR9_WIN_NAME_FMT, {NULL}, {NULL}, - {"Ctrl-R", NULL}}, + {"Ctrl-R", NULL}, + {NULL}, + {NULL} + }, {"ar8", "acroread", USE_SENDX, AR8_WIN_NAME, AR8_WIN_NAME_FMT, {NULL}, {NULL}, - {"Ctrl-W", FORK_EXEC_CMD, NULL}}, + {"Ctrl-W", FORK_EXEC_CMD, NULL}, + {NULL}, + {NULL} + }, {"ar7", "acroread", USE_SENDX, AR7_WIN_NAME, AR7_WIN_NAME_FMT, {NULL}, {NULL}, - {"Ctrl-W", "Alt-Left", NULL}}, + {"Ctrl-W", "Alt-Left", NULL}, + {NULL}, + {NULL} + }, {"ar5", "acroread", USE_SENDX, AR5_WIN_NAME, AR5_WIN_NAME_FMT, {NULL}, {NULL}, - {"Ctrl-W", "Alt-Left", NULL}}, + {"Ctrl-W", "Alt-Left", NULL}, + {NULL}, + {NULL} + }, /* * xpdf also allows 'xpdf -remote tex -reload', but if that xpdf server * is not running, rather than a failure return, a blank window is @@ -134,23 +172,30 @@ pdf_viewer_t pdf_viewers[] = XPDF_WIN_NAME, XPDF_WIN_NAME_FMT, {"-remote", "tex-server", NULL}, {NULL}, - {"r", NULL}}, + {"r", NULL}, + {NULL}, + {"%d", NULL} + }, {"evince", "evince", USE_SENDX, EVINCE_WIN_NAME, EVINCE_WIN_NAME_FMT, {NULL}, {NULL}, - {"Ctrl-R", NULL}}, + {"Ctrl-R", NULL}, + {"-i", "%d", NULL}, + {NULL} + }, #ifdef TRY_OCULAR {"okular", "okular", USE_SENDX, OKULAR_WIN_NAME, OKULAR_WIN_NAME_FMT, {NULL}, {NULL}, - {FOCUS_IN, "Fn-F5", FOCUS_OUT, NULL}}, + {FOCUS_IN, "Fn-F5", FOCUS_OUT, NULL}, + {NULL}, + {NULL} + }, #endif }; -char * progname; /* set in main(); NOT static! */ - #define DEFAULT_VIEWER (pdf_viewers[0].short_name) @@ -168,14 +213,17 @@ usage(void) fprintf(stderr, " %s [-v|--version]\n", progname); fprintf(stderr, " Show the version number and exit.\n"); - fprintf(stderr, " %s [-r|--reset_focus] [-viewer <prog>] <file.pdf>\n", - progname); + fprintf(stderr, " %s [-r|--reset_focus] [-viewer <prog>] [-p <n>] " + "<file.pdf>\n", progname); fprintf(stderr, " If the PDF viewer <prog> is displaying <file.pdf>, " "reload that file.\n"); fprintf(stderr, " Otherwise call <prog> to display <file.pdf>.\n"); fprintf(stderr, " If '-r' or '--reset_focus' is used, attempt to"); fprintf(stderr, " reset the input focus\n"); fprintf(stderr, " after calling the viewer program.\n"); + fprintf(stderr, " If the viewer allows it and is not already\n"); + fprintf(stderr, " running, the argument of -p specifies the\n"); + fprintf(stderr, " first page to display.\n"); fprintf(stderr, " The default viewer program is %s.\n", DEFAULT_VIEWER); fprintf(stderr, " Implemented viewers:"); for (i = 0; i < viewers - 1; i++) @@ -250,7 +298,8 @@ send_command(const char * window_name, const char * reload_cmd) */ static int -view_file(const char * filename, int viewer_index, int focus_reset) +view_file(const char * filename, int viewer_index, int focus_reset, + int initial_page) { char * window_name; pid_t pid; @@ -327,10 +376,61 @@ view_file(const char * filename, int viewer_index, int focus_reset) argv_list[i++] = pdf_viewer.program_name; for (p = pdf_viewer.exec_pre_options; *p;) argv_list[i++] = *p++; + + if (pdf_viewer.initial_page_pre_options[0] != NULL) + { + int j = 0; + char * buf; + + while (pdf_viewer.initial_page_pre_options[j + 1] != NULL) + argv_list[i++] = pdf_viewer.initial_page_pre_options[j++]; + + /* 10 is more than enough for the page number */ + buf = malloc(strlen(pdf_viewer.initial_page_pre_options[j]) + 10); + if (buf != NULL) + { + /* 1e8 or more pages? I doubt it. */ + sprintf(buf, pdf_viewer.initial_page_pre_options[j], + initial_page > 99999999 ? 1 : initial_page); + argv_list[i++] = buf; + } + else + fprintf(stderr, "%s: unable to allocate memory for page " + "specification!!\n" + "Crossing fingers and continuing.", progname); + } + argv_list[i++] = filename; - for (p = pdf_viewer.exec_post_options; *p;) - argv_list[i++] = *p++; + + if (pdf_viewer.initial_page_post_options[0] != NULL) + { + int j = 0; + char * buf; + + while (pdf_viewer.initial_page_post_options[j + 1] != NULL) + argv_list[i++] = pdf_viewer.initial_page_post_options[j++]; + + buf = malloc(strlen(pdf_viewer.initial_page_post_options[j]) + 10); + if (buf != NULL) + { + sprintf(buf, pdf_viewer.initial_page_post_options[j], + initial_page > 99999999 ? 1 : initial_page); + argv_list[i++] = buf; + } + else + fprintf(stderr, "%s: unable to allocate memory for page " + "specification!!\n" + "Crossing fingers and continuing.", progname); + } + argv_list[i++] = NULL; +#ifdef DEBUG + { + int k = 0; + for (; k < i-1; k++) + fprintf(stderr, "%s\n", argv_list[k]); + } +#endif if (execvp(pdf_viewer.program_name, (char **)argv_list)) { fprintf(stderr, "%s: %s startup failed\n", progname, @@ -355,44 +455,63 @@ main(int argc, char * argv[]) const char * viewer = pdf_viewers[0].short_name; char * env_viewer; int i; + int initial_page = 1; int viewer_index = -1; int focus_reset = 0; progname = argv[0]; + argc--; + argv++; env_viewer = getenv("PDF_VIEWER"); if (env_viewer != NULL) viewer = env_viewer; - if (argc < 2 || !strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) + if (argc < 1 || !strcmp(argv[0], "-h") || !strcmp(argv[0], "--help")) { usage(); return argc < 2 ? EXIT_FAILURE : EXIT_SUCCESS; } - if (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version")) + if (!strcmp(argv[0], "-v") || !strcmp(argv[0], "--version")) { printf("This is pdfopen version %s\n", VERSION); return EXIT_SUCCESS; } - if (!strcmp(argv[1], "--reset_focus") || !strcmp(argv[1], "-r")) + while (argc > 0) { - argc--; - argv++; - focus_reset = 1; - } + if (!strcmp(argv[0], "--reset_focus") || !strcmp(argv[0], "-r")) + { + argc--; + argv++; + focus_reset = 1; + continue; + } - if (argc == 4 && !strcmp(argv[1], "-viewer")) - { - viewer = argv[2]; - argc -= 2; - argv += 2; + if (argc >= 2 && !strcmp(argv[0], "-viewer")) + { + viewer = argv[1]; + argc -= 2; + argv += 2; + continue; + } + + if (argc >= 2 && !strcmp(argv[0], "-p")) + { + initial_page = atoi(argv[1]); + argc -= 2; + argv += 2; + continue; + } + + break; } - if (argc != 2) + /* Should only have 1 filename left now */ + if (argc != 1) { - fprintf(stderr, "%s: invalid number of arguments\n", progname); + fprintf(stderr, "%s: invalid argument(s)\n", progname); usage(); return EXIT_FAILURE; } @@ -414,7 +533,7 @@ main(int argc, char * argv[]) return EXIT_FAILURE; } - if (view_file(argv[1], viewer_index, focus_reset)) + if (view_file(argv[0], viewer_index, focus_reset, initial_page)) return EXIT_FAILURE; return EXIT_SUCCESS; diff --git a/Build/source/utils/xpdfopen/utils.c b/Build/source/utils/xpdfopen/utils.c index 3ec2844bf5e..5201b2dba58 100644 --- a/Build/source/utils/xpdfopen/utils.c +++ b/Build/source/utils/xpdfopen/utils.c @@ -1,7 +1,7 @@ /* - * utils.c: Items common to pdfopen and pdfclose. + * utils.c: Functions common to pdfopen and pdfclose. * - * Copyright (C) 2010, 2012 Jim Diamond <jim.diamond@acadiau.ca> + * Copyright (C) 2010--2014 Jim Diamond <jim.diamond@acadiau.ca> * You may freely use, modify and/or distribute this file. */ @@ -10,6 +10,7 @@ #include <string.h> #include "utils.h" #include "xpdfopen.h" +#include "externs.h" /* * Allocate memory and create a window name. diff --git a/Build/source/utils/xpdfopen/utils.h b/Build/source/utils/xpdfopen/utils.h index 8c8f6566c70..b9fe88574cb 100644 --- a/Build/source/utils/xpdfopen/utils.h +++ b/Build/source/utils/xpdfopen/utils.h @@ -1,15 +1,13 @@ /* * utils.h: declare prototypes for functions defined in utils.c * - * Copyright (C) 2010, 2012 Jim Diamond <jim.diamond@acadiau.ca> + * Copyright (C) 2010--2014 Jim Diamond <jim.diamond@acadiau.ca> * You may freely use, modify and/or distribute this file. */ #ifndef UTILS_H #define UTILS_H -extern char * progname; - char * make_window_name(const char * fmt, const char * basename); #endif diff --git a/Build/source/utils/xpdfopen/xpdfopen.h b/Build/source/utils/xpdfopen/xpdfopen.h index 51adecb0dcd..cf7e4f8c3f6 100644 --- a/Build/source/utils/xpdfopen/xpdfopen.h +++ b/Build/source/utils/xpdfopen/xpdfopen.h @@ -1,7 +1,7 @@ /* * xpdfopen.h: declare constants of possible use for xpdfopen programs. * - * Copyright (C) 2010 Jim Diamond <jim.diamond@acadiau.ca> + * Copyright (C) 2010--2014 Jim Diamond <jim.diamond@acadiau.ca> * * You may freely use, modify and/or distribute this file. */ @@ -9,6 +9,8 @@ #ifndef XPDFOPEN_H #define XPDFOPEN_H +#define VERSION "0.84" + /* * <prog>_WIN_NAME is the name of the window when no file is open. * <prog>_WIN_NAME_FMT is the (sprintf) format to generate the name |