* Fixed string conversion warnings in RTL.

git-svn-id: trunk@31752 -
This commit is contained in:
yury 2015-09-17 17:25:57 +00:00
parent b3226f2e63
commit 7c62aadf65
8 changed files with 53 additions and 53 deletions

View File

@ -1877,7 +1877,7 @@ var
s: rawbytestring;
begin
Do_getdir(drivenr,s);
dir:=s;
dir:=unicodestring(s);
end;
{$endif FPCRTL_FILESYSTEM_TWO_BYTE_API}

View File

@ -40,7 +40,7 @@ Function ParamStr(Param: Longint): UnicodeString;
In time, the system unit should get a GetExeName call.
}
if (Param=0) then
Paramstr:=System.Paramstr(0)
Paramstr:=UnicodeString(System.Paramstr(0))
else if (Param>0) and (Param<argc) then
paramstr:=UnicodeString(Argv[Param])
else

View File

@ -1916,7 +1916,7 @@ var
case parser.Token of
toString : s:=s+parser.TokenString;
toWString : begin
ProcessWideString(s);
ProcessWideString(WideString(s));
exit;
end
else parser.CheckToken(toString);

View File

@ -293,7 +293,7 @@ begin
// to ansistring does not give the original ansistring.
// See bug http://bugs.freepascal.org/view.php?id=15841
s:=HandleQuotedString;
fLastTokenWStr:=fLastTokenWStr+s;
fLastTokenWStr:=fLastTokenWStr+UnicodeString(s);
fLastTokenStr:=fLastTokenStr+s;
end;
'#' :
@ -476,7 +476,7 @@ end;
function TParser.TokenString: string;
begin
case fToken of
toWString : Result:=fLastTokenWStr;
toWString : Result:=string(fLastTokenWStr);
toFloat : if fFloatType<>#0 then
Result:=fLastTokenStr+fFloatType
else Result:=fLastTokenStr
@ -490,7 +490,7 @@ begin
if fToken=toWString then
Result:=fLastTokenWStr
else
Result:=fLastTokenStr;
Result:=WideString(fLastTokenStr);
end;
function TParser.TokenSymbolIs(const S: string): Boolean;

View File

@ -1526,12 +1526,12 @@ begin
begin
Result := FDriver.ReadString(StringType);
if (StringType=vaUTF8String) then
Result:=utf8Decode(Result);
Result:=string(utf8Decode(Result));
end
else if StringType in [vaWString] then
Result:= FDriver.ReadWidestring
Result:= string(FDriver.ReadWidestring)
else if StringType in [vaUString] then
Result:= FDriver.ReadUnicodeString
Result:= string(FDriver.ReadUnicodeString)
else
raise EReadError.Create(SInvalidPropertyValue);
end;

View File

@ -294,7 +294,7 @@ class function TEncoding.GetEncoding(const EncodingName: UnicodeString): TEncodi
var
ACodePage: TSystemCodePage;
begin
ACodePage := CodePageNameToCodePage(EncodingName);
ACodePage := CodePageNameToCodePage(AnsiString(EncodingName));
if ACodePage = $FFFF then
raise EEncodingError.CreateFmt(SNotValidCodePageName, [EncodingName]);
Result := TMBCSEncoding.Create(ACodePage);
@ -367,7 +367,7 @@ end;
function TMBCSEncoding.GetEncodingName: UnicodeString;
begin
Result := CodePageToCodePageName(CodePage);
Result := UnicodeString(CodePageToCodePageName(CodePage));
end;
constructor TMBCSEncoding.Create;
@ -500,7 +500,7 @@ end;
function TUnicodeEncoding.GetEncodingName: UnicodeString;
begin
Result := CodePageToCodePageName(CodePage);
Result := UnicodeString(CodePageToCodePageName(CodePage));
end;
constructor TUnicodeEncoding.Create;
@ -578,7 +578,7 @@ end;
function TBigEndianUnicodeEncoding.GetEncodingName: UnicodeString;
begin
Result := CodePageToCodePageName(CodePage);
Result := UnicodeString(CodePageToCodePageName(CodePage));
end;
function TBigEndianUnicodeEncoding.Clone: TEncoding;

