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

Comparing ray/src/util/getinfo.c (file contents):
Revision 2.8 by schorsch, Fri Jan 2 11:44:24 2004 UTC vs.
Revision 2.11 by greg, Mon Jul 28 20:12:20 2014 UTC

# Line 13 | Line 13 | static const char      RCSid[] = "$Id$";
13   #include  "platform.h"
14   #include  "resolu.h"
15  
16 + #ifdef getc_unlocked            /* avoid nasty file-locking overhead */
17 + #undef getchar
18 + #undef putchar
19 + #define getchar         getchar_unlocked
20 + #define putchar         putchar_unlocked
21 + #endif
22 +
23 + #ifdef _WIN32
24 + #include <process.h>
25 + #define execvp  _execvp
26 + #endif
27 +
28   static gethfunc tabstr;
29 < static void getdim(register FILE *fp);
29 > static void getdim(FILE *fp);
30   static void copycat(void);
31  
32  
33   static int
34   tabstr(                         /* put out line followed by tab */
35 <        register char  *s,
35 >        char  *s,
36          void *p
37   )
38   {
# Line 47 | Line 59 | main(
59          if (argc > 1 && !strcmp(argv[1], "-d")) {
60                  argc--; argv++;
61                  dim = 1;
50                SET_DEFAULT_BINARY(); /* for output file */
62                  SET_FILE_BINARY(stdin);
63 +        } else if (argc > 2 && !strcmp(argv[1], "-c")) {
64 +                SET_FILE_BINARY(stdin);
65 +                SET_FILE_BINARY(stdout);
66 +                getheader(stdin, (gethfunc *)fputs, stdout);
67 +                printargs(argc-2, argv+2, stdout);
68 +                fputc('\n', stdout);
69 +                fflush(stdout);
70 +                execvp(argv[2], argv+2);
71 +                perror(argv[2]);
72 +                return 1;
73          } else if (argc == 2 && !strcmp(argv[1], "-")) {
74                  SET_FILE_BINARY(stdin);
75                  SET_FILE_BINARY(stdout);
# Line 67 | Line 88 | main(
88                          } else {
89                                  tabstr(":\n", NULL);
90                                  getheader(fp, tabstr, NULL);
91 <                                putchar('\n');
91 >                                fputc('\n', stdout);
92                          }
93                          fclose(fp);
94                  }
# Line 76 | Line 97 | main(
97                  if (dim) {
98                          getdim(stdin);
99                  } else {
100 <                        getheader(stdin, (gethfunc*)fputs, stdout);
101 <                        putchar('\n');
100 >                        getheader(stdin, (gethfunc *)fputs, stdout);
101 >                        fputc('\n', stdout);
102                  }
103          }
104          return 0;
# Line 86 | Line 107 | main(
107  
108   static void
109   getdim(                         /* get dimensions from file */
110 <        register FILE  *fp
110 >        FILE  *fp
111   )
112   {
113          int  j;
114 <        register int  c;
114 >        int  c;
115  
116          getheader(fp, NULL, NULL);      /* skip header */
117  
# Line 105 | Line 126 | getdim(                                /* get dimensions from file */
126                  getc(fp);
127                  j = 0;
128                  while ((c = getc(fp)) != EOF)
129 <                        if (c == 0)
129 >                        if (c == 0) {
130                                  if (++j >= 4)
131                                          break;
132 <                                else
133 <                                        putchar(' ');
113 <                        else
132 >                                putchar(' ');
133 >                        } else {
134                                  putchar(c);
135 +                        }
136                  putchar('\n');
137                  break;
138          default:                /* ??? */
# Line 124 | Line 145 | getdim(                                /* get dimensions from file */
145   static void
146   copycat(void)                   /* copy input to output */
147   {
148 <        register int    c;
148 >        char    buf[8192];
149 >        int     n;
150  
151 <        while ((c = getchar()) != EOF)
152 <                putchar(c);
151 >        fflush(stdout);
152 >        while ((n = fread(buf, 1, sizeof(buf), stdin)) > 0)
153 >                if (write(fileno(stdout), buf, n) != n)
154 >                        break;
155   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines