char * variable_expand (const char *line) { // fprintf(stderr, "variable expand\n"); // origin return variable_expand_string(NULL, line, (long)-1); /* char* value = variable_expand_string(NULL, line, (long)-1); fprintf(stderr, "value %s\n", value); return value; */ }
static char * variable_append (const char *name, unsigned int length, const struct variable_set_list *set) { const struct variable *v; char *buf = 0; /* If there's nothing left to check, return the empty buffer. */ if (!set) return initialize_variable_output (); /* Try to find the variable in this variable set. */ v = lookup_variable_in_set (name, length, set->set); /* If there isn't one, look to see if there's one in a set above us. */ if (!v) return variable_append (name, length, set->next); /* If this variable type is append, first get any upper values. If not, initialize the buffer. */ if (v->append) buf = variable_append (name, length, set->next); else buf = initialize_variable_output (); /* Append this value to the buffer, and return it. If we already have a value, first add a space. */ if (buf > variable_buffer) buf = variable_buffer_output (buf, " ", 1); #ifdef CONFIG_WITH_VALUE_LENGTH assert (v->value_length == strlen (v->value)); #endif /* Either expand it or copy it, depending. */ if (! v->recursive) #ifdef CONFIG_WITH_VALUE_LENGTH return variable_buffer_output (buf, v->value, v->value_length); #else return variable_buffer_output (buf, v->value, strlen (v->value)); #endif #ifdef CONFIG_WITH_VALUE_LENGTH variable_expand_string_2 (buf, v->value, v->value_length, &buf); return buf; #else buf = variable_expand_string (buf, v->value, strlen (v->value)); return (buf + strlen (buf)); #endif }
char * variable_expand (const char *line) { #ifndef CONFIG_WITH_VALUE_LENGTH return variable_expand_string(NULL, line, (long)-1); #else /* CONFIG_WITH_VALUE_LENGTH */ char *s; /* this function is abused a lot like this: variable_expand(""). */ if (!*line) { s = variable_buffer_output (initialize_variable_output (), "\0", 2); return s - 2; } return variable_expand_string_2 (NULL, line, (long)-1, &s); #endif /* CONFIG_WITH_VALUE_LENGTH */ }
static char * variable_append (const char *name, unsigned int length, const struct variable_set_list *set, int local) { const struct variable *v; char *buf = 0; /* If this set is local and the next is not a parent, then next is local. */ int nextlocal = local && set->next_is_parent == 0; /* If there's nothing left to check, return the empty buffer. */ if (!set) return initialize_variable_output (); /* Try to find the variable in this variable set. */ v = lookup_variable_in_set (name, length, set->set); /* If there isn't one, or this one is private, try the set above us. */ if (!v || (!local && v->private_var)) return variable_append (name, length, set->next, nextlocal); /* If this variable type is append, first get any upper values. If not, initialize the buffer. */ if (v->append) buf = variable_append (name, length, set->next, nextlocal); else buf = initialize_variable_output (); /* Append this value to the buffer, and return it. If we already have a value, first add a space. */ if (buf > variable_buffer) buf = variable_buffer_output (buf, " ", 1); /* Either expand it or copy it, depending. */ if (! v->recursive) return variable_buffer_output (buf, v->value, strlen (v->value)); buf = variable_expand_string (buf, v->value, strlen (v->value)); return (buf + strlen (buf)); }
char * variable_expand (const char *line) { return variable_expand_string(NULL, line, (long)-1); }