Updated for 5.003_05.
[p5sagit/p5-mst-13.2.git] / embed.pl
old mode 100644 (file)
new mode 100755 (executable)
index 118b911..5ade24a
--- a/embed.pl
+++ b/embed.pl
@@ -3,10 +3,23 @@
 open(EM, ">embed.h") || die "Can't create embed.h: $!\n";
 
 print EM <<'END';
-/* This file is derived from global.sym and interp.sym */
+/* !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!! 
+   This file is built by embed.pl from global.sym and interp.sym.
+   Any changes made here will be lost 
+*/
 
 /* (Doing namespace management portably in C is really gross.) */
 
+/*  EMBED has no run-time penalty, but helps keep the Perl namespace
+    from colliding with that used by other libraries pulled in
+    by extensions or by embedding perl.  Allow a cc -DNO_EMBED
+    override, however, to keep binary compatability with previous
+    versions of perl.
+*/
+#ifndef NO_EMBED
+#  define EMBED 1 
+#endif
+
 #ifdef EMBED
 
 /* globals we need to hide from the world */
@@ -17,7 +30,8 @@ open(GL, "<global.sym") || die "Can't open global.sym: $!\n";
 while(<GL>) {
        s/[ \t]*#.*//;          # Delete comments.
        next unless /\S/;
-       s/(.*)/#define $1\t\tPerl_$1/;
+       s/^\s*(\S+).*$/#define $1\t\tPerl_$1/;
+       $global{$1} = 1; 
        s/(................\t)\t/$1/;
        print EM $_;
 }
@@ -32,13 +46,27 @@ print EM <<'END';
 
 #ifdef MULTIPLICITY
 
+/* Undefine symbols that were defined by EMBED. Somewhat ugly */
+
 END
 
+
+open(INT, "<interp.sym") || die "Can't open interp.sym: $!\n";
+while (<INT>) {
+       s/[ \t]*#.*//;          # Delete comments.
+       next unless /\S/;
+       s/^\s*(\S*).*$/#undef $1/;
+       print EM $_ if (exists $global{$1});
+}
+close(INT) || warn "Can't close interp.sym: $!\n";
+
+print EM "\n";
+
 open(INT, "<interp.sym") || die "Can't open interp.sym: $!\n";
 while (<INT>) {
        s/[ \t]*#.*//;          # Delete comments.
        next unless /\S/;
-       s/(.*)/#define $1\t\t(curinterp->I$1)/;
+       s/^\s*(\S+).*$/#define $1\t\t(curinterp->I$1)/;
        s/(................\t)\t/$1/;
        print EM $_;
 }
@@ -54,7 +82,7 @@ open(INT, "<interp.sym") || die "Can't open interp.sym: $!\n";
 while (<INT>) {
        s/[ \t]*#.*//;          # Delete comments.
        next unless /\S/;
-       s/(.*)/#define I$1\t\t$1/;
+       s/^\s*(\S+).*$/#define I$1\t\t$1/;
        s/(................\t)\t/$1/;
        print EM $_;
 }