Subject: GetArgument vs. quotes

From: [email-masked]
Date: Tue, 23 Feb 1999 18:21:01 -0600 (CST)

Full_Name: Matthias Clasen
Version: 2.2
CVS_Date: 
OS: RedHatLinux 5.2
X_Server: XFree 3.3.2
Submission from: (NULL) (132.230.142.6)

The GetArgument function in libs/ModParse.c doesn't properly
update the pstr pointer, if the token contains quotes. 
This can be seen in FvwmEvent:

*FvwmEventCmd Echo
*FvwmEvent "focus_change" "bla bla"
FvwmEvent
 
prints e" instead of bla bla

Fix:

--- ModParse.c.orig	Fri Feb  5 01:24:48 1999
+++ ModParse.c	Fri Feb  5 01:28:33 1999
@@ -25,7 +25,7 @@
 */

-char *PeekArgument(const char *pstr)
+char *DoPeekArgument(const char *pstr, char **pret)
 {
   char *tok=NULL;
   const char *p;
@@ -84,9 +84,16 @@
     }
   }
 
+  if (!isspace(*p)) p++;
+  if (pret) *pret = p;
   return tok;
 }
 
+char *PeekArgument(const char *pstr)
+{
+  return DoPeekArgument(pstr, NULL);
+}
+
 /*
 ** GetArgument: destructively rips next token from string, returning it
 **           (you should free returned string later)
@@ -95,12 +102,10 @@
 {
   char *tok ;
 
-  if (!pstr || !*pstr || !(tok=PeekArgument(*pstr)))
+  if (!pstr || !*pstr || !(tok=DoPeekArgument(*pstr, pstr)))
     return NULL;			/* *pstr=NULL; ???? */
 
   /* skip tok and following whitespace/separators in pstr & DON'T realloc
*/
-  EatWS(*pstr);
-  *pstr += strlen(tok);			/* != actual size (quote-collapsing) */
   EatWS(*pstr);
 
   if (!**pstr) 

--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]