Browse Source

* The fix in r15551 was not entirely correct. Must handle the case when string ends with a single whitespace.

git-svn-id: trunk@15570 -
sergei 15 years ago
parent
commit
1a50f3ed26
2 changed files with 11 additions and 8 deletions
  1. 5 4
      packages/fcl-xml/src/sax_html.pp
  2. 6 4
      packages/fcl-xml/src/sax_xml.pp

+ 5 - 4
packages/fcl-xml/src/sax_html.pp

@@ -325,11 +325,12 @@ var
   DoIncJ: Boolean;
   DoIncJ: Boolean;
 begin
 begin
   Attr := nil;
   Attr := nil;
-  i := 1;
-  while (i <= Length(s)) and not IsXMLWhitespace(s[i]) do
-    Inc(i);
+  i := 0;
+  repeat
+    Inc(i)
+  until (i > Length(s)) or IsXMLWhitespace(s[i]);
 
 
-  if i = Length(s) then
+  if i > Length(s) then
     Result := s
     Result := s
   else
   else
   begin
   begin

+ 6 - 4
packages/fcl-xml/src/sax_xml.pp

@@ -272,10 +272,12 @@ procedure TSAXXMLReader.EnterNewScannerContext(NewContext: TXMLScannerContext);
     DoIncJ: Boolean;
     DoIncJ: Boolean;
   begin
   begin
     Attr := nil;
     Attr := nil;
-    i := 1;
-    while (i <= Length(s)) and not (s[i] in WhitespaceChars) do
-      Inc(i);
-    if i = Length(s) then
+    i := 0;
+    repeat
+      Inc(i)
+    until (i > Length(s)) or (s[i] in WhitespaceChars);
+
+    if i > Length(s) then
       Result := LowerCase(s)
       Result := LowerCase(s)
     else
     else
     begin
     begin