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