version 1.5, 1996/09/24 04:19:26 |
version 1.6, 1997/09/22 05:45:26 |
|
|
|
|
/* Input-file-with-indexable-lines abstract type */ |
/* Input-file-with-indexable-lines abstract type */ |
|
|
static long i_size; /* size of the input file */ |
static off_t i_size; /* size of the input file */ |
static char *i_womp; /* plan a buffer for entire file */ |
static char *i_womp; /* plan a buffer for entire file */ |
static char **i_ptr; /* pointers to lines in i_womp */ |
static char **i_ptr; /* pointers to lines in i_womp */ |
|
|
|
|
#endif |
#endif |
if (i_womp == Nullch) |
if (i_womp == Nullch) |
return FALSE; |
return FALSE; |
if ((ifd = open(filename, 0)) < 0) |
if ((ifd = open(filename, O_RDONLY)) < 0) |
pfatal2("can't open file %s", filename); |
pfatal2("can't open file %s", filename); |
#ifndef lint |
#ifndef lint |
if (read(ifd, i_womp, (int)i_size) != i_size) { |
if (read(ifd, i_womp, (size_t)i_size) != i_size) { |
Close(ifd); /* probably means i_size > 15 or 16 bits worth */ |
Close(ifd); /* probably means i_size > 15 or 16 bits worth */ |
free(i_womp); /* at this point it doesn't matter if i_womp was */ |
free(i_womp); /* at this point it doesn't matter if i_womp was */ |
return FALSE; /* undersized. */ |
return FALSE; /* undersized. */ |
|
|
} |
} |
Fclose(ifp); |
Fclose(ifp); |
Close(tifd); |
Close(tifd); |
if ((tifd = open(TMPINNAME, 0)) < 0) { |
if ((tifd = open(TMPINNAME, O_RDONLY)) < 0) { |
pfatal2("can't reopen file %s", TMPINNAME); |
pfatal2("can't reopen file %s", TMPINNAME); |
} |
} |
} |
} |
|
|
else { |
else { |
tiline[whichbuf] = baseline; |
tiline[whichbuf] = baseline; |
#ifndef lint /* complains of long accuracy */ |
#ifndef lint /* complains of long accuracy */ |
Lseek(tifd, (long)baseline / lines_per_buf * BUFFERSIZE, 0); |
Lseek(tifd, (off_t)(baseline / lines_per_buf * BUFFERSIZE), 0); |
#endif |
#endif |
if (read(tifd, tibuf[whichbuf], BUFFERSIZE) < 0) |
if (read(tifd, tibuf[whichbuf], BUFFERSIZE) < 0) |
pfatal2("error reading tmp file %s", TMPINNAME); |
pfatal2("error reading tmp file %s", TMPINNAME); |