www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/07/07/14:13:45

From: "Mark E." <snowball3 AT bigfoot DOT com>
To: djgpp-workers AT delorie DOT com
Date: Sat, 7 Jul 2001 14:13:51 -0400
MIME-Version: 1.0
Subject: Re: dosexec.c changes
Message-ID: <3B47191F.26126.BB7A01@localhost>
In-reply-to: <3791-Sat07Jul2001201003+0300-eliz@is.elta.co.il>
References: <3B46FC1B DOT 14992 DOT 4A1DB3 AT localhost> (snowball3 AT bigfoot DOT com)
X-mailer: Pegasus Mail for Win32 (v3.12c)
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> I think you should call it in the fragment below with second argument
> `rd', not `rp'. 

> >     if (_use_lfn(path) || !rd)
> >     {
> >       i = find_extension(rpath, rp);

I think it's correct as-is. For one, it's what the current version in 
dosexec.c does:
  if (_use_lfn(rpath) || !rd)
  {
    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;

But that by itself isn't a good reason. My understanding of what's happening 
here: The code inside the if block is searching for an extension to append to 
the filename. The two ways to get inside this block are if lfn is supported 
or if the path in rpath doesn't already contain an extension. lfn support is 
an automatic pass because lfn paths may have more than one dot. 'rp' points 
to the end of the path, so this is where an extension must be appended. 'rd' 
points to the extension in rpath (if any). So using it instead of 'rp' means 
that the extension in rpath would be replaced by one ahead of it in the 
search order if that a file with that extension exists.

Plus it's also what the current version in dosexec.c does:
  if (_use_lfn(rpath) || !rd)
  {
    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;
        }
      }
    }
  }

- Raw text -


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