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

Comparing ray/src/cv/mgflib/mgfilt.c (file contents):
Revision 1.3 by greg, Thu May 11 20:17:31 1995 UTC vs.
Revision 1.8 by schorsch, Sat Nov 15 17:54:06 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1995 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   * Filter MGF stream, removing entities that won't be understood
6   */
7  
8   #include <stdio.h>
9 + #include <stdlib.h>
10   #include "parser.h"
11  
12 +                                /* Number of entities for major versions */
13 + short   nentlist[MG_VMAJOR] = MG_NELIST;
14  
15 +
16   int
17 < put_entity(ac, av)              /* general output routine */
18 < register int    ac;
19 < register char   **av;
17 > put_entity(             /* general output routine */
18 >        register int    ac,
19 >        register char   **av
20 > )
21   {
22          while (ac-- > 0) {
23                  fputs(*av++, stdout);
# Line 25 | Line 27 | register char  **av;
27   }
28  
29  
30 < main(argc, argv)        /* first argument is understood entities, comma-sep. */
31 < int     argc;
32 < char    *argv[];
30 > int
31 > main(   /* first argument is understood entities, comma-sep. */
32 >        int     argc,
33 >        char    *argv[]
34 > )
35   {
36          char    *cp1, *cp2;
37          int     i, en;
38  
39          if (argc < 2) {
40 <                fprintf(stderr, "Usage: %s entity,list [file ..]\n", argv[0]);
40 >                fprintf(stderr,
41 >                        "Usage: %s { version | entity,list } [file ..]\n",
42 >                                argv[0]);
43                  exit(1);
44          }
45 <        for (cp1 = cp2 = argv[1]; *cp1; cp1 = cp2) {
46 <                while (*cp2) {
47 <                        if (*cp2 == ',') {
48 <                                *cp2++ = '\0';
49 <                                break;
44 <                        }
45 <                        cp2++;
46 <                }
47 <                en = mg_entity(cp1);
48 <                if (en < 0) {
49 <                        fprintf(stderr, "%s: %s: no such entity\n",
50 <                                        argv[0], cp1);
45 >        if (isint(argv[1])) {
46 >                i = atoi(argv[1]);
47 >                if ((i < 1) | (i > MG_VMAJOR)) {
48 >                        fprintf(stderr, "%s: bad version number: %d\n",
49 >                                        argv[0], i);
50                          exit(1);
51                  }
52 <                mg_ehand[en] = put_entity;
53 <        }
52 >                for (en = nentlist[i-1]; en--; )
53 >                        mg_ehand[en] = put_entity;
54 >                mg_ehand[MG_E_INCLUDE] = NULL;          /* expand include's */
55 >        } else
56 >                for (cp1 = cp2 = argv[1]; *cp1; cp1 = cp2) {
57 >                        while (*cp2) {
58 >                                if (*cp2 == ',') {
59 >                                        *cp2++ = '\0';
60 >                                        break;
61 >                                }
62 >                                cp2++;
63 >                        }
64 >                        en = mg_entity(cp1);
65 >                        if (en < 0) {
66 >                                fprintf(stderr, "%s: %s: no such entity\n",
67 >                                                argv[0], cp1);
68 >                                exit(1);
69 >                        }
70 >                        mg_ehand[en] = put_entity;
71 >                }
72          mg_init();
73          if (argc < 3) {
74                  if (mg_load((char *)NULL) != MG_OK)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines