Skip to content

Commit 399aea8

Browse files
phix33trufae
authored andcommitted
Register pdc.structured from the pseudo plugin ##pseudo
1 parent db72ba8 commit 399aea8

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

libr/core/cconfig.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4638,7 +4638,6 @@ R_API int r_core_config_init(RCore *core) {
46384638
RConfigNode *cmdpdc = NODECB ("cmd.pdc", "", &cb_cmdpdc);
46394639
SETDESC (cmdpdc, "select pseudo-decompiler command to run after pdc");
46404640
update_cmdpdc_options (core, cmdpdc);
4641-
SETB ("pdc.structured", "false", "emit structured if/else instead of goto in pdc (experimental)");
46424641
SETCB ("cmd.log", "", &cb_cmdlog, "every time a new T log is added run this command");
46434642
SETS ("cmd.prompt", "", "prompt commands");
46444643
SETCB ("cmd.repeat", "false", &cb_cmdrepeat, "empty command an alias for '..' (repeat last command)");

libr/core/p/pseudo/plugin.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,25 @@ static RCmdResult pseudo_callback(RCmdContext *ctx) {
170170

171171
static bool plugin_init(RCorePluginSession *cps) {
172172
RCore *core = cps->core;
173-
RCmd *cmd = core->rcmd;
174-
if (!r_cmd_register (cmd, "pdc", pseudo_callback, NULL)) {
173+
if (!r_cmd_register (core->rcmd, "pdc", pseudo_callback, NULL)) {
175174
return false;
176175
}
176+
RConfig *cfg = core->config;
177+
r_config_lock (cfg, false);
178+
RConfigNode *node = r_config_set_b (cfg, "pdc.structured", false);
179+
r_config_node_desc (node, "emit structured if/else instead of goto in pdc (experimental)");
180+
r_config_lock (cfg, true);
177181
return true;
178182
}
179183

180184
static bool plugin_fini(RCorePluginSession *cps) {
181185
R_RETURN_VAL_IF_FAIL (cps && cps->core && cps->core->rcmd, false);
182-
r_cmd_unregister (cps->core->rcmd, "pdc");
186+
RCore *core = cps->core;
187+
r_cmd_unregister (core->rcmd, "pdc");
188+
// r_core_fini frees the config before it unloads the core plugins
189+
if (core->config) {
190+
r_config_rm (core->config, "pdc.structured");
191+
}
183192
return true;
184193
}
185194

0 commit comments

Comments
 (0)