* misc.c (argsplit): Properly split quoted args from the keyword and trim
authorDavid Shaw <dshaw@jabberwocky.com>
Wed, 28 Jul 2004 15:36:23 +0000 (15:36 +0000)
committerDavid Shaw <dshaw@jabberwocky.com>
Wed, 28 Jul 2004 15:36:23 +0000 (15:36 +0000)
whitespace afterwards.

g10/ChangeLog
g10/misc.c

index 5d623f8..0bbf97c 100644 (file)
@@ -1,3 +1,8 @@
+2004-07-28  David Shaw  <dshaw@jabberwocky.com>
+
+       * misc.c (argsplit): Properly split quoted args from the keyword
+       and trim whitespace afterwards.
+
 2004-07-27  David Shaw  <dshaw@jabberwocky.com>
 
        * misc.c (optsep): Add the ability to understand keyword="quoted
index 51c0e67..c2dfe35 100644 (file)
@@ -715,23 +715,34 @@ argsplit(char *string)
   equals=strchr(string,'=');
   if(equals)
     {
-      char *space;
+      char *quote,*space;
 
-      space=strchr(string,' ');
-      if(space)
+      *equals='\0';
+      arg=equals+1;
+
+      /* Quoted arg? */
+      quote=strchr(arg,'"');
+      if(quote)
        {
-         *space='\0';
-         arg=space+1;
+         arg=quote+1;
+
+         quote=strchr(arg,'"');
+         if(quote)
+           *quote='\0';
        }
       else
        {
-         *equals='\0';
-         arg=equals+1;
+         size_t spaces;
+
+         /* Trim leading spaces off of the arg */
+         spaces=strspn(arg," ");
+         arg+=spaces;
        }
 
-      space=strrchr(arg,' ');
+      /* Trim tailing spaces off of the tag */
+      space=strchr(string,' ');
       if(space)
-       arg=space+1;
+       *space='\0';
     }
 
   return arg;