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

Comparing ray/src/cal/lam.c (file contents):
Revision 1.21 by greg, Fri Jul 5 00:46:23 2019 UTC vs.
Revision 1.25 by greg, Tue Aug 13 16:31:35 2019 UTC

# Line 7 | Line 7 | static const char      RCSid[] = "$Id$";
7   *      7/14/88         Greg Ward
8   */
9  
10 #include <stdlib.h>
11 #include <string.h>
12 #include <stdio.h>
10   #include <ctype.h>
11  
15 #include "platform.h"
12   #include "rtio.h"
13 + #include "platform.h"
14 + #include "paths.h"
15  
16   #define MAXFILE         512             /* maximum number of files */
17  
# Line 42 | Line 40 | main(int argc, char *argv[])
40                          switch (argv[i][1]) {
41                          case 't':
42                                  curtab = argv[i]+2;
43 +                                if (!*curtab) curtab = "\n";
44                                  break;
45                          case 'u':
46                                  unbuff = !unbuff;
# Line 52 | Line 51 | main(int argc, char *argv[])
51                                          incnt = atol(argv[++i]);
52                                          break;
53                                  case 'f':
54 +                                case 'F':
55                                          curbytes = sizeof(float);
56                                          break;
57                                  case 'd':
58 +                                case 'D':
59                                          curbytes = sizeof(double);
60                                          break;
61                                  case 'i':
62 +                                case 'I':
63                                          curbytes = sizeof(int);
64                                          break;
65                                  case 'w':
66 +                                case 'W':
67                                          curbytes = 2;
68                                          break;
69                                  case 'b':
# Line 145 | Line 148 | main(int argc, char *argv[])
148                          if (bytsiz[i] > 0) {            /* binary input */
149                                  if (getbinary(buf, bytsiz[i], 1, input[i]) < 1)
150                                          break;
151 <                                putbinary(buf, bytsiz[i], 1, stdout);
151 >                                if (putbinary(buf, bytsiz[i], 1, stdout) != 1)
152 >                                        break;
153                          } else if (bytsiz[i] < 0) {     /* multi-line input */
154                                  int     n = -bytsiz[i];
155                                  while (n--) {
# Line 154 | Line 158 | main(int argc, char *argv[])
158                                          if ((i > 0) | (n < -bytsiz[i]-1))
159                                                  fputs(tabc[i], stdout);
160                                          buf[strlen(buf)-1] = '\0';
161 <                                        fputs(buf, stdout);
161 >                                        if (fputs(buf, stdout) == EOF)
162 >                                                break;
163                                  }
164                                  if (n >= 0)             /* fell short? */
165                                          break;
# Line 164 | Line 169 | main(int argc, char *argv[])
169                                  if (i)
170                                          fputs(tabc[i], stdout);
171                                  buf[strlen(buf)-1] = '\0';
172 <                                fputs(buf, stdout);
172 >                                if (fputs(buf, stdout) == EOF)
173 >                                        break;
174                          }
175                  }
176                  if (i < nfiles)
# Line 175 | Line 181 | main(int argc, char *argv[])
181                          fflush(stdout);
182          } while (--incnt);
183                                                          /* check ending */
184 +        if (fflush(stdout) == EOF) {
185 +                fputs(argv[0], stderr);
186 +                fputs(": write error on standard output\n", stderr);
187 +                return(1);
188 +        }
189          if (incnt > 0) {
190                  fputs(argv[0], stderr);
191                  fputs(": warning: premature EOD\n", stderr);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines