- if (file[1] == '/' && PATH_MAX > snprintf(path, PATH_MAX, "%.*s", f_len, file + 1)) {
- return try_include(cpp, path, &parsed) && parsed;
- } else {
+ if (!(flags & PSI_CPP_INCLUDE_NEXT) || *file->text == '/') {
+ /* first try as is, full or relative path */
+ char temp[PATH_MAX], *path = temp;
+
+ include_path(file, &path);
+
+ if ((flags & PSI_CPP_INCLUDE_ONCE) && zend_hash_str_exists(&cpp->once, path, f_len)) {
+ return true;
+ }
+ if (try_include(cpp, path, &parsed)) {
+ /* found */
+ return parsed;
+ }
+ }
+
+ /* look through search paths */
+ if (*file->text != '/') {
+ char path[PATH_MAX];