| 155 | } |
| 156 | |
| 157 | static MountRule parseRuleString(const std::string& ruleText) { |
| 158 | if (!validateSyntax(ruleText)) { |
| 159 | return {}; |
| 160 | } |
| 161 | |
| 162 | MountRule rule; |
| 163 | auto tokens = tokenizePreserveQuotes(ruleText); |
| 164 | |
| 165 | enum Section { NONE, ROOT, POINT, FILESYSTEM, SOURCE } current = NONE; |
| 166 | enum State { WRITING, IDLE } state = IDLE; |
| 167 | |
| 168 | for (std::string& word : tokens) { |
| 169 | if (state == IDLE) { |
| 170 | if (current == NONE) { |
| 171 | if (word == "root") current = ROOT; |
| 172 | else if (word == "point") current = POINT; |
| 173 | else if (word == "fs") current = FILESYSTEM; |
| 174 | else if (word == "source") current = SOURCE; |
| 175 | } else if (word == "{") { |
| 176 | state = WRITING; |
| 177 | } |
| 178 | } else if (state == WRITING && word == "}") { |
| 179 | current = NONE; |
| 180 | state = IDLE; |
| 181 | } else { |
| 182 | if ((word.front() == '"' && word.back() == '"') || |
| 183 | (word.front() == '\'' && word.back() == '\'')) { |
| 184 | word = word.substr(1, word.size() - 2); |
| 185 | } |
| 186 | |
| 187 | switch (current) { |
| 188 | case ROOT: |
| 189 | rule.rootSubstrs.push_back(word); |
| 190 | break; |
| 191 | case POINT: |
| 192 | rule.mountPointSubstrs.push_back(word); |
| 193 | break; |
| 194 | case FILESYSTEM: |
| 195 | rule.fsTypes.insert(word); |
| 196 | break; |
| 197 | case SOURCE: |
| 198 | rule.sources.push_back(word); // changed from insert() to push_back() |
| 199 | break; |
| 200 | default: |
| 201 | break; |
| 202 | } |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | return rule; |
| 207 | } |
| 208 | |
| 209 | static std::vector<MountRule> parseMultipleRules(const std::vector<std::string>& ruleTexts) { |
| 210 | std::vector<MountRule> rules; |
nothing calls this directly
no outgoing calls
no test coverage detected