win32 tweaks
[p5sagit/p5-mst-13.2.git] / embed.pl
index c981b42..a7fb0ed 100755 (executable)
--- a/embed.pl
+++ b/embed.pl
@@ -2,6 +2,25 @@
 
 require 5.003;
 
+# XXX others that may need adding
+#       warnhook
+#       hints
+#       copline
+my @extvars = qw(sv_undef sv_yes sv_no na dowarn
+                 curcop compiling 
+                 tainting tainted stack_base stack_sp sv_arenaroot
+                 curstash DBsub DBsingle debstash
+                 rsfp 
+                 stdingv
+                defgv
+                errgv
+                rsfp_filters
+                perldb
+                diehook
+                dirty
+                perl_destruct_level
+                );
+
 sub readsyms (\%$) {
     my ($syms, $file) = @_;
     %$syms = ();
@@ -28,8 +47,8 @@ sub readvars(\%$$) {
        or die "embed.pl: Can't open $file: $!\n";
     while (<FILE>) {
        s/[ \t]*#.*//;          # Delete comments.
-       if (/PERLVARI?\($pre(\w+)/) {
-           $$syms{$1} = $pre;
+       if (/PERLVARI?C?\($pre(\w+)/) {
+           $$syms{$1} = 1;
        }
     }
     close(FILE);
@@ -40,7 +59,7 @@ my %thread;
 
 readvars %intrp,  'intrpvar.h','I';
 readvars %thread, 'thrdvar.h','T';
-#readvars %global, 'perlvars.h','';
+readvars %globvar, 'perlvars.h','G';
 
 foreach my $sym (sort keys %intrp)
  {
@@ -52,6 +71,15 @@ foreach my $sym (sort keys %intrp)
    }
  }
 
+foreach my $sym (sort keys %globvar)
+ {
+  if (exists $global{$sym})
+   {
+    delete $global{$sym};
+    warn "$sym in global.sym as well as perlvars.h\n";
+   }
+ }
+
 foreach my $sym (keys %interp)
  {
   warn "extra $sym in interp.sym\n" 
@@ -77,13 +105,19 @@ sub embed ($) {
     my ($sym) = @_;
     hide($sym, "Perl_$sym");
 }
+sub embedvar ($) {
+    my ($sym) = @_;
+#   hide($sym, "Perl_$sym");
+    return '';
+}
+
 sub multon ($$$) {
     my ($sym,$pre,$ptr) = @_;
-    hide($sym, "($ptr->$pre$sym)");
+    hide("PL_$sym", "($ptr$pre$sym)");
 }
 sub multoff ($$) {
     my ($sym,$pre) = @_;
-    hide("$pre$sym", $sym);
+    return hide("PL_$pre$sym", "PL_$sym");
 }
 
 unlink 'embed.h';
@@ -156,7 +190,7 @@ print EM <<'END';
 END
 
 for $sym (sort keys %thread) {
-    print EM multon($sym,'T','curinterp');
+    print EM multon($sym,'T','PL_curinterp->');
 }
 
 print EM <<'END';
@@ -168,7 +202,7 @@ print EM <<'END';
 END
 
 for $sym (sort keys %intrp) {
-    print EM multon($sym,'I','curinterp');
+    print EM multon($sym,'I','PL_curinterp->');
 }
 
 print EM <<'END';
@@ -202,7 +236,7 @@ print EM <<'END';
 END
 
 for $sym (sort keys %intrp) {
-    print EM embed($sym);
+    print EM embedvar($sym);
 }
 
 print EM <<'END';
@@ -212,7 +246,7 @@ print EM <<'END';
 END
 
 for $sym (sort keys %thread) {
-    print EM embed($sym);
+    print EM embedvar($sym);
 }
 
 print EM <<'END';
@@ -228,13 +262,62 @@ print EM <<'END';
 END
 
 for $sym (sort keys %thread) {
-    print EM multon($sym,'T','thr');
+    print EM multon($sym,'T','thr->');
 }
 
 print EM <<'END';
 
 #endif /* USE_THREADS */
 
+#ifdef PERL_GLOBAL_STRUCT
+
 END
 
-close(EM);
\ No newline at end of file
+for $sym (sort keys %globvar) {
+    print EM multon($sym,'G','PL_Vars.');
+}
+
+print EM <<'END';
+
+#else /* !PERL_GLOBAL_STRUCT */
+
+END
+
+for $sym (sort keys %globvar) {
+    print EM multoff($sym,'G');
+}
+
+print EM <<'END';
+
+#ifdef EMBED
+
+END
+
+for $sym (sort keys %globvar) {
+    print EM embedvar($sym);
+}
+
+print EM <<'END';
+
+#endif /* EMBED */
+#endif /* PERL_GLOBAL_STRUCT */
+
+END
+
+print EM <<'END';
+
+#ifndef MIN_PERL_DEFINE  
+
+END
+
+for $sym (sort @extvars) {
+    print EM hide($sym,"PL_$sym");
+}
+
+print EM <<'END';
+
+#endif /* MIN_PERL_DEFINE */
+END
+
+
+close(EM);