Skip to content

Commit b9e5ce4

Browse files
paulbissfacebook-github-bot
authored andcommitted
Remove support for hdf.loadpaths search paths for includes and optional includes
Summary: None of our configs define `hdf.loadpaths` (in fact all of them seem to use absolute paths, though when no `loadpaths` is defined relative paths are just relative to the current config). Additionally none of our configs use the optional include (`-include`) syntax. Reviewed By: ricklavoie Differential Revision: D39525828 fbshipit-source-id: f9edc349a5d3c5b9b538b77eedd816183d2dc2c0
1 parent 6dc327e commit b9e5ce4

File tree

1 file changed

+3
-52
lines changed

1 file changed

+3
-52
lines changed

hphp/neo/neo_hdf.c

Lines changed: 3 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -949,9 +949,8 @@ static NEOERR* _hdf_read_string (HDF *hdf, const char **str, NEOSTRING *line,
949949
(*lineno)++;
950950
s = line->buf;
951951
SKIPWS(s);
952-
if ((!strncmp(s, "#include ", 9) || !strncmp(s, "-include ", 9)) && include_handle != INCLUDE_IGNORE)
952+
if (!strncmp(s, "#include ", 9) && include_handle != INCLUDE_IGNORE)
953953
{
954-
int required = !strncmp(s, "#include ", 9);
955954
if (include_handle == INCLUDE_ERROR)
956955
{
957956
return nerr_raise (NERR_PARSE,
@@ -987,7 +986,7 @@ static NEOERR* _hdf_read_string (HDF *hdf, const char **str, NEOSTRING *line,
987986
name = fullpath;
988987
}
989988
err = hdf_read_file_internal(hdf, name, include_handle + 1);
990-
if (err != STATUS_OK && required)
989+
if (err != STATUS_OK)
991990
{
992991
return nerr_pass_ctx(err, "In file %s:%d", path, *lineno);
993992
}
@@ -1206,66 +1205,18 @@ NEOERR * hdf_read_string (HDF *hdf, const char *str)
12061205
return nerr_pass(err);
12071206
}
12081207

1209-
/* The search path is part of the HDF by convention */
1210-
NEOERR* hdf_search_path (HDF *hdf, const char *path, char *full, int full_len)
1211-
{
1212-
HDF *paths;
1213-
struct stat s;
1214-
NEOERR* err = STATUS_OK;
1215-
1216-
paths = hdf_get_child (hdf, "hdf.loadpaths", &err);
1217-
if (err != STATUS_OK) return err;
1218-
1219-
for (; paths; paths = hdf_obj_next (paths))
1220-
{
1221-
char* value = hdf_obj_value(paths, &err);
1222-
if (err != STATUS_OK) return err;
1223-
snprintf (full, full_len, "%s/%s", value, path);
1224-
errno = 0;
1225-
if (stat (full, &s) == -1)
1226-
{
1227-
if (errno != ENOENT)
1228-
return nerr_raise_errno (NERR_SYSTEM, "Stat of %s failed", full);
1229-
}
1230-
else
1231-
{
1232-
return STATUS_OK;
1233-
}
1234-
}
1235-
1236-
strncpy (full, path, full_len);
1237-
full[full_len > 0 ? full_len-1 : full_len] = '\0';
1238-
1239-
if (stat (full, &s) == -1)
1240-
{
1241-
if (errno != ENOENT)
1242-
return nerr_raise_errno (NERR_SYSTEM, "Stat of %s failed", full);
1243-
}
1244-
else return STATUS_OK;
1245-
1246-
return nerr_raise (NERR_NOT_FOUND, "Path %s not found", path);
1247-
}
1248-
12491208
static NEOERR* hdf_read_file_internal (HDF *hdf, const char *path,
12501209
int include_handle)
12511210
{
12521211
NEOERR *err;
12531212
int lineno = 0;
1254-
char fpath[PATH_BUF_SIZE];
12551213
char *ibuf = NULL;
12561214
const char *ptr = NULL;
12571215
NEOSTRING line;
12581216

12591217
string_init(&line);
12601218

1261-
if (path == NULL)
1262-
return nerr_raise(NERR_ASSERT, "Can't read NULL file");
1263-
if (path[0] != '/')
1264-
{
1265-
err = hdf_search_path (hdf, path, fpath, PATH_BUF_SIZE);
1266-
if (err != STATUS_OK) return nerr_pass(err);
1267-
path = fpath;
1268-
}
1219+
if (path == NULL) return nerr_raise(NERR_ASSERT, "Can't read NULL file");
12691220

12701221
err = ne_load_file (path, &ibuf);
12711222
if (err) return nerr_pass(err);

0 commit comments

Comments
 (0)