117 |
/* Functions for normal input path search */ |
/* Functions for normal input path search */ |
118 |
|
|
119 |
void |
void |
120 |
m4_include_env_init (void) |
m4_include_env_init (m4 *context) |
121 |
{ |
{ |
122 |
if (no_gnu_extensions) |
if (m4_get_no_gnu_extensions_opt (context)) |
123 |
return; |
return; |
124 |
|
|
125 |
m4_search_path_env_init (&dirpath, getenv ("M4PATH"), FALSE); |
m4_search_path_env_init (&dirpath, getenv ("M4PATH"), FALSE); |
126 |
} |
} |
127 |
|
|
128 |
void |
void |
129 |
m4_add_include_directory (const char *dir) |
m4_add_include_directory (m4 *context, const char *dir) |
130 |
{ |
{ |
131 |
if (no_gnu_extensions) |
if (m4_get_no_gnu_extensions_opt (context)) |
132 |
return; |
return; |
133 |
|
|
134 |
m4_search_path_add (&dirpath, dir); |
m4_search_path_add (&dirpath, dir); |
139 |
} |
} |
140 |
|
|
141 |
FILE * |
FILE * |
142 |
m4_path_search (const char *dir, char **expanded_name) |
m4_path_search (m4 *context, const char *dir, char **expanded_name) |
143 |
{ |
{ |
144 |
FILE *fp; |
FILE *fp; |
145 |
struct m4_search_path *incl; |
struct m4_search_path *incl; |
155 |
} |
} |
156 |
|
|
157 |
/* If file not found, and filename absolute, fail. */ |
/* If file not found, and filename absolute, fail. */ |
158 |
if (*dir == '/' || no_gnu_extensions) |
if (*dir == '/' || m4_get_no_gnu_extensions_opt (context)) |
159 |
return NULL; |
return NULL; |
160 |
|
|
161 |
name = (char *) xmalloc (dirpath.max_length + 1 + strlen (dir) + 1); |
name = (char *) xmalloc (dirpath.max_length + 1 + strlen (dir) + 1); |
173 |
fp = fopen (name, "r"); |
fp = fopen (name, "r"); |
174 |
if (fp != NULL) |
if (fp != NULL) |
175 |
{ |
{ |
176 |
if (debug_level & M4_DEBUG_TRACE_PATH) |
if (BIT_TEST (m4_get_debug_level_opt (context), M4_DEBUG_TRACE_PATH)) |
177 |
M4_DEBUG_MESSAGE2 (_("Path search for `%s' found `%s'"), dir, name); |
M4_DEBUG_MESSAGE2 (context, _("Path search for `%s' found `%s'"), |
178 |
|
dir, name); |
179 |
|
|
180 |
if (expanded_name != NULL) |
if (expanded_name != NULL) |
181 |
*expanded_name = xstrdup (name); |
*expanded_name = xstrdup (name); |