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.23 by greg, Sun Mar 9 20:07:27 2014 UTC vs.
Revision 1.24 by greg, Sat May 10 01:27:14 2014 UTC

# Line 801 | Line 801 | struct field  *f
801   static void
802   putrec(void)                                /* output a record */
803   {
804 <        char  fmt[32];
804 >        char  fmt[32], typ[32];
805          int  n;
806          struct field  *f;
807          int  adlast, adnext;
808 +        double  dv, av;
809          
810          adlast = 0;
811          for (f = outfmt; f != NULL; f = f->next) {
# Line 835 | Line 836 | putrec(void)                                /* output
836                          break;
837                  case T_NUM:
838                          n = f->type & F_WID;
839 +                        typ[0] = (n <= 6) ? 'g' : 'e';
840 +                        typ[1] = '\0';
841 +                        dv = evalue(f->f.ne);
842 +                        if ((av = fabs(dv)) < 1L<<31) {
843 +                                long    iv = (int)(av + .5);
844 +                                if (iv && fabs(av-iv) <= av*1e-14)
845 +                                        strcpy(typ, ".0f");
846 +                        }
847                          if (adlast && adnext)
848 <                                strcpy(fmt, "%g");
848 >                                sprintf(fmt, "%%%s", typ);
849                          else if (adlast)
850 <                                sprintf(fmt, "%%-%dg", n);
850 >                                sprintf(fmt, "%%-%d%s", n, typ);
851                          else
852 <                                sprintf(fmt, "%%%dg", n);
853 <                        printf(fmt, evalue(f->f.ne));
852 >                                sprintf(fmt, "%%%d%s", n, typ);
853 >                        printf(fmt, dv);
854                          adlast = 1;
855                          break;
856                  }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines