changeset 1387:3067c096cfc4

Small code cleanup
author Mikael Berthe <mikael@lilotux.net>
date Sun, 02 Dec 2007 18:10:02 +0100
parents 8e763c2c331f
children 40371a7d49f4
files mcabber/connwrap/connwrap.c mcabber/src/commands.c
diffstat 2 files changed, 5 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/connwrap/connwrap.c	Sun Dec 02 17:56:51 2007 +0100
+++ b/mcabber/connwrap/connwrap.c	Sun Dec 02 18:10:02 2007 +0100
@@ -294,7 +294,7 @@
 	char *ip = inet_ntoa(sin->sin_addr), c;
 	struct timeval tv;
 
-	sprintf(buf, "%d", ntohs(sin->sin_port));
+	snprintf(buf, sizeof(buf), "%d", ntohs(sin->sin_port));
 	SOCKOUT("CONNECT ");
 	SOCKOUT(ip);
 	SOCKOUT(":");
--- a/mcabber/src/commands.c	Sun Dec 02 17:56:51 2007 +0100
+++ b/mcabber/src/commands.c	Sun Dec 02 18:10:02 2007 +0100
@@ -306,20 +306,14 @@
   // Locate the end of the word
   for (p2 = p1 ; *p2 && (*p2 != ' ') ; p2++)
     ;
-  // Extract the word
+  // Extract the word and look for an alias in the list
   word = g_strndup(p1, p2-p1);
-
-  // Look for an alias in the list
   value = settings_get(SETTINGS_TYPE_ALIAS, (const char*)word);
-  if (value) {
-    // There is an alias to expand
-    newline = g_new(char, strlen(value)+strlen(p2)+2);
-    *newline = COMMAND_CHAR;
-    strcpy(newline+1, value);
-    strcat(newline, p2);
-  }
   g_free(word);
 
+  if (value)
+    newline = g_strdup_printf("%c%s%s", COMMAND_CHAR, value, p2);
+
   return newline;
 }