浏览代码

* Fixed string conversion warnings in RTL.

git-svn-id: trunk@31752 -
yury 10 年之前
父节点
当前提交
7c62aadf65

+ 1 - 1
rtl/inc/system.inc

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

+ 1 - 1
rtl/inc/uuchar.pp

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

+ 1 - 1
rtl/objpas/classes/classes.inc

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

+ 3 - 3
rtl/objpas/classes/parser.inc

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

+ 3 - 3
rtl/objpas/classes/reader.inc

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

+ 4 - 4
rtl/objpas/sysutils/sysencoding.inc

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

+ 32 - 32
rtl/objpas/sysutils/sysformt.inc

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

+ 8 - 8
rtl/objpas/typinfo.pp

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