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.4 by greg, Sun May 25 05:27:16 2003 UTC vs.
Revision 1.5 by schorsch, Sun Jun 8 12:03:09 2003 UTC

# Line 7 | Line 7 | static const char RCSid[] = "$Id$";
7   *     9/11/87
8   */
9  
10 #include  <stdio.h>
11
10   #include  <stdlib.h>
11 <
11 > #include  <stdio.h>
12 > #include  <string.h>
13   #include  <math.h>
15
14   #include  <ctype.h>
15  
16 + #include  "platform.h"
17   #include  "calcomp.h"
18  
19   #ifdef  CPM
# Line 58 | Line 57 | struct field {                  /* record format struc
57   #define  savqstr(s)     strcpy(emalloc(strlen(s)+1),s)
58   #define  freqstr(s)     efree(s)
59  
60 < extern char  *strcpy(), *emalloc(), *savestr();
61 < struct strvar  *getsvar();
60 > static void scaninp(void), advinp(void), resetinp(void);
61 > static void putrec(void), putout(void), nbsynch(void);
62 > static int getrec(void);
63 > static void execute(char *file);
64 > static void initinp(FILE *fp);
65 > static void svpreset(char *eqn);
66 > static void readfmt(char *spec, int output);
67 > static int readfield(char **pp);
68 > static int getfield(struct field *f);
69 > static void chanset(int n, double v);
70 > static void bchanset(int n, double v);
71 > static struct strvar* getsvar(char *svname);
72  
73   struct field  *inpfmt = NULL;   /* input record format */
74   struct field  *outfmt = NULL;   /* output record structure */
# Line 88 | Line 97 | struct {
97   } ipb;                          /* circular lookahead buffer */
98  
99  
100 < main(argc, argv)
101 < int  argc;
102 < char  *argv[];
100 > int
101 > main(
102 > int  argc,
103 > char  *argv[]
104 > )
105   {
106          int  i;
107  
# Line 200 | Line 211 | eputs(" [-b][-l][-n][-w][-u][-tS][-s svar=sval][-e exp
211   }
212  
213  
214 < nbsynch()               /* non-blank starting synch character */
214 > static void
215 > nbsynch(void)               /* non-blank starting synch character */
216   {
217          if (inpfmt == NULL || (inpfmt->type & F_TYP) != T_LIT)
218                  return;
# Line 212 | Line 224 | nbsynch()               /* non-blank starting synch ch
224  
225  
226   int
227 < getinputrec(fp)         /* get next input record */
228 < FILE  *fp;
227 > getinputrec(            /* get next input record */
228 > FILE  *fp
229 > )
230   {
231          if (inpfmt != NULL)
232                  return(getrec());
# Line 227 | Line 240 | FILE  *fp;
240   }
241  
242  
243 < execute(file)           /* process a file */
244 < char  *file;
243 > static void
244 > execute(           /* process a file */
245 > char  *file
246 > )
247   {
248          int  conditional = vardefined("cond");
249          long  nrecs = 0;
# Line 258 | Line 273 | char  *file;
273   }
274  
275  
276 < putout()                /* produce an output record */
276 > static void
277 > putout(void)                /* produce an output record */
278   {
263        extern void  chanset(), bchanset();
279  
280          colpos = 0;
281          if (outfmt != NULL)
# Line 277 | Line 292 | putout()                /* produce an output record */
292  
293  
294   double
295 < chanvalue(n)            /* return value for column n */
296 < int  n;
295 > chanvalue(            /* return value for column n */
296 > int  n
297 > )
298   {
299          int  i;
300          register char  *cp;
# Line 329 | Line 345 | int  n;
345  
346  
347   void
348 < chanset(n, v)                   /* output column n */
349 < int  n;
350 < double  v;
348 > chanset(                   /* output column n */
349 > int  n,
350 > double  v
351 > )
352   {
353          if (colpos == 0)                /* no leading separator */
354                  colpos = 1;
# Line 344 | Line 361 | double  v;
361  
362  
363   void
364 < bchanset(n, v)                   /* output binary channel n */
365 < int  n;
366 < double  v;
364 > bchanset(                   /* output binary channel n */
365 > int  n,
366 > double  v
367 > )
368   {
369          static char     zerobuf[sizeof(double)];
370  
# Line 363 | Line 381 | double  v;
381   }
382  
383  
384 < readfmt(spec, output)                   /* read record format */
385 < char  *spec;
386 < int  output;
384 > static void
385 > readfmt(                   /* read record format */
386 > char  *spec,
387 > int  output
388 > )
389   {
390          int  fd;
391          char  *inptr;
# Line 429 | Line 449 | int  output;
449   }
450  
451  
452 < int
453 < readfield(pp)                   /* get next field in format */
454 < register char  **pp;
452 > static int
453 > readfield(                   /* get next field in format */
454 > register char  **pp
455 > )
456   {
457          int  type = F_NUL;
458          int  width = 0;
# Line 496 | Line 517 | register char  **pp;
517  
518  
519   struct strvar *
520 < getsvar(svname)                         /* get string variable */
521 < char  *svname;
520 > getsvar(                         /* get string variable */
521 > char  *svname
522 > )
523   {
524          register struct strvar  *sv;
525          
# Line 513 | Line 535 | char  *svname;
535   }
536  
537  
538 < svpreset(eqn)                    /* preset a string variable */
539 < char  *eqn;
538 > static void
539 > svpreset(                    /* preset a string variable */
540 > char  *eqn
541 > )
542   {
543          register struct strvar  *sv;
544          register char  *val;
# Line 533 | Line 557 | char  *eqn;
557   }
558  
559  
560 < clearrec()                      /* clear input record variables */
560 > static void
561 > clearrec(void)                  /* clear input record variables */
562   {
563          register struct field  *f;
564  
# Line 552 | Line 577 | clearrec()                     /* clear input record variables */
577   }
578  
579  
580 < getrec()                                /* get next record from file */
580 > static int
581 > getrec(void)                                /* get next record from file */
582   {
583          int  eatline;
584          register struct field  *f;
# Line 585 | Line 611 | getrec()                                /* get next re
611   }
612  
613  
614 < getfield(f)                             /* get next field */
615 < register struct field  *f;
614 > static int
615 > getfield(                             /* get next field */
616 > register struct field  *f
617 > )
618   {
619          static char  buf[MAXWORD+1];            /* no recursion! */
620          int  delim, inword;
# Line 672 | Line 700 | register struct field  *f;
700                          return(-1);                     /* doesn't match! */
701                  return(0);
702          }
703 +        return -1; /* pro forma return */
704   }
705  
706  
707 < putrec()                                /* output a record */
707 > static void
708 > putrec(void)                                /* output a record */
709   {
710          char  fmt[32];
711          register int  n;
# Line 725 | Line 755 | putrec()                                /* output a re
755   }
756  
757  
758 < initinp(fp)                     /* prepare lookahead buffer */
759 < FILE  *fp;
758 > static void
759 > initinp(FILE  *fp)                     /* prepare lookahead buffer */
760 >
761   {
762          ipb.fin = fp;
763          ipb.beg = ipb.end = inpbuf;
# Line 736 | Line 767 | FILE  *fp;
767   }
768  
769  
770 < scaninp()                       /* scan next character */
770 > static void
771 > scaninp(void)                       /* scan next character */
772   {
773          if (ipb.chr == EOF)
774                  return;
# Line 755 | Line 787 | scaninp()                       /* scan next character
787   }
788  
789  
790 < advinp()                        /* move home to current position */
790 > static void
791 > advinp(void)                        /* move home to current position */
792   {
793          ipb.beg = ipb.pos;
794   }
795  
796  
797 < resetinp()                      /* rewind position and advance 1 */
797 > static void
798 > resetinp(void)                      /* rewind position and advance 1 */
799   {
800          if (ipb.beg == NULL)            /* full */
801                  ipb.beg = ipb.end;
# Line 774 | Line 808 | resetinp()                      /* rewind position and
808  
809  
810   void
811 < eputs(msg)
778 < char  *msg;
811 > eputs(char  *msg)
812   {
813          fputs(msg, stderr);
814   }
815  
816  
817   void
818 < wputs(msg)
786 < char  *msg;
818 > wputs(char  *msg)
819   {
820          if (!nowarn)
821                  eputs(msg);
# Line 791 | Line 823 | char  *msg;
823  
824  
825   void
826 < quit(code)
795 < int  code;
826 > quit(int  code)
827   {
828          exit(code);
829   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines