src/settings.cpp
changeset 10699 c8718b56d984
parent 10695 95e0154da7a0
child 10703 2c998f3776d1
equal deleted inserted replaced
10698:2d3b87995c39 10699:c8718b56d984
   329 	IniGroup *group;
   329 	IniGroup *group;
   330 
   330 
   331 	if (len == 0) len = strlen(name);
   331 	if (len == 0) len = strlen(name);
   332 
   332 
   333 	/* does it exist already? */
   333 	/* does it exist already? */
   334 	for (group = ini->group; group; group = group->next)
   334 	for (group = ini->group; group != NULL; group = group->next) {
   335 		if (!memcmp(group->name, name, len) && group->name[len] == 0)
   335 		if (!memcmp(group->name, name, len) && group->name[len] == 0) {
   336 			return group;
   336 			return group;
       
   337 		}
       
   338 	}
   337 
   339 
   338 	/* otherwise make a new one */
   340 	/* otherwise make a new one */
   339 	group = ini_group_alloc(ini, name, len);
   341 	group = ini_group_alloc(ini, name, len);
   340 	group->comment = (char*)pool_strdup(&ini->pool, "\n", 1);
   342 	group->comment = (char*)pool_strdup(&ini->pool, "\n", 1);
   341 	return group;
   343 	return group;
   345 static IniItem *ini_getitem(IniGroup *group, const char *name, bool create)
   347 static IniItem *ini_getitem(IniGroup *group, const char *name, bool create)
   346 {
   348 {
   347 	IniItem *item;
   349 	IniItem *item;
   348 	size_t len = strlen(name);
   350 	size_t len = strlen(name);
   349 
   351 
   350 	for (item = group->item; item; item = item->next)
   352 	for (item = group->item; item != NULL; item = item->next) {
   351 		if (strcmp(item->name, name) == 0) return item;
   353 		if (strcmp(item->name, name) == 0) return item;
       
   354 	}
   352 
   355 
   353 	if (!create) return NULL;
   356 	if (!create) return NULL;
   354 
   357 
   355 	/* otherwise make a new one */
   358 	/* otherwise make a new one */
   356 	return ini_item_alloc(group, name, len);
   359 	return ini_item_alloc(group, name, len);