pidgin: c37bb443: Remove the length parameter from zephyr_...

rlaager at pidgin.im rlaager at pidgin.im
Wed Nov 26 17:51:02 EST 2008


-----------------------------------------------------------------
Revision: c37bb443c81847df5cb3b2727c3bb7dae4779eba
Ancestor: 3d22c492c3b48b989122a9b93197b74a72697f81
Author: rlaager at pidgin.im
Date: 2008-11-26T21:14:28
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/c37bb443c81847df5cb3b2727c3bb7dae4779eba

Modified files:
        libpurple/protocols/zephyr/zephyr.c

ChangeLog: 

Remove the length parameter from zephyr_recv_convert(), because we were
always passing it strlen(string) anyway.  strlen() stops at the first NUL,
so if we're assuming the string is NUL-terminated, we can just pass -1 as
the length to g_convert().

-------------- next part --------------
============================================================
--- libpurple/protocols/zephyr/zephyr.c	a796464d1acd656cf53281f77951679de2c7eb51
+++ libpurple/protocols/zephyr/zephyr.c	6d96063779acb0e58d4453ace66a7ad282f079a1
@@ -343,7 +343,7 @@ static zephyr_triple *find_sub_by_id(zep
    Converts strings to utf-8 if necessary using user specified encoding
 */
 
-static gchar *zephyr_recv_convert(PurpleConnection *gc,gchar *string, int len)
+static gchar *zephyr_recv_convert(PurpleConnection *gc, gchar *string)
 {
 	gchar *utf8;
 	GError *err = NULL;
@@ -351,7 +351,7 @@ static gchar *zephyr_recv_convert(Purple
 	if (g_utf8_validate(string, len, NULL)) {
 		return g_strdup(string);
 	} else {
-		utf8 = g_convert(string, len, "UTF-8", zephyr->encoding, NULL, NULL, &err);
+		utf8 = g_convert(string, -1, "UTF-8", zephyr->encoding, NULL, NULL, &err);
 		if (err) {
 			purple_debug_error("zephyr", "recv conversion error: %s\n", err->message);
 			utf8 = g_strdup(_("(There was an error converting this message.	 Check the 'Encoding' option in the Account Editor)"));
@@ -843,7 +843,7 @@ static void handle_message(PurpleConnect
 			tmpescape = g_markup_escape_text(buf, -1);
 			g_free(buf);
 			buf2 = zephyr_to_html(tmpescape);
-			buf3 = zephyr_recv_convert(gc,buf2, strlen(buf2));
+			buf3 = zephyr_recv_convert(gc, buf2);
 			g_free(buf2);
 			g_free(tmpescape);
 		}
@@ -883,7 +883,7 @@ static void handle_message(PurpleConnect
 			   Realm from the sender field */
 			sendertmp = zephyr_strip_local_realm(zephyr,notice.z_sender);
 			send_inst = g_strdup_printf("%s %s",sendertmp,notice.z_class_inst);					
-			send_inst_utf8 = zephyr_recv_convert(gc,send_inst, strlen(send_inst));
+			send_inst_utf8 = zephyr_recv_convert(gc,send_inst);
 			if (!send_inst_utf8) {
 				purple_debug_error("zephyr","send_inst %s became null\n", send_inst);
 				send_inst_utf8 = "malformed instance";
@@ -2580,7 +2580,7 @@ static void zephyr_chat_set_topic(Purple
 												gc->account);
 	gcc = purple_conversation_get_chat_data(gconv);
 
-	topic_utf8 = zephyr_recv_convert(gc,(gchar *)topic,strlen(topic));
+	topic_utf8 = zephyr_recv_convert(gc,(gchar *)topic);
 	purple_conv_chat_set_topic(gcc,sender,topic_utf8);
 	g_free(topic_utf8);
 	return;


More information about the Commits mailing list