~emersion/mrsh

0804d1d20c62c0368fb1f5fe94ae6e577d8a5dcd — Simon Ser 5 months ago b06b465
ast: print here_document in print_io_redirect
1 files changed, 14 insertions(+), 3 deletions(-)

M ast_print.c
M ast_print.c => ast_print.c +14 -3
@@ 137,6 137,8 @@ static const char *io_redirect_op_str(enum mrsh_io_redirect_op op) {
	assert(false);
}

static void print_word_array(struct mrsh_array *words, const char *prefix);

static void print_io_redirect(struct mrsh_io_redirect *redir,
		const char *prefix) {
	printf("io_redirect\n");


@@ 147,12 149,21 @@ static void print_io_redirect(struct mrsh_io_redirect *redir,
	print_prefix(prefix, false);
	printf("op %s\n", io_redirect_op_str(redir->op));

	char sub_prefix[make_sub_prefix(prefix, true, NULL)];
	make_sub_prefix(prefix, true, sub_prefix);
	bool name_is_last = redir->here_document.len == 0;
	char sub_prefix[make_sub_prefix(prefix, name_is_last, NULL)];
	make_sub_prefix(prefix, name_is_last, sub_prefix);

	print_prefix(prefix, true);
	print_prefix(prefix, name_is_last);
	printf("name ─ ");
	print_word(redir->name, sub_prefix);

	if (redir->here_document.len > 0) {
		make_sub_prefix(prefix, true, sub_prefix);

		print_prefix(prefix, true);
		printf("here_document\n");
		print_word_array(&redir->here_document, sub_prefix);
	}
}

static void print_assignment(struct mrsh_assignment *assign,