diff options
| author | Pi-Cla <pirateclip@protonmail.com> | 2022-05-05 00:05:22 -0600 |
|---|---|---|
| committer | Vedang Manerikar <ved.manerikar@gmail.com> | 2022-05-21 20:06:15 -0400 |
| commit | 97a298192978788db9adbe723b1aa384e2ddf638 (patch) | |
| tree | b1aa4af1f458477e126a008dfbf8db05b04d2f98 /server | |
| parent | fedd930a09a497c03df3ce5204ccbd80da724662 (diff) | |
Remove usage of all private poppler headers in pdf-tools
This commit also removes C++ entirely, as it is not needed anymore for
correct compilation of `epdfinfo`. The following changes are made:
- Remove private headers from all the server code. This involves:
- Replace private header functionality with the correct public
functions provided by poppler.
- Remove unneeded headers around date checks
- Delete dead-code (headers, m4 macros)
- Remove C++, g++ and similar aliases from all the code. Also:
- Remove related information from the README
- Remove related information from CI and Dockerfiles
Work done by: @Pi-Cla
Closes: #105, #103, #109, #114
Diffstat (limited to 'server')
22 files changed, 27 insertions, 270 deletions
diff --git a/server/Makefile.am b/server/Makefile.am index 1662dca..b39e805 100644 --- a/server/Makefile.am +++ b/server/Makefile.am @@ -1,10 +1,10 @@ bin_PROGRAMS = epdfinfo epdfinfo_CFLAGS = -Wall $(glib_CFLAGS) $(poppler_glib_CFLAGS) $(poppler_CFLAGS) \ $(png_CFLAGS) -epdfinfo_CXXFLAGS = -Wall $(epdfinfo_CFLAGS) +# Need -lm to link libm.so.6 epdfinfo_LDADD = $(glib_LIBS) $(poppler_glib_LIBS) $(poppler_LIBS) \ - $(png_LIBS) libsynctex.a $(zlib_LIBS) -epdfinfo_SOURCES = epdfinfo.c epdfinfo.h poppler-hack.cc + $(png_LIBS) libsynctex.a $(zlib_LIBS) -lm +epdfinfo_SOURCES = epdfinfo.c epdfinfo.h noinst_LIBRARIES = libsynctex.a libsynctex_a_SOURCES = synctex_parser.c synctex_parser_utils.c synctex_parser.h \ diff --git a/server/autobuild b/server/autobuild index f9d2557..d057900 100755 --- a/server/autobuild +++ b/server/autobuild @@ -157,8 +157,6 @@ have_packages_installed() done which make || return 1 which gcc || which cc || return 1 - which g++ || which c++ || return 1 - c++ $(pkg-config --cflags poppler) -o /dev/null -E install_test.cpp 2>/dev/null [ $? -eq 0 ] || return 1 return 0 } >/dev/null 2>&1 @@ -221,7 +219,6 @@ os_centos() { PACKAGES="autoconf automake gcc - gcc-c++ libpng-devel make pkgconfig @@ -252,15 +249,6 @@ os_openbsd() { PACKAGES="autoconf%2.69 automake%1.15 poppler poppler-utils png" export AUTOCONF_VERSION=2.69 export AUTOMAKE_VERSION=1.15 - if whereis clang++ ;then - export CXX=clang++ - elif whereis eg++ ;then - export CXX=eg++ - else - export CXX=eg++ - PACKAGES="${PACKAGES} g++" - fi - export CXXFLAGS="-std=c++11 -I/usr/local/include/poppler -I/usr/local/include" return 0 } @@ -274,7 +262,6 @@ os_fedora() { PACKAGES="autoconf automake gcc - gcc-c++ libpng-devel make poppler-devel @@ -296,12 +283,10 @@ os_debian() { fi PACKAGES="autoconf automake - g++ gcc libpng-dev libpoppler-dev libpoppler-glib-dev - libpoppler-private-dev libz-dev make pkg-config" @@ -457,7 +442,6 @@ os_opensuse() { automake autoconf gcc - gcc-c++ libpng16-devel libpng16-compat-devel zlib-devel @@ -570,8 +554,8 @@ if [ -n "$INSTALL_DIR" ]; then prefix=--bindir=$INSTALL_DIR fi -echo "./configure CXXFLAGS='-std=c++17' -q $prefix && make clean && make -s" -eval "./configure CXXFLAGS='-std=c++17' -q $(quote "$prefix") && make clean && make -s || exit_fail" +echo "./configure -q $prefix && make clean && make -s" +eval "./configure -q $(quote "$prefix") && make clean && make -s || exit_fail" echo if [ -n "$INSTALL_DIR" ]; then echo "---------------------------" diff --git a/server/configure.ac b/server/configure.ac index c2866b0..9a8c46d 100644 --- a/server/configure.ac +++ b/server/configure.ac @@ -10,7 +10,6 @@ AC_CONFIG_HEADERS([config.h]) # Checks for programs. AC_PROG_CC AM_PROG_CC_C_O -AC_PROG_CXX AC_PROG_RANLIB AM_PROG_AR @@ -43,22 +42,6 @@ if test "$have_w32" = true; then fi fi -SAVED_CPPFLAGS=$CPPFLAGS -CPPFLAGS=$poppler_CFLAGS -AC_LANG_PUSH([C++]) -# Check if we can use the -std=c++11 option. -m4_include([m4/ax_check_compile_flag.m4]) -AX_CHECK_COMPILE_FLAG([-std=c++11], [HAVE_STD_CXX11=yes]) - -if test "$HAVE_STD_CXX11" = yes; then - CXXFLAGS="-std=c++11 $CXXFLAGS" -fi -# Check for private poppler header. -AC_CHECK_HEADERS([Annot.h PDFDocEncoding.h], [], - AC_MSG_ERROR([cannot find necessary poppler-private header (see README.org)])) -AC_LANG_POP([C++]) -CPPFLAGS=$SAVED_CPPFLAGS - # Setup compile time features. if test "$HAVE_POPPLER_FIND_OPTS" = yes; then AC_DEFINE([HAVE_POPPLER_FIND_OPTS],1, diff --git a/server/epdfinfo.c b/server/epdfinfo.c index 3e0e7c1..061df61 100644 --- a/server/epdfinfo.c +++ b/server/epdfinfo.c @@ -1567,6 +1567,7 @@ annotation_print (const annotation_t *annot, /* const */ PopplerPage *page) gchar *text; gdouble opacity; cairo_region_t *region = NULL; + GDate *date; if (! annot || ! page) return; @@ -1668,11 +1669,13 @@ annotation_print (const annotation_t *annot, /* const */ PopplerPage *page) printf ("::"); /* Creation Date */ - text = xpoppler_annot_markup_get_created (ma); - if (text) + date = poppler_annot_markup_get_date (ma); + if (date != NULL && g_date_valid(date)) { - print_response_string (text, NONE); - g_free (text); + gchar datebuf[128]; + g_date_strftime (datebuf, 127, "%x", date); + print_response_string (datebuf, NONE); + g_date_free (date); } /* <<< Markup Annotation <<< */ @@ -2848,7 +2851,7 @@ cmd_editannot (const epdfinfo_t *ctx, const command_arg_t *args) area->x1 = r.x1 * width; area->y2 = height - (r.y1 * height); - xpoppler_annot_set_rectangle (pa, area); + poppler_annot_set_rectangle (pa, area); } else if (! strcmp (key, "label")) { diff --git a/server/epdfinfo.h b/server/epdfinfo.h index 9f80cfd..542b577 100644 --- a/server/epdfinfo.h +++ b/server/epdfinfo.h @@ -243,10 +243,4 @@ typedef struct const command_arg_type_t *args_spec; int nargs; } command_t; - -/* Defined in poppler-hack.cc */ -#ifdef HAVE_POPPLER_ANNOT_WRITE -extern void xpoppler_annot_set_rectangle (PopplerAnnot*, PopplerRectangle*); -#endif -extern gchar *xpoppler_annot_markup_get_created (PopplerAnnotMarkup*); #endif /* _EPDF_H_ */ diff --git a/server/install_test.cpp b/server/install_test.cpp deleted file mode 100644 index d553d2b..0000000 --- a/server/install_test.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include <PDFDocEncoding.h> -#include <iostream> - -int main() { - std::cout << "Hello World, pdf-tools!"; - return 0; -} diff --git a/server/m4/ax_check_compile_flag.m4 b/server/m4/ax_check_compile_flag.m4 deleted file mode 100644 index dcabb92..0000000 --- a/server/m4/ax_check_compile_flag.m4 +++ /dev/null @@ -1,74 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) -# -# DESCRIPTION -# -# Check whether the given FLAG works with the current language's compiler -# or gives an error. (Warnings, however, are ignored) -# -# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on -# success/failure. -# -# If EXTRA-FLAGS is defined, it is added to the current language's default -# flags (e.g. CFLAGS) when the check is done. The check is thus made with -# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to -# force the compiler to issue an error when a bad flag is given. -# -# INPUT gives an alternative input source to AC_COMPILE_IFELSE. -# -# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this -# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. -# -# LICENSE -# -# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> -# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com> -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see <https://www.gnu.org/licenses/>. -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 5 - -AC_DEFUN([AX_CHECK_COMPILE_FLAG], -[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF -AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl -AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ - ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS - _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" - AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], - [AS_VAR_SET(CACHEVAR,[yes])], - [AS_VAR_SET(CACHEVAR,[no])]) - _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) -AS_VAR_IF(CACHEVAR,yes, - [m4_default([$2], :)], - [m4_default([$3], :)]) -AS_VAR_POPDEF([CACHEVAR])dnl -])dnl AX_CHECK_COMPILE_FLAGS diff --git a/server/poppler-hack.cc b/server/poppler-hack.cc deleted file mode 100644 index 2451101..0000000 --- a/server/poppler-hack.cc +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (C) 2013, 2014 Andreas Politz - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. - -#include <config.h> -#include <PDFDocEncoding.h> -#include <Annot.h> -#include <glib.h> -#include <glib-object.h> -#include <poppler-features.h> - -extern "C" -{ - -GType poppler_annot_get_type (void) G_GNUC_CONST; -GType poppler_annot_markup_get_type (void) G_GNUC_CONST; - -#define POPPLER_TYPE_ANNOT (poppler_annot_get_type ()) -#define POPPLER_ANNOT(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), POPPLER_TYPE_ANNOT, PopplerAnnot)) -#define POPPLER_IS_ANNOT_MARKUP(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), POPPLER_TYPE_ANNOT_MARKUP)) -#define POPPLER_TYPE_ANNOT_MARKUP (poppler_annot_markup_get_type ()) - -#if POPPLER_CHECK_VERSION(0,72,0) -#define GET_CSTR c_str -#else -#define GET_CSTR getCString -#endif - - struct PopplerAnnot - { - GObject parent_instance; - Annot *annot; - }; - - struct PopplerAnnotMarkup - { - GObject parent_instance; - }; - - struct PopplerRectangle - { - double x1; - double y1; - double x2; - double y2; - }; - - // This function does not modify its argument s, but for - // compatibility reasons (e.g. getLength in GooString.h before 2015) - // with older poppler code, it can't be declared as such. - char *_xpoppler_goo_string_to_utf8(/* const */ GooString *s) - { - char *result; - - if (! s) - return NULL; - - if (s->hasUnicodeMarker()) { - result = g_convert (s->GET_CSTR () + 2, - s->getLength () - 2, - "UTF-8", "UTF-16BE", NULL, NULL, NULL); - } else { - int len; - gunichar *ucs4_temp; - int i; - - len = s->getLength (); - ucs4_temp = g_new (gunichar, len + 1); - for (i = 0; i < len; ++i) { - ucs4_temp[i] = pdfDocEncoding[(unsigned char)s->getChar(i)]; - } - ucs4_temp[i] = 0; - - result = g_ucs4_to_utf8 (ucs4_temp, -1, NULL, NULL, NULL); - - g_free (ucs4_temp); - } - - return result; - } -#ifdef HAVE_POPPLER_ANNOT_WRITE - // Set the rectangle of an annotation. It was first added in v0.26. - void xpoppler_annot_set_rectangle (PopplerAnnot *a, PopplerRectangle *rectangle) - { - GooString *state = (GooString*) a->annot->getAppearState (); - char *ustate = _xpoppler_goo_string_to_utf8 (state); - - a->annot->setRect (rectangle->x1, rectangle->y1, - rectangle->x2, rectangle->y2); - a->annot->setAppearanceState (ustate); - g_free (ustate); - } -#endif - // This function is in the library, but the enforced date parsing is - // incomplete (at least in some versions), because it ignores the - // timezone. - gchar *xpoppler_annot_markup_get_created (PopplerAnnotMarkup *poppler_annot) - { - AnnotMarkup *annot; - GooString *text; - - g_return_val_if_fail (POPPLER_IS_ANNOT_MARKUP (poppler_annot), NULL); - - annot = static_cast<AnnotMarkup *>(POPPLER_ANNOT (poppler_annot)->annot); - text = (GooString*) annot->getDate (); - - return text ? _xpoppler_goo_string_to_utf8 (text) : NULL; - } -} diff --git a/server/test/docker/templates/centos-7.Dockerfile.in b/server/test/docker/templates/centos-7.Dockerfile.in index 62f2eb4..cdebbef 100644 --- a/server/test/docker/templates/centos-7.Dockerfile.in +++ b/server/test/docker/templates/centos-7.Dockerfile.in @@ -1,3 +1,3 @@ # -*- dockerfile -*- FROM centos:7 -RUN yum update -y && yum install -y gcc gcc-c++ poppler-glib-devel +RUN yum update -y && yum install -y gcc poppler-glib-devel diff --git a/server/test/docker/templates/debian-10.Dockerfile.in b/server/test/docker/templates/debian-10.Dockerfile.in index 1808b78..139db32 100644 --- a/server/test/docker/templates/debian-10.Dockerfile.in +++ b/server/test/docker/templates/debian-10.Dockerfile.in @@ -1,3 +1,3 @@ # -*- dockerfile -*- FROM debian:10 -RUN apt-get update -y && apt-get install -y gcc g++ libpoppler-glib-dev +RUN apt-get update -y && apt-get install -y gcc libpoppler-glib-dev diff --git a/server/test/docker/templates/debian-8.Dockerfile.in b/server/test/docker/templates/debian-8.Dockerfile.in index adcc6d3..e7c7a15 100644 --- a/server/test/docker/templates/debian-8.Dockerfile.in +++ b/server/test/docker/templates/debian-8.Dockerfile.in @@ -1,4 +1,3 @@ # -*- dockerfile -*- FROM debian:8 -RUN apt-get update -y && apt-get install -y gcc g++ libpoppler-glib-dev - +RUN apt-get update -y && apt-get install -y gcc libpoppler-glib-dev diff --git a/server/test/docker/templates/debian-9.Dockerfile.in b/server/test/docker/templates/debian-9.Dockerfile.in index 1f4ece7..db166c3 100644 --- a/server/test/docker/templates/debian-9.Dockerfile.in +++ b/server/test/docker/templates/debian-9.Dockerfile.in @@ -1,4 +1,3 @@ # -*- dockerfile -*- FROM debian:9 -RUN apt-get update -y && apt-get install -y gcc g++ libpoppler-glib-dev - +RUN apt-get update -y && apt-get install -y gcc libpoppler-glib-dev diff --git a/server/test/docker/templates/fedora-32.Dockerfile.in b/server/test/docker/templates/fedora-32.Dockerfile.in index 46a0907..1ee8a68 100644 --- a/server/test/docker/templates/fedora-32.Dockerfile.in +++ b/server/test/docker/templates/fedora-32.Dockerfile.in @@ -1,3 +1,3 @@ # -*- dockerfile -*- FROM fedora:32 -RUN dnf update -y && dnf install -y gcc gcc-c++ poppler-glib-devel +RUN dnf update -y && dnf install -y gcc poppler-glib-devel diff --git a/server/test/docker/templates/fedora-33.Dockerfile.in b/server/test/docker/templates/fedora-33.Dockerfile.in index 06cae7b..13b0ae0 100644 --- a/server/test/docker/templates/fedora-33.Dockerfile.in +++ b/server/test/docker/templates/fedora-33.Dockerfile.in @@ -1,3 +1,3 @@ # -*- dockerfile -*- FROM fedora:33 -RUN dnf update -y && dnf install -y gcc gcc-c++ poppler-glib-devel +RUN dnf update -y && dnf install -y gcc poppler-glib-devel diff --git a/server/test/docker/templates/fedora-34.Dockerfile.in b/server/test/docker/templates/fedora-34.Dockerfile.in index 63e6abb..0a43238 100644 --- a/server/test/docker/templates/fedora-34.Dockerfile.in +++ b/server/test/docker/templates/fedora-34.Dockerfile.in @@ -1,3 +1,3 @@ # -*- dockerfile -*- FROM fedora:34 -RUN dnf update -y && dnf install -y gcc gcc-c++ poppler-glib-devel +RUN dnf update -y && dnf install -y gcc poppler-glib-devel diff --git a/server/test/docker/templates/fedora-35.Dockerfile.in b/server/test/docker/templates/fedora-35.Dockerfile.in index 09a25b2..1baf076 100644 --- a/server/test/docker/templates/fedora-35.Dockerfile.in +++ b/server/test/docker/templates/fedora-35.Dockerfile.in @@ -1,3 +1,3 @@ # -*- dockerfile -*- FROM fedora:35 -RUN dnf update -y && dnf install -y gcc gcc-c++ poppler-glib-devel +RUN dnf update -y && dnf install -y gcc poppler-glib-devel diff --git a/server/test/docker/templates/ubuntu-14.Dockerfile.in b/server/test/docker/templates/ubuntu-14.Dockerfile.in index 1c9aaa7..5cd2bbe 100644 --- a/server/test/docker/templates/ubuntu-14.Dockerfile.in +++ b/server/test/docker/templates/ubuntu-14.Dockerfile.in @@ -1,4 +1,3 @@ # -*- dockerfile -*- FROM ubuntu:trusty -RUN apt-get update -y && apt-get install -y gcc g++ libpoppler-glib-dev - +RUN apt-get update -y && apt-get install -y gcc libpoppler-glib-dev diff --git a/server/test/docker/templates/ubuntu-16.Dockerfile.in b/server/test/docker/templates/ubuntu-16.Dockerfile.in index e7d477e..e166f43 100644 --- a/server/test/docker/templates/ubuntu-16.Dockerfile.in +++ b/server/test/docker/templates/ubuntu-16.Dockerfile.in @@ -1,4 +1,3 @@ # -*- dockerfile -*- FROM ubuntu:xenial -RUN apt-get update -y && apt-get install -y gcc g++ libpoppler-glib-dev - +RUN apt-get update -y && apt-get install -y gcc libpoppler-glib-dev diff --git a/server/test/docker/templates/ubuntu-18.Dockerfile.in b/server/test/docker/templates/ubuntu-18.Dockerfile.in index a445804..5c04f3d 100644 --- a/server/test/docker/templates/ubuntu-18.Dockerfile.in +++ b/server/test/docker/templates/ubuntu-18.Dockerfile.in @@ -1,3 +1,3 @@ # -*- dockerfile -*- FROM ubuntu:bionic -RUN apt-get update -y && apt-get install -y gcc g++ libpoppler-glib-dev +RUN apt-get update -y && apt-get install -y gcc libpoppler-glib-dev diff --git a/server/test/docker/templates/ubuntu-20.10.Dockerfile.in b/server/test/docker/templates/ubuntu-20.10.Dockerfile.in index 1235de3..ff3294a 100644 --- a/server/test/docker/templates/ubuntu-20.10.Dockerfile.in +++ b/server/test/docker/templates/ubuntu-20.10.Dockerfile.in @@ -1,3 +1,3 @@ # -*- dockerfile -*- FROM ubuntu:groovy -RUN apt-get update -y && apt-get install -y gcc g++ libpoppler-glib-dev +RUN apt-get update -y && apt-get install -y gcc libpoppler-glib-dev diff --git a/server/test/docker/templates/ubuntu-20.Dockerfile.in b/server/test/docker/templates/ubuntu-20.Dockerfile.in index 80053e8..a039e5e 100644 --- a/server/test/docker/templates/ubuntu-20.Dockerfile.in +++ b/server/test/docker/templates/ubuntu-20.Dockerfile.in @@ -1,3 +1,3 @@ # -*- dockerfile -*- FROM ubuntu:focal -RUN apt-get update -y && apt-get install -y gcc g++ libpoppler-glib-dev +RUN apt-get update -y && apt-get install -y gcc libpoppler-glib-dev diff --git a/server/test/docker/templates/ubuntu-21.Dockerfile.in b/server/test/docker/templates/ubuntu-21.Dockerfile.in index b4f462f..809d7ed 100644 --- a/server/test/docker/templates/ubuntu-21.Dockerfile.in +++ b/server/test/docker/templates/ubuntu-21.Dockerfile.in @@ -1,3 +1,3 @@ # -*- dockerfile -*- FROM ubuntu:hirsute -RUN apt-get update -y && apt-get install -y gcc g++ libpoppler-glib-dev +RUN apt-get update -y && apt-get install -y gcc libpoppler-glib-dev |
