changeset 584:60fd513750ad

merge with cvs
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Thu, 13 Nov 2008 21:12:44 +0100
parents a78eb45c8721 (current diff) 6d57529fdeec (diff)
children 58952b16f941
files lout/misc.hh src/css.cc src/html.cc src/styleengine.cc src/table.cc
diffstat 35 files changed, 193 insertions(+), 92 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Nov 13 21:06:26 2008 +0100
+++ b/ChangeLog	Thu Nov 13 21:12:44 2008 +0100
@@ -4,22 +4,37 @@
 
 dillo-2.1
 
++- Added ipv6 addresses iteration and ipv4 fallback.
+   Patch: James Turner, Jorge Arellano
 +- Added support for numeric IPv6 addresses entered into the url bar.
  - Used the URL authority part instead of stripped default port in HTTP query.
    Patches: Justus Winter
 +- Fix for file inputs without values (forms).
  - Tuned input width a bit.
  - Cleaned up resource embedding (forms)
+ - Made cookierc parsing more robust.
+ - Switched a_UIcmd_save() to take its URL from history (not location bar).
+ - Set prefs.vw_fontname as deafult font for the UI.
+ - Fix: recover page focus when clicking-out of a widget.
    Patches: place (AKA corvid)
-+- Switched SSL enabled to configure.in (./configure --enable-ssl).
-   Patch: Jeremy Henty
++- Switched SSL-enabled to configure.in (./configure --enable-ssl).
+ - Standardised the installation of dpid/dpidrc with auto* tools.
+ - Set the ScrollGroup as the resizable widget in downloads dpi.
+ - Cleaned up and normalized D_SUN_LEN usage.
+   Patches: Jeremy Henty
 +- Allowed compilation with older machines by removing a few C99isms.
  - Added use of inttypes.h when stdint.h isn't found.
    Patches: Dan Fandrich
-+- Added ipv6 addresses iteration and ipv4 fallback.
-   Patch: James Turner, Jorge Arellano
-+- Set the File menu label to hide when the File menu button is shown.
-   Patch: Jorge Arellano
++- Made the DNS resolver report in numeric address notation.
+   Patch: Justus Winter
++- Reduced warnings with gcc-4.3.
+   Patch: Thomas Orgis
++- Added the "middle_click_drags_page" dillorc option.
+   Patch: Jorge Arellano, Thomas Orgis
++- Set the File menu label to hide when the File menu-button is shown.
+ ? Trying a new iconv() test in configure.in.
+ - Allowed the rc parser to skip whitespace around the equal sign.
+   Patches: Jorge Arellano
 
 dw
 
--- a/README	Thu Nov 13 21:06:26 2008 +0100
+++ b/README	Thu Nov 13 21:12:44 2008 +0100
@@ -23,7 +23,8 @@
 FLTK2
 -----
 
-  You can get the fltk2 library from fltk.org.
+  The FLTK2 library is statically linked into Dillo2.
+  You can get it from fltk.org.
 The recommended version is >= r6403. e.g. in:
 
   http://fltk.org/software.php?VERSION=2.0.x-r6403
--- a/configure.in	Thu Nov 13 21:06:26 2008 +0100
+++ b/configure.in	Thu Nov 13 21:12:44 2008 +0100
@@ -334,6 +334,7 @@
   LIBS="$old_libs $LIBICONV_LIBS"
   old_cflags="$CFLAGS"
   CFLAGS="$CFLAGS -Werror"
