ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/meta/sort.c
(Generate patch)

Comparing ray/src/meta/sort.c (file contents):
Revision 1.1 by greg, Sat Feb 22 02:07:26 2003 UTC vs.
Revision 1.2 by schorsch, Sun Jun 8 12:03:10 2003 UTC

# Line 5 | Line 5 | static const char      RCSid[] = "$Id$";
5   *   Sorting routines for meta-files
6   */
7  
8 + #include  "paths.h"
9 + #include  "meta.h"
10  
11 +
12   #define  PBSIZE  1000           /* max size of sort block */
13                                  /* maxalloc must be >= this */
14  
12
15   #define  NFILES  4              /* number of sort files */
16  
17  
18 + static void treemerge(int height, int nt, int nf, PLIST *pl,
19 +                int (*pcmp)(), FILE *ofp);
20 + static void sendsort( PLIST  *pl, int  (*pcmp)());
21 + static void order(PRIMITIVE  *pa[], int  n, PLIST  *pl);
22 + static char * tfname( int  lvl, int num);
23  
17 #include  "meta.h"
18
19
20
21
22
23
24
24   /*
25   *   This sort routine does a combination quicksort and
26   *   n-ary mergesort
27   */
28  
29  
30 < sort(infp, pcmp)                /* sort primitives according to pcmp */
31 <
32 < FILE  *infp;
33 < int  (*pcmp)();         /* compares pointers to pointers to primitives! */
34 <
30 > void
31 > sort(           /* sort primitives according to pcmp */
32 > FILE  *infp,
33 > int  (*pcmp)()          /* compares pointers to pointers to primitives! */
34 > )
35   {
36   PRIMITIVE  *prims[PBSIZE];             /* pointers to primitives */
37   PLIST  primlist;                       /* our primitives list */
# Line 79 | Line 78 | int  (*pcmp)();                /* compares pointers to pointers to p
78   *     0 or 1 global commands.
79   */
80  
81 < mergesort(fi, nf, pl, pcmp, ofp)        /* merge sorted files with list */
81 > void
82 > mergesort(      /* merge sorted files with list */
83  
84 < FILE  *fi[];            /* array of input files */
85 < int  nf;                /* number of input files */
86 < PLIST  *pl;             /* sorted list */
87 < int  (*pcmp)();         /* comparison function, takes primitive handles */
88 < FILE  *ofp;             /* output file */
89 <
84 > FILE  *fi[],            /* array of input files */
85 > int  nf,                /* number of input files */
86 > PLIST  *pl,             /* sorted list */
87 > int  (*pcmp)(),         /* comparison function, takes primitive handles */
88 > FILE  *ofp              /* output file */
89 > )
90   {
91      PRIMITIVE  *plp;            /* position in list */
92      PRIMITIVE  *pp[NFILES];     /* input primitives */
# Line 143 | Line 143 | FILE  *ofp;            /* output file */
143  
144  
145  
146 < static
147 < treemerge(height, nt, nf, pl, pcmp, ofp)        /* merge into one file */
146 > static void
147 > treemerge(      /* merge into one file */
148  
149 < int  height, nt, nf;
150 < PLIST  *pl;
151 < int  (*pcmp)();
152 < FILE  *ofp;
153 <
149 > int  height, int nt, int nf,
150 > PLIST  *pl,
151 > int  (*pcmp)(),
152 > FILE  *ofp
153 > )
154   {
155      char  *tfname();
156      FILE  *fi[NFILES], *fp;
# Line 191 | Line 191 | FILE  *ofp;
191  
192  
193  
194 < static
195 < sendsort(pl, pcmp)              /* send a sorted list */
194 > static void
195 > sendsort(               /* send a sorted list */
196  
197 < PLIST  *pl;
198 < int  (*pcmp)();
199 <
197 > PLIST  *pl,
198 > int  (*pcmp)()
199 > )
200   {
201      static int  nf = 0,
202                  intree = FALSE;
# Line 247 | Line 247 | int  (*pcmp)();
247  
248  
249  
250 + static void
251 + order(  /* order the first n array primitives into list */
252  
253 < static
254 < order(pa, n, pl)        /* order the first n array primitives into list */
255 <
256 < PRIMITIVE  *pa[];
255 < int  n;
256 < PLIST  *pl;
257 <
253 > PRIMITIVE  *pa[],
254 > int  n,
255 > PLIST  *pl
256 > )
257   {
258   register int  i;
259  
# Line 271 | Line 270 | PLIST  *pl;
270  
271  
272   static char *
273 < tfname(lvl, num)                /* create temporary file name */
273 > tfname(         /* create temporary file name */
274  
275 < int  lvl, num;
276 <
275 > int  lvl, int num
276 > )
277   {
278 +        static char  pathbuf[PATH_MAX];
279      static char  fnbuf[32];
280  
281 <    sprintf(fnbuf, "%sS%d%c%d", TDIR, getpid(), lvl+'A', num);
281 >    /*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);
284  
285 <    return(fnbuf);
285 >    /*return(fnbuf);*/
286 >        return pathbuf;
287   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines