Small tweaks

Lots of new code imported.
This commit is contained in:
rsc 2004-03-21 04:33:13 +00:00
parent a770daa795
commit 2277c5d7bb
86 changed files with 12444 additions and 91 deletions

View file

@ -15,11 +15,15 @@ hgethead(HConnect *c, int many)
int n;
hin = &c->hin;
fprint(2, "hgethead top %p - %p\n", hin->pos, hin->stop);
for(;;){
s = (char*)hin->pos;
pp = s;
fprint(2, "hgethead %p - %p\n", pp, hin->stop);
while(p = memchr(pp, '\n', (char*)hin->stop - pp)){
if(!many || p == pp || p == pp + 1 && *pp == '\r'){
fprint(2, "hgethead %p - %p newline at %p %d\n", pp, hin->stop, p, *pp);
if(!many || p == pp || (p == pp + 1 && *pp == '\r')){
fprint(2, "breaking\n");
pp = p + 1;
break;
}
@ -32,6 +36,7 @@ hgethead(HConnect *c, int many)
memmove(c->hstop, s, n);
c->hstop += n;
*c->hstop = '\0';
fprint(2, "p %p\n", p);
if(p != nil)
return 1;
if(hreadbuf(hin, hin->pos) == nil || hin->state == Hend)

View file

@ -157,10 +157,15 @@ hreadbuf(Hio *h, void *vsave)
memmove(h->start + cpy, hh->pos, in);
hh->pos += in;
}
}else if(in && (in = read(h->fd, h->start + cpy, in)) < 0){
h->state = Herr;
h->pos = h->stop;
return nil;
}else if(in){
fprint(2, "read %d from %d\n", in, h->fd);
if((in = read(h->fd, h->start + cpy, in)) < 0){
fprint(2, "got error: %r\n");
h->state = Herr;
h->pos = h->stop;
return nil;
}
fprint(2, "got %d\n", in);
}
if(in == 0)
h->state = Hend;