Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2002-05

Stupid implementation of execlp

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ondrej Bojar

Hi.

Your implementation of execlp in FPC is really bad.

It searches for the executable in first six directories of $PATH only.

Andrew.

Reply by email

Unknown author
to Ondrej Bojar
Ondrej Bojar wrote 5 lines
Hi. Your implementation of execlp in FPC is really bad. It searches for the executable in first six directories of $PATH only.

With reason: Pascal Strings can only contain 255 chars. Anything outside that range cannot be processed. Since the getenv only returns 255 chars, only that portion of the path is processed.

We can fix this, but that will be for the 1.1 branch of FPC.

Michael.

Reply by email

Samuel Liddicott
to Unknown author

----- Original Message -----
From:
To: "FPC development mailing list"
Sent: Thursday, May 23, 2002 6:00 PM
Subject: Re: [fpc-devel]Stupid implementation of execlp

With reason: Pascal Strings can only contain 255 chars. Anything outside

that

range cannot be processed. Since the getenv only returns 255 chars, only that portion of the path is processed. We can fix this, but that will be for the 1.1 branch of FPC.

Accepting your answer, but for discussions sake; TP7 also had pchar support, I wondered what the reason was for there not being a pchar version of getenv that exelp might use.

Just curious.

Sam

Reply by email

Unknown author
to Samuel Liddicott
Samuel Liddicott wrote 19 lines
----- Original Message ----- From: To: "FPC development mailing list" Sent: Thursday, May 23, 2002 6:00 PM Subject: Re: [fpc-devel]Stupid implementation of execlp > With reason: Pascal Strings can only contain 255 chars. Anything outside that > range cannot be processed. Since the getenv only returns 255 chars, only > that portion of the path is processed. > > We can fix this, but that will be for the 1.1 branch of FPC. Accepting your answer, but for discussions sake; TP7 also had pchar support, I wondered what the reason was for there not being a pchar version of getenv that exelp might use. Just curious.
Sheer laziness:
Procedure Execvp(Path:Pathstr;Args:ppchar;Ep:ppchar);
{
  This does the same as Execve, only it searches the PATH environment
  for the place of the Executable, except when Path starts with a slash.
  if the PATH environment variable is unavailable, the path is set to '.'
}
var
  thepath : string;  // <<<---- max 255 chars...
begin
  if path[1]'/' then
   begin
     Thepath:=strpas(getenv('PATH'));
     if thepath='' then

etc etc etc.

I'll change it so it scans the pchar for parts of the path.

Michael.

Reply by email