* A little "long argument" simulation, although not quite GNU * compliant. Takes a string of the form "some-option=some value" and * returns name = "some_option" and value = "some value" in malloc'ed * storage. Note that '-' is converted to '_' in the option name. If * there is no '=' in the input string then value will be NULL. */
| 11561 | * there is no '=' in the input string then value will be NULL. |
| 11562 | */ |
| 11563 | void |
| 11564 | ParseLongOption(const char *string, char **name, char **value) |
| 11565 | { |
| 11566 | size_t equal_pos; |
| 11567 | char *cp; |
| 11568 | |
| 11569 | AssertArg(string); |
| 11570 | AssertArg(name); |
| 11571 | AssertArg(value); |
| 11572 | |
| 11573 | equal_pos = strcspn(string, "="); |
| 11574 | |
| 11575 | if (string[equal_pos] == '=') |
| 11576 | { |
| 11577 | *name = guc_malloc(FATAL, equal_pos + 1); |
| 11578 | strlcpy(*name, string, equal_pos + 1); |
| 11579 | |
| 11580 | *value = guc_strdup(FATAL, &string[equal_pos + 1]); |
| 11581 | } |
| 11582 | else |
| 11583 | { |
| 11584 | /* no equal sign in string */ |
| 11585 | *name = guc_strdup(FATAL, string); |
| 11586 | *value = NULL; |
| 11587 | } |
| 11588 | |
| 11589 | for (cp = *name; *cp; cp++) |
| 11590 | if (*cp == '-') |
| 11591 | *cp = '_'; |
| 11592 | } |
| 11593 | |
| 11594 | |
| 11595 | /* |
no test coverage detected