Laz 1.2.2/FPC 2.6.4 - Windows 8. Also confirmed under Laz Trunk/FPC Trunk.
Where would I be expected to use StrToCmdLineParam?
I *think* I've found a bug, but I'm doubtful as this seems like a common function, so maybe it's being used incorrectly.
When I run the following
procedure TForm1.Button1Click(Sender: TObject);
Var
s: String;
begin
s := 'C:\Program Files';
ShowMessage(StrToCmdLineParam(s));
end;
I expect to see "C:\Program Files" as the result (" or double quotes are expected on the command line for file/folder names with spaces on them).
Instead I see 'C:\Program Files'
This is causing an issue in the Lazarus-CCR package mplayer. Any filenames with spaces passed to Filename don't get played. I've changed the relevant line in MPLayerCtrl.pas, confirming it's definitely StrToCmdLineParam at fault. I do know spaces in filenames causes problem for the mplayer package under Linux as well, but am not in a position to confirm if it's the single quotes at fault there, or some other issue.
So, either mplayer is incorrectly using StrToCmdLineParam (on at least Windows), or StrToCmdLineParam is returning incorrect values. I can't find any useful documentation on StrToCmdLineParam, so I'm really not sure which issue to report/try to fix, so am looking for advice from you guys :-)
More Information: StrToCmdLineParam is behaving as it's designed to behave (see comments in code below, this is directly from LazFileUtils.pas), so I'm kind of leaning towards it's use in mplayer is incorrect, on the other hand - I can't imagine when StrToCmdLineParam as is would be useful...
function StrToCmdLineParam(const Param: string): string;
{ <empty> -> ''
word -> word
word1 word2 -> 'word1 word2'
word's -> "word's"
a" -> 'a"'
"a" -> '"a"'
'a' -> "'a'"
#0 character -> cut the rest
}
const
NoQuot = ' ';
AnyQuot = '*';
var
Quot: Char;
p: PChar;
i: Integer;
begin
...