2005-01-14 [colin] 0.9.13cvs32.1
authorColin Leroy <colin@colino.net>
Fri, 14 Jan 2005 07:52:51 +0000 (07:52 +0000)
committerColin Leroy <colin@colino.net>
Fri, 14 Jan 2005 07:52:51 +0000 (07:52 +0000)
* src/html.c
* src/html.h
* src/msgcache.c
* AUTHORS
* tools/calypso_convert.pl
Sync with HEAD

AUTHORS
ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/html.c
src/html.h
src/msgcache.c
tools/calypso_convert.pl

diff --git a/AUTHORS b/AUTHORS
index d54ce8e..4afbe4f 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -216,3 +216,4 @@ contributors (beside the above; based on Changelog)
        IWAMOTO Kouichi
        Alex S Moore
        Felix Eckhofer
+       Rich Coe
index f24a348..606180d 100644 (file)
@@ -1,3 +1,12 @@
+2005-01-14 [colin]     0.9.13cvs32.1
+
+       * src/html.c
+       * src/html.h
+       * src/msgcache.c
+       * AUTHORS
+       * tools/calypso_convert.pl
+               Sync with HEAD
+
 2005-01-08 [colin]     0.9.13cvs29.2
 
        * src/prefs_filtering_action.c
index f3921e3..9f53b05 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.1.4.4 -r 1.1.4.5 src/gtk/progressdialog.c; cvs diff -u -r 1.1.4.2 -r 1.1.4.3 src/gtk/progressdialog.h; cvs diff -u -r 1.149.2.18 -r 1.149.2.19 src/inc.c; cvs diff -u -r 1.17.2.5 -r 1.17.2.6 src/send_message.c; ) > 0.9.13cvs28.3.patchset
 ( cvs diff -u -r 1.396.2.18 -r 1.396.2.19 ChangeLog; cvs diff -u -r 1.2504.2.41 -r 1.2504.2.42 ChangeLog.claws; cvs diff -u -r 1.391.2.18 -r 1.391.2.19 ChangeLog.jp; cvs diff -u -r 1.654.2.351 -r 1.654.2.352 configure.ac; cvs diff -u -r 1.56.2.31 -r 1.56.2.32 src/pop.c; cvs diff -u -r 1.17.2.13 -r 1.17.2.14 src/pop.h; ) > 0.9.13cvs29.1.patchset
 ( cvs diff -u -r 1.1.4.9 -r 1.1.4.10 src/prefs_filtering_action.c; cvs diff -u -r 1.59.2.12 -r 1.59.2.13 src/prefs_filtering.c; ) > 0.9.13cvs29.2.patchset
+( cvs diff -u -r 1.12.2.3 -r 1.12.2.4 src/html.c; cvs diff -u -r 1.3 -r 1.4 src/html.h; cvs diff -u -r 1.16.2.11 -r 1.16.2.12 src/msgcache.c; cvs diff -u -r 1.100.2.10 -r 1.100.2.11 AUTHORS; cvs diff -u -r 1.1 -r 1.2 tools/calypso_convert.pl; ) > 0.9.13cvs32.1.patchset
index 1e18a0b..904187e 100644 (file)
@@ -11,9 +11,9 @@ MINOR_VERSION=9
 MICRO_VERSION=13
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=29
+EXTRA_VERSION=32
 EXTRA_RELEASE=
-EXTRA_GTK2_VERSION=.2
+EXTRA_GTK2_VERSION=.1
 
 if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}${EXTRA_RELEASE}${EXTRA_GTK2_VERSION}
