Browse Source

* updated ansiexctractquotedstring (more delphi compat, both interface and code)

marco 21 years ago
parent
commit
d7cc714078
2 changed files with 40 additions and 19 deletions
  1. 35 17
      rtl/objpas/sysutils/sysstr.inc
  2. 5 2
      rtl/objpas/sysutils/sysstrh.inc

+ 35 - 17
rtl/objpas/sysutils/sysstr.inc

@@ -476,25 +476,40 @@ end ;
     deleted to the left and right and double occurances
     of Quote replaced by a single Quote   }
 
-function AnsiExtractQuotedStr(Const Src: PChar; Quote: Char): string;
-var i: integer; P, Q: PChar;
-begin
-P := Src;
-if Src^ = Quote then P := P + 1;
-Q := StrEnd(P);
-if PChar(Q - 1)^ = Quote then Q := Q - 1;
-SetLength(result, Q - P);
-i := 0;
-while P <> Q do begin
-   i := i + 1;
-   result[i] := P^;
-   if (P^ = Quote) and (PChar(P + 1)^ = Quote) then
-      P := P + 1;
-   P := P + 1;
+
+function AnsiExtractQuotedStr(var  Src: PChar; Quote: Char): string;
+var i: integer; P, Q,R: PChar;
+begin
+ P := Src;
+ Q := StrEnd(P);
+ result:='';
+ if P=Q then exit;
+ if P^<>quote then exit;
+ inc(p);
+   
+ setlength(result,(Q-P)+1);
+ R:=@Result[1];
+ i := 0;
+ while P <> Q do 
+   begin
+     R^:=P^; 
+     inc(R);
+     if (P^ = Quote) then
+       begin
+         P := P + 1;
+         if (p^ <> Quote) then
+          begin
+	    dec(R);
+	    break;
+          end;
+       end; 
+     P := P + 1;
    end ;
-SetLength(result, i);
+ src:=p;
+ SetLength(result, (R-pchar(@Result[1])));
 end ;
 
+
 {   AdjustLineBreaks returns S with all CR characters not followed by LF
     replaced with CR/LF  }
 //  under Linux all CR characters or CR/LF combinations should be replaced with LF
@@ -2187,7 +2202,10 @@ const
 
 {
   $Log$
-  Revision 1.16  2004-08-30 18:00:12  michael
+  Revision 1.17  2004-11-16 18:30:35  marco
+   * updated ansiexctractquotedstring (more delphi compat, both interface and code)
+
+  Revision 1.16  2004/08/30 18:00:12  michael
   + Extra index check in IsDelimiter
 
   Revision 1.15  2004/08/07 19:32:35  florian

+ 5 - 2
rtl/objpas/sysutils/sysstrh.inc

@@ -107,7 +107,7 @@ function TrimLeft(const S: string): string;
 function TrimRight(const S: string): string;
 function QuotedStr(const S: string): string;
 function AnsiQuotedStr(const S: string; Quote: char): string;
-function AnsiExtractQuotedStr(Const Src: PChar; Quote: Char): string;
+function AnsiExtractQuotedStr(var Src: PChar; Quote: Char): string;
 function AdjustLineBreaks(const S: string): string;
 function AdjustLineBreaks(const S: string; Style: TTextLineBreakStyle): string;
 function IsValidIdent(const Ident: string): boolean;
@@ -193,7 +193,10 @@ function BCDToInt(Value: integer): integer;
 
 {
   $Log$
-  Revision 1.9  2004-08-30 13:07:03  michael
+  Revision 1.10  2004-11-16 18:30:36  marco
+   * updated ansiexctractquotedstring (more delphi compat, both interface and code)
+
+  Revision 1.9  2004/08/30 13:07:03  michael
   + Added MACOS linebreakstyle (tlbsCR)
 
   Revision 1.8  2004/08/07 16:56:28  florian