mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-23 05:09:43 +00:00
Update r2papi from git, use src from /tmp instead of npm ##r2js (#23082)
* Dont uglify or minify, sed is more reliable * Fix h<tab> help message
This commit is contained in:
parent
14b4068db4
commit
762088e87f
@ -693,60 +693,6 @@ static int cmd_uniq(void *data, const char *input) { // "uniq"
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cmd_head(void *data, const char *_input) { // "head"
|
||||
RCore *core = (RCore *)data;
|
||||
int lines = 5;
|
||||
char *input = strdup (_input);
|
||||
char *arg = strchr (input, ' ');
|
||||
char *tmp, *count;
|
||||
static RCoreHelpMessage help_msg_h = {
|
||||
"head", " [n] [file]", "Print first n lines in file (default n=5)",
|
||||
NULL
|
||||
};
|
||||
if (arg) {
|
||||
arg = (char *)r_str_trim_head_ro (arg + 1); // contains "count filename"
|
||||
count = strchr (arg, ' ');
|
||||
if (count) {
|
||||
*count = 0; // split the count and file name
|
||||
tmp = (char *)r_str_trim_head_ro (count + 1);
|
||||
lines = atoi (arg);
|
||||
arg = tmp;
|
||||
}
|
||||
}
|
||||
switch (*input) {
|
||||
case '?': // "head?"
|
||||
r_core_cmd_help (core, help_msg_h);
|
||||
break;
|
||||
default: // "head"
|
||||
if (!arg) {
|
||||
arg = "";
|
||||
}
|
||||
if (r_fs_check (core->fs, arg)) {
|
||||
r_core_cmdf (core, "md %s", arg);
|
||||
} else {
|
||||
char *res = r_syscmd_head (arg, lines);
|
||||
if (res) {
|
||||
r_cons_print (res);
|
||||
free (res);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
free (input);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cmd_h(void *data, const char *_input) { // "head"
|
||||
if (r_str_startswith (_input, "ead")) {
|
||||
return cmd_head (data, _input);
|
||||
}
|
||||
if (r_str_startswith (_input, "elp")) {
|
||||
r_cons_printf ("%s\n", help_message);
|
||||
return 0;
|
||||
}
|
||||
return -1; // invalid command
|
||||
}
|
||||
|
||||
static int cmd_undo(void *data, const char *input) {
|
||||
RCore *core = (RCore *)data;
|
||||
switch (input[0]) {
|
||||
|
@ -822,7 +822,7 @@ static int cmd_help(void *data, const char *input) {
|
||||
}
|
||||
break;
|
||||
case 'o': // "?o"
|
||||
n = r_num_math (core->num, input+1);
|
||||
n = r_num_math (core->num, input + 1);
|
||||
r_cons_printf ("0%"PFMT64o"\n", n);
|
||||
break;
|
||||
case 'T': // "?T"
|
||||
@ -1055,7 +1055,7 @@ static int cmd_help(void *data, const char *input) {
|
||||
}
|
||||
} else {
|
||||
if (input[1]) { // ?=
|
||||
r_num_math (core->num, input+1);
|
||||
r_num_math (core->num, input + 1);
|
||||
} else {
|
||||
r_cons_printf ("0x%"PFMT64x"\n", core->num->value);
|
||||
}
|
||||
@ -1403,7 +1403,7 @@ static int cmd_help(void *data, const char *input) {
|
||||
}
|
||||
break;
|
||||
case ' ': {
|
||||
const char *msg = r_str_trim_head_ro (input+1);
|
||||
const char *msg = r_str_trim_head_ro (input + 1);
|
||||
// TODO: replace all ${flagname} by its value in hexa
|
||||
char *newmsg = filterFlags (core, msg);
|
||||
r_str_unescape (newmsg);
|
||||
@ -1473,7 +1473,7 @@ static int cmd_help(void *data, const char *input) {
|
||||
}
|
||||
break;
|
||||
case '_': // "?_" hud input
|
||||
r_core_yank_hud_file (core, input+1);
|
||||
r_core_yank_hud_file (core, input + 1);
|
||||
break;
|
||||
case 'i': // "?i" input num
|
||||
r_cons_set_raw(0);
|
||||
@ -1589,4 +1589,61 @@ static int cmd_help(void *data, const char *input) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static RCoreHelpMessage help_msg_h = {
|
||||
"help", "", "Show a friendly message",
|
||||
"head", " [n] [file]", "Print first n lines in file (default n=5)",
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_head(void *data, const char *_input) { // "head"
|
||||
RCore *core = (RCore *)data;
|
||||
int lines = 5;
|
||||
char *input = strdup (_input);
|
||||
char *arg = strchr (input, ' ');
|
||||
char *tmp, *count;
|
||||
if (arg) {
|
||||
arg = (char *)r_str_trim_head_ro (arg + 1); // contains "count filename"
|
||||
count = strchr (arg, ' ');
|
||||
if (count) {
|
||||
*count = 0; // split the count and file name
|
||||
tmp = (char *)r_str_trim_head_ro (count + 1);
|
||||
lines = atoi (arg);
|
||||
arg = tmp;
|
||||
}
|
||||
}
|
||||
switch (*input) {
|
||||
case '?': // "head?"
|
||||
r_core_cmd_help (core, help_msg_h);
|
||||
break;
|
||||
default: // "head"
|
||||
if (!arg) {
|
||||
arg = "";
|
||||
}
|
||||
if (r_fs_check (core->fs, arg)) {
|
||||
r_core_cmdf (core, "md %s", arg);
|
||||
} else {
|
||||
char *res = r_syscmd_head (arg, lines);
|
||||
if (res) {
|
||||
r_cons_print (res);
|
||||
free (res);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
free (input);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cmd_h(void *data, const char *_input) { // "head"
|
||||
if (r_str_startswith (_input, "ead")) {
|
||||
return cmd_head (data, _input);
|
||||
}
|
||||
if (r_str_startswith (_input, "elp")) {
|
||||
r_cons_printf ("%s\n", help_message);
|
||||
return 0;
|
||||
}
|
||||
r_core_cmd_help ((RCore*)data, help_msg_h);
|
||||
return -1; // invalid command
|
||||
}
|
||||
#endif
|
||||
|
@ -1076,6 +1076,7 @@ static const char *radare_argv[] = {
|
||||
"ft?", "ft", "ftn", "fV", "fx", "fq",
|
||||
"fz?", "fz", "fz-", "fz.", "fz:", "fz*",
|
||||
"g?", "g", "gw", "gc", "gl?", "gl", "gs", "gi", "gp", "ge", "gr", "gS",
|
||||
"help",
|
||||
"i?", "i", "ij", "iA", "ia", "ib", "ic", "icc", "iC",
|
||||
"id?", "id", "idp", "idpi", "idpi*", "idpd", "iD", "ie", "iee", "iE", "iE.",
|
||||
"ih", "iHH", "ii", "iI", "ik", "il", "iL", "im", "iM", "io", "iO?", "iO",
|
||||
@ -2790,7 +2791,7 @@ static void __init_autocomplete_default(RCore* core) {
|
||||
};
|
||||
const char *files[] = {
|
||||
".", "..", ".*", "/F", "/m", "!", "!!", "#!c", "#!v", "#!cpipe", "#!qjs", "#!tiny", "#!vala", "v.",
|
||||
"#!rust", "#!zig", "#!pipe", "#!python", "aeli", "arp", "arpg", "dmd", "drp", "drpg", "o", "oe", "ot", "o+", "o++", "on", "open",
|
||||
"#!rust", "#!zig", "#!pipe", "#!python", "aeli", "arp", "arpg", "dmd", "drp", "drpg", "oe", "ot", "o+", "o++", "on", "open",
|
||||
"idp", "idpi", "L", "obf", "o+", "o", "oc", "of", "r2", "rabin2", "rasm2", "rahash2", "rax2", "wff",
|
||||
"rafind2", "cd", "ls", "lua", "on", "wf", "rm", "wF", "wp", "Sd", "Sl", "to", "pm",
|
||||
"/m", "zos", "zfd", "zfs", "zfz", "cat", "wta", "wtf", "wxf", "dml", "dd", "dd+",
|
||||
|
@ -765,6 +765,7 @@ static void register_helpers(JSContext *ctx) {
|
||||
free (custom_papi);
|
||||
} else {
|
||||
eval (ctx, js_r2papi_qjs);
|
||||
// r_file_dump ("rapi.qjs", js_r2papi_qjs, strlen (js_r2papi_qjs), 0);
|
||||
}
|
||||
eval (ctx, "R=G.R=new R2Papi(r2);");
|
||||
eval (ctx, "G.Process = new ProcessClass(r2);");
|
||||
|
@ -1,6 +1,6 @@
|
||||
include deps.mk
|
||||
|
||||
USE_MINIFY=1
|
||||
USE_MINIFY=0
|
||||
USE_UGLIFY=0
|
||||
|
||||
ifeq ($(QJS_BRANCH),frida)
|
||||
@ -64,7 +64,12 @@ R2PAPI_FILES+=shell.js
|
||||
R2PAPI_FILES+=esil.js
|
||||
R2PAPI_FILES_JS=$(addprefix $(NM)/r2papi/,$(R2PAPI_FILES))
|
||||
|
||||
USE_CUSTOM_R2PAPI=1
|
||||
|
||||
js_r2papi.c: node_modules
|
||||
ifeq ($(USE_CUSTOM_R2PAPI),1)
|
||||
cp /tmp/r2papi.r2.js js_r2papi.qjs
|
||||
else
|
||||
# npm i js_r2papi
|
||||
printf "Using r2papi version: "
|
||||
-jq .version node_modules/r2papi/package.json
|
||||
@ -80,11 +85,17 @@ js_r2papi.c: node_modules
|
||||
| grep -v 'r2pipe\.js' \
|
||||
>> js_r2papi.qjs
|
||||
echo 'const r2pipe_js_1 = G;' >> js_r2papi.qjs
|
||||
endif
|
||||
ifeq ($(USE_MINIFY),1)
|
||||
npx minify --help > /dev/null npm i minify
|
||||
npx minify --js < js_r2papi.qjs > js_r2papi.mini.qjs
|
||||
else
|
||||
cp -f js_r2papi.qjs js_r2papi.mini.qjs
|
||||
# TODO remove multiline /* */ comments too
|
||||
cat js_r2papi.qjs | sed \
|
||||
-e 's, *, ,g' \
|
||||
-e 's,\\/\\/.*/,,' \
|
||||
> js_r2papi.mini.qjs
|
||||
endif
|
||||
ifeq ($(USE_UGLIFY),1)
|
||||
npx uglify-js --help > /dev/null || npm i uglify-js
|
||||
|
1002
shlr/qjs/js_r2papi.c
1002
shlr/qjs/js_r2papi.c
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"r2papi": "0.4.7"
|
||||
"r2papi": "0.4.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"minify": "11.2.1",
|
||||
|
@ -47,7 +47,8 @@ RebuildSpp() {
|
||||
}
|
||||
|
||||
RebuildQJS() {
|
||||
rm -f shlr/qjs/js_repl.c
|
||||
# rm -f shlr/qjs/js_repl.c
|
||||
rm -f shlr/qjs/js_r2papi.c
|
||||
make -C shlr/qjs
|
||||
Rebuild libr/lang
|
||||
touch libr/core/cmd.c
|
||||
|
Loading…
Reference in New Issue
Block a user