|
@@ -105,18 +105,16 @@ static char *context_retrieve(const context_t * this, const char *name)
|
|
|
|
|
|
if (this && this->pargv) {
|
|
|
const clish_parg_t *parg =
|
|
|
- clish_pargv_find_arg(this->pargv, name);
|
|
|
- if (NULL != parg) {
|
|
|
-
|
|
|
+ clish_pargv_find_arg(this->pargv, name);
|
|
|
+
|
|
|
+ if (parg)
|
|
|
tmp = clish_parg__get_value(parg);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
if (NULL == tmp) {
|
|
|
|
|
|
- if (this && this->viewid) {
|
|
|
+ if (this && this->viewid)
|
|
|
tmp = string = find_viewid_var(this->viewid, name);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
if (NULL == tmp) {
|
|
@@ -133,7 +131,7 @@ static char *context_retrieve(const context_t * this, const char *name)
|
|
|
escape_chars = clish_command__get_escape_chars(this->cmd);
|
|
|
}
|
|
|
result = lub_string_encode(tmp, escape_chars);
|
|
|
- if (NULL != string) {
|
|
|
+ if (string) {
|
|
|
|
|
|
lub_string_free(string);
|
|
|
}
|
|
@@ -158,7 +156,7 @@ static char *context_nextsegment(const context_t * this, const char **string)
|
|
|
p += 2;
|
|
|
tmp = p;
|
|
|
|
|
|
-
|
|
|
+
|
|
|
* find the end of the variable
|
|
|
*/
|
|
|
while (*p && p++[0] != '}') {
|
|
@@ -180,16 +178,15 @@ static char *context_nextsegment(const context_t * this, const char **string)
|
|
|
* of the words is an expandable variable
|
|
|
*/
|
|
|
for (q = strtok_r(text, ":", &saveptr);
|
|
|
- q; q = strtok_r(NULL, ":", &saveptr)) {
|
|
|
+ q; q = strtok_r(NULL, ":", &saveptr)) {
|
|
|
char *var = context_retrieve(this, q);
|
|
|
|
|
|
|
|
|
lub_string_cat(&result, var ? var : q);
|
|
|
|
|
|
|
|
|
- if (NULL != var) {
|
|
|
+ if (var)
|
|
|
valid = BOOL_TRUE;
|
|
|
- }
|
|
|
lub_string_free(var);
|
|
|
}
|
|
|
|
|
@@ -205,15 +202,13 @@ static char *context_nextsegment(const context_t * this, const char **string)
|
|
|
} else {
|
|
|
|
|
|
while (*p) {
|
|
|
- if ((p[0] == '$') && (p[1] == '{')) {
|
|
|
+ if ((p[0] == '$') && (p[1] == '{'))
|
|
|
break;
|
|
|
- }
|
|
|
len++;
|
|
|
p++;
|
|
|
}
|
|
|
- if (len > 0) {
|
|
|
+ if (len > 0)
|
|
|
result = lub_string_dupn(*string, len);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
*string = p;
|
|
@@ -227,9 +222,8 @@ static char *context_nextsegment(const context_t * this, const char **string)
|
|
|
* subtituting each occurance of a "${FRED}" type variable sub-string
|
|
|
* with the appropriate value.
|
|
|
*/
|
|
|
-char *clish_variable_expand(const char *string,
|
|
|
- const char *viewid,
|
|
|
- const clish_command_t * cmd, clish_pargv_t * pargv)
|
|
|
+char *clish_variable_expand(const char *string, const char *viewid,
|
|
|
+ const clish_command_t * cmd, clish_pargv_t * pargv)
|
|
|
{
|
|
|
char *seg, *result = NULL;
|
|
|
context_t context;
|