vt: fix plumbsel(), snarfsel()
- plumbsel() - remove debug prints - use smalloc() to convert to bytes - fix spurious -1 close of plumb fd - snarfsel() - fix rune buffer leak in open error case
This commit is contained in:
parent
de9aa721f6
commit
80cd634c4d
1 changed files with 19 additions and 15 deletions
|
@ -958,38 +958,42 @@ snarfsel(void)
|
||||||
Biobuf *b;
|
Biobuf *b;
|
||||||
Rune *r;
|
Rune *r;
|
||||||
|
|
||||||
b = Bopen("/dev/snarf", OWRITE|OTRUNC);
|
if((r = selrunes()) == nil)
|
||||||
if(b == nil)
|
|
||||||
return;
|
return;
|
||||||
r = selrunes();
|
if((b = Bopen("/dev/snarf", OWRITE|OTRUNC)) == nil){
|
||||||
if(!r)
|
free(r);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
Bprint(b, "%S", r);
|
Bprint(b, "%S", r);
|
||||||
Bterm(b);
|
Bterm(b);
|
||||||
free(r);
|
free(r);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
plumbsel(void)
|
plumbsel(void)
|
||||||
{
|
{
|
||||||
char buf[1024], wdir[512];
|
char *s, wdir[1024];
|
||||||
Rune *r;
|
Rune *r;
|
||||||
int plumb;
|
int plumb;
|
||||||
|
|
||||||
print("plumb\n");
|
|
||||||
if(getwd(wdir, sizeof wdir) == 0)
|
|
||||||
return;
|
|
||||||
if((r = selrunes()) == nil)
|
if((r = selrunes()) == nil)
|
||||||
return;
|
return;
|
||||||
print("wdir: %s, runes: %S\n", wdir, r);
|
if((s = smprint("%S", r)) == nil){
|
||||||
if((plumb = plumbopen("send", OWRITE)) != -1){
|
free(r);
|
||||||
snprint(buf, sizeof buf, "%S", r);
|
return;
|
||||||
print("buf: '%s'\n", buf);
|
|
||||||
plumbsendtext(plumb, "vt", nil, wdir, buf);
|
|
||||||
}
|
}
|
||||||
close(plumb);
|
|
||||||
free(r);
|
free(r);
|
||||||
|
if(getwd(wdir, sizeof wdir) == nil){
|
||||||
|
free(s);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if((plumb = plumbopen("send", OWRITE)) < 0){
|
||||||
|
free(s);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
plumbsendtext(plumb, "vt", nil, wdir, s);
|
||||||
|
close(plumb);
|
||||||
|
free(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue