diff options
| -rw-r--r-- | appl/cmd/m4.b | 16 | ||||
| -rw-r--r-- | dis/m4.dis | bin | 11974 -> 12295 bytes | |||
| -rw-r--r-- | man/1/m4 | 12 |
3 files changed, 27 insertions, 1 deletions
diff --git a/appl/cmd/m4.b b/appl/cmd/m4.b index 9315bf55..f24427b6 100644 --- a/appl/cmd/m4.b +++ b/appl/cmd/m4.b @@ -65,6 +65,7 @@ init(nil: ref Draw->Context, args: list of string) builtin("changecom", dochangecom); builtin("changequote", dochangequote); + builtin("copydef", docopydef); builtin("define", dodefine); builtin("divert", dodivert); builtin("divnum", dodivnum); @@ -457,6 +458,20 @@ doundefine(args: array of string) undefine(args[i]); } +docopydef(args: array of string) +{ + if(len args > 2 && args[1] != args[2]){ + undefine(args[2]); + if((n := lookup(args[1])) != nil){ + if(n.impl == nil) + define(args[2], n.repl); + else + builtin(args[2], n.impl); + }else + define(args[2], ""); + } +} + doeval(args: array of string) { if(len args > 1) @@ -683,6 +698,7 @@ dosyscmd(args: array of string) if(sh == nil) raise sys->sprint("load: can't load %s: %r", Sh->PATH); } + bout.flush(); sh->system(nil, args[1]); }exception e{ "load:*" => Binary files differ@@ -77,9 +77,19 @@ Change quote characters to the first and second arguments. without arguments restores the original values of .BR `\|' . .TP +copydef +The second argument is installed with the value of the macro +named by the first argument, +which may be a built-in macro. +Typically both arguments are quoted to prevent too early expansion. +A macro can be renamed using +.B copydef +followed by +.BR undefine . +.TP define The second argument is installed as the value of the macro -whose name is the first argument. +named by the first argument. When the macro is later called (expanded), each occurrence in the replacement text of .BI $ n, |
