| 136 | } |
| 137 | |
| 138 | void LoadConfigFromFile(std::istream &f) |
| 139 | { |
| 140 | std::string curSection; |
| 141 | std::string buffer; |
| 142 | |
| 143 | while(readline(f, buffer)) |
| 144 | { |
| 145 | if(lstrip(buffer).empty()) |
| 146 | continue; |
| 147 | |
| 148 | if(buffer[0] == '[') |
| 149 | { |
| 150 | auto line = const_cast<char*>(buffer.data()); |
| 151 | char *section = line+1; |
| 152 | char *endsection; |
| 153 | |
| 154 | endsection = std::strchr(section, ']'); |
| 155 | if(!endsection || section == endsection) |
| 156 | { |
| 157 | ERR(" config parse error: bad line \"%s\"\n", line); |
| 158 | continue; |
| 159 | } |
| 160 | if(endsection[1] != 0) |
| 161 | { |
| 162 | char *end = endsection+1; |
| 163 | while(std::isspace(*end)) |
| 164 | ++end; |
| 165 | if(*end != 0 && *end != '#') |
| 166 | { |
| 167 | ERR(" config parse error: bad line \"%s\"\n", line); |
| 168 | continue; |
| 169 | } |
| 170 | } |
| 171 | *endsection = 0; |
| 172 | |
| 173 | curSection.clear(); |
| 174 | if(al::strcasecmp(section, "general") != 0) |
| 175 | { |
| 176 | do { |
| 177 | char *nextp = std::strchr(section, '%'); |
| 178 | if(!nextp) |
| 179 | { |
| 180 | curSection += section; |
| 181 | break; |
| 182 | } |
| 183 | |
| 184 | curSection.append(section, nextp); |
| 185 | section = nextp; |
| 186 | |
| 187 | if(((section[1] >= '0' && section[1] <= '9') || |
| 188 | (section[1] >= 'a' && section[1] <= 'f') || |
| 189 | (section[1] >= 'A' && section[1] <= 'F')) && |
| 190 | ((section[2] >= '0' && section[2] <= '9') || |
| 191 | (section[2] >= 'a' && section[2] <= 'f') || |
| 192 | (section[2] >= 'A' && section[2] <= 'F'))) |
| 193 | { |
| 194 | int b{0}; |
| 195 | if(section[1] >= '0' && section[1] <= '9') |
no test coverage detected