Hi Frank
Attached is a patch for filename.pas to cater for MSYS. Since MSYS is a fork of the Cygwin project, many things that apply to Cygwin apply to MSYS as well.
You can ignore my previous post about front slashes, FileExists, et. al. This patch fixes all those issues. Thanks.
Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.bigfoot.com/~african_chief/
*** ./p/rts/filename.pas.org Thu Jul 10 04:19:36 2003 --- ./p/rts/filename.pas Wed Oct 15 16:46:24 2003 *************** const *** 106,115 ****
{$ifdef __OS_DOS__}
const OSDosFlag = True; QuotingCharacter = #0; ! PathSeparator = {$ifdef __CYGWIN__} ':' {$else} ';' {$endif}; DirSeparator = ''; DirSeparators = [':', '', '/']; ExtSeparator = '.'; --- 106,119 ----
{$ifdef __OS_DOS__}
+ {$if defined (__CYGWIN__) or defined(__MSYS__)} + {$define __POSIX_WIN32__} + {$endif} + const OSDosFlag = True; QuotingCharacter = #0; ! PathSeparator = {$ifdef __POSIX_WIN32__} ':' {$else} ';' {$endif}; DirSeparator = ''; DirSeparators = [':', '', '/']; ExtSeparator = '.'; *************** function Slash2OSDirSeparator (const s: *** 514,520 **** var i: Integer; begin Result := s; ! {$ifndef __CYGWIN__} if DirSeparator <> '/' then for i := 1 to Length (Result) do if Result[i] = '/' then Result[i] := DirSeparator --- 518,524 ---- var i: Integer; begin Result := s; ! {$ifndef __POSIX_WIN32__} if DirSeparator <> '/' then for i := 1 to Length (Result) do if Result[i] = '/' then Result[i] := DirSeparator *************** end; *** 533,539 **** function Slash2OSDirSeparator_CString (s: CString): CString; var Temp: CString; begin ! {$ifndef __CYGWIN__} if DirSeparator <> '/' then begin Temp := s; --- 537,543 ---- function Slash2OSDirSeparator_CString (s: CString): CString; var Temp: CString; begin ! {$ifndef __POSIX_WIN32__} if DirSeparator <> '/' then begin Temp := s; *************** begin *** 1372,1377 **** --- 1376,1385 ---- and ((Length (Path) = 9) or (Path[10] in ['/', ''])) then Result := '/cygdrive' {$endif} + {$ifdef __MSYS__} + else if (Path[1] in ['/', '']) then + Result := Path [1] + {$endif} else if Path[2] = ':' then Result := Copy (Path, 1, 2) else
Prof A Olowofoyeku (The African Chief) wrote:
Attached is a patch for filename.pas to cater for MSYS. Since MSYS is a fork of the Cygwin project, many things that apply to Cygwin apply to MSYS as well.
OK. Have you checked the occurrences of `__CYGWIN__' in string.pas, crt.inc, pipec.c? (The conditionals may be alright as they are for MSYS, but you may want to make sure.)
Frank
On 16 Oct 2003 at 3:35, Frank Heckenbach wrote:
Prof A Olowofoyeku (The African Chief) wrote:
Attached is a patch for filename.pas to cater for MSYS. Since MSYS is a fork of the Cygwin project, many things that apply to Cygwin apply to MSYS as well.
OK. Have you checked the occurrences of `__CYGWIN__' in string.pas,
This line: LineBreak = {$if defined (__OS_DOS__) and not defined (__CYGWIN__)}
should probably be amended to: LineBreak = {$if defined (__OS_DOS__) and not defined (__CYGWIN__) and not defined (__MSYS__)}
MSYS uses the unix line breaks, but understands DOS line breaks too.
crt.inc,
The test for "defined (_WIN32)" will cover MSYS too.
pipec.c?
Ditto here. I am not sure whether "#define fix_argv(argvec) (argvec)" will be needed for MSYS as it is for Cygwin. Is there a way to test whether it will be needed?
Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.bigfoot.com/~african_chief/
Prof A Olowofoyeku (The African Chief) wrote:
pipec.c?
Ditto here. I am not sure whether "#define fix_argv(argvec) (argvec)" will be needed for MSYS as it is for Cygwin.
Well, actually it (i.e., the function in the `#else' part) is needed *except* under Cygwin, so it's #defined as a no-op for Cygwin.
What the function does, according to the comment:
: /* This is a kludge to get around the Microsoft C spawn functions' propensity : to remove the outermost set of double quotes from all arguments. */
I.e., if you spawn a process with an argument of "foo" (including the quotes), the process will only see foo without quotes.
Is there a way to test whether it will be needed?
Compile this to `foo[.exe]':
program Foo;
var i: Integer;
begin for i := 1 to ParamCount do WriteLn (ParamStr (i)) end.
Then run this (might have to write 'foo.exe' in the `PExecute' call):
program Bar;
uses GPC, Pipe;
var Arguments: array [0 .. 2] of CString = ('foo', 'bar', '"bar"'); Status: Integer = 0; ErrMsg: TString = '';
begin PWait (PExecute ('foo', PCStrings (@Arguments), ErrMsg, PExecute_One), Status, 0); WriteLn (Status, ' ', ErrMsg) end.
The output should be:
bar "bar" 0
Frank
On 17 Oct 2003 at 7:36, Frank Heckenbach wrote:
[...]
Compile this to `foo[.exe]':
program Foo;
var i: Integer;
begin for i := 1 to ParamCount do WriteLn (ParamStr (i)) end.
Then run this (might have to write 'foo.exe' in the `PExecute' call):
program Bar;
uses GPC, Pipe;
var Arguments: array [0 .. 2] of CString = ('foo', 'bar', '"bar"'); Status: Integer = 0; ErrMsg: TString = '';
begin PWait (PExecute ('foo', PCStrings (@Arguments), ErrMsg, PExecute_One), Status, 0); WriteLn (Status, ' ', ErrMsg) end.
The output should be:
bar "bar" 0
This is the output that I get:
bar "bar 0
Best regards, The Chief --------- Prof. Abimbola Olowofoyeku (The African Chief) Web: http://www.bigfoot.com/~african_chief/
The output should be:
bar "bar" 0
This is the output that I get:
bar "bar 0
Then try changing the conditional in pipec.c
It is needed for MSYS as well. So we should have this:
#if defined (__CYGWIN__) || defined (__MSYS__)
#define fix_argv(argvec) (argvec)
#else
Exactly, like this. Do you get the correct output then?
Frank
On 18 Oct 2003 at 2:20, Frank Heckenbach wrote:
[...]
It is needed for MSYS as well. So we should have this:
#if defined (__CYGWIN__) || defined (__MSYS__)
#define fix_argv(argvec) (argvec)
#else
Exactly, like this. Do you get the correct output then?
Yes.
Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.bigfoot.com/~african_chief/
On 17 Oct 2003 at 7:36, Frank Heckenbach wrote:
Prof A Olowofoyeku (The African Chief) wrote:
pipec.c?
Ditto here. I am not sure whether "#define fix_argv(argvec) (argvec)" will be needed for MSYS as it is for Cygwin.
Well, actually it (i.e., the function in the `#else' part) is needed *except* under Cygwin, so it's #defined as a no-op for Cygwin.
[...]
It is needed for MSYS as well. So we should have this:
#if defined (__CYGWIN__) || defined (__MSYS__)
#define fix_argv(argvec) (argvec)
#else [....]
Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.bigfoot.com/~african_chief/