From d1e409f1f6f9726dc22d77980da44f46ba7036ac Mon Sep 17 00:00:00 2001 From: Peter Kallden Date: Thu, 22 Jan 2004 09:03:06 +0000 Subject: [PATCH] next_arg. slight oversight, when backslashing a needle we need to left shift the string 1 char. git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@574 423420c4-83ab-492f-b58f-81f9feb106b5 --- rdesktop.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/rdesktop.c b/rdesktop.c index 6fe0443..0645b86 100644 --- a/rdesktop.c +++ b/rdesktop.c @@ -750,28 +750,45 @@ next_arg(char *src, char needle) { char *nextval; char *p; + char *mvp = 0; - // EOS + /* EOS */ if (*src == (char) 0x00) return 0; p = src; - // skip escaped needles. + /* skip escaped needles */ while( (nextval = strchr(p, needle) ) ) { - if( *(nextval-1) != '\\' ) + mvp = nextval - 1; + /* found backslashed needle */ + if( *mvp == '\\' && (mvp > src) ) + { + /* move string one to the left */ + while( *(mvp+1) != (char)0x00 ) + { + *mvp = *(mvp+1); + *mvp++; + } + *mvp = (char)0x00; + p = nextval; + } + else + { + p = nextval +1; break; - p = nextval +1; + } + } - // more args available + /* more args available */ if (nextval) { *nextval = (char) 0x00; return ++nextval; } - // no more args after this, jump to EOS + /* no more args after this, jump to EOS */ nextval = src + strlen(src); return nextval; }