Browse Source

Merged revisions 7313,7325,7354,7361,7374,7378 via svnmerge from
svn+ssh://[email protected]/FPC/svn/fpc/trunk

........
r7313 | michael | 2007-05-12 01:32:25 +0200 (Sat, 12 May 2007) | 1 line

Removed debug message in CheckOptions
........
r7325 | michael | 2007-05-13 19:44:00 +0200 (Sun, 13 May 2007) | 1 line

* Fixed description of array type without index (open array)
........
r7354 | michael | 2007-05-16 09:31:58 +0200 (Wed, 16 May 2007) | 1 line

* Added brazilian translation by Antonio Galvao
........
r7361 | michael | 2007-05-16 16:57:55 +0200 (Wed, 16 May 2007) | 1 line

Better error checking at connect/disconnect
........
r7374 | michael | 2007-05-17 13:29:46 +0200 (Thu, 17 May 2007) | 1 line

* Marked some sections as private
........
r7378 | michael | 2007-05-17 17:53:02 +0200 (Thu, 17 May 2007) | 1 line

* SectionExists now Delphi compatible
........

git-svn-id: branches/fixes_2_2@8036 -

joost 18 years ago
parent
commit
4a7a80bf01

+ 2 - 0
.gitattributes

@@ -3873,6 +3873,8 @@ packages/fcl-base/tests/intl/restest.fr.mo -text
 packages/fcl-base/tests/intl/restest.fr.po svneol=native#text/plain
 packages/fcl-base/tests/intl/restest.nl.mo -text
 packages/fcl-base/tests/intl/restest.nl.po svneol=native#text/plain
+packages/fcl-base/tests/intl/restest.pb.mo -text
+packages/fcl-base/tests/intl/restest.pb.po svneol=native#text/plain
 packages/fcl-base/tests/intl/restest.ru.mo -text
 packages/fcl-base/tests/intl/restest.ru.po svneol=native#text/plain
 packages/fcl-base/tests/intl/resttest.po svneol=native#text/plain

+ 0 - 1
packages/fcl-base/src/inc/custapp.pp

@@ -428,7 +428,6 @@ begin
               If (P<Length(ShortOptions)) and (Shortoptions[P+1]=':') then
                 begin
                 // Required argument
-                Writeln('P ',P,' J ',J,' ',O[J],' ',l,' Havearg ',HaveArg);
                 If ((P+1)=Length(ShortOptions)) or (Shortoptions[P+2]<>':') Then
                   If (J<L) or not haveArg then // Must be last in multi-opt !!
                     Result:=Format(SErrOptionNeeded,[I,O[J]]);

+ 54 - 12
packages/fcl-base/src/inc/inifiles.pp

@@ -76,6 +76,7 @@ type
   end;
 
   TIniFileKey = class
+  Private
     FIdent: string;
     FValue: string;
   public
@@ -95,9 +96,11 @@ type
   end;
 
   TIniFileSection = class
+  private
     FName: string;
     FKeyList: TIniFileKeyList;
   public
+    Function Empty : Boolean;
     constructor Create(AName: string);
     destructor Destroy; override;
     property Name: string read FName;
@@ -160,6 +163,8 @@ type
     FCacheUpdates: Boolean;
     FDirty : Boolean;
     procedure FillSectionList(AStrings: TStrings);
+    Procedure DeleteSection(ASection : TIniFileSection);
+    Procedure MaybeDeleteSection(ASection : TIniFileSection);
   protected
     procedure MaybeUpdateFile;
     property Dirty : Boolean Read FDirty;
@@ -353,6 +358,22 @@ begin
   inherited Clear;
 end;
 
+Function TIniFileSection.Empty : Boolean;
+
+Var
+  I : Integer;
+
+begin
+  Result:=True;
+  I:=0;
+  While Result and (I<KeyList.Count)  do
+    begin
+    result:=IsComment(KeyList[i].Ident);
+    Inc(i);
+    end;
+end;
+
+
 { TIniFileSection }
 
 constructor TIniFileSection.Create(AName: string);
@@ -430,8 +451,13 @@ begin
 end;
 
 function TCustomIniFile.SectionExists(const Section: string): Boolean;
+
+Var
+  S : TIniFileSection;
+
 begin
-  Result := (FSectionList.SectionByName(Section,CaseSensitive) <> nil);
+  S:=FSectionList.SectionByName(Section,CaseSensitive);
+  Result:=Assigned(S) and Not S.Empty;
 end;
 
 function TCustomIniFile.ReadInteger(const Section, Ident: string; Default: Longint): Longint;
@@ -863,6 +889,20 @@ begin
   end;
 end;
 
+procedure TIniFile.DeleteSection(ASection : TIniFileSection);
+
+begin
+  FSectionList.Delete(FSectionList.IndexOf(ASection));
+  ASection.Free;
+end;
+
+Procedure TIniFile.MaybeDeleteSection(ASection : TIniFileSection);
+
+begin
+  If Asection.Empty then
+    DeleteSection(ASection);
+end;
+
 procedure TIniFile.EraseSection(const Section: string);
 var
   oSection: TIniFileSection;
@@ -871,8 +911,7 @@ begin
   if oSection <> nil then begin
     { It is needed so UpdateFile doesn't find a defunct section }
     { and cause the program to crash }
-    FSectionList.Delete(FSectionList.IndexOf(oSection));
-    oSection.Free;
+    DeleteSection(OSection);
     MaybeUpdateFile;
   end;
 end;
@@ -882,15 +921,18 @@ var
  oSection: TIniFileSection;
  oKey: TIniFileKey;
 begin
- oSection := FSectionList.SectionByName(Section,CaseSensitive);
- if oSection <> nil then begin
-   oKey := oSection.KeyList.KeyByName(Ident,CaseSensitive);
-   if oKey <> nil then begin
-     oSection.KeyList.Delete(oSection.KeyList.IndexOf(oKey));
-     oKey.Free;
-     MaybeUpdateFile;
-   end;
- end;
+  oSection := FSectionList.SectionByName(Section,CaseSensitive);
+  if oSection <> nil then 
+    begin
+    oKey := oSection.KeyList.KeyByName(Ident,CaseSensitive);
+    if oKey <> nil then 
+      begin
+      oSection.KeyList.Delete(oSection.KeyList.IndexOf(oKey));
+      oKey.Free;
+      MaybeDeleteSection(oSection);
+      MaybeUpdateFile;
+      end;
+    end;
 end;
 
 procedure TIniFile.UpdateFile;

+ 20 - 7
packages/fcl-base/src/inc/simpleipc.pp

@@ -46,13 +46,14 @@ Type
   TIPCServerComm = Class(TObject)
   Private
     FOwner  : TSimpleIPCServer;
+  Protected  
+    Function  GetInstanceID : String; virtual; abstract;
   Public
     Constructor Create(AOwner : TSimpleIPCServer); virtual;
     Property Owner : TSimpleIPCServer read FOwner;
     Procedure StartServer; virtual; Abstract;
     Procedure StopServer;virtual; Abstract;
     Function  PeekMessage(TimeOut : Integer) : Boolean;virtual; Abstract;
-    Function  GetInstanceID : String; virtual; abstract;
     Procedure ReadMessage ;virtual; Abstract;
     Property InstanceID : String read GetInstanceID;
   end;
@@ -372,16 +373,28 @@ end;
 
 procedure TSimpleIPCClient.Connect;
 begin
-  FIPCComm:=CommClass.Create(Self);
-  FIPCComm.Connect;
-  FActive:=True;
+  If Not assigned(FIPCComm) then
+    begin
+    FIPCComm:=CommClass.Create(Self);
+    Try
+      FIPCComm.Connect;
+    Except
+      FreeAndNil(FIPCComm);
+      Raise;
+    end;  
+    FActive:=True;
+    end;
 end;
 
 procedure TSimpleIPCClient.Disconnect;
 begin
-  FIPCComm.DisConnect;
-  FreeAndNil(FIPCComm);
-  FActive:=False;
+  If Assigned(FIPCComm) then
+    Try
+      FIPCComm.DisConnect;
+    Finally
+      FActive:=False;
+      FreeAndNil(FIPCComm);
+    end;  
 end;
 
 function TSimpleIPCClient.ServerRunning: Boolean;

+ 1 - 1
packages/fcl-base/tests/intl/Makefile

@@ -3,7 +3,7 @@
 # Add a 2 letter code when adding a language to DEMOLANGUAGES
 #
 
-DEMOLANGUAGES=fr nl de
+DEMOLANGUAGES=fr nl de pb
 
 #
 # No need to add after this line.

BIN
packages/fcl-base/tests/intl/restest.de.mo


BIN
packages/fcl-base/tests/intl/restest.fr.mo


BIN
packages/fcl-base/tests/intl/restest.nl.mo


BIN
packages/fcl-base/tests/intl/restest.pb.mo


+ 16 - 0
packages/fcl-base/tests/intl/restest.pb.po

@@ -0,0 +1,16 @@
+#: testo:testing
+msgid "Testing :"
+msgstr "Testando:"
+
+#: testo:first
+msgid "First"
+msgstr "Primeiro"
+
+#: testo:second
+msgid "Second"
+msgstr "Segundo"
+
+#: testo:third
+msgid "Third"
+msgstr "Terceiro"
+

+ 4 - 1
packages/fcl-passrc/src/pastree.pp

@@ -1116,7 +1116,10 @@ end;
 
 function TPasArrayType.GetDeclaration (full : boolean) : string;
 begin
-  Result:='Array['+IndexRange+'] of ';
+  Result:='Array';
+  If (IndexRange<>'') then
+    Result:=Result+'['+IndexRange+']';
+  Result:=Result+' of ';
   If IsPacked then
      Result := 'packed '+Result;      // 12/04/04 Dave - Added
   If Assigned(Eltype) then