소스 검색

* AlwaysQuote added (bug ID 31126)

git-svn-id: trunk@35333 -
michael 8 년 전
부모
커밋
f0a8355b84
2개의 변경된 파일15개의 추가작업 그리고 6개의 파일을 삭제
  1. 2 0
      rtl/objpas/classes/classesh.inc
  2. 13 6
      rtl/objpas/classes/stringl.inc

+ 2 - 0
rtl/objpas/classes/classesh.inc

@@ -603,6 +603,7 @@ type
     FDefaultEncoding: TEncoding;
     FEncoding: TEncoding;
     FSpecialCharsInited : boolean;
+    FAlwaysQuote: Boolean;
     FQuoteChar : Char;
     FDelimiter : Char;
     FNameValueSeparator : Char;
@@ -707,6 +708,7 @@ type
     property Encoding: TEncoding read FEncoding;
     property LineBreak : string Read GetLineBreak write SetLineBreak;
     Property StrictDelimiter : Boolean Read FStrictDelimiter Write FStrictDelimiter;
+    property AlwaysQuote: Boolean read FAlwaysQuote write FAlwaysQuote;
     property QuoteChar: Char read GetQuoteChar write SetQuoteChar;
     Property NameValueSeparator : Char Read GetNameValueSeparator Write SetNameValueSeparator;
     property ValueFromIndex[Index: Integer]: string read GetValueFromIndex write SetValueFromIndex;

+ 13 - 6
rtl/objpas/classes/stringl.inc

@@ -200,7 +200,8 @@ Var
   p : pchar;
   BreakChars : set of char;
   S : String;
-  
+  doQuote : Boolean;
+    
 begin
   CheckSpecialChars;
   result:='';
@@ -213,11 +214,16 @@ begin
   For i:=0 to count-1 do
     begin
     S:=Strings[i];
-    p:=pchar(S);
-    //Quote strings that include BreakChars:
-    while not(p^ in BreakChars) do
-     inc(p);
-    if (p<>pchar(S)+length(S)) then
+    doQuote:=FAlwaysQuote;
+    If not DoQuote then
+      begin
+      p:=pchar(S);
+      //Quote strings that include BreakChars:
+      while not(p^ in BreakChars) do
+        inc(p);
+      DoQuote:=(p<>pchar(S)+length(S));  
+      end;
+    if DoQuote then
       Result:=Result+QuoteString(S,QuoteChar)
     else
       Result:=Result+S;
@@ -722,6 +728,7 @@ begin
   FDefaultEncoding:=TEncoding.Default;
   FEncoding:=nil;
   FWriteBOM:=True;
+  FAlwaysQuote:=False;
 end;
 
 Function TStrings.Add(const S: string): Integer;