Feature #269 ยป 0029-fc_cmdline.c-Replace-NULLs-with-nullptrs.patch
utility/fc_cmdline.c | ||
---|---|---|
#include "fc_cmdline.h"
|
||
/* get 'struct cmdline_value_list' and related functions: */
|
||
/* Get 'struct cmdline_value_list' and related functions: */
|
||
#define SPECLIST_TAG cmdline_value
|
||
#define SPECLIST_TYPE char
|
||
#include "speclist.h"
|
||
... | ... | |
TYPED_LIST_ITERATE(char *, vallist, pvalue)
|
||
#define cmdline_value_list_iterate_end LIST_ITERATE_END
|
||
static struct cmdline_value_list *cmdline_values = NULL;
|
||
static struct cmdline_value_list *cmdline_values = nullptr;
|
||
/**********************************************************************//**
|
||
Return a char* to the parameter of the option or NULL.
|
||
Return a char* to the parameter of the option or nullptr.
|
||
*i can be increased to get next string in the array argv[].
|
||
It is an error for the option to exist but be an empty string.
|
||
This doesn't use log_*() because it is used before logging is set up.
|
||
... | ... | |
{
|
||
int len = strlen(option_name);
|
||
if (gc && cmdline_values == NULL) {
|
||
if (gc && cmdline_values == nullptr) {
|
||
cmdline_values = cmdline_value_list_new();
|
||
}
|
||
... | ... | |
return ret;
|
||
}
|
||
return NULL;
|
||
return nullptr;
|
||
}
|
||
/**********************************************************************//**
|
||
... | ... | |
**************************************************************************/
|
||
void cmdline_option_values_free(void)
|
||
{
|
||
if (cmdline_values != NULL) {
|
||
if (cmdline_values != nullptr) {
|
||
cmdline_value_list_iterate(cmdline_values, pval) {
|
||
free(pval);
|
||
} cmdline_value_list_iterate_end;
|
||
... | ... | |
{
|
||
unsigned int token;
|
||
fc_assert_ret_val(NULL != str, -1);
|
||
fc_assert_ret_val(str != nullptr, -1);
|
||
for (token = 0; token < num_tokens && *str != '\0'; token++) {
|
||
size_t len, padlength = 0;
|
||
/* skip leading delimiters */
|
||
/* Skip leading delimiters */
|
||
str += strspn(str, delimiterset);
|
||
len = fc_strcspn(str, delimiterset);
|
||
/* strip start/end quotes if they exist */
|
||
/* Strip start/end quotes if they exist */
|
||
if (len >= 2) {
|
||
if ((str[0] == '"' && str[len - 1] == '"')
|
||
|| (str[0] == '\'' && str[len - 1] == '\'')) {
|
||
len -= 2;
|
||
padlength = 1; /* to set the string past the end quote */
|
||
padlength = 1; /* To set the string past the end quote */
|
||
str++;
|
||
}
|
||
}
|
||
tokens[token] = fc_malloc(len + 1);
|
||
(void) fc_strlcpy(tokens[token], str, len + 1); /* adds the '\0' */
|
||
(void) fc_strlcpy(tokens[token], str, len + 1); /* Adds the '\0' */
|
||
str += len + padlength;
|
||
}
|
utility/fc_cmdline.h | ||
---|---|---|
}
|
||
#endif /* __cplusplus */
|
||
#endif /* FC__CMDLINE_H */
|
||
#endif /* FC__CMDLINE_H */
|