5 |
|
* Sorting routines for meta-files |
6 |
|
*/ |
7 |
|
|
8 |
< |
#include "paths.h" |
8 |
> |
#include "rtprocess.h" /* getpid() */ |
9 |
> |
#include "rterror.h" |
10 |
|
#include "meta.h" |
11 |
|
|
12 |
|
|
80 |
|
*/ |
81 |
|
|
82 |
|
void |
83 |
< |
mergesort( /* merge sorted files with list */ |
83 |
> |
pmergesort( /* merge sorted files with list */ |
84 |
|
|
85 |
|
FILE *fi[], /* array of input files */ |
86 |
|
int nf, /* number of input files */ |
102 |
|
|
103 |
|
for (i = 0; i < nf; i++) { /* initialize input files */ |
104 |
|
if ((pp[i] = palloc()) == NULL) |
105 |
< |
error(SYSTEM, "memory exhausted in mergesort"); |
105 |
> |
error(SYSTEM, "memory exhausted in pmergesort"); |
106 |
|
readp(pp[i], fi[i]); |
107 |
|
} |
108 |
|
|
153 |
|
FILE *ofp |
154 |
|
) |
155 |
|
{ |
155 |
– |
char *tfname(); |
156 |
|
FILE *fi[NFILES], *fp; |
157 |
|
int i; |
158 |
|
|
164 |
|
if ((fp = ofp) == NULL) |
165 |
|
fp = efopen(tfname(height + 1, nt), "w"); |
166 |
|
|
167 |
< |
mergesort(fi, nf, pl, pcmp, fp); |
167 |
> |
pmergesort(fi, nf, pl, pcmp, fp); |
168 |
|
|
169 |
|
for (i = 0; i < nf; i++) { |
170 |
|
fclose(fi[i]); |
276 |
|
) |
277 |
|
{ |
278 |
|
static char pathbuf[PATH_MAX]; |
279 |
< |
static char fnbuf[32]; |
279 |
> |
static char fnbuf[PATH_MAX]; |
280 |
> |
static size_t psiz; |
281 |
|
|
282 |
+ |
if (pathbuf[0] == '\0') { /* first time */ |
283 |
+ |
temp_directory(pathbuf, sizeof(pathbuf)); |
284 |
+ |
psiz = strlen(pathbuf); |
285 |
+ |
} |
286 |
+ |
snprintf(fnbuf, sizeof(pathbuf)-psiz, |
287 |
+ |
"%s/S%d%c%d", pathbuf, getpid(), lvl+'A', num); |
288 |
|
/*sprintf(fnbuf, "%sS%d%c%d", TDIR, getpid(), lvl+'A', num);*/ |
282 |
– |
sprintf(fnbuf, "%c%d_XXXXXX", lvl+'A', num); |
283 |
– |
temp_filename(pathbuf, sizeof(pathbuf), fnbuf); |
289 |
|
|
290 |
< |
/*return(fnbuf);*/ |
286 |
< |
return pathbuf; |
290 |
> |
return(fnbuf); |
291 |
|
} |