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.2 by schorsch, Sun Jun 8 12:03:10 2003 UTC vs.
Revision 1.8 by schorsch, Sat Nov 15 02:13:37 2003 UTC

# Line 5 | Line 5 | static const char      RCSid[] = "$Id$";
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  
13  
# Line 79 | Line 81 | int  (*pcmp)()         /* compares pointers to pointers to pr
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 */
# Line 90 | Line 92 | FILE  *ofp             /* output file */
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  
# Line 101 | Line 103 | FILE  *ofp             /* output file */
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  
# Line 152 | Line 154 | int  (*pcmp)(),
154   FILE  *ofp
155   )
156   {
155    char  *tfname();
157      FILE  *fi[NFILES], *fp;
158      int  i;
159      
# Line 164 | Line 165 | FILE  *ofp
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]);
# Line 200 | Line 201 | int  (*pcmp)()
201   {
202      static int  nf = 0,
203                  intree = FALSE;
203    FILE  *fp;
204  
205      if (isglob(pl->pbot->com)) {
206  
# Line 276 | Line 276 | int  lvl, int num
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   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines