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

Comparing ray/src/cal/rcalc.c (file contents):
Revision 1.24 by greg, Sat May 10 01:27:14 2014 UTC vs.
Revision 1.26 by greg, Thu Mar 24 18:48:28 2016 UTC

# Line 73 | Line 73 | struct field  *inpfmt = NULL;   /* input record format
73   struct field  *outfmt = NULL;   /* output record structure */
74   struct strvar  *svhead = NULL;  /* string variables */
75  
76 + long  incnt = 0;                /* limit number of input records? */
77 + long  outcnt = 0;               /* limit number of output records? */
78 +
79   int  blnkeq = 1;                /* blanks compare equal? */
80   int  igneol = 0;                /* ignore end of line? */
81   int  passive = 0;               /* passive mode (transmit unmatched input) */
# Line 157 | Line 160 | char  *argv[]
160                                  nbicols = 0;
161                                  readfmt(argv[++i], 0);
162                                  break;
163 +                        case 'n':
164 +                                incnt = atol(argv[++i]);
165 +                                break;
166                          case 'a':
167                                  itype = 'a';
168                                  nbicols = 0;
# Line 197 | Line 203 | char  *argv[]
203                                  otype = 'a';
204                                  readfmt(argv[++i], 1);
205                                  break;
206 +                        case 'n':
207 +                                outcnt = atol(argv[++i]);
208 +                                break;
209                          case 'a':
210                                  otype = 'a';
211                                  break;
# Line 323 | Line 332 | char  *file
332                          putout();
333                          ++nout;
334                  }
335 +                if (incnt && nrecs >= incnt)
336 +                        break;
337 +                if (outcnt && nout >= outcnt)
338 +                        break;
339          }
340          fclose(fp);
341   }
# Line 801 | Line 814 | struct field  *f
814   static void
815   putrec(void)                                /* output a record */
816   {
817 <        char  fmt[32], typ[32];
817 >        char  fmt[32], typ[16];
818          int  n;
819          struct field  *f;
820          int  adlast, adnext;
# Line 836 | Line 849 | putrec(void)                                /* output
849                          break;
850                  case T_NUM:
851                          n = f->type & F_WID;
839                        typ[0] = (n <= 6) ? 'g' : 'e';
840                        typ[1] = '\0';
852                          dv = evalue(f->f.ne);
853 <                        if ((av = fabs(dv)) < 1L<<31) {
853 >                        av = fabs(dv);
854 >                        if (n <= 9)
855 >                                strcpy(typ, "g");
856 >                        else
857 >                                sprintf(typ, ".%de", n-5);
858 >                        if (av < 1L<<31) {
859                                  long    iv = (int)(av + .5);
860                                  if (iv && fabs(av-iv) <= av*1e-14)
861                                          strcpy(typ, ".0f");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines