summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles.Forsyth <devnull@localhost>2009-04-20 16:43:43 +0000
committerCharles.Forsyth <devnull@localhost>2009-04-20 16:43:43 +0000
commit11c5a36b342b52487be9ec5fda0d5adeec61037f (patch)
tree523c026487ddedcd94f04e729351d750a7f2b56b
parent64047388f80c4b4daa68a5568c2b8a4ad5d63816 (diff)
20090420-1743
-rw-r--r--appl/cmd/m4.b16
-rw-r--r--dis/m4.disbin11974 -> 12295 bytes
-rw-r--r--man/1/m412
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:*" =>
diff --git a/dis/m4.dis b/dis/m4.dis
index 0d9e9606..6911a452 100644
--- a/dis/m4.dis
+++ b/dis/m4.dis
Binary files differ
diff --git a/man/1/m4 b/man/1/m4
index fcfb3e2d..dfab4fb0 100644
--- a/man/1/m4
+++ b/man/1/m4
@@ -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,