Version: e21daea
Steps to reproduce:
- Add
:def argtest math,"arg:ins",rtn to joerc and then add either math,"arg:ins",rtn <KEY> or argtest <KEY>. Replace <KEY> with some key, of course
- Use the "arg" command and then try either one. Observe that the first one correctly prints the argument it was called with, while the second always prints "0". This issue also affects a default
indentregion and cutc in jmacsrc
Analysis:
macro.c exmacro:
/* Take argument */
/* ANALYSIS: arg is reset to 0 */
if (argset) {
larg = arg;
arg = 0;
argset = 0;
} else {
larg = 1;
}
/* Just a simple command? */
if (!m->steps) {
/* ANALYSIS: this will be called since defined macros are wrapped in a CMD */
return exsimple(m, larg, u, k);
}
macro.c exsimple:
/* ANALYSIS: execute the CMD */
ret = execmd(cmd, m->k != NO_MORE_DATA ? m->k : k);
cmd.c execmd:
if (cmd->m)
/* ANALYSIS: call back to exmacro to execute the real macro, remember arg will always be 0 now! */
return exmacro(cmd->m, 0, k);
Proposed fix:
--- a/joe/macro.c
+++ b/joe/macro.c
@@ -395,6 +395,11 @@
int o_arg_set = argset;
int o_arg = arg;
+ /* If it's actually a defined macro, execute it and don't overwrite arg */
+
+ if (!m->steps && m->cmd->m)
+ return exmacro(m->cmd->m, 0, k);
+
/* Take argument */
if (argset) {
This checks if it's a defined macro, and executes it right away without overwriting arg. This seems to fix the issue and makes the 2 test cases act identically as they should.
Version: e21daea
Steps to reproduce:
:def argtest math,"arg:ins",rtnto joerc and then add eithermath,"arg:ins",rtn <KEY>orargtest <KEY>. Replace<KEY>with some key, of courseindentregionandcutcin jmacsrcAnalysis:
macro.c
exmacro:macro.c
exsimple:cmd.c
execmd:Proposed fix:
This checks if it's a defined macro, and executes it right away without overwriting
arg. This seems to fix the issue and makes the 2 test cases act identically as they should.