+  AC_LANG_PUSH([C++])
   AC_TRY_COMPILE([#include <iconv.h>],
 [
      const char *inPtr;
@@ -343,6 +344,7 @@
       iconv(encoder, &inPtr, &inLeft, &outPtr, &outRoom);
 ],
 iconv_old=yes,iconv_old=no)
+  AC_LANG_POP([C++])
   LIBS="$old_libs"
   CFLAGS="$old_cflags"
 
--- a/dillorc	Thu Nov 13 21:06:26 2008 +0100
+++ b/dillorc	Thu Nov 13 21:12:44 2008 +0100
@@ -203,6 +203,11 @@
 # If you prefer to open a new Window instead, set it to NO.
 #middle_click_opens_new_tab=YES
 
+# Mouse middle click by default drives drag-scrolling.
+# To paste an URL into the window instead of scrolling, set it to NO.
+# Note: You could always paste the URL onto the URL box clear button.
+#middle_click_drags_page=YES
+
 # Focus follows new Tabs.
 # You can hold SHIFT to temporarily revert this behaviour.
 #focus_new_tab=YES
--- a/dlib/dlib.c	Thu Nov 13 21:06:26 2008 +0100
+++ b/dlib/dlib.c	Thu Nov 13 21:12:44 2008 +0100
@@ -776,6 +776,10 @@
       *p = 0;
       *name = *line;
 
+      /* skip whitespace */
+      if (p < eq)
+         for (++p; isspace(*p); ++p);
+
       /* get value */
       if (p == eq) {
          for (++p; isspace(*p); ++p);
--- a/dpi/bookmarks.c	Thu Nov 13 21:06:26 2008 +0100
+++ b/dpi/bookmarks.c	Thu Nov 13 21:12:44 2008 +0100
@@ -44,11 +44,6 @@
 #define _MSG(...)
 #define MSG(...)  printf("[bookmarks dpi]: " __VA_ARGS__)
 
-/* This one is tricky, some sources state it should include the byte
- * for the terminating NULL, and others say it shouldn't. */
-# define D_SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \
-                        + strlen ((ptr)->sun_path))
-
 #define DOCTYPE \
    "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>\n"
 
--- a/dpi/cookies.c	Thu Nov 13 21:06:26 2008 +0100
+++ b/dpi/cookies.c	Thu Nov 13 21:12:44 2008 +0100
@@ -64,12 +64,6 @@
 #define MSG(...)  printf("[cookies dpi]: " __VA_ARGS__)
 
 
-/* This one is tricky, some sources state it should include the byte
- * for the terminating NULL, and others say it shouldn't. */
-# define D_SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \
-                        + strlen ((ptr)->sun_path))
-
-
 /*
  * a_List_add()
  *
@@ -1247,12 +1241,11 @@
          j = 0;
 
          /* Get the domain */
-         while (!isspace(line[i]))
+         while (line[i] != '\0' && !isspace(line[i]))
             domain[j++] = line[i++];
          domain[j] = '\0';
 
          /* Skip past whitespaces */
-         i++;
          while (isspace(line[i]))
             i++;
 
--- a/dpi/downloads.cc	Thu Nov 13 21:06:26 2008 +0100
+++ b/dpi/downloads.cc	Thu Nov 13 21:12:44 2008 +0100
@@ -513,7 +513,7 @@
          if (isdigit(*q++ = *p)) {
             // keep here
          } else if (*p == 'K') {
-            for(--q; isdigit(q[-1]); --q); log_state = ST_discard;
+            for(--q; isdigit(q[-1]); --q) ; log_state = ST_discard;
          } else {
             log_state = ST_copy;
          }
@@ -1027,10 +1027,10 @@
 {
    DLItem *dl_item = mDList->get(n_item);
 
-   // Remove the widget from the scroll group
+   // Remove the widget from the packed group
    mPG->remove(dl_item->get_widget());
-   // Resize the scroll group
-   mPG->resize(mWin->w(), 1);
+   // WORKAROUND: without this call FLTK2 doesn't clear the background.
+   mScroll->redraw();
 
    mDList->del(n_item);
    delete(dl_item);
@@ -1093,7 +1093,7 @@
     mScroll->end();
     mScroll->type(ScrollGroup::VERTICAL);
    mWin->end();
-   mWin->resizable(mPG);
+   mWin->resizable(mScroll);
    mWin->callback(dlwin_esc_cb, NULL);
    mWin->show();
 
--- a/dpi/https.c	Thu Nov 13 21:06:26 2008 +0100
+++ b/dpi/https.c	Thu Nov 13 21:12:44 2008 +0100
@@ -25,7 +25,7 @@
  * the https dillo plugin with the OpenSSL project's "OpenSSL"
  * library, and distribute the linked executables, without including
  * the source code for OpenSSL in the source distribution. You must
- * obey the GNU General Public License, version 2, in all respects
+ * obey the GNU General Public License, version 3, in all respects
  * for all of the code used other than "OpenSSL".
  *
  */
--- a/dpid/Makefile.am	Thu Nov 13 21:06:26 2008 +0100
+++ b/dpid/Makefile.am	Thu Nov 13 21:12:44 2008 +0100
@@ -3,7 +3,7 @@
 bin_PROGRAMS = dpid
 dpid_LDADD = ../dpip/libDpip.a ../dlib/libDlib.a
 
-EXTRA_DIST = dpidc
+EXTRA_DIST = dpidc dpidrc.in
 bin_SCRIPTS = dpidc
 
 dpid_SOURCES = \
@@ -21,11 +21,9 @@
 	main.c \
 	misc_new.c
 
-install-data-local :
-	$(mkinstalldirs) $(DESTDIR)$(sysconfdir)
-	echo dpi_dir=$(libdir)/dillo/dpi > $(DESTDIR)$(sysconfdir)/dpidrc
-	echo >> $(DESTDIR)$(sysconfdir)/dpidrc
-	echo "proto.file=file/file.dpi" >> $(DESTDIR)$(sysconfdir)/dpidrc
-	echo "proto.ftp=ftp/ftp.filter.dpi" >> $(DESTDIR)$(sysconfdir)/dpidrc
-	echo "proto.https=https/https.filter.dpi" >> $(DESTDIR)$(sysconfdir)/dpidrc
-	echo "proto.data=datauri/datauri.filter.dpi" >> $(DESTDIR)$(sysconfdir)/dpidrc
+sysconf_DATA = dpidrc
+CLEANFILES = $(sysconf_DATA)
+
+dpidrc: dpidrc.in Makefile
+	sed -e 's|[@]libdir[@]|$(libdir)|' dpidrc.in > dpidrc
+
--- a/dpid/dpid.c	Thu Nov 13 21:06:26 2008 +0100
+++ b/dpid/dpid.c	Thu Nov 13 21:12:44 2008 +0100
@@ -728,7 +728,6 @@
       DpiBye_cmd = a_Dpip_build_cmd("cmd=%s", "DpiBye");
 
    sun_path_len = sizeof(sa.sun_path);
-   addr_len = sizeof(dpi_addr);
 
    dpi_addr.sun_family = AF_LOCAL;
 
@@ -746,6 +745,7 @@
          MSG_ERR("\n - socket path = %s\n", dpi_attr_list[i].sockpath);
       }
       strncpy(dpi_addr.sun_path, dpi_attr_list[i].sockpath, sun_path_len);
