2006-02-16 [wwp] 2.0.0cvs57
[claws.git] / src / quote_fmt_parse.y
index 791d260520b6240eb425ad3d2e1dc28b085fb39e..e345257396df6842fecebd8a40324be9861d5fdf 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2002 Hiroyuki Yamamoto and the Sylpheed-Claws Team
+ * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Sylpheed-Claws Team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -14,7 +14,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
 %{
@@ -42,6 +42,7 @@ int yylex(void);
 
 static MsgInfo *msginfo = NULL;
 static gboolean *visible = NULL;
+static gboolean dry_run = FALSE;
 static gint maxsize = 0;
 static gint stacksize = 0;
 
@@ -52,7 +53,7 @@ static const gchar *quote_str = NULL;
 static const gchar *body = NULL;
 static gint error = 0;
 
-static gint cursor_pos  = 0;
+static gint cursor_pos  = -1;
 
 extern int quote_fmt_firsttime;
 
@@ -116,11 +117,12 @@ gint quote_fmt_get_cursor_pos(void)
        }
 
 void quote_fmt_init(MsgInfo *info, const gchar *my_quote_str,
-                   const gchar *my_body)
+                   const gchar *my_body, gboolean my_dry_run)
 {
        quote_str = my_quote_str;
        body = my_body;
        msginfo = info;
+       dry_run = my_dry_run;
        stacksize = 0;
        add_visibility(TRUE);
        if (buffer != NULL)
@@ -131,7 +133,7 @@ void quote_fmt_init(MsgInfo *info, const gchar *my_quote_str,
          * force LEX initialization
          */
        quote_fmt_firsttime = 1;
-       cursor_pos = 0;
+       cursor_pos = -1;
 }
 
 void quote_fmterror(char *str)
@@ -304,7 +306,7 @@ static void quote_fmt_show_sender_initial(const MsgInfo *msginfo)
        p = msginfo->fromname;
        cur = tmp;
        while (*p) {
-               if (*p && isalnum(*p)) {
+               if (*p && g_utf8_validate(p, 1, NULL)) {
                        *cur = toupper(*p);
                                cur++;
                        len++;
@@ -379,7 +381,7 @@ static void quote_fmt_insert_program_output(const gchar *progname)
                while (fgets(buffer, sizeof(buffer), file)) {
                        INSERT(buffer);
                }
-               fclose(file);
+               pclose(file);
        }
 }
 
@@ -647,9 +649,13 @@ query:
 insert:
        INSERT_FILE OPARENT string CPARENT
        {
-               quote_fmt_insert_file($3);
+               if (!dry_run) {
+                       quote_fmt_insert_file($3);
+               }
        }
        | INSERT_PROGRAMOUTPUT OPARENT string CPARENT
        {
-               quote_fmt_insert_program_output($3);
+               if (!dry_run) {
+                       quote_fmt_insert_program_output($3);
+               }
        };