At Charles Bailey's suggestion, this is a revised patch to 
vmstrnenv in vms/vms.c, so that the prefix: 
        <esc><nul><2 byte RMS IFI>
is only removed from:
        SYS$COMMAND, SYS$INPUT, SYS$OUTPUT, SYS$ERROR

I wasn't able to find any obvious flags, etc. that marked these as
"special", so they're inserted 'manually' as a special case. 

--- vms/vms.c-orig      Fri Mar  3 11:01:39 2000
+++ vms/vms.c   Fri Mar 10 09:21:05 2000
@@ -103,7 +104,7 @@
 vmstrnenv(const char *lnm, char *eqv, unsigned long int idx,
   struct dsc$descriptor_s **tabvec, unsigned long int flags)
 {
-    char uplnm[LNM$C_NAMLENGTH], *cp1, *cp2;
+    char uplnm[LNM$C_NAMLENGTH+1], *cp1, *cp2;
     unsigned short int eqvlen, curtab, ivlnm = 0, ivsym = 0, ivenv = 0, secure;
     unsigned long int retsts, attr = LNM$M_CASE_BLIND;
     unsigned char acmode;
@@ -138,6 +139,7 @@
     }
     lnmdsc.dsc$w_length = cp1 - lnm;
     lnmdsc.dsc$a_pointer = uplnm;
+    uplnm[lnmdsc.dsc$w_length] = '\0';
     secure = flags & PERL__TRNENV_SECURE;
     acmode = secure ? PSL$C_EXEC : PSL$C_USER;
     if (!tabvec || !*tabvec) tabvec = env_tables;
@@ -207,6 +209,16 @@
         retsts = sys$trnlnm(&attr,tabvec[curtab],&lnmdsc,&acmode,lnmlst);
         if (retsts == SS$_IVLOGNAM) { ivlnm = 1; continue; }
         if (retsts == SS$_NOLOGNAM) continue;
+        /* PPFs have a prefix */
+        if (strcmp(uplnm,"SYS$COMMAND") == 0 || 
+            strcmp(uplnm,"SYS$INPUT") == 0 ||
+            strcmp(uplnm,"SYS$OUTPUT") == 0 ||
+            strcmp(uplnm,"SYS$ERROR") == 0) {
+            if (eqvlen >= 4 && eqv[0] == 0x1b && eqv[1] == 0x00) {
+                memcpy(eqv,eqv+4,eqvlen-4);
+                eqvlen -= 4;
+            }
+        }
         break;
       }
     }
--
 Drexel University       \V                     --Chuck Lane
----------------->--------*------------<[EMAIL PROTECTED]
     (215) 895-1545      / \  Particle Physics  [EMAIL PROTECTED]
FAX: (215) 895-5934        /~~~~~~~~~~~         [EMAIL PROTECTED]

Reply via email to