MCPcopy Create free account
hub / github.com/apache/cloudberry / ParseLongOption

Function ParseLongOption

src/backend/utils/misc/guc.c:11563–11592  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

11561 * there is no '=' in the input string then value will be NULL.
11562 */
11563void
11564ParseLongOption(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/*

Callers 6

process_startup_optionsFunction · 0.85
ProcessGUCArrayFunction · 0.85
PostmasterMainFunction · 0.85
AuxiliaryProcessMainFunction · 0.85

Calls 3

guc_mallocFunction · 0.85
strlcpyFunction · 0.85
guc_strdupFunction · 0.85

Tested by

no test coverage detected