Jean-Marc Lasgouttes wrote:
> I have taken a look at it, and it seems fine to me. I have to admit I
> have problems understanding Forkedcall::generateChild, but I trust
> your carefulness (?).

It's not meant to be hard. It does this:

Store the input string
    "exe option option option"
as a vector<char>

Convert all spaces ' ' to '\0'

Strip the quotes that you added to LibScriptFileSearch so that the string
    "exe 'option' 'option'
becomes the vector<char> "data"
    "exe\0\0option\0\0\0option\0"

Create a vector<char *> "argv" to point to each word of the vector<char>.
It is argv that is passed to execvp. In the above case, argv would
contain:
    argv[0] -> data[0]
    argv[1] -> data[5]
    argv[2] -> data[14]
    argv[3] = '\0'

Doing this means only two calls to "new" and both of these calls are
managed by the vector. No need to clean up after ourselves.

To reassure you that it works, it has been in the 1.4.x tree since 26 March
last year (the vector<char>, vector<char *> change). The stuff to strip
the quotes was added on 25 Oct. It really does work.

-- 
Angus

Reply via email to