-
- /* expand vars and squash the list of words into the head
- * of the argv word list */
- for (word = top_word; word; word = word->next) {
-
- /* if it's a variable, perform the substitution */
- if (word->type == GRUB2_WORD_VAR) {
- expand_var(script, word);
- word->type = GRUB2_WORD_TEXT;
- }
-
- /* split; this will potentially insert argv
- * entries after top_word. */
- if (word->split)
- process_split(script, top_word, word);
-
- /* accumulate word text into the top word, so
- * we end up with a shallow tree of argv data */
- /* todo: don't do this in process_split */
- if (word != top_word) {
- top_word->text = talloc_asprintf_append(
- top_word->text,
- "%s", word->text);
- }
-
-
- }
- top_word->next = NULL;
+ argv->argv = talloc_realloc(argv, argv->argv, char *,
+ argv->argc);
+ /* because we've parsed a separate word here, we know that
+ * we need at least an empty string */
+ argv->argv[argv->argc - 1] = talloc_strdup(argv->argv, "");
+
+ for (word = top_word; word; word = word->next)
+ append_word_to_argv(script, argv, word);