Clean up comments and channel prefix list in a test file.
[ircu2.10.12-pk.git] / ircd / m_away.c
index a321f9bb21078513cf65f8e33bfdd47214d5bf6b..00fc7ab5d5627db273bf7a9217dbff3756a098e5 100644 (file)
@@ -129,9 +129,8 @@ static int user_set_away(struct User* user, char* message)
       len = AWAYLEN;
     }
     if (away)
-      away = (char*) MyRealloc(away, len + 1);
-    else
-      away = (char*) MyMalloc(len + 1);
+      MyFree(away);
+    away = (char*) MyMalloc(len + 1);
     assert(0 != away);
 
     user->away = away;
@@ -142,7 +141,7 @@ static int user_set_away(struct User* user, char* message)
 
 
 /*
- * m_away - generic message handler template
+ * m_away - generic message handler
  * - Added 14 Dec 1988 by jto.
  *
  * parv[0] = sender prefix
@@ -154,12 +153,15 @@ static int user_set_away(struct User* user, char* message)
 int m_away(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 {
   char* away_message = parv[1];
+  int was_away = cli_user(sptr)->away != 0;
 
   assert(0 != cptr);
   assert(cptr == sptr);
 
-  if (user_set_away(cli_user(sptr), away_message)) {
-    sendcmdto_serv_butone(sptr, CMD_AWAY, cptr, ":%s", away_message);
+  if (user_set_away(cli_user(sptr), away_message))
+  {
+    if (!was_away)    
+      sendcmdto_serv_butone(sptr, CMD_AWAY, cptr, ":%s", away_message);
     send_reply(sptr, RPL_NOWAWAY);
   }
   else {
@@ -170,7 +172,7 @@ int m_away(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 }
 
 /*
- * ms_away - server message handler template
+ * ms_away - server message handler
  * - Added 14 Dec 1988 by jto.
  *
  * parv[0] = sender prefix