+      addr_len = D_SUN_LEN(&dpi_addr);
       if (connect(dpi_socket, (struct sockaddr *) &dpi_addr, addr_len) == -1) {
          ERRMSG("stop_active_dpis", "connect", errno);
          MSG_ERR("%s\n", dpi_addr.sun_path);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dpid/dpidrc.in	Thu Nov 13 21:12:44 2008 +0100
@@ -0,0 +1,6 @@
+dpi_dir=@libdir@/dillo/dpi
+
+proto.file=file/file.dpi
+proto.ftp=ftp/ftp.filter.dpi
+proto.https=https/https.filter.dpi
+proto.data=datauri/datauri.filter.dpi
--- a/dw/findtext.hh	Thu Nov 13 21:06:26 2008 +0100
+++ b/dw/findtext.hh	Thu Nov 13 21:12:44 2008 +0100
@@ -65,7 +65,7 @@
 
    inline static bool charsEqual (char c1, char c2, bool caseSens)
    { return caseSens ? c1 == c2 : tolower (c1) == tolower (c2) ||
-      isspace (c1) && isspace (c2); }
+      (isspace (c1) && isspace (c2)); }
 
 public:
    FindtextState ();
--- a/dw/fltkviewbase.cc	Thu Nov 13 21:06:26 2008 +0100
+++ b/dw/fltkviewbase.cc	Thu Nov 13 21:12:44 2008 +0100
@@ -204,6 +204,10 @@
                                  translateViewYToCanvasY (event_y ()),
                                  getDwButtonState (), event_button ());
       //printf ("PUSH => %s\n", processed ? "true" : "false");
+      if (processed) {
+         /* pressed dw content; fltk widgets should no longer have focus */
+         ::fltk::focus(NULL);
+      }
       return processed ? true : Group::handle (event);
 
    case RELEASE:
--- a/dw/style.hh	Thu Nov 13 21:06:26 2008 +0100
+++ b/dw/style.hh	Thu Nov 13 21:12:44 2008 +0100
@@ -346,11 +346,11 @@
 
 /** \brief Returns a percentage, \em v is relative to 1, not to 100. */
 inline Length createPerLength(double v) {
-   return (int)(v * (1 << 18)) & ~3 | 2; }
+   return ((int)(v * (1 << 18)) & ~3) | 2; }
 
 /** \brief Returns a relative length. */
 inline Length createRelLength(double v) {
-   return (int)(v * (1 << 18)) & ~3 | 3; }
+   return ((int)(v * (1 << 18)) & ~3) | 3; }
 
 /** \brief Returns true if \em l is an absolute length. */
 inline bool isAbsLength(Length l) { return (l & 3) == 1; }
--- a/lout/misc.hh	Thu Nov 13 21:06:26 2008 +0100
+++ b/lout/misc.hh	Thu Nov 13 21:12:44 2008 +0100
@@ -166,7 +166,7 @@
     */
    inline T* getRef (int i) {
       if (BOUND_CHECKING)
-         assert (i >= 0 && i < this->num);
+         assert (i >= 0 && this->num - i > 0);
       return array + i;
    }
 
