summaryrefslogtreecommitdiff
path: root/base/inifile.cc
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2003-10-25 18:19:32 -0400
committerNathan Binkert <binkertn@umich.edu>2003-10-25 18:19:32 -0400
commitff7b6892bcd00c53e1aa8beb86f5da2ab90fe733 (patch)
treecb8b093374ebc5fb9f4b3e27b3028096c43fb316 /base/inifile.cc
parent2eec2853915a8b77fbe48d028704c19c556183d5 (diff)
downloadgem5-ff7b6892bcd00c53e1aa8beb86f5da2ab90fe733.tar.xz
Add the directory where the ini file was found into the #include
search path --HG-- extra : convert_revision : 9a6bceb931613b718bf5a561b354ba9ccb847a78
Diffstat (limited to 'base/inifile.cc')
-rw-r--r--base/inifile.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/base/inifile.cc b/base/inifile.cc
index 6baf22850..52468f46e 100644
--- a/base/inifile.cc
+++ b/base/inifile.cc
@@ -85,6 +85,17 @@ IniFile::loadCPP(const string &file, vector<char *> &cppArgs)
tmpf.close();
+ const char *cfile = file.c_str();
+ char *dir = basename(cfile);
+ char *dir_arg = NULL;
+ if (*dir != '.' && dir != cfile) {
+ string arg = "-I";
+ arg += dir;
+
+ dir_arg = new char[arg.size() + 1];
+ strcpy(dir_arg, arg.c_str());
+ }
+
#ifdef CPP_PIPE
if (pipe(fd) == -1)
return false;
@@ -120,6 +131,9 @@ IniFile::loadCPP(const string &file, vector<char *> &cppArgs)
for (int i = 0; i < arg_count; i++)
args[nextArg++] = cppArgs[i];
+ if (dir_arg)
+ args[nextArg++] = dir_arg;
+
args[nextArg++] = filename;
args[nextArg++] = NULL;
@@ -135,6 +149,8 @@ IniFile::loadCPP(const string &file, vector<char *> &cppArgs)
int retval;
waitpid(pid, &retval, 0);
+ delete [] dir_arg;
+
// check for normal completion of CPP
if (!WIFEXITED(retval) || WEXITSTATUS(retval) != 0)
return false;