Mercurial > hg > index.cgi
annotate lwasm/input.c @ 559:ddc7b05a5675
Add --no-warn=ifp1 flag to suppress warnings about ifp1 and ipf2
author | William Astle <lost@l-w.ca> |
---|---|
date | Thu, 21 Sep 2023 13:13:23 -0600 |
parents | 7627d2b3b81f |
children |
rev | line source |
---|---|
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1 /* |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
2 input.c |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
3 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
4 Copyright © 2010 William Astle |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
5 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
6 This file is part of LWTOOLS. |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
7 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
8 LWTOOLS is free software: you can redistribute it and/or modify it under the |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
9 terms of the GNU General Public License as published by the Free Software |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
10 Foundation, either version 3 of the License, or (at your option) any later |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
11 version. |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
12 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
13 This program is distributed in the hope that it will be useful, but WITHOUT |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
16 more details. |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
17 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
18 You should have received a copy of the GNU General Public License along with |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
19 this program. If not, see <http://www.gnu.org/licenses/>. |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
20 */ |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
21 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
22 /* |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
23 This file is used to handle reading input files. It serves to encapsulate |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
24 the entire input system to make porting to different media and systems |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
25 less difficult. |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
26 */ |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
27 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
28 #include <errno.h> |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
29 #include <stdio.h> |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
30 #include <string.h> |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
31 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
32 #include <lw_alloc.h> |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
33 #include <lw_stringlist.h> |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
34 #include <lw_string.h> |
2
7317fbe024af
Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents:
0
diff
changeset
|
35 #include <lw_error.h> |
7317fbe024af
Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents:
0
diff
changeset
|
36 |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
37 #include "lwasm.h" |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
38 #include "input.h" |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
39 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
40 /* |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
41 Data type for storing input buffers |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
42 */ |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
43 |
219 | 44 #define IGNOREERROR (errno == ENOENT && (as -> preprocess || as -> flags & FLAG_DEPENDNOERR)) |
73
1f77ae5c3590
Added --dependnoerr flag to list dependencies on non-existent files without bailing out; also suppress error reports during dependency generation
lost@l-w.ca
parents:
10
diff
changeset
|
45 |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
46 enum input_types_e |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
47 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
48 input_type_file, // regular file, no search path |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
49 input_type_include, // include path, start from "local" |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
50 input_type_string, // input from a string |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
51 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
52 input_type_error // invalid input type |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
53 }; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
54 |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
55 struct input_stack_node |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
56 { |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
57 input_stack_entry *entry; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
58 struct input_stack_node *next; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
59 }; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
60 |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
61 struct input_stack |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
62 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
63 struct input_stack *next; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
64 int type; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
65 void *data; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
66 int data2; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
67 char *filespec; |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
68 struct input_stack_node *stack; |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
69 }; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
70 |
10
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
2
diff
changeset
|
71 static char *make_filename(char *p, char *f) |
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
2
diff
changeset
|
72 { |
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
2
diff
changeset
|
73 int l; |
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
2
diff
changeset
|
74 char *r; |
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
2
diff
changeset
|
75 l = strlen(p) + strlen(f) + 1; |
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
2
diff
changeset
|
76 r = lw_alloc(l + 1); |
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
2
diff
changeset
|
77 sprintf(r, "%s/%s", p, f); |
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
2
diff
changeset
|
78 return r; |
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
2
diff
changeset
|
79 } |
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
2
diff
changeset
|
80 |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
81 #define IS ((struct input_stack *)(as -> input_data)) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
82 |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
83 struct ifl *ifl_head = NULL; |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
84 |
379
d791d47afc48
Add m80ext pragma for Macro-80C compatibility and ignore END in includes
William Astle <lost@l-w.ca>
parents:
279
diff
changeset
|
85 int input_isinclude(asmstate_t *as) |
d791d47afc48
Add m80ext pragma for Macro-80C compatibility and ignore END in includes
William Astle <lost@l-w.ca>
parents:
279
diff
changeset
|
86 { |
d791d47afc48
Add m80ext pragma for Macro-80C compatibility and ignore END in includes
William Astle <lost@l-w.ca>
parents:
279
diff
changeset
|
87 return IS->type == input_type_include; |
d791d47afc48
Add m80ext pragma for Macro-80C compatibility and ignore END in includes
William Astle <lost@l-w.ca>
parents:
279
diff
changeset
|
88 } |
d791d47afc48
Add m80ext pragma for Macro-80C compatibility and ignore END in includes
William Astle <lost@l-w.ca>
parents:
279
diff
changeset
|
89 |
247
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
90 static int input_isabsolute(const char *s) |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
91 { |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
92 #if defined(WIN32) || defined(WIN64) |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
93 // aiming for the root of the current drive - treat as absolute |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
94 if (s[0] == '/') |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
95 return 1; |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
96 // check for drive letter stuff |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
97 if (!s[0] || !s[1]) |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
98 return 0; |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
99 if (s[1] != ':') |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
100 return 0; |
279
4051bc09da78
Fix absolute path handling on Windows
William Astle <lost@l-w.ca>
parents:
252
diff
changeset
|
101 if ((s[0] >= 'A' && s[0] <= 'Z') || (s[0] >= 'a' && s[0] <= 'z')) |
247
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
102 return 1; |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
103 return 0; |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
104 #else |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
105 /* this is suitable for unix-like systems */ |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
106 if (s[0] == '/') |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
107 return 1; |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
108 return 0; |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
109 #endif |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
110 } |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
111 |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
112 /* this adds real filenames that were opened to a list */ |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
113 void input_add_to_resource_list(asmstate_t *as, const char *s) |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
114 { |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
115 struct ifl *ifl; |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
116 |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
117 /* first see if the file is already referenced */ |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
118 for (ifl = ifl_head; ifl; ifl = ifl -> next) |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
119 { |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
120 if (strcmp(s, ifl -> fn) == 0) |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
121 break; |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
122 } |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
123 if (!ifl) |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
124 { |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
125 ifl = lw_alloc(sizeof(struct ifl)); |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
126 ifl -> next = ifl_head; |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
127 ifl_head = ifl; |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
128 ifl -> fn = lw_strdup(s); |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
129 } |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
130 } |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
131 |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
132 void input_init(asmstate_t *as) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
133 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
134 struct input_stack *t; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
135 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
136 if (as -> file_dir) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
137 lw_stack_destroy(as -> file_dir); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
138 as -> file_dir = lw_stack_create(lw_free); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
139 as -> includelist = lw_stack_create(lw_free); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
140 lw_stringlist_reset(as -> input_files); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
141 while (IS) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
142 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
143 t = IS; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
144 as -> input_data = IS -> next; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
145 lw_free(t); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
146 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
147 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
148 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
149 void input_pushpath(asmstate_t *as, char *fn) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
150 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
151 /* take apart fn into path and filename then push the path */ |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
152 /* onto the current file path stack */ |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
153 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
154 /* also add it to the list of files included */ |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
155 char *dn, *dp; |
2
7317fbe024af
Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents:
0
diff
changeset
|
156 // int o; |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
157 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
158 dn = lw_strdup(fn); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
159 lw_stack_push(as -> includelist, dn); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
160 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
161 dn = lw_strdup(fn); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
162 dp = dn + strlen(dn); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
163 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
164 while (--dp != dn) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
165 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
166 if (*dp == '/') |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
167 break; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
168 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
169 if (*dp == '/') |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
170 *dp = '\0'; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
171 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
172 if (dp == dn) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
173 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
174 lw_free(dn); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
175 dn = lw_strdup("."); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
176 lw_stack_push(as -> file_dir, dn); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
177 return; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
178 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
179 dp = lw_strdup(dn); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
180 lw_free(dn); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
181 lw_stack_push(as -> file_dir, dp); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
182 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
183 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
184 void input_openstring(asmstate_t *as, char *s, char *str) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
185 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
186 struct input_stack *t; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
187 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
188 t = lw_alloc(sizeof(struct input_stack)); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
189 t -> filespec = lw_strdup(s); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
190 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
191 t -> type = input_type_string; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
192 t -> data = lw_strdup(str); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
193 t -> data2 = 0; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
194 t -> next = IS; |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
195 t -> stack = NULL; |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
196 as -> input_data = t; |
93
5bf9edabd661
Squashed the remaining memory leaks revealed by valgrind
lost@l-w.ca
parents:
74
diff
changeset
|
197 // t -> filespec = lw_strdup(s); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
198 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
199 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
200 void input_open(asmstate_t *as, char *s) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
201 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
202 struct input_stack *t; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
203 char *s2; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
204 char *p, *p2; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
205 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
206 t = lw_alloc(sizeof(struct input_stack)); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
207 t -> filespec = lw_strdup(s); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
208 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
209 for (s2 = s; *s2 && (*s2 != ':'); s2++) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
210 /* do nothing */ ; |
248
891bab942b5a
Another adjustment for the drive letter problem.
William Astle <lost@l-w.ca>
parents:
247
diff
changeset
|
211 if (input_isabsolute(s) || !*s2) |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
212 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
213 t -> type = input_type_file; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
214 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
215 else |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
216 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
217 char *ts; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
218 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
219 ts = lw_strndup(s, s2 - s); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
220 s = s2 + 1; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
221 if (!strcmp(ts, "include")) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
222 t -> type = input_type_include; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
223 else if (!strcmp(ts, "file")) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
224 t -> type = input_type_file; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
225 else |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
226 t -> type = input_type_error; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
227 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
228 lw_free(ts); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
229 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
230 t -> next = as -> input_data; |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
231 t -> stack = NULL; |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
232 as -> input_data = t; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
233 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
234 switch (IS -> type) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
235 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
236 case input_type_include: |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
237 /* first check for absolute path and if so, skip path */ |
247
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
238 if (input_isabsolute(s)) |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
239 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
240 /* absolute path */ |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
241 IS -> data = fopen(s, "rb"); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
242 debug_message(as, 1, "Opening (abs) %s", s); |
73
1f77ae5c3590
Added --dependnoerr flag to list dependencies on non-existent files without bailing out; also suppress error reports during dependency generation
lost@l-w.ca
parents:
10
diff
changeset
|
243 if (!IS -> data && !IGNOREERROR) |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
244 { |
74
e95eaf2f7fe0
Added missing newlines to error messages related to opening files
lost@l-w.ca
parents:
73
diff
changeset
|
245 lw_error("Cannot open file '%s': %s\n", s, strerror(errno)); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
246 } |
219 | 247 else |
248 { | |
249 as -> fileerr = 1; | |
250 } | |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
251 input_pushpath(as, s); |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
252 input_add_to_resource_list(as, s); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
253 return; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
254 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
255 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
256 /* relative path, check relative to "current file" directory */ |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
257 p = lw_stack_top(as -> file_dir); |
10
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
2
diff
changeset
|
258 p2 = make_filename(p, s); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
259 debug_message(as, 1, "Open: (cd) %s\n", p2); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
260 IS -> data = fopen(p2, "rb"); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
261 if (IS -> data) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
262 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
263 input_pushpath(as, p2); |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
264 input_add_to_resource_list(as, p2); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
265 lw_free(p2); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
266 return; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
267 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
268 debug_message(as, 2, "Failed to open: (cd) %s (%s)\n", p2, strerror(errno)); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
269 lw_free(p2); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
270 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
271 /* now check relative to entries in the search path */ |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
272 lw_stringlist_reset(as -> include_list); |
2
7317fbe024af
Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents:
0
diff
changeset
|
273 while ((p = lw_stringlist_current(as -> include_list))) |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
274 { |
10
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
2
diff
changeset
|
275 p2 = make_filename(p, s); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
276 debug_message(as, 1, "Open (sp): %s\n", p2); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
277 IS -> data = fopen(p2, "rb"); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
278 if (IS -> data) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
279 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
280 input_pushpath(as, p2); |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
281 input_add_to_resource_list(as, p2); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
282 lw_free(p2); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
283 return; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
284 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
285 debug_message(as, 2, "Failed to open: (sp) %s (%s)\n", p2, strerror(errno)); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
286 lw_free(p2); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
287 lw_stringlist_next(as -> include_list); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
288 } |
73
1f77ae5c3590
Added --dependnoerr flag to list dependencies on non-existent files without bailing out; also suppress error reports during dependency generation
lost@l-w.ca
parents:
10
diff
changeset
|
289 if (IGNOREERROR) |
1f77ae5c3590
Added --dependnoerr flag to list dependencies on non-existent files without bailing out; also suppress error reports during dependency generation
lost@l-w.ca
parents:
10
diff
changeset
|
290 { |
1f77ae5c3590
Added --dependnoerr flag to list dependencies on non-existent files without bailing out; also suppress error reports during dependency generation
lost@l-w.ca
parents:
10
diff
changeset
|
291 input_pushpath(as, s); |
219 | 292 as -> fileerr = 1; |
73
1f77ae5c3590
Added --dependnoerr flag to list dependencies on non-existent files without bailing out; also suppress error reports during dependency generation
lost@l-w.ca
parents:
10
diff
changeset
|
293 return; |
1f77ae5c3590
Added --dependnoerr flag to list dependencies on non-existent files without bailing out; also suppress error reports during dependency generation
lost@l-w.ca
parents:
10
diff
changeset
|
294 } |
74
e95eaf2f7fe0
Added missing newlines to error messages related to opening files
lost@l-w.ca
parents:
73
diff
changeset
|
295 lw_error("Cannot open include file '%s': %s\n", s, strerror(errno)); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
296 break; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
297 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
298 case input_type_file: |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
299 debug_message(as, 1, "Opening (reg): %s\n", s); |
554
7627d2b3b81f
Allow using - to refer to standard input for file names
William Astle <lost@l-w.ca>
parents:
379
diff
changeset
|
300 if (s[0] == '-' && s[1] == '\0') |
7627d2b3b81f
Allow using - to refer to standard input for file names
William Astle <lost@l-w.ca>
parents:
379
diff
changeset
|
301 IS -> data = stdin; |
7627d2b3b81f
Allow using - to refer to standard input for file names
William Astle <lost@l-w.ca>
parents:
379
diff
changeset
|
302 else |
7627d2b3b81f
Allow using - to refer to standard input for file names
William Astle <lost@l-w.ca>
parents:
379
diff
changeset
|
303 IS -> data = fopen(s, "rb"); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
304 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
305 if (!IS -> data) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
306 { |
74
e95eaf2f7fe0
Added missing newlines to error messages related to opening files
lost@l-w.ca
parents:
73
diff
changeset
|
307 lw_error("Cannot open file '%s': %s\n", s, strerror(errno)); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
308 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
309 input_pushpath(as, s); |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
310 input_add_to_resource_list(as, s); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
311 return; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
312 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
313 |
74
e95eaf2f7fe0
Added missing newlines to error messages related to opening files
lost@l-w.ca
parents:
73
diff
changeset
|
314 lw_error("Cannot figure out how to open '%s'.\n", t -> filespec); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
315 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
316 |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
317 FILE *input_open_standalone(asmstate_t *as, char *s, char **rfn) |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
318 { |
2
7317fbe024af
Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents:
0
diff
changeset
|
319 // char *s2; |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
320 FILE *fp; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
321 char *p, *p2; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
322 |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
323 debug_message(as, 2, "Open file (st) %s", s); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
324 /* first check for absolute path and if so, skip path */ |
247
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
325 if (input_isabsolute(s)) |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
326 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
327 /* absolute path */ |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
328 debug_message(as, 2, "Open file (st abs) %s", s); |
186 | 329 if (as -> flags & FLAG_DEPEND) |
330 printf("%s\n", s); | |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
331 fp = fopen(s, "rb"); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
332 if (!fp) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
333 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
334 return NULL; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
335 } |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
336 if (rfn) |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
337 *rfn = lw_strdup(s); |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
338 input_add_to_resource_list(as, s); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
339 return fp; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
340 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
341 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
342 /* relative path, check relative to "current file" directory */ |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
343 p = lw_stack_top(as -> file_dir); |
172
a88b04ba5ab8
Fixed segfault opening relative paths without a current directory on the stack; probably a symptom of another bug somewhere
William Astle <lost@l-w.ca>
parents:
110
diff
changeset
|
344 p2 = make_filename(p ? p : "", s); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
345 debug_message(as, 2, "Open file (st cd) %s", p2); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
346 fp = fopen(p2, "rb"); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
347 if (fp) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
348 { |
186 | 349 if (as -> flags & FLAG_DEPEND) |
350 printf("%s\n", p2); | |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
351 input_add_to_resource_list(as, p2); |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
352 if (rfn) |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
353 *rfn = lw_strdup(p2); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
354 lw_free(p2); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
355 return fp; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
356 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
357 lw_free(p2); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
358 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
359 /* now check relative to entries in the search path */ |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
360 lw_stringlist_reset(as -> include_list); |
2
7317fbe024af
Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents:
0
diff
changeset
|
361 while ((p = lw_stringlist_current(as -> include_list))) |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
362 { |
10
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
2
diff
changeset
|
363 p2 = make_filename(p, s); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
364 debug_message(as, 2, "Open file (st ip) %s", p2); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
365 fp = fopen(p2, "rb"); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
366 if (fp) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
367 { |
186 | 368 if (as -> flags & FLAG_DEPEND) |
369 printf("%s\n", p2); | |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
370 input_add_to_resource_list(as, p2); |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
371 if (rfn) |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
372 *rfn = lw_strdup(p2); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
373 lw_free(p2); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
374 return fp; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
375 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
376 lw_free(p2); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
377 lw_stringlist_next(as -> include_list); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
378 } |
186 | 379 |
380 // last ditch output for dependencies | |
381 if (as -> flags & FLAG_DEPEND) | |
382 { | |
383 p = lw_stack_top(as -> file_dir); | |
384 p2 = make_filename(p ? p : "", s); | |
385 printf("%s\n", p2); | |
386 lw_free(p2); | |
387 } | |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
388 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
389 return NULL; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
390 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
391 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
392 char *input_readline(asmstate_t *as) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
393 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
394 char *s; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
395 char linebuff[2049]; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
396 int lbloc; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
397 int eol = 0; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
398 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
399 /* if no file is open, open one */ |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
400 nextfile: |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
401 if (!IS) { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
402 s = lw_stringlist_current(as -> input_files); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
403 if (!s) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
404 return NULL; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
405 lw_stringlist_next(as -> input_files); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
406 input_open(as, s); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
407 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
408 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
409 switch (IS -> type) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
410 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
411 case input_type_file: |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
412 case input_type_include: |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
413 /* read from a file */ |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
414 lbloc = 0; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
415 for (;;) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
416 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
417 int c, c2; |
73
1f77ae5c3590
Added --dependnoerr flag to list dependencies on non-existent files without bailing out; also suppress error reports during dependency generation
lost@l-w.ca
parents:
10
diff
changeset
|
418 c = EOF; |
1f77ae5c3590
Added --dependnoerr flag to list dependencies on non-existent files without bailing out; also suppress error reports during dependency generation
lost@l-w.ca
parents:
10
diff
changeset
|
419 if (IS -> data) |
1f77ae5c3590
Added --dependnoerr flag to list dependencies on non-existent files without bailing out; also suppress error reports during dependency generation
lost@l-w.ca
parents:
10
diff
changeset
|
420 c = fgetc(IS -> data); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
421 if (c == EOF) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
422 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
423 if (lbloc == 0) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
424 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
425 struct input_stack *t; |
110 | 426 struct input_stack_node *n; |
73
1f77ae5c3590
Added --dependnoerr flag to list dependencies on non-existent files without bailing out; also suppress error reports during dependency generation
lost@l-w.ca
parents:
10
diff
changeset
|
427 if (IS -> data) |
1f77ae5c3590
Added --dependnoerr flag to list dependencies on non-existent files without bailing out; also suppress error reports during dependency generation
lost@l-w.ca
parents:
10
diff
changeset
|
428 fclose(IS -> data); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
429 lw_free(lw_stack_pop(as -> file_dir)); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
430 lw_free(IS -> filespec); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
431 t = IS -> next; |
110 | 432 while (IS -> stack) |
433 { | |
434 n = IS -> stack; | |
435 IS -> stack = n -> next; | |
436 lw_free(n -> entry); | |
437 lw_free(n); | |
438 } | |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
439 lw_free(IS); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
440 as -> input_data = t; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
441 goto nextfile; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
442 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
443 linebuff[lbloc] = '\0'; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
444 eol = 1; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
445 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
446 else if (c == '\r') |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
447 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
448 linebuff[lbloc] = '\0'; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
449 eol = 1; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
450 c2 = fgetc(IS -> data); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
451 if (c2 == EOF) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
452 c = EOF; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
453 else if (c2 != '\n') |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
454 ungetc(c2, IS -> data); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
455 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
456 else if (c == '\n') |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
457 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
458 linebuff[lbloc] = '\0'; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
459 eol = 1; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
460 c2 = fgetc(IS -> data); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
461 if (c2 == EOF) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
462 c = EOF; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
463 else if (c2 != '\r') |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
464 ungetc(c2, IS -> data); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
465 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
466 else |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
467 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
468 if (lbloc < 2048) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
469 linebuff[lbloc++] = c; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
470 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
471 if (eol) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
472 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
473 s = lw_strdup(linebuff); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
474 return s; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
475 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
476 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
477 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
478 case input_type_string: |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
479 /* read from a string */ |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
480 if (((char *)(IS -> data))[IS -> data2] == '\0') |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
481 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
482 struct input_stack *t; |
110 | 483 struct input_stack_node *n; |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
484 lw_free(IS -> data); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
485 lw_free(IS -> filespec); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
486 t = IS -> next; |
110 | 487 while (IS -> stack) |
488 { | |
489 n = IS -> stack; | |
490 IS -> stack = n -> next; | |
491 lw_free(n -> entry); | |
492 lw_free(n); | |
493 } | |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
494 lw_free(IS); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
495 as -> input_data = t; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
496 goto nextfile; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
497 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
498 s = (char *)(IS -> data); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
499 lbloc = 0; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
500 for (;;) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
501 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
502 int c; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
503 c = s[IS -> data2]; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
504 if (c) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
505 IS -> data2++; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
506 if (c == '\0') |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
507 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
508 linebuff[lbloc] = '\0'; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
509 eol = 1; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
510 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
511 else if (c == '\r') |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
512 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
513 linebuff[lbloc] = '\0'; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
514 eol = 1; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
515 if (s[IS -> data2] == '\n') |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
516 IS -> data2++; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
517 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
518 else if (c == '\n') |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
519 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
520 linebuff[lbloc] = '\0'; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
521 eol = 1; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
522 if (s[IS -> data2] == '\r') |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
523 IS -> data2++; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
524 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
525 else |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
526 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
527 if (lbloc < 2048) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
528 linebuff[lbloc++] = c; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
529 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
530 if (eol) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
531 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
532 s = lw_strdup(linebuff); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
533 return s; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
534 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
535 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
536 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
537 default: |
74
e95eaf2f7fe0
Added missing newlines to error messages related to opening files
lost@l-w.ca
parents:
73
diff
changeset
|
538 lw_error("Problem reading from unknown input type\n"); |
2
7317fbe024af
Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents:
0
diff
changeset
|
539 return NULL; |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
540 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
541 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
542 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
543 char *input_curspec(asmstate_t *as) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
544 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
545 if (IS) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
546 return IS -> filespec; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
547 return NULL; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
548 } |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
549 |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
550 void input_stack_push(asmstate_t *as, input_stack_entry *e) |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
551 { |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
552 struct input_stack_node *n; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
553 |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
554 n = lw_alloc(sizeof(struct input_stack_node)); |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
555 n -> next = IS -> stack; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
556 n -> entry = e; |
110 | 557 IS -> stack = n; |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
558 } |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
559 |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
560 input_stack_entry *input_stack_pop(asmstate_t *as, int magic, int (*fn)(input_stack_entry *e, void *data), void *data) |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
561 { |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
562 struct input_stack_node *n, *n2; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
563 input_stack_entry *e2; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
564 |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
565 n2 = NULL; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
566 for (n = IS -> stack; n; n = n -> next) |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
567 { |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
568 if (n -> entry -> magic == magic) |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
569 { |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
570 if ((*fn)(n -> entry, data)) |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
571 { |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
572 /* we have a match */ |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
573 e2 = n -> entry; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
574 if (n2) |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
575 n2 -> next = n -> next; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
576 else |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
577 IS -> stack = n -> next; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
578 lw_free(n); |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
579 return e2; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
580 } |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
581 } |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
582 n2 = n; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
583 } |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
584 return NULL; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
585 } |