Switch to unified view

a/src/conftree.cpp b/src/conftree.cpp
...
...
96
            line = cline;
96
            line = cline;
97
        }
97
        }
98
98
99
        // Note that we trim whitespace before checking for backslash-eol
99
        // Note that we trim whitespace before checking for backslash-eol
100
        // This avoids invisible whitespace problems.
100
        // This avoids invisible whitespace problems.
101
        if (trimvalues) {
101
        trimstring(line);
102
            trimstring(line);
103
        } else {
104
            ltrimstring(line);
105
        }
102
        if (line.empty() || line.at(0) == '#') {
106
        if (line.empty() || line.at(0) == '#') {
103
            if (eof) {
107
            if (eof) {
104
                break;
108
                break;
105
            }
109
            }
106
            if (varcomment_rx.simpleMatch(line)) {
110
            if (varcomment_rx.simpleMatch(line)) {
...
...
117
            continue;
121
            continue;
118
        }
122
        }
119
        appending = false;
123
        appending = false;
120
124
121
        if (line[0] == '[') {
125
        if (line[0] == '[') {
122
            trimstring(line, "[]");
126
            trimstring(line, "[] \t");
123
            if (dotildexpand) {
127
            if (dotildexpand) {
124
                submapkey = path_tildexpand(line);
128
                submapkey = path_tildexpand(line);
125
            } else {
129
            } else {
126
                submapkey = line;
130
                submapkey = line;
127
            }
131
            }
...
...
140
        // Compute name and value, trim white space
144
        // Compute name and value, trim white space
141
        string nm, val;
145
        string nm, val;
142
        nm = line.substr(0, eqpos);
146
        nm = line.substr(0, eqpos);
143
        trimstring(nm);
147
        trimstring(nm);
144
        val = line.substr(eqpos + 1, string::npos);
148
        val = line.substr(eqpos + 1, string::npos);
149
        if (trimvalues) {
145
        trimstring(val);
150
            trimstring(val);
151
        }
146
152
147
        if (nm.length() == 0) {
153
        if (nm.length() == 0) {
148
            m_order.push_back(ConfLine(ConfLine::CFL_COMMENT, line));
154
            m_order.push_back(ConfLine(ConfLine::CFL_COMMENT, line));
149
            continue;
155
            continue;
150
        }
156
        }
...
...
154
        }
160
        }
155
    }
161
    }
156
}
162
}
157
163
158
164
159
ConfSimple::ConfSimple(int readonly, bool tildexp)
165
ConfSimple::ConfSimple(int readonly, bool tildexp, bool trimv)
160
    : dotildexpand(tildexp), m_fmtime(0), m_holdWrites(false)
166
    : dotildexpand(tildexp), trimvalues(trimv), m_fmtime(0), m_holdWrites(false)
161
{
167
{
162
    status = readonly ? STATUS_RO : STATUS_RW;
168
    status = readonly ? STATUS_RO : STATUS_RW;
163
}
169
}
164
170
165
void ConfSimple::reparse(const string& d)
171
void ConfSimple::reparse(const string& d)
...
...
167
    clear();
173
    clear();
168
    stringstream input(d, ios::in);
174
    stringstream input(d, ios::in);
169
    parseinput(input);
175
    parseinput(input);
170
}
176
}
171
177
172
ConfSimple::ConfSimple(const string& d, int readonly, bool tildexp)
178
ConfSimple::ConfSimple(const string& d, int readonly, bool tildexp, bool trimv)
173
    : dotildexpand(tildexp), m_fmtime(0), m_holdWrites(false)
179
    : dotildexpand(tildexp), trimvalues(trimv), m_fmtime(0), m_holdWrites(false)
174
{
180
{
175
    status = readonly ? STATUS_RO : STATUS_RW;
181
    status = readonly ? STATUS_RO : STATUS_RW;
176
182
177
    stringstream input(d, ios::in);
183
    stringstream input(d, ios::in);
178
    parseinput(input);
184
    parseinput(input);
179
}
185
}
180
186
181
ConfSimple::ConfSimple(const char *fname, int readonly, bool tildexp)
187
ConfSimple::ConfSimple(const char *fname, int readonly, bool tildexp,
182
    : dotildexpand(tildexp), m_filename(fname), m_fmtime(0), m_holdWrites(false)
188
                       bool trimv)
189
    : dotildexpand(tildexp), trimvalues(trimv), m_filename(fname),
190
      m_fmtime(0), m_holdWrites(false)
183
{
191
{
184
    status = readonly ? STATUS_RO : STATUS_RW;
192
    status = readonly ? STATUS_RO : STATUS_RW;
185
193
186
    ifstream input;
194
    ifstream input;
187
    if (readonly) {
195
    if (readonly) {