(servercmd, io_gets, output): Fix client to read lines longer than
1024 bytes from the server. Closes #1223255.
This commit is contained in:
parent
0b15696223
commit
89e2b3b481
3 changed files with 34 additions and 21 deletions
|
@ -111,23 +111,31 @@ ioq_drain(struct ioqueue *ioq)
|
|||
}
|
||||
|
||||
char *
|
||||
ioq_gets(struct ioqueue *ioq, char *buf, int cc)
|
||||
ioq_gets(struct ioqueue *ioq, char *buf, int cc, int *eol)
|
||||
{
|
||||
char *p;
|
||||
char *end;
|
||||
int nbytes;
|
||||
|
||||
*eol = 0;
|
||||
|
||||
cc--;
|
||||
|
||||
nbytes = ioqtobuf(ioq, buf, cc);
|
||||
if (nbytes < cc)
|
||||
cc = nbytes;
|
||||
end = &buf[cc];
|
||||
end = &buf[nbytes];
|
||||
for (p = buf; p < end && *p; p++) {
|
||||
if (*p == '\n') {
|
||||
*p = '\0';
|
||||
*eol = 1;
|
||||
dequeuecc(ioq, (p - buf) + 1);
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
if (cc && (p - buf) == cc) {
|
||||
dequeuecc(ioq, cc);
|
||||
buf[cc] = '\0';
|
||||
return buf;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue