diff options
author | nyamatongwe <devnull@localhost> | 2000-07-03 08:28:47 +0000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2000-07-03 08:28:47 +0000 |
commit | 067aef7d295fe623e6b6bf7fe90b31819e37c8ba (patch) | |
tree | a1c4a6bc312af180eb260af10d76aff9ec267718 /src/PropSet.cxx | |
parent | c5164f693e8468a022e2b67add63b653b889cac9 (diff) | |
download | scintilla-mirror-067aef7d295fe623e6b6bf7fe90b31819e37c8ba.tar.gz |
Added 'if' and 'import' statements to properties files.
Diffstat (limited to 'src/PropSet.cxx')
-rw-r--r-- | src/PropSet.cxx | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/src/PropSet.cxx b/src/PropSet.cxx index b582327b7..2558201a6 100644 --- a/src/PropSet.cxx +++ b/src/PropSet.cxx @@ -97,6 +97,8 @@ void PropSet::Set(const char *key, const char *val) { } void PropSet::Set(char *keyval) { + while (isspace(*keyval)) + keyval++; char *eqat = strchr(keyval, '='); if (eqat) { *eqat = '\0'; @@ -244,29 +246,38 @@ void PropSet::Clear() { used = 0; } -void PropSet::ReadFromMemory(const char *data, int len) { - if (len > 0) { - const char *pd = data; - char linebuf[60000]; - while (GetFullLine(pd, len, linebuf, sizeof(linebuf))) { - if (isalpha(linebuf[0])) - Set(linebuf); - } - // If there is a final line: - if (isalpha(linebuf[0])) +void PropSet::ReadFromMemory(const char *data, int len, const char *directoryForImports) { + const char *pd = data; + char linebuf[60000]; + bool ifIsTrue = true; + while (len > 0) { + GetFullLine(pd, len, linebuf, sizeof(linebuf)); + if (isalpha(linebuf[0])) // If clause ends with first non-indented line + ifIsTrue = true; + if (isprefix(linebuf, "if ")) { + const char *expr = linebuf + strlen("if") + 1; + ifIsTrue = GetInt(expr); + } else if (isprefix(linebuf, "import ") && directoryForImports) { + char importPath[MAX_PATH]; + strcpy(importPath, directoryForImports); + strcat(importPath, linebuf + strlen("import") + 1); + strcat(importPath, ".properties"); + Read(importPath,directoryForImports); + } else if (isalpha(linebuf[0])) { + Set(linebuf); + } else if (isspace(linebuf[0]) && ifIsTrue) { Set(linebuf); + } } } -void PropSet::Read(const char *filename) { - //printf("Opening properties <%s>\n", filename); - Clear(); +void PropSet::Read(const char *filename, const char *directoryForImports) { char propsData[60000]; FILE *rcfile = fopen(filename, "rb"); if (rcfile) { int lenFile = fread(propsData, 1, sizeof(propsData), rcfile); fclose(rcfile); - ReadFromMemory(propsData, lenFile); + ReadFromMemory(propsData, lenFile, directoryForImports); } else { //printf("Could not open <%s>\n", filename); } |