25
26 /*
27 * read.c
28 *
29 * This file contains the makefile reader.
30 */
31
32 /*
33 * Included files
34 */
35 #include <avo/avo_alloca.h> /* alloca() */
36 #include <errno.h> /* errno */
37 #include <fcntl.h> /* fcntl() */
38 #include <mk/defs.h>
39 #include <mksh/macro.h> /* expand_value(), expand_macro() */
40 #include <mksh/misc.h> /* getmem() */
41 #include <mksh/read.h> /* get_next_block_fn() */
42 #include <sys/uio.h> /* read() */
43 #include <unistd.h> /* read(), unlink() */
44
45 #if defined(HP_UX) || defined(linux)
46 #include <avo/types.h>
47 extern "C" Avo_err *avo_find_run_dir(char **dirp);
48 #endif
49
50 /*
51 * typedefs & structs
52 */
53
54 /*
55 * Static variables
56 */
57
58 static int line_started_with_space=0; // Used to diagnose spaces instead of tabs
59
60 /*
61 * File table of contents
62 */
63 static void parse_makefile(register Name true_makefile_name, register Source source);
64 static Source push_macro_value(register Source bp, register wchar_t *buffer, int size, register Source source);
65 extern void enter_target_groups_and_dependencies(Name_vector target, Name_vector depes, Cmd_line command, Separator separator, Boolean target_group_seen);
66 extern Name normalize_name(register wchar_t *name_string, register int length);
67
68 /*
100 register Property makefile = maybe_append_prop(makefile_name,
101 makefile_prop);
102 Boolean forget_after_parse = false;
103 static pathpt makefile_path;
104 register int n;
105 char *path;
106 register Source source = ALLOC(Source);
107 Property orig_makefile = makefile;
108 Dependency *dpp;
109 Dependency dp;
110 register int length;
111 wchar_t *previous_file_being_read = file_being_read;
112 int previous_line_number = line_number;
113 wchar_t previous_current_makefile[MAXPATHLEN];
114 Makefile_type save_makefile_type;
115 Name normalized_makefile_name;
116 register wchar_t *string_start;
117 register wchar_t *string_end;
118
119
120 #if defined(HP_UX) || defined(linux)
121 Avo_err *findrundir_err;
122 char *run_dir, makerules_dir[BUFSIZ];
123 #endif
124
125 wchar_t * wcb = get_wstring(makefile_name->string_mb);
126
127 #ifdef NSE
128 if (report_file){
129 wscpy(previous_current_makefile, current_makefile);
130 wscpy(current_makefile, wcb);
131 }
132 #endif
133 if (max_include_depth++ >= 40) {
134 fatal(catgets(catd, 1, 66, "Too many nested include statements"));
135 }
136 if (makefile->body.makefile.contents != NULL) {
137 retmem(makefile->body.makefile.contents);
138 }
139 source->inp_buf =
140 source->inp_buf_ptr =
141 source->inp_buf_end = NULL;
142 source->error_converting = false;
143 makefile->body.makefile.contents = NULL;
|
25
26 /*
27 * read.c
28 *
29 * This file contains the makefile reader.
30 */
31
32 /*
33 * Included files
34 */
35 #include <avo/avo_alloca.h> /* alloca() */
36 #include <errno.h> /* errno */
37 #include <fcntl.h> /* fcntl() */
38 #include <mk/defs.h>
39 #include <mksh/macro.h> /* expand_value(), expand_macro() */
40 #include <mksh/misc.h> /* getmem() */
41 #include <mksh/read.h> /* get_next_block_fn() */
42 #include <sys/uio.h> /* read() */
43 #include <unistd.h> /* read(), unlink() */
44
45
46 /*
47 * typedefs & structs
48 */
49
50 /*
51 * Static variables
52 */
53
54 static int line_started_with_space=0; // Used to diagnose spaces instead of tabs
55
56 /*
57 * File table of contents
58 */
59 static void parse_makefile(register Name true_makefile_name, register Source source);
60 static Source push_macro_value(register Source bp, register wchar_t *buffer, int size, register Source source);
61 extern void enter_target_groups_and_dependencies(Name_vector target, Name_vector depes, Cmd_line command, Separator separator, Boolean target_group_seen);
62 extern Name normalize_name(register wchar_t *name_string, register int length);
63
64 /*
96 register Property makefile = maybe_append_prop(makefile_name,
97 makefile_prop);
98 Boolean forget_after_parse = false;
99 static pathpt makefile_path;
100 register int n;
101 char *path;
102 register Source source = ALLOC(Source);
103 Property orig_makefile = makefile;
104 Dependency *dpp;
105 Dependency dp;
106 register int length;
107 wchar_t *previous_file_being_read = file_being_read;
108 int previous_line_number = line_number;
109 wchar_t previous_current_makefile[MAXPATHLEN];
110 Makefile_type save_makefile_type;
111 Name normalized_makefile_name;
112 register wchar_t *string_start;
113 register wchar_t *string_end;
114
115
116
117 wchar_t * wcb = get_wstring(makefile_name->string_mb);
118
119 #ifdef NSE
120 if (report_file){
121 wscpy(previous_current_makefile, current_makefile);
122 wscpy(current_makefile, wcb);
123 }
124 #endif
125 if (max_include_depth++ >= 40) {
126 fatal(catgets(catd, 1, 66, "Too many nested include statements"));
127 }
128 if (makefile->body.makefile.contents != NULL) {
129 retmem(makefile->body.makefile.contents);
130 }
131 source->inp_buf =
132 source->inp_buf_ptr =
133 source->inp_buf_end = NULL;
134 source->error_converting = false;
135 makefile->body.makefile.contents = NULL;
|