!!: Fix extra \r on Windows (#2401)
* `!!`: Fix extra `\r` on Windows * Use more efficient algorithm * "Fix" cmd_pipe test * "Fix" shared_memory.py * Move feat_redirect test to archos/not-windows-any
This commit is contained in:
parent
88ec019514
commit
934588cfa5
6 changed files with 30 additions and 18 deletions
|
|
@ -9,9 +9,7 @@ static ut8 *remove_cr(ut8 *str) {
|
|||
char *s = (char *)str;
|
||||
char *start = s;
|
||||
while (*s) {
|
||||
if (s[0] == '\r' &&
|
||||
(s[1] == '\n' ||
|
||||
(s[1] == '\r' && s[2] == '\n' /* TODO remove this */))) {
|
||||
if (s[0] == '\r' && s[1] == '\n') {
|
||||
memmove(s, s + 1, strlen(s + 1) + 1);
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,6 +191,21 @@ static RzCmdStatus system_common_handler(RzCore *core, bool force_rzcons, int ar
|
|||
bool succ = system_exec(core, argc - 1, &argv[1], need_rzcons ? &out : NULL, &length, &ret);
|
||||
rz_cons_sleep_end(bed);
|
||||
if (need_rzcons) {
|
||||
#if __WINDOWS__
|
||||
char *src = out;
|
||||
char *dest = src;
|
||||
char *end = out + length;
|
||||
while (src != end) {
|
||||
*dest = *src;
|
||||
if (src[0] == '\r' && src + 1 != end && src[1] == '\n') {
|
||||
// dest does not move
|
||||
length--;
|
||||
} else {
|
||||
dest++;
|
||||
}
|
||||
src++;
|
||||
}
|
||||
#endif
|
||||
rz_cons_memcat(out, length);
|
||||
}
|
||||
free(out);
|
||||
|
|
|
|||
10
test/db/archos/not-windows-any/feat_redirect
Normal file
10
test/db/archos/not-windows-any/feat_redirect
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
NAME="p8|sed -e s,0,x,g>x;cat x;rm x"
|
||||
FILE=malloc://512
|
||||
CMDS=<<EOF
|
||||
wv 0x100
|
||||
p8 8| sed -e s,1,x,g>x;cat x;rm x
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
000x000000000000
|
||||
EOF
|
||||
RUN
|
||||
|
|
@ -39,7 +39,7 @@ FILE=--
|
|||
CMDS=<<EOF
|
||||
?q `env~?^ASAN_LD_PRELOAD=`
|
||||
?+ env LD_PRELOAD=`env ASAN_LD_PRELOAD`
|
||||
!python3 -c 'import rzpipe;rz=rzpipe.open("--");rz.cmd("Po bins/other/ls.rzdb");print(rz.cmd("?v custom_main"))'
|
||||
!python3 -c 'import rzpipe;rz=rzpipe.open("--");rz.cmd("Po bins/other/ls.rzdb");print(rz.cmd("?v custom_main").replace("\r\n","\n"))'
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
0x4070
|
||||
|
|
|
|||
|
|
@ -13,17 +13,6 @@ EXPECT=<<EOF
|
|||
EOF
|
||||
RUN
|
||||
|
||||
NAME="p8|sed -e s,0,x,g>x;cat x;rm x"
|
||||
FILE=malloc://512
|
||||
CMDS=<<EOF
|
||||
wv 0x100
|
||||
p8 8| sed -e s,1,x,g>x;cat x;rm x
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
000x000000000000
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=append to file
|
||||
FILE==
|
||||
CMDS=<<EOF
|
||||
|
|
|
|||
|
|
@ -24,10 +24,10 @@ for fname in FILENAMES:
|
|||
rzp.cmd("e scr.interactive=false")
|
||||
infoj = rzp.cmdj("ij")
|
||||
print(infoj["bin"])
|
||||
print(rzp.cmd("px 16"))
|
||||
print(rzp.cmd("px 16").replace("\r\n", "\n"))
|
||||
rzp.cmd("aaa")
|
||||
print(rzp.cmd("afl"))
|
||||
print(rzp.cmd("pdf @ entry0"))
|
||||
print(rzp.cmd("afl").replace("\r\n", "\n"))
|
||||
print(rzp.cmd("pdf @ entry0").replace("\r\n", "\n"))
|
||||
rzp.quit()
|
||||
shm.close()
|
||||
shm.unlink()
|
||||
|
|
|
|||
Loading…
Reference in a new issue