AggPas: Simplified XML parsing code and removed horrible gotos. Patch from Anton Kavalenka, issue #40997.

This change also allows to workaround the following FPC 3.3.1 issue:
https://gitlab.com/freepascal.org/fpc/source/-/issues/40765
This commit is contained in:
Maxim Ganetsky 2024-06-23 17:40:56 +03:00
parent 83675a15d8
commit 04a06d06cc

View File

@ -872,33 +872,15 @@ end;
{ poolCopyString } { poolCopyString }
function poolCopyString(pool : STRING_POOL_ptr; s : XML_Char_ptr ) : XML_Char_ptr; function poolCopyString(pool : STRING_POOL_ptr; s : XML_Char_ptr ) : XML_Char_ptr;
label
_w0 ;
begin begin
goto _w0; repeat
if (poolAppendChar(pool, s^)=0) then
while s^ <> XML_Char(0 ) do exit(nil);
begin
_w0:
if poolAppendChar(pool ,s^ ) = 0 then
begin
result:=NIL;
exit;
end;
inc(ptrcomp(s ) ,sizeof(XML_Char ) ); inc(ptrcomp(s ) ,sizeof(XML_Char ) );
until s^ = XML_Char(0 );
end;
s := pool.start; s := pool.start;
poolFinish(pool); poolFinish(pool);
result:=s; result:=s;
end; end;
{ poolAppendString {..} { poolAppendString {..}
@ -1376,10 +1358,6 @@ var
da : DEFAULT_ATTRIBUTE_ptr; da : DEFAULT_ATTRIBUTE_ptr;
p : TAG_ptr; p : TAG_ptr;
label
_w0 ,_w1 ;
begin begin
uri:=nil; uri:=nil;
dtd:=parser.m_dtd; { save one level of indirection } dtd:=parser.m_dtd; { save one level of indirection }
@ -1796,26 +1774,16 @@ begin
while s^ <> XML_T(':' ) do while s^ <> XML_T(':' ) do
inc(ptrcomp(s ) ,sizeof(XML_Char ) ); inc(ptrcomp(s ) ,sizeof(XML_Char ) );
goto _w0; repeat
while s^ <> XML_Char(0 ) do { copies null terminator }
begin
_w0:
c:=s^; c:=s^;
if poolAppendChar(@parser.m_tempPool ,s^ ) = 0 then if poolAppendChar(@parser.m_tempPool ,s^ ) = 0 then
begin begin
result:=XML_ERROR_NO_MEMORY; result:=XML_ERROR_NO_MEMORY;
exit; exit;
end; end;
uriHash:=CHAR_HASH(uriHash ,c ); uriHash:=CHAR_HASH(uriHash ,c );
inc(ptrcomp(s ) ,sizeof(XML_Char ) ); inc(ptrcomp(s ) ,sizeof(XML_Char ) );
until s^ = XML_Char(0 );
end;
{ Check hash table for duplicate of expanded name (uriName). { Check hash table for duplicate of expanded name (uriName).
Derived from code in lookup(HASH_TABLE *table, ...). } Derived from code in lookup(HASH_TABLE *table, ...). }
@ -1866,23 +1834,14 @@ begin
s:=b.prefix.name; s:=b.prefix.name;
goto _w1; repeat
while s^ <> XML_Char(0 ) do
begin
_w1:
if poolAppendChar(@parser.m_tempPool ,s^ ) = 0 then if poolAppendChar(@parser.m_tempPool ,s^ ) = 0 then
begin begin
result:=XML_ERROR_NO_MEMORY; result:=XML_ERROR_NO_MEMORY;
exit; exit;
end; end;
inc(ptrcomp(s ) ,sizeof(XML_Char ) ); inc(ptrcomp(s ) ,sizeof(XML_Char ) );
until s^ = XML_Char(0 );
end;
end; end;
{ store expanded name in attribute list } { store expanded name in attribute list }