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.5 by greg, Mon Jun 16 14:54:54 2003 UTC

# Line 8 | Line 8 | static const char      RCSid[] = "$Id$";
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  
# Line 79 | Line 83 | int  (*pcmp)()         /* compares pointers to pointers to pr
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 */
# Line 101 | Line 105 | FILE  *ofp             /* output file */
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  
# Line 152 | Line 156 | int  (*pcmp)(),
156   FILE  *ofp
157   )
158   {
155    char  *tfname();
159      FILE  *fi[NFILES], *fp;
160      int  i;
161      
# Line 164 | Line 167 | FILE  *ofp
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]);
# Line 276 | Line 279 | int  lvl, int num
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   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines