2
0
Эх сурвалжийг харах

o several strings changed into ansistrings, resolves #19318, no compilation speed degrations measurable
* TCmdStr changed into an ansistring
* command line parameter handling uses now ansistrings
* message handling parameters are now ansistrings

git-svn-id: trunk@17469 -

florian 14 жил өмнө
parent
commit
13285ab264

+ 7 - 6
compiler/cmsgs.pas

@@ -33,6 +33,7 @@ const
 
 type
   ppchar=^pchar;
+  TMsgStr = AnsiString;
 
   TArrayOfPChar = array[0..1000] of pchar;
   PArrayOfPChar = ^TArrayOfPChar;
@@ -60,7 +61,7 @@ type
     procedure CreateIdx;
     function  GetPChar(nr:longint):pchar;
     function  ClearVerbosity(nr:longint):boolean;
-    function  Get(nr:longint;const args:array of string):ansistring;
+    function  Get(nr:longint;const args:array of TMsgStr):ansistring;
   end;
 
 { this will read a line until #10 or #0 and also increase p }
@@ -74,11 +75,11 @@ uses
   cutils;
 
 
-function MsgReplace(const s:string;const args:array of string):ansistring;
+function MsgReplace(const s:TMsgStr;const args:array of TMsgStr):ansistring;
 var
   last,
   i  : longint;
-  hs : ansistring;
+  hs : TMsgStr;
 
 begin
   if s='' then
@@ -169,7 +170,7 @@ var
   s,s1    : string;
   buf     : pointer;
 
-  procedure err(const msgstr:string);
+  procedure err(const msgstr:TMsgStr);
   begin
     writeln('*** PPC, file ',fn,', error in line ',line,': ',msgstr);
     error:=true;
@@ -367,7 +368,7 @@ var
   i  : longint;
 begin
   i:=0;
-  while not(p^ in [#0,#10]) and (i<255) do
+  while not(p^ in [#0,#10]) and (i<256) do
    begin
      inc(i);
      GetMsgLine[i]:=p^;
@@ -402,7 +403,7 @@ begin
   result:=true;
 end;
 
-function TMessage.Get(nr:longint;const args:array of string):ansistring;
+function TMessage.Get(nr:longint;const args:array of TMsgStr):ansistring;
 var
   hp : pchar;
 begin

+ 3 - 3
compiler/compiler.pas

@@ -118,7 +118,7 @@ uses
 {$endif nativent}
   ,globtype;
 
-function Compile(const cmd:string):longint;
+function Compile(const cmd:TCmdStr):longint;
 
 implementation
 
@@ -163,7 +163,7 @@ begin
 end;
 
 
-procedure InitCompiler(const cmd:string);
+procedure InitCompiler(const cmd:TCmdStr);
 begin
   if CompilerInited then
    DoneCompiler;
@@ -197,7 +197,7 @@ begin
 end;
 
 
-function Compile(const cmd:string):longint;
+function Compile(const cmd:TCmdStr):longint;
 
 {$maxfpuregisters 0}
 

+ 8 - 7
compiler/fppu.pas

@@ -35,9 +35,10 @@ unit fppu;
 interface
 
     uses
-       cutils,cclasses,
-       globtype,globals,finput,fmodule,
-       symbase,ppu,symtype;
+      cmsgs,verbose,
+      cutils,cclasses,
+      globtype,globals,finput,fmodule,
+      symbase,ppu,symtype;
 
     type
 
@@ -77,7 +78,7 @@ interface
           procedure load_implementation;
           procedure load_usedunits;
           procedure printcomments;
-          procedure queuecomment(s:string;v,w:longint);
+          procedure queuecomment(const s:TMsgStr;v,w:longint);
           procedure writesourcefiles;
           procedure writeusedunit(intf:boolean);
           procedure writelinkcontainer(var p:tlinkcontainer;id:byte;strippath:boolean);
@@ -108,7 +109,7 @@ implementation
 uses
   SysUtils,
   cfileutl,
-  verbose,systems,version,
+  systems,version,
   symtable, symsym,
   wpoinfo,
   scanner,
@@ -155,7 +156,7 @@ var
         inherited reset;
       end;
 
-    procedure tppumodule.queuecomment(s:string;v,w:longint);
+    procedure tppumodule.queuecomment(const s:TMsgStr;v,w:longint);
     begin
       if comments = nil then
         comments := TCmdStrList.create;
@@ -1397,7 +1398,7 @@ var
             localsymtable:=tstaticsymtable.create(modulename^,moduleid);
             tstaticsymtable(localsymtable).ppuload(ppufile);
           end;
-          
+
         { we can now derefence all pointers to the implementation parts }
         tstoredsymtable(globalsymtable).derefimpl;
         if assigned(localsymtable) then

+ 1 - 1
compiler/globals.pas

@@ -1402,7 +1402,7 @@ implementation
 
    procedure get_exepath;
      var
-	   localExepath : TCmdStr;
+       localExepath : TCmdStr;
        exeName:TCmdStr;
 {$ifdef need_path_search}
        hs1 : TPathStr;

+ 1 - 1
compiler/globtype.pas

@@ -32,7 +32,7 @@ interface
          executed from the FPC application. In some circomstances, this can be more
          than 255 characters. That's why using Ansi Strings}
        TCmdStr = AnsiString;
-       TPathStr = String;
+       TPathStr = AnsiString;
 
        { Integer type corresponding to pointer size }
 {$ifdef cpu64bitaddr}

+ 25 - 25
compiler/options.pas

@@ -52,15 +52,15 @@ Type
     procedure WriteInfo;
     procedure WriteHelpPages;
     procedure WriteQuickInfo;
-    procedure IllegalPara(const opt:string);
-    procedure UnsupportedPara(const opt:string);
-    procedure IgnoredPara(const opt:string);
+    procedure IllegalPara(const opt:TCmdStr);
+    procedure UnsupportedPara(const opt:TCmdStr);
+    procedure IgnoredPara(const opt:TCmdStr);
     function  Unsetbool(var Opts:TCmdStr; Pos: Longint):boolean;
-    procedure interpret_option(const opt :string;ispara:boolean);
-    procedure Interpret_envvar(const envname : string);
-    procedure Interpret_file(const filename : string);
+    procedure interpret_option(const opt :TCmdStr;ispara:boolean);
+    procedure Interpret_envvar(const envname : TCmdStr);
+    procedure Interpret_file(const filename : TPathStr);
     procedure Read_Parameters;
-    procedure parsecmd(cmd:string);
+    procedure parsecmd(cmd:TCmdStr);
     procedure TargetOptions(def:boolean);
     procedure CheckOptionsCompatibility;
     procedure ForceStaticLinking;
@@ -71,7 +71,7 @@ Type
 var
   coption : TOptionClass;
 
-procedure read_arguments(cmd:string);
+procedure read_arguments(cmd:TCmdStr);
 
 
 implementation
@@ -440,7 +440,7 @@ begin
 end;
 
 
-procedure Toption.IllegalPara(const opt:string);
+procedure Toption.IllegalPara(const opt:TCmdStr);
 begin
   Message1(option_illegal_para,opt);
   Message(option_help_pages_para);
@@ -448,14 +448,14 @@ begin
 end;
 
 
-procedure toption.UnsupportedPara(const opt: string);
+procedure toption.UnsupportedPara(const opt: TCmdStr);
 begin
   Message1(option_unsupported_target,opt);
   StopOptions(1);
 end;
 
 
-procedure toption.IgnoredPara(const opt: string);
+procedure toption.IgnoredPara(const opt: TCmdStr);
 begin
   Message1(option_ignored_target,opt);
 end;
@@ -488,7 +488,7 @@ begin
 end;
 
 
-procedure TOption.interpret_option(const opt:string;ispara:boolean);
+procedure TOption.interpret_option(const opt:TCmdStr;ispara:boolean);
 var
   code : integer;
   c    : char;
@@ -517,7 +517,7 @@ begin
   case opt[1] of
     '-' :
       begin
-         more:=Copy(opt,3,255);
+         more:=Copy(opt,3,2147483647);
          if firstpass then
            Message1(option_interpreting_firstpass_option,opt)
          else
@@ -1769,9 +1769,9 @@ begin
 end;
 
 
-procedure Toption.Interpret_file(const filename : string);
+procedure Toption.Interpret_file(const filename : TPathStr);
 
-  procedure RemoveSep(var fn:string);
+  procedure RemoveSep(var fn:TPathStr);
   var
     i : longint;
   begin
@@ -1785,7 +1785,7 @@ procedure Toption.Interpret_file(const filename : string);
     fn:=copy(fn,1,i);
   end;
 
-  function GetName(var fn:string):string;
+  function GetName(var fn:TPathStr):TPathStr;
   var
     i : longint;
   begin
@@ -1801,7 +1801,7 @@ const
 var
   f     : text;
   s, tmp,
-  opts  : string;
+  opts  : TCmdStr;
   skip  : array[0..maxlevel] of boolean;
   line,
   level : longint;
@@ -1954,14 +1954,14 @@ begin
 end;
 
 
-procedure Toption.Interpret_envvar(const envname : string);
+procedure Toption.Interpret_envvar(const envname : TCmdStr);
 var
   argstart,
   env,
   pc     : pchar;
   arglen : longint;
   quote  : set of char;
-  hs     : string;
+  hs     : TCmdStr;
 begin
   Message1(option_using_env,envname);
   env:=GetEnvPChar(envname);
@@ -2013,14 +2013,14 @@ end;
 
 procedure toption.read_parameters;
 var
-  opts       : string;
+  opts       : TCmdStr;
   paramindex : longint;
 begin
   paramindex:=0;
   while paramindex<paramcount do
    begin
      inc(paramindex);
-     opts:=system.paramstr(paramindex);
+     opts:=objpas.paramstr(paramindex);
      case opts[1] of
        '@' :
          if not firstpass then
@@ -2043,10 +2043,10 @@ begin
 end;
 
 
-procedure toption.parsecmd(cmd:string);
+procedure toption.parsecmd(cmd:TCmdStr);
 var
   i,ps  : longint;
-  opts  : string;
+  opts  : TCmdStr;
 begin
   while (cmd<>'') do
    begin
@@ -2054,7 +2054,7 @@ begin
       delete(cmd,1,1);
      i:=pos(' ',cmd);
      if i=0 then
-      i:=256;
+       i:=2147483647;
      opts:=Copy(cmd,1,i-1);
      Delete(cmd,1,i);
      case opts[1] of
@@ -2351,7 +2351,7 @@ begin
 end;
 
 
-procedure read_arguments(cmd:string);
+procedure read_arguments(cmd:TCmdStr);
 var
   env: ansistring;
   i : tfeature;

+ 1 - 1
compiler/scanner.pas

@@ -1684,8 +1684,8 @@ In case not, the value returned can be arbitrary.
         foundfile : TCmdStr;
         path,
         name,
-        args,
         hs    : tpathstr;
+        args  : string;
         hp    : tinputfile;
         found : boolean;
       begin

+ 29 - 29
compiler/verbose.pas

@@ -70,7 +70,7 @@ interface
       paraprintnodetree : byte;
 
     type
-      tmsgqueueevent = procedure(s:string;v,w:longint) of object;
+      tmsgqueueevent = procedure(const s:TMsgStr;v,w:longint) of object;
 
     const
       msgfilename : string = '';
@@ -88,25 +88,25 @@ interface
     procedure Comment(l:longint;s:ansistring);
     function  MessagePchar(w:longint):pchar;
     procedure Message(w:longint;onqueue:tmsgqueueevent=nil);
-    procedure Message1(w:longint;const s1:string;onqueue:tmsgqueueevent=nil);
-    procedure Message2(w:longint;const s1,s2:string;onqueue:tmsgqueueevent=nil);
-    procedure Message3(w:longint;const s1,s2,s3:string;onqueue:tmsgqueueevent=nil);
-    procedure Message4(w:longint;const s1,s2,s3,s4:string;onqueue:tmsgqueueevent=nil);
+    procedure Message1(w:longint;const s1:TMsgStr;onqueue:tmsgqueueevent=nil);
+    procedure Message2(w:longint;const s1,s2:TMsgStr;onqueue:tmsgqueueevent=nil);
+    procedure Message3(w:longint;const s1,s2,s3:TMsgStr;onqueue:tmsgqueueevent=nil);
+    procedure Message4(w:longint;const s1,s2,s3,s4:TMsgStr;onqueue:tmsgqueueevent=nil);
     procedure MessagePos(const pos:tfileposinfo;w:longint;onqueue:tmsgqueueevent=nil);
-    procedure MessagePos1(const pos:tfileposinfo;w:longint;const s1:string;onqueue:tmsgqueueevent=nil);
-    procedure MessagePos2(const pos:tfileposinfo;w:longint;const s1,s2:string;onqueue:tmsgqueueevent=nil);
-    procedure MessagePos3(const pos:tfileposinfo;w:longint;const s1,s2,s3:string;onqueue:tmsgqueueevent=nil);
-    procedure MessagePos4(const pos:tfileposinfo;w:longint;const s1,s2,s3,s4:string;onqueue:tmsgqueueevent=nil);
+    procedure MessagePos1(const pos:tfileposinfo;w:longint;const s1:TMsgStr;onqueue:tmsgqueueevent=nil);
+    procedure MessagePos2(const pos:tfileposinfo;w:longint;const s1,s2:TMsgStr;onqueue:tmsgqueueevent=nil);
+    procedure MessagePos3(const pos:tfileposinfo;w:longint;const s1,s2,s3:TMsgStr;onqueue:tmsgqueueevent=nil);
+    procedure MessagePos4(const pos:tfileposinfo;w:longint;const s1,s2,s3,s4:TMsgStr;onqueue:tmsgqueueevent=nil);
 
     { message calls with codegenerror support }
     procedure cgmessage(t : longint);
-    procedure cgmessage1(t : longint;const s : string);
-    procedure cgmessage2(t : longint;const s1,s2 : string);
-    procedure cgmessage3(t : longint;const s1,s2,s3 : string);
+    procedure cgmessage1(t : longint;const s : TMsgStr);
+    procedure cgmessage2(t : longint;const s1,s2 : TMsgStr);
+    procedure cgmessage3(t : longint;const s1,s2,s3 : TMsgStr);
     procedure CGMessagePos(const pos:tfileposinfo;t:longint);
-    procedure CGMessagePos1(const pos:tfileposinfo;t:longint;const s1:string);
-    procedure CGMessagePos2(const pos:tfileposinfo;t:longint;const s1,s2:string);
-    procedure CGMessagePos3(const pos:tfileposinfo;t:longint;const s1,s2,s3:string);
+    procedure CGMessagePos1(const pos:tfileposinfo;t:longint;const s1:TMsgStr);
+    procedure CGMessagePos2(const pos:tfileposinfo;t:longint;const s1,s2:TMsgStr);
+    procedure CGMessagePos3(const pos:tfileposinfo;t:longint;const s1,s2,s3:TMsgStr);
 
     procedure FlushOutput;
 
@@ -697,7 +697,7 @@ implementation
       end;
 
 
-    procedure Message1(w:longint;const s1:string;onqueue:tmsgqueueevent=nil);
+    procedure Message1(w:longint;const s1:TMsgStr;onqueue:tmsgqueueevent=nil);
 
       begin
         MaybeLoadMessageFile;
@@ -705,21 +705,21 @@ implementation
       end;
 
 
-    procedure Message2(w:longint;const s1,s2:string;onqueue:tmsgqueueevent=nil);
+    procedure Message2(w:longint;const s1,s2:TMsgStr;onqueue:tmsgqueueevent=nil);
       begin
         MaybeLoadMessageFile;
         Msg2Comment(msg^.Get(w,[s1,s2]),w,onqueue);
       end;
 
 
-    procedure Message3(w:longint;const s1,s2,s3:string;onqueue:tmsgqueueevent=nil);
+    procedure Message3(w:longint;const s1,s2,s3:TMsgStr;onqueue:tmsgqueueevent=nil);
       begin
         MaybeLoadMessageFile;
         Msg2Comment(msg^.Get(w,[s1,s2,s3]),w,onqueue);
       end;
 
 
-    procedure Message4(w:longint;const s1,s2,s3,s4:string;onqueue:tmsgqueueevent=nil);
+    procedure Message4(w:longint;const s1,s2,s3,s4:TMsgStr;onqueue:tmsgqueueevent=nil);
       begin
         MaybeLoadMessageFile;
         Msg2Comment(msg^.Get(w,[s1,s2,s3,s4]),w,onqueue);
@@ -738,7 +738,7 @@ implementation
       end;
 
 
-    procedure MessagePos1(const pos:tfileposinfo;w:longint;const s1:string;onqueue:tmsgqueueevent=nil);
+    procedure MessagePos1(const pos:tfileposinfo;w:longint;const s1:TMsgStr;onqueue:tmsgqueueevent=nil);
       var
         oldpos : tfileposinfo;
       begin
@@ -750,7 +750,7 @@ implementation
       end;
 
 
-    procedure MessagePos2(const pos:tfileposinfo;w:longint;const s1,s2:string;onqueue:tmsgqueueevent=nil);
+    procedure MessagePos2(const pos:tfileposinfo;w:longint;const s1,s2:TMsgStr;onqueue:tmsgqueueevent=nil);
       var
         oldpos : tfileposinfo;
       begin
@@ -762,7 +762,7 @@ implementation
       end;
 
 
-    procedure MessagePos3(const pos:tfileposinfo;w:longint;const s1,s2,s3:string;onqueue:tmsgqueueevent=nil);
+    procedure MessagePos3(const pos:tfileposinfo;w:longint;const s1,s2,s3:TMsgStr;onqueue:tmsgqueueevent=nil);
       var
         oldpos : tfileposinfo;
       begin
@@ -774,7 +774,7 @@ implementation
       end;
 
 
-    procedure MessagePos4(const pos:tfileposinfo;w:longint;const s1,s2,s3,s4:string;onqueue:tmsgqueueevent=nil);
+    procedure MessagePos4(const pos:tfileposinfo;w:longint;const s1,s2,s3,s4:TMsgStr;onqueue:tmsgqueueevent=nil);
       var
         oldpos : tfileposinfo;
       begin
@@ -802,7 +802,7 @@ implementation
            end;
       end;
 
-    procedure cgmessage1(t : longint;const s : string);
+    procedure cgmessage1(t : longint;const s : TMsgStr);
       var
          olderrorcount : longint;
       begin
@@ -814,7 +814,7 @@ implementation
            end;
       end;
 
-    procedure cgmessage2(t : longint;const s1,s2 : string);
+    procedure cgmessage2(t : longint;const s1,s2 : TMsgStr);
       var
          olderrorcount : longint;
       begin
@@ -826,7 +826,7 @@ implementation
            end;
       end;
 
-    procedure cgmessage3(t : longint;const s1,s2,s3 : string);
+    procedure cgmessage3(t : longint;const s1,s2,s3 : TMsgStr);
       var
          olderrorcount : longint;
       begin
@@ -851,7 +851,7 @@ implementation
            end;
       end;
 
-    procedure cgmessagepos1(const pos:tfileposinfo;t : longint;const s1 : string);
+    procedure cgmessagepos1(const pos:tfileposinfo;t : longint;const s1 : TMsgStr);
       var
          olderrorcount : longint;
       begin
@@ -863,7 +863,7 @@ implementation
            end;
       end;
 
-    procedure cgmessagepos2(const pos:tfileposinfo;t : longint;const s1,s2 : string);
+    procedure cgmessagepos2(const pos:tfileposinfo;t : longint;const s1,s2 : TMsgStr);
       var
          olderrorcount : longint;
       begin
@@ -875,7 +875,7 @@ implementation
            end;
       end;
 
-    procedure cgmessagepos3(const pos:tfileposinfo;t : longint;const s1,s2,s3 : string);
+    procedure cgmessagepos3(const pos:tfileposinfo;t : longint;const s1,s2,s3 : TMsgStr);
       var
          olderrorcount : longint;
       begin