225 |
void parse_config_file(char *map, size_t len) |
void parse_config_file(char *map, size_t len) |
226 |
{ |
{ |
227 |
/* modified for bbox */ |
/* modified for bbox */ |
228 |
char *end_4 = map + len - 4; /* 4 == length of "USE_" */ |
char *end_3 = map + len - 3; /* 3 == length of "IF_" */ |
229 |
char *end_7 = map + len - 7; |
char *end_7 = map + len - 7; |
230 |
char *p = map; |
char *p = map; |
231 |
char *q; |
char *q; |
232 |
int off; |
int off; |
233 |
|
|
234 |
for (; p < end_4; p++) { |
for (; p <= end_3; p++) { |
235 |
|
/* Find next identifier's beginning */ |
236 |
|
if (!(isalnum(*p) || *p == '_')) |
237 |
|
continue; |
238 |
|
|
239 |
|
/* Check it */ |
240 |
if (p < end_7 && p[6] == '_') { |
if (p < end_7 && p[6] == '_') { |
241 |
if (!memcmp(p, "CONFIG", 6)) goto conf7; |
if (!memcmp(p, "CONFIG", 6)) goto conf7; |
242 |
if (!memcmp(p, "ENABLE", 6)) goto conf7; |
if (!memcmp(p, "ENABLE", 6)) goto conf7; |
243 |
|
if (!memcmp(p, "IF_NOT", 6)) goto conf7; |
244 |
} |
} |
245 |
/* We have at least 5 chars: for() has |
/* we have at least 3 chars because of p <= end_3 */ |
246 |
* "p < end-4", not "p <= end-4" |
/*if (!memcmp(p, "IF_", 3)) goto conf3;*/ |
247 |
* therefore we don't need to check p <= end-5 here */ |
if (p[0] == 'I' && p[1] == 'F' && p[2] == '_') goto conf3; |
248 |
if (p[4] == '_') |
|
249 |
if (!memcmp(p, "SKIP", 4)) goto conf5; |
/* This identifier is not interesting, skip it */ |
250 |
/* Ehhh, gcc is too stupid to just compare it as 32bit int */ |
while (p <= end_3 && (isalnum(*p) || *p == '_')) |
251 |
if (p[0] == 'U') |
p++; |
|
if (!memcmp(p, "USE_", 4)) goto conf4; |
|
252 |
continue; |
continue; |
253 |
|
|
254 |
conf4: off = 4; |
conf3: off = 3; |
|
conf5: off = 5; |
|
255 |
conf7: off = 7; |
conf7: off = 7; |
256 |
p += off; |
p += off; |
257 |
for (q = p; q < end_4+4; q++) { |
for (q = p; q < end_3+3; q++) { |
258 |
if (!(isalnum(*q) || *q == '_')) |
if (!(isalnum(*q) || *q == '_')) |
259 |
break; |
break; |
260 |
} |
} |