View File

@ -44,7 +44,7 @@ Var ChPos,OldPos,ArgPos,DoArg,Len : SizeInt;
While (ChPos<=Len) and
(Fmt[ChPos]<='9') and (Fmt[ChPos]>='0') do inc(ChPos);
If ChPos>len then
DoFormatError(feInvalidFormat,Fmt);
DoFormatError(feInvalidFormat,ansistring(Fmt));
If Fmt[ChPos]='*' then
begin
@ -57,7 +57,7 @@ Var ChPos,OldPos,ArgPos,DoArg,Len : SizeInt;
end;
If (ChPos>OldPos) or (ArgN>High(Args)) then
DoFormatError(feInvalidFormat,Fmt);
DoFormatError(feInvalidFormat,ansistring(Fmt));
ArgPos:=ArgN+1;
@ -66,7 +66,7 @@ Var ChPos,OldPos,ArgPos,DoArg,Len : SizeInt;
vtInt64: Value := Args[ArgN].VInt64^;
vtQWord: Value := Args[ArgN].VQWord^;
else
DoFormatError(feInvalidFormat,Fmt);
DoFormatError(feInvalidFormat,ansistring(Fmt));
end;
Inc(ChPos);
end
@ -76,7 +76,7 @@ Var ChPos,OldPos,ArgPos,DoArg,Len : SizeInt;
begin
Val (Copy(Fmt,OldPos,ChPos-OldPos),value,code);
// This should never happen !!
If Code>0 then DoFormatError (feInvalidFormat,Fmt);
If Code>0 then DoFormatError (feInvalidFormat,ansistring(Fmt));
end
else
Value:=-1;
@ -92,7 +92,7 @@ Var ChPos,OldPos,ArgPos,DoArg,Len : SizeInt;
value:=0; // Delphi undocumented behaviour, assume 0, #11099
If Fmt[ChPos]=':' then
begin
If Value=-1 then DoFormatError(feMissingArgument,fmt);
If Value=-1 then DoFormatError(feMissingArgument,ansistring(Fmt));
Index:=Value;
Value:=-1;
Inc(ChPos);
@ -214,7 +214,7 @@ begin
If (Doarg>High(Args)) or (Args[Doarg].Vtype<>AT) then
begin
if err then
DoFormatError(feInvalidArgindex,Fmt);
DoFormatError(feInvalidArgindex,ansistring(Fmt));
dec(ArgPos);
exit;
end;
@ -250,10 +250,10 @@ begin
Width:=Abs(width);
Index:=Prec-Length(ToAdd);
If ToAdd[1]<>'-' then
ToAdd:=StringOfChar('0',Index)+ToAdd
ToAdd:=TFormatString(StringOfChar('0',Index))+ToAdd
else
// + 1 to accomodate for - sign in length !!
Insert(StringOfChar('0',Index+1),toadd,2);
Insert(TFormatString(StringOfChar('0',Index+1)),toadd,2);
end;
'U' : begin
if Checkarg(vtinteger,false) then
@ -264,38 +264,38 @@ begin
Str(Args[DoArg].VQWord^,toadd);
Width:=Abs(width);
Index:=Prec-Length(ToAdd);
ToAdd:=StringOfChar('0',Index)+ToAdd
ToAdd:=TFormatString(StringOfChar('0',Index))+ToAdd
end;
{$ifndef FPUNONE}
'E' : begin
if CheckArg(vtCurrency,false) then
ToAdd:=FloatToStrF(Args[doarg].VCurrency^,ffexponent,Prec,3,FormatSettings)
ToAdd:=TFormatString(FloatToStrF(Args[doarg].VCurrency^,ffexponent,Prec,3,FormatSettings))
else if CheckArg(vtExtended,true) then
ToAdd:=FloatToStrF(Args[doarg].VExtended^,ffexponent,Prec,3,FormatSettings);
ToAdd:=TFormatString(FloatToStrF(Args[doarg].VExtended^,ffexponent,Prec,3,FormatSettings));
end;
'F' : begin
if CheckArg(vtCurrency,false) then
ToAdd:=FloatToStrF(Args[doarg].VCurrency^,ffFixed,9999,Prec,FormatSettings)
ToAdd:=TFormatString(FloatToStrF(Args[doarg].VCurrency^,ffFixed,9999,Prec,FormatSettings))
else if CheckArg(vtExtended,true) then
ToAdd:=FloatToStrF(Args[doarg].VExtended^,ffFixed,9999,Prec,FormatSettings);
ToAdd:=TFormatString(FloatToStrF(Args[doarg].VExtended^,ffFixed,9999,Prec,FormatSettings));
end;
'G' : begin
if CheckArg(vtCurrency,false) then
ToAdd:=FloatToStrF(Args[doarg].VCurrency^,ffGeneral,Prec,3,FormatSettings)
ToAdd:=TFormatString(FloatToStrF(Args[doarg].VCurrency^,ffGeneral,Prec,3,FormatSettings))
else if CheckArg(vtExtended,true) then
ToAdd:=FloatToStrF(Args[doarg].VExtended^,ffGeneral,Prec,3,FormatSettings);
ToAdd:=TFormatString(FloatToStrF(Args[doarg].VExtended^,ffGeneral,Prec,3,FormatSettings));
end;
'N' : begin
if CheckArg(vtCurrency,false) then
ToAdd:=FloatToStrF(Args[doarg].VCurrency^,ffNumber,9999,Prec,FormatSettings)
ToAdd:=TFormatString(FloatToStrF(Args[doarg].VCurrency^,ffNumber,9999,Prec,FormatSettings))
else if CheckArg(vtExtended,true) then
ToAdd:=FloatToStrF(Args[doarg].VExtended^,ffNumber,9999,Prec,FormatSettings);
ToAdd:=TFormatString(FloatToStrF(Args[doarg].VExtended^,ffNumber,9999,Prec,FormatSettings));
end;
'M' : begin
if CheckArg(vtExtended,false) then
ToAdd:=FloatToStrF(Args[doarg].VExtended^,ffCurrency,9999,Prec,FormatSettings)
ToAdd:=TFormatString(FloatToStrF(Args[doarg].VExtended^,ffCurrency,9999,Prec,FormatSettings))
else if CheckArg(vtCurrency,true) then
ToAdd:=FloatToStrF(Args[doarg].VCurrency^,ffCurrency,9999,Prec,FormatSettings);
ToAdd:=TFormatString(FloatToStrF(Args[doarg].VCurrency^,ffCurrency,9999,Prec,FormatSettings));
end;
{$else}
'E','F','G','N','M':
@ -303,28 +303,28 @@ begin
{$endif}
'S' : begin
if CheckArg(vtString,false) then
hs:=Args[doarg].VString^
hs:=TFormatString(Args[doarg].VString^)
else
if CheckArg(vtChar,false) then
hs:=Args[doarg].VChar
hs:=TFormatString(Args[doarg].VChar)
else
if CheckArg(vtPChar,false) then
hs:=Args[doarg].VPChar
hs:=TFormatString(Args[doarg].VPChar)
else
if CheckArg(vtPWideChar,false) then
hs:=WideString(Args[doarg].VPWideChar)
hs:=TFormatString(WideString(Args[doarg].VPWideChar))
else
if CheckArg(vtWideChar,false) then
hs:=WideString(Args[doarg].VWideChar)
hs:=TFormatString(WideString(Args[doarg].VWideChar))
else
if CheckArg(vtWidestring,false) then
hs:=WideString(Args[doarg].VWideString)
hs:=TFormatString(WideString(Args[doarg].VWideString))
else
if CheckArg(vtAnsiString,false) then
hs:=ansistring(Args[doarg].VAnsiString)
hs:=TFormatString(ansistring(Args[doarg].VAnsiString))
else
if CheckArg(vtUnicodeString,false) then
hs:=UnicodeString(Args[doarg].VUnicodeString)
hs:=TFormatString(UnicodeString(Args[doarg].VUnicodeString))
else
if CheckArg(vtVariant,true) then
hs:=Args[doarg].VVariant^;
@ -335,7 +335,7 @@ begin
end;
'P' : Begin
CheckArg(vtpointer,true);
ToAdd:=HexStr(ptruint(Args[DoArg].VPointer),sizeof(Ptruint)*2);
ToAdd:=TFormatString(HexStr(ptruint(Args[DoArg].VPointer),sizeof(Ptruint)*2));
// Insert ':'. Is this needed in 32 bit ? No it isn't.
// Insert(':',ToAdd,5);
end;
@ -358,7 +358,7 @@ begin
index:=31;
end;
If Prec>index then
ToAdd:=HexStr(int64(vq),index)
ToAdd:=TFormatString(HexStr(int64(vq),index))
else
begin
// determine minimum needed number of hex digits.
@ -367,7 +367,7 @@ begin
inc(Index);
If Index>Prec then
Prec:=Index;
ToAdd:=HexStr(int64(vq),Prec);
ToAdd:=TFormatString(HexStr(int64(vq),Prec));
end;
end;
'%': ToAdd:='%';
@ -375,9 +375,9 @@ begin
If Width<>-1 then
If Length(ToAdd)<Width then
If not Left then
ToAdd:=Space(Width-Length(ToAdd))+ToAdd
ToAdd:=TFormatString(Space(Width-Length(ToAdd)))+ToAdd
else
ToAdd:=ToAdd+space(Width-Length(ToAdd));
ToAdd:=ToAdd+TFormatString(space(Width-Length(ToAdd)));
Result:=Result+ToAdd;
end;
inc(ChPos);

