2004-12-13 [colin] 0.9.13cvs14.1
authorColin Leroy <colin@colino.net>
Mon, 13 Dec 2004 07:35:44 +0000 (07:35 +0000)
committerColin Leroy <colin@colino.net>
Mon, 13 Dec 2004 07:35:44 +0000 (07:35 +0000)
* src/quote_fmt_parse.y
Sync with HEAD

ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/quote_fmt_parse.y

index 45c197777117caec6671b36204a9759cd298cdab..fdd5aefee6dace880a27c4ca7cc07f76416252de 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-13 [colin]     0.9.13cvs14.1
+
+       * src/quote_fmt_parse.y
+               Sync with HEAD
+
 2004-12-10 [colin]     0.9.13cvs12.1
 
        * src/prefs_themes.c
 2004-12-10 [colin]     0.9.13cvs12.1
 
        * src/prefs_themes.c
index 4ce37bf7937a43e673161d35802f6f8d15cc53cb..d028249eb8393e6614895d4bd3243b3801ca50aa 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.2.2.3 -r 1.2.2.4 src/gtk/colorlabel.c; ) > 0.9.13cvs9.1.patchset
 ( cvs diff -u -r 1.49.2.27 -r 1.49.2.28 src/procmime.c; ) > 0.9.13cvs10.1.patchset
 ( cvs diff -u -r 1.3.2.14 -r 1.3.2.15 src/prefs_themes.c; cvs diff -u -r 1.274.2.25 -r 1.274.2.26 src/mainwindow.c; cvs diff -u -r 1.94.2.36 -r 1.94.2.37 src/messageview.c; ) > 0.9.13cvs12.1.patchset
 ( cvs diff -u -r 1.2.2.3 -r 1.2.2.4 src/gtk/colorlabel.c; ) > 0.9.13cvs9.1.patchset
 ( cvs diff -u -r 1.49.2.27 -r 1.49.2.28 src/procmime.c; ) > 0.9.13cvs10.1.patchset
 ( cvs diff -u -r 1.3.2.14 -r 1.3.2.15 src/prefs_themes.c; cvs diff -u -r 1.274.2.25 -r 1.274.2.26 src/mainwindow.c; cvs diff -u -r 1.94.2.36 -r 1.94.2.37 src/messageview.c; ) > 0.9.13cvs12.1.patchset
+( cvs diff -u -r 1.22.2.5 -r 1.22.2.6 src/quote_fmt_parse.y; ) > 0.9.13cvs14.1.patchset
index c2281b7c8211cb3a4b983ebcaa1b412a71d11445..0b594471f972473027ec8cfd2fb932f63d1241db 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=13
 INTERFACE_AGE=0
 BINARY_AGE=0
 MICRO_VERSION=13
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=12
+EXTRA_VERSION=14
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=.1
 
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=.1
 
index a28647fb5e948278eebc07d9d1a61fc0c5b84546..31336ca5e0c7f271768f38ee618a5b2c2e1778ad 100644 (file)
@@ -143,6 +143,236 @@ static int isseparator(int ch)
 {
        return isspace(ch) || ch == '.' || ch == '-';
 }
 {
        return isspace(ch) || ch == '.' || ch == '-';
 }
