Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 djview4 (4.11-1) unstable; urgency=medium
 .
   [ Leon Bottou ]
   * release 4.11
 .
   [Ondřej Nový]
   * d/watch: Use https protocol
 .
   [ Barak A. Pearlmutter ]
   * bump standards version
   * tweak gbp upstream tag regex to match both release_xxx and release.xxx
Author: Barak A. Pearlmutter <bap@debian.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: 2018-10-08

--- djview4-4.11.orig/mac/make_djview_bundle.sh
+++ djview4-4.11/mac/make_djview_bundle.sh
@@ -69,6 +69,10 @@ done
     run ln -s "$target"  "$bundle/$d" || exit
 done
 
+# misc copies
+run cp ../src/djview.1 $bundle/share/man/man1
+run cp $bundle/Resources/qt.conf $bundle/MacOS
+
 # merge MacOS, bin, and plugins directories
 run mv $bundle/bin/* $bundle/MacOS || exit
 run rmdir $bundle/bin || exit
@@ -87,33 +91,42 @@ done
 
 # copy needed qt plugins
 ( cd "$QTDIR" ; \
-  ls -1 plugins/{platforms,imageformats,printsupport}/*.dylib | \
+  ls -1 plugins/{platforms,imageformats,styles,printsupport}/*.dylib | \
+  grep -v libqwebgl.dylib | \
   grep -v _debug.dylib ) | \
 while read plugin ; do
   run mkdir -p $bundle/$(dirname "$plugin") || exit
   run cp "$QTDIR/$plugin" $bundle/"$plugin" || exit
 done
 
+
+
 # copy needed libraries  
-for lib in \
-    $(otool -L $bundle/MacOS/djview | awk '/^\t/{print $1}') \
-    $(otool -L $bundle/MacOS/platforms/libqcocoa.dylib | awk '/^\t/{print $1}') 
-do
-  case "$lib" in 
-    $BREWDIR/*) 
+for loader in \
+    $bundle/MacOS/djview \
+    $bundle/MacOS/*/*.dylib 
+do 
+  for lib in $(otool -L $loader | awk '/^\t/{print $1}') 
+  do
+    if [ $(basename "$lib") != $(basename "$loader") ]
+    then
+      case "$lib" in 
+      $BREWDIR/*) 
         libname=$(basename "$lib")
 	test -r "./$bundle/lib/$libname" || \
 	    run cp "$lib" "./$bundle/lib/$libname" || exit ;;
-    @rpath/*)
+      @rpath/*)
         libname=$(basename "$lib")
         lib="$QTDIR/lib${lib/#@rpath//}"
 	test -r "./$bundle/lib/$libname" || \
 	    run cp "$lib" "./$bundle/lib/$libname" || exit ;;
-    $QTDIR/*)
+      $QTDIR/*)
         libname=$(basename "$lib")
 	test -r "./$bundle/lib/$libname" || \
 	    run cp "$lib" "./$bundle/lib/$libname" || exit ;;
-  esac
+      esac
+    fi
+  done
 done
 
 # copy translations
--- djview4-4.11.orig/src/qdjviewprefs.cpp
+++ djview4-4.11/src/qdjviewprefs.cpp
@@ -1156,8 +1156,10 @@ QDjViewPrefsDialog::reset()
         case QDjView::STANDALONE_SLIDESHOW:
           d->saved[i].remember = false;
           d->saved[i].zoom = QDjVuWidget::ZOOM_FITPAGE;
+          /* FALLTHRU */
         case QDjView::STANDALONE_FULLSCREEN:
           d->saved[i].options &= ~(optMSS|optS|optT);
+          /* FALLTHRU */
         case QDjView::STANDALONE:
           break;
         case QDjView::EMBEDDED_PLUGIN:
--- djview4-4.11.orig/src/qdjvuwidget.cpp
+++ djview4-4.11/src/qdjvuwidget.cpp
@@ -1932,7 +1932,7 @@ QDjVuPrivate::pageinfoPage(QDjVuPage *pa
         case DDJVU_JOB_OK:
           if (p)
             getAnnotationsAndText(p);
-          // no break!
+          /* FALLTHRU */
         case DDJVU_JOB_STARTED:
           if (p && p->dpi <= 0)
             {
@@ -4374,12 +4374,14 @@ QDjVuPrivate::paintHiddenText(QImage &im
                     case 2:
                       paint.translate(dw, dh);
                       paint.rotate(180);
+                      /* FALLTHRU */
                     default:
                       paint.scale(dw/bw, dh/bh);
                       break;
                     case 3:
                       paint.translate(dw, dh);
                       paint.rotate(180);
+                      /* FALLTHRU */
                     case 1:
                       paint.translate(dw, 0);
                       paint.rotate(90);
--- djview4-4.11.orig/src/tiff2pdf.c
+++ djview4-4.11/src/tiff2pdf.c
@@ -85,11 +85,28 @@
 #ifndef TIFFmin
 # define TIFFmin(A,B) ((A)<(B)?(A):(B))
 #endif
+#ifndef TIFFclip
+# define TIFFclip(A,B) ((A)<(0)?(0):((A)>(B)?(B):(A)))
+#endif
 
 #ifdef HAVE_GETOPT_H
 # include <getopt.h>
 #endif
 
+#ifdef _WIN32
+# ifndef HAVE_SNPRINTF
+static int
+snprintf(char* str, size_t size, const char* format, ...)
+{
+  int count;
+  va_list ap;
+  va_start(ap, format);
+  count = vsnprintf(str, size, format, ap);
+  va_end(ap);
+  return count;
+}
+# endif
+#endif
 
 
 #ifndef HAVE_GETOPT_H
@@ -3848,8 +3865,8 @@ t2p_sample_rgbaa_to_rgb(tdata_t data, ui
     /* For the 3 first samples, there is overlapping between souce and
        destination, so use memmove().
        See http://bugzilla.maptools.org/show_bug.cgi?id=2577 */
-    for(i = 0; i < 3 && i < samplecount; i++)
-        memmove((uint8*)data + i * 3, (uint8*)data + i * 4, 3);
+	for(i = 0; i < 3 && i < samplecount; i++)
+		memmove((uint8*)data + i * 3, (uint8*)data + i * 4, 3);
 	for(; i < samplecount; i++)
 		memcpy((uint8*)data + i * 3, (uint8*)data + i * 4, 3);
 
@@ -4266,13 +4283,13 @@ void t2p_pdf_currenttime(T2P* t2p)
 
 	currenttime = localtime(&timenow);
 	snprintf(t2p->pdf_datetime, sizeof(t2p->pdf_datetime),
-		 "D:%.4d%.2d%.2d%.2d%.2d%.2d",
-		 (currenttime->tm_year + 1900) % 65536,
-		 (currenttime->tm_mon + 1) % 256,
-		 (currenttime->tm_mday) % 256,
-		 (currenttime->tm_hour) % 256,
-		 (currenttime->tm_min) % 256,
-		 (currenttime->tm_sec) % 256);
+             "D:%.4d%.2d%.2d%.2d%.2d%.2d",
+             TIFFclip( (currenttime->tm_year + 1900) % 65536 , 9999),
+             TIFFclip( (currenttime->tm_mon + 1) % 256 , 99),
+             TIFFclip( (currenttime->tm_mday) % 256 , 99),
+             TIFFclip( (currenttime->tm_hour) % 256 , 99),
+             TIFFclip( (currenttime->tm_min) % 256 , 99),
+             TIFFclip( (currenttime->tm_sec) % 256 , 99));
 
 	return;
 }
