8 |
|
#include "paths.h" |
9 |
|
#include "meta.h" |
10 |
|
|
11 |
+ |
#ifdef _WIN32 |
12 |
+ |
#include <process.h> /* getpid() */ |
13 |
+ |
#endif |
14 |
|
|
15 |
+ |
|
16 |
|
#define PBSIZE 1000 /* max size of sort block */ |
17 |
|
/* maxalloc must be >= this */ |
18 |
|
|
83 |
|
*/ |
84 |
|
|
85 |
|
void |
86 |
< |
mergesort( /* merge sorted files with list */ |
86 |
> |
pmergesort( /* merge sorted files with list */ |
87 |
|
|
88 |
|
FILE *fi[], /* array of input files */ |
89 |
|
int nf, /* number of input files */ |
105 |
|
|
106 |
|
for (i = 0; i < nf; i++) { /* initialize input files */ |
107 |
|
if ((pp[i] = palloc()) == NULL) |
108 |
< |
error(SYSTEM, "memory exhausted in mergesort"); |
108 |
> |
error(SYSTEM, "memory exhausted in pmergesort"); |
109 |
|
readp(pp[i], fi[i]); |
110 |
|
} |
111 |
|
|
156 |
|
FILE *ofp |
157 |
|
) |
158 |
|
{ |
155 |
– |
char *tfname(); |
159 |
|
FILE *fi[NFILES], *fp; |
160 |
|
int i; |
161 |
|
|
167 |
|
if ((fp = ofp) == NULL) |
168 |
|
fp = efopen(tfname(height + 1, nt), "w"); |
169 |
|
|
170 |
< |
mergesort(fi, nf, pl, pcmp, fp); |
170 |
> |
pmergesort(fi, nf, pl, pcmp, fp); |
171 |
|
|
172 |
|
for (i = 0; i < nf; i++) { |
173 |
|
fclose(fi[i]); |
279 |
|
) |
280 |
|
{ |
281 |
|
static char pathbuf[PATH_MAX]; |
282 |
< |
static char fnbuf[32]; |
282 |
> |
static char fnbuf[PATH_MAX]; |
283 |
> |
static size_t psiz; |
284 |
|
|
285 |
+ |
if (pathbuf[0] == '\0') { /* first time */ |
286 |
+ |
temp_directory(pathbuf, sizeof(pathbuf)); |
287 |
+ |
psiz = strlen(pathbuf); |
288 |
+ |
} |
289 |
+ |
snprintf(fnbuf, sizeof(pathbuf)-psiz, |
290 |
+ |
"%s/S%d%c%d", pathbuf, getpid(), lvl+'A', num); |
291 |
|
/*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); |
292 |
|
|
293 |
< |
/*return(fnbuf);*/ |
286 |
< |
return pathbuf; |
293 |
> |
return(fnbuf); |
294 |
|
} |