wr_fd no longer exists, because the object module now buffers
This commit is contained in:
parent
e59812782e
commit
f0dccf3ca0
1 changed files with 21 additions and 13 deletions
|
@ -38,10 +38,13 @@ char **argv;
|
||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern long lseek();
|
||||||
|
|
||||||
strip(name)
|
strip(name)
|
||||||
char *name;
|
char *name;
|
||||||
{
|
{
|
||||||
long size;
|
long size;
|
||||||
|
int fw;
|
||||||
|
|
||||||
if (! rd_open(name)) {
|
if (! rd_open(name)) {
|
||||||
fprintf(stderr, "astrip: cannot open %s\n", name);
|
fprintf(stderr, "astrip: cannot open %s\n", name);
|
||||||
|
@ -68,51 +71,56 @@ char *name;
|
||||||
return(2);
|
return(2);
|
||||||
}
|
}
|
||||||
wr_ohead(&buf);
|
wr_ohead(&buf);
|
||||||
|
wr_close();
|
||||||
if (writeerror) {
|
if (writeerror) {
|
||||||
fprintf(stderr, "astrip: write error on temp file %s\n", tname);
|
fprintf(stderr, "astrip: write error on temp file %s\n", tname);
|
||||||
rd_close();
|
rd_close();
|
||||||
wr_close();
|
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
if(copy(name, tname, size)) {
|
fw = open(tname, 2);
|
||||||
|
if (fw < 0 || lseek(fw, (long)SZ_HEAD, 0) < 0) {
|
||||||
|
fprintf(stderr, "astrip: cannot create temp file %s\n", tname);
|
||||||
rd_close();
|
rd_close();
|
||||||
wr_close();
|
close(fw);
|
||||||
|
return(2);
|
||||||
|
}
|
||||||
|
if(copy(name, tname, size, rd_fd(), fw)) {
|
||||||
|
rd_close();
|
||||||
|
close(fw);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
rd_close();
|
rd_close();
|
||||||
wr_close();
|
close(fw);
|
||||||
size += SZ_HEAD;
|
size += SZ_HEAD;
|
||||||
if (! wr_open(name)) {
|
fw = open(name, 1);
|
||||||
|
if (fw < 0) {
|
||||||
fprintf(stderr, "astrip: cannot write %s\n", name);
|
fprintf(stderr, "astrip: cannot write %s\n", name);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
if (! rd_open(tname)) {
|
if (! rd_open(tname)) {
|
||||||
fprintf(stderr, "astrip: cannot read temp file %s\n", tname);
|
fprintf(stderr, "astrip: cannot read temp file %s\n", tname);
|
||||||
wr_close();
|
close(fw);
|
||||||
return(2);
|
return(2);
|
||||||
}
|
}
|
||||||
if(copy(tname, name, size)) {
|
if(copy(tname, name, size, rd_fd(), fw)) {
|
||||||
wr_close();
|
close(fw);
|
||||||
rd_close();
|
rd_close();
|
||||||
return(2);
|
return(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
wr_close();
|
close(fw);
|
||||||
rd_close();
|
rd_close();
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
copy(fnam, tnam, size)
|
copy(fnam, tnam, size, fr, fw)
|
||||||
char *fnam;
|
char *fnam;
|
||||||
char *tnam;
|
char *tnam;
|
||||||
long size;
|
long size;
|
||||||
{
|
{
|
||||||
register s, n;
|
register s, n;
|
||||||
char lbuf[512];
|
char lbuf[512];
|
||||||
int fr, fw;
|
|
||||||
|
|
||||||
fr = rd_fd();
|
|
||||||
fw = wr_fd();
|
|
||||||
while(size != (long)0) {
|
while(size != (long)0) {
|
||||||
s = 512;
|
s = 512;
|
||||||
if(size < 512)
|
if(size < 512)
|
||||||
|
|
Loading…
Reference in a new issue