FreeCalypso > hg > ueda-linux
annotate miscutil/protel-parts-condense.c @ 144:ffadaa339478
protel-parts-condense misc utility written
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 20 Sep 2020 02:40:23 +0000 |
parents | |
children |
rev | line source |
---|---|
144
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This program reads a Protel netlist (exported from Altium), extracts |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * the component list portion and emits it in a condensed form. |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdlib.h> |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <string.h> |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <strings.h> |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 static char *infname; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 static FILE *inf; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 static char linebuf[80], savebuf[6][80]; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 static int lineno; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 static |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 get_line() |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 char *cp; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 if (!fgets(linebuf, sizeof linebuf, inf)) |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 return(0); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 lineno++; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 cp = index(linebuf, '\n'); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 if (!cp) { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 fprintf(stderr, "%s line %d: missing newline\n", |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 infname, lineno); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 exit(1); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 *cp = '\0'; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 if (cp > linebuf && cp[-1] == '\r') |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 *--cp = '\0'; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 return(1); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 static void |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 get_line_notfirst() |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 if (!get_line()) { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 fprintf(stderr, "error: unexpected EOF in input\n"); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 exit(1); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 if (!strcmp(linebuf, "[")) { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 fprintf(stderr, "%s line %d: [ NOT expected\n", |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 infname, lineno); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 exit(1); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 if (!strcmp(linebuf, "(")) { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 fprintf(stderr, "%s line %d: ( NOT expected\n", |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 infname, lineno); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 exit(1); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 static void |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 check_line_for_nonprint_chars() |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 char *cp; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 int c; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 for (cp = linebuf; *cp; cp++) { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 c = *cp; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 if ((c < ' ' || c > '~') && c != '\t') { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 fprintf(stderr, "%s line %d: non-printable char\n", |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 infname, lineno); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 exit(1); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 static int |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 item_needs_quoting(str) |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 char *str; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 char *cp; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 int c; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 if (!str[0]) |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 return(1); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 for (cp = str; *cp; cp++) { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 c = *cp; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 if (c == '\t' || c == ' ' || c == '\"' || c == '\\') |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 return(1); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 return(0); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 static void |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 print_item_quoted(str) |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 char *str; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 char *cp; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 int c; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 putchar('\"'); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 for (cp = str; *cp; cp++) { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 c = *cp; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 if (c == '\t') { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 putchar('\\'); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 putchar('t'); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 continue; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 if (c == '\"' || c == '\\') |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 putchar('\\'); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 putchar(c); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 putchar('\"'); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 static void |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 print_item(str) |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 char *str; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 if (item_needs_quoting(str)) |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 print_item_quoted(str); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 else |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 fputs(str, stdout); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 static void |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 process_component_block() |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 int i; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 for (i = 0; i < 6; i++) { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 get_line_notfirst(); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 if (!strcmp(linebuf, "]")) { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 fprintf(stderr, "%s line %d: ] NOT expected\n", |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 infname, lineno); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 exit(1); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 if (!strcmp(linebuf, ")")) { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 fprintf(stderr, "%s line %d: ) NOT expected\n", |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 infname, lineno); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 exit(1); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 check_line_for_nonprint_chars(); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 strcpy(savebuf[i], linebuf); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 get_line_notfirst(); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 if (strcmp(linebuf, "]")) { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 fprintf(stderr, "%s line %d: expected ]\n", infname, lineno); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 exit(1); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 print_item(savebuf[0]); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 putchar(' '); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 print_item(savebuf[1]); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 putchar(' '); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 print_item(savebuf[2]); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 putchar(' '); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 print_item(savebuf[3]); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 putchar(' '); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 print_item(savebuf[4]); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 putchar(' '); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 print_item(savebuf[5]); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 putchar('\n'); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 static void |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 skip_net_block() |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 for (;;) { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 get_line_notfirst(); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 if (!strcmp(linebuf, "]")) { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 fprintf(stderr, "%s line %d: ] NOT expected\n", |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 infname, lineno); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 exit(1); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 if (!strcmp(linebuf, ")")) |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 break; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 main(argc, argv) |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 char **argv; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 if (argc != 2) { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 fprintf(stderr, "usage: %s protel-netlist-file\n", argv[0]); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 exit(1); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 infname = argv[1]; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 inf = fopen(infname, "r"); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 if (!inf) { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 perror(infname); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 exit(1); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 for (;;) { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 if (!get_line()) |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 break; |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 if (!strcmp(linebuf, "[")) |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 process_component_block(); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 else if (!strcmp(linebuf, "(")) |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 skip_net_block(); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 else { |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 fprintf(stderr, |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 "%s line %d: expected beginning of block\n", |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 infname, lineno); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 exit(1); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 } |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 exit(0); |
ffadaa339478
protel-parts-condense misc utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 } |