1e6f372
--- perl-5.8.7/perl.c.orig	2005-04-22 17:14:27.000000000 +0300
1e6f372
+++ perl-5.8.7/perl.c	2005-06-17 22:31:31.000000000 +0300
1e6f372
@@ -109,6 +109,7 @@
1e6f372
 #endif
1e6f372
 
1e6f372
 static I32 read_e_script(pTHX_ int idx, SV *buf_sv, int maxlen);
1e6f372
+STATIC void incpush_oldversion(pTHX_ char *dir);
1e6f372
 
1e6f372
 #ifdef IAMSUID
1e6f372
 #ifndef DOSUID
1e6f372
@@ -4435,6 +4436,7 @@
1e6f372
      * DLL-based path intuition to work correctly */
1e6f372
 #  if !defined(WIN32)
1e6f372
     incpush(SITEARCH_EXP, FALSE, FALSE, TRUE);
1e6f372
+    incpush_oldversion(aTHX_ SITEARCH_EXP);
1e6f372
 #  endif
1e6f372
 #endif
1e6f372
 
1e6f372
@@ -4456,6 +4458,7 @@
1e6f372
      * DLL-based path intuition to work correctly */
1e6f372
 #  if !defined(WIN32)
1e6f372
     incpush(PERL_VENDORARCH_EXP, FALSE, FALSE, TRUE);
1e6f372
+    incpush_oldversion(aTHX_ PERL_VENDORARCH_EXP);
1e6f372
 #  endif
1e6f372
 #endif
1e6f372
 
1e6f372
@@ -4497,6 +4500,36 @@
1e6f372
 #  define PERLLIB_MANGLE(s,n) (s)
1e6f372
 #endif
1e6f372
 
1e6f372
+#define VERSION_DIRECTORY_STRING "/5.8.7"
1e6f372
+STATIC void
1e6f372
+incpush_oldversion(pTHX_ char *dir)
1e6f372
+{
1e6f372
+#ifdef PERL_INC_VERSION_LIST
1e6f372
+  const char *incverlist[] = { PERL_INC_VERSION_LIST };
1e6f372
+  const char **incver;
1e6f372
+  const char *verdir;
1e6f372
+
1e6f372
+  verdir = strstr(dir, VERSION_DIRECTORY_STRING);
1e6f372
+  if (!verdir)
1e6f372
+    return;
1e6f372
+
1e6f372
+  for (incver = incverlist; *incver; incver++) {
1e6f372
+    char *new_dir = malloc(strlen(dir) + strlen(*incver) + 2);
1e6f372
+    char *p = new_dir;
1e6f372
+
1e6f372
+    strcpy(new_dir, dir);
1e6f372
+    p += verdir - dir + 1; /* advance to char following '/' in VERSION_DIRECTORY_STRING */
1e6f372
+    memcpy(p, *incver, strlen(*incver)); /* copy incver there instead */
1e6f372
+    p += strlen(*incver);	/* advance past version we just copied */
1e6f372
+    strcpy(p, verdir + strlen(VERSION_DIRECTORY_STRING)); /* and copy the rest of the original dir */
1e6f372
+
1e6f372
+    incpush(new_dir, FALSE, FALSE, FALSE);
1e6f372
+    free(new_dir);
1e6f372
+  }
1e6f372
+#endif
1e6f372
+}
1e6f372
+
1e6f372
+
1e6f372
 /* Push a directory onto @INC if it exists.
1e6f372
    Generate a new SV if we do this, to save needing to copy the SV we push
1e6f372
    onto @INC  */