- char *option = optionlist_cpy;
- while (1) { /* breaks in the code */
- if (!option)
- break;
- char *name = option;
- int len = strlen(name);
- XBT_DEBUG("Still to parse and set: '%s'. len=%d; option-name=%ld", name, len, (long) (option - name));
-
- /* Pass the value */
- while (option - name <= (len - 1) && *option != ' ' && *option != '\n' && *option != '\t' && *option != ',') {
- XBT_DEBUG("Take %c.", *option);
- option++;
- }
- if (option - name == len) {
- XBT_DEBUG("Boundary=EOL");
- option = NULL; /* don't do next iteration */
- } else {
- XBT_DEBUG("Boundary on '%c'. len=%d;option-name=%ld", *option, len, (long) (option - name));
- /* Pass the following blank chars */
- *(option++) = '\0';
- while (option - name < (len - 1) && (*option == ' ' || *option == '\n' || *option == '\t')) {
- /* fprintf(stderr,"Ignore a blank char.\n"); */
- option++;
- }
- if (option - name == len - 1)
- option = NULL; /* don't do next iteration */
- }
- XBT_DEBUG("parse now:'%s'; parse later:'%s'", name, option);
-
- if (name[0] == ' ' || name[0] == '\n' || name[0] == '\t')
+ std::string optionlist(options);
+ while (not optionlist.empty()) {
+ XBT_DEBUG("Still to parse and set: '%s'", optionlist.c_str());
+
+ // skip separators
+ size_t pos = optionlist.find_first_not_of(" \t\n,");
+ optionlist.erase(0, pos);
+ // find option
+ pos = optionlist.find_first_of(" \t\n,");
+ std::string name = optionlist.substr(0, pos);
+ optionlist.erase(0, pos);
+ XBT_DEBUG("parse now:'%s'; parse later:'%s'", name.c_str(), optionlist.c_str());
+
+ if (name.empty())