#! /bin/sh -e
## XX_PATCHNAME.dpatch by YOUR NAME <YOUR EMAIL>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
patch_opts="${patch_opts:--f --no-backup-if-mismatch ${2:+-d $2}}"

if [ $# -lt 1 ]; then
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    exit 1
fi
case "$1" in
       -patch) patch $patch_opts -p1 < $0;;
       -unpatch) patch $patch_opts -p1 -R < $0;;
	*)
		echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
		exit 1;;
esac

exit 0

--- xemacs21-21.4.15.orig/configure.in
+++ xemacs21-21.4.15/configure.in
@@ -349,7 +349,7 @@
 with_menubars=''
 with_scrollbars=''
 dnl can't turn off widgets here because of systems where they are demanded
-with_widgets=''
+with_widgets='athena'
 with_dialogs=''
 with_file_coding=''
 cpp='' cppflags='' libs='' ldflags=''
@@ -2039,10 +2044,10 @@
 dnl #### Should make this Solaris-friendly.
 dnl Link with -z nocombreloc for now.
 if test "$pdump" != "yes"; then
-  AC_MSG_CHECKING(for \"-z nocombreloc\" linker flag)
+  AC_MSG_CHECKING(for \"-Xlinker -znocombreloc\" linker flag)
   case "`ld --help 2>&1`" in
     *-z\ nocombreloc* ) AC_MSG_RESULT(yes)
-      XE_PREPEND(-z nocombreloc, ld_switch_site) ;;
+      XE_PREPEND(-Xlinker -znocombreloc, ld_switch_site) ;;
     *) AC_MSG_RESULT(no) ;;
   esac
 fi
@@ -4500,7 +4506,8 @@
     AC_MSG_RESULT(2); dbfunc=db_open])],[
     AC_MSG_RESULT(1); dbfunc=dbopen])
     AC_CHECK_FUNC($dbfunc,     with_database_berkdb=yes need_libdb=no, [
-    AC_CHECK_LIB(db, $dbfunc,  with_database_berkdb=yes need_libdb=yes)])
+    AC_CHECK_LIB(db, $dbfunc,  with_database_berkdb=yes need_libdb=yes, [
+    AC_CHECK_LIB(db, [${dbfunc}_4001], with_database_berkdb=yes need_libdb=yes) ])])
   fi
 
   if test "$with_database_berkdb" = "yes"; then
@@ -4856,6 +4863,7 @@
   esac
 done
 AC_SUBST(DOCDIR)
+AC_DEFINE_UNQUOTED(DOCDIR, "$docdir")
 
 AC_SUBST(archlibdir)
 AC_SUBST(ARCHLIBDIR_USER_DEFINED)
@@ -5084,7 +5092,7 @@
 echo "  Relocating allocator for buffers:  $rel_alloc"
 echo "  GNU version of malloc:             ${GNU_MALLOC}${GNU_MALLOC_reason}"
 case "$ld_switch_site" in
-  *nocombreloc*) echo "  Linking with \`-z nocombreloc'.
+  *nocombreloc*) echo "  Linking with \`-Xlinker -znocombreloc'.
     - Consider configuring with --pdump." ;;
 esac
 
--- xemacs21-21.4.15.orig/lisp/ChangeLog
+++ xemacs21-21.4.15/lisp/ChangeLog
@@ -430,6 +430,12 @@
 
 	* XEmacs 21.4.9 "Informed Management" is released.
 
+2002-07-27  James LewisMoss  <dres@lewismoss.org>
+
+	* gnuserv.el (gnuserv-edit-files): fallback to gtk if x device
+	fails.  Fixes problem where gnuclient fails for gtk instances when
+	gnuclient was built with X configure.
+
 2002-06-22  Ville Skyttä  <ville.skytta@xemacs.org>
 
 	* subr.el (add-to-list): Sync with GNU Emacs 21.2, adding the
--- xemacs21-21.4.15.orig/lisp/font-menu.el
+++ xemacs21-21.4.15/lisp/font-menu.el
@@ -158,6 +158,11 @@
   :type '(choice (string :tag "Format string")
 		 (function)))
 
