Skip to content

Commit

Permalink
Fix XML indent ##cons
Browse files Browse the repository at this point in the history
  • Loading branch information
radare authored and trufae committed Sep 28, 2023
1 parent 913d03b commit 41b8b4c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
9 changes: 8 additions & 1 deletion libr/core/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -4059,7 +4059,7 @@ static int r_core_cmd_subst_i(RCore *core, char *cmd, char *colon, bool *tmpseek
p = strchr (p + 1, ';');
}
}
if (p && *p && p[1] == '>') {
if (R_STR_ISNOTEMPTY (p) && p[0] != '<' && p[1] == '>') {
str = p + 2;
while (*str == '>') {
str++;
Expand Down Expand Up @@ -4278,6 +4278,13 @@ static int r_core_cmd_subst_i(RCore *core, char *cmd, char *colon, bool *tmpseek
/* pipe console to file */
ptr = (char *)r_str_firstbut (cmd, '>', "\"");
// TODO honor `
if (ptr + 2 > cmd) {
// Handle ~<>
char *prev = ptr - 2;
if (r_str_startswith (prev, "~<>")) {
ptr = NULL;
}
}
if (ptr) {
if (ptr > cmd) {
char *ch = ptr - 1;
Expand Down
23 changes: 23 additions & 0 deletions test/db/cmd/cons_grep
Original file line number Diff line number Diff line change
Expand Up @@ -623,3 +623,26 @@ EXPECT=<<EOF
"format": "any"
EOF
RUN

NAME=xml indent
FILE=malloc://128
CMDS=<<EOF
'w <html><body>heh</body><a>bold</a></html>
psz~<>
EOF
EXPECT=<<EOF

<html>

<body>
heh
</body>

<a>
bold
</a>

</html>

EOF
RUN

0 comments on commit 41b8b4c

Please sign in to comment.