MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / SM_ParseConfig

Function SM_ParseConfig

core/CoreConfig.cpp:321–395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

319}
320
321void SM_ParseConfig(FILE *fp, ke::HashMap<std::string, std::string, StringPolicy> &cvars_list)
322{
323 char line[4096];
324 char cvar_name[256];
325
326 while (fgets(line, sizeof(line), fp))
327 {
328 char *ptr = line;
329
330 // Ignore whitespaces and tabs
331 while (*ptr == ' ' || *ptr == '\t')
332 {
333 ptr++;
334 }
335
336 // Ignore empty lines if found
337 if (*ptr == '\0' || *ptr == '\n' || *ptr == '\r')
338 {
339 continue;
340 }
341
342 // Ignore comments
343 if (*ptr == '/' && *(ptr + 1) == '/')
344 {
345 continue;
346 }
347
348 size_t i = 0;
349 while (*ptr != '\0' && *ptr != '\n' && *ptr != '\r' && *ptr != ' ' && *ptr != '\t' && i < (sizeof(cvar_name) - 1))
350 {
351 cvar_name[i++] = *ptr++;
352 }
353
354 cvar_name[i] = '\0';
355
356 if (!i)
357 {
358 continue;
359 }
360
361 auto p = cvars_list.findForAdd(cvar_name);
362 if (p.found())
363 {
364 continue;
365 }
366
367 // Remove spaces and tabs before the value
368 while (*ptr == ' ' || *ptr == '\t')
369 {
370 ptr++;
371 }
372
373 char *value_start = ptr;
374 char *value_end = value_start + strlen(value_start);
375
376 while (value_end > value_start &&
377 (*(value_end - 1) == '\n' ||
378 *(value_end - 1) == '\r' ||

Callers 1

Calls 2

findForAddMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected