/*
* 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
#include "procmsg.h"
#include "procmime.h"
#include "utils.h"
+#include "codeconv.h"
#include "procheader.h"
#include "quote_fmt.h"
static MsgInfo *msginfo = NULL;
static gboolean *visible = NULL;
+static gboolean dry_run = FALSE;
static gint maxsize = 0;
static gint stacksize = 0;
static const gchar *body = NULL;
static gint error = 0;
-static gint cursor_pos = 0;
+static gint cursor_pos = -1;
extern int quote_fmt_firsttime;
}
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)
* force LEX initialization
*/
quote_fmt_firsttime = 1;
- cursor_pos = 0;
+ cursor_pos = -1;
}
void quote_fmterror(char *str)
}
}
- INSERT(result);
+ if (g_utf8_validate(result, -1, NULL)) {
+ INSERT(result);
+ } else {
+ gchar *utf = conv_codeset_strdup(result,
+ conv_get_locale_charset_str_no_utf8(),
+ CS_INTERNAL);
+ if (utf == NULL ||
+ !g_utf8_validate(utf, -1, NULL)) {
+ g_free(utf);
+ utf = g_malloc(strlen(result)*2+1);
+ conv_localetodisp(utf,
+ strlen(result)*2+1, result);
+ }
+ if (g_utf8_validate(utf, -1, NULL)) {
+ INSERT(utf);
+ }
+ g_free(utf);
+ }
}
#undef STR_SIZE
#undef RLEFT
p = msginfo->fromname;
cur = tmp;
while (*p) {
- if (*p && isalnum(*p)) {
+ if (*p && g_utf8_validate(p, 1, NULL)) {
*cur = toupper(*p);
cur++;
len++;
while (fgets(buffer, sizeof(buffer), file)) {
INSERT(buffer);
}
- fclose(file);
+ pclose(file);
}
}
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);
+ }
};