delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/05/31/12:55:05

From: "Mark E." <snowball3 AT bigfoot DOT com>
To: djgpp-workers AT delorie DOT com
Date: Wed, 31 May 2000 12:55:17 -0400
MIME-Version: 1.0
Subject: Re: __dosexec_find_on_path question
Message-ID: <39350BB5.12671.1E8A2E@localhost>
References: <39345E39 DOT 31070 DOT 44E4CF AT localhost>
In-reply-to: <Pine.SUN.3.91.1000531095944.8817M@is>
X-mailer: Pegasus Mail for Win32 (v3.12c)
Reply-To: djgpp-workers AT delorie DOT com

> Other than that, I have no objections.

Below is the revised patch. I left __dosexec_find_on_path alone, since it's not meant 
to be used outside of libc (that's my understanding anyway) and changing it isn't 
required to fix spawn*.

Index: djgpp/src/libc/dos/process/dosexec.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/dos/process/dosexec.c,v
retrieving revision 1.5
diff -c -3 -p -r1.5 dosexec.c
*** dosexec.c	1999/06/03 17:27:36	1.5
--- dosexec.c	2000/05/31 16:49:03
*************** static int script_exec(const char *progr
*** 893,912 ****
     possible extension of an executable file.  It only mentions
     those extensions that can be *omitted* when you invoke the
     executable from one of the shells used on MSDOS.  */
  static struct {
    const char *extension;
    int (*interp)(const char *, char **, char **);
  } interpreters[] = {
!   { ".com", direct_exec },
!   { ".exe", go32_exec },
!   { ".bat", __dosexec_command_exec },
!   { ".btm", __dosexec_command_exec },
!   { ".sh",  script_exec },  /* for compatibility with ms_sh */
!   { ".ksh", script_exec },
!   { ".pl", script_exec },   /* Perl */
!   { ".sed", script_exec },
!   { "",     go32_exec },
!   { 0,      script_exec },  /* every extension not mentioned above calls it */
    { 0,      0 },
  };
  
--- 893,916 ----
     possible extension of an executable file.  It only mentions
     those extensions that can be *omitted* when you invoke the
     executable from one of the shells used on MSDOS.  */
+ 
+ #define INTERP_FLAG_SKIP_SEARCH 1
+ 
  static struct {
    const char *extension;
    int (*interp)(const char *, char **, char **);
+   unsigned char flags;
  } interpreters[] = {
!   { ".com", direct_exec, 0 },
!   { ".exe", go32_exec, 0 },
!   { ".bat", __dosexec_command_exec, 0 },
!   { ".btm", __dosexec_command_exec, 0 },
!   { ".sh",  script_exec, INTERP_FLAG_SKIP_SEARCH },  /* Bash */
!   { ".ksh", script_exec, INTERP_FLAG_SKIP_SEARCH },
!   { ".pl", script_exec, INTERP_FLAG_SKIP_SEARCH },   /* Perl */
!   { ".sed", script_exec, INTERP_FLAG_SKIP_SEARCH }, /* Sed */
!   { "",     go32_exec, 0 },
!   { 0,      script_exec, 0 },  /* every extension not mentioned above calls it */
    { 0,      0 },
  };
  
*************** int __spawnve(int mode, const char *path
*** 1061,1075 ****
    {
      for (i=0; interpreters[i].extension; i++)
      {
!       strcpy(rp, interpreters[i].extension);
!       if (access(rpath, F_OK) == 0 && !(is_dir = (access(rpath, D_OK) == 0)))
        {
! 	found = 1;
! 	break;
        }
      }
    }
! 
    if (!found)
    {
      const char *rpath_ext;
--- 1065,1083 ----
    {
      for (i=0; interpreters[i].extension; i++)
      {
!       if ((interpreters[i].flags & INTERP_FLAG_SKIP_SEARCH) == 0)
        {
!         strcpy(rp, interpreters[i].extension);
!         if (access(rpath, F_OK) == 0 && !(is_dir = (access(rpath, D_OK) == 0)))
!         {
! 	  found = 1;
! 	  break;
!         }
        }
      }
    }
!   *rp = 0;
!   
    if (!found)
    {
      const char *rpath_ext;




- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019