rtl: reduce amount of warnings regards implicit string conversions + little formatting

git-svn-id: trunk@20925 -
This commit is contained in:
paul 2012-04-19 01:33:47 +00:00
parent 901eb84b3d
commit 19d1cf9470
4 changed files with 90 additions and 96 deletions

View File

@ -376,7 +376,7 @@ begin
end end
else else
begin begin
temp:=S; temp:=UnicodeString(S);
Size:=Length(temp); Size:=Length(temp);
widestringmanager.Unicode2AnsiMoveProc(PUnicodeChar(Pointer(temp)),result,cp,Size); widestringmanager.Unicode2AnsiMoveProc(PUnicodeChar(Pointer(temp)),result,cp,Size);
end; end;

View File

@ -1325,8 +1325,8 @@ var
sign : valreal; sign : valreal;
esign, esign,
exponent, exponent,
decpoint,i : SizeInt; decpoint : SizeInt;
flags : byte; flags : byte;
begin begin
fpc_Val_Real_ShortStr:=0.0; fpc_Val_Real_ShortStr:=0.0;
code:=1; code:=1;

View File

@ -941,13 +941,13 @@ procedure UnicodeCharLenToStrVar(Src : PUnicodeChar;Len : SizeInt;out Dest : Uni
procedure UnicodeCharLenToStrVar(Src : PUnicodeChar;Len : SizeInt;out Dest : AnsiString); procedure UnicodeCharLenToStrVar(Src : PUnicodeChar;Len : SizeInt;out Dest : AnsiString);
begin begin
Dest:=UnicodeCharLenToString(Src,Len); Dest:=AnsiString(UnicodeCharLenToString(Src,Len));
end; end;
procedure UnicodeCharToStrVar(S : PUnicodeChar;out Dest : AnsiString); procedure UnicodeCharToStrVar(S : PUnicodeChar;out Dest : AnsiString);
begin begin
Dest:=UnicodeCharToString(S); Dest:=AnsiString(UnicodeCharToString(S));
end; end;
@ -966,7 +966,7 @@ procedure WideCharLenToStrVar(Src : PWideChar;Len : SizeInt;out Dest : UnicodeSt
procedure WideCharLenToStrVar(Src : PWideChar;Len : SizeInt;out Dest : AnsiString); procedure WideCharLenToStrVar(Src : PWideChar;Len : SizeInt;out Dest : AnsiString);
begin begin
Dest:=WideCharLenToString(Src,Len); Dest:=AnsiString(WideCharLenToString(Src,Len));
end; end;
@ -978,7 +978,7 @@ procedure WideCharToStrVar(S : PWideChar;out Dest : UnicodeString);
procedure WideCharToStrVar(S : PWideChar;out Dest : AnsiString); procedure WideCharToStrVar(S : PWideChar;out Dest : AnsiString);
begin begin
Dest:=WideCharToString(S); Dest:=AnsiString(WideCharToString(S));
end; end;
@ -1201,45 +1201,44 @@ end;
{$ifndef FPUNONE} {$ifndef FPUNONE}
Function fpc_Val_Real_UnicodeStr(Const S : UnicodeString; out Code : ValSInt): ValReal; [public, alias:'FPC_VAL_REAL_UNICODESTR']; compilerproc; Function fpc_Val_Real_UnicodeStr(Const S : UnicodeString; out Code : ValSInt): ValReal; [public, alias:'FPC_VAL_REAL_UNICODESTR']; compilerproc;
Var Var
SS : String; SS: ShortString;
begin begin
fpc_Val_Real_UnicodeStr := 0; fpc_Val_Real_UnicodeStr:=0;
if length(S) > 255 then if length(S)>255 then
code := 256 code:=256
else else
begin begin
SS := S; SS:=ShortString(S);
Val(SS,fpc_Val_Real_UnicodeStr,code); Val(SS,fpc_Val_Real_UnicodeStr,code);
end; end;
end; end;
{$endif} {$endif}
function fpc_val_enum_unicodestr(str2ordindex:pointer;const s:unicodestring;out code:valsint):longint;compilerproc; function fpc_val_enum_unicodestr(str2ordindex:pointer;const s:unicodestring;out code:valsint):longint;compilerproc;
var
var ss:shortstring; ss: ShortString;
begin begin
if length(s)>255 then if length(s)>255 then
code:=256 code:=256
else else
begin begin
ss:=s; ss:=ShortString(s);
val(ss,fpc_val_enum_unicodestr,code); val(ss,fpc_val_enum_unicodestr,code);
end; end;
end; end;
Function fpc_Val_Currency_UnicodeStr(Const S : UnicodeString; out Code : ValSInt): Currency; [public, alias:'FPC_VAL_CURRENCY_UNICODESTR']; compilerproc; Function fpc_Val_Currency_UnicodeStr(Const S : UnicodeString; out Code : ValSInt): Currency; [public, alias:'FPC_VAL_CURRENCY_UNICODESTR']; compilerproc;
Var Var
SS : String; SS: ShortString;
begin begin
if length(S) > 255 then if length(S)>255 then
begin begin
fpc_Val_Currency_UnicodeStr:=0; fpc_Val_Currency_UnicodeStr:=0;
code := 256; code:=256;
end end
else else
begin begin
SS := S; SS:=ShortString(S);
Val(SS,fpc_Val_Currency_UnicodeStr,code); Val(SS,fpc_Val_Currency_UnicodeStr,code);
end; end;
end; end;
@ -1247,14 +1246,14 @@ end;
Function fpc_Val_UInt_UnicodeStr (Const S : UnicodeString; out Code : ValSInt): ValUInt; [public, alias:'FPC_VAL_UINT_UNICODESTR']; compilerproc; Function fpc_Val_UInt_UnicodeStr (Const S : UnicodeString; out Code : ValSInt): ValUInt; [public, alias:'FPC_VAL_UINT_UNICODESTR']; compilerproc;
Var Var
SS : ShortString; SS: ShortString;
begin begin
fpc_Val_UInt_UnicodeStr := 0; fpc_Val_UInt_UnicodeStr:=0;
if length(S) > 255 then if length(S)>255 then
code := 256 code:=256
else else
begin begin
SS := S; SS:=ShortString(S);
Val(SS,fpc_Val_UInt_UnicodeStr,code); Val(SS,fpc_Val_UInt_UnicodeStr,code);
end; end;
end; end;
@ -1262,14 +1261,14 @@ end;
Function fpc_Val_SInt_UnicodeStr (DestSize: SizeInt; Const S : UnicodeString; out Code : ValSInt): ValSInt; [public, alias:'FPC_VAL_SINT_UNICODESTR']; compilerproc; Function fpc_Val_SInt_UnicodeStr (DestSize: SizeInt; Const S : UnicodeString; out Code : ValSInt): ValSInt; [public, alias:'FPC_VAL_SINT_UNICODESTR']; compilerproc;
Var Var
SS : ShortString; SS: ShortString;
begin begin
fpc_Val_SInt_UnicodeStr:=0; fpc_Val_SInt_UnicodeStr:=0;
if length(S)>255 then if length(S)>255 then
code:=256 code:=256
else else
begin begin
SS := S; SS:=ShortString(S);
fpc_Val_SInt_UnicodeStr := int_Val_SInt_ShortStr(DestSize,SS,Code); fpc_Val_SInt_UnicodeStr := int_Val_SInt_ShortStr(DestSize,SS,Code);
end; end;
end; end;
@ -1279,14 +1278,14 @@ end;
Function fpc_Val_qword_UnicodeStr (Const S : UnicodeString; out Code : ValSInt): qword; [public, alias:'FPC_VAL_QWORD_UNICODESTR']; compilerproc; Function fpc_Val_qword_UnicodeStr (Const S : UnicodeString; out Code : ValSInt): qword; [public, alias:'FPC_VAL_QWORD_UNICODESTR']; compilerproc;
Var Var
SS : ShortString; SS: ShortString;
begin begin
fpc_Val_qword_UnicodeStr:=0; fpc_Val_qword_UnicodeStr:=0;
if length(S)>255 then if length(S)>255 then
code:=256 code:=256
else else
begin begin
SS := S; SS:=ShortString(S);
Val(SS,fpc_Val_qword_UnicodeStr,Code); Val(SS,fpc_Val_qword_UnicodeStr,Code);
end; end;
end; end;
@ -1294,14 +1293,14 @@ end;
Function fpc_Val_int64_UnicodeStr (Const S : UnicodeString; out Code : ValSInt): Int64; [public, alias:'FPC_VAL_INT64_UNICODESTR']; compilerproc; Function fpc_Val_int64_UnicodeStr (Const S : UnicodeString; out Code : ValSInt): Int64; [public, alias:'FPC_VAL_INT64_UNICODESTR']; compilerproc;
Var Var
SS : ShortString; SS: ShortString;
begin begin
fpc_Val_int64_UnicodeStr:=0; fpc_Val_int64_UnicodeStr:=0;
if length(S)>255 then if length(S)>255 then
code:=256 code:=256
else else
begin begin
SS := S; SS:=ShortString(S);
Val(SS,fpc_Val_int64_UnicodeStr,Code); Val(SS,fpc_Val_int64_UnicodeStr,Code);
end; end;
end; end;
@ -1312,56 +1311,54 @@ end;
{$ifndef FPUNONE} {$ifndef FPUNONE}
procedure fpc_UnicodeStr_Float(d : ValReal;len,fr,rt : SizeInt;out s : UnicodeString);compilerproc; procedure fpc_UnicodeStr_Float(d : ValReal;len,fr,rt : SizeInt;out s : UnicodeString);compilerproc;
var var
ss : shortstring; ss: shortstring;
begin begin
str_real(len,fr,d,treal_type(rt),ss); str_real(len,fr,d,treal_type(rt),ss);
s:=ss; s:=UnicodeString(ss);
end; end;
{$endif} {$endif}
procedure fpc_unicodestr_enum(ordinal,len:sizeint;typinfo,ord2strindex:pointer;out s:unicodestring);compilerproc; procedure fpc_unicodestr_enum(ordinal,len:sizeint;typinfo,ord2strindex:pointer;out s:unicodestring);compilerproc;
var
var ss:shortstring; ss: ShortString;
begin begin
fpc_shortstr_enum(ordinal,len,typinfo,ord2strindex,ss); fpc_shortstr_enum(ordinal,len,typinfo,ord2strindex,ss);
s:=ss; s:=UnicodeString(ss);
end; end;
procedure fpc_unicodestr_bool(b : boolean;len:sizeint;out s:unicodestring);compilerproc; procedure fpc_unicodestr_bool(b : boolean;len:sizeint;out s:unicodestring);compilerproc;
var
var ss:shortstring; ss: ShortString;
begin begin
fpc_shortstr_bool(b,len,ss); fpc_shortstr_bool(b,len,ss);
s:=ss; s:=UnicodeString(ss);
end; end;
{$ifdef FPC_HAS_STR_CURRENCY} {$ifdef FPC_HAS_STR_CURRENCY}
procedure fpc_UnicodeStr_Currency(c : Currency;len,fr : SizeInt;out s : UnicodeString);compilerproc; procedure fpc_UnicodeStr_Currency(c : Currency;len,fr : SizeInt;out s : UnicodeString);compilerproc;
var var
ss : shortstring; ss: shortstring;
begin begin
str(c:len:fr,ss); str(c:len:fr,ss);
s:=ss; s:=UnicodeString(ss);
end; end;
{$endif FPC_HAS_STR_CURRENCY} {$endif FPC_HAS_STR_CURRENCY}
Procedure fpc_UnicodeStr_SInt(v : ValSint; Len : SizeInt; out S : UnicodeString);compilerproc; Procedure fpc_UnicodeStr_SInt(v : ValSint; Len : SizeInt; out S : UnicodeString);compilerproc;
Var Var
SS : ShortString; SS: ShortString;
begin begin
Str (v:Len,SS); Str (v:Len,SS);
S:=SS; S:=UnicodeString(SS);
end; end;
Procedure fpc_UnicodeStr_UInt(v : ValUInt;Len : SizeInt; out S : UnicodeString);compilerproc; Procedure fpc_UnicodeStr_UInt(v : ValUInt;Len : SizeInt; out S : UnicodeString);compilerproc;
Var Var
SS : ShortString; SS: ShortString;
begin begin
str(v:Len,SS); str(v:Len,SS);
S:=SS; S:=UnicodeString(SS);
end; end;
@ -1369,19 +1366,19 @@ end;
Procedure fpc_UnicodeStr_Int64(v : Int64; Len : SizeInt; out S : UnicodeString);compilerproc; Procedure fpc_UnicodeStr_Int64(v : Int64; Len : SizeInt; out S : UnicodeString);compilerproc;
Var Var
SS : ShortString; SS: ShortString;
begin begin
Str (v:Len,SS); Str (v:Len,SS);
S:=SS; S:=UnicodeString(SS);
end; end;
Procedure fpc_UnicodeStr_Qword(v : Qword;Len : SizeInt; out S : UnicodeString);compilerproc; Procedure fpc_UnicodeStr_Qword(v : Qword;Len : SizeInt; out S : UnicodeString);compilerproc;
Var Var
SS : ShortString; SS: ShortString;
begin begin
str(v:Len,SS); str(v:Len,SS);
S:=SS; S:=UnicodeString(SS);
end; end;
{$endif CPU64} {$endif CPU64}
@ -1832,7 +1829,7 @@ function AnsiToUtf8(const s : RawByteString): RawByteString;{$ifdef SYSTEMINLINE
function Utf8ToAnsi(const s : RawByteString) : RawByteString;{$ifdef SYSTEMINLINE}inline;{$endif} function Utf8ToAnsi(const s : RawByteString) : RawByteString;{$ifdef SYSTEMINLINE}inline;{$endif}
begin begin
Result:=Utf8Decode(s); Result:=RawByteString(Utf8Decode(s));
end; end;

View File

@ -762,45 +762,44 @@ end;
{$ifndef FPUNONE} {$ifndef FPUNONE}
Function fpc_Val_Real_WideStr(Const S : WideString; out Code : ValSInt): ValReal; [public, alias:'FPC_VAL_REAL_WIDESTR']; compilerproc; Function fpc_Val_Real_WideStr(Const S : WideString; out Code : ValSInt): ValReal; [public, alias:'FPC_VAL_REAL_WIDESTR']; compilerproc;
Var Var
SS : String; SS: ShortString;
begin begin
fpc_Val_Real_WideStr := 0; fpc_Val_Real_WideStr := 0;
if length(S) > 255 then if length(S)>255 then
code := 256 code:=256
else else
begin begin
SS := S; SS:=ShortString(S);
Val(SS,fpc_Val_Real_WideStr,code); Val(SS,fpc_Val_Real_WideStr,code);
end; end;
end; end;
{$endif} {$endif}
function fpc_val_enum_widestr(str2ordindex:pointer;const s:widestring;out code:valsint):longint;compilerproc; function fpc_val_enum_widestr(str2ordindex:pointer;const s:widestring;out code:valsint):longint;compilerproc;
var
var ss:shortstring; ss: ShortString;
begin begin
if length(s)>255 then if length(s)>255 then
code:=256 code:=256
else else
begin begin
ss:=s; ss:=ShortString(s);
val(ss,fpc_val_enum_widestr,code); val(ss,fpc_val_enum_widestr,code);
end; end;
end; end;
Function fpc_Val_Currency_WideStr(Const S : WideString; out Code : ValSInt): Currency; [public, alias:'FPC_VAL_CURRENCY_WIDESTR']; compilerproc; Function fpc_Val_Currency_WideStr(Const S : WideString; out Code : ValSInt): Currency; [public, alias:'FPC_VAL_CURRENCY_WIDESTR']; compilerproc;
Var Var
SS : String; SS: ShortString;
begin begin
if length(S) > 255 then if length(S)>255 then
begin begin
fpc_Val_Currency_WideStr:=0; fpc_Val_Currency_WideStr:=0;
code := 256; code:=256;
end end
else else
begin begin
SS := S; SS:=ShortString(S);
Val(SS,fpc_Val_Currency_WideStr,code); Val(SS,fpc_Val_Currency_WideStr,code);
end; end;
end; end;
@ -808,14 +807,14 @@ end;
Function fpc_Val_UInt_WideStr (Const S : WideString; out Code : ValSInt): ValUInt; [public, alias:'FPC_VAL_UINT_WIDESTR']; compilerproc; Function fpc_Val_UInt_WideStr (Const S : WideString; out Code : ValSInt): ValUInt; [public, alias:'FPC_VAL_UINT_WIDESTR']; compilerproc;
Var Var
SS : ShortString; SS: ShortString;
begin begin
fpc_Val_UInt_WideStr := 0; fpc_Val_UInt_WideStr:=0;
if length(S) > 255 then if length(S)>255 then
code := 256 code:=256
else else
begin begin
SS := S; SS:=ShortString(S);
Val(SS,fpc_Val_UInt_WideStr,code); Val(SS,fpc_Val_UInt_WideStr,code);
end; end;
end; end;
@ -823,14 +822,14 @@ end;
Function fpc_Val_SInt_WideStr (DestSize: SizeInt; Const S : WideString; out Code : ValSInt): ValSInt; [public, alias:'FPC_VAL_SINT_WIDESTR']; compilerproc; Function fpc_Val_SInt_WideStr (DestSize: SizeInt; Const S : WideString; out Code : ValSInt): ValSInt; [public, alias:'FPC_VAL_SINT_WIDESTR']; compilerproc;
Var Var
SS : ShortString; SS: ShortString;
begin begin
fpc_Val_SInt_WideStr:=0; fpc_Val_SInt_WideStr:=0;
if length(S)>255 then if length(S)>255 then
code:=256 code:=256
else else
begin begin
SS := S; SS:=ShortString(S);
fpc_Val_SInt_WideStr := int_Val_SInt_ShortStr(DestSize,SS,Code); fpc_Val_SInt_WideStr := int_Val_SInt_ShortStr(DestSize,SS,Code);
end; end;
end; end;
@ -840,14 +839,14 @@ end;
Function fpc_Val_qword_WideStr (Const S : WideString; out Code : ValSInt): qword; [public, alias:'FPC_VAL_QWORD_WIDESTR']; compilerproc; Function fpc_Val_qword_WideStr (Const S : WideString; out Code : ValSInt): qword; [public, alias:'FPC_VAL_QWORD_WIDESTR']; compilerproc;
Var Var
SS : ShortString; SS: ShortString;
begin begin
fpc_Val_qword_WideStr:=0; fpc_Val_qword_WideStr:=0;
if length(S)>255 then if length(S)>255 then
code:=256 code:=256
else else
begin begin
SS := S; SS:=ShortString(S);
Val(SS,fpc_Val_qword_WideStr,Code); Val(SS,fpc_Val_qword_WideStr,Code);
end; end;
end; end;
@ -855,14 +854,14 @@ end;
Function fpc_Val_int64_WideStr (Const S : WideString; out Code : ValSInt): Int64; [public, alias:'FPC_VAL_INT64_WIDESTR']; compilerproc; Function fpc_Val_int64_WideStr (Const S : WideString; out Code : ValSInt): Int64; [public, alias:'FPC_VAL_INT64_WIDESTR']; compilerproc;
Var Var
SS : ShortString; SS: ShortString;
begin begin
fpc_Val_int64_WideStr:=0; fpc_Val_int64_WideStr:=0;
if length(S)>255 then if length(S)>255 then
code:=256 code:=256
else else
begin begin
SS := S; SS:=ShortString(S);
Val(SS,fpc_Val_int64_WideStr,Code); Val(SS,fpc_Val_int64_WideStr,Code);
end; end;
end; end;
@ -873,56 +872,54 @@ end;
{$ifndef FPUNONE} {$ifndef FPUNONE}
procedure fpc_WideStr_Float(d : ValReal;len,fr,rt : SizeInt;out s : WideString);compilerproc; procedure fpc_WideStr_Float(d : ValReal;len,fr,rt : SizeInt;out s : WideString);compilerproc;
var var
ss : shortstring; ss: ShortString;
begin begin
str_real(len,fr,d,treal_type(rt),ss); str_real(len,fr,d,treal_type(rt),ss);
s:=ss; s:=WideString(ss);
end; end;
{$endif} {$endif}
procedure fpc_widestr_enum(ordinal,len:sizeint;typinfo,ord2strindex:pointer;out s:widestring);compilerproc; procedure fpc_widestr_enum(ordinal,len:sizeint;typinfo,ord2strindex:pointer;out s:widestring);compilerproc;
var
var ss:shortstring; ss: ShortString;
begin begin
fpc_shortstr_enum(ordinal,len,typinfo,ord2strindex,ss); fpc_shortstr_enum(ordinal,len,typinfo,ord2strindex,ss);
s:=ss; s:=WideString(ss);
end; end;
procedure fpc_widestr_bool(b : boolean;len:sizeint;out s:widestring);compilerproc; procedure fpc_widestr_bool(b : boolean;len:sizeint;out s:widestring);compilerproc;
var
var ss:shortstring; ss: ShortString;
begin begin
fpc_shortstr_bool(b,len,ss); fpc_shortstr_bool(b,len,ss);
s:=ss; s:=WideString(ss);
end; end;
{$ifdef FPC_HAS_STR_CURRENCY} {$ifdef FPC_HAS_STR_CURRENCY}
procedure fpc_WideStr_Currency(c : Currency;len,fr : SizeInt;out s : WideString);compilerproc; procedure fpc_WideStr_Currency(c : Currency;len,fr : SizeInt;out s : WideString);compilerproc;
var var
ss : shortstring; ss: ShortString;
begin begin
str(c:len:fr,ss); str(c:len:fr,ss);
s:=ss; s:=WideString(ss);
end; end;
{$endif FPC_HAS_STR_CURRENCY} {$endif FPC_HAS_STR_CURRENCY}
Procedure fpc_WideStr_SInt(v : ValSint; Len : SizeInt; out S : WideString);compilerproc; Procedure fpc_WideStr_SInt(v : ValSint; Len : SizeInt; out S : WideString);compilerproc;
Var Var
SS : ShortString; SS: ShortString;
begin begin
Str (v:Len,SS); Str (v:Len,SS);
S:=SS; S:=WideString(SS);
end; end;
Procedure fpc_WideStr_UInt(v : ValUInt;Len : SizeInt; out S : WideString);compilerproc; Procedure fpc_WideStr_UInt(v : ValUInt;Len : SizeInt; out S : WideString);compilerproc;
Var Var
SS : ShortString; SS: ShortString;
begin begin
str(v:Len,SS); str(v:Len,SS);
S:=SS; S:=WideString(SS);
end; end;
@ -930,19 +927,19 @@ end;
Procedure fpc_WideStr_Int64(v : Int64; Len : SizeInt; out S : WideString);compilerproc; Procedure fpc_WideStr_Int64(v : Int64; Len : SizeInt; out S : WideString);compilerproc;
Var Var
SS : ShortString; SS: ShortString;
begin begin
Str (v:Len,SS); Str(v:Len,SS);
S:=SS; S:=WideString(SS);
end; end;
Procedure fpc_WideStr_Qword(v : Qword;Len : SizeInt; out S : WideString);compilerproc; Procedure fpc_WideStr_Qword(v : Qword;Len : SizeInt; out S : WideString);compilerproc;
Var Var
SS : ShortString; SS: ShortString;
begin begin
str(v:Len,SS); str(v:Len,SS);
S:=SS; S:=WideString(SS);
end; end;
{$endif CPU64} {$endif CPU64}