[poppler] 2 commits - cpp/poppler-page.cpp cpp/poppler-private.h goo/gfile.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Sun Mar 4 21:12:57 UTC 2018


 cpp/poppler-page.cpp  |    3 +++
 cpp/poppler-private.h |    3 +++
 goo/gfile.cc          |   40 +++++++++++++++++++++++++++++++++++++---
 3 files changed, 43 insertions(+), 3 deletions(-)

New commits:
commit 41321580f0a13309e5de44eb42851e3c82a5ef8f
Author: Adam Reichold <adam.reichold at t-online.de>
Date:   Sun Mar 4 09:17:00 2018 +0100

    Use the detection idiom to handle the non-standard struct stat field name for high-resolution mtime on Mac OS X.

diff --git a/goo/gfile.cc b/goo/gfile.cc
index e4c9b9fb..218882d3 100644
--- a/goo/gfile.cc
+++ b/goo/gfile.cc
@@ -21,7 +21,7 @@
 // Copyright (C) 2008, 2010, 2012, 2013 Hib Eris <hib at hiberis.nl>
 // Copyright (C) 2009, 2012, 2014, 2017, 2018 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2009 Kovid Goyal <kovid at kovidgoyal.net>
-// Copyright (C) 2013 Adam Reichold <adamreichold at myopera.com>
+// Copyright (C) 2013, 2018 Adam Reichold <adamreichold at myopera.com>
 // Copyright (C) 2013, 2017 Adrian Johnson <ajohnson at redneon.com>
 // Copyright (C) 2013 Peter Breitenlohner <peb at mppmu.mpg.de>
 // Copyright (C) 2013, 2017 Thomas Freitag <Thomas.Freitag at alfa.de>
@@ -65,6 +65,40 @@
 #define PATH_MAX 1024
 #endif
 
+namespace {
+
+template< typename... >
+struct void_type
+{
+  using type = void;
+};
+
+template< typename... Args >
+using void_t = typename void_type< Args... >::type;
+
+template< typename Stat, typename = void_t<> >
+struct StatMtim
+{
+  static const struct timespec& value(const Stat& stbuf) {
+    return stbuf.st_mtim;
+  }
+};
+
+// Mac OS X uses a different field name than POSIX and this detects it.
+template< typename Stat >
+struct StatMtim< Stat, void_t< decltype ( Stat::st_mtimespec ) > >
+{
+  static const struct timespec& value(const Stat& stbuf) {
+    return stbuf.st_mtimespec;
+  }
+};
+
+inline const struct timespec& mtim(const struct stat& stbuf) {
+  return StatMtim< struct stat >::value(stbuf);
+}
+
+}
+
 //------------------------------------------------------------------------
 
 GooString *getCurrentDir() {
@@ -687,7 +721,7 @@ GooFile::GooFile(int fdA)
 {
     struct stat statbuf;
     fstat(fd, &statbuf);
-    modifiedTimeOnOpen = statbuf.st_mtim;
+    modifiedTimeOnOpen = mtim(statbuf);
 }
 
 bool GooFile::modificationTimeChangedSinceOpen() const
@@ -695,7 +729,7 @@ bool GooFile::modificationTimeChangedSinceOpen() const
     struct stat statbuf;
     fstat(fd, &statbuf);
 
-    return modifiedTimeOnOpen.tv_sec != statbuf.st_mtim.tv_sec || modifiedTimeOnOpen.tv_nsec != statbuf.st_mtim.tv_nsec;
+    return modifiedTimeOnOpen.tv_sec != mtim(statbuf).tv_sec || modifiedTimeOnOpen.tv_nsec != mtim(statbuf).tv_nsec;
 }
 
 #endif // _WIN32
commit b14baefb406b8f08f0702edd686ebc7698cb7f15
Author: Adam Reichold <adam.reichold at t-online.de>
Date:   Mon Feb 12 08:09:00 2018 +0100

    Explicitly anchor destructor of text_box_data to avoid linker errors using Clang on Mac OS X.

diff --git a/cpp/poppler-page.cpp b/cpp/poppler-page.cpp
index 83d48f07..a4ebfe51 100644
--- a/cpp/poppler-page.cpp
+++ b/cpp/poppler-page.cpp
@@ -3,6 +3,7 @@
  * Copyright (C) 2017, Albert Astals Cid <aacid at kde.org>
  * Copyright (C) 2017, Jason Alan Palmer <jalanpalmer at gmail.com>
  * Copyright (C) 2018, Suzuki Toshiya <mpsuzuki at hiroshima-u.ac.jp>
+ * Copyright (C) 2018, Adam Reichold <adam.reichold at t-online.de>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -290,6 +291,8 @@ ustring page::text(const rectf &r, text_layout_enum layout_mode) const
 /*
  * text_box object for page::text_list()
  */
+text_box_data::~text_box_data() = default;
+
 text_box::~text_box() = default;
 
 text_box::text_box(text_box_data *data) : m_data{data}
diff --git a/cpp/poppler-private.h b/cpp/poppler-private.h
index 3753567f..d954bdb2 100644
--- a/cpp/poppler-private.h
+++ b/cpp/poppler-private.h
@@ -4,6 +4,7 @@
  * Copyright (C) 2014, Hans-Peter Deifel <hpdeifel at gmx.de>
  * Copyright (C) 2016 Jakub Alba <jakubalba at gmail.com>
  * Copyright (C) 2018, Suzuki Toshiya <mpsuzuki at hiroshima-u.ac.jp>
+ * Copyright (C) 2018, Adam Reichold <adam.reichold at t-online.de>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -70,6 +71,8 @@ void delete_all(const Collection &c)
 
 struct text_box_data
 {
+    ~text_box_data();
+
     ustring text;
     rectf bbox;
     std::vector<rectf> char_bboxes;


More information about the poppler mailing list