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

Comparing ray/src/cal/calc.c (file contents):
Revision 1.4 by schorsch, Thu Jul 17 09:21:29 2003 UTC vs.
Revision 1.8 by greg, Thu Dec 19 16:56:31 2013 UTC

# Line 8 | Line 8 | static const char      RCSid[] = "$Id$";
8   */
9  
10   #include  <stdlib.h>
11 #include  <stdio.h>
12 #include  <string.h>
11   #include  <setjmp.h>
12   #include  <ctype.h>
13  
14 + #include  "rtio.h"
15   #include  "rterror.h"
16   #include  "calcomp.h"
17  
# Line 25 | Line 24 | jmp_buf  env;
24   int  recover = 0;
25  
26  
27 + int
28   main(argc, argv)
29   int  argc;
30   char  *argv[];
31   {
32 <        char  expr[512];
32 >        char  expr[2048];
33 >        char  *epos;
34          FILE  *fp;
35          int  i;
36 <        register char  *cp;
36 >        char  *cp;
37  
38          esupport |= E_VARIABLE|E_INCHAN|E_FUNCTION;
39          esupport &= ~(E_REDEFW|E_RCONST|E_OUTCHAN);
# Line 41 | Line 42 | char  *argv[];
42   #endif
43          varset("PI", ':', 3.14159265358979323846);
44  
45 <        for (i = 1; i < argc; i++)
46 <                fcompile(argv[i]);
47 <
45 >        for (i = 1; i < argc; i++) {
46 >                cp = getpath(argv[i], getrlibpath(), 0);
47 >                if (cp == NULL) {
48 >                        eputs(argv[0]);
49 >                        eputs(": cannot find file '");
50 >                        eputs(argv[i]);
51 >                        eputs("'\n");
52 >                        quit(1);
53 >                }
54 >                fcompile(cp);
55 >        }
56          setjmp(env);
57          recover = 1;
58          eclock++;
59  
60 <        while (fgets(expr, sizeof(expr), stdin) != NULL) {
61 <                for (cp = expr; *cp && *cp != '\n'; cp++)
62 <                        ;
63 <                *cp = '\0';
60 >        epos = expr;
61 >        while (fgets(epos, sizeof(expr)-(epos-expr), stdin) != NULL) {
62 >                while (*epos && *epos != '\n')
63 >                        epos++;
64 >                if (*epos && epos > expr && epos[-1] == '\\') {
65 >                        epos[-1] = ' ';
66 >                        continue;               /* escaped newline */
67 >                }
68 >                *epos = '\0';
69 >                epos = expr;
70                  switch (expr[0]) {
71                  case '\0':
72                          continue;
# Line 85 | Line 100 | char  *argv[];
100                                  eputs("file name required\n");
101                                  continue;
102                          }
103 +                        cp = getpath(cp, getrlibpath(), 0);
104 +                        if (cp == NULL) {
105 +                                eputs("cannot find file\n");
106 +                                continue;
107 +                        }
108                          fcompile(cp);
109                          eclock++;
110                          continue;
# Line 116 | Line 136 | char  *argv[];
136  
137          recover = 0;
138          quit(0);
139 +        return 0; /* pro forma exit */
140   }
141  
142  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines