updates
authorPekka Riikonen <priikone@silcnet.org>
Thu, 21 Jun 2001 15:10:06 +0000 (15:10 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Thu, 21 Jun 2001 15:10:06 +0000 (15:10 +0000)
CHANGES
TODO
lib/silcutil/silcutil.c

diff --git a/CHANGES b/CHANGES
index 85738f14f9bfe1a965ee7e984a31e3f4259a060d..2a159c486aac0ceb36e11616649fbde2f535d75f 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,9 @@
+Thu Jun 21 17:10:08 CEST 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Fixed the silc_parse_command_line to remove extra spaces
+         from the start and end of the arguments.  Affected file is
+         lib/silcutil/silcutil.c.
+
 Tue Jun 19 22:10:36 EEST 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
 
        * Fixed a possible crash in silc_packet_send_prepare.  It now
diff --git a/TODO b/TODO
index 83903d2dc2cc4c212a9c31af26901bb8120188ac..ad15d63429dcca71c1c09ca97793ac49063354f4 100644 (file)
--- a/TODO
+++ b/TODO
@@ -3,9 +3,6 @@ TODO/bugs in Irssi SILC client
 
  o LEAVE does not work correctly, it doesn't leave the channel for real!
 
- o The input line parser in client (librarys) doesn't like extra spaces
-   at the end of line (like after commands).
-
  o /KICK does not remove the client from Irssi's NAMES list.
 
  o Giving KILL command crashes the client.
index dee8d90b72569c84b565ce5188b9573fc24b6a16..56ff3090be7d3a0bd8cb150f84f36c1a291017d5 100644 (file)
@@ -420,15 +420,21 @@ void silc_parse_command_line(unsigned char *buffer,
   int i, len = 0;
   int argc = 0;
   const char *cp = buffer;
+  char *tmp;
 
   *parsed = silc_calloc(1, sizeof(**parsed));
   *parsed_lens = silc_calloc(1, sizeof(**parsed_lens));
 
   /* Get the command first */
   len = strcspn(cp, " ");
-  (*parsed)[0] = silc_to_upper((char *)cp);
+  tmp = silc_to_upper((char *)cp);
+  (*parsed)[0] = silc_calloc(len + 1, sizeof(char));
+  memcpy((*parsed)[0], tmp, len);
+  silc_free(tmp);
   (*parsed_lens)[0] = len;
-  cp += len + 1;
+  cp += len;
+  while (*cp == ' ')
+    cp++;
   argc++;
 
   /* Parse arguments */
@@ -439,6 +445,10 @@ void silc_parse_command_line(unsigned char *buffer,
        len = strcspn(cp, " ");
       else
        len = strlen(cp);
+      while (len && cp[len - 1] == ' ')
+       len--;
+      if (!len)
+       break;
       
       *parsed = silc_realloc(*parsed, sizeof(**parsed) * (argc + 1));
       *parsed_lens = silc_realloc(*parsed_lens, 
@@ -452,7 +462,8 @@ void silc_parse_command_line(unsigned char *buffer,
       if (strlen(cp) == 0)
        break;
       else
-       cp++;
+       while (*cp == ' ')
+         cp++;
     }
   }