summaryrefslogtreecommitdiff
path: root/packages/fcl-xml
diff options
context:
space:
mode:
authorsergei <sergei@3ad0048d-3df7-0310-abae-a5850022a9f2>2010-10-30 10:25:33 +0000
committersergei <sergei@3ad0048d-3df7-0310-abae-a5850022a9f2>2010-10-30 10:25:33 +0000
commit34322eef37bb9836ae8e3416a6e9c609ab568342 (patch)
tree4c4879b75d7998c31218599c3ce5b2df7fdf6473 /packages/fcl-xml
parentda66726984f4ab8fc9e879642d0a1b0c416d6401 (diff)
downloadfpc-34322eef37bb9836ae8e3416a6e9c609ab568342.tar.gz
* xmlread.pp: since FIdRefs and FNotationRefs are never used at the same time (the former is used only while parsing root, the latter only while parsing DTD), simplify things a bit by replacing them with a single FForwardRefs.
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@16259 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/fcl-xml')
-rw-r--r--packages/fcl-xml/src/xmlread.pp46
1 files changed, 21 insertions, 25 deletions
diff --git a/packages/fcl-xml/src/xmlread.pp b/packages/fcl-xml/src/xmlread.pp
index 45abc60023..231aeb036c 100644
--- a/packages/fcl-xml/src/xmlread.pp
+++ b/packages/fcl-xml/src/xmlread.pp
@@ -294,8 +294,7 @@ type
FDocType: TDOMDocumentTypeEx; // a shortcut
FPEMap: THashTable;
FGEMap: THashTable;
- FIDRefs: TFPList;
- FNotationRefs: TFPList;
+ FForwardRefs: TFPList;
FCurrContentType: TElementContentType;
FSaViolation: Boolean;
FDTDStartPos: PWideChar;
@@ -337,8 +336,8 @@ type
procedure StoreLocation(out Loc: TLocation);
function ValidateAttrSyntax(AttrDef: TAttributeDef; const aValue: WideString): Boolean;
procedure ValidateAttrValue(Attr: TDOMAttr; const aValue: WideString);
- procedure AddForwardRef(aList: TFPList; Buf: PWideChar; Length: Integer);
- procedure ClearRefs(aList: TFPList);
+ procedure AddForwardRef(Buf: PWideChar; Length: Integer);
+ procedure ClearForwardRefs;
procedure ValidateIdRefs;
procedure StandaloneError(LineOffs: Integer = 0);
procedure CallErrorHandler(E: EXMLReadError);
@@ -1240,8 +1239,7 @@ begin
inherited Create;
BufAllocate(FName, 128);
BufAllocate(FValue, 512);
- FIDRefs := TFPList.Create;
- FNotationRefs := TFPList.Create;
+ FForwardRefs := TFPList.Create;
FAttrChunks := TFPList.Create;
// Set char rules to XML 1.0
@@ -1284,15 +1282,13 @@ begin
FSource.Free;
FPEMap.Free;
FGEMap.Free;
- ClearRefs(FNotationRefs);
- ClearRefs(FIDRefs);
+ ClearForwardRefs;
FNsAttHash.Free;
FNSHelper.Free;
if FOwnsDoctype then
FDocType.Free;
- FNotationRefs.Free;
- FIDRefs.Free;
+ FForwardRefs.Free;
FAttrChunks.Free;
inherited Destroy;
end;
@@ -2404,7 +2400,7 @@ begin
ValidationError('Duplicate token in NOTATION attribute declaration',[], FName.Length);
if not DiscardIt then
- AddForwardRef(FNotationRefs, FName.Buffer, FName.Length);
+ AddForwardRef(FName.Buffer, FName.Length);
SkipWhitespace;
until not CheckForChar('|');
ExpectChar(')');
@@ -2519,7 +2515,7 @@ begin
ExpectWhitespace;
StoreLocation(FTokenStart);
Entity.FNotationName := ExpectName;
- AddForwardRef(FNotationRefs, FName.Buffer, FName.Length);
+ AddForwardRef(FName.Buffer, FName.Length);
// SAX: DTDHandler.UnparsedEntityDecl(...);
end;
end;
@@ -3180,34 +3176,34 @@ begin
end;
end;
-procedure TXMLReader.AddForwardRef(aList: TFPList; Buf: PWideChar; Length: Integer);
+procedure TXMLReader.AddForwardRef(Buf: PWideChar; Length: Integer);
var
w: PForwardRef;
begin
New(w);
SetString(w^.Value, Buf, Length);
w^.Loc := FTokenStart;
- aList.Add(w);
+ FForwardRefs.Add(w);
end;
-procedure TXMLReader.ClearRefs(aList: TFPList);
+procedure TXMLReader.ClearForwardRefs;
var
I: Integer;
begin
- for I := 0 to aList.Count-1 do
- Dispose(PForwardRef(aList.List^[I]));
- aList.Clear;
+ for I := 0 to FForwardRefs.Count-1 do
+ Dispose(PForwardRef(FForwardRefs.List^[I]));
+ FForwardRefs.Clear;
end;
procedure TXMLReader.ValidateIdRefs;
var
I: Integer;
begin
- for I := 0 to FIDRefs.Count-1 do
- with PForwardRef(FIDRefs.List^[I])^ do
+ for I := 0 to FForwardRefs.Count-1 do
+ with PForwardRef(FForwardRefs.List^[I])^ do
if Doc.GetElementById(Value) = nil then
DoErrorPos(esError, Format('The ID ''%s'' does not match any element', [Value]), Loc);
- ClearRefs(FIDRefs);
+ ClearForwardRefs;
end;
procedure TXMLReader.ProcessDefaultAttributes(ElDef: TElementDecl);
@@ -3387,7 +3383,7 @@ begin
EndPos := StartPos;
while (EndPos <= L) and (aValue[EndPos] <> #32) do
Inc(EndPos);
- AddForwardRef(FIDRefs, @aValue[StartPos], EndPos-StartPos);
+ AddForwardRef(@aValue[StartPos], EndPos-StartPos);
StartPos := EndPos + 1;
end;
end;
@@ -3427,11 +3423,11 @@ var
I: Integer;
begin
if FValidate then
- for I := 0 to FNotationRefs.Count-1 do
- with PForwardRef(FNotationRefs[I])^ do
+ for I := 0 to FForwardRefs.Count-1 do
+ with PForwardRef(FForwardRefs[I])^ do
if FDocType.Notations.GetNamedItem(Value) = nil then
DoErrorPos(esError, Format('Notation ''%s'' is not declared', [Value]), Loc);
- ClearRefs(FNotationRefs);
+ ClearForwardRefs;
end;
procedure TXMLReader.DoText(ch: PWideChar; Count: Integer; Whitespace: Boolean);