Browse Source

# revisions: 32775,32791

git-svn-id: branches/fixes_3_0@33755 -
marco 9 years ago
parent
commit
563003c4a6
2 changed files with 32 additions and 17 deletions
  1. 29 14
      rtl/objpas/sysutils/sysstr.inc
  2. 3 3
      rtl/objpas/sysutils/sysstrh.inc

+ 29 - 14
rtl/objpas/sysutils/sysstr.inc

@@ -706,20 +706,35 @@ end;
     'A' to 'Z', 'a' to 'z' or '_' and the following characters are
     'A' to 'Z', 'a' to 'z' or '_' and the following characters are
     on of: 'A' to 'Z', 'a' to 'z', '0'..'9' or '_'    }
     on of: 'A' to 'Z', 'a' to 'z', '0'..'9' or '_'    }
 
 
-function IsValidIdent(const Ident: string): boolean;
-var i, len: integer;
-begin
-result := false;
-len := length(Ident);
-if len <> 0 then begin
-   result := Ident[1] in ['A'..'Z', 'a'..'z', '_'];
-   i := 1;
-   while (result) and (i < len) do begin
-      i := i + 1;
-      result := result and (Ident[i] in ['A'..'Z', 'a'..'z', '0'..'9', '_']);
-      end ;
-   end ;
-end ;
+function IsValidIdent(const Ident: string; AllowDots : Boolean = False): boolean;
+
+Const
+  Alpha = ['A'..'Z', 'a'..'z', '_'];
+  AlphaNum = Alpha + ['0'..'9'];
+  AlphaDot = AlphaNum + ['.'];
+  
+var 
+  i, len: integer;
+  allowed : Set of char;
+  
+begin
+  Len:=Length(Ident);
+  Result:=Len<>0;
+  if Result then 
+    begin
+    result:=Ident[1] in Alpha;
+    if AllowDots then
+      Allowed:=AlphaDot
+    else
+      Allowed:=AlphaNum;
+    I:=2;  
+    While Result and (I<=Len) do
+      begin
+      Result:=Ident[i] in Allowed;
+      Inc(I);
+      end;
+   end;
+end;
 
 
 {   IntToStr returns a string representing the value of Value    }
 {   IntToStr returns a string representing the value of Value    }
 
 

+ 3 - 3
rtl/objpas/sysutils/sysstrh.inc

@@ -35,8 +35,8 @@ type
 const
 const
   { For floattodatetime and VariantToDate }
   { For floattodatetime and VariantToDate }
 {$ifndef FPUNONE}
 {$ifndef FPUNONE}
-  MinDateTime: TDateTime =  -693593.0;     { 01/01/0001 12:00:00.000 AM }
-  MaxDateTime: TDateTime =  2958465.99999; { 12/31/9999 11:59:59.999 PM }
+  MinDateTime: TDateTime =  -693593.0;        { 01/01/0001 12:00:00.000 AM }
+  MaxDateTime: TDateTime =  2958465.99999999; { 12/31/9999 11:59:59.999 PM }
 
 
 {$if defined(FPC_HAS_TYPE_EXTENDED) or defined(FPC_HAS_TYPE_FLOAT128)}
 {$if defined(FPC_HAS_TYPE_EXTENDED) or defined(FPC_HAS_TYPE_FLOAT128)}
   MinCurrency: Currency = -922337203685477.5808;
   MinCurrency: Currency = -922337203685477.5808;
@@ -103,7 +103,7 @@ function AnsiDequotedStr(const S: string; AQuote: Char): string;
 function AnsiExtractQuotedStr(var Src: PChar; Quote: Char): string;
 function AnsiExtractQuotedStr(var Src: PChar; Quote: Char): string;
 function AdjustLineBreaks(const S: string): string;
 function AdjustLineBreaks(const S: string): string;
 function AdjustLineBreaks(const S: string; Style: TTextLineBreakStyle): string;
 function AdjustLineBreaks(const S: string; Style: TTextLineBreakStyle): string;
-function IsValidIdent(const Ident: string): boolean;
+function IsValidIdent(const Ident: string; AllowDots : Boolean = False): boolean;
 function IntToStr(Value: Longint): string;
 function IntToStr(Value: Longint): string;
 function IntToStr(Value: Int64): string;
 function IntToStr(Value: Int64): string;
 function IntToStr(Value: QWord): string;
 function IntToStr(Value: QWord): string;