--- a/lout/object.cc	Thu Nov 13 21:06:26 2008 +0100
+++ b/lout/object.cc	Thu Nov 13 21:12:44 2008 +0100
@@ -251,7 +251,7 @@
 
    return
       // Identical?
-      this == other ||
+      this == other || (
       (// Both first parts are NULL, ...
          (first == NULL && otherPair->first == NULL) ||
          // ... or both first parts are not NULL and equal
@@ -260,7 +260,7 @@
       // Same with second part.
       ((second == NULL && otherPair->second == NULL) ||
        (second != NULL && otherPair->second != NULL
-        && second->equals (otherPair->second)));
+        && second->equals (otherPair->second))));
 }
 
 int PairBase::hashValue()
--- a/src/IO/dpi.c	Thu Nov 13 21:06:26 2008 +0100
+++ b/src/IO/dpi.c	Thu Nov 13 21:12:44 2008 +0100
@@ -353,7 +353,7 @@
       strncpy(pun.sun_path, uds_name, sizeof (pun.sun_path));
 
       if ((SockFD = socket(AF_LOCAL, SOCK_STREAM, 0)) == -1 ||
-          connect(SockFD, (void*)&pun, D_SUN_LEN(&pun)) == -1) {
+          connect(SockFD, (struct sockaddr *) &pun, D_SUN_LEN(&pun)) == -1) {
          MSG("Dpi_check_uds: %s %s\n", dStrerror(errno), uds_name);
       } else {
          Dpi_close_fd(SockFD);
@@ -497,7 +497,7 @@
       _MSG("dpid_uds_name = [%s]\n", dpid_uds_name);
       strncpy(dpid.sun_path, dpid_uds_name, sizeof(dpid.sun_path));
 
-      if (connect(sock, (struct sockaddr *) &dpid, sizeof(dpid)) == -1)
+      if (connect(sock, (struct sockaddr *) &dpid, D_SUN_LEN(&dpid)) == -1)
          perror("connect");
       /* ask dpid to check the server plugin and send its UDS name back */
       request = a_Dpip_build_cmd("cmd=%s msg=%s", "check_server", server_name);
@@ -717,7 +717,6 @@
 
    srs_name = Dpi_get_dpid_uds_name();
    sun_path_len = sizeof(sa.sun_path);
-   addr_len = sizeof(sa);
 
    sa.sun_family = AF_LOCAL;
 
@@ -725,6 +724,7 @@
       MSG("a_Dpi_bye_dpid: %s\n", dStrerror(errno));
    }
    strncpy(sa.sun_path, srs_name, sizeof (sa.sun_path));
+   addr_len = D_SUN_LEN(&sa);
    if (connect(new_socket, (struct sockaddr *) &sa, addr_len) == -1) {
       MSG("a_Dpi_bye_dpid: %s\n", dStrerror(errno));
       MSG("%s\n", sa.sun_path);
--- a/src/IO/http.c	Thu Nov 13 21:06:26 2008 +0100
+++ b/src/IO/http.c	Thu Nov 13 21:12:44 2008 +0100
@@ -398,6 +398,7 @@
          dFree(np);
       }
    }
+   _MSG("Http_must_use_proxy: %s\n  %s\n", URL_STR(url), ret ? "YES":"NO");
    return ret;
 }
 
--- a/src/cookies.c	Thu Nov 13 21:06:26 2008 +0100
+++ b/src/cookies.c	Thu Nov 13 21:12:44 2008 +0100
@@ -254,12 +254,11 @@
          j = 0;
 
          /* Get the domain */
-         while (!isspace(line[i]))
+         while (line[i] != '\0' && !isspace(line[i]))
             domain[j++] = line[i++];
          domain[j] = '\0';
 
          /* Skip past whitespaces */
-         i++;
          while (isspace(line[i]))
             i++;
 
--- a/src/css.cc	Thu Nov 13 21:06:26 2008 +0100
+++ b/src/css.cc	Thu Nov 13 21:12:44 2008 +0100
@@ -144,6 +144,10 @@
    sheet[CSS_PRIMARY_USER_IMPORTANT] = userImportantStyle;
 }
 
