aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-06-22 03:53:47 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-06-22 03:53:47 +0800
commit34bc515362401bdb0c747b9d4e524e7c2430a9d1 (patch)
tree2778a3856f32ceceaf2fae57b28431d24ba8755e
parentf8db9032d6813046f468718d9d22545a1b519a73 (diff)
downloadgsoc2013-evolution-34bc515362401bdb0c747b9d4e524e7c2430a9d1.tar
gsoc2013-evolution-34bc515362401bdb0c747b9d4e524e7c2430a9d1.tar.gz
gsoc2013-evolution-34bc515362401bdb0c747b9d4e524e7c2430a9d1.tar.bz2
gsoc2013-evolution-34bc515362401bdb0c747b9d4e524e7c2430a9d1.tar.lz
gsoc2013-evolution-34bc515362401bdb0c747b9d4e524e7c2430a9d1.tar.xz
gsoc2013-evolution-34bc515362401bdb0c747b9d4e524e7c2430a9d1.tar.zst
gsoc2013-evolution-34bc515362401bdb0c747b9d4e524e7c2430a9d1.zip
New function that decides if 2 word types are mergeable. An atom and a
2001-06-21 Jeffrey Stedfast <fejj@ximian.com> * camel-mime-utils.c (word_types_compatable): New function that decides if 2 word types are mergeable. An atom and a qstring are mergeable; 2 qstrings are mergeable; and 2 encoded words are mergeable. (header_encode_phrase_merge_words): If 2 words are merged, the new word type is the MAX of the combined types. This means that if we merge a qstring and an atom, the resulting word type is a qstring. * camel-internet-address.c (internet_format): s/g_string_sprintfa/g_string_append since this makes more sense in this particular case. (internet_encode): Same here. svn path=/trunk/; revision=10377
-rw-r--r--camel/ChangeLog16
-rw-r--r--camel/camel-internet-address.c11
-rw-r--r--camel/camel-mime-utils.c62
3 files changed, 59 insertions, 30 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index d3e4ad5f20..a5a593ef23 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,21 @@
2001-06-21 Jeffrey Stedfast <fejj@ximian.com>
+ * camel-mime-utils.c (word_types_compatable): New function that
+ decides if 2 word types are mergeable. An atom and a qstring are
+ mergeable; 2 qstrings are mergeable; and 2 encoded words are
+ mergeable.
+ (header_encode_phrase_merge_words): If 2 words are merged, the new
+ word type is the MAX of the combined types. This means that if we
+ merge a qstring and an atom, the resulting word type is a
+ qstring.
+
+ * camel-internet-address.c (internet_format):
+ s/g_string_sprintfa/g_string_append since this makes more sense in
+ this particular case.
+ (internet_encode): Same here.
+
+2001-06-21 Jeffrey Stedfast <fejj@ximian.com>
+
* providers/smtp/camel-smtp-transport.c (smtp_send): Use
camel_address_length() rather than casting and accessing data
members.
diff --git a/camel/camel-internet-address.c b/camel/camel-internet-address.c
index 902178c303..f9ae9dd37b 100644
--- a/camel/camel-internet-address.c
+++ b/camel/camel-internet-address.c
@@ -132,7 +132,7 @@ internet_encode (CamelAddress *a)
g_string_append(out, ", ");
enc = camel_internet_address_encode_address(&len, addr->name, addr->address);
- g_string_sprintfa(out, "%s", enc);
+ g_string_append(out, enc);
g_free(enc);
}
@@ -228,7 +228,7 @@ internet_format (CamelAddress *a)
g_string_append(out, ", ");
enc = camel_internet_address_format_address(addr->name, addr->address);
- g_string_sprintfa(out, "%s", enc);
+ g_string_append(out, enc);
g_free(enc);
}
@@ -238,7 +238,8 @@ internet_format (CamelAddress *a)
return ret;
}
-static int internet_cat (CamelAddress *dest, const CamelAddress *source)
+static int
+internet_cat (CamelAddress *dest, const CamelAddress *source)
{
int i;
@@ -292,7 +293,7 @@ camel_internet_address_new (void)
* Return value: Index of added entry.
**/
int
-camel_internet_address_add (CamelInternetAddress *a, const char *name, const char *address)
+camel_internet_address_add (CamelInternetAddress *a, const char *name, const char *address)
{
struct _address *new;
int index;
@@ -320,7 +321,7 @@ camel_internet_address_add (CamelInternetAddress *a, const char *name, const cha
* Return value: TRUE if such an address exists, or FALSE otherwise.
**/
gboolean
-camel_internet_address_get (const CamelInternetAddress *a, int index, const char **namep, const char **addressp)
+camel_internet_address_get (const CamelInternetAddress *a, int index, const char **namep, const char **addressp)
{
struct _address *addr;
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index d787559710..5f66c08ab4 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -1405,12 +1405,23 @@ struct _phrase_word {
int encoding;
};
-/* split the input into words
- with info about each word
- merge common word types
- clean up
-*/
+static gboolean
+word_types_compatable (enum _phrase_word_t type1, enum _phrase_word_t type2)
+{
+ switch (type1) {
+ case WORD_ATOM:
+ return type2 == WORD_QSTRING;
+ case WORD_QSTRING:
+ return type2 != WORD_2047;
+ case WORD_2047:
+ return type2 == WORD_2047;
+ default:
+ return FALSE;
+ }
+}
+/* split the input into words with info about each word
+ * merge common word types clean up */
static GList *
header_encode_phrase_get_words (const unsigned char *in)
{
@@ -1431,14 +1442,13 @@ header_encode_phrase_get_words (const unsigned char *in)
newinptr = g_utf8_next_char (inptr);
c = g_utf8_get_char (inptr);
-
+
if (!g_unichar_validate (c)) {
w(g_warning ("Invalid UTF-8 sequence encountered (pos %d, char '%c'): %s",
(inptr - in), inptr[0], in));
inptr++;
continue;
}
-
inptr = newinptr;
if (g_unichar_isspace (c)) {
@@ -1494,29 +1504,31 @@ header_encode_phrase_merge_words (GList **wordsp)
wordl = words;
while (wordl) {
word = wordl->data;
- /* leave atoms as atoms (unless they're surrounded by quoted words??) */
- if (word->type != WORD_ATOM) {
- nextl = g_list_next (wordl);
- while (nextl) {
- next = nextl->data;
- /* merge nodes of the same type AND we are not creating too long a string */
- if (word->type == next->type) {
- if (next->end - word->start < CAMEL_FOLD_PREENCODED) {
- word->end = next->end;
- words = g_list_remove_link (words, nextl);
- g_free (next);
- nextl = g_list_next (wordl);
- } else {
- /* if it is going to be too long, make sure we include the
- separating whitespace */
- word->end = next->start;
- break;
- }
+ nextl = g_list_next (wordl);
+
+ while (nextl) {
+ next = nextl->data;
+ /* merge nodes of the same type AND we are not creating too long a string */
+ if (word_types_compatable (word->type, next->type)) {
+ if (next->end - word->start < CAMEL_FOLD_PREENCODED) {
+ /* the resulting word type is the MAX of the 2 types */
+ word->type = MAX(word->type, next->type);
+
+ word->end = next->end;
+ words = g_list_remove_link (words, nextl);
+ g_free (next);
+ nextl = g_list_next (wordl);
} else {
+ /* if it is going to be too long, make sure we include the
+ separating whitespace */
+ word->end = next->start;
break;
}
+ } else {
+ break;
}
}
+
wordl = g_list_next (wordl);
}