[785] in BarnOwl Developers
[D-O-H] r787 - branches/barnowl_unicode/owl
daemon@ATHENA.MIT.EDU (asedeno@MIT.EDU)
Thu Oct 29 18:09:41 2009
Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
To: dirty-owl-hackers@mit.edu
From: asedeno@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Fri, 28 Dec 2007 17:21:58 -0500 (EST)
Author: asedeno
Date: 2007-12-28 17:21:57 -0500 (Fri, 28 Dec 2007)
New Revision: 787
Modified:
branches/barnowl_unicode/owl/message.c
branches/barnowl_unicode/owl/util.c
branches/barnowl_unicode/owl/zephyr.c
Log:
unicode/glib branch
Fixing bug encountered when last field was not null-terminated.
Modified: branches/barnowl_unicode/owl/message.c
===================================================================
--- branches/barnowl_unicode/owl/message.c 2007-12-28 22:04:34 UTC (rev 786)
+++ branches/barnowl_unicode/owl/message.c 2007-12-28 22:21:57 UTC (rev 787)
@@ -78,7 +78,7 @@
owl_pair_create(pair, owl_global_intern(&g, attrname), NULL);
owl_list_append_element(&(m->attributes), pair);
}
- owl_pair_set_value(pair, owl_validate_or_convert(attrvalue, -1));
+ owl_pair_set_value(pair, owl_validate_or_convert(attrvalue));
}
/* return the value associated with the named attribute, or NULL if
Modified: branches/barnowl_unicode/owl/util.c
===================================================================
--- branches/barnowl_unicode/owl/util.c 2007-12-28 22:04:34 UTC (rev 786)
+++ branches/barnowl_unicode/owl/util.c 2007-12-28 22:21:57 UTC (rev 787)
@@ -800,13 +800,13 @@
* out characters in Unicode Plane 16, as we use that plane internally
* for formatting.
*/
-char * owl_validate_or_convert(char *in, int len)
+char * owl_validate_or_convert(char *in)
{
- if (g_utf8_validate(in, len , NULL)) {
+ if (g_utf8_validate(in, -1, NULL)) {
return owl_strip_format_chars(in);
}
else {
- return g_convert(in, len,
+ return g_convert(in, -1,
"UTF-8", "ISO-8859-1",
NULL, NULL, NULL);
}
Modified: branches/barnowl_unicode/owl/zephyr.c
===================================================================
--- branches/barnowl_unicode/owl/zephyr.c 2007-12-28 22:04:34 UTC (rev 786)
+++ branches/barnowl_unicode/owl/zephyr.c 2007-12-28 22:21:57 UTC (rev 787)
@@ -368,7 +368,7 @@
count++;
if (count == j) {
/* just found the end of the field we're looking for */
- return(owl_validate_or_convert(n->z_message + save, -1));
+ return(owl_validate_or_convert(n->z_message + save));
} else {
save = i + 1;
}
@@ -376,7 +376,13 @@
}
/* catch the last field, which might not be null terminated */
if (count == j - 1) {
- return owl_validate_or_convert(n->z_message + save, n->z_message_len - save);
+ char *tmp, *out;
+ tmp = owl_malloc(n->z_message_len-save+5);
+ memcpy(tmp, n->z_message+save, n->z_message_len-save);
+ tmp[n->z_message_len-save]='\0';
+ out = owl_validate_or_convert(tmp);
+ owl_free(tmp);
+ return out;
}
return(owl_strdup(""));