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

Comparing ray/src/common/portio.c (file contents):
Revision 2.1 by greg, Mon Jul 13 15:36:01 1992 UTC vs.
Revision 2.7 by greg, Tue Feb 25 02:47:21 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1992 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Portable i/o for binary files
6 + *
7 + * External symbols declared in standard.h
8   */
9  
10 + #include "copyright.h"
11 +
12   #include <stdio.h>
13  
14 + #ifndef frexp
15 + extern double  frexp();
16 + #endif
17 + #ifndef ldexp
18 + extern double  ldexp();
19 + #endif
20  
21 +
22 + void
23   putstr(s, fp)                   /* write null-terminated string to fp */
24   register char  *s;
25   register FILE  *fp;
# Line 21 | Line 30 | register FILE  *fp;
30   }
31  
32  
33 + void
34   putint(i, siz, fp)              /* write a siz-byte integer to fp */
35   long  i;
36   register int  siz;
37   register FILE  *fp;
38   {
39          while (siz--)
40 <                putc(i>>(siz<<3) & 0xff, fp);
40 >                putc((int)(i>>(siz<<3) & 0xff), fp);
41   }
42  
43  
44 + void
45   putflt(f, fp)                   /* put out floating point number */
46 < double  f;
46 > double  f;
47 > FILE  *fp;
48   {
37        extern double  frexp();
49          int  e;
50  
51          putint((long)(frexp(f,&e)*0x7fffffff), 4, fp);
# Line 84 | Line 95 | double
95   getflt(fp)                      /* get a floating point number */
96   FILE  *fp;
97   {
98 <        extern double  ldexp();
99 <        double  d;
98 >        long    l;
99 >        double  d;
100  
101 <        d = (double)getint(4, fp)/0x7fffffff;
101 >        l = getint(4, fp);
102 >        d = (l + (l > 0 ? .5 : -.5)) * (1./0x7fffffff);
103          return(ldexp(d, (int)getint(1, fp)));
104   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines