+ do
+ {
+ argument="";
+ quotechar = '\0';
+ // eat leading whitespace:
+ while(*cptr && isspace(*cptr))
+ cptr++;
+ if(*cptr == '\'' || *cptr == '"')
+ quotechar = *cptr++;
+ do
+ {
+ if(*cptr == '\\' && ! escaped)
+ {
+ escaped = TRUE;
+ cptr++;
+ continue;
+ }
+ // all other characters:
+ argument += *cptr ++;
+ escaped = FALSE;
+ // Have we reached the end of the argument?
+ if((*cptr == quotechar && ! escaped)
+ || (quotechar == '\0' && isspace(*cptr))
+ || *cptr == '\0')
+ {
+ wxASSERT(argc < WXEXECUTE_NARGS);
+ argv[argc] = new char[argument.Len()+1];
+ strcpy(argv[argc], argument.c_str());
+ argc++;
+ // if not at end of buffer, swallow last character:
+ if(*cptr) cptr++;
+ break; // done with this one, start over
+ }
+ }while(*cptr);
+ }while(*cptr);
+ argv[argc] = NULL;
+