Mercurial > hg > index.cgi
annotate lwasm/input.c @ 279:4051bc09da78
Fix absolute path handling on Windows
Actually recognize lower case drive letters. Lower case letters include the
range 'a' ... 'z', not 'a' ... 'A', the latter containing zero members as
the test was previously implemented.
author | William Astle <lost@l-w.ca> |
---|---|
date | Tue, 16 Jul 2013 17:04:45 -0600 |
parents | 201b2774cb0e |
children | d791d47afc48 |
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 |
247
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
85 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
|
86 { |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
87 #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
|
88 // 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
|
89 if (s[0] == '/') |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
90 return 1; |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
91 // 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
|
92 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
|
93 return 0; |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
94 if (s[1] != ':') |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
95 return 0; |
279
4051bc09da78
Fix absolute path handling on Windows
William Astle <lost@l-w.ca>
parents:
252
diff
changeset
|
96 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
|
97 return 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 #else |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
100 /* 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
|
101 if (s[0] == '/') |
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 #endif |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
105 } |
4b36eaaf80c3
First attempt at fixing the drive letter problem on Windows
William Astle <lost@l-w.ca>
parents:
224
diff
changeset
|
106 |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
107 /* 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
|
108 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
|
109 { |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
110 struct ifl *ifl; |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
111 |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
112 /* 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
|
113 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
|
114 { |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
115 if (strcmp(s, ifl -> fn) == 0) |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
116 break; |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
117 } |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
118 if (!ifl) |
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 ifl = lw_alloc(sizeof(struct ifl)); |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
121 ifl -> next = ifl_head; |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
122 ifl_head = ifl; |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
123 ifl -> fn = lw_strdup(s); |
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 } |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
126 |
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
|
127 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
|
128 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
129 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
|
130 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
131 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
|
132 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
|
133 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
|
134 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
|
135 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
|
136 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
|
137 { |
2c24602be78f
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 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
|
139 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
|
140 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
|
141 } |
2c24602be78f
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 |
2c24602be78f
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 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
|
145 { |
2c24602be78f
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 /* 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
|
147 /* 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
|
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 /* 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
|
150 char *dn, *dp; |
2
7317fbe024af
Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents:
0
diff
changeset
|
151 // 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
|
152 |
2c24602be78f
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 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
|
154 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
|
155 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
156 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
|
157 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
|
158 |
2c24602be78f
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 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
|
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 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
|
162 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
|
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 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
|
165 *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
|
166 |
2c24602be78f
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 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
|
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 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
|
170 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
|
171 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
|
172 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
|
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 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
|
175 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
|
176 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
|
177 } |
2c24602be78f
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 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
|
180 { |
2c24602be78f
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 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
|
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 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
|
184 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
|
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 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
|
187 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
|
188 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
|
189 t -> next = IS; |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
190 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
|
191 as -> input_data = t; |
93
5bf9edabd661
Squashed the remaining memory leaks revealed by valgrind
lost@l-w.ca
parents:
74
diff
changeset
|
192 // 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
|
193 } |
2c24602be78f
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 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
195 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
|
196 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
197 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
|
198 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
|
199 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
|
200 |
2c24602be78f
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 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
|
202 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
|
203 |
2c24602be78f
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 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
|
205 /* do nothing */ ; |
248
891bab942b5a
Another adjustment for the drive letter problem.
William Astle <lost@l-w.ca>
parents:
247
diff
changeset
|
206 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
|
207 { |
2c24602be78f
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 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
|
209 } |
2c24602be78f
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 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
|
211 { |
2c24602be78f
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 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
|
213 |
2c24602be78f
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 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
|
215 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
|
216 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
|
217 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
|
218 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
|
219 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
|
220 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
|
221 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
|
222 |
2c24602be78f
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 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
|
224 } |
2c24602be78f
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 t -> next = as -> input_data; |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
226 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
|
227 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
|
228 |
2c24602be78f
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 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
|
230 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
231 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
|
232 /* 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
|
233 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
|
234 { |
2c24602be78f
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 /* 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
|
236 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
|
237 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
|
238 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
|
239 { |
74
e95eaf2f7fe0
Added missing newlines to error messages related to opening files
lost@l-w.ca
parents:
73
diff
changeset
|
240 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
|
241 } |
219 | 242 else |
243 { | |
244 as -> fileerr = 1; | |
245 } | |
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 input_pushpath(as, s); |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
247 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
|
248 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
|
249 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
250 |
2c24602be78f
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 /* 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
|
252 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
|
253 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
|
254 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
|
255 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
|
256 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
|
257 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
258 input_pushpath(as, p2); |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
259 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
|
260 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
|
261 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
|
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 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
|
264 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
|
265 |
2c24602be78f
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 /* 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
|
267 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
|
268 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
|
269 { |
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
|
270 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
|
271 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
|
272 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
|
273 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
|
274 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
275 input_pushpath(as, p2); |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
276 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
|
277 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
|
278 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
|
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 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
|
281 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
|
282 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
|
283 } |
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
|
284 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
|
285 { |
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
|
286 input_pushpath(as, s); |
219 | 287 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
|
288 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
|
289 } |
74
e95eaf2f7fe0
Added missing newlines to error messages related to opening files
lost@l-w.ca
parents:
73
diff
changeset
|
290 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
|
291 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
|
292 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
293 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
|
294 debug_message(as, 1, "Opening (reg): %s\n", 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
|
295 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
|
296 |
2c24602be78f
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 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
|
298 { |
74
e95eaf2f7fe0
Added missing newlines to error messages related to opening files
lost@l-w.ca
parents:
73
diff
changeset
|
299 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
|
300 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
301 input_pushpath(as, s); |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
302 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
|
303 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
|
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 |
74
e95eaf2f7fe0
Added missing newlines to error messages related to opening files
lost@l-w.ca
parents:
73
diff
changeset
|
306 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
|
307 } |
2c24602be78f
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 |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
309 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
|
310 { |
2
7317fbe024af
Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents:
0
diff
changeset
|
311 // 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
|
312 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
|
313 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
|
314 |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
315 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
|
316 /* 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
|
317 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
|
318 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
319 /* 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
|
320 debug_message(as, 2, "Open file (st abs) %s", s); |
186 | 321 if (as -> flags & FLAG_DEPEND) |
322 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
|
323 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
|
324 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
|
325 { |
2c24602be78f
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 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
|
327 } |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
328 if (rfn) |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
329 *rfn = lw_strdup(s); |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
330 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
|
331 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
|
332 } |
2c24602be78f
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 /* 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
|
335 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
|
336 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
|
337 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
|
338 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
|
339 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
|
340 { |
186 | 341 if (as -> flags & FLAG_DEPEND) |
342 printf("%s\n", p2); | |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
343 input_add_to_resource_list(as, p2); |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
344 if (rfn) |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
345 *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
|
346 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
|
347 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
|
348 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
349 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
|
350 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
351 /* 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
|
352 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
|
353 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
|
354 { |
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
|
355 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
|
356 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
|
357 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
|
358 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
|
359 { |
186 | 360 if (as -> flags & FLAG_DEPEND) |
361 printf("%s\n", p2); | |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
362 input_add_to_resource_list(as, p2); |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
363 if (rfn) |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
364 *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
|
365 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
|
366 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
|
367 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
368 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
|
369 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
|
370 } |
186 | 371 |
372 // last ditch output for dependencies | |
373 if (as -> flags & FLAG_DEPEND) | |
374 { | |
375 p = lw_stack_top(as -> file_dir); | |
376 p2 = make_filename(p ? p : "", s); | |
377 printf("%s\n", p2); | |
378 lw_free(p2); | |
379 } | |
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
|
380 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
381 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
|
382 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
383 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
384 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
|
385 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
386 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
|
387 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
|
388 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
|
389 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
|
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 /* 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
|
392 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
|
393 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
|
394 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
|
395 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
|
396 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
|
397 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
|
398 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
|
399 } |
2c24602be78f
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 |
2c24602be78f
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 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
|
402 { |
2c24602be78f
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 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
|
404 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
|
405 /* 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
|
406 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
|
407 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
|
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 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
|
410 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
|
411 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
|
412 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
|
413 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
|
414 { |
2c24602be78f
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 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
|
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 struct input_stack *t; |
110 | 418 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
|
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 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
|
421 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
|
422 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
|
423 t = IS -> next; |
110 | 424 while (IS -> stack) |
425 { | |
426 n = IS -> stack; | |
427 IS -> stack = n -> next; | |
428 lw_free(n -> entry); | |
429 lw_free(n); | |
430 } | |
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
|
431 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
|
432 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
|
433 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
|
434 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
435 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
|
436 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
|
437 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
438 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
|
439 { |
2c24602be78f
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 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
|
441 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
|
442 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
|
443 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
|
444 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
|
445 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
|
446 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
|
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 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
|
449 { |
2c24602be78f
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 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
|
451 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
|
452 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
|
453 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
|
454 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
|
455 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
|
456 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
|
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 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
|
459 { |
2c24602be78f
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 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
|
461 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
|
462 } |
2c24602be78f
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 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
|
464 { |
2c24602be78f
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 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
|
466 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
|
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 } |
2c24602be78f
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 |
2c24602be78f
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 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
|
471 /* 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
|
472 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
|
473 { |
2c24602be78f
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 struct input_stack *t; |
110 | 475 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
|
476 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
|
477 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
|
478 t = IS -> next; |
110 | 479 while (IS -> stack) |
480 { | |
481 n = IS -> stack; | |
482 IS -> stack = n -> next; | |
483 lw_free(n -> entry); | |
484 lw_free(n); | |
485 } | |
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
|
486 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
|
487 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
|
488 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
|
489 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
490 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
|
491 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
|
492 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
|
493 { |
2c24602be78f
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 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
|
495 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
|
496 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
|
497 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
|
498 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
|
499 { |
2c24602be78f
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 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
|
501 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
|
502 } |
2c24602be78f
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 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
|
504 { |
2c24602be78f
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 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
|
506 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
|
507 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
|
508 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
|
509 } |
2c24602be78f
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 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
|
511 { |
2c24602be78f
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 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
|
513 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
|
514 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
|
515 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
|
516 } |
2c24602be78f
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 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
|
518 { |
2c24602be78f
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 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
|
520 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
|
521 } |
2c24602be78f
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 (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
|
523 { |
2c24602be78f
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 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
|
525 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
|
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 } |
2c24602be78f
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 |
2c24602be78f
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 default: |
74
e95eaf2f7fe0
Added missing newlines to error messages related to opening files
lost@l-w.ca
parents:
73
diff
changeset
|
530 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
|
531 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
|
532 } |
2c24602be78f
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 } |
2c24602be78f
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 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
|
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 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
|
538 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
|
539 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
|
540 } |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
541 |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
542 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
|
543 { |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
544 struct input_stack_node *n; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
545 |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
546 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
|
547 n -> next = IS -> stack; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
548 n -> entry = e; |
110 | 549 IS -> stack = n; |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
550 } |
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 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
|
553 { |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
554 struct input_stack_node *n, *n2; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
555 input_stack_entry *e2; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
556 |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
557 n2 = NULL; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
558 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
|
559 { |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
560 if (n -> entry -> magic == magic) |
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 if ((*fn)(n -> entry, data)) |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
563 { |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
564 /* we have a match */ |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
565 e2 = n -> entry; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
566 if (n2) |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
567 n2 -> next = n -> next; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
568 else |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
569 IS -> stack = n -> next; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
570 lw_free(n); |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
571 return e2; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
572 } |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
573 } |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
574 n2 = n; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
575 } |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
576 return NULL; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
93
diff
changeset
|
577 } |