소스 검색

* Amended fix from Bruno Fierens to handle CR/LF in GetNextLineBreak

michael 4 년 전
부모
커밋
caca92c60d
1개의 변경된 파일21개의 추가작업 그리고 6개의 파일을 삭제
  1. 21 6
      packages/rtl/classes.pas

+ 21 - 6
packages/rtl/classes.pas

@@ -3224,19 +3224,34 @@ end;
 
 function TStrings.GetNextLinebreak(const Value: String; out S: String; var P: Integer): Boolean;
 
-Var
-  PP : Integer;
+var
+  PPLF,PPCR,PP,PL: Integer;
 
 begin
   S:='';
   Result:=False;
   If ((Length(Value)-P)<0) then
-    exit;
-  PP:=TJSString(Value).IndexOf(LineBreak,P-1)+1;
-  if (PP<1) then
+    Exit;
+  PPLF:=TJSString(Value).IndexOf(#10,P-1)+1;
+  PPCR:=TJSString(Value).IndexOf(#13,P-1)+1;
+  PL:=1;
+  if (PPLF>0) and (PPCR>0) then
+    begin
+    if (PPLF-PPCR)=1 then 
+      PL:=2;
+    if PPLF<PPCR then
+      PP:=PPLF
+    else
+      PP:=PPCR;
+    end
+  else if (PPLF>0) and (PPCR<1) then
+    PP:=PPLF
+  else if (PPCR > 0) and (PPLF<1) then
+    PP:=PPCR
+  else 
     PP:=Length(Value)+1;
   S:=Copy(Value,P,PP-P);
-  P:=PP+length(LineBreak);
+  P:=PP+PL;
   Result:=True;
 end;