5 |
|
* Sorting routines for meta-files |
6 |
|
*/ |
7 |
|
|
8 |
< |
#include "paths.h" |
8 |
> |
#include "platform.h" /* [_]snprintf() */ |
9 |
> |
#include "rtprocess.h" /* getpid() */ |
10 |
> |
#include "rterror.h" |
11 |
|
#include "meta.h" |
12 |
|
|
11 |
– |
#ifdef _WIN32 |
12 |
– |
#include <process.h> /* getpid() */ |
13 |
– |
#endif |
13 |
|
|
15 |
– |
|
14 |
|
#define PBSIZE 1000 /* max size of sort block */ |
15 |
|
/* maxalloc must be >= this */ |
16 |
|
|
81 |
|
*/ |
82 |
|
|
83 |
|
void |
84 |
< |
mergesort( /* merge sorted files with list */ |
84 |
> |
pmergesort( /* merge sorted files with list */ |
85 |
|
|
86 |
|
FILE *fi[], /* array of input files */ |
87 |
|
int nf, /* number of input files */ |
92 |
|
{ |
93 |
|
PRIMITIVE *plp; /* position in list */ |
94 |
|
PRIMITIVE *pp[NFILES]; /* input primitives */ |
95 |
< |
int minf; |
95 |
> |
int minf = 0; |
96 |
|
PRIMITIVE *minp; |
97 |
|
register int i; |
98 |
|
|
103 |
|
|
104 |
|
for (i = 0; i < nf; i++) { /* initialize input files */ |
105 |
|
if ((pp[i] = palloc()) == NULL) |
106 |
< |
error(SYSTEM, "memory exhausted in mergesort"); |
106 |
> |
error(SYSTEM, "memory exhausted in pmergesort"); |
107 |
|
readp(pp[i], fi[i]); |
108 |
|
} |
109 |
|
|
165 |
|
if ((fp = ofp) == NULL) |
166 |
|
fp = efopen(tfname(height + 1, nt), "w"); |
167 |
|
|
168 |
< |
mergesort(fi, nf, pl, pcmp, fp); |
168 |
> |
pmergesort(fi, nf, pl, pcmp, fp); |
169 |
|
|
170 |
|
for (i = 0; i < nf; i++) { |
171 |
|
fclose(fi[i]); |
201 |
|
{ |
202 |
|
static int nf = 0, |
203 |
|
intree = FALSE; |
206 |
– |
FILE *fp; |
204 |
|
|
205 |
|
if (isglob(pl->pbot->com)) { |
206 |
|
|