index 11f5124..5974236 100644 (file)
@@ -405,12 +405,16 @@ gchar *html_parse(HTMLParser *parser)
 
        while (*parser->bufp != '\0') {
                switch (*parser->bufp) {
-               case '<':
-                       if (parser->str->len == 0)
-                               html_parse_tag(parser);
-                       else
-                               return parser->str->str;
-                       break;
+               case '<': {
+                       HTMLState st;
+                       st = html_parse_tag(parser);
+                       /* when we see an href, we need to flush the str
+                        * buffer.  Then collect all the chars until we
+                        * see the end anchor tag
+                        */
+                       if (HTML_HREF_BEG == st || HTML_HREF == st)
+                           return parser->str->str;
+                       } break;
                case '&':
                        html_parse_special(parser);
                        break;
@@ -632,12 +636,10 @@ static HTMLState html_parse_tag(HTMLParser *parser)
                        g_free(parser->href);
                        parser->href =
                                g_strdup(((HTMLAttr *)tag->attr->data)->value);
-                       parser->state = HTML_HREF;
+                       parser->state = HTML_HREF_BEG;
                }
        } else if (!strcmp(tag->name, "/a")) {
-               g_free(parser->href);
-               parser->href = NULL;
-               parser->state = HTML_NORMAL;
+               parser->state = HTML_HREF;
        } else if (!strcmp(tag->name, "p")) {
                parser->space = FALSE;
                if (!parser->empty_line) {
@@ -731,6 +733,69 @@ static void html_parse_special(HTMLParser *parser)
                        html_append_char(parser, ch);
                        parser->state = HTML_NORMAL;
                        return;
+               } else {
+                   char *symb = NULL;
+                   switch (ch) {
+                   /* http://www.w3schools.com/html/html_entitiesref.asp */
+                   case 338:   /* capital ligature OE  &OElig;  */
+                       symb = "OE";  break;
+                   case 339:   /* small ligature OE    &oelig;  */
+                       symb = "oe";  break;
+                   case 352:   /* capital S w/caron    &Scaron; */
+                   case 353:   /* small S w/caron      &scaron; */
+                   case 376:   /* cap Y w/ diaeres     &Yuml;   */
+                       break;
+                   case 710:   /* circumflex accent    &circ;   */
+                       symb = "^";  break;
+                   case 732:   /* small tilde          &tilde;  */
+                       symb = "~";  break;
+                   case 8194:  /* en space             &ensp;   */
+                   case 8195:  /* em space             &emsp;   */
+                   case 8201:  /* thin space           &thinsp; */
+                       symb = " ";  break;
+                   case 8204:  /* zero width non-joiner &zwnj;  */
+                   case 8205:  /* zero width joiner    &zwj;    */
+                   case 8206:  /* l-t-r mark           &lrm;    */
+                   case 8207:  /* r-t-l mark           &rlm     */
+                       break;
+                   case 8211:  /* en dash              &ndash;  */
+                       symb = "-";  break;
+                   case 8212:  /* em dash              &mdash;  */
+                       symb = "--";  break;
+                   case 8216:  /* l single quot mark   &lsquo;  */
+                       symb = "`";  break;
+                   case 8217:  /* r single quot mark   &rsquo;  */
+                       symb = "'";  break;
+                   case 8218:  /* single low-9 quot    &sbquo;  */
+                       symb = ",";  break;
+                   case 8220:  /* l double quot mark   &ldquo;  */
+                       symb = "``";  break;
+                   case 8221:  /* r double quot mark   &rdquo;  */
+                       symb = "''";  break;
+                   case 8222:  /* double low-9 quot    &bdquo;  */
+                       symb = ",,";  break;
+                   case 8224:  /* dagger               &dagger; */
+                   case 8225:  /* double dagger        &Dagger; */
+                       break;
+                   case 8230:  /* horizontal ellipsis  &hellip; */
+                       symb = "...";  break;
+                   case 8240:  /* per mile             &permil; */
+                       symb = "\%o";  break;
+                   case 8249:  /* l-pointing angle quot &lsaquo; */
+                       symb = "<";  break;
+                   case 8250:  /* r-pointing angle quot &rsaquo; */
+                       symb = ">";  break;
+                   case 8364:  /* euro                 &euro;   */
+                       symb = "&euro";  break;
+                   case 8482:  /* trademark            &trade;  */
+                       symb  = "(TM)";  break;
+                   default: break;
+                   }
+                   if (symb) {
+                       html_append_str(parser, symb, -1);
+                       parser->state = HTML_NORMAL;
+                       return;
+                   }
                }
        }
 
index 7267c17..c7e1a75 100644 (file)
@@ -38,7 +38,8 @@ typedef enum
        HTML_UNKNOWN,
        HTML_CONV_FAILED,
        HTML_ERR,
-       HTML_EOF
+       HTML_EOF,
+       HTML_HREF_BEG
 } HTMLState;
 
 typedef struct _HTMLParser     HTMLParser;
