mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 21:39:18 +02:00
+ paramstr(longint):unicode string function in uuchar
* optimised objpas.paramstr (let the compiler convert the pchar to ansistring instead of using an unoptimised loop) git-svn-id: branches/cpstrrtl@24958 -
This commit is contained in:
parent
5a72bc3656
commit
112fafc6fd
@ -21,7 +21,31 @@ interface
|
|||||||
char = widechar;
|
char = widechar;
|
||||||
pchar = pwidechar;
|
pchar = pwidechar;
|
||||||
|
|
||||||
|
|
||||||
|
{$ifdef FPC_HAS_FEATURE_COMMANDARGS}
|
||||||
|
Function ParamStr(Param: Longint): UnicodeString;
|
||||||
|
{$endif FPC_HAS_FEATURE_COMMANDARGS}
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
{$ifdef FPC_HAS_FEATURE_COMMANDARGS}
|
||||||
|
Function ParamStr(Param: Longint): UnicodeString;
|
||||||
|
begin
|
||||||
|
{
|
||||||
|
Paramstr(0) should return the name of the binary.
|
||||||
|
Since this functionality is included in the system unit,
|
||||||
|
we fetch it from there.
|
||||||
|
Normally, pathnames are less than 255 chars anyway,
|
||||||
|
so this will work correct in 99% of all cases.
|
||||||
|
In time, the system unit should get a GetExeName call.
|
||||||
|
}
|
||||||
|
if (Param=0) then
|
||||||
|
Paramstr:=System.Paramstr(0)
|
||||||
|
else if (Param>0) and (Param<argc) then
|
||||||
|
paramstr:=UnicodeString(Argv[Param])
|
||||||
|
else
|
||||||
|
paramstr:='';
|
||||||
|
end;
|
||||||
|
{$endif FPC_HAS_FEATURE_COMMANDARGS}
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -214,33 +214,23 @@ end;
|
|||||||
{$endif FPC_HAS_FEATURE_FILEIO}
|
{$endif FPC_HAS_FEATURE_FILEIO}
|
||||||
|
|
||||||
{$ifdef FPC_HAS_FEATURE_COMMANDARGS}
|
{$ifdef FPC_HAS_FEATURE_COMMANDARGS}
|
||||||
Function ParamStr(Param : Integer) : Ansistring;
|
Function ParamStr(Param : Integer) : ansistring;
|
||||||
|
begin
|
||||||
Var Len : longint;
|
{
|
||||||
|
Paramstr(0) should return the name of the binary.
|
||||||
begin
|
Since this functionality is included in the system unit,
|
||||||
{
|
we fetch it from there.
|
||||||
Paramstr(0) should return the name of the binary.
|
Normally, pathnames are less than 255 chars anyway,
|
||||||
Since this functionality is included in the system unit,
|
so this will work correct in 99% of all cases.
|
||||||
we fetch it from there.
|
In time, the system unit should get a GetExeName call.
|
||||||
Normally, pathnames are less than 255 chars anyway,
|
}
|
||||||
so this will work correct in 99% of all cases.
|
if (Param=0) then
|
||||||
In time, the system unit should get a GetExeName call.
|
Result:=System.Paramstr(0)
|
||||||
}
|
else if (Param>0) and (Param<argc) then
|
||||||
if (Param=0) then
|
Result:=Argv[Param]
|
||||||
Result:=System.Paramstr(0)
|
else
|
||||||
else if (Param>0) and (Param<argc) then
|
Result:='';
|
||||||
begin
|
end;
|
||||||
Len:=0;
|
|
||||||
While Argv[Param][Len]<>#0 do
|
|
||||||
Inc(len);
|
|
||||||
SetLength(Result,Len);
|
|
||||||
If Len>0 then
|
|
||||||
Move(Argv[Param][0],Result[1],Len);
|
|
||||||
end
|
|
||||||
else
|
|
||||||
paramstr:='';
|
|
||||||
end;
|
|
||||||
{$endif FPC_HAS_FEATURE_COMMANDARGS}
|
{$endif FPC_HAS_FEATURE_COMMANDARGS}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user