+(defcustom font-menu-max-number nil
+  "The maximum number of fonts retrieved from the server"
+  :type 'integer
+  :group 'font-menu)
+
 (defvar font-menu-preferred-resolution
   (make-specifier-and-init 'generic '((global ((mswindows) . ":")
 					      ((gtk) . "*-*")
--- xemacs21-21.4.15.orig/lisp/x-font-menu.el
+++ xemacs21-21.4.15/lisp/x-font-menu.el
@@ -89,7 +89,8 @@
 	family size weight entry monospaced-p
 	dev-cache cache families sizes weights)
     (dolist (name (cond ((null debug)	; debugging kludge
-			 (list-fonts "*-*-*-*-*-*-*-*-*-*-*-*-*-*" device))
+			 (list-fonts "*-*-*-*-*-*-*-*-*-*-*-*-*-*" device
+                                     font-menu-max-number))
 			((stringp debug) (split-string debug "\n"))
 			(t debug)))
       (when (and (string-match x-font-regexp-ascii name)
--- xemacs21-21.4.15.orig/src/ChangeLog
+++ xemacs21-21.4.15/src/ChangeLog
@@ -311,6 +315,11 @@
 
 	* specifier.c (Fvalid_specifier_type_p): Typo in comment.
 
+2002-11-16  James LewisMoss  <dres@lewismoss.org>
+
+	* dumper.c (pdump_load): add search for file DUMP in DOCDIR along
+	with the patterned exe path search.
+
 2002-11-13  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* event-Xt.c (Xt_timeout):
--- xemacs21-21.4.15.orig/src/config.h.in
+++ xemacs21-21.4.15/src/config.h.in
@@ -905,6 +905,7 @@
 #undef MODULEDIR_USER_DEFINED
 #undef SITEMODULEDIR_USER_DEFINED
 #undef DOCDIR_USER_DEFINED
+#undef DOCDIR
 #undef LISPDIR_USER_DEFINED
 #undef PACKAGE_PATH_USER_DEFINED
 #undef SITELISPDIR_USER_DEFINED
--- xemacs21-21.4.15.orig/src/console.h
+++ xemacs21-21.4.15/src/console.h
@@ -238,7 +238,8 @@
 						Error_behavior errb);
   Lisp_Object (*font_instance_properties_method) (Lisp_Font_Instance *);
   Lisp_Object (*list_fonts_method) (Lisp_Object pattern,
-				    Lisp_Object device);
+				    Lisp_Object device,
+                                    Lisp_Object maxnumber);
   Lisp_Object (*find_charset_font_method) (Lisp_Object device,
 					   Lisp_Object font,
 					   Lisp_Object charset);
--- xemacs21-21.4.15.orig/src/dumper.c
+++ xemacs21-21.4.15/src/dumper.c
@@ -1322,9 +1322,24 @@
 }
 #endif /* !WIN32_NATIVE */
 
+static int
+pdump_file_doc_dir_try (char *exe_path)
+{
+  char *w = exe_path + strlen (exe_path);
+
+  sprintf (w, "%s", "DUMP");
+
+  if (pdump_file_get (exe_path))
+    {
+      if (pdump_load_check ())
+        return 1;
+      pdump_free ();
+    }
+  return 0;
+}
 
 static int
-pdump_file_try (char *exe_path)
+pdump_file_exe_path_try (char *exe_path)
 {
   char *w = exe_path + strlen (exe_path);
 
@@ -1439,9 +1454,16 @@
 
   /* Save exe_path because pdump_file_try() modifies it */
   strcpy(real_exe_path, exe_path);
-  if (pdump_file_try (exe_path)
+  if (pdump_file_exe_path_try (exe_path)
       || (xrealpath(real_exe_path, real_exe_path)
-	  && pdump_file_try (real_exe_path)))
+	  && pdump_file_exe_path_try (real_exe_path)))
+    {
+      pdump_load_finish ();
+      return 1;
+    }
+
+  sprintf(exe_path, "%s", DOCDIR);
+  if (pdump_file_doc_dir_try (exe_path))
     {
       pdump_load_finish ();
       return 1;
--- xemacs21-21.4.15.orig/src/glyphs-gtk.c
+++ xemacs21-21.4.15/src/glyphs-gtk.c
@@ -2103,6 +2104,21 @@
 	    }
 	  GTK_WIDGET_FLAGS(FRAME_GTK_TEXT_WIDGET (f)) = old_flags;
 	}
+      else
+	{
+	  if (IMAGE_INSTANCE_GTK_ALREADY_PUT(p))
+	    {
+	      /* Do nothing... */
+	    }
+	  else
+	    {
+	      /* Must make sure we have put the image at least once! */
+	      IMAGE_INSTANCE_GTK_ALREADY_PUT(p) = TRUE;
+	      gtk_fixed_put (GTK_FIXED (FRAME_GTK_TEXT_WIDGET (f)),
+			     wid,
+			     -dga->xoffset, -dga->yoffset);
+	    }
+	}
 
       if (!IMAGE_INSTANCE_SUBWINDOW_DISPLAYEDP (p))
 	{
@@ -2219,7 +2235,6 @@
   /* This function can GC */
   Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
   Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
-  Lisp_Object frame = DOMAIN_FRAME (domain);
 
   if (!DEVICE_GTK_P (XDEVICE (device)))
     signal_simple_error ("Not a GTK device", device);
--- xemacs21-21.4.15.orig/src/objects-gtk.c
+++ xemacs21-21.4.15/src/objects-gtk.c
@@ -369,7 +369,7 @@
 }
 
 static Lisp_Object
-gtk_list_fonts (Lisp_Object pattern, Lisp_Object device)
+gtk_list_fonts (Lisp_Object pattern, Lisp_Object device, Lisp_Object maxnumber)
 {
   const char *patternext;
 
--- xemacs21-21.4.15.orig/src/objects-msw.c
+++ xemacs21-21.4.15/src/objects-msw.c
@@ -1592,7 +1592,8 @@
 }
 
 static Lisp_Object
-mswindows_list_fonts (Lisp_Object pattern, Lisp_Object device)
+mswindows_list_fonts (Lisp_Object pattern, Lisp_Object device,
+                      Lisp_Object maxnumber)
 {
   Lisp_Object fonttail, result = Qnil;
   char *extpattern;
--- xemacs21-21.4.15.orig/src/objects-tty.c
+++ xemacs21-21.4.15/src/objects-tty.c
@@ -275,7 +275,7 @@
 }
 
 static Lisp_Object
-tty_list_fonts (Lisp_Object pattern, Lisp_Object device)
+tty_list_fonts (Lisp_Object pattern, Lisp_Object device, Lisp_Object maxnumber)
 {
   return list1 (build_string ("normal"));
 }
--- xemacs21-21.4.15.orig/src/objects-x.c
+++ xemacs21-21.4.15/src/objects-x.c
@@ -862,17 +862,23 @@
 }
 
 static Lisp_Object
-x_list_fonts (Lisp_Object pattern, Lisp_Object device)
+x_list_fonts (Lisp_Object pattern, Lisp_Object device, Lisp_Object maxnumber)
 {
   Extbyte **names;
   int count = 0;
+  int max_number = MAX_FONT_COUNT;
   Lisp_Object result = Qnil;
   const Extbyte *patternext;
 
   LISP_STRING_TO_EXTERNAL (pattern, patternext, Qx_font_name_encoding);
 
+  if (!NILP(maxnumber) && INTP(maxnumber))
+  {
+      max_number = XINT(maxnumber);
+  }
+
   names = XListFonts (DEVICE_X_DISPLAY (XDEVICE (device)),
-		      patternext, MAX_FONT_COUNT, &count);
+		      patternext, maxnumber, &count);
   while (count--)
     result = Fcons (build_ext_string (names[count], Qx_font_name_encoding),
 		    result);
--- xemacs21-21.4.15.orig/src/objects.c
+++ xemacs21-21.4.15/src/objects.c
@@ -459,17 +459,18 @@
 			     font_instance_properties, (f));
 }
 
-DEFUN ("list-fonts", Flist_fonts, 1, 2, 0, /*
+DEFUN ("list-fonts", Flist_fonts, 1, 3, 0, /*
 Return a list of font names matching the given pattern.
 DEVICE specifies which device to search for names, and defaults to the
 currently selected device.
 */
-       (pattern, device))
+       (pattern, device, maxnumber))
 {
   CHECK_STRING (pattern);
   XSETDEVICE (device, decode_device (device));
 
-  return MAYBE_LISP_DEVMETH (XDEVICE (device), list_fonts, (pattern, device));
+  return MAYBE_LISP_DEVMETH (XDEVICE (device), list_fonts, (pattern, device,
+                                                            maxnumber));
 }
 
 
