* ratchet <
dave...@gmail.com>
Haven't checked all the prerequisities, but:
| static int
| inputproc(ClientData instancedata, char *buf, int toRead, int *errorCodePtr) {
| InteractiveState* is = (InteractiveState* ) instancedata; //not used
| if (input == "") { // blocked!
| return EAGAIN;
| }
| input.copy(buf, input.size());
I'd say you should copy no more than 'toRead' bytes here instead of
input.size(), since 'buf' might not be able to hold more than that, and
you create a buffer overrun if "toRead < input.size()".
Not sure whether this is related to your problem, though.
| This works fine for most things, but if I try to interpret a command
| like "gets stdin name" there are problems. The command causes
| inputproc to run again, but there is no new input yet, so it returns
| EAGAIN. However when the user puts in another string, this is not used
| to set the value of "name." When I watch the "buf" and "toRead"
| variables while debugging, I see some interesting behavior that I
| don't understand. toRead is smaller by the length of "gets stdin " and
| the text "name\n" is in "buf" when inputproc is called.
Could be that the first round did not ask for *all* input, but only a
part of it, but you already have read all of it.
HTH
R'