+
+static void quote_fmt_show_date(const MsgInfo *msginfo, const gchar *format)
+{
+       char  result[100];
+       char *rptr;
+       char  zone[6];
+       struct tm lt;
+       const char *fptr;
+       const char *zptr;
+
+       if (!msginfo->date)
+               return;
+       
+       /* 
+        * ALF - GNU C's strftime() has a nice format specifier 
+        * for time zone offset (%z). Non-standard however, so 
+        * emulate it.
+        */
+
+#define RLEFT (sizeof result) - (rptr - result)        
+#define STR_SIZE(x) (sizeof (x) - 1)
+
+       zone[0] = 0;
+
+       if (procheader_date_parse_to_tm(msginfo->date, &lt, zone)) {
+               /*
+                * break up format string in tiny bits delimited by valid %z's and 
+                * feed it to strftime(). don't forget that '%%z' mean literal '%z'.
+                */
+               for (rptr = result, fptr = format; fptr && *fptr && rptr < &result[sizeof result - 1];) {
+                       int         perc;
+                       const char *p;
+                       char       *tmp;
+                       
+                       if (NULL != (zptr = strstr(fptr, "%z"))) {
+                               /*
+                                * count nr. of prepended percent chars
+                                */
+                               for (perc = 0, p = zptr; p && p >= format && *p == '%'; p--, perc++)
+                                       ;
+                               /*
+                                * feed to strftime()
+                                */
+                               tmp = g_strndup(fptr, zptr - fptr + (perc % 2 ? 0 : STR_SIZE("%z")));
+                               if (tmp) {
+                                       rptr += strftime(rptr, RLEFT, tmp, &lt);
+                                       g_free(tmp);
+                               }
+                               /*
+                                * append time zone offset
+                                */
+                               if (zone[0] && perc % 2) 
+                                       rptr += g_snprintf(rptr, RLEFT, "%s", zone);
+                               fptr = zptr + STR_SIZE("%z");
+                       } else {
+                               rptr += strftime(rptr, RLEFT, fptr, &lt);
+                               fptr  = NULL;
+                       }
+               }
+               
+               INSERT(result);
+       }
+#undef STR_SIZE                        
+#undef RLEFT                   
+}              
+
+static void quote_fmt_show_first_name(const MsgInfo *msginfo)
+{
+       guchar *p;
+       gchar *str;
+
+       if (!msginfo->fromname)
+               return; 
+       
+       p = strchr(msginfo->fromname, ',');
+       if (p != NULL) {
+               /* fromname is like "Duck, Donald" */
+               p++;
+               while (*p && isspace(*p)) p++;
+               str = alloca(strlen(p) + 1);
+               if (str != NULL) {
+                       strcpy(str, p);
+                       INSERT(str);
+               }
+       } else {
+               /* fromname is like "Donald Duck" */
+               str = alloca(strlen(msginfo->fromname) + 1);
+               if (str != NULL) {
+                       strcpy(str, msginfo->fromname);
+                       p = str;
+                       while (*p && !isspace(*p)) p++;
+                       *p = '\0';
+                       INSERT(str);
+               }
+       }
+}
+
+static void quote_fmt_show_last_name(const MsgInfo *msginfo)
+{
+       gchar *p;
+       gchar *str;
+
+       /* This probably won't work together very well with Middle
+           names and the like - thth */
+       if (!msginfo->fromname) 
+               return;
+
+       str = alloca(strlen(msginfo->fromname) + 1);
+       if (str != NULL) {
+               strcpy(str, msginfo->fromname);
+               p = strchr(str, ',');
+               if (p != NULL) {
+                       /* fromname is like "Duck, Donald" */
+                       *p = '\0';
+                       INSERT(str);
+               } else {
+                       /* fromname is like "Donald Duck" */
+                       p = str;
+                       while (*p && !isspace(*p)) p++;
+                       if (*p) {
+                           /* We found a space. Get first 
+                            none-space char and insert
+                            rest of string from there. */
+                           while (*p && isspace(*p)) p++;
+                           if (*p) {
+                               INSERT(p);
+                           } else {
+                               /* If there is no none-space 
+                                char, just insert whole 
+                                fromname. */
+                               INSERT(str);
+                           }
+                       } else {
+                           /* If there is no space, just 
+                            insert whole fromname. */
+                           INSERT(str);
+                       }
+               }
+       }
+}
+
+static void quote_fmt_show_sender_initial(const MsgInfo *msginfo)
+{
+#define MAX_SENDER_INITIAL 20
+       gchar tmp[MAX_SENDER_INITIAL];
+       guchar *p;
+       gchar *cur;
+       gint len = 0;
+
+       if (!msginfo->fromname) 
+               return;
+
+       p = msginfo->fromname;
+       cur = tmp;
+       while (*p) {
+               if (*p && isalnum(*p)) {
+                       *cur = toupper(*p);
+                               cur++;
+                       len++;
+                       if (len >= MAX_SENDER_INITIAL - 1)
+                               break;
+               } else
+                       break;
+               while (*p && !isseparator(*p)) p++;
+               while (*p && isseparator(*p)) p++;
+       }
+       *cur = '\0';
+       INSERT(tmp);
+}
+
+static void quote_fmt_show_msg(MsgInfo *msginfo, const gchar *body,
+                              gboolean quoted, gboolean signature,
+                              const gchar *quote_str)
+{
+       gchar buf[BUFFSIZE];
+       FILE *fp;
+
+       if (!(msginfo->folder || body))
+               return;
+
+       if (body)
+               fp = str_open_as_stream(body);
+       else
+               fp = procmime_get_first_text_content(msginfo);
+
+       if (fp == NULL)
+               g_warning("Can't get text part\n");
+       else {
+               while (fgets(buf, sizeof(buf), fp) != NULL) {
+                       strcrchomp(buf);
+                       
+                       if (!signature && strncmp(buf, "-- \n", 4) == 0)
+                               break;
+               
+                       if (quoted && quote_str)
+                               INSERT(quote_str);
+                       
+                       INSERT(buf);
+               }
+               fclose(fp);
+       }
+}
+
+static void quote_fmt_insert_file(const gchar *filename)
+{
+       FILE *file;
+       char buffer[256];
+       
+       if ((file = fopen(filename, "rb")) != NULL) {
+               while (fgets(buffer, sizeof(buffer), file)) {
+                       INSERT(buffer);
+               }
+               fclose(file);
+       }
+
+}
+
+static void quote_fmt_insert_program_output(const gchar *progname)
+{
+       FILE *file;
+       char buffer[256];
+
+       if ((file = popen(progname, "r")) != NULL) {
+               while (fgets(buffer, sizeof(buffer), file)) {
+                       INSERT(buffer);
+               }
+               fclose(file);
+       }
+}
+
 %}
 
 %union {
 %}
 
 %union {
@@ -221,65 +451,7 @@ special:
        }
        | SHOW_DATE_EXPR OPARENT string CPARENT
        {
        }
        | SHOW_DATE_EXPR OPARENT string CPARENT
        {
-               /* 
-                * ALF - GNU C's strftime() has a nice format specifier 
-                * for time zone offset (%z). Non-standard however, so 
-                * emulate it.
-                */
-               if (msginfo->date) {
-                       char  result[100];
-                       char *rptr;
-                       char  zone[6];
-                       struct tm lt;
-                       const char *fptr;
-                       const char *zptr;
-
-#define RLEFT (sizeof result) - (rptr - result)        
-#define STR_SIZE(x) (sizeof (x) - 1)
-
-                       zone[0] = 0;
-
-                       if (procheader_date_parse_to_tm(msginfo->date, &lt, zone)) {
-                               /*
-                                * break up format string in tiny bits delimited by valid %z's and 
-                                * feed it to strftime(). don't forget that '%%z' mean literal '%z'.
-                                */
-                               for (rptr = result, fptr = $3; fptr && *fptr && rptr < &result[sizeof result - 1];) {
-                                       int         perc;
-                                       const char *p;
-                                       char       *tmp;
-                                       
-                                       if (NULL != (zptr = strstr(fptr, "%z"))) {
-                                               /*
-                                                * count nr. of prepended percent chars
-                                                */
-                                               for (perc = 0, p = zptr; p && p >= $3 && *p == '%'; p--, perc++)
-                                                       ;
-                                               /*
-                                                * feed to strftime()
-                                                */
-                                               tmp = g_strndup(fptr, zptr - fptr + (perc % 2 ? 0 : STR_SIZE("%z")));
-                                               if (tmp) {
-                                                       rptr += strftime(rptr, RLEFT, tmp, &lt);
-                                                       g_free(tmp);
-                                               }
-                                               /*
-                                                * append time zone offset
-                                                */
-                                               if (zone[0] && perc % 2) 
-                                                       rptr += g_snprintf(rptr, RLEFT, "%s", zone);
-                                               fptr = zptr + STR_SIZE("%z");
-                                       } else {
-                                               rptr += strftime(rptr, RLEFT, fptr, &lt);
-                                               fptr  = NULL;
-                                       }
-                               }
-                               
-                               INSERT(result);
-                       }
-#undef STR_SIZE                        
-#undef RLEFT                   
-               }
+               quote_fmt_show_date(msginfo, $3);
        }
        | SHOW_DATE
        {
        }
        | SHOW_DATE
        {
@@ -298,101 +470,15 @@ special:
        }
        | SHOW_FIRST_NAME
        {
        }
        | SHOW_FIRST_NAME
        {
-               if (msginfo->fromname) {
-                       guchar *p;
-                       gchar *str;
-
-                       p = strchr(msginfo->fromname, ',');
-                       if (p != NULL) {
-                               /* fromname is like "Duck, Donald" */
-                               p++;
-                               while (*p && isspace(*p)) p++;
-                               str = alloca(strlen(p) + 1);
-                               if (str != NULL) {
-                                       strcpy(str, p);
-                                       INSERT(str);
-                               }
-                       } else {
-                               /* fromname is like "Donald Duck" */
-                               str = alloca(strlen(msginfo->fromname) + 1);
-                               if (str != NULL) {
-                                       strcpy(str, msginfo->fromname);
-                                       p = str;
-                                       while (*p && !isspace(*p)) p++;
-                                       *p = '\0';
-                                       INSERT(str);
-                               }
-                       }
-               }
+               quote_fmt_show_first_name(msginfo);
        }
        | SHOW_LAST_NAME
         {
        }
        | SHOW_LAST_NAME
         {
-                /* This probably won't work together very well with Middle
-                 names and the like - thth */
-               if (msginfo->fromname) {
-                       gchar *p;
-                       gchar *str;
-
-                       str = alloca(strlen(msginfo->fromname) + 1);
-                       if (str != NULL) {
-                               strcpy(str, msginfo->fromname);
-                               p = strchr(str, ',');
-                               if (p != NULL) {
-                                       /* fromname is like "Duck, Donald" */
-                                       *p = '\0';
-                                       INSERT(str);
-                               } else {
-                                       /* fromname is like "Donald Duck" */
-                                       p = str;
-                                       while (*p && !isspace(*p)) p++;
-                                       if (*p) {
-                                           /* We found a space. Get first 
-                                            none-space char and insert
-                                            rest of string from there. */
-                                           while (*p && isspace(*p)) p++;
-                                           if (*p) {
-                                               INSERT(p);
-                                           } else {
-                                               /* If there is no none-space 
-                                                char, just insert whole 
-                                                fromname. */
-                                               INSERT(str);
-                                           }
-                                       } else {
-                                           /* If there is no space, just 
-                                            insert whole fromname. */
-                                           INSERT(str);
-                                       }
-                               }
-                       }
-               }
+               quote_fmt_show_last_name(msginfo);
        }
        | SHOW_SENDER_INITIAL
        {
        }
        | SHOW_SENDER_INITIAL
        {
-#define MAX_SENDER_INITIAL 20
-               if (msginfo->fromname) {
-                       gchar tmp[MAX_SENDER_INITIAL];
-                       guchar *p;
-                       gchar *cur;
-                       gint len = 0;
-
-                       p = msginfo->fromname;
-                       cur = tmp;
-                       while (*p) {
-                               if (*p && isalnum(*p)) {
-                                       *cur = toupper(*p);
-                                               cur++;
-                                       len++;
-                                       if (len >= MAX_SENDER_INITIAL - 1)
-                                               break;
-                               } else
-                                       break;
-                               while (*p && !isseparator(*p)) p++;
-                               while (*p && isseparator(*p)) p++;
-                       }
-                       *cur = '\0';
-                       INSERT(tmp);
-               }
+               quote_fmt_show_sender_initial(msginfo);
        }
        | SHOW_SUBJECT
        {
        }
        | SHOW_SUBJECT
        {
@@ -425,99 +511,19 @@ special:
        }
        | SHOW_MESSAGE
        {
        }
        | SHOW_MESSAGE
        {
-               if (msginfo->folder || body) {
-                       gchar buf[BUFFSIZE];
-                       FILE *fp;
-
-                       if (body)
-                               fp = str_open_as_stream(body);
-                       else
-                               fp = procmime_get_first_text_content(msginfo);
-
-                       if (fp == NULL)
-                               g_warning("Can't get text part\n");
-                       else {
-                               while (fgets(buf, sizeof(buf), fp) != NULL) {
-                                       strcrchomp(buf);
-                                       INSERT(buf);
-                               }
-                               fclose(fp);
-                       }
-               }
+               quote_fmt_show_msg(msginfo, body, FALSE, TRUE, quote_str);
        }
        | SHOW_QUOTED_MESSAGE
        {
        }
        | SHOW_QUOTED_MESSAGE
        {
-               if (msginfo->folder || body) {
-                       gchar buf[BUFFSIZE];
-                       FILE *fp;
-
-                       if (body)
-                               fp = str_open_as_stream(body);
-                       else
-                               fp = procmime_get_first_text_content(msginfo);
-
-                       if (fp == NULL)
-                               g_warning("Can't get text part\n");
-                       else {
-                               while (fgets(buf, sizeof(buf), fp) != NULL) {
-                                       strcrchomp(buf);
-                                       if (quote_str)
-                                               INSERT(quote_str);
-                                       INSERT(buf);
-                               }
-                               fclose(fp);
-                       }
-               }
+               quote_fmt_show_msg(msginfo, body, TRUE, TRUE, quote_str);
        }
        | SHOW_MESSAGE_NO_SIGNATURE
        {
        }
        | SHOW_MESSAGE_NO_SIGNATURE
        {
-               if (msginfo->folder || body) {
-                       gchar buf[BUFFSIZE];
-                       FILE *fp;
-
-                       if (body)
-                               fp = str_open_as_stream(body);
-                       else
-                               fp = procmime_get_first_text_content(msginfo);
-
-                       if (fp == NULL)
-                               g_warning("Can't get text part\n");
-                       else {
-                               while (fgets(buf, sizeof(buf), fp) != NULL) {
-                                       strcrchomp(buf);
-                                       if (strncmp(buf, "-- \n", 4) == 0)
-                                               break;
-                                       INSERT(buf);
-                               }
-                               fclose(fp);
-                       }
-               }
+               quote_fmt_show_msg(msginfo, body, FALSE, FALSE, quote_str);
        }
        | SHOW_QUOTED_MESSAGE_NO_SIGNATURE
        {
        }
        | SHOW_QUOTED_MESSAGE_NO_SIGNATURE
        {
-               if (msginfo->folder || body) {
-                       gchar buf[BUFFSIZE];
-                       FILE *fp;
-
-                       if (body)
-                               fp = str_open_as_stream(body);
-                       else
-                               fp = procmime_get_first_text_content(msginfo);
-
-                       if (fp == NULL)
-                               g_warning("Can't get text part\n");
-                       else {
-                               while (fgets(buf, sizeof(buf), fp) != NULL) {
-                                       strcrchomp(buf);
-                                       if (strncmp(buf, "-- \n", 4) == 0)
-                                               break;
-                                       if (quote_str)
-                                               INSERT(quote_str);
-                                       INSERT(buf);
-                               }
-                               fclose(fp);
-                       }
-               }
+               quote_fmt_show_msg(msginfo, body, TRUE, FALSE, quote_str);
        }
        | SHOW_BACKSLASH
        {
        }
        | SHOW_BACKSLASH
        {
@@ -629,29 +635,9 @@ query:
 insert:
        INSERT_FILE OPARENT string CPARENT
        {
 insert:
        INSERT_FILE OPARENT string CPARENT
        {
-               {
-                       FILE *file;
-                       char buffer[256];
-                       
-                       if((file = fopen($3, "rb")) != NULL) {
-                               while(fgets(buffer, sizeof(buffer), file)) {
-                                       INSERT(buffer);
-                               }
-                               fclose(file);
-                       }
-               }
+               quote_fmt_insert_file($3);
        }
        | INSERT_PROGRAMOUTPUT OPARENT string CPARENT
        {
        }
        | INSERT_PROGRAMOUTPUT OPARENT string CPARENT
        {
-               {
-                       FILE *file;
-                       char buffer[256];
-
-                       if((file = popen($3, "r")) != NULL) {
-                               while(fgets(buffer, sizeof(buffer), file)) {
-                                       INSERT(buffer);
-                               }
-                               fclose(file);
-                       }
-               }
+               quote_fmt_insert_program_output($3);
        };
        };