summaryrefslogtreecommitdiff
path: root/metapost
diff options
context:
space:
mode:
Diffstat (limited to 'metapost')
-rw-r--r--metapost/context/base/mp-grph.mp24
1 files changed, 20 insertions, 4 deletions
diff --git a/metapost/context/base/mp-grph.mp b/metapost/context/base/mp-grph.mp
index 3cd9f2cfb..48776a09f 100644
--- a/metapost/context/base/mp-grph.mp
+++ b/metapost/context/base/mp-grph.mp
@@ -22,13 +22,29 @@ string CRLF ; CRLF := char 10 & char 13 ;
picture _currentpicture_ ;
+numeric _fig_nesting_ ; _fig_nesting_ := 0 ;
+
def beginfig (expr c) =
- begingroup
- charcode := c ;
- resetfig ;
- scantokens extra_beginfig ;
+ _fig_nesting_ := _fig_nesting_ + 1 ;
+ if _fig_nesting_ = 1 :
+ begingroup
+ charcode := c ;
+ resetfig ;
+ scantokens extra_beginfig ;
+ fi ;
enddef ;
+def endfig =
+ ; % safeguard
+ if _fig_nesting_ = 1 :
+ scantokens extra_endfig;
+ shipit ;
+ endgroup ;
+ fi ;
+ _fig_nesting_ := _fig_nesting_ - 1 ;
+enddef;
+
+
def resetfig =
clearxy ;
clearit ;