src/settings.cpp
changeset 6437 37959741e252
parent 6429 3512a65a7cfe
child 6454 ad53226c2027
equal deleted inserted replaced
6436:8b3d676f30bd 6437:37959741e252
   259 				group->comment = (char*)pool_strdup(&ini->pool, comment, comment_size);
   259 				group->comment = (char*)pool_strdup(&ini->pool, comment, comment_size);
   260 				comment_size = 0;
   260 				comment_size = 0;
   261 			}
   261 			}
   262 		} else if (group) {
   262 		} else if (group) {
   263 			/* find end of keyname */
   263 			/* find end of keyname */
   264 			for (t = s; *t != '\0' && *t != '=' && *t != '\t' && *t != ' '; t++);
   264 			if (*s == '\"') {
       
   265 				s++;
       
   266 				for (t = s; *t != '\0' && *t != '\"'; t++);
       
   267 				if (*t == '\"') *t = ' ';
       
   268 			} else {
       
   269 				for (t = s; *t != '\0' && *t != '=' && *t != '\t' && *t != ' '; t++);
       
   270 			}
   265 
   271 
   266 			/* it's an item in an existing group */
   272 			/* it's an item in an existing group */
   267 			item = ini_item_alloc(group, s, t-s);
   273 			item = ini_item_alloc(group, s, t-s);
   268 			if (comment_size) {
   274 			if (comment_size) {
   269 				item->comment = (char*)pool_strdup(&ini->pool, comment, comment_size);
   275 				item->comment = (char*)pool_strdup(&ini->pool, comment, comment_size);
   347 		fprintf(f, "[%s]\n", group->name);
   353 		fprintf(f, "[%s]\n", group->name);
   348 		for (item = group->item; item != NULL; item = item->next) {
   354 		for (item = group->item; item != NULL; item = item->next) {
   349 			assert(item->value != NULL);
   355 			assert(item->value != NULL);
   350 			if (item->comment != NULL) fputs(item->comment, f);
   356 			if (item->comment != NULL) fputs(item->comment, f);
   351 
   357 
       
   358 			/* protect item->name with quotes if needed */
       
   359 			if (strchr(item->name, ' ') != NULL) {
       
   360 				fprintf(f, "\"%s\"", item->name);
       
   361 			} else {
       
   362 				fprintf(f, "%s", item->name);
       
   363 			}
       
   364 
   352 			/* Don't give an equal sign to list items that don't have a parameter */
   365 			/* Don't give an equal sign to list items that don't have a parameter */
   353 			if (group->type == IGT_LIST && *item->value == '\0') {
   366 			if (group->type == IGT_LIST && *item->value == '\0') {
   354 				fprintf(f, "%s\n", item->name);
   367 				fprintf(f, "\n");
   355 			} else {
   368 			} else {
   356 				fprintf(f, "%s = %s\n", item->name, item->value);
   369 				fprintf(f, " = %s\n", item->value);
   357 			}
   370 			}
   358 		}
   371 		}
   359 	}
   372 	}
   360 	if (ini->comment) fputs(ini->comment, f);
   373 	if (ini->comment) fputs(ini->comment, f);
   361 
   374