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.8 by schorsch, Thu Jul 17 09:21:29 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 + #include "rtio.h"
15  
16 + #ifndef frexp
17 + extern double  frexp();
18 + #endif
19 + #ifndef ldexp
20 + extern double  ldexp();
21 + #endif
22 +
23 +
24 + void
25   putstr(s, fp)                   /* write null-terminated string to fp */
26   register char  *s;
27   register FILE  *fp;
# Line 21 | Line 32 | register FILE  *fp;
32   }
33  
34  
35 + void
36   putint(i, siz, fp)              /* write a siz-byte integer to fp */
37   long  i;
38   register int  siz;
39   register FILE  *fp;
40   {
41          while (siz--)
42 <                putc(i>>(siz<<3) & 0xff, fp);
42 >                putc((int)(i>>(siz<<3) & 0xff), fp);
43   }
44  
45  
46 + void
47   putflt(f, fp)                   /* put out floating point number */
48 < double  f;
48 > double  f;
49 > FILE  *fp;
50   {
37        extern double  frexp();
51          int  e;
52  
53          putint((long)(frexp(f,&e)*0x7fffffff), 4, fp);
# Line 84 | Line 97 | double
97   getflt(fp)                      /* get a floating point number */
98   FILE  *fp;
99   {
100 <        extern double  ldexp();
101 <        double  d;
100 >        long    l;
101 >        double  d;
102  
103 <        d = (double)getint(4, fp)/0x7fffffff;
103 >        l = getint(4, fp);
104 >        d = (l + (l > 0 ? .5 : -.5)) * (1./0x7fffffff);
105          return(ldexp(d, (int)getint(1, fp)));
106   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines