+ return identify_string(headername);
+}
+
+static bool do_include(bool system_include, const char *headername)
+{
+ if (!system_include) {
+ /* for "bla" includes first try current dir
+ * TODO: this isn't correct, should be the directory of the source file
+ */
+ FILE *file = fopen(headername, "r");
+ if (file != NULL) {
+ switch_input(file, headername);
+ return true;
+ }
+ }
+
+ size_t headername_len = strlen(headername);
+ assert(obstack_object_size(&pp_obstack) == 0);
+ /* check searchpath */
+ for (searchpath_entry_t *entry = searchpath; entry != NULL;
+ entry = entry->next) {
+ const char *path = entry->path;
+ size_t len = strlen(path);
+ obstack_grow(&pp_obstack, path, len);
+ if (path[len-1] != '/')
+ obstack_1grow(&pp_obstack, '/');
+ obstack_grow(&pp_obstack, headername, headername_len+1);
+
+ char *complete_path = obstack_finish(&pp_obstack);
+ FILE *file = fopen(complete_path, "r");
+ if (file != NULL) {
+ const char *filename = identify_string(complete_path);
+ switch_input(file, filename);
+ return true;
+ }
+ obstack_free(&pp_obstack, complete_path);
+ }
+
+ return false;