merges from irssi.org cvs.
[silc.git] / apps / irssi / src / core / expandos.c
index 777d50e1e38d61d565c3e0633cdd69f86a3cd341..130d6025d3e2ad1bb023f9221401a8df471c02e1 100644 (file)
@@ -431,8 +431,21 @@ static char *expando_sysarch(SERVER_REC *server, void *item, int *free_ret)
 /* Topic of active channel (or address of queried nick) */
 static char *expando_topic(SERVER_REC *server, void *item, int *free_ret)
 {
-       return IS_CHANNEL(item) ? CHANNEL(item)->topic :
-               IS_QUERY(item) ? QUERY(item)->address : "";
+       if (IS_CHANNEL(item))
+               return CHANNEL(item)->topic;
+       if (IS_QUERY(item)) {
+               QUERY_REC *query = QUERY(item);
+
+               if (query->server_tag == NULL)
+                       return "";
+
+                *free_ret = TRUE;
+               return query->address == NULL ?
+                       g_strdup_printf("(%s)", query->server_tag) :
+                       g_strdup_printf("%s (%s)", query->address,
+                                       query->server_tag);
+       }
+        return "";
 }
 
 /* Server tag */