Browse Source

* Patch from Werner Pamler to implement TStringSplitOptions.ExcludeLastEmpty

git-svn-id: trunk@47068 -
michael 4 years ago
parent
commit
5283049a62
2 changed files with 11 additions and 1 deletions
  1. 10 0
      rtl/objpas/sysutils/syshelp.inc
  2. 1 1
      rtl/objpas/sysutils/syshelph.inc

+ 10 - 0
rtl/objpas/sysutils/syshelp.inc

@@ -1232,6 +1232,11 @@ begin
       Inc(Len);
       end;
     end;
+
+  if (TStringSplitOptions.ExcludeLastEmpty=Options) then
+    if (Len > 0) and (Result[Len-1] = '') then
+      dec(Len);
+
   SetLength(Result,Len);
 end;
 
@@ -1318,6 +1323,11 @@ begin
       Inc(Len);
       end;
     end;
+
+  If (TStringSplitOptions.ExcludeLastEmpty=Options) then
+    if (Len > 0) and (Result[Len-1] = '') then
+      dec(Len);
+
   SetLength(Result,Len);
 end;
 

+ 1 - 1
rtl/objpas/sysutils/syshelph.inc

@@ -52,7 +52,7 @@ Type
   TCompareOptions = system.TCompareOptions;
 
 {$SCOPEDENUMS ON}
-  TStringSplitOptions = (None, ExcludeEmpty);
+  TStringSplitOptions = (None, ExcludeEmpty, ExcludeLastEmpty);
 {$SCOPEDENUMS OFF}
 
   { TStringHelper }