index 4db82a3..6167d2d 100644 (file)
@@ -237,9 +237,10 @@ gint msgcache_get_memory_usage(MsgCache *cache)
 #define READ_CACHE_DATA_INT(n, fp) \
 { \
        guint32 idata; \
+       size_t ni; \
  \
-       if (fread(&idata, sizeof(idata), 1, fp) != 1) { \
-               g_warning("Cache data is corrupted\n"); \
+       if (sizeof(idata) != (ni = fread(&idata, 1, sizeof(idata), fp))) { \
+               g_warning("read_int: Cache data corrupted, read %d of %d at offset %d\n", ni, sizeof(idata), ftell(fp)); \
                procmsg_msginfo_free(msginfo); \
                error = TRUE; \
                break; \
@@ -322,55 +323,39 @@ static FILE *msgcache_open_data_file(const gchar *file, gint version,
        return fp;
 }
 
-static gint msgcache_read_cache_data_str(FILE *fp, gchar **str, StringConverter *conv)
+static gint 
+msgcache_read_cache_data_str(FILE *fp, gchar **str, StringConverter *conv)
 {
-       gchar buf[BUFFSIZE], *tmpstr = NULL;
-       gint ret = 0;
-       guint32 len;
-
-       if (fread(&len, sizeof(len), 1, fp) == 1) {
-               if (len > G_MAXINT)
-                       ret = -1;
-               else {
-                       gchar *tmp = NULL;
-
-                       while (len > 0) {
-                               size_t size = MIN(len, BUFFSIZE - 1);
-
-                               if (fread(buf, size, 1, fp) != 1) {
-                                       ret = -1;
-                                       if (tmp) g_free(tmp);
-                                       tmpstr = NULL;
-                                       break;
-                               }
-
-                               buf[size] = '\0';
-                               if (tmp) {
-                                       *str = g_strconcat(tmp, buf, NULL);
-                                       g_free(tmp);
-                                       tmp = tmpstr;
-                               } else
-                                       tmp = tmpstr = g_strdup(buf);
-
-                               len -= size;
-                       }
-               }
-       } else
-               ret = -1;
-
-       if (ret < 0)
-               g_warning("Cache data is corrupted\n");
-
-       if (tmpstr != NULL && conv != NULL) {
-               *str = conv->convert(conv, tmpstr);
-               g_free(tmpstr);
-       } else if (tmpstr != NULL) {
-               *str = g_strdup(tmpstr);
-               g_free(tmpstr);
-       } else
-               *str = NULL;
-
-       return ret;
+    gchar *tmpstr = NULL;
+    size_t ni;
+    guint32 len;
+
+    *str = NULL;
+    if (sizeof(len) != (ni = fread(&len, 1, sizeof(len), fp))
+       || len > G_MAXINT) {
+       g_warning("read_data_str: Cache data (len) corrupted, read %d of %d bytes at offset %d\n", 
+               ni, sizeof(len), ftell(fp));
+       return -1;
+    }
+    if (0 == len)
+       return 0;
+    tmpstr = g_malloc(len + 1);
+
+    if (len != (ni = fread(tmpstr, 1, len, fp))) {
+       g_warning("read_data_str: Cache data corrupted, read %d of %d bytes at offset %d\n", 
+               ni, len, ftell(fp));
+       g_free(tmpstr);
+       return -1;
+    }
+    tmpstr[len] = 0;
+
+    if (conv != NULL) {
+           *str = conv->convert(conv, tmpstr);
+           g_free(tmpstr);
+    } else 
+           *str = tmpstr;
+
+    return 0;
 }
 
 gchar *strconv_strdup_convert(StringConverter *conv, gchar *srcstr)
index 19ddc89..cded19a 100644 (file)
@@ -143,12 +143,15 @@ sub savemail {
        if (! $testonly ) {
                if ($create_dirs) {
                        $targetdir = $outdir.'/'.$folder ;
-                       ( -d $outdir)    || mkdir $outdir;
-                       ( -d $targetdir) || mkdir $targetdir;
+                       my $curdir = '';
+                       foreach (split('/',$targetdir)) {
+                               $curdir .= $_ . '/';
+                               ( -d $curdir) || mkdir $curdir;
+                       }
                }
 
                open (OUTFILE, ">".$targetdir.'/'.$mailname);
-               foreach (@lines) { printf OUTFILE "$_\n" ; }
+               foreach (@lines) { print OUTFILE "$_\n" ; }
                close (OUTFILE);
 
                if ($incl_attach) {