+CssContext::~CssContext () {
+}
+
+
 void CssContext::apply (CssPropertyList *props, Doctree *docTree,
          CssPropertyList *tagStyle, CssPropertyList *nonCss) {
 
--- a/src/dialog.cc	Thu Nov 13 21:06:26 2008 +0100
+++ b/src/dialog.cc	Thu Nov 13 21:12:44 2008 +0100
@@ -193,7 +193,7 @@
    txt[0] = txt[6] = NULL;
    txt[1] = alt1; txt[2] = alt2; txt[3] = alt3;
    txt[4] = alt4; txt[5] = alt5;
-   for (int i=1; txt[i]; ++i, ++nb);
+   for (int i=1; txt[i]; ++i, ++nb) ;
 
    Window *window = new Window(ww,wh,"Choice5");
    window->begin();
--- a/src/dillo.cc	Thu Nov 13 21:06:26 2008 +0100
+++ b/src/dillo.cc	Thu Nov 13 21:12:44 2008 +0100
@@ -26,6 +26,7 @@
 
 #include <fltk/Window.h>
 #include <fltk/TabGroup.h>
+#include <fltk/Font.h>
 #include <fltk/run.h>
 
 #include "msg.h"
@@ -108,6 +109,12 @@
    // WORKAROUND: sometimes the default pager triggers redraw storms
    fltk::TabGroup::default_pager(fltk::PAGER_SHRINK);
 
+   fltk::Font *dfont = fltk::font(prefs.vw_fontname, 0);
+   if (dfont) {
+      fltk::Widget::default_style->textfont(dfont);
+      fltk::Widget::default_style->labelfont(dfont);
+   }
+
    // Create a new UI/bw pair
    BrowserWindow *bw = a_UIcmd_browser_window_new(0, 0, NULL);
 
--- a/src/dns.c	Thu Nov 13 21:06:26 2008 +0100
+++ b/src/dns.c	Thu Nov 13 21:12:44 2008 +0100
@@ -18,6 +18,7 @@
 #include <netdb.h>
 #include <sys/types.h>
 #include <sys/socket.h>
+#include <arpa/inet.h>
 #include <netinet/in.h>
 #include <errno.h>
 #include <unistd.h>
@@ -268,6 +269,8 @@
    struct addrinfo hints, *res0;
    int error;
    Dlist *hosts;
+   size_t length, i;
+   char addr_string[40];
 
    memset(&hints, 0, sizeof(hints));
    hints.ai_family = AF_UNSPEC;
@@ -307,8 +310,18 @@
    }
 
    /* tell our findings */
-   MSG("Dns_server [%d]: %s is %p\n", channel,
-       dns_server[channel].hostname, hosts);
+   MSG("Dns_server [%d]: %s is", channel,
+       dns_server[channel].hostname);
+   if ((length = dList_length(hosts))) {
+      for (i = 0; i < length; i++) {
+         a_Dns_dillohost_to_string(dList_nth_data(hosts, i),
+                                   addr_string, sizeof(addr_string));
+         MSG(" %s", addr_string);
+      }
+      MSG("\n");
+   } else {
+      MSG(" (nil)\n");
+   }
    dns_server[channel].addr_list = hosts;
    dns_server[channel].ip_ready = TRUE;
 
@@ -482,3 +495,20 @@
    dFree(dns_cache);
 }
 
+/*
+ *  Writes a string representation of the given DilloHost
+ *  into dst. dst will be \0 terminated.
+ *  Please note that dst must be at least 40 bytes long for IPv6
+ *  addresses.
+ */
+void a_Dns_dillohost_to_string(DilloHost *host, char *dst, size_t size)
+{
+   if (!inet_ntop(host->af, host->data, dst, size)) {
+      switch (errno) {
+         case EAFNOSUPPORT:
+            snprintf(dst, size, "Unknown address family");
+         case ENOSPC:
+            snprintf(dst, size, "Buffer too small");
+      }
+   }
+}
--- a/src/dns.h	Thu Nov 13 21:06:26 2008 +0100
+++ b/src/dns.h	Thu Nov 13 21:12:44 2008 +0100
@@ -22,7 +22,7 @@
   int alen;
   char data[DILLO_ADDR_MAX];
 } DilloHost;
-
+void a_Dns_dillohost_to_string(DilloHost *host, char *dst, size_t size);
 
 #ifdef __cplusplus
 }
--- a/src/html.cc	Thu Nov 13 21:06:26 2008 +0100
+++ b/src/html.cc	Thu Nov 13 21:12:44 2008 +0100
@@ -724,10 +724,12 @@
    if (link == -1) {
       _MSG(" Link  LEAVE  notify...\n");
       a_UIcmd_set_msg(bw, "");
+      a_UIcmd_set_pointer_on_link(bw, FALSE);
    } else {
       _MSG(" Link  ENTER  notify...\n");
       Html_set_link_coordinates(html, link, x, y);
       a_UIcmd_set_msg(bw, "%s", URL_STR(html->links->get(link)));
+      a_UIcmd_set_pointer_on_link(bw, TRUE);
    }
    return true;
 }
@@ -997,7 +999,7 @@
 
    } else if (isalpha(*s)) {
       /* character entity reference */
-      while (*++s && (isalnum(*s) || strchr(":_.-", *s)));
+      while (*++s && (isalnum(*s) || strchr(":_.-", *s))) ;
       c = *s;
       *s = 0;
 
@@ -1177,10 +1179,10 @@
       Pword = a_Html_parse_entities(html, word, size);
       for (start = i = 0; Pword[i]; start = i)
          if (isspace(Pword[i])) {
-            while (Pword[++i] && isspace(Pword[i]));
+            while (Pword[++i] && isspace(Pword[i])) ;
             Html_process_space(html, Pword + start, i - start);
          } else {
-            while (Pword[++i] && !isspace(Pword[i]));
+            while (Pword[++i] && !isspace(Pword[i])) ;
             ch = Pword[i];
             Pword[i] = 0;
             DW2TB(html->dw)->addText(Pword, html->styleEngine->style ());
@@ -1199,7 +1201,7 @@
          Pword = a_Html_parse_entities(html, word, size);
          for (i = 0; Pword[i]; ++i)
             if (strchr("\t\f\n\r", Pword[i]))
-               for (j = i; (Pword[j] = Pword[j+1]); ++j);
+               for (j = i; (Pword[j] = Pword[j+1]); ++j) ;
    
          DW2TB(html->dw)->addText(Pword, html->styleEngine->style ());
          dFree(Pword);
@@ -1319,8 +1321,8 @@
           (cmp = (new_idx != html->stack->getRef(stack_idx)->tag_idx)) &&
           ((w3c_mode &&
             Tags[html->stack->getRef(stack_idx)->tag_idx].EndTag == 'O') ||
-           (!w3c_mode &&
-            (Tags[html->stack->getRef(stack_idx)->tag_idx].EndTag == 'O') ||
+           ((!w3c_mode &&
+            (Tags[html->stack->getRef(stack_idx)->tag_idx].EndTag == 'O')) ||
              Tags[html->stack->getRef(stack_idx)->tag_idx].TagLevel <
              Tags[new_idx].TagLevel))) {
       --stack_idx;
@@ -1504,7 +1506,7 @@
     * and replace '\n' and '\r' with ' ' inside quoted strings. */
    for (i = 0, p = ntag; *p; ++p) {
       if (isspace(*p)) {
-         for (ntag[i++] = ' '; isspace(p[1]); ++p);
+         for (ntag[i++] = ' '; isspace(p[1]); ++p) ;
       } else if ((quote = *p) == '"' || *p == '\'') {
          for (ntag[i++] = *p++; (ntag[i++] = *p) && *p != quote; ++p) {
             if (*p == '\n' || *p == '\r')
@@ -2892,7 +2894,7 @@
             sprintf(delay_str, ".");
 
          /* Skip to anything after "URL=" */
-         while (*content && *(content++) != '=');
+         while (*content && *(content++) != '=') ;
 
          /* Send a custom HTML message.
           * TODO: This is a hairy hack,
@@ -3745,7 +3747,7 @@
 
       if (isspace(buf[buf_index])) {
          /* whitespace: group all available whitespace */
-         while (++buf_index < bufsize && isspace(buf[buf_index]));
+         while (++buf_index < bufsize && isspace(buf[buf_index])) ;
          Html_process_space(html, buf + token_start, buf_index - token_start);
          token_start = buf_index;
 
--- a/src/prefs.c	Thu Nov 13 21:06:26 2008 +0100
+++ b/src/prefs.c	Thu Nov 13 21:12:44 2008 +0100
@@ -61,6 +61,7 @@
 
 /* define enumeration values to be returned for specific symbols */
 typedef enum {
+   DRC_TOKEN_MIDDLE_CLICK_DRAGS_PAGE,
    DRC_TOKEN_ALLOW_WHITE_BG,
    DRC_TOKEN_BG_COLOR,
    DRC_TOKEN_CONTRAST_VISITED_COLOR,
@@ -141,6 +142,7 @@
    { "limit_text_width", DRC_TOKEN_LIMIT_TEXT_WIDTH },
    { "link_color", DRC_TOKEN_LINK_COLOR },
    { "load_images", DRC_TOKEN_LOAD_IMAGES },
+   { "middle_click_drags_page", DRC_TOKEN_MIDDLE_CLICK_DRAGS_PAGE },
    { "middle_click_opens_new_tab", DRC_TOKEN_MIDDLE_CLICK_OPENS_NEW_TAB },
    { "no_proxy", DRC_TOKEN_NOPROXY },
    { "panel_size", DRC_TOKEN_PANEL_SIZE },
@@ -236,6 +238,9 @@
    case DRC_TOKEN_ALLOW_WHITE_BG:
       prefs.allow_white_bg = (strcmp(value, "YES") == 0);
       break;
+   case DRC_TOKEN_MIDDLE_CLICK_DRAGS_PAGE:
+      prefs.middle_click_drags_page = (strcmp(value, "YES") == 0);
+      break;
    case DRC_TOKEN_FORCE_MY_COLORS:
       prefs.force_my_colors = (strcmp(value, "YES") == 0);
       break;
@@ -459,6 +464,7 @@
    prefs.save_dir = dStrdup(D_SAVE_DIR);
    prefs.show_msg = TRUE;
    prefs.show_extra_warnings = FALSE;
+   prefs.middle_click_drags_page = TRUE;
 
    /* this locale stuff is to avoid parsing problems with float numbers */
    old_locale = dStrdup (setlocale (LC_NUMERIC, NULL));
--- a/src/prefs.h	Thu Nov 13 21:06:26 2008 +0100
+++ b/src/prefs.h	Thu Nov 13 21:12:44 2008 +0100
@@ -62,6 +62,7 @@
    char *save_dir;
    bool_t show_msg;
    bool_t show_extra_warnings;
+   bool_t middle_click_drags_page;
 };
 
 /* Global Data */
--- a/src/styleengine.cc	Thu Nov 13 21:06:26 2008 +0100
+++ b/src/styleengine.cc	Thu Nov 13 21:12:44 2008 +0100
@@ -41,6 +41,7 @@
 
 StyleEngine::~StyleEngine () {
    delete stack;
+   delete cssContext;
 }
 
 /**
--- a/src/table.cc	Thu Nov 13 21:06:26 2008 +0100
+++ b/src/table.cc	Thu Nov 13 21:12:44 2008 +0100
@@ -35,7 +35,7 @@
 
 static void Html_tag_open_table_cell(DilloHtml *html,
                                      const char *tag, int tagsize,
-                                     dw::core::style::TextAlignType text_align);
+                                    dw::core::style::TextAlignType text_align);
 
 /*
  * <TABLE>
@@ -287,8 +287,9 @@
 
       if (html->styleEngine->style ()->textAlign
           == TEXT_ALIGN_STRING)
-         col_tb = new dw::TableCell (((dw::Table*)S_TOP(html)->table)->getCellRef (),
-                                     prefs.limit_text_width);
+         col_tb = new dw::TableCell (
+                     ((dw::Table*)S_TOP(html)->table)->getCellRef (),
+                     prefs.limit_text_width);
       else
          col_tb = new Textblock (prefs.limit_text_width);
 
--- a/src/ui.cc	Thu Nov 13 21:06:26 2008 +0100
+++ b/src/ui.cc	Thu Nov 13 21:12:44 2008 +0100
@@ -621,9 +621,7 @@
 {
    int s_h = 20;
 
-   Font *f = font(prefs.vw_fontname, 0);
-   if (f)
-      this->labelfont(f);
+   PointerOnLink = FALSE;
 
    Tabs = NULL;
    TabTooltip = NULL;
@@ -801,6 +799,14 @@
             ret = 1;
          }
       }
+
+   } else if (event == PUSH) {
+      if (prefs.middle_click_drags_page == 0 &&
+          event_button() == MiddleButton &&
+          !a_UIcmd_pointer_on_link(a_UIcmd_get_bw_by_widget(this))) {
+         paste_url();
+         ret = 1;
+      }
    }
 
    if (!ret)
--- a/src/ui.hh	Thu Nov 13 21:06:26 2008 +0100
+++ b/src/ui.hh	Thu Nov 13 21:12:44 2008 +0100
@@ -64,6 +64,7 @@
 
    UIPanelmode Panelmode;
    Findbar *findbar;
+   int PointerOnLink;
 
    PackedGroup *make_toolbar(int tw, int th);
    PackedGroup *make_location();
@@ -103,6 +104,8 @@
 
    CustTabGroup *tabs() { return Tabs; }
    void tabs(CustTabGroup *tabs) { Tabs = tabs; }
+   int pointerOnLink() { return PointerOnLink; }
+   void pointerOnLink(int flag) { PointerOnLink = flag; }
 
    // Hooks to method callbacks
    void panel_cb_i();
--- a/src/uicmd.cc	Thu Nov 13 21:06:26 2008 +0100
+++ b/src/uicmd.cc	Thu Nov 13 21:12:44 2008 +0100
@@ -33,6 +33,8 @@
 
 #include "nav.h"
 
+#define DEFAULT_TAB_LABEL "Dillo"
+
 // Handy macro
 #define BW2UI(bw) ((UI*)((bw)->ui))
 
@@ -83,11 +85,12 @@
    void remove (Widget *w) {
       TabGroup::remove (w);
       /* fixup resizable in case we just removed it */
-      if (resizable () == w)
+      if (resizable () == w) {
          if (children () > 0)
             resizable (child (children () - 1));
          else
             resizable (NULL);
+      }
 
       if (children () < 2)
          hideLabels ();
@@ -177,7 +180,7 @@
    win->add(DilloTabs);
 
    // Create and set the UI
-   UI *new_ui = new UI(0, 0, ww, wh, "Label", old_bw ? BW2UI(old_bw) : NULL);
+   UI *new_ui = new UI(0, 0, ww, wh, DEFAULT_TAB_LABEL, old_bw ? BW2UI(old_bw) : NULL);
    new_ui->set_status("http://www.dillo.org/");
    new_ui->tabs(DilloTabs);
 
@@ -242,7 +245,7 @@
                                         vbw);
 
    // Create and set the UI
-   UI *new_ui = new UI(0, 0, ui->w(), ui->h(), "Label", ui);
+   UI *new_ui = new UI(0, 0, ui->w(), ui->h(), DEFAULT_TAB_LABEL, ui);
    new_ui->tabs(ui->tabs());
 
    new_ui->tabs()->add(new_ui);
@@ -481,24 +484,21 @@
 void a_UIcmd_save(void *vbw)
 {
    const char *name;
-   char *SuggestedName, *urlstr;
-   DilloUrl *url;
-
-   a_UIcmd_set_save_dir(prefs.save_dir);
+   char *SuggestedName;
+   BrowserWindow *bw = (BrowserWindow *)vbw;
+   const DilloUrl *url = a_History_get_url(NAV_TOP_UIDX(bw));
 
-   urlstr = a_UIcmd_get_location_text((BrowserWindow*)vbw);
-   url = a_Url_new(urlstr, NULL);
-   SuggestedName = UIcmd_make_save_filename(URL_PATH(url));
-   name = a_Dialog_save_file("Save Page as File", NULL, SuggestedName);
-   MSG("a_UIcmd_save: %s\n", name);
-   dFree(SuggestedName);
-   dFree(urlstr);
+   if (url) {
+      a_UIcmd_set_save_dir(prefs.save_dir);
+      SuggestedName = UIcmd_make_save_filename(URL_PATH(url));
+      name = a_Dialog_save_file("Save Page as File", NULL, SuggestedName);
+      MSG("a_UIcmd_save: %s\n", name);
+      dFree(SuggestedName);
 
-   if (name) {
-      a_Nav_save_url((BrowserWindow*)vbw, url, name);
-   }
-
-   a_Url_free(url);
+      if (name) {
+         a_Nav_save_url(bw, url, name);
+      }
+   } 
 }
 
 /*
@@ -912,6 +912,22 @@
 }
 
 /*
+ * Keep track of mouse pointer over a link.
+ */
+void a_UIcmd_set_pointer_on_link(BrowserWindow *bw, int flag)
+{
+   BW2UI(bw)->pointerOnLink(flag);
+}
+
+/*
+ * Is the mouse pointer over a link?
+ */
+int a_UIcmd_pointer_on_link(BrowserWindow *bw)
+{
+   return BW2UI(bw)->pointerOnLink();
+}
+
+/*
  * Toggle control panel (aka. fullscreen)
  */
 void a_UIcmd_fullscreen_toggle(BrowserWindow *bw)
--- a/src/uicmd.hh	Thu Nov 13 21:06:26 2008 +0100
+++ b/src/uicmd.hh	Thu Nov 13 21:12:44 2008 +0100
@@ -73,7 +73,8 @@
 void a_UIcmd_set_images_enabled(BrowserWindow *bw, int flag);
 void a_UIcmd_set_buttons_sens(BrowserWindow *bw);
 void a_UIcmd_fullscreen_toggle(BrowserWindow *bw);
-
+void a_UIcmd_set_pointer_on_link(BrowserWindow *bw, int flag);
+int a_UIcmd_pointer_on_link(BrowserWindow *bw);
 
 #ifdef __cplusplus
 }
--- a/src/url.h	Thu Nov 13 21:06:26 2008 +0100
+++ b/src/url.h	Thu Nov 13 21:12:44 2008 +0100
@@ -95,12 +95,12 @@
 struct _DilloUrl {
    Dstr  *url_string;
    const char *buffer;
-   const char *scheme;            //
-   const char *authority;         //
-   const char *path;              // These are references only
-   const char *query;             // (no need to free them)
-   const char *fragment;          //
-   const char *hostname;          //
+   const char *scheme;            /**/
+   const char *authority;         /**/
+   const char *path;              /* These are references only */
+   const char *query;             /* (no need to free them) */
+   const char *fragment;          /**/
+   const char *hostname;          /**/
    int port;
    int flags;
    Dstr *data;                    /* POST */