View File

@ -1432,9 +1432,9 @@ begin
Result:='';
case Propinfo^.PropType^.Kind of
tkWString:
Result:=GetWideStrProp(Instance,PropInfo);
Result:=AnsiString(GetWideStrProp(Instance,PropInfo));
tkUString:
Result := GetUnicodeStrProp(Instance,PropInfo);
Result := AnsiString(GetUnicodeStrProp(Instance,PropInfo));
tkSString:
begin
case (PropInfo^.PropProcs) and 3 of
@ -1490,9 +1490,9 @@ var
begin
case Propinfo^.PropType^.Kind of
tkWString:
SetWideStrProp(Instance,PropInfo,Value);
SetWideStrProp(Instance,PropInfo,WideString(Value));
tkUString:
SetUnicodeStrProp(Instance,PropInfo,Value);
SetUnicodeStrProp(Instance,PropInfo,UnicodeString(Value));
tkSString:
begin
case (PropInfo^.PropProcs shr 2) and 3 of
@ -1571,7 +1571,7 @@ begin
Result:='';
case Propinfo^.PropType^.Kind of
tkSString,tkAString:
Result:=GetStrProp(Instance,PropInfo);
Result:=WideString(GetStrProp(Instance,PropInfo));
tkUString :
Result := GetUnicodeStrProp(Instance,PropInfo);
tkWString:
@ -1607,7 +1607,7 @@ var
begin
case Propinfo^.PropType^.Kind of
tkSString,tkAString:
SetStrProp(Instance,PropInfo,Value);
SetStrProp(Instance,PropInfo,AnsiString(Value));
tkUString:
SetUnicodeStrProp(Instance,PropInfo,Value);
tkWString:
@ -1655,7 +1655,7 @@ begin
Result:='';
case Propinfo^.PropType^.Kind of
tkSString,tkAString:
Result:=GetStrProp(Instance,PropInfo);
Result:=UnicodeString(GetStrProp(Instance,PropInfo));
tkWString:
Result:=GetWideStrProp(Instance,PropInfo);
tkUString:
@ -1691,7 +1691,7 @@ var
begin
case Propinfo^.PropType^.Kind of
tkSString,tkAString:
SetStrProp(Instance,PropInfo,Value);
SetStrProp(Instance,PropInfo,AnsiString(Value));
tkWString:
SetWideStrProp(Instance,PropInfo,Value);
tkUString: