summaryrefslogtreecommitdiff
path: root/src/corelib/render/software/agg-demos/expat-pas
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/render/software/agg-demos/expat-pas')
-rw-r--r--[-rwxr-xr-x]src/corelib/render/software/agg-demos/expat-pas/ascii.inc232
-rw-r--r--[-rwxr-xr-x]src/corelib/render/software/agg-demos/expat-pas/asciitab.inc134
-rw-r--r--[-rwxr-xr-x]src/corelib/render/software/agg-demos/expat-pas/asciitab_bt_colon_.inc134
-rw-r--r--[-rwxr-xr-x]src/corelib/render/software/agg-demos/expat-pas/expat.pas1796
-rw-r--r--[-rwxr-xr-x]src/corelib/render/software/agg-demos/expat-pas/expat_basics.pas436
-rw-r--r--[-rwxr-xr-x]src/corelib/render/software/agg-demos/expat-pas/expat_external.inc294
-rw-r--r--[-rwxr-xr-x]src/corelib/render/software/agg-demos/expat-pas/expat_external.pas104
-rw-r--r--[-rwxr-xr-x]src/corelib/render/software/agg-demos/expat-pas/expat_mode.inc184
-rw-r--r--[-rwxr-xr-x]src/corelib/render/software/agg-demos/expat-pas/iasciitab.inc138
-rw-r--r--[-rwxr-xr-x]src/corelib/render/software/agg-demos/expat-pas/iasciitab_bt_colon_.inc136
-rw-r--r--[-rwxr-xr-x]src/corelib/render/software/agg-demos/expat-pas/readme.txt208
-rw-r--r--[-rwxr-xr-x]src/corelib/render/software/agg-demos/expat-pas/utf8tab.inc134
-rw-r--r--[-rwxr-xr-x]src/corelib/render/software/agg-demos/expat-pas/winconfig.inc104
-rw-r--r--[-rwxr-xr-x]src/corelib/render/software/agg-demos/expat-pas/xmlparse.inc12950
-rw-r--r--[-rwxr-xr-x]src/corelib/render/software/agg-demos/expat-pas/xmlrole.pas1318
-rw-r--r--[-rwxr-xr-x]src/corelib/render/software/agg-demos/expat-pas/xmltok.pas3196
-rw-r--r--[-rwxr-xr-x]src/corelib/render/software/agg-demos/expat-pas/xmltok_impl.inc8352
-rw-r--r--[-rwxr-xr-x]src/corelib/render/software/agg-demos/expat-pas/xmltok_ns.inc352
18 files changed, 15101 insertions, 15101 deletions
diff --git a/src/corelib/render/software/agg-demos/expat-pas/ascii.inc b/src/corelib/render/software/agg-demos/expat-pas/ascii.inc
index a0abb31e..5630767f 100755..100644
--- a/src/corelib/render/software/agg-demos/expat-pas/ascii.inc
+++ b/src/corelib/render/software/agg-demos/expat-pas/ascii.inc
@@ -1,116 +1,116 @@
-//----------------------------------------------------------------------------
-// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
-// and Clark Cooper
-// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
-//
-// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
-// Pascal Port By: Milan Marusinec alias Milano
-// milan@marusinec.sk
-// http://www.pasports.org/pasexpat
-// Copyright (c) 2006
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// [Pascal Port History] -----------------------------------------------------
-//
-// 17.05.2006-Milano: Unit port establishment
-//
-{ ascii.inc }
- ASCII_A = char($41 );
- ASCII_B = char($42 );
- ASCII_C = char($43 );
- ASCII_D = char($44 );
- ASCII_E = char($45 );
- ASCII_F = char($46 );
- ASCII_G = char($47 );
- ASCII_H = char($48 );
- ASCII_I = char($49 );
- ASCII_J = char($4A );
- ASCII_K = char($4B );
- ASCII_L = char($4C );
- ASCII_M = char($4D );
- ASCII_N = char($4E );
- ASCII_O = char($4F );
- ASCII_P = char($50 );
- ASCII_Q = char($51 );
- ASCII_R = char($52 );
- ASCII_S = char($53 );
- ASCII_T = char($54 );
- ASCII_U = char($55 );
- ASCII_V = char($56 );
- ASCII_W = char($57 );
- ASCII_X = char($58 );
- ASCII_Y = char($59 );
- ASCII_Z = char($5A );
-
- ASCII_al = char($61 );
- ASCII_bl = char($62 );
- ASCII_cl = char($63 );
- ASCII_dl = char($64 );
- ASCII_el = char($65 );
- ASCII_fl = char($66 );
- ASCII_gl = char($67 );
- ASCII_hl = char($68 );
- ASCII_il = char($69 );
- ASCII_jl = char($6A );
- ASCII_kl = char($6B );
- ASCII_ll = char($6C );
- ASCII_ml = char($6D );
- ASCII_nl = char($6E );
- ASCII_ol = char($6F );
- ASCII_pl = char($70 );
- ASCII_ql = char($71 );
- ASCII_rl = char($72 );
- ASCII_sl = char($73 );
- ASCII_tl = char($74 );
- ASCII_ul = char($75 );
- ASCII_vl = char($76 );
- ASCII_wl = char($77 );
- ASCII_xl = char($78 );
- ASCII_yl = char($79 );
- ASCII_zl = char($7A );
-
- ASCII_0 = char($30 );
- ASCII_1 = char($31 );
- ASCII_2 = char($32 );
- ASCII_3 = char($33 );
- ASCII_4 = char($34 );
- ASCII_5 = char($35 );
- ASCII_6 = char($36 );
- ASCII_7 = char($37 );
- ASCII_8 = char($38 );
- ASCII_9 = char($39 );
-
- ASCII_TAB = char($09 );
- ASCII_SPACE = char($20 );
- ASCII_EXCL = char($21 );
- ASCII_QUOT = char($22 );
- ASCII_AMP = char($26 );
- ASCII_APOS = char($27 );
- ASCII_MINUS = char($2D );
- ASCII_PERIOD = char($2E );
- ASCII_COLON = char($3A );
- ASCII_SEMI = char($3B );
- ASCII_LT = char($3C );
- ASCII_EQUALS = char($3D );
- ASCII_GT = char($3E );
- ASCII_LSQB = char($5B );
- ASCII_RSQB = char($5D );
- ASCII_UNDERSCORE = char($5F );
+//----------------------------------------------------------------------------
+// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+// and Clark Cooper
+// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
+//
+// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
+// Pascal Port By: Milan Marusinec alias Milano
+// milan@marusinec.sk
+// http://www.pasports.org/pasexpat
+// Copyright (c) 2006
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// [Pascal Port History] -----------------------------------------------------
+//
+// 17.05.2006-Milano: Unit port establishment
+//
+{ ascii.inc }
+ ASCII_A = char($41 );
+ ASCII_B = char($42 );
+ ASCII_C = char($43 );
+ ASCII_D = char($44 );
+ ASCII_E = char($45 );
+ ASCII_F = char($46 );
+ ASCII_G = char($47 );
+ ASCII_H = char($48 );
+ ASCII_I = char($49 );
+ ASCII_J = char($4A );
+ ASCII_K = char($4B );
+ ASCII_L = char($4C );
+ ASCII_M = char($4D );
+ ASCII_N = char($4E );
+ ASCII_O = char($4F );
+ ASCII_P = char($50 );
+ ASCII_Q = char($51 );
+ ASCII_R = char($52 );
+ ASCII_S = char($53 );
+ ASCII_T = char($54 );
+ ASCII_U = char($55 );
+ ASCII_V = char($56 );
+ ASCII_W = char($57 );
+ ASCII_X = char($58 );
+ ASCII_Y = char($59 );
+ ASCII_Z = char($5A );
+
+ ASCII_al = char($61 );
+ ASCII_bl = char($62 );
+ ASCII_cl = char($63 );
+ ASCII_dl = char($64 );
+ ASCII_el = char($65 );
+ ASCII_fl = char($66 );
+ ASCII_gl = char($67 );
+ ASCII_hl = char($68 );
+ ASCII_il = char($69 );
+ ASCII_jl = char($6A );
+ ASCII_kl = char($6B );
+ ASCII_ll = char($6C );
+ ASCII_ml = char($6D );
+ ASCII_nl = char($6E );
+ ASCII_ol = char($6F );
+ ASCII_pl = char($70 );
+ ASCII_ql = char($71 );
+ ASCII_rl = char($72 );
+ ASCII_sl = char($73 );
+ ASCII_tl = char($74 );
+ ASCII_ul = char($75 );
+ ASCII_vl = char($76 );
+ ASCII_wl = char($77 );
+ ASCII_xl = char($78 );
+ ASCII_yl = char($79 );
+ ASCII_zl = char($7A );
+
+ ASCII_0 = char($30 );
+ ASCII_1 = char($31 );
+ ASCII_2 = char($32 );
+ ASCII_3 = char($33 );
+ ASCII_4 = char($34 );
+ ASCII_5 = char($35 );
+ ASCII_6 = char($36 );
+ ASCII_7 = char($37 );
+ ASCII_8 = char($38 );
+ ASCII_9 = char($39 );
+
+ ASCII_TAB = char($09 );
+ ASCII_SPACE = char($20 );
+ ASCII_EXCL = char($21 );
+ ASCII_QUOT = char($22 );
+ ASCII_AMP = char($26 );
+ ASCII_APOS = char($27 );
+ ASCII_MINUS = char($2D );
+ ASCII_PERIOD = char($2E );
+ ASCII_COLON = char($3A );
+ ASCII_SEMI = char($3B );
+ ASCII_LT = char($3C );
+ ASCII_EQUALS = char($3D );
+ ASCII_GT = char($3E );
+ ASCII_LSQB = char($5B );
+ ASCII_RSQB = char($5D );
+ ASCII_UNDERSCORE = char($5F );
diff --git a/src/corelib/render/software/agg-demos/expat-pas/asciitab.inc b/src/corelib/render/software/agg-demos/expat-pas/asciitab.inc
index ca3bec48..4da035d6 100755..100644
--- a/src/corelib/render/software/agg-demos/expat-pas/asciitab.inc
+++ b/src/corelib/render/software/agg-demos/expat-pas/asciitab.inc
@@ -1,67 +1,67 @@
-//----------------------------------------------------------------------------
-// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
-// and Clark Cooper
-// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
-//
-// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
-// Pascal Port By: Milan Marusinec alias Milano
-// milan@marusinec.sk
-// http://www.pasports.org/pasexpat
-// Copyright (c) 2006
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// [Pascal Port History] -----------------------------------------------------
-//
-// 11.06.2006-Milano: Unit port establishment
-//
-{ asciitab.inc }
-{ $00 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $04 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $08 } BT_NONXML ,BT_S ,BT_LF ,BT_NONXML ,
-{ $0C } BT_NONXML ,BT_CR ,BT_NONXML ,BT_NONXML ,
-{ $10 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $14 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $18 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $1C } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $20 } BT_S ,BT_EXCL ,BT_QUOT ,BT_NUM ,
-{ $24 } BT_OTHER ,BT_PERCNT ,BT_AMP ,BT_APOS ,
-{ $28 } BT_LPAR ,BT_RPAR ,BT_AST ,BT_PLUS ,
-{ $2C } BT_COMMA ,BT_MINUS ,BT_NAME ,BT_SOL ,
-{ $30 } BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,
-{ $34 } BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,
-{ $38 } BT_DIGIT ,BT_DIGIT ,BT_COLON ,BT_SEMI ,
-{ $3C } BT_LT ,BT_EQUALS ,BT_GT ,BT_QUEST ,
-{ $40 } BT_OTHER ,BT_HEX ,BT_HEX ,BT_HEX ,
-{ $44 } BT_HEX ,BT_HEX ,BT_HEX ,BT_NMSTRT ,
-{ $48 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $4C } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $50 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $54 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $58 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_LSQB ,
-{ $5C } BT_OTHER ,BT_RSQB ,BT_OTHER ,BT_NMSTRT ,
-{ $60 } BT_OTHER ,BT_HEX ,BT_HEX ,BT_HEX ,
-{ $64 } BT_HEX ,BT_HEX ,BT_HEX ,BT_NMSTRT ,
-{ $68 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $6C } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $70 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $74 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $78 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_OTHER ,
-{ $7C } BT_VERBAR ,BT_OTHER ,BT_OTHER ,BT_OTHER ,
+//----------------------------------------------------------------------------
+// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+// and Clark Cooper
+// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
+//
+// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
+// Pascal Port By: Milan Marusinec alias Milano
+// milan@marusinec.sk
+// http://www.pasports.org/pasexpat
+// Copyright (c) 2006
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// [Pascal Port History] -----------------------------------------------------
+//
+// 11.06.2006-Milano: Unit port establishment
+//
+{ asciitab.inc }
+{ $00 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $04 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $08 } BT_NONXML ,BT_S ,BT_LF ,BT_NONXML ,
+{ $0C } BT_NONXML ,BT_CR ,BT_NONXML ,BT_NONXML ,
+{ $10 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $14 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $18 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $1C } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $20 } BT_S ,BT_EXCL ,BT_QUOT ,BT_NUM ,
+{ $24 } BT_OTHER ,BT_PERCNT ,BT_AMP ,BT_APOS ,
+{ $28 } BT_LPAR ,BT_RPAR ,BT_AST ,BT_PLUS ,
+{ $2C } BT_COMMA ,BT_MINUS ,BT_NAME ,BT_SOL ,
+{ $30 } BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,
+{ $34 } BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,
+{ $38 } BT_DIGIT ,BT_DIGIT ,BT_COLON ,BT_SEMI ,
+{ $3C } BT_LT ,BT_EQUALS ,BT_GT ,BT_QUEST ,
+{ $40 } BT_OTHER ,BT_HEX ,BT_HEX ,BT_HEX ,
+{ $44 } BT_HEX ,BT_HEX ,BT_HEX ,BT_NMSTRT ,
+{ $48 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $4C } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $50 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $54 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $58 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_LSQB ,
+{ $5C } BT_OTHER ,BT_RSQB ,BT_OTHER ,BT_NMSTRT ,
+{ $60 } BT_OTHER ,BT_HEX ,BT_HEX ,BT_HEX ,
+{ $64 } BT_HEX ,BT_HEX ,BT_HEX ,BT_NMSTRT ,
+{ $68 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $6C } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $70 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $74 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $78 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_OTHER ,
+{ $7C } BT_VERBAR ,BT_OTHER ,BT_OTHER ,BT_OTHER ,
diff --git a/src/corelib/render/software/agg-demos/expat-pas/asciitab_bt_colon_.inc b/src/corelib/render/software/agg-demos/expat-pas/asciitab_bt_colon_.inc
index 9a796a70..6abf8df5 100755..100644
--- a/src/corelib/render/software/agg-demos/expat-pas/asciitab_bt_colon_.inc
+++ b/src/corelib/render/software/agg-demos/expat-pas/asciitab_bt_colon_.inc
@@ -1,67 +1,67 @@
-//----------------------------------------------------------------------------
-// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
-// and Clark Cooper
-// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
-//
-// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
-// Pascal Port By: Milan Marusinec alias Milano
-// milan@marusinec.sk
-// http://www.pasports.org/pasexpat
-// Copyright (c) 2006
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// [Pascal Port History] -----------------------------------------------------
-//
-// 11.06.2006-Milano: Unit port establishment
-//
-{ asciitab_bt_colon_.inc }
-{ $00 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $04 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $08 } BT_NONXML ,BT_S ,BT_LF ,BT_NONXML ,
-{ $0C } BT_NONXML ,BT_CR ,BT_NONXML ,BT_NONXML ,
-{ $10 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $14 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $18 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $1C } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $20 } BT_S ,BT_EXCL ,BT_QUOT ,BT_NUM ,
-{ $24 } BT_OTHER ,BT_PERCNT ,BT_AMP ,BT_APOS ,
-{ $28 } BT_LPAR ,BT_RPAR ,BT_AST ,BT_PLUS ,
-{ $2C } BT_COMMA ,BT_MINUS ,BT_NAME ,BT_SOL ,
-{ $30 } BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,
-{ $34 } BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,
-{ $38 } BT_DIGIT ,BT_DIGIT ,BT_COLON_ ,BT_SEMI ,
-{ $3C } BT_LT ,BT_EQUALS ,BT_GT ,BT_QUEST ,
-{ $40 } BT_OTHER ,BT_HEX ,BT_HEX ,BT_HEX ,
-{ $44 } BT_HEX ,BT_HEX ,BT_HEX ,BT_NMSTRT ,
-{ $48 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $4C } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $50 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $54 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $58 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_LSQB ,
-{ $5C } BT_OTHER ,BT_RSQB ,BT_OTHER ,BT_NMSTRT ,
-{ $60 } BT_OTHER ,BT_HEX ,BT_HEX ,BT_HEX ,
-{ $64 } BT_HEX ,BT_HEX ,BT_HEX ,BT_NMSTRT ,
-{ $68 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $6C } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $70 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $74 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $78 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_OTHER ,
-{ $7C } BT_VERBAR ,BT_OTHER ,BT_OTHER ,BT_OTHER ,
+//----------------------------------------------------------------------------
+// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+// and Clark Cooper
+// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
+//
+// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
+// Pascal Port By: Milan Marusinec alias Milano
+// milan@marusinec.sk
+// http://www.pasports.org/pasexpat
+// Copyright (c) 2006
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// [Pascal Port History] -----------------------------------------------------
+//
+// 11.06.2006-Milano: Unit port establishment
+//
+{ asciitab_bt_colon_.inc }
+{ $00 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $04 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $08 } BT_NONXML ,BT_S ,BT_LF ,BT_NONXML ,
+{ $0C } BT_NONXML ,BT_CR ,BT_NONXML ,BT_NONXML ,
+{ $10 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $14 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $18 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $1C } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $20 } BT_S ,BT_EXCL ,BT_QUOT ,BT_NUM ,
+{ $24 } BT_OTHER ,BT_PERCNT ,BT_AMP ,BT_APOS ,
+{ $28 } BT_LPAR ,BT_RPAR ,BT_AST ,BT_PLUS ,
+{ $2C } BT_COMMA ,BT_MINUS ,BT_NAME ,BT_SOL ,
+{ $30 } BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,
+{ $34 } BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,
+{ $38 } BT_DIGIT ,BT_DIGIT ,BT_COLON_ ,BT_SEMI ,
+{ $3C } BT_LT ,BT_EQUALS ,BT_GT ,BT_QUEST ,
+{ $40 } BT_OTHER ,BT_HEX ,BT_HEX ,BT_HEX ,
+{ $44 } BT_HEX ,BT_HEX ,BT_HEX ,BT_NMSTRT ,
+{ $48 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $4C } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $50 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $54 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $58 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_LSQB ,
+{ $5C } BT_OTHER ,BT_RSQB ,BT_OTHER ,BT_NMSTRT ,
+{ $60 } BT_OTHER ,BT_HEX ,BT_HEX ,BT_HEX ,
+{ $64 } BT_HEX ,BT_HEX ,BT_HEX ,BT_NMSTRT ,
+{ $68 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $6C } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $70 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $74 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $78 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_OTHER ,
+{ $7C } BT_VERBAR ,BT_OTHER ,BT_OTHER ,BT_OTHER ,
diff --git a/src/corelib/render/software/agg-demos/expat-pas/expat.pas b/src/corelib/render/software/agg-demos/expat-pas/expat.pas
index c4c7ddce..0fb4f42d 100755..100644
--- a/src/corelib/render/software/agg-demos/expat-pas/expat.pas
+++ b/src/corelib/render/software/agg-demos/expat-pas/expat.pas
@@ -1,898 +1,898 @@
-//----------------------------------------------------------------------------
-// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
-// and Clark Cooper
-// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
-//
-// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
-// Pascal Port By: Milan Marusinec alias Milano
-// milan@marusinec.sk
-// http://www.pasports.org/pasexpat
-// Copyright (c) 2006
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// [Pascal Port History] -----------------------------------------------------
-//
-// 01.05.2006-Milano: Unit port establishment
-// 07.06.2006-Milano: porting
-//
-{ expat.pas }
-unit
- expat ;
-
-INTERFACE
-
-uses
- expat_basics ,
- xmltok ,
- xmlrole ;
-
-{$I expat_mode.inc }
-
-{ TYPES DEFINITION }
-type
-{$I expat_external.inc }
-
- XML_Parser = ^XML_ParserStruct;
-
- XML_Bool = int8u;
-
-{ The XML_Status enum gives the possible return values for several API functions. }
- XML_Status = (XML_STATUS_ERROR ,XML_STATUS_OK ,XML_STATUS_SUSPENDED );
-
- XML_Error = (
- XML_ERROR_NONE ,
- XML_ERROR_NO_MEMORY ,
- XML_ERROR_SYNTAX ,
- XML_ERROR_NO_ELEMENTS ,
- XML_ERROR_INVALID_TOKEN ,
- XML_ERROR_UNCLOSED_TOKEN ,
- XML_ERROR_PARTIAL_CHAR ,
- XML_ERROR_TAG_MISMATCH ,
- XML_ERROR_DUPLICATE_ATTRIBUTE ,
- XML_ERROR_JUNK_AFTER_DOC_ELEMENT ,
- XML_ERROR_PARAM_ENTITY_REF ,
- XML_ERROR_UNDEFINED_ENTITY ,
- XML_ERROR_RECURSIVE_ENTITY_REF ,
- XML_ERROR_ASYNC_ENTITY ,
- XML_ERROR_BAD_CHAR_REF ,
- XML_ERROR_BINARY_ENTITY_REF ,
- XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF ,
- XML_ERROR_MISPLACED_XML_PI ,
- XML_ERROR_UNKNOWN_ENCODING ,
- XML_ERROR_INCORRECT_ENCODING ,
- XML_ERROR_UNCLOSED_CDATA_SECTION ,
- XML_ERROR_EXTERNAL_ENTITY_HANDLING ,
- XML_ERROR_NOT_STANDALONE ,
- XML_ERROR_UNEXPECTED_STATE ,
- XML_ERROR_ENTITY_DECLARED_IN_PE ,
- XML_ERROR_FEATURE_REQUIRES_XML_DTD ,
- XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING ,
- { Added in 1.95.7. }
- XML_ERROR_UNBOUND_PREFIX ,
- { Added in 1.95.8. }
- XML_ERROR_UNDECLARING_PREFIX ,
- XML_ERROR_INCOMPLETE_PE ,
- XML_ERROR_XML_DECL ,
- XML_ERROR_TEXT_DECL ,
- XML_ERROR_PUBLICID ,
- XML_ERROR_SUSPENDED ,
- XML_ERROR_NOT_SUSPENDED ,
- XML_ERROR_ABORTED ,
- XML_ERROR_FINISHED ,
- XML_ERROR_SUSPEND_PE ,
- { Added in 2.0. }
- XML_ERROR_RESERVED_PREFIX_XML ,
- XML_ERROR_RESERVED_PREFIX_XMLNS ,
- XML_ERROR_RESERVED_NAMESPACE_URI );
-
- XML_Content_Type = (
- ___SKIP_ZERO____ ,
- XML_CTYPE_EMPTY ,
- XML_CTYPE_ANY ,
- XML_CTYPE_MIXED ,
- XML_CTYPE_NAME ,
- XML_CTYPE_CHOICE ,
- XML_CTYPE_SEQ );
-
- XML_Content_Quant = (
- XML_CQUANT_NONE ,
- XML_CQUANT_OPT ,
- XML_CQUANT_REP ,
- XML_CQUANT_PLUS );
-
- XML_ParamEntityParsing = (
- XML_PARAM_ENTITY_PARSING_NEVER ,
- XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE ,
- XML_PARAM_ENTITY_PARSING_ALWAYS );
-
-{ If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be
- XML_CQUANT_NONE, and the other fields will be zero or NULL.
- If type == XML_CTYPE_MIXED, then quant will be NONE or REP and
- numchildren will contain number of elements that may be mixed in
- and children point to an array of XML_Content cells that will be
- all of XML_CTYPE_NAME type with no quantification.
-
- If type == XML_CTYPE_NAME, then the name points to the name, and
- the numchildren field will be zero and children will be NULL. The
- quant fields indicates any quantifiers placed on the name.
-
- CHOICE and SEQ will have name NULL, the number of children in
- numchildren and children will point, recursively, to an array
- of XML_Content cells.
-
- The EMPTY, ANY, and MIXED types will only occur at top level. }
- XML_Content_ptr = ^XML_Content;
-
- XML_cp = record
- type_ : XML_Content_Type;
- quant : XML_Content_Quant;
- name : XML_Char_ptr;
-
- numchildren : unsigned;
- children : XML_Content_ptr;
-
- end;
-
- XML_Content = XML_cp;
-
-{ This is called for an element declaration. See above for
- description of the model argument. It's the caller's responsibility
- to free model when finished with it. }
- XML_ElementDeclHandler = procedure(userData : pointer; name : XML_Char_ptr; model : XML_Content_ptr );
-
-{ The Attlist declaration handler is called for *each* attribute. So
- a single Attlist declaration with multiple attributes declared will
- generate multiple calls to this handler. The "default" parameter
- may be NULL in the case of the "#IMPLIED" or "#REQUIRED"
- keyword. The "isrequired" parameter will be true and the default
- value will be NULL in the case of "#REQUIRED". If "isrequired" is
- true and default is non-NULL, then this is a "#FIXED" default. }
- XML_AttlistDeclHandler = procedure(
- userData : pointer;
- elname ,attname ,att_type ,dflt : XML_Char_ptr;
- isrequired : int );
-
-{ The XML declaration handler is called for *both* XML declarations
- and text declarations. The way to distinguish is that the version
- parameter will be NULL for text declarations. The encoding
- parameter may be NULL for XML declarations. The standalone
- parameter will be -1, 0, or 1 indicating respectively that there
- was no standalone parameter in the declaration, that it was given
- as no, or that it was given as yes. }
- XML_XmlDeclHandler = procedure(userData : pointer; version ,encoding : XML_Char_ptr; standalone : int );
-
-{ This is called for entity declarations. The is_parameter_entity
- argument will be non-zero if the entity is a parameter entity, zero
- otherwise.
-
- For internal entities (<!ENTITY foo "bar">), value will
- be non-NULL and systemId, publicID, and notationName will be NULL.
- The value string is NOT nul-terminated; the length is provided in
- the value_length argument. Since it is legal to have zero-length
- values, do not use this argument to test for internal entities.
-
- For external entities, value will be NULL and systemId will be
- non-NULL. The publicId argument will be NULL unless a public
- identifier was provided. The notationName argument will have a
- non-NULL value only for unparsed entity declarations.
-
- Note that is_parameter_entity can't be changed to XML_Bool, since
- that would break binary compatibility. }
- XML_EntityDeclHandler = procedure(
- userData : pointer;
- entityName : XML_Char_ptr;
- is_parameter_entity : int;
- value : XML_Char_ptr;
- value_length : int;
- base ,systemId ,publicId ,notationName : XML_Char_ptr );
-
-{ atts is array of name/value pairs, terminated by 0;
- names and values are 0 terminated. }
- XML_StartElementHandler = procedure(userData : pointer; name : XML_Char_ptr; atts : XML_Char_ptr_ptr );
- XML_EndElementHandler = procedure(userData : pointer; name : XML_Char_ptr );
-
-{ s is not 0 terminated. }
- XML_CharacterDataHandler = procedure(userData : pointer; s : XML_Char_ptr; len : int );
-
-{ target and data are 0 terminated }
- XML_ProcessingInstructionHandler = procedure(userData : pointer; target ,data : XML_Char_ptr );
-
-{ data is 0 terminated }
- XML_CommentHandler = procedure(userData : pointer; data : XML_Char_ptr );
-
- XML_StartCdataSectionHandler = procedure(userData : pointer );
- XML_EndCdataSectionHandler = procedure(userData : pointer );
-
-
-{ This is called for any characters in the XML document for which
- there is no applicable handler. This includes both characters that
- are part of markup which is of a kind that is not reported
- (comments, markup declarations), or characters that are part of a
- construct which could be reported but for which no handler has been
- supplied. The characters are passed exactly as they were in the XML
- document except that they will be encoded in UTF-8 or UTF-16.
- Line boundaries are not normalized. Note that a byte order mark
- character is not passed to the default handler. There are no
- guarantees about how characters are divided between calls to the
- default handler: for example, a comment might be split between
- multiple calls. }
- XML_DefaultHandler = procedure(userData : pointer; s : XML_Char_ptr; len : int );
-
-{ This is called for the start of the DOCTYPE declaration, before
- any DTD or internal subset is parsed. }
- XML_StartDoctypeDeclHandler = procedure(
- userData : pointer;
- doctypeName ,sysid ,pubid : XML_Char_ptr;
- has_internal_subset : int );
-
-{ This is called for the start of the DOCTYPE declaration when the
- closing > is encountered, but after processing any external
- subset. }
- XML_EndDoctypeDeclHandler = procedure(userData : pointer );
-
-{ OBSOLETE -- OBSOLETE -- OBSOLETE
- This handler has been superceded by the EntityDeclHandler above.
- It is provided here for backward compatibility.
-
- This is called for a declaration of an unparsed (NDATA) entity.
- The base argument is whatever was set by XML_SetBase. The
- entityName, systemId and notationName arguments will never be
- NULL. The other arguments may be. }
- XML_UnparsedEntityDeclHandler = procedure(
- userData : pointer;
- entityName ,base ,systemId ,publicId ,notationName : XML_Char_ptr );
-
-{ This is called for a declaration of notation. The base argument is
- whatever was set by XML_SetBase. The notationName will never be
- NULL. The other arguments can be. }
- XML_NotationDeclHandler = procedure(
- userData : pointer;
- notationName ,base ,systemId ,publicId : XML_Char_ptr );
-
-{ When namespace processing is enabled, these are called once for
- each namespace declaration. The call to the start and end element
- handlers occur between the calls to the start and end namespace
- declaration handlers. For an xmlns attribute, prefix will be
- NULL. For an xmlns="" attribute, uri will be NULL. }
- XML_StartNamespaceDeclHandler = procedure(userData : pointer; prefix ,uri : XML_Char_ptr );
- XML_EndNamespaceDeclHandler = procedure(userData : pointer; prefix : XML_Char_ptr );
-
-{ This is called if the document is not standalone, that is, it has an
- external subset or a reference to a parameter entity, but does not
- have standalone="yes". If this handler returns XML_STATUS_ERROR,
- then processing will not continue, and the parser will return a
- XML_ERROR_NOT_STANDALONE error.
- If parameter entity parsing is enabled, then in addition to the
- conditions above this handler will only be called if the referenced
- entity was actually read. }
- XML_NotStandaloneHandler = function(userData : pointer ) : int;
-
-{ This is called for a reference to an external parsed general
- entity. The referenced entity is not automatically parsed. The
- application can parse it immediately or later using
- XML_ExternalEntityParserCreate.
-
- The parser argument is the parser parsing the entity containing the
- reference; it can be passed as the parser argument to
- XML_ExternalEntityParserCreate. The systemId argument is the
- system identifier as specified in the entity declaration; it will
- not be NULL.
-
- The base argument is the system identifier that should be used as
- the base for resolving systemId if systemId was relative; this is
- set by XML_SetBase; it may be NULL.
-
- The publicId argument is the public identifier as specified in the
- entity declaration, or NULL if none was specified; the whitespace
- in the public identifier will have been normalized as required by
- the XML spec.
-
- The context argument specifies the parsing context in the format
- expected by the context argument to XML_ExternalEntityParserCreate;
- context is valid only until the handler returns, so if the
- referenced entity is to be parsed later, it must be copied.
- context is NULL only when the entity is a parameter entity.
-
- The handler should return XML_STATUS_ERROR if processing should not
- continue because of a fatal error in the handling of the external
- entity. In this case the calling parser will return an
- XML_ERROR_EXTERNAL_ENTITY_HANDLING error.
-
- Note that unlike other handlers the first argument is the parser,
- not userData. }
- XML_ExternalEntityRefHandler = function(
- parser : XML_Parser;
- context ,base ,systemId ,publicId : XML_Char_ptr ) : int;
-
-{ This is called in two situations:
- 1) An entity reference is encountered for which no declaration
- has been read *and* this is not an error.
- 2) An internal entity reference is read, but not expanded, because
- XML_SetDefaultHandler has been called.
- Note: skipped parameter entities in declarations and skipped general
- entities in attribute values cannot be reported, because
- the event would be out of sync with the reporting of the
- declarations or attribute values }
- XML_SkippedEntityHandler = procedure(userData : pointer; entityName : XML_Char_ptr; is_parameter_entity : int );
-
-(* This structure is filled in by the XML_UnknownEncodingHandler to
- provide information to the parser about encodings that are unknown
- to the parser.
-
- The map[b] member gives information about byte sequences whose
- first byte is b.
-
- If map[b] is c where c is >= 0, then b by itself encodes the
- Unicode scalar value c.
-
- If map[b] is -1, then the byte sequence is malformed.
-
- If map[b] is -n, where n >= 2, then b is the first byte of an
- n-byte sequence that encodes a single Unicode scalar value.
-
- The data member will be passed as the first argument to the convert
- function.
-
- The convert function is used to convert multibyte sequences; s will
- point to a n-byte sequence where map[(unsigned char)*s] == -n. The
- convert function must return the Unicode scalar value represented
- by this byte sequence or -1 if the byte sequence is malformed.
-
- The convert function may be NULL if the encoding is a single-byte
- encoding, that is if map[b] >= -1 for all bytes b.
-
- When the parser is finished with the encoding, then if release is
- not NULL, it will call release passing it the data member; once
- release has been called, the convert function will not be called
- again.
-
- Expat places certain restrictions on the encodings that are supported
- using this mechanism.
-
- 1. Every ASCII character that can appear in a well-formed XML document,
- other than the characters
-
- $@\^`{}~
-
- must be represented by a single byte, and that byte must be the
- same byte that represents that character in ASCII.
-
- 2. No character may require more than 4 bytes to encode.
-
- 3. All characters encoded must have Unicode scalar values <=
- 0xFFFF, (i.e., characters that would be encoded by surrogates in
- UTF-16 are not allowed). Note that this restriction doesn't
- apply to the built-in support for UTF-8 and UTF-16.
-
- 4. No Unicode character may be encoded by more than one distinct
- sequence of bytes. *)
- XML_Encoding_ptr = ^XML_Encoding;
- XML_Encoding = record
- map : array[0..255 ] of int;
- data : pointer;
-
- convert : function (data : pointer; s : char_ptr ) : int;
- release : procedure(data : pointer );
-
- end;
-
-{ This is called for an encoding that is unknown to the parser.
-
- The encodingHandlerData argument is that which was passed as the
- second argument to XML_SetUnknownEncodingHandler.
-
- The name argument gives the name of the encoding as specified in
- the encoding declaration.
-
- If the callback can provide information about the encoding, it must
- fill in the XML_Encoding structure, and return XML_STATUS_OK.
- Otherwise it must return XML_STATUS_ERROR.
-
- If info does not describe a suitable encoding, then the parser will
- return an XML_UNKNOWN_ENCODING error. }
- XML_UnknownEncodingHandler = function(
- encodingHandlerData : pointer;
- name : XML_Char_ptr;
- info : XML_Encoding_ptr ) : int;
-
-
- XML_Memory_Handling_Suite_ptr = ^XML_Memory_Handling_Suite;
- XML_Memory_Handling_Suite = record
- malloc_fcn : function(var ptr : pointer; sz : integer ) : boolean;
- realloc_fcn : function(var ptr : pointer; old ,sz : integer ) : boolean;
- free_fcn : function(var ptr : pointer; sz : integer ) : boolean;
-
- end;
-
- KEY = XML_Char_ptr;
-
- NAMED_ptr_ptr = ^NAMED_ptr;
- NAMED_ptr = ^NAMED;
- NAMED = record
- name : KEY;
- alloc : int;
-
- end;
-
- HASH_TABLE_ptr = ^HASH_TABLE;
- HASH_TABLE = record
- v : NAMED_ptr_ptr;
- a : int;
-
- power : int8u;
- size ,
- used : size_t;
- mem : XML_Memory_Handling_Suite_ptr;
-
- end;
-
- ENTITY_ptr = ^ENTITY;
- ENTITY = record
- name : XML_Char_ptr;
- alloc : int;
-
- textPtr : XML_Char_ptr;
- textLen , { length in XML_Chars }
- processed : int; { # of processed bytes - when suspended }
- systemId ,
- base ,
- publicId ,
- notation : XML_Char_ptr;
-
- open ,
- is_param ,
- is_internal : XML_Bool; { true if declared in internal subset outside PE }
-
- end;
-
- OPEN_INTERNAL_ENTITY_ptr = ^OPEN_INTERNAL_ENTITY;
- OPEN_INTERNAL_ENTITY = record
- internalEventPtr ,
- internalEventEndPtr : char_ptr;
-
- next : OPEN_INTERNAL_ENTITY_ptr;
- entity : ENTITY_ptr;
-
- startTagLevel : int;
- betweenDecl : XML_Bool; { WFC: PE Between Declarations }
-
- end;
-
- CONTENT_SCAFFOLD_ptr = ^CONTENT_SCAFFOLD;
- CONTENT_SCAFFOLD = record
- type_ : XML_Content_Type;
- quant : XML_Content_Quant;
- name : XML_Char_ptr;
-
- firstchild ,
- lastchild ,
- childcnt ,
- nextsib : int;
-
- end;
-
- PREFIX_ptr = ^PREFIX;
-
- ATTRIBUTE_ID_ptr = ^ATTRIBUTE_ID;
- ATTRIBUTE_ID = record
- name : XML_Char_ptr;
- alloc : int;
- prefix : PREFIX_ptr;
-
- maybeTokenized ,
- xmlns : XML_Bool;
-
- end;
-
- DEFAULT_ATTRIBUTE_ptr = ^DEFAULT_ATTRIBUTE;
- DEFAULT_ATTRIBUTE = record
- id : ATTRIBUTE_ID_ptr;
-
- isCdata : XML_Bool;
- value : XML_Char_ptr;
-
- end;
-
- ELEMENT_TYPE_ptr = ^ELEMENT_TYPE;
- ELEMENT_TYPE = record
- name : XML_Char_ptr;
- alloc : int;
- prefix : PREFIX_ptr;
- idAtt : ATTRIBUTE_ID_ptr;
-
- nDefaultAtts ,
- allocDefaultAtts ,
- defaultAttsAlloc : int;
-
- defaultAtts : DEFAULT_ATTRIBUTE_ptr;
-
- end;
-
- TAG_NAME_ptr = ^TAG_NAME;
- TAG_NAME = record
- str ,
- localPart ,
- prefix : XML_Char_ptr;
- strLen ,
- uriLen ,
- prefixLen : int;
-
- end;
-
-{ TAG represents an open element.
- The name of the element is stored in both the document and API
- encodings. The memory buffer 'buf' is a separately-allocated
- memory area which stores the name. During the XML_Parse()/
- XMLParseBuffer() when the element is open, the memory for the 'raw'
- version of the name (in the document encoding) is shared with the
- document buffer. If the element is open across calls to
- XML_Parse()/XML_ParseBuffer(), the buffer is re-allocated to
- contain the 'raw' name as well.
-
- A parser re-uses these structures, maintaining a list of allocated
- TAG objects in a free list. }
- BINDING_ptr_ptr = ^BINDING_ptr;
- BINDING_ptr = ^BINDING;
-
- TAG_ptr = ^TAG;
- TAG = record
- parent : TAG_ptr; { parent of this element }
- rawName : char_ptr; { tagName in the original encoding }
-
- rawNameLength : int;
-
- name : TAG_NAME; { tagName in the API encoding }
-
- buf , { buffer for name components }
- bufEnd : char_ptr; { end of the buffer }
- alloc : int;
-
- bindings : BINDING_ptr;
-
- end;
-
- BINDING = record
- prefix : PREFIX_ptr;
-
- nextTagBinding ,
- prevPrefixBinding : BINDING_ptr;
-
- attId : ATTRIBUTE_ID_ptr;
- uri : XML_Char_ptr;
-
- uriLen ,
- uriAlloc : int;
-
- end;
-
- PREFIX = record
- name : XML_Char_ptr;
- alloc : int;
- binding : BINDING_ptr;
-
- end;
-
- NS_ATT_ptr = ^NS_ATT;
- NS_ATT = record
- version ,
- hash : int32u;
- uriName : XML_Char_ptr;
-
- end;
-
- BLOCK_ptr = ^BLOCK;
- BLOCK = record
- next : BLOCK_ptr;
- size ,
- alloc : int;
-
- s : array[0..0 ] of XML_Char;
-
- end;
-
- STRING_POOL_ptr = ^STRING_POOL;
- STRING_POOL = record
- blocks ,
- freeBlocks : BLOCK_ptr;
-
- end_ ,
- ptr ,
- start : XML_Char_ptr;
-
- mem : XML_Memory_Handling_Suite_ptr;
-
- end;
-
- DTD_ptr = ^DTD;
- DTD = record
- generalEntities ,
- elementTypes ,
- attributeIds ,
- prefixes : HASH_TABLE;
-
- pool ,
- entityValuePool : STRING_POOL;
-
- { false once a parameter entity reference has been skipped }
- keepProcessing : XML_Bool;
-
- { true once an internal or external PE reference has been encountered;
- this includes the reference to an external subset }
- hasParamEntityRefs ,
- standalone : XML_Bool;
-
- {$IFDEF XML_DTD }
- { indicates if external PE has been read }
- paramEntityRead : XML_Bool;
- paramEntities : HASH_TABLE;
-
- {$ENDIF }
-
- defaultPrefix : PREFIX;
-
- { === scaffolding for building content model === }
- in_eldecl : XML_Bool;
- scaffold : CONTENT_SCAFFOLD_ptr;
-
- contentStringLen ,
- scaffSize ,
- scaffCount : unsigned;
-
- scaffLevel : int;
- scaffIndex : int_ptr;
- scaffAlloc : int;
-
- end;
-
- XML_Parsing = (
- XML_INITIALIZED ,
- XML_PARSING_ ,
- XML_FINISHED ,
- XML_SUSPENDED );
-
- XML_ParsingStatus = record
- parsing : XML_Parsing;
- finalBuffer : XML_Bool;
-
- end;
-
- Processor = function(parser : XML_Parser; start ,end_ : char_ptr; endPtr : char_ptr_ptr ) : XML_Error;
-
- XML_ParserStruct = record
- m_userData ,
- m_handlerArg : pointer;
-
- m_buffer : char_ptr;
- m_mem : XML_Memory_Handling_Suite;
-
- { first character to be parsed }
- m_bufferPtr : char_ptr;
-
- { past last character to be parsed }
- m_bufferEnd : char_ptr;
-
- { allocated end of buffer }
- m_bufferLim : char_ptr;
-
- { the size of the allocated buffer }
- m_bufferAloc : int;
-
- m_parseEndByteIndex : XML_Index;
-
- m_parseEndPtr : char_ptr;
- m_dataBuf ,
- m_dataBufEnd : XML_Char_ptr;
-
- { XML Handlers }
- m_startElementHandler : XML_StartElementHandler;
- m_endElementHandler : XML_EndElementHandler;
- m_characterDataHandler : XML_CharacterDataHandler;
- m_processingInstructionHandler : XML_ProcessingInstructionHandler;
- m_commentHandler : XML_CommentHandler;
- m_startCdataSectionHandler : XML_StartCdataSectionHandler;
- m_endCdataSectionHandler : XML_EndCdataSectionHandler;
- m_defaultHandler : XML_DefaultHandler;
- m_startDoctypeDeclHandler : XML_StartDoctypeDeclHandler;
- m_endDoctypeDeclHandler : XML_EndDoctypeDeclHandler;
- m_unparsedEntityDeclHandler : XML_UnparsedEntityDeclHandler;
- m_notationDeclHandler : XML_NotationDeclHandler;
- m_startNamespaceDeclHandler : XML_StartNamespaceDeclHandler;
- m_endNamespaceDeclHandler : XML_EndNamespaceDeclHandler;
- m_notStandaloneHandler : XML_NotStandaloneHandler;
- m_externalEntityRefHandler : XML_ExternalEntityRefHandler;
- m_externalEntityRefHandlerArg : XML_Parser;
- m_skippedEntityHandler : XML_SkippedEntityHandler;
- m_unknownEncodingHandler : XML_UnknownEncodingHandler;
- m_elementDeclHandler : XML_ElementDeclHandler;
- m_attlistDeclHandler : XML_AttlistDeclHandler;
- m_entityDeclHandler : XML_EntityDeclHandler;
- m_xmlDeclHandler : XML_XmlDeclHandler;
-
- m_encoding : ENCODING_ptr;
- m_initEncoding : INIT_ENCODING;
- m_internalEncoding : ENCODING_ptr;
- m_protocolEncodingName : XML_Char_ptr;
-
- m_ns ,
- m_ns_triplets : XML_Bool;
-
- m_unknownEncodingMem ,
- m_unknownEncodingData ,
- m_unknownEncodingHandlerData : pointer;
- m_unknownEncodingAlloc : int;
-
- m_unknownEncodingRelease : procedure(void : pointer );
-
- m_prologState : PROLOG_STATE;
- m_processor : Processor;
- m_errorCode : XML_Error;
- m_eventPtr ,
- m_eventEndPtr ,
- m_positionPtr : char_ptr;
-
- m_openInternalEntities ,
- m_freeInternalEntities : OPEN_INTERNAL_ENTITY_ptr;
-
- m_defaultExpandInternalEntities : XML_Bool;
-
- m_tagLevel : int;
- m_declEntity : ENTITY_ptr;
-
- m_doctypeName ,
- m_doctypeSysid ,
- m_doctypePubid ,
- m_declAttributeType ,
- m_declNotationName ,
- m_declNotationPublicId : XML_Char_ptr;
-
- m_declElementType : ELEMENT_TYPE_ptr;
- m_declAttributeId : ATTRIBUTE_ID_ptr;
-
- m_declAttributeIsCdata ,
- m_declAttributeIsId : XML_Bool;
-
- m_dtd : DTD_ptr;
-
- m_curBase : XML_Char_ptr;
-
- m_tagStack ,
- m_freeTagList : TAG_ptr;
-
- m_inheritedBindings ,
- m_freeBindingList : BINDING_ptr;
-
- m_attsSize ,
- m_attsAlloc ,
- m_nsAttsAlloc ,
- m_nSpecifiedAtts ,
- m_idAttIndex : int;
-
- m_atts : ATTRIBUTE_ptr;
- m_nsAtts : NS_ATT_ptr;
-
- m_nsAttsVersion : unsigned;
- m_nsAttsPower : int8u;
-
- m_position : POSITION;
- m_tempPool ,
- m_temp2Pool : STRING_POOL;
-
- m_groupConnector : char_ptr;
- m_groupSize ,
- m_groupAlloc : unsigned;
-
- m_namespaceSeparator : XML_Char;
-
- m_parentParser : XML_Parser;
- m_parsingStatus : XML_ParsingStatus;
-
- {$IFDEF XML_DTD }
- m_isParamEntity ,
- m_useForeignDTD : XML_Bool;
-
- m_paramEntityParsing : XML_ParamEntityParsing;
-
- {$ENDIF }
-
- end;
-
-{ GLOBAL CONSTANTS }
-const
- XML_TRUE = 1;
- XML_FALSE = 0;
-
-
-{ GLOBAL PROCEDURES }
-{ Constructs a new parser; encoding is the encoding specified by the
- external protocol or NIL if there is none specified. }
- function XML_ParserCreate(const encoding : XML_Char_ptr ) : XML_Parser;
-
-{ Constructs a new parser using the memory management suite referred to
- by memsuite. If memsuite is NULL, then use the standard library memory
- suite. If namespaceSeparator is non-NULL it creates a parser with
- namespace processing as described above. The character pointed at
- will serve as the namespace separator.
-
- All further memory operations used for the created parser will come from
- the given suite. }
- function XML_ParserCreate_MM(
- encoding : XML_Char_ptr;
- memsuite : XML_Memory_Handling_Suite_ptr;
- namespaceSeparator : XML_Char_ptr ) : XML_Parser;
-
-{ This value is passed as the userData argument to callbacks. }
- procedure XML_SetUserData(parser : XML_Parser; userData : pointer );
-
- procedure XML_SetElementHandler(
- parser : XML_Parser;
- start : XML_StartElementHandler;
- end_ : XML_EndElementHandler );
-
- procedure XML_SetCharacterDataHandler(
- parser : XML_Parser;
- handler : XML_CharacterDataHandler );
-
-{ Parses some input. Returns XML_STATUS_ERROR if a fatal error is
- detected. The last call to XML_Parse must have isFinal true; len
- may be zero for this call (or any other).
-
- Though the return values for these functions has always been
- described as a Boolean value, the implementation, at least for the
- 1.95.x series, has always returned exactly one of the XML_Status
- values. }
- function XML_Parse(parser : XML_Parser; const s : char_ptr; len ,isFinal : int ) : XML_Status;
-
-{ If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then
- XML_GetErrorCode returns information about the error. }
- function XML_GetErrorCode(parser : XML_Parser ) : XML_Error;
-
-{ Returns a string describing the error. }
- function XML_ErrorString(code : XML_Error ) : XML_LChar_ptr;
-
-{ These functions return information about the current parse
- location. They may be called from any callback called to report
- some parse event; in this case the location is the location of the
- first of the sequence of characters that generated the event. When
- called from callbacks generated by declarations in the document
- prologue, the location identified isn't as neatly defined, but will
- be within the relevant markup. When called outside of the callback
- functions, the position indicated will be just past the last parse
- event (regardless of whether there was an associated callback).
-
- They may also be called after returning from a call to XML_Parse
- or XML_ParseBuffer. If the return value is XML_STATUS_ERROR then
- the location is the location of the character at which the error
- was detected; otherwise the location is the location of the last
- parse event, as described above. }
- function XML_GetCurrentLineNumber(parser : XML_Parser ) : XML_Size;
-
-{ Frees memory used by the parser. }
- procedure XML_ParserFree(parser : XML_Parser );
-
-
-IMPLEMENTATION
-{ LOCAL VARIABLES & CONSTANTS }
-{ UNIT IMPLEMENTATION }
-{$I xmlparse.inc }
-
-END.
-
-
+//----------------------------------------------------------------------------
+// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+// and Clark Cooper
+// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
+//
+// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
+// Pascal Port By: Milan Marusinec alias Milano
+// milan@marusinec.sk
+// http://www.pasports.org/pasexpat
+// Copyright (c) 2006
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// [Pascal Port History] -----------------------------------------------------
+//
+// 01.05.2006-Milano: Unit port establishment
+// 07.06.2006-Milano: porting
+//
+{ expat.pas }
+unit
+ expat ;
+
+INTERFACE
+
+uses
+ expat_basics ,
+ xmltok ,
+ xmlrole ;
+
+{$I expat_mode.inc }
+
+{ TYPES DEFINITION }
+type
+{$I expat_external.inc }
+
+ XML_Parser = ^XML_ParserStruct;
+
+ XML_Bool = int8u;
+
+{ The XML_Status enum gives the possible return values for several API functions. }
+ XML_Status = (XML_STATUS_ERROR ,XML_STATUS_OK ,XML_STATUS_SUSPENDED );
+
+ XML_Error = (
+ XML_ERROR_NONE ,
+ XML_ERROR_NO_MEMORY ,
+ XML_ERROR_SYNTAX ,
+ XML_ERROR_NO_ELEMENTS ,
+ XML_ERROR_INVALID_TOKEN ,
+ XML_ERROR_UNCLOSED_TOKEN ,
+ XML_ERROR_PARTIAL_CHAR ,
+ XML_ERROR_TAG_MISMATCH ,
+ XML_ERROR_DUPLICATE_ATTRIBUTE ,
+ XML_ERROR_JUNK_AFTER_DOC_ELEMENT ,
+ XML_ERROR_PARAM_ENTITY_REF ,
+ XML_ERROR_UNDEFINED_ENTITY ,
+ XML_ERROR_RECURSIVE_ENTITY_REF ,
+ XML_ERROR_ASYNC_ENTITY ,
+ XML_ERROR_BAD_CHAR_REF ,
+ XML_ERROR_BINARY_ENTITY_REF ,
+ XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF ,
+ XML_ERROR_MISPLACED_XML_PI ,
+ XML_ERROR_UNKNOWN_ENCODING ,
+ XML_ERROR_INCORRECT_ENCODING ,
+ XML_ERROR_UNCLOSED_CDATA_SECTION ,
+ XML_ERROR_EXTERNAL_ENTITY_HANDLING ,
+ XML_ERROR_NOT_STANDALONE ,
+ XML_ERROR_UNEXPECTED_STATE ,
+ XML_ERROR_ENTITY_DECLARED_IN_PE ,
+ XML_ERROR_FEATURE_REQUIRES_XML_DTD ,
+ XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING ,
+ { Added in 1.95.7. }
+ XML_ERROR_UNBOUND_PREFIX ,
+ { Added in 1.95.8. }
+ XML_ERROR_UNDECLARING_PREFIX ,
+ XML_ERROR_INCOMPLETE_PE ,
+ XML_ERROR_XML_DECL ,
+ XML_ERROR_TEXT_DECL ,
+ XML_ERROR_PUBLICID ,
+ XML_ERROR_SUSPENDED ,
+ XML_ERROR_NOT_SUSPENDED ,
+ XML_ERROR_ABORTED ,
+ XML_ERROR_FINISHED ,
+ XML_ERROR_SUSPEND_PE ,
+ { Added in 2.0. }
+ XML_ERROR_RESERVED_PREFIX_XML ,
+ XML_ERROR_RESERVED_PREFIX_XMLNS ,
+ XML_ERROR_RESERVED_NAMESPACE_URI );
+
+ XML_Content_Type = (
+ ___SKIP_ZERO____ ,
+ XML_CTYPE_EMPTY ,
+ XML_CTYPE_ANY ,
+ XML_CTYPE_MIXED ,
+ XML_CTYPE_NAME ,
+ XML_CTYPE_CHOICE ,
+ XML_CTYPE_SEQ );
+
+ XML_Content_Quant = (
+ XML_CQUANT_NONE ,
+ XML_CQUANT_OPT ,
+ XML_CQUANT_REP ,
+ XML_CQUANT_PLUS );
+
+ XML_ParamEntityParsing = (
+ XML_PARAM_ENTITY_PARSING_NEVER ,
+ XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE ,
+ XML_PARAM_ENTITY_PARSING_ALWAYS );
+
+{ If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be
+ XML_CQUANT_NONE, and the other fields will be zero or NULL.
+ If type == XML_CTYPE_MIXED, then quant will be NONE or REP and
+ numchildren will contain number of elements that may be mixed in
+ and children point to an array of XML_Content cells that will be
+ all of XML_CTYPE_NAME type with no quantification.
+
+ If type == XML_CTYPE_NAME, then the name points to the name, and
+ the numchildren field will be zero and children will be NULL. The
+ quant fields indicates any quantifiers placed on the name.
+
+ CHOICE and SEQ will have name NULL, the number of children in
+ numchildren and children will point, recursively, to an array
+ of XML_Content cells.
+
+ The EMPTY, ANY, and MIXED types will only occur at top level. }
+ XML_Content_ptr = ^XML_Content;
+
+ XML_cp = record
+ type_ : XML_Content_Type;
+ quant : XML_Content_Quant;
+ name : XML_Char_ptr;
+
+ numchildren : unsigned;
+ children : XML_Content_ptr;
+
+ end;
+
+ XML_Content = XML_cp;
+
+{ This is called for an element declaration. See above for
+ description of the model argument. It's the caller's responsibility
+ to free model when finished with it. }
+ XML_ElementDeclHandler = procedure(userData : pointer; name : XML_Char_ptr; model : XML_Content_ptr );
+
+{ The Attlist declaration handler is called for *each* attribute. So
+ a single Attlist declaration with multiple attributes declared will
+ generate multiple calls to this handler. The "default" parameter
+ may be NULL in the case of the "#IMPLIED" or "#REQUIRED"
+ keyword. The "isrequired" parameter will be true and the default
+ value will be NULL in the case of "#REQUIRED". If "isrequired" is
+ true and default is non-NULL, then this is a "#FIXED" default. }
+ XML_AttlistDeclHandler = procedure(
+ userData : pointer;
+ elname ,attname ,att_type ,dflt : XML_Char_ptr;
+ isrequired : int );
+
+{ The XML declaration handler is called for *both* XML declarations
+ and text declarations. The way to distinguish is that the version
+ parameter will be NULL for text declarations. The encoding
+ parameter may be NULL for XML declarations. The standalone
+ parameter will be -1, 0, or 1 indicating respectively that there
+ was no standalone parameter in the declaration, that it was given
+ as no, or that it was given as yes. }
+ XML_XmlDeclHandler = procedure(userData : pointer; version ,encoding : XML_Char_ptr; standalone : int );
+
+{ This is called for entity declarations. The is_parameter_entity
+ argument will be non-zero if the entity is a parameter entity, zero
+ otherwise.
+
+ For internal entities (<!ENTITY foo "bar">), value will
+ be non-NULL and systemId, publicID, and notationName will be NULL.
+ The value string is NOT nul-terminated; the length is provided in
+ the value_length argument. Since it is legal to have zero-length
+ values, do not use this argument to test for internal entities.
+
+ For external entities, value will be NULL and systemId will be
+ non-NULL. The publicId argument will be NULL unless a public
+ identifier was provided. The notationName argument will have a
+ non-NULL value only for unparsed entity declarations.
+
+ Note that is_parameter_entity can't be changed to XML_Bool, since
+ that would break binary compatibility. }
+ XML_EntityDeclHandler = procedure(
+ userData : pointer;
+ entityName : XML_Char_ptr;
+ is_parameter_entity : int;
+ value : XML_Char_ptr;
+ value_length : int;
+ base ,systemId ,publicId ,notationName : XML_Char_ptr );
+
+{ atts is array of name/value pairs, terminated by 0;
+ names and values are 0 terminated. }
+ XML_StartElementHandler = procedure(userData : pointer; name : XML_Char_ptr; atts : XML_Char_ptr_ptr );
+ XML_EndElementHandler = procedure(userData : pointer; name : XML_Char_ptr );
+
+{ s is not 0 terminated. }
+ XML_CharacterDataHandler = procedure(userData : pointer; s : XML_Char_ptr; len : int );
+
+{ target and data are 0 terminated }
+ XML_ProcessingInstructionHandler = procedure(userData : pointer; target ,data : XML_Char_ptr );
+
+{ data is 0 terminated }
+ XML_CommentHandler = procedure(userData : pointer; data : XML_Char_ptr );
+
+ XML_StartCdataSectionHandler = procedure(userData : pointer );
+ XML_EndCdataSectionHandler = procedure(userData : pointer );
+
+
+{ This is called for any characters in the XML document for which
+ there is no applicable handler. This includes both characters that
+ are part of markup which is of a kind that is not reported
+ (comments, markup declarations), or characters that are part of a
+ construct which could be reported but for which no handler has been
+ supplied. The characters are passed exactly as they were in the XML
+ document except that they will be encoded in UTF-8 or UTF-16.
+ Line boundaries are not normalized. Note that a byte order mark
+ character is not passed to the default handler. There are no
+ guarantees about how characters are divided between calls to the
+ default handler: for example, a comment might be split between
+ multiple calls. }
+ XML_DefaultHandler = procedure(userData : pointer; s : XML_Char_ptr; len : int );
+
+{ This is called for the start of the DOCTYPE declaration, before
+ any DTD or internal subset is parsed. }
+ XML_StartDoctypeDeclHandler = procedure(
+ userData : pointer;
+ doctypeName ,sysid ,pubid : XML_Char_ptr;
+ has_internal_subset : int );
+
+{ This is called for the start of the DOCTYPE declaration when the
+ closing > is encountered, but after processing any external
+ subset. }
+ XML_EndDoctypeDeclHandler = procedure(userData : pointer );
+
+{ OBSOLETE -- OBSOLETE -- OBSOLETE
+ This handler has been superceded by the EntityDeclHandler above.
+ It is provided here for backward compatibility.
+
+ This is called for a declaration of an unparsed (NDATA) entity.
+ The base argument is whatever was set by XML_SetBase. The
+ entityName, systemId and notationName arguments will never be
+ NULL. The other arguments may be. }
+ XML_UnparsedEntityDeclHandler = procedure(
+ userData : pointer;
+ entityName ,base ,systemId ,publicId ,notationName : XML_Char_ptr );
+
+{ This is called for a declaration of notation. The base argument is
+ whatever was set by XML_SetBase. The notationName will never be
+ NULL. The other arguments can be. }
+ XML_NotationDeclHandler = procedure(
+ userData : pointer;
+ notationName ,base ,systemId ,publicId : XML_Char_ptr );
+
+{ When namespace processing is enabled, these are called once for
+ each namespace declaration. The call to the start and end element
+ handlers occur between the calls to the start and end namespace
+ declaration handlers. For an xmlns attribute, prefix will be
+ NULL. For an xmlns="" attribute, uri will be NULL. }
+ XML_StartNamespaceDeclHandler = procedure(userData : pointer; prefix ,uri : XML_Char_ptr );
+ XML_EndNamespaceDeclHandler = procedure(userData : pointer; prefix : XML_Char_ptr );
+
+{ This is called if the document is not standalone, that is, it has an
+ external subset or a reference to a parameter entity, but does not
+ have standalone="yes". If this handler returns XML_STATUS_ERROR,
+ then processing will not continue, and the parser will return a
+ XML_ERROR_NOT_STANDALONE error.
+ If parameter entity parsing is enabled, then in addition to the
+ conditions above this handler will only be called if the referenced
+ entity was actually read. }
+ XML_NotStandaloneHandler = function(userData : pointer ) : int;
+
+{ This is called for a reference to an external parsed general
+ entity. The referenced entity is not automatically parsed. The
+ application can parse it immediately or later using
+ XML_ExternalEntityParserCreate.
+
+ The parser argument is the parser parsing the entity containing the
+ reference; it can be passed as the parser argument to
+ XML_ExternalEntityParserCreate. The systemId argument is the
+ system identifier as specified in the entity declaration; it will
+ not be NULL.
+
+ The base argument is the system identifier that should be used as
+ the base for resolving systemId if systemId was relative; this is
+ set by XML_SetBase; it may be NULL.
+
+ The publicId argument is the public identifier as specified in the
+ entity declaration, or NULL if none was specified; the whitespace
+ in the public identifier will have been normalized as required by
+ the XML spec.
+
+ The context argument specifies the parsing context in the format
+ expected by the context argument to XML_ExternalEntityParserCreate;
+ context is valid only until the handler returns, so if the
+ referenced entity is to be parsed later, it must be copied.
+ context is NULL only when the entity is a parameter entity.
+
+ The handler should return XML_STATUS_ERROR if processing should not
+ continue because of a fatal error in the handling of the external
+ entity. In this case the calling parser will return an
+ XML_ERROR_EXTERNAL_ENTITY_HANDLING error.
+
+ Note that unlike other handlers the first argument is the parser,
+ not userData. }
+ XML_ExternalEntityRefHandler = function(
+ parser : XML_Parser;
+ context ,base ,systemId ,publicId : XML_Char_ptr ) : int;
+
+{ This is called in two situations:
+ 1) An entity reference is encountered for which no declaration
+ has been read *and* this is not an error.
+ 2) An internal entity reference is read, but not expanded, because
+ XML_SetDefaultHandler has been called.
+ Note: skipped parameter entities in declarations and skipped general
+ entities in attribute values cannot be reported, because
+ the event would be out of sync with the reporting of the
+ declarations or attribute values }
+ XML_SkippedEntityHandler = procedure(userData : pointer; entityName : XML_Char_ptr; is_parameter_entity : int );
+
+(* This structure is filled in by the XML_UnknownEncodingHandler to
+ provide information to the parser about encodings that are unknown
+ to the parser.
+
+ The map[b] member gives information about byte sequences whose
+ first byte is b.
+
+ If map[b] is c where c is >= 0, then b by itself encodes the
+ Unicode scalar value c.
+
+ If map[b] is -1, then the byte sequence is malformed.
+
+ If map[b] is -n, where n >= 2, then b is the first byte of an
+ n-byte sequence that encodes a single Unicode scalar value.
+
+ The data member will be passed as the first argument to the convert
+ function.
+
+ The convert function is used to convert multibyte sequences; s will
+ point to a n-byte sequence where map[(unsigned char)*s] == -n. The
+ convert function must return the Unicode scalar value represented
+ by this byte sequence or -1 if the byte sequence is malformed.
+
+ The convert function may be NULL if the encoding is a single-byte
+ encoding, that is if map[b] >= -1 for all bytes b.
+
+ When the parser is finished with the encoding, then if release is
+ not NULL, it will call release passing it the data member; once
+ release has been called, the convert function will not be called
+ again.
+
+ Expat places certain restrictions on the encodings that are supported
+ using this mechanism.
+
+ 1. Every ASCII character that can appear in a well-formed XML document,
+ other than the characters
+
+ $@\^`{}~
+
+ must be represented by a single byte, and that byte must be the
+ same byte that represents that character in ASCII.
+
+ 2. No character may require more than 4 bytes to encode.
+
+ 3. All characters encoded must have Unicode scalar values <=
+ 0xFFFF, (i.e., characters that would be encoded by surrogates in
+ UTF-16 are not allowed). Note that this restriction doesn't
+ apply to the built-in support for UTF-8 and UTF-16.
+
+ 4. No Unicode character may be encoded by more than one distinct
+ sequence of bytes. *)
+ XML_Encoding_ptr = ^XML_Encoding;
+ XML_Encoding = record
+ map : array[0..255 ] of int;
+ data : pointer;
+
+ convert : function (data : pointer; s : char_ptr ) : int;
+ release : procedure(data : pointer );
+
+ end;
+
+{ This is called for an encoding that is unknown to the parser.
+
+ The encodingHandlerData argument is that which was passed as the
+ second argument to XML_SetUnknownEncodingHandler.
+
+ The name argument gives the name of the encoding as specified in
+ the encoding declaration.
+
+ If the callback can provide information about the encoding, it must
+ fill in the XML_Encoding structure, and return XML_STATUS_OK.
+ Otherwise it must return XML_STATUS_ERROR.
+
+ If info does not describe a suitable encoding, then the parser will
+ return an XML_UNKNOWN_ENCODING error. }
+ XML_UnknownEncodingHandler = function(
+ encodingHandlerData : pointer;
+ name : XML_Char_ptr;
+ info : XML_Encoding_ptr ) : int;
+
+
+ XML_Memory_Handling_Suite_ptr = ^XML_Memory_Handling_Suite;
+ XML_Memory_Handling_Suite = record
+ malloc_fcn : function(var ptr : pointer; sz : integer ) : boolean;
+ realloc_fcn : function(var ptr : pointer; old ,sz : integer ) : boolean;
+ free_fcn : function(var ptr : pointer; sz : integer ) : boolean;
+
+ end;
+
+ KEY = XML_Char_ptr;
+
+ NAMED_ptr_ptr = ^NAMED_ptr;
+ NAMED_ptr = ^NAMED;
+ NAMED = record
+ name : KEY;
+ alloc : int;
+
+ end;
+
+ HASH_TABLE_ptr = ^HASH_TABLE;
+ HASH_TABLE = record
+ v : NAMED_ptr_ptr;
+ a : int;
+
+ power : int8u;
+ size ,
+ used : size_t;
+ mem : XML_Memory_Handling_Suite_ptr;
+
+ end;
+
+ ENTITY_ptr = ^ENTITY;
+ ENTITY = record
+ name : XML_Char_ptr;
+ alloc : int;
+
+ textPtr : XML_Char_ptr;
+ textLen , { length in XML_Chars }
+ processed : int; { # of processed bytes - when suspended }
+ systemId ,
+ base ,
+ publicId ,
+ notation : XML_Char_ptr;
+
+ open ,
+ is_param ,
+ is_internal : XML_Bool; { true if declared in internal subset outside PE }
+
+ end;
+
+ OPEN_INTERNAL_ENTITY_ptr = ^OPEN_INTERNAL_ENTITY;
+ OPEN_INTERNAL_ENTITY = record
+ internalEventPtr ,
+ internalEventEndPtr : char_ptr;
+
+ next : OPEN_INTERNAL_ENTITY_ptr;
+ entity : ENTITY_ptr;
+
+ startTagLevel : int;
+ betweenDecl : XML_Bool; { WFC: PE Between Declarations }
+
+ end;
+
+ CONTENT_SCAFFOLD_ptr = ^CONTENT_SCAFFOLD;
+ CONTENT_SCAFFOLD = record
+ type_ : XML_Content_Type;
+ quant : XML_Content_Quant;
+ name : XML_Char_ptr;
+
+ firstchild ,
+ lastchild ,
+ childcnt ,
+ nextsib : int;
+
+ end;
+
+ PREFIX_ptr = ^PREFIX;
+
+ ATTRIBUTE_ID_ptr = ^ATTRIBUTE_ID;
+ ATTRIBUTE_ID = record
+ name : XML_Char_ptr;
+ alloc : int;
+ prefix : PREFIX_ptr;
+
+ maybeTokenized ,
+ xmlns : XML_Bool;
+
+ end;
+
+ DEFAULT_ATTRIBUTE_ptr = ^DEFAULT_ATTRIBUTE;
+ DEFAULT_ATTRIBUTE = record
+ id : ATTRIBUTE_ID_ptr;
+
+ isCdata : XML_Bool;
+ value : XML_Char_ptr;
+
+ end;
+
+ ELEMENT_TYPE_ptr = ^ELEMENT_TYPE;
+ ELEMENT_TYPE = record
+ name : XML_Char_ptr;
+ alloc : int;
+ prefix : PREFIX_ptr;
+ idAtt : ATTRIBUTE_ID_ptr;
+
+ nDefaultAtts ,
+ allocDefaultAtts ,
+ defaultAttsAlloc : int;
+
+ defaultAtts : DEFAULT_ATTRIBUTE_ptr;
+
+ end;
+
+ TAG_NAME_ptr = ^TAG_NAME;
+ TAG_NAME = record
+ str ,
+ localPart ,
+ prefix : XML_Char_ptr;
+ strLen ,
+ uriLen ,
+ prefixLen : int;
+
+ end;
+
+{ TAG represents an open element.
+ The name of the element is stored in both the document and API
+ encodings. The memory buffer 'buf' is a separately-allocated
+ memory area which stores the name. During the XML_Parse()/
+ XMLParseBuffer() when the element is open, the memory for the 'raw'
+ version of the name (in the document encoding) is shared with the
+ document buffer. If the element is open across calls to
+ XML_Parse()/XML_ParseBuffer(), the buffer is re-allocated to
+ contain the 'raw' name as well.
+
+ A parser re-uses these structures, maintaining a list of allocated
+ TAG objects in a free list. }
+ BINDING_ptr_ptr = ^BINDING_ptr;
+ BINDING_ptr = ^BINDING;
+
+ TAG_ptr = ^TAG;
+ TAG = record
+ parent : TAG_ptr; { parent of this element }
+ rawName : char_ptr; { tagName in the original encoding }
+
+ rawNameLength : int;
+
+ name : TAG_NAME; { tagName in the API encoding }
+
+ buf , { buffer for name components }
+ bufEnd : char_ptr; { end of the buffer }
+ alloc : int;
+
+ bindings : BINDING_ptr;
+
+ end;
+
+ BINDING = record
+ prefix : PREFIX_ptr;
+
+ nextTagBinding ,
+ prevPrefixBinding : BINDING_ptr;
+
+ attId : ATTRIBUTE_ID_ptr;
+ uri : XML_Char_ptr;
+
+ uriLen ,
+ uriAlloc : int;
+
+ end;
+
+ PREFIX = record
+ name : XML_Char_ptr;
+ alloc : int;
+ binding : BINDING_ptr;
+
+ end;
+
+ NS_ATT_ptr = ^NS_ATT;
+ NS_ATT = record
+ version ,
+ hash : int32u;
+ uriName : XML_Char_ptr;
+
+ end;
+
+ BLOCK_ptr = ^BLOCK;
+ BLOCK = record
+ next : BLOCK_ptr;
+ size ,
+ alloc : int;
+
+ s : array[0..0 ] of XML_Char;
+
+ end;
+
+ STRING_POOL_ptr = ^STRING_POOL;
+ STRING_POOL = record
+ blocks ,
+ freeBlocks : BLOCK_ptr;
+
+ end_ ,
+ ptr ,
+ start : XML_Char_ptr;
+
+ mem : XML_Memory_Handling_Suite_ptr;
+
+ end;
+
+ DTD_ptr = ^DTD;
+ DTD = record
+ generalEntities ,
+ elementTypes ,
+ attributeIds ,
+ prefixes : HASH_TABLE;
+
+ pool ,
+ entityValuePool : STRING_POOL;
+
+ { false once a parameter entity reference has been skipped }
+ keepProcessing : XML_Bool;
+
+ { true once an internal or external PE reference has been encountered;
+ this includes the reference to an external subset }
+ hasParamEntityRefs ,
+ standalone : XML_Bool;
+
+ {$IFDEF XML_DTD }
+ { indicates if external PE has been read }
+ paramEntityRead : XML_Bool;
+ paramEntities : HASH_TABLE;
+
+ {$ENDIF }
+
+ defaultPrefix : PREFIX;
+
+ { === scaffolding for building content model === }
+ in_eldecl : XML_Bool;
+ scaffold : CONTENT_SCAFFOLD_ptr;
+
+ contentStringLen ,
+ scaffSize ,
+ scaffCount : unsigned;
+
+ scaffLevel : int;
+ scaffIndex : int_ptr;
+ scaffAlloc : int;
+
+ end;
+
+ XML_Parsing = (
+ XML_INITIALIZED ,
+ XML_PARSING_ ,
+ XML_FINISHED ,
+ XML_SUSPENDED );
+
+ XML_ParsingStatus = record
+ parsing : XML_Parsing;
+ finalBuffer : XML_Bool;
+
+ end;
+
+ Processor = function(parser : XML_Parser; start ,end_ : char_ptr; endPtr : char_ptr_ptr ) : XML_Error;
+
+ XML_ParserStruct = record
+ m_userData ,
+ m_handlerArg : pointer;
+
+ m_buffer : char_ptr;
+ m_mem : XML_Memory_Handling_Suite;
+
+ { first character to be parsed }
+ m_bufferPtr : char_ptr;
+
+ { past last character to be parsed }
+ m_bufferEnd : char_ptr;
+
+ { allocated end of buffer }
+ m_bufferLim : char_ptr;
+
+ { the size of the allocated buffer }
+ m_bufferAloc : int;
+
+ m_parseEndByteIndex : XML_Index;
+
+ m_parseEndPtr : char_ptr;
+ m_dataBuf ,
+ m_dataBufEnd : XML_Char_ptr;
+
+ { XML Handlers }
+ m_startElementHandler : XML_StartElementHandler;
+ m_endElementHandler : XML_EndElementHandler;
+ m_characterDataHandler : XML_CharacterDataHandler;
+ m_processingInstructionHandler : XML_ProcessingInstructionHandler;
+ m_commentHandler : XML_CommentHandler;
+ m_startCdataSectionHandler : XML_StartCdataSectionHandler;
+ m_endCdataSectionHandler : XML_EndCdataSectionHandler;
+ m_defaultHandler : XML_DefaultHandler;
+ m_startDoctypeDeclHandler : XML_StartDoctypeDeclHandler;
+ m_endDoctypeDeclHandler : XML_EndDoctypeDeclHandler;
+ m_unparsedEntityDeclHandler : XML_UnparsedEntityDeclHandler;
+ m_notationDeclHandler : XML_NotationDeclHandler;
+ m_startNamespaceDeclHandler : XML_StartNamespaceDeclHandler;
+ m_endNamespaceDeclHandler : XML_EndNamespaceDeclHandler;
+ m_notStandaloneHandler : XML_NotStandaloneHandler;
+ m_externalEntityRefHandler : XML_ExternalEntityRefHandler;
+ m_externalEntityRefHandlerArg : XML_Parser;
+ m_skippedEntityHandler : XML_SkippedEntityHandler;
+ m_unknownEncodingHandler : XML_UnknownEncodingHandler;
+ m_elementDeclHandler : XML_ElementDeclHandler;
+ m_attlistDeclHandler : XML_AttlistDeclHandler;
+ m_entityDeclHandler : XML_EntityDeclHandler;
+ m_xmlDeclHandler : XML_XmlDeclHandler;
+
+ m_encoding : ENCODING_ptr;
+ m_initEncoding : INIT_ENCODING;
+ m_internalEncoding : ENCODING_ptr;
+ m_protocolEncodingName : XML_Char_ptr;
+
+ m_ns ,
+ m_ns_triplets : XML_Bool;
+
+ m_unknownEncodingMem ,
+ m_unknownEncodingData ,
+ m_unknownEncodingHandlerData : pointer;
+ m_unknownEncodingAlloc : int;
+
+ m_unknownEncodingRelease : procedure(void : pointer );
+
+ m_prologState : PROLOG_STATE;
+ m_processor : Processor;
+ m_errorCode : XML_Error;
+ m_eventPtr ,
+ m_eventEndPtr ,
+ m_positionPtr : char_ptr;
+
+ m_openInternalEntities ,
+ m_freeInternalEntities : OPEN_INTERNAL_ENTITY_ptr;
+
+ m_defaultExpandInternalEntities : XML_Bool;
+
+ m_tagLevel : int;
+ m_declEntity : ENTITY_ptr;
+
+ m_doctypeName ,
+ m_doctypeSysid ,
+ m_doctypePubid ,
+ m_declAttributeType ,
+ m_declNotationName ,
+ m_declNotationPublicId : XML_Char_ptr;
+
+ m_declElementType : ELEMENT_TYPE_ptr;
+ m_declAttributeId : ATTRIBUTE_ID_ptr;
+
+ m_declAttributeIsCdata ,
+ m_declAttributeIsId : XML_Bool;
+
+ m_dtd : DTD_ptr;
+
+ m_curBase : XML_Char_ptr;
+
+ m_tagStack ,
+ m_freeTagList : TAG_ptr;
+
+ m_inheritedBindings ,
+ m_freeBindingList : BINDING_ptr;
+
+ m_attsSize ,
+ m_attsAlloc ,
+ m_nsAttsAlloc ,
+ m_nSpecifiedAtts ,
+ m_idAttIndex : int;
+
+ m_atts : ATTRIBUTE_ptr;
+ m_nsAtts : NS_ATT_ptr;
+
+ m_nsAttsVersion : unsigned;
+ m_nsAttsPower : int8u;
+
+ m_position : POSITION;
+ m_tempPool ,
+ m_temp2Pool : STRING_POOL;
+
+ m_groupConnector : char_ptr;
+ m_groupSize ,
+ m_groupAlloc : unsigned;
+
+ m_namespaceSeparator : XML_Char;
+
+ m_parentParser : XML_Parser;
+ m_parsingStatus : XML_ParsingStatus;
+
+ {$IFDEF XML_DTD }
+ m_isParamEntity ,
+ m_useForeignDTD : XML_Bool;
+
+ m_paramEntityParsing : XML_ParamEntityParsing;
+
+ {$ENDIF }
+
+ end;
+
+{ GLOBAL CONSTANTS }
+const
+ XML_TRUE = 1;
+ XML_FALSE = 0;
+
+
+{ GLOBAL PROCEDURES }
+{ Constructs a new parser; encoding is the encoding specified by the
+ external protocol or NIL if there is none specified. }
+ function XML_ParserCreate(const encoding : XML_Char_ptr ) : XML_Parser;
+
+{ Constructs a new parser using the memory management suite referred to
+ by memsuite. If memsuite is NULL, then use the standard library memory
+ suite. If namespaceSeparator is non-NULL it creates a parser with
+ namespace processing as described above. The character pointed at
+ will serve as the namespace separator.
+
+ All further memory operations used for the created parser will come from
+ the given suite. }
+ function XML_ParserCreate_MM(
+ encoding : XML_Char_ptr;
+ memsuite : XML_Memory_Handling_Suite_ptr;
+ namespaceSeparator : XML_Char_ptr ) : XML_Parser;
+
+{ This value is passed as the userData argument to callbacks. }
+ procedure XML_SetUserData(parser : XML_Parser; userData : pointer );
+
+ procedure XML_SetElementHandler(
+ parser : XML_Parser;
+ start : XML_StartElementHandler;
+ end_ : XML_EndElementHandler );
+
+ procedure XML_SetCharacterDataHandler(
+ parser : XML_Parser;
+ handler : XML_CharacterDataHandler );
+
+{ Parses some input. Returns XML_STATUS_ERROR if a fatal error is
+ detected. The last call to XML_Parse must have isFinal true; len
+ may be zero for this call (or any other).
+
+ Though the return values for these functions has always been
+ described as a Boolean value, the implementation, at least for the
+ 1.95.x series, has always returned exactly one of the XML_Status
+ values. }
+ function XML_Parse(parser : XML_Parser; const s : char_ptr; len ,isFinal : int ) : XML_Status;
+
+{ If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then
+ XML_GetErrorCode returns information about the error. }
+ function XML_GetErrorCode(parser : XML_Parser ) : XML_Error;
+
+{ Returns a string describing the error. }
+ function XML_ErrorString(code : XML_Error ) : XML_LChar_ptr;
+
+{ These functions return information about the current parse
+ location. They may be called from any callback called to report
+ some parse event; in this case the location is the location of the
+ first of the sequence of characters that generated the event. When
+ called from callbacks generated by declarations in the document
+ prologue, the location identified isn't as neatly defined, but will
+ be within the relevant markup. When called outside of the callback
+ functions, the position indicated will be just past the last parse
+ event (regardless of whether there was an associated callback).
+
+ They may also be called after returning from a call to XML_Parse
+ or XML_ParseBuffer. If the return value is XML_STATUS_ERROR then
+ the location is the location of the character at which the error
+ was detected; otherwise the location is the location of the last
+ parse event, as described above. }
+ function XML_GetCurrentLineNumber(parser : XML_Parser ) : XML_Size;
+
+{ Frees memory used by the parser. }
+ procedure XML_ParserFree(parser : XML_Parser );
+
+
+IMPLEMENTATION
+{ LOCAL VARIABLES & CONSTANTS }
+{ UNIT IMPLEMENTATION }
+{$I xmlparse.inc }
+
+END.
+
+
diff --git a/src/corelib/render/software/agg-demos/expat-pas/expat_basics.pas b/src/corelib/render/software/agg-demos/expat-pas/expat_basics.pas
index 9ef5c0b3..784ea25a 100755..100644
--- a/src/corelib/render/software/agg-demos/expat-pas/expat_basics.pas
+++ b/src/corelib/render/software/agg-demos/expat-pas/expat_basics.pas
@@ -1,218 +1,218 @@
-//----------------------------------------------------------------------------
-// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
-// and Clark Cooper
-// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
-//
-// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
-// Pascal Port By: Milan Marusinec alias Milano
-// milan@marusinec.sk
-// http://www.pasports.org/pasexpat
-// Copyright (c) 2006
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// [Pascal Port History] -----------------------------------------------------
-//
-// 10.05.2006-Milano: Unit port establishment
-//
-{ expat_basics.pas }
-unit
- expat_basics ;
-
-INTERFACE
-
-{$I expat_mode.inc }
-
-{ GLOBAL PROCEDURES }
- function expat_getmem (var ptr : pointer; sz : integer ) : boolean;
- function expat_realloc(var ptr : pointer; old ,sz : integer ) : boolean;
- function expat_freemem(var ptr : pointer; sz : integer ) : boolean;
-
- procedure NoP;
-
-// SHR for signed integers is differently implemented in pascal compilers
-// than in c++ compilers. On the assembler level, c++ is using the SAR and
-// pascal is using SHR. That gives completely different result, when the
-// number is negative. We have to be compatible with c++ implementation,
-// thus instead of directly using SHR we emulate c++ solution.
- function shr_int8 (i ,shift : shortint ) : shortint;
- function shr_int16(i ,shift : smallint ) : smallint;
- function shr_int32(i ,shift : longint ) : longint;
-
-
-IMPLEMENTATION
-{ LOCAL VARIABLES & CONSTANTS }
-{ UNIT IMPLEMENTATION }
-{ EXPAT_GETMEM }
-function expat_getmem;
-begin
- result:=false;
-
- try
- getmem(ptr ,sz );
-
- result:=true;
-
- except
- ptr:=NIL;
-
- end;
-
-end;
-
-{ EXPAT_REALLOC }
-function expat_realloc;
-var
- nb : pointer;
- max : integer;
-
-begin
- if expat_getmem(nb ,sz ) then
- begin
- max:=old;
-
- if max > sz then
- max:=sz;
-
- move(ptr^ ,nb^ ,max );
-
- expat_freemem(ptr ,old );
-
- ptr :=nb;
- result:=true;
-
- end
- else
- result:=false;
-
-end;
-
-{ EXPAT_FREEMEM }
-function expat_freemem;
-begin
- if ptr = NIL then
- result:=true
-
- else
- try
- freemem(ptr ,sz );
-
- ptr :=NIL;
- result:=true;
-
- except
- result:=false;
-
- end;
-
-end;
-
-{ NOP }
-procedure NoP;
-begin
-end;
-
-{ SHR_INT8 }
-function shr_int8;
-begin
-{$IFDEF EXPAT_CPU_386 }
- asm
- mov al ,byte ptr [i ]
- mov cl ,byte ptr [shift ]
- sar al ,cl
- mov byte ptr [result ] ,al
-
- end;
-
-{$ENDIF }
-
-{$IFDEF EXPAT_CPU_PPC }
- asm
- lbz r2,i
- extsb r2,r2
- lbz r3,shift
- extsb r3,r3
- sraw r2,r2,r3
- extsb r2,r2
- stb r2,result
-
- end;
-
-{$ENDIF }
-
-end;
-
-{ SHR_INT16 }
-function shr_int16;
-begin
-{$IFDEF EXPAT_CPU_386 }
- asm
- mov ax ,word ptr [i ]
- mov cx ,word ptr [shift ]
- sar ax ,cl
- mov word ptr [result ] ,ax
-
- end;
-
-{$ENDIF }
-
-{$IFDEF EXPAT_CPU_PPC }
- asm
- lha r2,i
- lha r3,shift
- sraw r2,r2,r3
- extsh r2,r2
- sth r2,result
-
- end;
-
-{$ENDIF }
-
-end;
-
-{ SHR_INT32 }
-function shr_int32;
-begin
-{$IFDEF EXPAT_CPU_386 }
- asm
- mov eax ,dword ptr [i ]
- mov ecx ,dword ptr [shift ]
- sar eax ,cl
- mov dword ptr [result ] ,eax
-
- end;
-
-{$ENDIF }
-
-{$IFDEF EXPAT_CPU_PPC }
- asm
- lwz r3,i
- lwz r2,shift
- sraw r3,r3,r2
- stw r3,result
-
- end;
-
-{$ENDIF }
-
-end;
-
-END.
-
+//----------------------------------------------------------------------------
+// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+// and Clark Cooper
+// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
+//
+// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
+// Pascal Port By: Milan Marusinec alias Milano
+// milan@marusinec.sk
+// http://www.pasports.org/pasexpat
+// Copyright (c) 2006
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// [Pascal Port History] -----------------------------------------------------
+//
+// 10.05.2006-Milano: Unit port establishment
+//
+{ expat_basics.pas }
+unit
+ expat_basics ;
+
+INTERFACE
+
+{$I expat_mode.inc }
+
+{ GLOBAL PROCEDURES }
+ function expat_getmem (var ptr : pointer; sz : integer ) : boolean;
+ function expat_realloc(var ptr : pointer; old ,sz : integer ) : boolean;
+ function expat_freemem(var ptr : pointer; sz : integer ) : boolean;
+
+ procedure NoP;
+
+// SHR for signed integers is differently implemented in pascal compilers
+// than in c++ compilers. On the assembler level, c++ is using the SAR and
+// pascal is using SHR. That gives completely different result, when the
+// number is negative. We have to be compatible with c++ implementation,
+// thus instead of directly using SHR we emulate c++ solution.
+ function shr_int8 (i ,shift : shortint ) : shortint;
+ function shr_int16(i ,shift : smallint ) : smallint;
+ function shr_int32(i ,shift : longint ) : longint;
+
+
+IMPLEMENTATION
+{ LOCAL VARIABLES & CONSTANTS }
+{ UNIT IMPLEMENTATION }
+{ EXPAT_GETMEM }
+function expat_getmem;
+begin
+ result:=false;
+
+ try
+ getmem(ptr ,sz );
+
+ result:=true;
+
+ except
+ ptr:=NIL;
+
+ end;
+
+end;
+
+{ EXPAT_REALLOC }
+function expat_realloc;
+var
+ nb : pointer;
+ max : integer;
+
+begin
+ if expat_getmem(nb ,sz ) then
+ begin
+ max:=old;
+
+ if max > sz then
+ max:=sz;
+
+ move(ptr^ ,nb^ ,max );
+
+ expat_freemem(ptr ,old );
+
+ ptr :=nb;
+ result:=true;
+
+ end
+ else
+ result:=false;
+
+end;
+
+{ EXPAT_FREEMEM }
+function expat_freemem;
+begin
+ if ptr = NIL then
+ result:=true
+
+ else
+ try
+ freemem(ptr ,sz );
+
+ ptr :=NIL;
+ result:=true;
+
+ except
+ result:=false;
+
+ end;
+
+end;
+
+{ NOP }
+procedure NoP;
+begin
+end;
+
+{ SHR_INT8 }
+function shr_int8;
+begin
+{$IFDEF EXPAT_CPU_386 }
+ asm
+ mov al ,byte ptr [i ]
+ mov cl ,byte ptr [shift ]
+ sar al ,cl
+ mov byte ptr [result ] ,al
+
+ end;
+
+{$ENDIF }
+
+{$IFDEF EXPAT_CPU_PPC }
+ asm
+ lbz r2,i
+ extsb r2,r2
+ lbz r3,shift
+ extsb r3,r3
+ sraw r2,r2,r3
+ extsb r2,r2
+ stb r2,result
+
+ end;
+
+{$ENDIF }
+
+end;
+
+{ SHR_INT16 }
+function shr_int16;
+begin
+{$IFDEF EXPAT_CPU_386 }
+ asm
+ mov ax ,word ptr [i ]
+ mov cx ,word ptr [shift ]
+ sar ax ,cl
+ mov word ptr [result ] ,ax
+
+ end;
+
+{$ENDIF }
+
+{$IFDEF EXPAT_CPU_PPC }
+ asm
+ lha r2,i
+ lha r3,shift
+ sraw r2,r2,r3
+ extsh r2,r2
+ sth r2,result
+
+ end;
+
+{$ENDIF }
+
+end;
+
+{ SHR_INT32 }
+function shr_int32;
+begin
+{$IFDEF EXPAT_CPU_386 }
+ asm
+ mov eax ,dword ptr [i ]
+ mov ecx ,dword ptr [shift ]
+ sar eax ,cl
+ mov dword ptr [result ] ,eax
+
+ end;
+
+{$ENDIF }
+
+{$IFDEF EXPAT_CPU_PPC }
+ asm
+ lwz r3,i
+ lwz r2,shift
+ sraw r3,r3,r2
+ stw r3,result
+
+ end;
+
+{$ENDIF }
+
+end;
+
+END.
+
diff --git a/src/corelib/render/software/agg-demos/expat-pas/expat_external.inc b/src/corelib/render/software/agg-demos/expat-pas/expat_external.inc
index 3d5089b8..0beffa44 100755..100644
--- a/src/corelib/render/software/agg-demos/expat-pas/expat_external.inc
+++ b/src/corelib/render/software/agg-demos/expat-pas/expat_external.inc
@@ -1,147 +1,147 @@
-//----------------------------------------------------------------------------
-// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
-// and Clark Cooper
-// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
-//
-// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
-// Pascal Port By: Milan Marusinec alias Milano
-// milan@marusinec.sk
-// http://www.pasports.org/pasexpat
-// Copyright (c) 2006
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// [Pascal Port History] -----------------------------------------------------
-//
-// 03.05.2006-Milano: Unit port establishment
-//
-{ expat_external.inc }
-(* General Integer Types *)
- int8 = shortint;
- int8u = byte;
- int16 = smallint;
- int16u = word;
- int32 = longint;
- int32u = longword;
- int64 = system.int64;
-
-{$IFDEF FPC }
- int64u = qword;
-
-{$ELSE }
- int64u = system.int64;
-
-{$ENDIF }
-
-(* General Character Types *)
- char8 = char;
- char16 = int16u;
- char32 = int32u;
-
-(* C/C++ compatibility Types *)
- int = int32;
- unsigned = int32u;
- size_t = int32u;
-
-(* Pascal Pointer Computation Type *)
-{$IFDEF CPU64 }
- ptrcomp = system.int64;
-
-{$ELSE }
- ptrcomp = integer;
-
-{$ENDIF }
-
-(* Type Pointers *)
- int8_ptr = ^int8;
- int8_ptr_ptr = ^int8_ptr;
-
- int8u_ptr = ^int8u;
- int8u_ptr_ptr = ^int8u_ptr;
-
- int16_ptr = ^int16;
- int16_ptr_ptr = ^int16_ptr;
-
- int16u_ptr = ^int16u;
- int16u_ptr_ptr = ^int16u_ptr;
-
- int32_ptr = ^int32;
- int32_ptr_ptr = ^int32_ptr;
-
- int32u_ptr = ^int32u;
- int32u_ptr_ptr = ^int32u_ptr;
-
- int64_ptr = ^int64;
- int64_ptr_ptr = ^int64_ptr;
-
- int64u_ptr = ^int64u;
- int64u_ptr_ptr = ^int64u_ptr;
-
- char8_ptr = ^char8;
- char8_ptr_ptr = ^char8_ptr;
-
- char16_ptr = ^char16;
- char16_ptr_ptr = ^char16_ptr;
-
- char32_ptr = ^char32;
- char32_ptr_ptr = ^char32_ptr;
-
- int_ptr = ^int;
- int_ptr_ptr = ^int_ptr;
-
- unsigned_ptr = ^unsigned;
- unsigned_ptr_ptr = ^unsigned_ptr;
-
- char_ptr = ^char;
- char_ptr_ptr = ^char_ptr;
-
-(* Expat Types *)
-{$IFDEF XML_UNICODE } // Information is UTF-16 encoded.
-{$IFDEF XML_UNICODE_WCHAR_T }
- XML_Char = int16u;
- XML_LChar = int16u;
-
-{$ELSE }
- XML_Char = word;
- XML_LChar = char;
-
-{$ENDIF }
-
-{$ELSE } // Information is UTF-8 encoded.
- XML_Char = char;
- XML_LChar = char;
-
-{$ENDIF }
-
- XML_Char_ptr = ^XML_Char;
- XML_LChar_ptr = ^XML_LChar;
-
- XML_Char_ptr_ptr = ^XML_Char_ptr;
-
-{$IFDEF XML_LARGE_SIZE } // Use large integers for file/stream positions.
- XML_Index = int64;
- XML_Size = int64u;
-
-{$ELSE }
- XML_Index = longint;
- XML_Size = longword;
-
-{$ENDIF }
-
+//----------------------------------------------------------------------------
+// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+// and Clark Cooper
+// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
+//
+// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
+// Pascal Port By: Milan Marusinec alias Milano
+// milan@marusinec.sk
+// http://www.pasports.org/pasexpat
+// Copyright (c) 2006
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// [Pascal Port History] -----------------------------------------------------
+//
+// 03.05.2006-Milano: Unit port establishment
+//
+{ expat_external.inc }
+(* General Integer Types *)
+ int8 = shortint;
+ int8u = byte;
+ int16 = smallint;
+ int16u = word;
+ int32 = longint;
+ int32u = longword;
+ int64 = system.int64;
+
+{$IFDEF FPC }
+ int64u = qword;
+
+{$ELSE }
+ int64u = system.int64;
+
+{$ENDIF }
+
+(* General Character Types *)
+ char8 = char;
+ char16 = int16u;
+ char32 = int32u;
+
+(* C/C++ compatibility Types *)
+ int = int32;
+ unsigned = int32u;
+ size_t = int32u;
+
+(* Pascal Pointer Computation Type *)
+{$IFDEF CPU64 }
+ ptrcomp = system.int64;
+
+{$ELSE }
+ ptrcomp = integer;
+
+{$ENDIF }
+
+(* Type Pointers *)
+ int8_ptr = ^int8;
+ int8_ptr_ptr = ^int8_ptr;
+
+ int8u_ptr = ^int8u;
+ int8u_ptr_ptr = ^int8u_ptr;
+
+ int16_ptr = ^int16;
+ int16_ptr_ptr = ^int16_ptr;
+
+ int16u_ptr = ^int16u;
+ int16u_ptr_ptr = ^int16u_ptr;
+
+ int32_ptr = ^int32;
+ int32_ptr_ptr = ^int32_ptr;
+
+ int32u_ptr = ^int32u;
+ int32u_ptr_ptr = ^int32u_ptr;
+
+ int64_ptr = ^int64;
+ int64_ptr_ptr = ^int64_ptr;
+
+ int64u_ptr = ^int64u;
+ int64u_ptr_ptr = ^int64u_ptr;
+
+ char8_ptr = ^char8;
+ char8_ptr_ptr = ^char8_ptr;
+
+ char16_ptr = ^char16;
+ char16_ptr_ptr = ^char16_ptr;
+
+ char32_ptr = ^char32;
+ char32_ptr_ptr = ^char32_ptr;
+
+ int_ptr = ^int;
+ int_ptr_ptr = ^int_ptr;
+
+ unsigned_ptr = ^unsigned;
+ unsigned_ptr_ptr = ^unsigned_ptr;
+
+ char_ptr = ^char;
+ char_ptr_ptr = ^char_ptr;
+
+(* Expat Types *)
+{$IFDEF XML_UNICODE } // Information is UTF-16 encoded.
+{$IFDEF XML_UNICODE_WCHAR_T }
+ XML_Char = int16u;
+ XML_LChar = int16u;
+
+{$ELSE }
+ XML_Char = word;
+ XML_LChar = char;
+
+{$ENDIF }
+
+{$ELSE } // Information is UTF-8 encoded.
+ XML_Char = char;
+ XML_LChar = char;
+
+{$ENDIF }
+
+ XML_Char_ptr = ^XML_Char;
+ XML_LChar_ptr = ^XML_LChar;
+
+ XML_Char_ptr_ptr = ^XML_Char_ptr;
+
+{$IFDEF XML_LARGE_SIZE } // Use large integers for file/stream positions.
+ XML_Index = int64;
+ XML_Size = int64u;
+
+{$ELSE }
+ XML_Index = longint;
+ XML_Size = longword;
+
+{$ENDIF }
+
diff --git a/src/corelib/render/software/agg-demos/expat-pas/expat_external.pas b/src/corelib/render/software/agg-demos/expat-pas/expat_external.pas
index 0d936abb..cda1d98f 100755..100644
--- a/src/corelib/render/software/agg-demos/expat-pas/expat_external.pas
+++ b/src/corelib/render/software/agg-demos/expat-pas/expat_external.pas
@@ -1,52 +1,52 @@
-//----------------------------------------------------------------------------
-// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
-// and Clark Cooper
-// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
-//
-// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
-// Pascal Port By: Milan Marusinec alias Milano
-// milan@marusinec.sk
-// http://www.pasports.org/pasexpat
-// Copyright (c) 2006
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// [Pascal Port History] -----------------------------------------------------
-//
-// 03.05.2006-Milano: Unit port establishment
-//
-{ expat_external.pas }
-unit
- expat_external ;
-
-INTERFACE
-
-{$I expat_mode.inc }
-
-{ TYPES DEFINITION }
-type
-{$I expat_external.inc }
-
-IMPLEMENTATION
-{ LOCAL VARIABLES & CONSTANTS }
-{ UNIT IMPLEMENTATION }
-
-END.
-
+//----------------------------------------------------------------------------
+// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+// and Clark Cooper
+// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
+//
+// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
+// Pascal Port By: Milan Marusinec alias Milano
+// milan@marusinec.sk
+// http://www.pasports.org/pasexpat
+// Copyright (c) 2006
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// [Pascal Port History] -----------------------------------------------------
+//
+// 03.05.2006-Milano: Unit port establishment
+//
+{ expat_external.pas }
+unit
+ expat_external ;
+
+INTERFACE
+
+{$I expat_mode.inc }
+
+{ TYPES DEFINITION }
+type
+{$I expat_external.inc }
+
+IMPLEMENTATION
+{ LOCAL VARIABLES & CONSTANTS }
+{ UNIT IMPLEMENTATION }
+
+END.
+
diff --git a/src/corelib/render/software/agg-demos/expat-pas/expat_mode.inc b/src/corelib/render/software/agg-demos/expat-pas/expat_mode.inc
index e6422fe8..1de7e1e3 100755..100644
--- a/src/corelib/render/software/agg-demos/expat-pas/expat_mode.inc
+++ b/src/corelib/render/software/agg-demos/expat-pas/expat_mode.inc
@@ -1,92 +1,92 @@
-//
-// PasExpat 2.0.0 RM0.83 compiler options configuration file
-//
-
-{DEFINE EXPAT_DEBUG }
-
-//----------------------------------------------------------------------------
-
-{DEFINE XML_UNICODE_WCHAR_T }
-{DEFINE XML_LARGE_SIZE }
-{DEFINE XML_MIN_SIZE }
-
-//----- PLATFORM DEPENDENT CONFIG --------------------------------------------
-
-{IFDEF WIN32 }
- {$I winconfig.inc }
-
-{ENDIF }
-
-//----------------------------------------------------------------------------
-{$IFDEF XML_UNICODE_WCHAR_T }
- {$DEFINE XML_UNICODE }
-
-{$ENDIF }
-
-{$IFDEF CPUPOWERPC }
- {$DEFINE EXPAT_CPU_PPC }
-
-{$ENDIF }
-
-{$IFDEF CPUI386 }
- {$DEFINE EXPAT_CPU_386 }
-
-{$ENDIF }
-
-{$IFDEF CPU386 }
- {$DEFINE EXPAT_CPU_386 }
-
-{$ENDIF }
-
-{$IFDEF FPC }
- {$MODE DELPHI }
-
-{$ENDIF }
-
-//----------------------------------------------------------------------------
-{$IFDEF EXPAT_DEBUG }
- {$DEFINE EXPAT_FULL_DEBUG }
-
-{$ENDIF }
-
-//----------------------------------------------------------------------------
-{ SWITCHES CONFIGURATION }
-{$IFNDEF FPC }
- {$A- }{ Fields alignment OFF }
- {$F+ }{ Far code generation }
-{$ENDIF }
-
-{$B- }{ Complete boolean evaluation }
-{$V- }{ String type checking }
-{$X+ }{ Extended syntax }
-
-{$IFDEF EXPAT_FULL_DEBUG }
- {$R+ }{ Range checking }
- {$I+ }{ IO checking }
- {$Q+ }{ Overflow checking }
-
- {$IFNDEF FPC }
- {$O- }{ Code Optimization }
- {$ENDIF }
-
- {$D+ }{ Debug Info ON }
- {$Y+ }{ References Info ON }
-
-{$ELSE }
- {$R- }{ Range checking }
- {$I- }{ IO checking }
- {$Q- }{ Overflow checking }
-
- { Code Optimization }
- {$IFNDEF FPC }
- {$IFDEF EXPAT_OPTIMIZE }
- {$O+ }
- {$ELSE }
- {$O- }
- {$ENDIF }
- {$ENDIF }
-
- {$D- }{ Debug Info OFF }
- {$Y- }{ References Info OFF }
-
-{$ENDIF }
+//
+// PasExpat 2.0.0 RM0.83 compiler options configuration file
+//
+
+{DEFINE EXPAT_DEBUG }
+
+//----------------------------------------------------------------------------
+
+{DEFINE XML_UNICODE_WCHAR_T }
+{DEFINE XML_LARGE_SIZE }
+{DEFINE XML_MIN_SIZE }
+
+//----- PLATFORM DEPENDENT CONFIG --------------------------------------------
+
+{IFDEF WIN32 }
+ {$I winconfig.inc }
+
+{ENDIF }
+
+//----------------------------------------------------------------------------
+{$IFDEF XML_UNICODE_WCHAR_T }
+ {$DEFINE XML_UNICODE }
+
+{$ENDIF }
+
+{$IFDEF CPUPOWERPC }
+ {$DEFINE EXPAT_CPU_PPC }
+
+{$ENDIF }
+
+{$IFDEF CPUI386 }
+ {$DEFINE EXPAT_CPU_386 }
+
+{$ENDIF }
+
+{$IFDEF CPU386 }
+ {$DEFINE EXPAT_CPU_386 }
+
+{$ENDIF }
+
+{$IFDEF FPC }
+ {$MODE DELPHI }
+
+{$ENDIF }
+
+//----------------------------------------------------------------------------
+{$IFDEF EXPAT_DEBUG }
+ {$DEFINE EXPAT_FULL_DEBUG }
+
+{$ENDIF }
+
+//----------------------------------------------------------------------------
+{ SWITCHES CONFIGURATION }
+{$IFNDEF FPC }
+ {$A- }{ Fields alignment OFF }
+ {$F+ }{ Far code generation }
+{$ENDIF }
+
+{$B- }{ Complete boolean evaluation }
+{$V- }{ String type checking }
+{$X+ }{ Extended syntax }
+
+{$IFDEF EXPAT_FULL_DEBUG }
+ {$R+ }{ Range checking }
+ {$I+ }{ IO checking }
+ {$Q+ }{ Overflow checking }
+
+ {$IFNDEF FPC }
+ {$O- }{ Code Optimization }
+ {$ENDIF }
+
+ {$D+ }{ Debug Info ON }
+ {$Y+ }{ References Info ON }
+
+{$ELSE }
+ {$R- }{ Range checking }
+ {$I- }{ IO checking }
+ {$Q- }{ Overflow checking }
+
+ { Code Optimization }
+ {$IFNDEF FPC }
+ {$IFDEF EXPAT_OPTIMIZE }
+ {$O+ }
+ {$ELSE }
+ {$O- }
+ {$ENDIF }
+ {$ENDIF }
+
+ {$D- }{ Debug Info OFF }
+ {$Y- }{ References Info OFF }
+
+{$ENDIF }
diff --git a/src/corelib/render/software/agg-demos/expat-pas/iasciitab.inc b/src/corelib/render/software/agg-demos/expat-pas/iasciitab.inc
index 620240cf..4518ef99 100755..100644
--- a/src/corelib/render/software/agg-demos/expat-pas/iasciitab.inc
+++ b/src/corelib/render/software/agg-demos/expat-pas/iasciitab.inc
@@ -1,69 +1,69 @@
-//----------------------------------------------------------------------------
-// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
-// and Clark Cooper
-// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
-//
-// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
-// Pascal Port By: Milan Marusinec alias Milano
-// milan@marusinec.sk
-// http://www.pasports.org/pasexpat
-// Copyright (c) 2006
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// [Pascal Port History] -----------------------------------------------------
-//
-// 17.05.2006-Milano: Unit port establishment
-//
-{ iasciitab.inc }
-{ Like asciitab.h, except that $D has code BT_S rather than BT_CR }
-{ $00 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $04 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $08 } BT_NONXML ,BT_S ,BT_LF ,BT_NONXML ,
-{ $0C } BT_NONXML ,BT_S ,BT_NONXML ,BT_NONXML ,
-{ $10 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $14 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $18 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $1C } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $20 } BT_S ,BT_EXCL ,BT_QUOT ,BT_NUM ,
-{ $24 } BT_OTHER ,BT_PERCNT ,BT_AMP ,BT_APOS ,
-{ $28 } BT_LPAR ,BT_RPAR ,BT_AST ,BT_PLUS ,
-{ $2C } BT_COMMA ,BT_MINUS ,BT_NAME ,BT_SOL ,
-{ $30 } BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,
-{ $34 } BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,
-{ $38 } BT_DIGIT ,BT_DIGIT ,BT_COLON ,BT_SEMI ,
-{ $3C } BT_LT ,BT_EQUALS ,BT_GT ,BT_QUEST ,
-{ $40 } BT_OTHER ,BT_HEX ,BT_HEX ,BT_HEX ,
-{ $44 } BT_HEX ,BT_HEX ,BT_HEX ,BT_NMSTRT ,
-{ $48 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $4C } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $50 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $54 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $58 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_LSQB ,
-{ $5C } BT_OTHER ,BT_RSQB ,BT_OTHER ,BT_NMSTRT ,
-{ $60 } BT_OTHER ,BT_HEX ,BT_HEX ,BT_HEX ,
-{ $64 } BT_HEX ,BT_HEX ,BT_HEX ,BT_NMSTRT ,
-{ $68 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $6C } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $70 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $74 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $78 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_OTHER ,
-{ $7C } BT_VERBAR ,BT_OTHER ,BT_OTHER ,BT_OTHER ,
-
+//----------------------------------------------------------------------------
+// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+// and Clark Cooper
+// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
+//
+// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
+// Pascal Port By: Milan Marusinec alias Milano
+// milan@marusinec.sk
+// http://www.pasports.org/pasexpat
+// Copyright (c) 2006
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// [Pascal Port History] -----------------------------------------------------
+//
+// 17.05.2006-Milano: Unit port establishment
+//
+{ iasciitab.inc }
+{ Like asciitab.h, except that $D has code BT_S rather than BT_CR }
+{ $00 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $04 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $08 } BT_NONXML ,BT_S ,BT_LF ,BT_NONXML ,
+{ $0C } BT_NONXML ,BT_S ,BT_NONXML ,BT_NONXML ,
+{ $10 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $14 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $18 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $1C } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $20 } BT_S ,BT_EXCL ,BT_QUOT ,BT_NUM ,
+{ $24 } BT_OTHER ,BT_PERCNT ,BT_AMP ,BT_APOS ,
+{ $28 } BT_LPAR ,BT_RPAR ,BT_AST ,BT_PLUS ,
+{ $2C } BT_COMMA ,BT_MINUS ,BT_NAME ,BT_SOL ,
+{ $30 } BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,
+{ $34 } BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,
+{ $38 } BT_DIGIT ,BT_DIGIT ,BT_COLON ,BT_SEMI ,
+{ $3C } BT_LT ,BT_EQUALS ,BT_GT ,BT_QUEST ,
+{ $40 } BT_OTHER ,BT_HEX ,BT_HEX ,BT_HEX ,
+{ $44 } BT_HEX ,BT_HEX ,BT_HEX ,BT_NMSTRT ,
+{ $48 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $4C } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $50 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $54 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $58 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_LSQB ,
+{ $5C } BT_OTHER ,BT_RSQB ,BT_OTHER ,BT_NMSTRT ,
+{ $60 } BT_OTHER ,BT_HEX ,BT_HEX ,BT_HEX ,
+{ $64 } BT_HEX ,BT_HEX ,BT_HEX ,BT_NMSTRT ,
+{ $68 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $6C } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $70 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $74 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $78 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_OTHER ,
+{ $7C } BT_VERBAR ,BT_OTHER ,BT_OTHER ,BT_OTHER ,
+
diff --git a/src/corelib/render/software/agg-demos/expat-pas/iasciitab_bt_colon_.inc b/src/corelib/render/software/agg-demos/expat-pas/iasciitab_bt_colon_.inc
index c38172f2..3e995f05 100755..100644
--- a/src/corelib/render/software/agg-demos/expat-pas/iasciitab_bt_colon_.inc
+++ b/src/corelib/render/software/agg-demos/expat-pas/iasciitab_bt_colon_.inc
@@ -1,68 +1,68 @@
-//----------------------------------------------------------------------------
-// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
-// and Clark Cooper
-// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
-//
-// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
-// Pascal Port By: Milan Marusinec alias Milano
-// milan@marusinec.sk
-// http://www.pasports.org/pasexpat
-// Copyright (c) 2006
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// [Pascal Port History] -----------------------------------------------------
-//
-// 17.05.2006-Milano: Unit port establishment
-//
-{ iasciitab_bt_colon_.inc }
-{ Like asciitab.h, except that $D has code BT_S rather than BT_CR }
-{ $00 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $04 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $08 } BT_NONXML ,BT_S ,BT_LF ,BT_NONXML ,
-{ $0C } BT_NONXML ,BT_S ,BT_NONXML ,BT_NONXML ,
-{ $10 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $14 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $18 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $1C } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $20 } BT_S ,BT_EXCL ,BT_QUOT ,BT_NUM ,
-{ $24 } BT_OTHER ,BT_PERCNT ,BT_AMP ,BT_APOS ,
-{ $28 } BT_LPAR ,BT_RPAR ,BT_AST ,BT_PLUS ,
-{ $2C } BT_COMMA ,BT_MINUS ,BT_NAME ,BT_SOL ,
-{ $30 } BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,
-{ $34 } BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,
-{ $38 } BT_DIGIT ,BT_DIGIT ,BT_COLON_ ,BT_SEMI ,
-{ $3C } BT_LT ,BT_EQUALS ,BT_GT ,BT_QUEST ,
-{ $40 } BT_OTHER ,BT_HEX ,BT_HEX ,BT_HEX ,
-{ $44 } BT_HEX ,BT_HEX ,BT_HEX ,BT_NMSTRT ,
-{ $48 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $4C } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $50 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $54 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $58 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_LSQB ,
-{ $5C } BT_OTHER ,BT_RSQB ,BT_OTHER ,BT_NMSTRT ,
-{ $60 } BT_OTHER ,BT_HEX ,BT_HEX ,BT_HEX ,
-{ $64 } BT_HEX ,BT_HEX ,BT_HEX ,BT_NMSTRT ,
-{ $68 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $6C } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $70 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $74 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
-{ $78 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_OTHER ,
-{ $7C } BT_VERBAR ,BT_OTHER ,BT_OTHER ,BT_OTHER ,
+//----------------------------------------------------------------------------
+// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+// and Clark Cooper
+// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
+//
+// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
+// Pascal Port By: Milan Marusinec alias Milano
+// milan@marusinec.sk
+// http://www.pasports.org/pasexpat
+// Copyright (c) 2006
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// [Pascal Port History] -----------------------------------------------------
+//
+// 17.05.2006-Milano: Unit port establishment
+//
+{ iasciitab_bt_colon_.inc }
+{ Like asciitab.h, except that $D has code BT_S rather than BT_CR }
+{ $00 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $04 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $08 } BT_NONXML ,BT_S ,BT_LF ,BT_NONXML ,
+{ $0C } BT_NONXML ,BT_S ,BT_NONXML ,BT_NONXML ,
+{ $10 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $14 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $18 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $1C } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $20 } BT_S ,BT_EXCL ,BT_QUOT ,BT_NUM ,
+{ $24 } BT_OTHER ,BT_PERCNT ,BT_AMP ,BT_APOS ,
+{ $28 } BT_LPAR ,BT_RPAR ,BT_AST ,BT_PLUS ,
+{ $2C } BT_COMMA ,BT_MINUS ,BT_NAME ,BT_SOL ,
+{ $30 } BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,
+{ $34 } BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,BT_DIGIT ,
+{ $38 } BT_DIGIT ,BT_DIGIT ,BT_COLON_ ,BT_SEMI ,
+{ $3C } BT_LT ,BT_EQUALS ,BT_GT ,BT_QUEST ,
+{ $40 } BT_OTHER ,BT_HEX ,BT_HEX ,BT_HEX ,
+{ $44 } BT_HEX ,BT_HEX ,BT_HEX ,BT_NMSTRT ,
+{ $48 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $4C } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $50 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $54 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $58 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_LSQB ,
+{ $5C } BT_OTHER ,BT_RSQB ,BT_OTHER ,BT_NMSTRT ,
+{ $60 } BT_OTHER ,BT_HEX ,BT_HEX ,BT_HEX ,
+{ $64 } BT_HEX ,BT_HEX ,BT_HEX ,BT_NMSTRT ,
+{ $68 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $6C } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $70 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $74 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,
+{ $78 } BT_NMSTRT ,BT_NMSTRT ,BT_NMSTRT ,BT_OTHER ,
+{ $7C } BT_VERBAR ,BT_OTHER ,BT_OTHER ,BT_OTHER ,
diff --git a/src/corelib/render/software/agg-demos/expat-pas/readme.txt b/src/corelib/render/software/agg-demos/expat-pas/readme.txt
index 351a5f9a..1449e860 100755..100644
--- a/src/corelib/render/software/agg-demos/expat-pas/readme.txt
+++ b/src/corelib/render/software/agg-demos/expat-pas/readme.txt
@@ -1,104 +1,104 @@
-================================================================================
-
- Expat XML Parser - version 2.0.0
- Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
- and Clark Cooper
- Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
-
- Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
- Pascal Port By: Milan Marusinec alias Milano
- milan@marusinec.sk
- http://www.pasports.org/pasexpat
- Copyright (c) 2006
-
-================================================================================
- Introduction
-================================================================================
-
- Expat is an XML parser library written in C. It is a stream-oriented parser
- in which an application registers handlers for things the parser might find
- in the XML document (like start tags).
-
- Read more at: http://expat.sourceforge.net
-
- This version of Expat library is the Object Pascal one and this Readme Note
- is dealing with issues mainly around the Pascal version.
-
-================================================================================
- Compilation matrix
-================================================================================
-
- Expat can be currently compiled on the platforms with compilers
- according to the following matrix:
-
- +----------------------+---------------------+---------------------+
- | Platform / Compiler | Free Pascal (FPC) | Delphi (Borland) |
- +======================+=====================+=====================+
- | Windows Win32 API | versions 2.0 and up | versions 2.0 and up |
- +----------------------+---------------------+---------------------+
- | Linux X11 | versions 2.0 and up | * no support * |
- +----------------------+---------------------+---------------------+
- | Mac OS X Carbon | versions 2.0 and up | * no support * |
- +----------------------+---------------------+---------------------+
-
-================================================================================
- Port comments
-================================================================================
-
- The Object Pascal version (PasExpat) was created for the main reason of having
- a pascal version of the library when porting the SVG demo example in the AggPas
- porting project, which was dependant on Expat for C.
-
- This port is based on the C version 2.0.0, which was officialy released
- on 11 January 2006.
-
- PasExpat port is the pure manual work. There were used no c_to_pascal conversion
- utilities and the port is the native-one, which means it uses no external dll
- bindings - it's all just the native pascal code.
-
- This Pascal library is an unfinished version marked as 0.83, which means
- it is approximately 83% of the functionality of the original C library.
-
- To use the library, just include the "expat" keyword into the uses clause.
-
- General Pascal port Issues
- ==========================
-
- Source code comment marks:
-
- Here and there around the PasExpat source code, following comment marks
- can be found:
-
- {untested} - unit or procedure/function, which was ported but not tested
-
- {not_implemented} - procedure/function, which was not ported, because
- related features were not implemented in port
-
- {hack} - marks some nonstandard solution
-
- {..} - part of the code, which is unfinished.
-
- Compiling mode:
-
- The "expat_mode.inc" is the main compiler mode configuration file.
- The only one item, you would wish to change is the EXPAT_DEBUG conditional,
- which turns on/off the debug mode compilation settings. With the
- EXPAT_DEBUG not defined the range checking for example is turned off,
- which should lead to building the faster and smallest code.
-
-================================================================================
- What's next
-================================================================================
-
- As I said, this version is rather unfinished but sufficient for the AggPas
- SVG demo to work. In the near future, I am not gonna finish it, but if someone
- would need it with full functionality, I suggest to pick up this 0.83 release
- and finish the port.
-
-
- All for now
- Yours Milano
-
-================================================================================
- End of file
-================================================================================
+================================================================================
+
+ Expat XML Parser - version 2.0.0
+ Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+ and Clark Cooper
+ Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
+
+ Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
+ Pascal Port By: Milan Marusinec alias Milano
+ milan@marusinec.sk
+ http://www.pasports.org/pasexpat
+ Copyright (c) 2006
+
+================================================================================
+ Introduction
+================================================================================
+
+ Expat is an XML parser library written in C. It is a stream-oriented parser
+ in which an application registers handlers for things the parser might find
+ in the XML document (like start tags).
+
+ Read more at: http://expat.sourceforge.net
+
+ This version of Expat library is the Object Pascal one and this Readme Note
+ is dealing with issues mainly around the Pascal version.
+
+================================================================================
+ Compilation matrix
+================================================================================
+
+ Expat can be currently compiled on the platforms with compilers
+ according to the following matrix:
+
+ +----------------------+---------------------+---------------------+
+ | Platform / Compiler | Free Pascal (FPC) | Delphi (Borland) |
+ +======================+=====================+=====================+
+ | Windows Win32 API | versions 2.0 and up | versions 2.0 and up |
+ +----------------------+---------------------+---------------------+
+ | Linux X11 | versions 2.0 and up | * no support * |
+ +----------------------+---------------------+---------------------+
+ | Mac OS X Carbon | versions 2.0 and up | * no support * |
+ +----------------------+---------------------+---------------------+
+
+================================================================================
+ Port comments
+================================================================================
+
+ The Object Pascal version (PasExpat) was created for the main reason of having
+ a pascal version of the library when porting the SVG demo example in the AggPas
+ porting project, which was dependant on Expat for C.
+
+ This port is based on the C version 2.0.0, which was officialy released
+ on 11 January 2006.
+
+ PasExpat port is the pure manual work. There were used no c_to_pascal conversion
+ utilities and the port is the native-one, which means it uses no external dll
+ bindings - it's all just the native pascal code.
+
+ This Pascal library is an unfinished version marked as 0.83, which means
+ it is approximately 83% of the functionality of the original C library.
+
+ To use the library, just include the "expat" keyword into the uses clause.
+
+ General Pascal port Issues
+ ==========================
+
+ Source code comment marks:
+
+ Here and there around the PasExpat source code, following comment marks
+ can be found:
+
+ {untested} - unit or procedure/function, which was ported but not tested
+
+ {not_implemented} - procedure/function, which was not ported, because
+ related features were not implemented in port
+
+ {hack} - marks some nonstandard solution
+
+ {..} - part of the code, which is unfinished.
+
+ Compiling mode:
+
+ The "expat_mode.inc" is the main compiler mode configuration file.
+ The only one item, you would wish to change is the EXPAT_DEBUG conditional,
+ which turns on/off the debug mode compilation settings. With the
+ EXPAT_DEBUG not defined the range checking for example is turned off,
+ which should lead to building the faster and smallest code.
+
+================================================================================
+ What's next
+================================================================================
+
+ As I said, this version is rather unfinished but sufficient for the AggPas
+ SVG demo to work. In the near future, I am not gonna finish it, but if someone
+ would need it with full functionality, I suggest to pick up this 0.83 release
+ and finish the port.
+
+
+ All for now
+ Yours Milano
+
+================================================================================
+ End of file
+================================================================================
diff --git a/src/corelib/render/software/agg-demos/expat-pas/utf8tab.inc b/src/corelib/render/software/agg-demos/expat-pas/utf8tab.inc
index d05f745b..d43f8a18 100755..100644
--- a/src/corelib/render/software/agg-demos/expat-pas/utf8tab.inc
+++ b/src/corelib/render/software/agg-demos/expat-pas/utf8tab.inc
@@ -1,67 +1,67 @@
-//----------------------------------------------------------------------------
-// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
-// and Clark Cooper
-// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
-//
-// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
-// Pascal Port By: Milan Marusinec alias Milano
-// milan@marusinec.sk
-// http://www.pasports.org/pasexpat
-// Copyright (c) 2006
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// [Pascal Port History] -----------------------------------------------------
-//
-// 17.05.2006-Milano: Unit port establishment
-//
-{ utf8tab.inc }
-{ $80 } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
-{ $84 } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
-{ $88 } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
-{ $8C } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
-{ $90 } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
-{ $94 } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
-{ $98 } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
-{ $9C } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
-{ $A0 } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
-{ $A4 } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
-{ $A8 } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
-{ $AC } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
-{ $B0 } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
-{ $B4 } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
-{ $B8 } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
-{ $BC } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
-{ $C0 } BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,
-{ $C4 } BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,
-{ $C8 } BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,
-{ $CC } BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,
-{ $D0 } BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,
-{ $D4 } BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,
-{ $D8 } BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,
-{ $DC } BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,
-{ $E0 } BT_LEAD3 ,BT_LEAD3 ,BT_LEAD3 ,BT_LEAD3 ,
-{ $E4 } BT_LEAD3 ,BT_LEAD3 ,BT_LEAD3 ,BT_LEAD3 ,
-{ $E8 } BT_LEAD3 ,BT_LEAD3 ,BT_LEAD3 ,BT_LEAD3 ,
-{ $EC } BT_LEAD3 ,BT_LEAD3 ,BT_LEAD3 ,BT_LEAD3 ,
-{ $F0 } BT_LEAD4 ,BT_LEAD4 ,BT_LEAD4 ,BT_LEAD4 ,
-{ $F4 } BT_LEAD4 ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $F8 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
-{ $FC } BT_NONXML ,BT_NONXML ,BT_MALFORM ,BT_MALFORM
+//----------------------------------------------------------------------------
+// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+// and Clark Cooper
+// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
+//
+// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
+// Pascal Port By: Milan Marusinec alias Milano
+// milan@marusinec.sk
+// http://www.pasports.org/pasexpat
+// Copyright (c) 2006
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// [Pascal Port History] -----------------------------------------------------
+//
+// 17.05.2006-Milano: Unit port establishment
+//
+{ utf8tab.inc }
+{ $80 } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
+{ $84 } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
+{ $88 } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
+{ $8C } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
+{ $90 } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
+{ $94 } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
+{ $98 } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
+{ $9C } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
+{ $A0 } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
+{ $A4 } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
+{ $A8 } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
+{ $AC } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
+{ $B0 } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
+{ $B4 } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
+{ $B8 } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
+{ $BC } BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,BT_TRAIL ,
+{ $C0 } BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,
+{ $C4 } BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,
+{ $C8 } BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,
+{ $CC } BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,
+{ $D0 } BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,
+{ $D4 } BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,
+{ $D8 } BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,
+{ $DC } BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,BT_LEAD2 ,
+{ $E0 } BT_LEAD3 ,BT_LEAD3 ,BT_LEAD3 ,BT_LEAD3 ,
+{ $E4 } BT_LEAD3 ,BT_LEAD3 ,BT_LEAD3 ,BT_LEAD3 ,
+{ $E8 } BT_LEAD3 ,BT_LEAD3 ,BT_LEAD3 ,BT_LEAD3 ,
+{ $EC } BT_LEAD3 ,BT_LEAD3 ,BT_LEAD3 ,BT_LEAD3 ,
+{ $F0 } BT_LEAD4 ,BT_LEAD4 ,BT_LEAD4 ,BT_LEAD4 ,
+{ $F4 } BT_LEAD4 ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $F8 } BT_NONXML ,BT_NONXML ,BT_NONXML ,BT_NONXML ,
+{ $FC } BT_NONXML ,BT_NONXML ,BT_MALFORM ,BT_MALFORM
diff --git a/src/corelib/render/software/agg-demos/expat-pas/winconfig.inc b/src/corelib/render/software/agg-demos/expat-pas/winconfig.inc
index 2b5b01d3..a48bf0d0 100755..100644
--- a/src/corelib/render/software/agg-demos/expat-pas/winconfig.inc
+++ b/src/corelib/render/software/agg-demos/expat-pas/winconfig.inc
@@ -1,52 +1,52 @@
-//----------------------------------------------------------------------------
-// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
-// and Clark Cooper
-// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
-//
-// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
-// Pascal Port By: Milan Marusinec alias Milano
-// milan@marusinec.sk
-// http://www.pasports.org/pasexpat
-// Copyright (c) 2006
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// [Pascal Port History] -----------------------------------------------------
-//
-// 18.05.2006-Milano: Unit port establishment
-//
-{ winconfig.inc }
-{$DEFINE XML_NS }
-{$DEFINE XML_DTD }
-{$DEFINE XML_CONTEXT_BYTES }
-
-{ Windows has memmove() available. }
-{$DEFINE HAVE_MEMMOVE }
-
-{ We will assume all Windows platforms are little endian }
-{$DEFINE BYTEORDER_1234 }
-
-const
- _XML_NS = 1;
- _XML_DTD = 1;
-
- _XML_CONTEXT_BYTES = 1024;
- _BYTEORDER = 1234;
-
+//----------------------------------------------------------------------------
+// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+// and Clark Cooper
+// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
+//
+// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
+// Pascal Port By: Milan Marusinec alias Milano
+// milan@marusinec.sk
+// http://www.pasports.org/pasexpat
+// Copyright (c) 2006
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// [Pascal Port History] -----------------------------------------------------
+//
+// 18.05.2006-Milano: Unit port establishment
+//
+{ winconfig.inc }
+{$DEFINE XML_NS }
+{$DEFINE XML_DTD }
+{$DEFINE XML_CONTEXT_BYTES }
+
+{ Windows has memmove() available. }
+{$DEFINE HAVE_MEMMOVE }
+
+{ We will assume all Windows platforms are little endian }
+{$DEFINE BYTEORDER_1234 }
+
+const
+ _XML_NS = 1;
+ _XML_DTD = 1;
+
+ _XML_CONTEXT_BYTES = 1024;
+ _BYTEORDER = 1234;
+
diff --git a/src/corelib/render/software/agg-demos/expat-pas/xmlparse.inc b/src/corelib/render/software/agg-demos/expat-pas/xmlparse.inc
index a27a73eb..d8b2e9b4 100755..100644
--- a/src/corelib/render/software/agg-demos/expat-pas/xmlparse.inc
+++ b/src/corelib/render/software/agg-demos/expat-pas/xmlparse.inc
@@ -1,6475 +1,6475 @@
-//----------------------------------------------------------------------------
-// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
-// and Clark Cooper
-// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
-//
-// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
-// Pascal Port By: Milan Marusinec alias Milano
-// milan@marusinec.sk
-// http://www.pasports.org/pasexpat
-// Copyright (c) 2006
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// [Pascal Port History] -----------------------------------------------------
-//
-// 03.05.2006-Milano: Unit port establishment
-// 02.06.2006-Milano: porting
-// 06.06.2006-Milano: -"-
-// 07.06.2006-Milano: doProlog
-// 08.06.2006-Milano: doProlog finished, porting
-// 09.06.2006-Milano: porting
-// 12.06.2006-Milano: -"-
-// 14.06.2006-Milano: -"-
-// 15.06.2006-Milano: doContent
-// 16.06.2006-Milano: porting, storeAtts
-// 17.06.2006-Milano: -"-
-// 20.06.2006-Milano: epilogProcessor, porting
-// 22.06.2006-Milano: appendAttributeValue
-//
-{ xmlparse.inc }
-{$Q- }
-{$R- }
-function poolStoreString(pool : STRING_POOL_ptr; enc : ENCODING_ptr; ptr ,end_ : char_ptr ) : XML_Char_ptr; forward;
-procedure poolFinish (pool : STRING_POOL_ptr ); forward;
-procedure poolClear (pool : STRING_POOL_ptr ); forward;
-procedure poolDestroy (pool : STRING_POOL_ptr ); forward;
-function poolAppendChar (pool : STRING_POOL_ptr; c : char ) : int; forward;
-
-function reportProcessingInstruction(parser : XML_Parser; enc : ENCODING_ptr; start ,end_ : char_ptr ) : int; forward;
-function reportComment (parser : XML_Parser; enc : ENCODING_ptr; start ,end_ : char_ptr ) : int; forward;
-
-function getAttributeId(parser : XML_Parser; enc : ENCODING_ptr; start ,end_ : char_ptr ) : ATTRIBUTE_ID_ptr; forward;
-
-function storeAttributeValue(
- parser : XML_Parser; enc : ENCODING_ptr; isCdata : XML_Bool;
- ptr ,end_ : char_ptr; pool : STRING_POOL_ptr ) : XML_Error; forward;
-
-const
- implicitContext : array[0..40 ] of XML_Char = (
- 'x' ,'m' ,'l' ,'=' ,'h' ,'t' ,'t' ,'p' ,':' ,'/' ,'/' ,
- 'w' ,'w' ,'w' ,'.' ,'w' ,'3' ,'.' ,'o' ,'r' ,'g' ,'/' ,
- 'X' ,'M' ,'L' ,'/' ,'1' ,'9' ,'9' ,'8' ,'/' ,
- 'n' ,'a' ,'m' ,'e' ,'s' ,'p' ,'a' ,'c' ,'e' ,#0 );
-
- INIT_TAG_BUF_SIZE = 32; { must be a multiple of sizeof(XML_Char) }
- INIT_DATA_BUF_SIZE = 1024;
- INIT_ATTS_SIZE = 16;
- INIT_ATTS_VERSION = $FFFFFFFF;
- INIT_BLOCK_SIZE = 1024;
- INIT_BUFFER_SIZE = 1024;
-
- EXPAND_SPARE = 24;
-
- INIT_SCAFFOLD_ELEMENTS = 32;
-
- INIT_POWER = 6;
-
-type
- ICHAR_ptr_ptr = ^ICHAR_ptr;
- ICHAR_ptr = ^ICHAR;
-
-{$IFDEF XML_UNICODE }
- ICHAR = int16u;
-
-{$ELSE }
- ICHAR = char;
-
-{$ENDIF }
-
- HASH_TABLE_ITER_ptr = ^HASH_TABLE_ITER;
- HASH_TABLE_ITER = record
- p ,
- end_ : NAMED_ptr_ptr;
-
- end;
-
-const
-{$IFDEF XML_UNICODE }
- XML_ENCODE_MAX = XML_UTF16_ENCODE_MAX;
-
-{$ELSE }
- XML_ENCODE_MAX = XML_UTF8_ENCODE_MAX;
-
-{$ENDIF }
-
-{ memcmp }
-function memcmp(p1 ,p2 : int8u_ptr; l : int ) : int;
-begin
- while l > 0 do
- begin
- if p1^ <> p2^ then
- begin
- result:=p1^ - p2^;
-
- exit;
-
- end;
-
- dec(l );
- inc(ptrcomp(p1 ) );
- inc(ptrcomp(p2 ) );
-
- end;
-
- result:=0;
-
-end;
-
-{ CHAR_HASH }
-{ Basic character hash algorithm, taken from Python's string hash:
- h = h * 1000003 ^ character, the constant being a prime number. }
-function CHAR_HASH(h : int32u; c : XML_Char ) : int32u;
-begin
-{$IFDEF XML_UNICODE }
- result:=(h * $F4243 ) xor int16u(c );
-
-{$ELSE }
- result:=(h * $F4243 ) xor int8u(c );
-
-{$ENDIF }
-
-end;
-
-{ MUST_CONVERT }
-function MUST_CONVERT(enc : ENCODING_ptr; s : char_ptr ) : int;
-begin
-{$IFDEF XML_UNICODE }
- result:=
- int(
- not boolean(enc.isUtf16 ) or
- boolean(int32u(s ) and 1 ) );
-
-{$ELSE }
- result:=int(not boolean(enc.isUtf8 ) );
-
-{$ENDIF }
-
-end;
-
-{ For probing (after a collision) we need a step size relative prime
- to the hash table size, which is a power of 2. We use double-hashing,
- since we can calculate a second hash value cheaply by taking those bits
- of the first hash value that were discarded (masked out) when the table
- index was calculated: index:=hash and mask, where mask:=table.size - 1.
- We limit the maximum step size to table.size div 4 (mask shr 2 ) and make
- it odd, since odd numbers are always relative prime to a power of 2. }
-{ SECOND_HASH }
-function SECOND_HASH(hash ,mask : int32u; power : int8u ) : int8u;
-begin
- result:=((hash and not mask ) shr (power - 1 ) ) and (mask shr 2 );
-
-end;
-
-{ PROBE_STEP }
-function PROBE_STEP(hash ,mask : int32u; power : int8u ) : int8u;
-begin
- result:=SECOND_HASH(hash, mask, power) or 1;
-
-end;
-
-{ XML_T }
-function XML_T(x : char ) : XML_Char;
-begin
- result:=x;
-
-end;
-
-{ XML_L }
-function XML_L(x : char ) : XML_Char;
-begin
- result:=x;
-
-end;
-
-{ ROUND_UP }
-{ Round up n to be a multiple of sz, where sz is a power of 2. }
-function ROUND_UP(n ,sz : int ) : int;
-begin
- result:=(n + (sz - 1 ) ) and not(sz - 1 );
-
-end;
-
-{ XmlConvert }
-procedure XmlConvert(enc : ENCODING_ptr; fromP ,fromLim ,toP ,toLim : pointer );
-begin
-{$IFDEF XML_UNICODE }
- XmlUtf16Convert(enc ,fromP ,fromLim ,toP ,toLim );
-
-{$ELSE }
- XmlUtf8Convert(enc ,fromP ,fromLim ,toP ,toLim );
-
-{$ENDIF }
-
-end;
-
-{ XmlEncode }
-function XmlEncode(charNumber : int; buf : pointer ) : int;
-begin
-{$IFDEF XML_UNICODE }
- result:=XmlUtf16Encode(charNumber ,buf );
-
-{$ELSE }
- result:=XmlUtf8Encode(charNumber ,buf );
-
-{$ENDIF }
-
-end;
-
-{ poolInit }
-procedure poolInit(pool : STRING_POOL_ptr; ms : XML_Memory_Handling_Suite_ptr );
-begin
- pool.blocks :=NIL;
- pool.freeBlocks:=NIL;
- pool.start :=NIL;
- pool.ptr :=NIL;
- pool.end_ :=NIL;
- pool.mem :=ms;
-
-end;
-
-{ hashTableDestroy }
-procedure hashTableDestroy(table : HASH_TABLE_ptr );
-var
- i : size_t;
-
-begin
- i:=0;
-
- while i < table.size do
- begin
- if NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^ <> NIL then
- table.mem.free_fcn(
- pointer(NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^ ) ,
- NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^^.alloc );
-
- inc(i );
-
- end;
-
- table.mem.free_fcn(pointer(table.v ) ,table.a );
-
-end;
-
-{ hashTableInit }
-procedure hashTableInit(p : HASH_TABLE_ptr; ms : XML_Memory_Handling_Suite_ptr );
-begin
- p.power:=0;
- p.size :=0;
- p.used :=0;
- p.v :=NIL;
- p.mem :=ms;
-
-end;
-
-{ hashTableIterInit }
-procedure hashTableIterInit(iter : HASH_TABLE_ITER_ptr; table : HASH_TABLE_ptr );
-begin
- iter.p :=table.v;
- iter.end_:=NAMED_ptr_ptr(ptrcomp(iter.p ) + table.size * sizeof(NAMED_ptr ) );
-
-end;
-
-{ hashTableIterNext }
-function hashTableIterNext(iter : HASH_TABLE_ITER_ptr ) : NAMED_ptr;
-var
- tem : NAMED_ptr;
-
-begin
- while iter.p <> iter.end_ do
- begin
- tem:=iter.p^;
-
- inc(ptrcomp(iter.p ) ,sizeof(NAMED_ptr ) );
-
- if tem <> NIL then
- begin
- result:=tem;
-
- exit;
-
- end;
-
- end;
-
- result:=NIL;
-
-end;
-
-{ dtdCreate }
-function dtdCreate(ms : XML_Memory_Handling_Suite_ptr ) : DTD_ptr;
-var
- p : DTD_ptr;
-
-begin
- ms.malloc_fcn(pointer(p ) ,sizeof(DTD ) );
-
- if p = NIL then
- begin
- result:=p;
-
- exit;
-
- end;
-
- poolInit(@p.pool ,ms );
- poolInit(@p.entityValuePool ,ms );
-
- hashTableInit(@p.generalEntities ,ms );
- hashTableInit(@p.elementTypes ,ms );
- hashTableInit(@p.attributeIds ,ms );
- hashTableInit(@p.prefixes ,ms );
-
-{$IFDEF XML_DTD }
- p.paramEntityRead:=XML_FALSE;
-
- hashTableInit(@p.paramEntities ,ms );
-
-{$ENDIF }
-
- p.defaultPrefix.name :=NIL;
- p.defaultPrefix.binding:=NIL;
-
- p.in_eldecl :=XML_FALSE;
- p.scaffIndex :=NIL;
- p.scaffAlloc :=0;
- p.scaffold :=NIL;
- p.scaffLevel :=0;
- p.scaffSize :=0;
- p.scaffCount :=0;
- p.contentStringLen:=0;
-
- p.keepProcessing :=XML_TRUE;
- p.hasParamEntityRefs:=XML_FALSE;
- p.standalone :=XML_FALSE;
-
- result:=p;
-
-end;
-
-{ dtdDestroy }
-procedure dtdDestroy(p : DTD_ptr; isDocEntity : XML_Bool; ms : XML_Memory_Handling_Suite_ptr );
-var
- iter : HASH_TABLE_ITER;
-
- e : ELEMENT_TYPE_ptr;
-
-begin
- hashTableIterInit(@iter ,@p.elementTypes );
-
- repeat
- e:=ELEMENT_TYPE_ptr(hashTableIterNext(@iter ) );
-
- if e = NIL then
- break;
-
- if e.allocDefaultAtts <> 0 then
- ms.free_fcn(pointer(e.defaultAtts ) ,e.defaultAttsAlloc );
-
- until false;
-
- hashTableDestroy(@p.generalEntities );
-
-{$IFDEF XML_DTD }
- hashTableDestroy(@p.paramEntities );
-
-{$ENDIF }
-
- hashTableDestroy(@p.elementTypes );
- hashTableDestroy(@p.attributeIds );
- hashTableDestroy(@p.prefixes );
-
- poolDestroy(@p.pool );
- poolDestroy(@p.entityValuePool );
-
- if isDocEntity <> 0 then
- begin
- ms.free_fcn(pointer(p.scaffIndex ) ,p.scaffAlloc );
- ms.free_fcn(pointer(p.scaffold ) ,sizeof(CONTENT_SCAFFOLD ) );
-
- end;
-
- ms.free_fcn(pointer(p ) ,sizeof(DTD ) );
-
-end;
-
-{ handleUnknownEncoding {..}
-function handleUnknownEncoding(parser : XML_Parser; encodingName : XML_Char_ptr ) : XML_Error;
-begin
-end;
-
-{ initializeEncoding }
-function initializeEncoding(parser : XML_Parser ) : XML_Error;
-var
- s : char_ptr;
- ok : int;
-
-begin
-{$IFDEF XML_UNICODE {..}
-
-
-{$ELSE }
- s:=pointer(parser.m_protocolEncodingName );
-
-{$ENDIF }
-
- if parser.m_ns <> 0 then
- ok:=XmlInitEncodingNS(@parser.m_initEncoding ,@parser.m_encoding ,pointer(s ) )
- else
- ok:=XmlInitEncoding(@parser.m_initEncoding ,@parser.m_encoding ,pointer(s ) );
-
- if ok <> 0 then
- result:=XML_ERROR_NONE
- else
- result:=handleUnknownEncoding(parser ,parser.m_protocolEncodingName );
-
-end;
-
-{ reportDefault {..}
-procedure reportDefault(parser : XML_Parser; enc : ENCODING_ptr; start ,end_ : char_ptr );
-begin
-end;
-
-{ getContext {..}
-function getContext(parser : XML_Parser ) : XML_Char_ptr;
-begin
-end;
-
-{ processXmlDecl }
-function processXmlDecl(parser : XML_Parser; isGeneralTextEntity : int; s ,next : char_ptr ) : XML_Error;
-var
- encodingName ,version ,versionend : char_ptr;
-
- storedEncName ,storedversion : XML_Char_ptr;
-
- newEncoding : ENCODING_ptr;
-
- standalone ,ok : int;
-
- result_ : XML_Error;
-
-begin
- encodingName :=NIL;
- storedEncName:=NIL;
- newEncoding :=NIL;
- version :=NIL;
- storedversion:=NIL;
- standalone :=-1;
-
- if parser.m_ns <> 0 then
- ok:=
- XmlParseXmlDeclNS(
- isGeneralTextEntity ,parser.m_encoding ,pointer(s ) ,pointer(next ) ,
- @parser.m_eventPtr ,@version ,@versionend ,@encodingName ,
- @newEncoding ,@standalone )
- else
- ok:=
- XmlParseXmlDecl(
- isGeneralTextEntity ,parser.m_encoding ,pointer(s ) ,pointer(next ) ,
- @parser.m_eventPtr ,@version ,@versionend ,@encodingName ,
- @newEncoding ,@standalone );
-
- if ok = 0 then
- if isGeneralTextEntity <> 0 then
- begin
- result:=XML_ERROR_TEXT_DECL;
-
- exit;
-
- end
- else
- begin
- result:=XML_ERROR_XML_DECL;
-
- exit;
-
- end;
-
- if (isGeneralTextEntity = 0 ) and
- (standalone = 1 ) then
- begin
- parser.m_dtd.standalone:=XML_TRUE;
-
- {$IFDEF XML_DTD }
- if parser.m_paramEntityParsing = XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE then
- parser.m_paramEntityParsing:=XML_PARAM_ENTITY_PARSING_NEVER;
-
- {$ENDIF }
-
- end;
-
- if @parser.m_xmlDeclHandler <> NIL then
- begin
- if encodingName <> NIL then
- begin
- storedEncName:=
- poolStoreString(
- @parser.m_temp2Pool ,
- parser.m_encoding ,
- encodingName,
- char_ptr(ptrcomp(encodingName ) + XmlNameLength(parser.m_encoding ,pointer(encodingName ) ) ) );
-
- if storedEncName = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- poolFinish(@parser.m_temp2Pool );
-
- end;
-
- if version <> NIL then
- begin
- storedversion:=
- poolStoreString(
- @parser.m_temp2Pool ,
- parser.m_encoding ,
- version ,
- char_ptr(ptrcomp(versionend ) - parser.m_encoding.minBytesPerChar ) );
-
- if storedversion = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- end;
-
- parser.m_xmlDeclHandler(
- parser.m_handlerArg ,storedversion ,storedEncName ,standalone );
-
- end
- else
- if @parser.m_defaultHandler <> NIL then
- reportDefault(parser ,parser.m_encoding ,s ,next );
-
- if parser.m_protocolEncodingName = NIL then
- begin
- if newEncoding <> NIL then
- begin
- if newEncoding.minBytesPerChar <> parser.m_encoding.minBytesPerChar then
- begin
- parser.m_eventPtr:=encodingName;
-
- result:=XML_ERROR_INCORRECT_ENCODING;
-
- exit;
-
- end;
-
- parser.m_encoding:=newEncoding;
-
- end
- else
- if encodingName <> NIL then
- begin
- if storedEncName = NIL then
- begin
- storedEncName:=
- poolStoreString(
- @parser.m_temp2Pool ,parser.m_encoding ,encodingName ,
- char_ptr(ptrcomp(encodingName ) + XmlNameLength(parser.m_encoding ,pointer(encodingName ) ) ) );
-
- if storedEncName = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- end;
-
- result_:=handleUnknownEncoding(parser ,storedEncName );
-
- poolClear(@parser.m_temp2Pool );
-
- if result_ = XML_ERROR_UNKNOWN_ENCODING then
- parser.m_eventPtr:=encodingName;
-
- result:=result_;
-
- exit;
-
- end;
-
- end;
-
- if (storedEncName <> NIL ) or
- (storedversion <> NIL ) then
- poolClear(@parser.m_temp2Pool );
-
- result:=XML_ERROR_NONE;
-
-end;
-
-{ poolClear }
-procedure poolClear(pool : STRING_POOL_ptr );
-var
- p ,tem : BLOCK_ptr;
-
-begin
- if pool.freeBlocks = NIL then
- pool.freeBlocks:=pool.blocks
-
- else
- begin
- p:=pool.blocks;
-
- while p <> NIL do
- begin
- tem :=p.next;
- p.next :=pool.freeBlocks;
- pool.freeBlocks:=p;
- p :=tem;
-
- end;
-
- end;
-
- pool.blocks:=NIL;
- pool.start :=NIL;
- pool.ptr :=NIL;
- pool.end_ :=NIL;
-
-end;
-
-{ poolDestroy }
-procedure poolDestroy(pool : STRING_POOL_ptr );
-var
- p ,tem : BLOCK_ptr;
-
-begin
- p:=pool.blocks;
-
- while p <> NIL do
- begin
- tem:=p.next;
-
- pool.mem.free_fcn(pointer(p ) ,p.alloc );
-
- p:=tem;
-
- end;
-
- p:=pool.freeBlocks;
-
- while p <> NIL do
- begin
- tem:=p.next;
-
- pool.mem.free_fcn(pointer(p ) ,p.alloc );
-
- p:=tem;
-
- end;
-
-end;
-
-{ poolGrow }
-function poolGrow(pool : STRING_POOL_ptr ) : XML_Bool;
-var
- tem : BLOCK_ptr;
-
- blockSize : int;
-
-begin
- if pool.freeBlocks <> NIL then
- begin
- if pool.start = NIL then
- begin
- pool.blocks :=pool.freeBlocks;
- pool.freeBlocks :=pool.freeBlocks.next;
- pool.blocks.next:=NIL;
-
- pool.start:=@pool.blocks.s;
- pool.end_ :=XML_Char_ptr(ptrcomp(pool.start ) + pool.blocks.size * sizeof(XML_Char ) );
- pool.ptr :=pool.start;
-
- result:=XML_TRUE;
-
- exit;
-
- end;
-
- if ptrcomp(pool.end_ ) - ptrcomp(pool.start ) < pool.freeBlocks.size then
- begin
- tem:=pool.freeBlocks.next;
-
- pool.freeBlocks.next:=pool.blocks;
- pool.blocks :=pool.freeBlocks;
- pool.freeBlocks :=tem;
-
- move(
- pool.start^ ,
- pointer(@pool.blocks.s )^ ,
- ptrcomp(pool.end_ ) - ptrcomp(pool.start ) );
-
- pool.ptr :=XML_Char_ptr(ptrcomp(@pool.blocks.s ) + ptrcomp(pool.ptr ) - ptrcomp(pool.start ) );
- pool.start:=@pool.blocks.s;
- pool.end_ :=XML_Char_ptr(ptrcomp(pool.start ) + pool.blocks.size * sizeof(XML_Char ) );
-
- result:=XML_TRUE;
-
- exit;
-
- end;
-
- end;
-
- if (pool.blocks <> NIL ) and
- (pool.start = @pool.blocks.s ) then
- begin
- blockSize:=(ptrcomp(pool.end_ ) - ptrcomp(pool.start ) ) * 2 div sizeof(XML_Char );
-
- pool.mem.realloc_fcn(
- pointer(pool.blocks ) ,
- pool.blocks.alloc ,
- (sizeof(BLOCK_ptr ) + sizeof(int ) * 2 ) + blockSize * sizeof(XML_Char ) );
-
- if pool.blocks = NIL then
- begin
- result:=XML_FALSE;
-
- exit;
-
- end
- else
- pool.blocks.alloc:=(sizeof(BLOCK_ptr ) + sizeof(int ) * 2 ) + blockSize * sizeof(XML_Char );
-
- pool.blocks.size:=blockSize;
-
- pool.ptr :=XML_Char_ptr(ptrcomp(@pool.blocks.s ) + (ptrcomp(pool.ptr ) - ptrcomp(pool.start ) ) );
- pool.start:=@pool.blocks.s;
- pool.end_ :=XML_Char_ptr(ptrcomp(pool.start ) + blockSize * sizeof(XML_Char ) );
-
- end
- else
- begin
- blockSize:=(ptrcomp(pool.end_ ) - ptrcomp(pool.start ) ) div sizeof(XML_Char );
-
- if blockSize < INIT_BLOCK_SIZE then
- blockSize:=INIT_BLOCK_SIZE
- else
- blockSize:=blockSize * 2;
-
- pool.mem.malloc_fcn(
- pointer(tem ) ,
- (sizeof(BLOCK_ptr ) + sizeof(int ) * 2 ) + blockSize * sizeof(XML_Char ) );
-
- if tem = NIL then
- begin
- result:=XML_FALSE;
-
- exit;
-
- end;
-
- tem.size :=blockSize;
- tem.alloc:=(sizeof(BLOCK_ptr ) + sizeof(int ) * 2 ) + blockSize * sizeof(XML_Char );
- tem.next :=pool.blocks;
-
- pool.blocks:=tem;
-
- if pool.ptr <> pool.start then
- move(
- pool.start^ ,
- pointer(@tem.s )^ ,
- ptrcomp(pool.ptr ) - ptrcomp(pool.start ) );
-
- pool.ptr :=XML_Char_ptr(ptrcomp(@tem.s ) + (ptrcomp(pool.ptr ) - ptrcomp(pool.start ) ) * sizeof(XML_Char ) );
- pool.start:=@tem.s;
- pool.end_ :=XML_Char_ptr(ptrcomp(@tem.s ) + blockSize * sizeof(XML_Char ) );
-
- end;
-
- result:=XML_TRUE;
-
-end;
-
-{ poolAppend }
-function poolAppend(pool : STRING_POOL_ptr; enc : ENCODING_ptr; ptr ,end_ : char_ptr ) : XML_Char_ptr;
-begin
- if (pool.ptr = NIL ) and
- (poolGrow(pool ) = 0 ) then
- begin
- result:=NIL;
-
- exit;
-
- end;
-
- repeat
- XmlConvert(
- enc ,@ptr ,end_ ,
- ICHAR_ptr_ptr(@pool.ptr ) ,
- ICHAR_ptr(pool.end_ ) );
-
- if ptr = end_ then
- break;
-
- if poolGrow(pool ) = 0 then
- result:=NIL;
-
- until false;
-
- result:=pool.start;
-
-end;
-
-{ poolStoreString }
-function poolStoreString(pool : STRING_POOL_ptr; enc : ENCODING_ptr; ptr ,end_ : char_ptr ) : XML_Char_ptr;
-begin
- if poolAppend(pool ,enc ,ptr ,end_ ) = NIL then
- begin
- result:=NIL;
-
- exit;
-
- end;
-
- if (pool.ptr = pool.end_ ) and
- (poolGrow(pool ) = 0 ) then
- begin
- result:=NIL;
-
- exit;
-
- end;
-
- pool.ptr^:=XML_Char(0 );
-
- inc(ptrcomp(pool.ptr ) );
-
- result:=pool.start;
-
-end;
-
-{ poolCopyString }
-function poolCopyString(pool : STRING_POOL_ptr; s : XML_Char_ptr ) : XML_Char_ptr;
-label
- _w0 ;
-
-begin
- goto _w0;
-
- while s^ <> XML_Char(0 ) do
- begin
- _w0:
- if poolAppendChar(pool ,s^ ) = 0 then
- begin
- result:=NIL;
-
- exit;
-
- end;
-
- inc(ptrcomp(s ) ,sizeof(XML_Char ) );
-
- end;
-
- s:=pool.start;
-
- poolFinish(pool );
-
- result:=s;
-
-end;
-
-{ poolAppendString {..}
-function poolAppendString(pool : STRING_POOL_ptr; s : XML_Char_ptr ) : XML_Char_ptr;
-begin
-end;
-
-{ poolStart }
-function poolStart(pool : STRING_POOL_ptr ) : XML_Char_ptr;
-begin
- result:=pool.start;
-
-end;
-
-{ poolLength }
-function poolLength(pool : STRING_POOL_ptr ) : int;
-begin
- result:=ptrcomp(pool.ptr ) - ptrcomp(pool.start );
-
-end;
-
-{ poolChop }
-procedure poolChop(pool : STRING_POOL_ptr );
-begin
- dec(ptrcomp(pool.ptr ) ,sizeof(XML_Char ) );
-
-end;
-
-{ poolLastChar }
-function poolLastChar(pool : STRING_POOL_ptr ) : XML_Char;
-begin
- result:=XML_Char_ptr(ptrcomp(pool.ptr ) - 1 * sizeof(XML_Char ) )^;
-
-end;
-
-{ poolDiscard }
-procedure poolDiscard(pool : STRING_POOL_ptr );
-begin
- pool.ptr:=pool.start;
-
-end;
-
-{ poolFinish }
-procedure poolFinish(pool : STRING_POOL_ptr );
-begin
- pool.start:=pool.ptr;
-
-end;
-
-{ poolAppendChar }
-function poolAppendChar(pool : STRING_POOL_ptr; c : char ) : int;
-begin
- if (pool.ptr = pool.end_ ) and
- (poolGrow(pool ) = 0 ) then
- result:=0
- else
- begin
- pool.ptr^:=c;
-
- inc(ptrcomp(pool.ptr ) );
-
- result:=1;
-
- end;
-
-end;
-
-{ keyeq }
-function keyeq(s1 ,s2 : KEY ) : XML_Bool;
-begin
- while s1^ = s2^ do
- begin
- if s1^ = #0 then
- begin
- result:=XML_TRUE;
-
- exit;
-
- end;
-
- inc(ptrcomp(s1 ) ,sizeof(XML_Char ) );
- inc(ptrcomp(s2 ) ,sizeof(XML_Char ) );
-
- end;
-
- result:=XML_FALSE;
-
-end;
-
-{ hash }
-function hash(s : KEY ) : int32u;
-var
- h : int32u;
-
-begin
- h:=0;
-
- while s^ <> XML_Char(0 ) do
- begin
- h:=CHAR_HASH(h ,s^ );
-
- inc(ptrcomp(s ) ,sizeof(XML_Char ) );
-
- end;
-
- result:=h;
-
-end;
-
-{ lookup }
-function lookup(table : HASH_TABLE_ptr; name : KEY; createSize : size_t ) : NAMED_ptr;
-var
- i ,tsize ,newSize ,j : size_t;
-
- h ,mask ,newMask ,newHash : int32u;
-
- step ,newPower : int8u;
-
- newV : NAMED_ptr_ptr;
-
-begin
- if table.size = 0 then
- begin
- if createSize = 0 then
- begin
- result:=NIL;
-
- exit;
-
- end;
-
- table.power:=INIT_POWER;
-
- { table->size is a power of 2 }
- table.size:=size_t(1 shl INIT_POWER );
-
- tsize:=table.size * sizeof(NAMED_ptr );
-
- table.mem.malloc_fcn(pointer(table.v ) ,tsize );
-
- if table.v = NIL then
- begin
- table.size:=0;
-
- result:=NIL;
-
- exit;
-
- end
- else
- table.a:=tsize;
-
- fillchar(table.v^ ,tsize ,0 );
-
- i:=hash(name ) and (table.size - 1 );
-
- end
- else
- begin
- h :=hash(name );
- mask:=table.size - 1;
- step:=0;
- i :=h and mask;
-
- while NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^ <> NIL do
- begin
- if keyeq(
- name ,
- NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^^.name ) <> 0 then
- begin
- result:=NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^;
-
- exit;
-
- end;
-
- if step = 0 then
- step:=PROBE_STEP(h ,mask ,table.power );
-
- if i < step then
- inc(i ,table.size - step )
- else
- dec(i ,step );
-
- end;
-
- if createSize = 0 then
- begin
- result:=NIL;
-
- exit;
-
- end;
-
- { check for overflow (table is half full) }
- if table.used shr (table.power - 1 ) <> 0 then
- begin
- newPower:=table.power + 1;
- newSize :=size_t(1 shl newPower );
- newMask :=newSize - 1;
- tsize :=newSize * sizeof(NAMED_ptr );
-
- table.mem.malloc_fcn(pointer(newV ) ,tsize );
-
- if newV = NIL then
- begin
- result:=NIL;
-
- exit;
-
- end;
-
- fillchar(newV^ ,tsize ,0 );
-
- i:=0;
-
- while i < table.size do
- begin
- if NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^ <> NIL then
- begin
- newHash:=hash(NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^^.name );
- j :=newHash and newMask;
- step :=0;
-
- while NAMED_ptr_ptr(ptrcomp(newV ) + j * sizeof(NAMED_ptr ) )^ <> NIL do
- begin
- if step = 0 then
- step:=PROBE_STEP(newHash ,newMask ,newPower );
-
- if j < step then
- inc(j ,newSize - step )
- else
- dec(j ,step );
-
- end;
-
- NAMED_ptr_ptr(ptrcomp(newV ) + j * sizeof(NAMED_ptr ) )^:=
- NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^;
-
- end;
-
- inc(i );
-
- end;
-
- table.mem.free_fcn(pointer(table.v ) ,table.a );
-
- table.v :=newV;
- table.a :=tsize;
- table.power:=newPower;
- table.size :=newSize;
-
- i :=h and newMask;
- step:=0;
-
- while NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^ <> NIL do
- begin
- if step = 0 then
- step:=PROBE_STEP(h ,newMask ,newPower );
-
- if i < step then
- inc(i ,newSize - step )
- else
- dec(i ,step );
-
- end;
-
- end;
-
- end;
-
- table.mem.malloc_fcn(
- pointer(NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^ ) ,
- createSize );
-
- if NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^ = NIL then
- begin
- result:=NIL;
-
- exit;
-
- end;
-
- fillchar(NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^^ ,createSize ,0 );
-
- NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^^.name :=name;
- NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^^.alloc:=createSize;
-
- inc(table.used );
-
- result:=NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^;
-
-end;
-
-{ normalizePublicId }
-procedure normalizePublicId(publicId : XML_Char_ptr );
-var
- p ,s : XML_Char_ptr;
-
-begin
- p:=publicId;
- s:=publicId;
-
- while s^ <> XML_Char(0 ) do
- begin
- case s^ of
- XML_Char($20 ) ,XML_Char($D ) ,XML_Char($A ) :
- if (p <> publicId ) and
- (XML_Char_ptr(ptrcomp(p ) -1 * sizeof(XML_Char ) )^ <> XML_Char($20 ) ) then
- begin
- p^:=XML_Char($20 );
-
- inc(ptrcomp(p ) ,sizeof(XML_Char ) );
-
- end;
-
- else
- begin
- p^:=s^;
-
- inc(ptrcomp(p ) ,sizeof(XML_Char ) );
-
- end;
-
- end;
-
- inc(ptrcomp(s ) ,sizeof(XML_Char ) );
-
- end;
-
- if (p <> publicId ) and
- (XML_Char_ptr(ptrcomp(p ) -1 * sizeof(XML_Char ) )^ = XML_Char($20 ) ) then
- dec(ptrcomp(p ) ,sizeof(XML_Char ) );
-
- p^:=XML_T(#0 );
-
-end;
-
-{ setElementTypePrefix {..}
-function setElementTypePrefix(parser : XML_Parser; elementType : ELEMENT_TYPE_ptr ) : int;
-begin
-end;
-
-{ addBinding {..}
-{ addBinding overwrites the value of prefix.binding without checking.
- Therefore one must keep track of the old value outside of addBinding. }
-function addBinding(
- parser : XML_Parser; prefix : PREFIX_ptr; attId : ATTRIBUTE_ID_ptr;
- uri : XML_Char_ptr; bindingsPtr : BINDING_ptr_ptr ) : XML_Error;
-begin
-end;
-
-{ storeRawNames }
-{ Initially tag.rawName always points into the parse buffer;
- for those TAG instances opened while the current parse buffer was
- processed, and not yet closed, we need to store tag.rawName in a more
- permanent location, since the parse buffer is about to be discarded. }
-function storeRawNames(parser : XML_Parser ) : XML_Bool;
-var
- tag : TAG_ptr;
-
- bufSize ,nameLen : int;
-
- rawNameBuf ,temp : char_ptr;
-
-begin
- tag:=parser.m_tagStack;
-
- while tag <> NIL do
- begin
- nameLen :=sizeof(XML_Char ) * (tag.name.strLen + 1 );
- rawNameBuf:=char_ptr(ptrcomp(tag.buf ) + nameLen );
-
- { Stop if already stored. Since tagStack is a stack, we can stop
- at the first entry that has already been copied; everything
- below it in the stack is already been accounted for in a
- previous call to this function. }
- if tag.rawName = rawNameBuf then
- break;
-
- { For re-use purposes we need to ensure that the
- size of tag.buf is a multiple of sizeof(XML_Char ). }
- bufSize:=nameLen + ROUND_UP(tag.rawNameLength ,sizeof(XML_Char ) );
-
- if bufSize > ptrcomp(tag.bufEnd ) - ptrcomp(tag.buf ) then
- begin
- if parser.m_mem.realloc_fcn(pointer(tag.buf ) ,tag.alloc ,bufSize ) then
- temp:=tag.buf
- else
- temp:=NIL;
-
- if temp = NIL then
- begin
- result:=XML_FALSE;
-
- exit;
-
- end;
-
- tag.alloc:=bufSize;
-
- { if tag.name.str points to tag.buf (only when namespace
- processing is off) then we have to update it }
- if tag.name.str = XML_Char_ptr(tag.buf ) then
- tag.name.str:=XML_Char_ptr(temp );
-
- { if tag->name.localPart is set (when namespace processing is on)
- then update it as well, since it will always point into tag->buf }
- if tag.name.localPart <> NIL then
- tag.name.localPart:=
- XML_Char_ptr(
- ptrcomp(temp ) +
- (ptrcomp(tag.name.localPart ) - ptrcomp(tag.buf ) ) );
-
- tag.buf :=temp;
- tag.bufEnd:=char_ptr(ptrcomp(temp ) + bufSize );
- rawNameBuf:=char_ptr(ptrcomp(temp ) + nameLen );
-
- end;
-
- move(tag.rawName^ ,rawNameBuf^ ,tag.rawNameLength );
-
- tag.rawName:=rawNameBuf;
- tag :=tag.parent;
-
- end;
-
- result:=XML_TRUE;
-
-end;
-
-{ storeAtts }
-{ Precondition: all arguments must be non-NULL;
- Purpose:
- - normalize attributes
- - check attributes for well-formedness
- - generate namespace aware attribute names (URI, prefix)
- - build list of attributes for startElementHandler
- - default attributes
- - process namespace declarations (check and report them)
- - generate namespace aware element name (URI, prefix) }
-function storeAtts(
- parser : XML_Parser; enc : ENCODING_ptr;
- attStr : char_ptr; tagNamePtr : TAG_NAME_ptr;
- bindingsPtr : BINDING_ptr_ptr ) : XML_Error;
-var
- dtd : DTD_ptr;
-
- elementType : ELEMENT_TYPE_ptr;
-
- nDefaultAtts ,attIndex ,prefixLen ,i ,n ,nPrefixes ,oldAttsSize ,j ,nsAttsSize : int;
-
- version ,uriHash ,mask : int32u;
-
- step : int8u;
-
- appAtts : XML_Char_ptr_ptr; { the attribute list for the application }
-
- uri ,localPart ,name ,s ,s1 ,s2 : XML_Char_ptr;
-
- c : XML_Char;
-
- binding ,b : BINDING_ptr;
-
- attId ,id : ATTRIBUTE_ID_ptr;
-
- result_ : XML_Error;
-
- isCdata : XML_Bool;
-
- da : DEFAULT_ATTRIBUTE_ptr;
-
- p : TAG_ptr;
-
-label
- _w0 ,_w1 ;
-
-begin
- dtd:=parser.m_dtd; { save one level of indirection }
-
- attIndex :=0;
- nPrefixes:=0;
-
-{ lookup the element type name }
- elementType:=
- ELEMENT_TYPE_ptr(lookup(
- @dtd.elementTypes ,tagNamePtr.str ,0 ) );
-
- if elementType = NIL then
- begin
- name:=poolCopyString(@dtd.pool ,tagNamePtr.str );
-
- if name = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- elementType:=
- ELEMENT_TYPE_ptr(lookup(
- @dtd.elementTypes ,name ,sizeof(ELEMENT_TYPE ) ) );
-
- if elementType = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- if (parser.m_ns <> 0 ) and
- (setElementTypePrefix(parser ,elementType ) = 0 ) then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- end;
-
- nDefaultAtts:=elementType.nDefaultAtts;
-
-{ get the attributes from the tokenizer }
- n:=XmlGetAttributes(enc ,pointer(attStr ) ,parser.m_attsSize ,parser.m_atts );
-
- if n + nDefaultAtts > parser.m_attsSize then
- begin
- oldAttsSize :=parser.m_attsSize;
- parser.m_attsSize:=n + nDefaultAtts + INIT_ATTS_SIZE;
-
- if not parser.m_mem.realloc_fcn(
- pointer(parser.m_atts ) ,
- parser.m_attsAlloc ,
- parser.m_attsSize * sizeof(ATTRIBUTE ) ) then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end
- else
- parser.m_attsAlloc:=parser.m_attsSize * sizeof(ATTRIBUTE );
-
- if n > oldAttsSize then
- XmlGetAttributes(enc ,pointer(attStr ) ,n ,parser.m_atts );
-
- end;
-
- appAtts:=XML_Char_ptr_ptr(parser.m_atts );
-
- i:=0;
-
- while i < n do
- begin
- { add the name and value to the attribute list }
- attId:=
- getAttributeId(
- parser ,enc ,
- pointer(ATTRIBUTE_ptr(ptrcomp(parser.m_atts ) + i * sizeof(ATTRIBUTE ) )^.name ) ,
- pointer(
- ptrcomp(ATTRIBUTE_ptr(ptrcomp(parser.m_atts ) + i * sizeof(ATTRIBUTE ) )^.name ) +
- XmlNameLength(enc ,ATTRIBUTE_ptr(ptrcomp(parser.m_atts ) + i * sizeof(ATTRIBUTE ) )^.name ) ) );
-
- if attId = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- { Detect duplicate attributes by their QNames. This does not work when
- namespace processing is turned on and different prefixes for the same
- namespace are used. For this case we have a check further down. }
- if XML_Char_ptr(ptrcomp(attId.name ) - 1 * sizeof(XML_Char ) )^ <> XML_Char(0 ) then
- begin
- if enc = parser.m_encoding then
- parser.m_eventPtr:=pointer(ATTRIBUTE_ptr(ptrcomp(parser.m_atts ) + i * sizeof(ATTRIBUTE ) )^.name );
-
- result:=XML_ERROR_DUPLICATE_ATTRIBUTE;
-
- exit;
-
- end;
-
- XML_Char_ptr(ptrcomp(attId.name ) - 1 * sizeof(XML_Char ) )^:=XML_Char(1 );
-
- XML_Char_ptr_ptr(ptrcomp(appAtts ) + attIndex * sizeof(XML_Char_ptr ) )^:=attId.name;
-
- inc(attIndex );
-
- if ATTRIBUTE_ptr(ptrcomp(parser.m_atts ) + i * sizeof(ATTRIBUTE ) )^.normalized = #0 then
- begin
- isCdata:=XML_TRUE;
-
- { figure out whether declared as other than CDATA }
- if attId.maybeTokenized <> 0 then
- begin
- j:=0;
-
- while j < nDefaultAtts do
- begin
- if attId = DEFAULT_ATTRIBUTE_ptr(ptrcomp(elementType.defaultAtts ) + j * sizeof(DEFAULT_ATTRIBUTE ) )^.id then
- begin
- isCdata:=DEFAULT_ATTRIBUTE_ptr(ptrcomp(elementType.defaultAtts ) + j * sizeof(DEFAULT_ATTRIBUTE ) )^.isCdata;
-
- break;
-
- end;
-
- inc(j );
-
- end;
-
- end;
-
- { normalize the attribute value }
- result_:=
- storeAttributeValue(
- parser ,enc ,isCdata ,
- pointer(ATTRIBUTE_ptr(ptrcomp(parser.m_atts ) + i * sizeof(ATTRIBUTE ) )^.valuePtr ) ,
- pointer(ATTRIBUTE_ptr(ptrcomp(parser.m_atts ) + i * sizeof(ATTRIBUTE ) )^.valueEnd ) ,
- @parser.m_tempPool );
-
- if result_ <> XML_Error(0 ) then
- begin
- result:=result_;
-
- exit;
-
- end;
-
- XML_Char_ptr_ptr(ptrcomp(appAtts ) + attIndex * sizeof(XML_Char_ptr ) )^:=poolStart(@parser.m_tempPool );
-
- poolFinish(@parser.m_tempPool );
-
- end
- else
- begin
- { the value did not need normalizing }
- XML_Char_ptr_ptr(ptrcomp(appAtts ) + attIndex * sizeof(XML_Char_ptr ) )^:=
- poolStoreString(
- @parser.m_tempPool ,enc ,
- pointer(ATTRIBUTE_ptr(ptrcomp(parser.m_atts ) + i * sizeof(ATTRIBUTE ) )^.valuePtr ) ,
- pointer(ATTRIBUTE_ptr(ptrcomp(parser.m_atts ) + i * sizeof(ATTRIBUTE ) )^.valueEnd ) );
-
- if XML_Char_ptr_ptr(ptrcomp(appAtts ) + attIndex * sizeof(XML_Char_ptr ) )^ = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- poolFinish(@parser.m_tempPool );
-
- end;
-
- { handle prefixed attribute names }
- if attId.prefix <> NIL then
- if attId.xmlns <> 0 then
- begin
- { deal with namespace declarations here }
- result_:=
- addBinding(
- parser ,attId.prefix ,attId ,
- XML_Char_ptr_ptr(ptrcomp(appAtts ) + attIndex * sizeof(XML_Char_ptr ) )^ ,
- bindingsPtr );
-
- if result_ <> XML_Error(0 ) then
- begin
- result:=result_;
-
- exit;
-
- end;
-
- dec(attIndex );
-
- end
- else
- begin
- { deal with other prefixed names later }
- inc(attIndex );
- inc(nPrefixes );
-
- XML_Char_ptr(ptrcomp(attId.name ) - 1 * sizeof(XML_Char ) )^:=XML_Char(2 );
-
- end
- else
- inc(attIndex );
-
- inc(i );
-
- end;
-
-{ set-up for XML_GetSpecifiedAttributeCount and XML_GetIdAttributeIndex }
- parser.m_nSpecifiedAtts:=attIndex;
-
- if (elementType.idAtt <> NIL ) and
- (XML_Char_ptr(ptrcomp(elementType.idAtt.name ) - 1 * sizeof(XML_Char ) )^ <> XML_Char(0 ) ) then
- begin
- i:=0;
-
- while i < attIndex do
- begin
- if XML_Char_ptr_ptr(ptrcomp(appAtts ) + i * sizeof(XML_Char_ptr ) )^ = elementType.idAtt.name then
- begin
- parser.m_idAttIndex:=i;
-
- break;
-
- end;
-
- inc(i ,2 );
-
- end;
-
- end
- else
- parser.m_idAttIndex:=-1;
-
-{ do attribute defaulting }
- i:=0;
-
- while i < nDefaultAtts do
- begin
- da:=DEFAULT_ATTRIBUTE_ptr(ptrcomp(elementType.defaultAtts ) + i * sizeof(DEFAULT_ATTRIBUTE ) );
-
- if (XML_Char_ptr(ptrcomp(da.id.name ) - 1 * sizeof(XML_Char ) )^ = XML_Char(0 ) ) and
- (da.value <> NIL ) then
- if da.id.prefix <> NIL then
- if da.id.xmlns <> 0 then
- begin
- result_:=
- addBinding(
- parser ,da.id.prefix ,da.id ,
- da.value ,bindingsPtr );
-
- if result_ <> XML_Error(0 ) then
- begin
- result:=result_;
-
- exit;
-
- end;
-
- end
- else
- begin
- XML_Char_ptr(ptrcomp(da.id.name ) - 1 * sizeof(XML_Char ) )^:=XML_Char(2 );
-
- inc(nPrefixes );
-
- XML_Char_ptr_ptr(ptrcomp(appAtts ) + attIndex * sizeof(XML_Char_ptr ) )^:=da.id.name;
-
- inc(attIndex );
-
- XML_Char_ptr_ptr(ptrcomp(appAtts ) + attIndex * sizeof(XML_Char_ptr ) )^:=da.value;
-
- inc(attIndex );
-
- end
- else
- begin
- XML_Char_ptr(ptrcomp(da.id.name ) - 1 * sizeof(XML_Char ) )^:=XML_Char(1 );
-
- XML_Char_ptr_ptr(ptrcomp(appAtts ) + attIndex * sizeof(XML_Char_ptr ) )^:=da.id.name;
-
- inc(attIndex );
-
- XML_Char_ptr_ptr(ptrcomp(appAtts ) + attIndex * sizeof(XML_Char_ptr ) )^:=da.value;
-
- inc(attIndex );
-
- end;
-
- inc(i );
-
- end;
-
- XML_Char_ptr_ptr(ptrcomp(appAtts ) + attIndex * sizeof(XML_Char_ptr ) )^:=NIL;
-
-{ expand prefixed attribute names, check for duplicates,
- and clear flags that say whether attributes were specified }
- i:=0;
-
- if nPrefixes <> 0 then
- begin
- { j = hash table index }
- version :=parser.m_nsAttsVersion;
- nsAttsSize:=1 shl parser.m_nsAttsPower;
-
- { size of hash table must be at least 2 * (# of prefixed attributes) }
- if shr_int32(nPrefixes shl 1 ,parser.m_nsAttsPower ) <> 0 then{ true for nsAttsPower = 0 }
- begin
- { hash table size must also be a power of 2 and >= 8 }
- while shr_int32(nPrefixes ,parser.m_nsAttsPower ) <> 0 do
- inc(parser.m_nsAttsPower );
-
- if parser.m_nsAttsPower < 3 then
- parser.m_nsAttsPower:=3;
-
- nsAttsSize:=1 shl parser.m_nsAttsPower;
-
- if not parser.m_mem.realloc_fcn(
- pointer(parser.m_nsAtts ) ,
- parser.m_nsAttsAlloc ,
- nsAttsSize * sizeof(NS_ATT ) ) then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end
- else
- parser.m_nsAttsAlloc:=nsAttsSize * sizeof(NS_ATT );
-
- version:=0; { force re-initialization of nsAtts hash table }
-
- end;
-
- { using a version flag saves us from initializing nsAtts every time }
- if version = 0 then { initialize version flags when version wraps around }
- begin
- version:=INIT_ATTS_VERSION;
-
- j:=nsAttsSize;
-
- while j <> 0 do
- begin
- dec(j );
-
- NS_ATT_ptr(ptrcomp(parser.m_nsAtts ) + j * sizeof(NS_ATT ) )^.version:=version;
-
- end;
-
- end;
-
- dec(version );
-
- parser.m_nsAttsVersion:=version;
-
- { expand prefixed names and check for duplicates }
- while i < attIndex do
- begin
- s:=XML_Char_ptr_ptr(ptrcomp(appAtts ) + i * sizeof(XML_Char_ptr ) )^;
-
- if XML_Char_ptr(ptrcomp(s ) - 1 * sizeof(XML_Char ) )^ = XML_Char(2 ) then { prefixed }
- begin
- uriHash:=0;
-
- XML_Char_ptr(ptrcomp(s ) - 1 * sizeof(XML_Char ) )^:=XML_Char(0 ); { clear flag }
-
- id:=ATTRIBUTE_ID_ptr(lookup(@dtd.attributeIds ,s ,0 ) );
- b :=id.prefix.binding;
-
- if b = NIL then
- begin
- result:=XML_ERROR_UNBOUND_PREFIX;
-
- exit;
-
- end;
-
- { as we expand the name we also calculate its hash value }
- j:=0;
-
- while j < b.uriLen do
- begin
- c:=XML_Char_ptr(ptrcomp(b.uri ) + j * sizeof(XML_Char ) )^;
-
- if poolAppendChar(@parser.m_tempPool ,c ) = 0 then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- uriHash:=CHAR_HASH(uriHash ,c );
-
- inc(j );
-
- end;
-
- while s^ <> XML_T(':' ) do
- inc(ptrcomp(s ) ,sizeof(XML_Char ) );
-
- goto _w0;
-
- while s^ <> XML_Char(0 ) do { copies null terminator }
- begin
- _w0:
- c:=s^;
-
- if poolAppendChar(@parser.m_tempPool ,s^ ) = 0 then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- uriHash:=CHAR_HASH(uriHash ,c );
-
- inc(ptrcomp(s ) ,sizeof(XML_Char ) );
-
- end;
-
- { Check hash table for duplicate of expanded name (uriName).
- Derived from code in lookup(HASH_TABLE *table, ...). }
- step:=0;
- mask:=nsAttsSize - 1;
- j :=uriHash and mask; { index into hash table }
-
- while NS_ATT_ptr(ptrcomp(parser.m_nsAtts ) + j * sizeof(NS_ATT ) )^.version = version do
- begin
- { for speed we compare stored hash values first }
- if uriHash = NS_ATT_ptr(ptrcomp(parser.m_nsAtts ) + j * sizeof(NS_ATT ) )^.hash then
- begin
- s1:=poolStart(@parser.m_tempPool );
- s2:=NS_ATT_ptr(ptrcomp(parser.m_nsAtts ) + j * sizeof(NS_ATT ) )^.uriName;
-
- { s1 is null terminated, but not s2 }
- while (s1^ = s2^ ) and
- (s1^ <> XML_Char(0 ) ) do
- begin
- inc(ptrcomp(s1 ) ,sizeof(XML_Char ) );
- inc(ptrcomp(s2 ) ,sizeof(XML_Char ) );
-
- end;
-
- if s1^ = XML_Char(0 ) then
- begin
- result:=XML_ERROR_DUPLICATE_ATTRIBUTE;
-
- exit;
-
- end;
-
- end;
-
- if step = 0 then
- step:=PROBE_STEP(uriHash ,mask ,parser.m_nsAttsPower );
-
- if j < step then
- inc(j ,nsAttsSize - step )
- else
- dec(j ,step );
-
- end;
-
- if parser.m_ns_triplets <> 0 then { append namespace separator and prefix }
- begin
- XML_Char_ptr(ptrcomp(parser.m_tempPool.ptr ) - 1 * sizeof(XML_Char ) )^:=parser.m_namespaceSeparator;
-
- s:=b.prefix.name;
-
- goto _w1;
-
- while s^ <> XML_Char(0 ) do
- begin
- _w1:
- if poolAppendChar(@parser.m_tempPool ,s^ ) = 0 then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- inc(ptrcomp(s ) ,sizeof(XML_Char ) );
-
- end;
-
- end;
-
- { store expanded name in attribute list }
- s:=poolStart(@parser.m_tempPool );
-
- poolFinish(@parser.m_tempPool );
-
- XML_Char_ptr_ptr(ptrcomp(appAtts ) + i * sizeof(XML_Char_ptr ) )^:=s;
-
- { fill empty slot with new version, uriName and hash value }
- NS_ATT_ptr(ptrcomp(parser.m_nsAtts ) + j * sizeof(NS_ATT ) )^.version:=version;
- NS_ATT_ptr(ptrcomp(parser.m_nsAtts ) + j * sizeof(NS_ATT ) )^.hash :=uriHash;
- NS_ATT_ptr(ptrcomp(parser.m_nsAtts ) + j * sizeof(NS_ATT ) )^.uriName:=s;
-
- dec(nPrefixes );
-
- if nPrefixes = 0 then
- begin
- inc(i ,2 );
-
- break;
-
- end;
-
- end
- else { not prefixed }
- XML_Char_ptr(ptrcomp(s ) - 1 * sizeof(XML_Char ) )^:=XML_Char(0 ); { clear flag }
-
- inc(i ,2 );
-
- end;
-
- end;
-
-{ clear flags for the remaining attributes }
- while i < attIndex do
- begin
- XML_Char_ptr(
- ptrcomp(
- XML_Char_ptr_ptr(ptrcomp(appAtts ) + i * sizeof(XML_Char_ptr ) )^ )
- - 1 * sizeof(XML_Char ) )^:=XML_Char(0 );
-
- inc(i ,2 );
-
- end;
-
- binding:=bindingsPtr^;
-
- while binding <> NIL do
- begin
- XML_Char_ptr(ptrcomp(binding.attId.name ) - 1 * sizeof(XML_Char ) )^:=XML_Char(0 );
-
- binding:=binding.nextTagBinding;
-
- end;
-
- if parser.m_ns = 0 then
- begin
- result:=XML_ERROR_NONE;
-
- exit;
-
- end;
-
-{ expand the element type name }
- if elementType.prefix <> NIL then
- begin
- binding:=elementType.prefix.binding;
-
- if binding = NIL then
- begin
- result:=XML_ERROR_UNBOUND_PREFIX;
-
- exit;
-
- end;
-
- localPart:=tagNamePtr.str;
-
- while localPart^ <> XML_T(':' ) do
- inc(ptrcomp(localPart ) ,sizeof(XML_Char ) );
-
- end
- else
- if dtd.defaultPrefix.binding <> NIL then
- begin
- binding :=dtd.defaultPrefix.binding;
- localPart:=tagNamePtr.str;
-
- end
- else
- begin
- result:=XML_ERROR_NONE;
-
- exit;
-
- end;
-
- prefixLen:=0;
-
- if (parser.m_ns_triplets <> 0 ) and
- (binding.prefix.name <> NIL ) then
- begin
- while XML_Char_ptr(ptrcomp(binding.prefix.name ) + prefixLen * sizeof(XML_Char ) )^ <> XML_Char(0 ) do
- inc(prefixLen );
-
- inc(prefixLen ); { prefixLen includes null terminator }
-
- end;
-
- tagNamePtr.localPart:=localPart;
- tagNamePtr.uriLen :=binding.uriLen;
- tagNamePtr.prefix :=binding.prefix.name;
- tagNamePtr.prefixLen:=prefixLen;
-
- i:=0;
-
- while XML_Char_ptr(ptrcomp(localPart ) + i * sizeof(XML_Char ) )^ <> XML_Char(0 ) do
- inc(i );
-
- inc(i ); { i includes null terminator }
-
- n:=i + binding.uriLen + prefixLen;
-
- if n > binding.uriAlloc then
- begin
- parser.m_mem.malloc_fcn(pointer(uri ) ,(n + EXPAND_SPARE ) * sizeof(XML_Char ) );
-
- if uri = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- j:=binding.uriAlloc;
-
- binding.uriAlloc:=n + EXPAND_SPARE;
-
- move(
- binding.uri^ ,
- uri^ ,
- binding.uriLen * sizeof(XML_Char ) );
-
- p:=parser.m_tagStack;
-
- while p <> NIL do
- begin
- if p.name.str = binding.uri then
- p.name.str:=uri;
-
- p:=p.parent;
-
- end;
-
- parser.m_mem.free_fcn(pointer(binding.uri ) ,j * sizeof(XML_Char ) );
-
- binding.uri:=uri;
-
- end;
-
-{ if namespaceSeparator != '\0' then uri includes it already }
- uri:=XML_Char_ptr(ptrcomp(binding.uri ) + binding.uriLen * sizeof(XML_Char ) );
-
- move(
- localPart^ ,
- uri^ ,
- i * sizeof(XML_Char ) );
-
-{ we always have a namespace separator between localPart and prefix }
- if prefixLen <> 0 then
- begin
- inc(ptrcomp(uri ) ,(i - 1 ) * sizeof(XML_Char ) );
-
- uri^:=parser.m_namespaceSeparator; { replace null terminator }
-
- move(
- binding.prefix.name^ ,
- XML_Char_ptr(ptrcomp(uri ) + 1 * sizeof(XML_Char ) )^ ,
- prefixLen * sizeof(XML_Char ) );
-
- end;
-
- tagNamePtr.str:=binding.uri;
-
- result:=XML_ERROR_NONE;
-
-end;
-
-{ processInternalEntity {..}
-function processInternalEntity(parser : XML_Parser; entity : ENTITY_ptr; betweenDecl : XML_Bool ) : XML_Error;
-begin
-end;
-
-{ epilogProcessor }
-function epilogProcessor(parser : XML_Parser; s ,end_ : char_ptr; nextPtr : char_ptr_ptr ) : XML_Error;
-var
- next : char_ptr;
-
- tok : int;
-
-begin
- parser.m_processor:=@epilogProcessor;
- parser.m_eventPtr :=s;
-
- repeat
- next:=NIL;
- tok :=XmlPrologTok(parser.m_encoding ,pointer(s ) ,pointer(end_ ) ,@next );
-
- parser.m_eventEndPtr:=next;
-
- case tok of
- -XML_TOK_PROLOG_S :
- begin
- if @parser.m_defaultHandler <> NIL then
- begin
- reportDefault(parser ,parser.m_encoding ,s ,next );
-
- if parser.m_parsingStatus.parsing = XML_FINISHED then
- begin
- result:=XML_ERROR_ABORTED;
-
- exit;
-
- end;
-
- end;
-
- nextPtr^:=next;
- result :=XML_ERROR_NONE;
-
- exit;
-
- end;
-
- XML_TOK_NONE :
- begin
- nextPtr^:=s;
- result :=XML_ERROR_NONE;
-
- exit;
-
- end;
-
- XML_TOK_PROLOG_S :
- if @parser.m_defaultHandler <> NIL then
- reportDefault(parser ,parser.m_encoding ,s ,next );
-
- XML_TOK_PI :
- if reportProcessingInstruction(parser ,parser.m_encoding ,s ,next ) = 0 then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- XML_TOK_COMMENT :
- if reportComment(parser ,parser.m_encoding ,s ,next ) = 0 then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- XML_TOK_INVALID :
- begin
- parser.m_eventPtr:=next;
-
- result:=XML_ERROR_INVALID_TOKEN;
-
- exit;
-
- end;
-
- XML_TOK_PARTIAL :
- begin
- if parser.m_parsingStatus.finalBuffer = 0 then
- begin
- nextPtr^:=s;
- result :=XML_ERROR_NONE;
-
- exit;
-
- end;
-
- result:=XML_ERROR_UNCLOSED_TOKEN;
-
- exit;
-
- end;
-
- XML_TOK_PARTIAL_CHAR :
- begin
- if parser.m_parsingStatus.finalBuffer = 0 then
- begin
- nextPtr^:=s;
- result :=XML_ERROR_NONE;
-
- exit;
-
- end;
-
- result:=XML_ERROR_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- else
- begin
- result:=XML_ERROR_JUNK_AFTER_DOC_ELEMENT;
-
- exit;
-
- end;
-
- end;
-
- parser.m_eventPtr:=next;
-
- s:=next;
-
- case parser.m_parsingStatus.parsing of
- XML_SUSPENDED :
- begin
- nextPtr^:=next;
- result :=XML_ERROR_NONE;
-
- exit;
-
- end;
-
- XML_FINISHED :
- begin
- result:=XML_ERROR_ABORTED;
-
- exit;
-
- end;
-
- end;
-
- until false;
-
-end;
-
-{ doCdataSection {..}
-{ startPtr gets set to non-null if the section is closed, and to null if
- the section is not yet closed. }
-function doCdataSection(
- parser : XML_Parser;
- enc : ENCODING_ptr;
- startPtr : char_ptr_ptr;
- end_ : char_ptr;
- nextPtr : char_ptr_ptr;
- haveMore : XML_Bool ) : XML_Error;
-begin
-end;
-
-{ cdataSectionProcessor {..}
-{ The idea here is to avoid using stack for each CDATA section when
- the whole file is parsed with one call. }
-function cdataSectionProcessor(parser : XML_Parser; start ,end_ : char_ptr; endPtr : char_ptr_ptr ) : XML_Error;
-begin
-end;
-
-{ doContent }
-function doContent(
- parser : XML_Parser;
- startTagLevel : int;
- enc : ENCODING_ptr;
- s ,end_ : char_ptr;
- nextPtr : char_ptr_ptr;
- haveMore : XML_Bool ) : XML_Error;
-var
- dtd : DTD_ptr;
-
- eventPP ,eventEndPP : char_ptr_ptr;
-
- next ,rawNameEnd ,fromPtr ,temp ,rawName : char_ptr;
-
- tok ,bufSize ,convLen ,len ,n : int;
-
- c ,ch : XML_Char;
-
- name ,context ,toPtr ,localPart ,prefix ,uri : XML_Char_ptr;
-
- entity : ENTITY_ptr;
-
- result_ : XML_Error;
-
- tag : TAG_ptr;
-
- bindings ,b : BINDING_ptr;
-
- noElmHandlers : XML_Bool;
-
- name_ : TAG_NAME;
-
- buf : array[0..XML_ENCODE_MAX - 1 ] of XML_Char;
-
- dataPtr : ICHAR_ptr;
-
-label
- _break ;
-
-begin
-{ save one level of indirection }
- dtd:=parser.m_dtd;
-
- if enc = parser.m_encoding then
- begin
- eventPP :=@parser.m_eventPtr;
- eventEndPP:=@parser.m_eventEndPtr;
-
- end
- else
- begin
- eventPP :=@parser.m_openInternalEntities.internalEventPtr;
- eventEndPP:=@parser.m_openInternalEntities.internalEventEndPtr;
-
- end;
-
- eventPP^:=s;
-
- repeat
- next:=s; { XmlContentTok doesn't always set the last arg }
-
- tok:=XmlContentTok(enc ,pointer(s ) ,pointer(end_ ) ,@next );
-
- eventEndPP^:=next;
-
- case tok of
- XML_TOK_TRAILING_CR :
- begin
- if haveMore <> 0 then
- begin
- nextPtr^:=s;
- result :=XML_ERROR_NONE;
-
- exit;
-
- end;
-
- eventEndPP^:=end_;
-
- if @parser.m_characterDataHandler <> NIL then
- begin
- c:=XML_Char($A );
-
- parser.m_characterDataHandler(parser.m_handlerArg ,@c ,1 );
-
- end
- else
- if @parser.m_defaultHandler <> NIL then
- reportDefault(parser ,enc ,s ,end_ );
-
- { We are at the end of the final buffer, should we check for
- XML_SUSPENDED, XML_FINISHED? }
- if startTagLevel = 0 then
- begin
- result:=XML_ERROR_NO_ELEMENTS;
-
- exit;
-
- end;
-
- if parser.m_tagLevel <> startTagLevel then
- begin
- result:=XML_ERROR_ASYNC_ENTITY;
-
- exit;
-
- end;
-
- nextPtr^:=end_;
- result :=XML_ERROR_NONE;
-
- exit;
-
- end;
-
- XML_TOK_NONE :
- begin
- if haveMore <> 0 then
- begin
- nextPtr^:=s;
- result :=XML_ERROR_NONE;
-
- exit;
-
- end;
-
- if startTagLevel > 0 then
- begin
- if parser.m_tagLevel <> startTagLevel then
- begin
- result:=XML_ERROR_ASYNC_ENTITY;
-
- exit;
-
- end;
-
- nextPtr^:=s;
- result :=XML_ERROR_NONE;
-
- exit;
-
- end;
-
- result:=XML_ERROR_NO_ELEMENTS;
-
- exit;
-
- end;
-
- XML_TOK_INVALID :
- begin
- eventPP^:=next;
- result :=XML_ERROR_INVALID_TOKEN;
-
- exit;
-
- end;
-
- XML_TOK_PARTIAL :
- begin
- if haveMore <> 0 then
- begin
- nextPtr^:=s;
- result :=XML_ERROR_NONE;
-
- exit;
-
- end;
-
- result:=XML_ERROR_UNCLOSED_TOKEN;
-
- exit;
-
- end;
-
- XML_TOK_PARTIAL_CHAR :
- begin
- if haveMore <> 0 then
- begin
- nextPtr^:=s;
- result :=XML_ERROR_NONE;
-
- exit;
-
- end;
-
- result:=XML_ERROR_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- XML_TOK_ENTITY_REF :
- begin
- ch:=
- XML_Char(XmlPredefinedEntityName(
- enc ,
- pointer(ptrcomp(s ) + enc.minBytesPerChar ) ,
- pointer(ptrcomp(next ) - enc.minBytesPerChar ) ) );
-
- if ch <> XML_Char(0 ) then
- begin
- if @parser.m_characterDataHandler <> NIL then
- parser.m_characterDataHandler(parser.m_handlerArg ,@ch ,1 )
- else
- if @parser.m_defaultHandler <> NIL then
- reportDefault(parser ,enc ,s ,next );
-
- goto _break;
-
- end;
-
- name:=
- poolStoreString(
- @dtd.pool ,enc ,
- char_ptr(ptrcomp(s ) + enc.minBytesPerChar ) ,
- char_ptr(ptrcomp(next ) - enc.minBytesPerChar ) );
-
- if name = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- entity:=ENTITY_ptr(lookup(@dtd.generalEntities ,name ,0 ) );
-
- poolDiscard(@dtd.pool );
-
- { First, determine if a check for an existing declaration is needed;
- if yes, check that the entity exists, and that it is internal,
- otherwise call the skipped entity or default handler. }
- if (dtd.hasParamEntityRefs = 0 ) or
- (dtd.standalone <> 0 ) then
- if entity = NIL then
- begin
- result:=XML_ERROR_UNDEFINED_ENTITY;
-
- exit;
-
- end
- else
- if entity.is_internal = 0 then
- begin
- result:=XML_ERROR_ENTITY_DECLARED_IN_PE;
-
- exit;
-
- end
- else
- else
- if entity = NIL then
- begin
- if @parser.m_skippedEntityHandler <> NIL then
- parser.m_skippedEntityHandler(parser.m_handlerArg ,name ,0 )
- else
- if @parser.m_defaultHandler <> NIL then
- reportDefault(parser ,enc ,s ,next );
-
- goto _break;
-
- end;
-
- if entity.open <> 0 then
- begin
- result:=XML_ERROR_RECURSIVE_ENTITY_REF;
-
- exit;
-
- end;
-
- if entity.notation <> NIL then
- begin
- result:=XML_ERROR_BINARY_ENTITY_REF;
-
- exit;
-
- end;
-
- if entity.textPtr <> NIL then
- begin
- if parser.m_defaultExpandInternalEntities <> 0 then
- begin
- if @parser.m_skippedEntityHandler <> NIL then
- parser.m_skippedEntityHandler(parser.m_handlerArg ,entity.name ,0 )
- else
- if @parser.m_defaultHandler <> NIL then
- reportDefault(parser ,enc ,s ,next );
-
- goto _break;
-
- end;
-
- result_:=processInternalEntity(parser ,entity ,XML_FALSE );
-
- if result_ <> XML_ERROR_NONE then
- begin
- result:=result_;
-
- exit;
-
- end;
-
- end
- else
- if @parser.m_externalEntityRefHandler <> NIL then
- begin
- entity.open:=XML_TRUE;
- context :=getContext(parser );
- entity.open:=XML_FALSE;
-
- if context = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- if parser.m_externalEntityRefHandler(
- parser.m_externalEntityRefHandlerArg ,
- context ,
- entity.base ,
- entity.systemId ,
- entity.publicId ) = 0 then
- begin
- result:=XML_ERROR_EXTERNAL_ENTITY_HANDLING;
-
- exit;
-
- end;
-
- poolDiscard(@parser.m_tempPool );
-
- end
- else
- if @parser.m_defaultHandler <> NIL then
- reportDefault(parser ,enc ,s ,next );
-
- end;
-
- XML_TOK_START_TAG_NO_ATTS ,XML_TOK_START_TAG_WITH_ATTS :
- begin
- if parser.m_freeTagList <> NIL then
- begin
- tag:=parser.m_freeTagList;
-
- parser.m_freeTagList:=parser.m_freeTagList.parent;
-
- end
- else
- begin
- parser.m_mem.malloc_fcn(pointer(tag ) ,sizeof(expat.TAG ) );
-
- if tag = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- parser.m_mem.malloc_fcn(pointer(tag.buf ) ,INIT_TAG_BUF_SIZE );
-
- if tag.buf = NIL then
- begin
- parser.m_mem.free_fcn(pointer(tag ) ,sizeof(expat.TAG ) );
-
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end
- else
- tag.alloc:=INIT_TAG_BUF_SIZE;
-
- tag.bufEnd:=char_ptr(ptrcomp(tag.buf ) + INIT_TAG_BUF_SIZE );
-
- end;
-
- tag.bindings :=NIL;
- tag.parent :=parser.m_tagStack;
- parser.m_tagStack :=tag;
- tag.name.localPart:=NIL;
- tag.name.prefix :=NIL;
- tag.rawName :=char_ptr(ptrcomp(s ) + enc.minBytesPerChar );
- tag.rawNameLength :=XmlNameLength(enc ,pointer(tag.rawName ) );
-
- inc(parser.m_tagLevel );
-
- rawNameEnd:=char_ptr(ptrcomp(tag.rawName ) + tag.rawNameLength );
- fromPtr :=tag.rawName;
- toPtr :=XML_Char_ptr(tag.buf );
-
- repeat
- XmlConvert(
- enc ,
- @fromPtr ,rawNameEnd ,
- ICHAR_ptr_ptr(@toPtr ) ,ICHAR_ptr(ptrcomp(tag.bufEnd ) - 1 ) );
-
- convLen:=(ptrcomp(toPtr ) - ptrcomp(tag.buf ) ) div sizeof(XML_Char );
-
- if fromPtr = rawNameEnd then
- begin
- tag.name.strLen:=convLen;
-
- break;
-
- end;
-
- bufSize:=(ptrcomp(tag.bufEnd ) - ptrcomp(tag.buf ) ) shl 1;
-
- parser.m_mem.realloc_fcn(pointer(tag.buf ) ,tag.alloc ,bufSize );
-
- if temp = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end
- else
- tag.alloc:=bufSize;
-
- tag.buf :=temp;
- tag.bufEnd:=char_ptr(ptrcomp(temp ) + bufSize );
-
- toPtr:=XML_Char_ptr(ptrcomp(temp ) + convLen );
-
- until false;
-
- tag.name.str:=XML_Char_ptr(tag.buf );
-
- toPtr^ :=XML_T(#0 );
- result_:=storeAtts(parser ,enc ,s ,@tag.name ,@tag.bindings );
-
- if result_ <> XML_Error(0 ) then
- begin
- result:=result_;
-
- exit;
-
- end;
-
- if @parser.m_startElementHandler <> NIL then
- parser.m_startElementHandler(
- parser.m_handlerArg ,tag.name.str ,
- XML_Char_ptr_ptr(parser.m_atts ) )
- else
- if @parser.m_defaultHandler <> NIL then
- reportDefault(parser ,enc ,s ,next );
-
- poolClear(@parser.m_tempPool );
-
- end;
-
- XML_TOK_EMPTY_ELEMENT_NO_ATTS ,XML_TOK_EMPTY_ELEMENT_WITH_ATTS :
- begin
- rawName :=char_ptr(ptrcomp(s ) + enc.minBytesPerChar );
- bindings :=NIL;
- noElmHandlers:=XML_TRUE;
-
- name_.str:=
- poolStoreString(
- @parser.m_tempPool ,enc ,rawName ,
- char_ptr(ptrcomp(rawName ) + XmlNameLength(enc ,pointer(rawName ) ) ) );
-
- if name_.str = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- poolFinish(@parser.m_tempPool );
-
- result_:=storeAtts(parser ,enc ,s ,@name_ ,@bindings );
-
- if result_ <> XML_Error(0 ) then
- begin
- result:=result_;
-
- exit;
-
- end;
-
- poolFinish(@parser.m_tempPool );
-
- if @parser.m_startElementHandler <> NIL then
- begin
- parser.m_startElementHandler(
- parser.m_handlerArg ,name_.str ,XML_Char_ptr_ptr(parser.m_atts ) );
-
- noElmHandlers:=XML_FALSE;
-
- end;
-
- if @parser.m_endElementHandler <> NIL then
- begin
- if @parser.m_startElementHandler <> NIL then
- eventPP^:=eventEndPP^;
-
- parser.m_endElementHandler(parser.m_handlerArg ,name_.str );
-
- noElmHandlers:=XML_FALSE;
-
- end;
-
- if (noElmHandlers <> 0 ) and
- (@parser.m_defaultHandler <> NIL ) then
- reportDefault(parser ,enc ,s ,next );
-
- poolClear(@parser.m_tempPool );
-
- while bindings <> NIL do
- begin
- b:=bindings;
-
- if @parser.m_endNamespaceDeclHandler <> NIL then
- parser.m_endNamespaceDeclHandler(parser.m_handlerArg ,b.prefix.name );
-
- bindings :=bindings.nextTagBinding;
- b.nextTagBinding:=parser.m_freeBindingList;
-
- parser.m_freeBindingList:=b;
- b.prefix.binding :=b.prevPrefixBinding;
-
- end;
-
- if parser.m_tagLevel = 0 then
- begin
- result:=epilogProcessor(parser ,next ,end_ ,nextPtr );
-
- exit;
-
- end;
-
- end;
-
- XML_TOK_END_TAG :
- if parser.m_tagLevel = startTagLevel then
- begin
- result:=XML_ERROR_ASYNC_ENTITY;
-
- exit;
-
- end
- else
- begin
- tag :=parser.m_tagStack;
- parser.m_tagStack :=tag.parent;
- tag.parent :=parser.m_freeTagList;
- parser.m_freeTagList:=tag;
-
- rawName:=char_ptr(ptrcomp(s ) + enc.minBytesPerChar * 2 );
- len :=XmlNameLength(enc ,pointer(rawName ) );
-
- if (len <> tag.rawNameLength ) or
- (memcmp(pointer(tag.rawName ) ,pointer(rawName ) ,len ) <> 0 ) then
- begin
- eventPP^:=rawName;
- result :=XML_ERROR_TAG_MISMATCH;
-
- exit;
-
- end;
-
- dec(parser.m_tagLevel );
-
- if @parser.m_endElementHandler <> NIL then
- begin
- localPart:=tag.name.localPart;
-
- if (parser.m_ns <> 0 ) and
- (localPart <> NIL ) then
- begin
- { localPart and prefix may have been overwritten in
- tag->name.str, since this points to the binding->uri
- buffer which gets re-used; so we have to add them again }
- uri:=XML_Char_ptr(ptrcomp(tag.name.str ) + tag.name.uriLen );
-
- { don't need to check for space - already done in storeAtts() }
- while localPart^ <> XML_Char(0 ) do
- begin
- uri^:=localPart^;
-
- inc(ptrcomp(uri ) ,sizeof(XML_Char ) );
- inc(ptrcomp(localPart ) ,sizeof(XML_Char ) );
-
- end;
-
- prefix:=XML_Char_ptr(tag.name.prefix );
-
- if (parser.m_ns_triplets <> 0 ) and
- (prefix <> NIL ) then
- begin
- uri^:=parser.m_namespaceSeparator;
-
- inc(ptrcomp(uri ) ,sizeof(XML_Char ) );
-
- while prefix^ <> XML_Char(0 ) do
- begin
- uri^:=prefix^;
-
- inc(ptrcomp(uri ) ,sizeof(XML_Char ) );
- inc(ptrcomp(prefix ) ,sizeof(XML_Char ) );
-
- end;
-
- end;
-
- uri^:=XML_T(#0 );
-
- end;
-
- parser.m_endElementHandler(parser.m_handlerArg ,tag.name.str );
-
- end
- else
- if @parser.m_defaultHandler <> NIL then
- reportDefault(parser ,enc ,s ,next );
-
- while tag.bindings <> NIL do
- begin
- b:=tag.bindings;
-
- if @parser.m_endNamespaceDeclHandler <> NIL then
- parser.m_endNamespaceDeclHandler(parser.m_handlerArg ,b.prefix.name );
-
- tag.bindings :=tag.bindings.nextTagBinding;
- b.nextTagBinding :=parser.m_freeBindingList;
- parser.m_freeBindingList:=b;
- b.prefix.binding :=b.prevPrefixBinding;
-
- end;
-
- if parser.m_tagLevel = 0 then
- begin
- result:=epilogProcessor(parser ,next ,end_ ,nextPtr );
-
- exit;
-
- end;
-
- end;
-
- XML_TOK_CHAR_REF :
- begin
- n:=XmlCharRefNumber(enc ,pointer(s ) );
-
- if n < 0 then
- begin
- result:=XML_ERROR_BAD_CHAR_REF;
-
- exit;
-
- end;
-
- if @parser.m_characterDataHandler <> NIL then
- parser.m_characterDataHandler(
- parser.m_handlerArg ,@buf[0 ] ,
- XmlEncode(n ,ICHAR_ptr(@buf ) ) )
- else
- if @parser.m_defaultHandler <> NIL then
- reportDefault(parser ,enc ,s ,next );
-
- end;
-
- XML_TOK_XML_DECL :
- begin
- result:=XML_ERROR_MISPLACED_XML_PI;
-
- exit;
-
- end;
-
- XML_TOK_DATA_NEWLINE :
- if @parser.m_characterDataHandler <> NIL then
- begin
- c:=XML_Char($A );
-
- parser.m_characterDataHandler(parser.m_handlerArg ,@c ,1 );
-
- end
- else
- if @parser.m_defaultHandler <> NIL then
- reportDefault(parser ,enc ,s ,next );
-
- XML_TOK_CDATA_SECT_OPEN :
- begin
- if @parser.m_startCdataSectionHandler <> NIL then
- parser.m_startCdataSectionHandler(parser.m_handlerArg )
- {$IFDEF 0 }
- { Suppose you doing a transformation on a document that involves
- changing only the character data. You set up a defaultHandler
- and a characterDataHandler. The defaultHandler simply copies
- characters through. The characterDataHandler does the
- transformation and writes the characters out escaping them as
- necessary. This case will fail to work if we leave out the
- following two lines (because & and < inside CDATA sections will
- be incorrectly escaped).
-
- However, now we have a start/endCdataSectionHandler, so it seems
- easier to let the user deal with this. }
- else
- if @parser.m_characterDataHandler <> NIL then
- parser.m_characterDataHandler(parser.m_handlerArg ,parser.m_dataBuf ,0 )
- {$ENDIF }
- else
- if @parser.m_defaultHandler <> NIL then
- reportDefault(parser ,enc ,s ,next );
-
- result_:=doCdataSection(parser ,enc ,@next ,end_ ,nextPtr ,haveMore );
-
- if result_ <> XML_ERROR_NONE then
- begin
- result:=result_;
-
- exit;
-
- end
- else
- if next = NIL then
- begin
- parser.m_processor:=@cdataSectionProcessor;
-
- result:=result_;
-
- exit;
-
- end;
-
- end;
-
- XML_TOK_TRAILING_RSQB :
- begin
- if haveMore <> 0 then
- begin
- nextPtr^:=s;
- result :=XML_ERROR_NONE;
-
- exit;
-
- end;
-
- if @parser.m_characterDataHandler <> NIL then
- if MUST_CONVERT(enc ,s ) <> 0 then
- begin
- dataPtr:=ICHAR_ptr(parser.m_dataBuf );
-
- XmlConvert(enc ,@s ,end_ ,@dataPtr ,ICHAR_ptr(parser.m_dataBufEnd ) );
-
- parser.m_characterDataHandler(
- parser.m_handlerArg ,
- parser.m_dataBuf ,
- (ptrcomp(dataPtr ) - ptrcomp(parser.m_dataBuf ) ) div sizeof(ICHAR ) );
-
- end
- else
- parser.m_characterDataHandler(
- parser.m_handlerArg ,
- XML_Char_ptr(s ) ,
- (ptrcomp(end_ ) - ptrcomp(s ) ) div sizeof(XML_Char ) )
- else
- if @parser.m_defaultHandler <> NIL then
- reportDefault(parser ,enc ,s ,end_ );
-
- { We are at the end of the final buffer, should we check for
- XML_SUSPENDED, XML_FINISHED? }
- if startTagLevel = 0 then
- begin
- eventPP^:=end_;
- result :=XML_ERROR_NO_ELEMENTS;
-
- exit;
-
- end;
-
- if parser.m_tagLevel <> startTagLevel then
- begin
- eventPP^:=end_;
- result :=XML_ERROR_ASYNC_ENTITY;
-
- exit;
-
- end;
-
- nextPtr^:=end_;
- result :=XML_ERROR_NONE;
-
- exit;
-
- end;
-
- XML_TOK_DATA_CHARS :
- if @parser.m_characterDataHandler <> NIL then
- if MUST_CONVERT(enc ,s ) <> 0 then
- repeat
- dataPtr:=ICHAR_ptr(parser.m_dataBuf );
-
- XmlConvert(enc ,@s ,next ,@dataPtr ,ICHAR_ptr(parser.m_dataBufEnd ) );
-
- eventEndPP^:=s;
-
- parser.m_characterDataHandler(
- parser.m_handlerArg ,
- parser.m_dataBuf ,
- (ptrcomp(dataPtr ) - ptrcomp(parser.m_dataBuf ) ) div sizeof(ICHAR ) );
-
- if s = next then
- break;
-
- eventPP^:=s;
-
- until false
- else
- parser.m_characterDataHandler(
- parser.m_handlerArg ,
- XML_Char_ptr(s ) ,
- (ptrcomp(next ) - ptrcomp(s ) ) div sizeof(XML_Char ) )
-
- else
- if @parser.m_defaultHandler <> NIL then
- reportDefault(parser ,enc ,s ,next );
-
- XML_TOK_PI :
- if reportProcessingInstruction(parser ,enc ,s ,next ) = 0 then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- XML_TOK_COMMENT :
- if reportComment(parser ,enc ,s ,next ) = 0 then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- else
- if @parser.m_defaultHandler <> NIL then
- reportDefault(parser ,enc ,s ,next );
-
- end;
-
- _break:
- eventPP^:=next;
- s :=next;
-
- case parser.m_parsingStatus.parsing of
- XML_SUSPENDED:
- begin
- nextPtr^:=next;
- result :=XML_ERROR_NONE;
-
- exit;
-
- end;
-
- XML_FINISHED:
- begin
- result:=XML_ERROR_ABORTED;
-
- exit;
-
- end;
-
- end;
-
- until false;
-
-{ not reached }
-
-end;
-
-{ contentProcessor }
-function contentProcessor(parser : XML_Parser; start ,end_ : char_ptr; endPtr : char_ptr_ptr ) : XML_Error;
-var
- result_ : XML_Error;
-
-begin
- result_:=
- doContent(
- parser ,0 ,parser.m_encoding ,start ,end_ ,
- endPtr ,XML_Bool(not parser.m_parsingStatus.finalBuffer ) );
-
- if result_ = XML_ERROR_NONE then
- if storeRawNames(parser ) = 0 then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- result:=result_;
-
-end;
-
-{ getElementType {..}
-function getElementType(parser : XML_Parser; enc : ENCODING_ptr; ptr ,end_ : char_ptr ) : ELEMENT_TYPE_ptr;
-begin
-end;
-
-{ getAttributeId }
-function getAttributeId(parser : XML_Parser; enc : ENCODING_ptr; start ,end_ : char_ptr ) : ATTRIBUTE_ID_ptr;
-var
- dtd : DTD_ptr;
-
- id : ATTRIBUTE_ID_ptr;
-
- name : XML_Char_ptr;
-
- i ,j : int;
-
-begin
-{ save one level of indirection }
- dtd:=parser.m_dtd;
-
- if poolAppendChar(@dtd.pool ,XML_T(#0 ) ) = 0 then
- begin
- result:=NIL;
-
- exit;
-
- end;
-
- name:=poolStoreString(@dtd.pool ,enc ,start ,end_ );
-
- if name = NIL then
- begin
- result:=NIL;
-
- exit;
-
- end;
-
-{ skip quotation mark - its storage will be re-used (like in name[-1]) }
- inc(ptrcomp(name ) ,sizeof(XML_Char ) );
-
- id:=ATTRIBUTE_ID_ptr(lookup(@dtd.attributeIds ,name ,sizeof(ATTRIBUTE_ID ) ) );
-
- if id = NIL then
- begin
- result:=NIL;
-
- exit;
-
- end;
-
- if id.name <> name then
- poolDiscard(@dtd.pool )
-
- else
- begin
- poolFinish(@dtd.pool );
-
- if parser.m_ns = 0 then
- else
- if (XML_Char_ptr(ptrcomp(name ) + 0 * sizeof(XML_Char ) )^ = XML_T('x' ) ) and
- (XML_Char_ptr(ptrcomp(name ) + 1 * sizeof(XML_Char ) )^ = XML_T('m' ) ) and
- (XML_Char_ptr(ptrcomp(name ) + 2 * sizeof(XML_Char ) )^ = XML_T('l' ) ) and
- (XML_Char_ptr(ptrcomp(name ) + 3 * sizeof(XML_Char ) )^ = XML_T('n' ) ) and
- (XML_Char_ptr(ptrcomp(name ) + 4 * sizeof(XML_Char ) )^ = XML_T('s' ) ) and
- ((XML_Char_ptr(ptrcomp(name ) + 5 * sizeof(XML_Char ) )^ = XML_T(#0 ) ) or
- (XML_Char_ptr(ptrcomp(name ) + 5 * sizeof(XML_Char ) )^ = XML_T(':' ) ) ) then
- begin
- if XML_Char_ptr(ptrcomp(name ) + 5 * sizeof(XML_Char ) )^ = XML_T(#0 ) then
- id.prefix:=@dtd.defaultPrefix
- else
- id.prefix:=PREFIX_ptr(lookup(@dtd.prefixes ,XML_Char_ptr(ptrcomp(name ) + 6 * sizeof(XML_Char ) ) ,sizeof(PREFIX ) ) );
-
- id.xmlns:=XML_TRUE;
-
- end
- else
- begin
- i:=0;
-
- while XML_Char_ptr(ptrcomp(name ) + i * sizeof(XML_Char ) )^ <> XML_Char(0 ) do
- begin
- { attributes without prefix are *not* in the default namespace }
- if XML_Char_ptr(ptrcomp(name ) + i * sizeof(XML_Char ) )^ = XML_T(':' ) then
- begin
- j:=0;
-
- while j < i do
- begin
- if poolAppendChar(@dtd.pool ,XML_Char_ptr(ptrcomp(name ) + j * sizeof(XML_Char ) )^ ) = 0 then
- begin
- result:=NIL;
-
- exit;
-
- end;
-
- inc(j );
-
- end;
-
- if poolAppendChar(@dtd.pool ,XML_T(#0 ) ) = 0 then
- begin
- result:=NIL;
-
- exit;
-
- end;
-
- id.prefix:=
- PREFIX_ptr(
- lookup(@dtd.prefixes ,poolStart(@dtd.pool ) ,sizeof(PREFIX ) ) );
-
- if id.prefix.name = poolStart(@dtd.pool ) then
- poolFinish(@dtd.pool )
- else
- poolDiscard(@dtd.pool );
-
- break;
-
- end;
-
- inc(i );
-
- end;
-
- end;
-
- end;
-
- result:=id;
-
-end;
-
-{ defineAttribute {..}
-function defineAttribute(
- type_ : ELEMENT_TYPE_ptr; attId : ATTRIBUTE_ID_ptr;
- isCdata ,isId : XML_Bool; value : XML_Char_ptr; parser : XML_Parser ) : int;
-begin
-end;
-
-{ appendAttributeValue }
-function appendAttributeValue(
- parser : XML_Parser; enc : ENCODING_ptr; isCdata : XML_Bool;
- ptr ,end_ : char_ptr; pool : STRING_POOL_ptr ) : XML_Error;
-var
- dtd : DTD_ptr;
-
- next : char_ptr;
-
- tok ,i ,n : int;
-
- buf : array[0..XML_ENCODE_MAX - 1 ] of XML_Char;
-
- name ,textEnd : XML_Char_ptr;
-
- entity : ENTITY_ptr;
-
- checkEntityDecl : char;
-
- ch : XML_Char;
-
- result_ : XML_Error;
-
-label
- _break ,_go0 ;
-
-begin
-{ save one level of indirection }
- dtd:=parser.m_dtd;
-
- repeat
- tok:=XmlAttributeValueTok(enc ,pointer(ptr ) ,pointer(end_ ) ,@next );
-
- case tok of
- XML_TOK_NONE :
- begin
- result:=XML_ERROR_NONE;
-
- exit;
-
- end;
-
- XML_TOK_INVALID :
- begin
- if enc = parser.m_encoding then
- parser.m_eventPtr:=next;
-
- result:=XML_ERROR_INVALID_TOKEN;
-
- end;
-
- XML_TOK_PARTIAL :
- begin
- if enc = parser.m_encoding then
- parser.m_eventPtr:=ptr;
-
- result:=XML_ERROR_INVALID_TOKEN;
-
- end;
-
- XML_TOK_CHAR_REF :
- begin
- n:=XmlCharRefNumber(enc ,pointer(ptr ) );
-
- if n < 0 then
- begin
- if enc = parser.m_encoding then
- parser.m_eventPtr:=ptr;
-
- result:=XML_ERROR_BAD_CHAR_REF;
-
- end;
-
- if (isCdata = 0 ) and
- (n = $20 ) and { space }
- ((poolLength(pool ) = 0 ) or
- (poolLastChar(pool ) = XML_Char($20 ) ) ) then
- goto _break;
-
- n:=XmlEncode(n ,ICHAR_ptr(buf ) );
-
- if n = 0 then
- begin
- if enc = parser.m_encoding then
- parser.m_eventPtr:=ptr;
-
- result:=XML_ERROR_BAD_CHAR_REF;
-
- exit;
-
- end;
-
- i:=0;
-
- while i < n do
- begin
- if poolAppendChar(pool ,buf[i ] ) = 0 then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- inc(i );
-
- end;
-
- end;
-
- XML_TOK_DATA_CHARS :
- if poolAppend(pool ,enc ,ptr ,next ) = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- XML_TOK_TRAILING_CR :
- begin
- next:=char_ptr(ptrcomp(ptr ) + enc.minBytesPerChar );
-
- goto _go0;
-
- end;
-
- XML_TOK_ATTRIBUTE_VALUE_S ,XML_TOK_DATA_NEWLINE :
- _go0:
- begin
- if (isCdata = 0 ) and
- ((poolLength(pool ) = 0 ) or
- (poolLastChar(pool ) = XML_Char($20 ) ) ) then
- goto _break;
-
- if poolAppendChar(pool ,char($20 ) ) = 0 then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- end;
-
- XML_TOK_ENTITY_REF :
- begin
- ch:=
- XML_Char(
- XmlPredefinedEntityName(
- enc ,
- pointer(char_ptr(ptrcomp(ptr ) + enc.minBytesPerChar ) ) ,
- pointer(char_ptr(ptrcomp(next ) - enc.minBytesPerChar ) ) ) );
-
- if ch <> XML_Char(0 ) then
- begin
- if poolAppendChar(pool, ch) = 0 then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- goto _break;
-
- end;
-
- name:=
- poolStoreString(
- @parser.m_temp2Pool ,enc ,
- char_ptr(ptrcomp(ptr ) + enc.minBytesPerChar ) ,
- char_ptr(ptrcomp(next ) - enc.minBytesPerChar ) );
-
- if name = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- entity:=ENTITY_ptr(lookup(@parser.m_dtd.generalEntities ,name ,0 ) );
-
- poolDiscard(@parser.m_temp2Pool );
-
- { First, determine if a check for an existing declaration is needed;
- if yes, check that the entity exists, and that it is internal. }
- if pool = @parser.m_dtd.pool then { are we called from prolog? }
- begin
- if dtd.standalone <> 0 then
- checkEntityDecl:=char(parser.m_openInternalEntities = NIL )
- else
- checkEntityDecl:=char(dtd.hasParamEntityRefs = 0 );
-
- {$IFDEF XML_DTD }
- checkEntityDecl:=char((checkEntityDecl <> #0 ) and (parser.m_prologState.documentEntity <> 0 ) )
-
- {$ENDIF }
-
- end
- else { if pool = @tempPool: we are called from content }
- checkEntityDecl:=char((dtd.hasParamEntityRefs = 0 ) or (dtd.standalone <> 0 ) );
-
- if checkEntityDecl <> #0 then
- if entity = NIL then
- begin
- result:=XML_ERROR_UNDEFINED_ENTITY;
-
- exit;
-
- end
- else
- if entity.is_internal = 0 then
- begin
- result:=XML_ERROR_ENTITY_DECLARED_IN_PE;
-
- exit;
-
- end
- else
- else
- if entity = NIL then
- { Cannot report skipped entity here - see comments on
- skippedEntityHandler.
- if @parser.m_skippedEntityHandler <> NIL then
- parser.m_skippedEntityHandler(parser.m_handlerArg ,name ,0 ); }
- { Cannot call the default handler because this would be
- out of sync with the call to the startElementHandler.
- if (pool = @parser.m_tempPool ) and
- (@parser.m_defaultHandler <> NIL ) then
- reportDefault(parser ,enc ,ptr ,next ); }
- goto _break;
-
- if entity.open <> 0 then
- begin
- if enc = parser.m_encoding then
- parser.m_eventPtr:=ptr;
-
- result:=XML_ERROR_RECURSIVE_ENTITY_REF;
-
- exit;
-
- end;
-
- if entity.notation <> NIL then
- begin
- if enc = parser.m_encoding then
- parser.m_eventPtr:=ptr;
-
- result:=XML_ERROR_BINARY_ENTITY_REF;
-
- exit;
-
- end;
-
- if entity.textPtr = NIL then
- begin
- if enc = parser.m_encoding then
- parser.m_eventPtr:=ptr;
-
- result:=XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF;
-
- exit;
-
- end
- else
- begin
- textEnd:=XML_Char_ptr(ptrcomp(entity.textPtr ) + entity.textLen * sizeof(XML_Char ) );
-
- entity.open:=XML_TRUE;
-
- result_:=
- appendAttributeValue(
- parser ,parser.m_internalEncoding ,isCdata ,
- char_ptr(entity.textPtr ) ,
- char_ptr(textEnd ) ,pool );
-
- entity.open:=XML_FALSE;
-
- if result_ <> XML_Error(0 ) then
- begin
- result:=result_;
-
- exit;
-
- end;
-
- end;
-
- end;
-
- else
- begin
- if enc = parser.m_encoding then
- parser.m_eventPtr:=ptr;
-
- result:=XML_ERROR_UNEXPECTED_STATE;
-
- exit;
-
- end;
-
- end;
-
- _break:
- ptr:=next;
-
- until false;
-
-{ not reached }
-
-end;
-
-{ storeAttributeValue }
-function storeAttributeValue(
- parser : XML_Parser; enc : ENCODING_ptr; isCdata : XML_Bool;
- ptr ,end_ : char_ptr; pool : STRING_POOL_ptr ) : XML_Error;
-var
- result_ : XML_Error;
-
-begin
- result_:=appendAttributeValue(parser ,enc ,isCdata ,ptr ,end_ ,pool );
-
- if result_ <> XML_Error(0 ) then
- begin
- result:=result_;
-
- exit;
-
- end;
-
- if (isCdata = 0 ) and
- (poolLength(pool ) <> 0 ) and
- (poolLastChar(pool ) = XML_Char($20 ) ) then
- poolChop(pool );
-
- if poolAppendChar(pool ,XML_T(#0 ) ) = 0 then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- result:=XML_ERROR_NONE;
-
-end;
-
-{ storeEntityValue {..}
-function storeEntityValue(parser : XML_Parser; enc : ENCODING_ptr; start ,end_ : char_ptr ) : XML_Error;
-begin
-end;
-
-{ doIgnoreSection {..}
-{ startPtr gets set to non-null is the section is closed, and to null
- if the section is not yet closed. }
-function doIgnoreSection(
- parser : XML_Parser;
- enc : ENCODING_ptr;
- startPtr : char_ptr_ptr;
- end_ : char_ptr;
- nextPtr : char_ptr_ptr;
- haveMore : XML_Bool ) : XML_Error;
-begin
-end;
-
-{ ignoreSectionProcessor {..}
-{ The idea here is to avoid using stack for each IGNORE section when
- the whole file is parsed with one call. }
-function ignoreSectionProcessor(parser : XML_Parser; start ,end_ : char_ptr; endPtr : char_ptr_ptr ) : XML_Error;
-begin
-end;
-
-{ nextScaffoldPart {..}
-function nextScaffoldPart(parser : XML_Parser ) : int;
-begin
-end;
-
-{ build_model {..}
-function build_model(parser : XML_Parser ) : XML_Content_ptr;
-begin
-end;
-
-{ reportProcessingInstruction {..}
-function reportProcessingInstruction(parser : XML_Parser; enc : ENCODING_ptr; start ,end_ : char_ptr ) : int;
-begin
-end;
-
-{ normalizeLines {..}
-procedure normalizeLines(s : XML_Char_ptr );
-begin
-end;
-
-{ reportComment }
-function reportComment(parser : XML_Parser; enc : ENCODING_ptr; start ,end_ : char_ptr ) : int;
-var
- data : XML_Char_ptr;
-
-begin
- if @parser.m_commentHandler = NIL then
- begin
- if @parser.m_defaultHandler <> NIL then
- reportDefault(parser ,enc ,start ,end_ );
-
- result:=1;
-
- exit;
-
- end;
-
- data:=
- poolStoreString(
- @parser.m_tempPool ,enc ,
- char_ptr(ptrcomp(start ) + enc.minBytesPerChar * 4 ) ,
- char_ptr(ptrcomp(end_ ) - enc.minBytesPerChar * 3 ) );
-
- if data = NIL then
- begin
- result:=0;
-
- exit;
-
- end;
-
- normalizeLines(data );
-
- parser.m_commentHandler(parser.m_handlerArg ,data );
-
- poolClear(@parser.m_tempPool );
-
- result:=1;
-
-end;
-
-{ doProlog }
-function doProlog(
- parser : XML_Parser;
- enc : ENCODING_ptr;
- s ,end_ : char_ptr;
- tok : int;
- next : char_ptr;
- nextPtr : char_ptr_ptr;
- haveMore : XML_Bool ) : XML_Error;
-const
-{$IFDEF XML_DTD }
- externalSubsetName : array[0..1 ] of XML_Char = ('#' ,#0 );
-
-{$ENDIF }
-
- atypeCDATA : array[0..5 ] of XML_Char = ('C' ,'D' ,'A' ,'T' ,'A' ,#0 );
- atypeID : array[0..2 ] of XML_Char = ('I' ,'D' ,#0 );
- atypeIDREF : array[0..5 ] of XML_Char = ('I' ,'D' ,'R' ,'E' ,'F' ,#0 );
- atypeIDREFS : array[0..6 ] of XML_Char = ('I' ,'D' ,'R' ,'E' ,'F' ,'S' ,#0 );
- atypeENTITY : array[0..6 ] of XML_Char = ('E' ,'N' ,'T' ,'I' ,'T' ,'Y' ,#0 );
- atypeENTITIES : array[0..8 ] of XML_Char = ('E' ,'N' ,'T' ,'I' ,'T' ,'I' ,'E' ,'S',#0 );
- atypeNMTOKEN : array[0..7 ] of XML_Char = ('N' ,'M' ,'T' ,'O' ,'K' ,'E' ,'N' ,#0 );
- atypeNMTOKENS : array[0..8 ] of XML_Char = ('N' ,'M' ,'T' ,'O' ,'K' ,'E' ,'N' ,'S',#0 );
- notationPrefix : array[0..8 ] of XML_Char = ('N' ,'O' ,'T' ,'A' ,'T' ,'I' ,'O' ,'N',#0 );
- enumValueSep : array[0..1 ] of XML_Char = ('|' ,#0 );
- enumValueStart : array[0..1 ] of XML_Char = ('(' ,#0 );
-
-var
- dtd : DTD_ptr;
-
- eventPP ,eventEndPP : char_ptr_ptr;
-
- quant : XML_Content_Quant;
-
- role ,myindex ,nameLen : int;
-
- handleDefault ,hadParamEntityRefs ,ok ,betweenDecl : XML_Bool;
-
- result_ : XML_Error;
-
- tem ,prefix ,attVal ,name ,systemId : XML_Char_ptr;
-
- entity : ENTITY_ptr;
-
- ctemp ,nxt : char_ptr;
-
- itemp : int_ptr;
-
- content ,model : XML_Content_ptr;
-
- el : ELEMENT_TYPE_ptr;
-
-label
- _break ,_go0 ,_go1 ,
- alreadyChecked ,checkAttListDeclHandler ,elementContent ,closeGroup ;
-
-begin
-{ save one level of indirection }
- dtd:=parser.m_dtd;
-
- if enc = parser.m_encoding then
- begin
- eventPP :=@parser.m_eventPtr;
- eventEndPP:=@parser.m_eventEndPtr;
-
- end
- else
- begin
- eventPP :=@parser.m_openInternalEntities.internalEventPtr;
- eventEndPP:=@parser.m_openInternalEntities.internalEventEndPtr;
-
- end;
-
- repeat
- handleDefault:=XML_TRUE;
- eventPP^ :=s;
- eventEndPP^ :=next;
-
- if tok <= 0 then
- begin
- if (haveMore <> 0 ) and
- (tok <> XML_TOK_INVALID ) then
- begin
- nextPtr^:=s;
- result :=XML_ERROR_NONE;
-
- exit;
-
- end;
-
- case tok of
- XML_TOK_INVALID :
- begin
- eventPP^:=next;
- result :=XML_ERROR_INVALID_TOKEN;
-
- exit;
-
- end;
-
- XML_TOK_PARTIAL :
- begin
- result:=XML_ERROR_UNCLOSED_TOKEN;
-
- exit;
-
- end;
-
- XML_TOK_PARTIAL_CHAR :
- begin
- result:=XML_ERROR_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- XML_TOK_NONE :
- begin
- {$IFDEF XML_DTD }
- { for internal PE NOT referenced between declarations }
- if (enc <> parser.m_encoding ) and
- (parser.m_openInternalEntities.betweenDecl = 0 ) then
- begin
- nextPtr^:=s;
- result :=XML_ERROR_NONE;
-
- exit;
-
- end;
-
- { WFC: PE Between Declarations - must check that PE contains
- complete markup, not only for external PEs, but also for
- internal PEs if the reference occurs between declarations. }
- if (parser.m_isParamEntity <> 0 ) or
- (enc <> parser.m_encoding ) then
- begin
- if XmlTokenRole(@parser.m_prologState ,XML_TOK_NONE ,pointer(end_ ) ,pointer(end_ ) ,enc ) = XML_ROLE_ERROR then
- begin
- result:=XML_ERROR_INCOMPLETE_PE;
-
- exit;
-
- end;
-
- nextPtr^:=s;
- result :=XML_ERROR_NONE;
-
- exit;
-
- end;
-
- {$ENDIF }
-
- result:=XML_ERROR_NO_ELEMENTS;
-
- exit;
-
- end;
-
- else
- begin
- tok :=-tok;
- next:=end_;
-
- end;
-
- end;
-
- end;
-
- role:=XmlTokenRole(@parser.m_prologState ,tok ,pointer(s ) ,pointer(next ) ,enc );
-
- case role of
- XML_ROLE_XML_DECL :
- begin
- result_:=processXmlDecl(parser ,0 ,s ,next );
-
- if result_ <> XML_ERROR_NONE then
- begin
- result:=result_;
-
- exit;
-
- end;
-
- enc:=parser.m_encoding;
-
- handleDefault:=XML_FALSE;
-
- end;
-
- XML_ROLE_DOCTYPE_NAME :
- begin
- if @parser.m_startDoctypeDeclHandler <> NIL then
- begin
- parser.m_doctypeName:=poolStoreString(@parser.m_tempPool ,enc ,s ,next );
-
- if parser.m_doctypeName = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- poolFinish(@parser.m_tempPool );
-
- parser.m_doctypePubid:=NIL;
- handleDefault :=XML_FALSE;
-
- end;
-
- parser.m_doctypeSysid:=NIL; { always initialize to NULL }
-
- end;
-
- XML_ROLE_DOCTYPE_INTERNAL_SUBSET :
- if @parser.m_startDoctypeDeclHandler <> NIL then
- begin
- parser.m_startDoctypeDeclHandler(
- parser.m_handlerArg ,parser.m_doctypeName ,
- parser.m_doctypeSysid ,parser.m_doctypePubid ,1 );
-
- parser.m_doctypeName:=NIL;
-
- poolClear(@parser.m_tempPool );
-
- handleDefault:=XML_FALSE;
-
- end;
-
- {$IFDEF XML_DTD }
- XML_ROLE_TEXT_DECL :
- begin
- result_:=processXmlDecl(parser ,1 ,s ,next );
-
- if result_ <> XML_ERROR_NONE then
- begin
- result:=result_;
-
- exit;
-
- end;
-
- enc :=parser.m_encoding;
- handleDefault:=XML_FALSE;
-
- end;
-
- {$ENDIF }
-
- XML_ROLE_DOCTYPE_PUBLIC_ID :
- begin
- {$IFDEF XML_DTD }
- parser.m_useForeignDTD:=XML_FALSE;
- parser.m_declEntity :=
- ENTITY_ptr(
- lookup(@dtd.paramEntities ,@externalSubsetName[0 ] ,sizeof(expat.ENTITY ) ) );
-
- if parser.m_declEntity = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- {$ENDIF }
- dtd.hasParamEntityRefs:=XML_TRUE;
-
- if @parser.m_startDoctypeDeclHandler <> NIL then
- begin
- if XmlIsPublicId(enc ,pointer(s ) ,pointer(next ) ,pointer(eventPP ) ) = 0 then
- begin
- result:=XML_ERROR_PUBLICID;
-
- exit;
-
- end;
-
- parser.m_doctypePubid:=
- poolStoreString(
- @parser.m_tempPool ,enc ,
- char_ptr(ptrcomp(s ) + enc.minBytesPerChar ) ,
- char_ptr(ptrcomp(next ) - enc.minBytesPerChar ) );
-
- if parser.m_doctypePubid = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- normalizePublicId(XML_Char_ptr(parser.m_doctypePubid ) );
- poolFinish (@parser.m_tempPool );
-
- handleDefault:=XML_FALSE;
-
- goto alreadyChecked;
-
- end;
-
- { fall through }
- goto _go0;
-
- end;
-
- XML_ROLE_ENTITY_PUBLIC_ID :
- _go0:
- begin
- if XmlIsPublicId(enc ,pointer(s ) ,pointer(next ) ,pointer(eventPP ) ) = 0 then
- begin
- result:=XML_ERROR_PUBLICID;
-
- exit;
-
- end;
-
- alreadyChecked:
- if (dtd.keepProcessing <> 0 ) and
- (parser.m_declEntity <> NIL ) then
- begin
- tem:=
- poolStoreString(
- @dtd.pool ,enc ,
- char_ptr(ptrcomp(s ) + enc.minBytesPerChar ) ,
- char_ptr(ptrcomp(next ) - enc.minBytesPerChar ) );
-
- if tem = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- normalizePublicId(tem );
-
- parser.m_declEntity.publicId:=tem;
-
- poolFinish(@dtd.pool );
-
- if @parser.m_entityDeclHandler <> NIL then
- handleDefault:=XML_FALSE;
-
- end;
-
- end;
-
- XML_ROLE_DOCTYPE_CLOSE :
- begin
- if parser.m_doctypeName <> NIL then
- begin
- parser.m_startDoctypeDeclHandler(
- parser.m_handlerArg ,parser.m_doctypeName ,
- parser.m_doctypeSysid ,parser.m_doctypePubid ,0 );
-
- poolClear(@parser.m_tempPool );
-
- handleDefault:=XML_FALSE;
-
- end;
-
- { doctypeSysid will be non-NULL in the case of a previous
- XML_ROLE_DOCTYPE_SYSTEM_ID, even if startDoctypeDeclHandler
- was not set, indicating an external subset }
- {$IFDEF XML_DTD }
- if (parser.m_doctypeSysid <> NIL ) or
- (parser.m_useForeignDTD <> 0 ) then
- begin
- hadParamEntityRefs :=dtd.hasParamEntityRefs;
- dtd.hasParamEntityRefs:=XML_TRUE;
-
- if (parser.m_paramEntityParsing <> XML_ParamEntityParsing(0 ) ) and
- (@parser.m_externalEntityRefHandler <> NIL ) then
- begin
- entity:=
- ENTITY_ptr(
- lookup(@dtd.paramEntities ,@externalSubsetName[0 ] ,sizeof(expat.ENTITY ) ) );
-
- if entity = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- if parser.m_useForeignDTD <> 0 then
- entity.base:=parser.m_curBase;
-
- dtd.paramEntityRead:=XML_FALSE;
-
- if parser.m_externalEntityRefHandler(
- parser.m_externalEntityRefHandlerArg ,0 ,
- entity.base ,
- entity.systemId ,
- entity.publicId ) = 0 then
- begin
- result:=XML_ERROR_EXTERNAL_ENTITY_HANDLING;
-
- exit;
-
- end;
-
- if dtd.paramEntityRead <> 0 then
- if (dtd.standalone = 0 ) and
- (@parser.m_notStandaloneHandler <> NIL ) and
- (parser.m_notStandaloneHandler(parser.m_handlerArg ) = 0 ) then
- begin
- result:=XML_ERROR_NOT_STANDALONE;
-
- exit;
-
- end
- else
- else
- { if we didn't read the foreign DTD then this means that there
- is no external subset and we must reset dtd.hasParamEntityRefs }
- if parser.m_doctypeSysid = NIL then
- dtd.hasParamEntityRefs:=hadParamEntityRefs;
-
- { end of DTD - no need to update dtd.keepProcessing }
-
- end;
-
- parser.m_useForeignDTD:=XML_FALSE;
-
- end;
-
- {$ENDIF }
- if @parser.m_endDoctypeDeclHandler <> NIL then
- begin
- parser.m_endDoctypeDeclHandler(parser.m_handlerArg );
-
- handleDefault:=XML_FALSE;
-
- end;
-
- end;
-
- XML_ROLE_INSTANCE_START :
- begin
- {$IFDEF XML_DTD }
- { if there is no DOCTYPE declaration then now is the
- last chance to read the foreign DTD }
- if parser.m_useForeignDTD <> 0 then
- begin
- hadParamEntityRefs :=dtd.hasParamEntityRefs;
- dtd.hasParamEntityRefs:=XML_TRUE;
-
- if (parser.m_paramEntityParsing <> XML_ParamEntityParsing(0 ) ) and
- (@parser.m_externalEntityRefHandler <> NIL ) then
- begin
- entity:=
- ENTITY_ptr(
- lookup(@dtd.paramEntities ,@externalSubsetName[0 ] ,sizeof(expat.ENTITY ) ) );
-
- if entity = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- entity.base :=parser.m_curBase;
- dtd.paramEntityRead:=XML_FALSE;
-
- if parser.m_externalEntityRefHandler(
- parser.m_externalEntityRefHandlerArg ,0 ,
- entity.base ,
- entity.systemId ,
- entity.publicId ) = 0 then
- begin
- result:=XML_ERROR_EXTERNAL_ENTITY_HANDLING;
-
- exit;
-
- end;
-
- if dtd.paramEntityRead <> 0 then
- if (dtd.standalone = 0 ) and
- (@parser.m_notStandaloneHandler <> NIL ) and
- (parser.m_notStandaloneHandler(parser.m_handlerArg ) = 0 ) then
- begin
- result:=XML_ERROR_NOT_STANDALONE;
-
- exit;
-
- end
- else
- else
- { if we didn't read the foreign DTD then this means that there
- is no external subset and we must reset dtd.hasParamEntityRefs }
- dtd.hasParamEntityRefs:=hadParamEntityRefs;
-
- { end of DTD - no need to update dtd.keepProcessing }
-
- end;
-
- end;
-
- {$ENDIF }
- parser.m_processor:=@contentProcessor;
-
- result:=contentProcessor(parser ,s ,end_ ,nextPtr );
-
- exit;
-
- end;
-
- XML_ROLE_ATTLIST_ELEMENT_NAME :
- begin
- parser.m_declElementType:=getElementType(parser ,enc ,s ,next );
-
- if parser.m_declElementType = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- goto checkAttListDeclHandler;
-
- end;
-
- XML_ROLE_ATTRIBUTE_NAME :
- begin
- parser.m_declAttributeId:=getAttributeId(parser ,enc ,s ,next );
-
- if parser.m_declAttributeId = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- parser.m_declAttributeIsCdata:=XML_FALSE;
- parser.m_declAttributeType :=NIL;
- parser.m_declAttributeIsId :=XML_FALSE;
-
- goto checkAttListDeclHandler;
-
- end;
-
- XML_ROLE_ATTRIBUTE_TYPE_CDATA :
- begin
- parser.m_declAttributeIsCdata:=XML_TRUE;
- parser.m_declAttributeType :=@atypeCDATA[0 ];
-
- goto checkAttListDeclHandler;
-
- end;
-
- XML_ROLE_ATTRIBUTE_TYPE_ID :
- begin
- parser.m_declAttributeIsId:=XML_TRUE;
- parser.m_declAttributeType:=@atypeID[0 ];
-
- goto checkAttListDeclHandler;
-
- end;
-
- XML_ROLE_ATTRIBUTE_TYPE_IDREF :
- begin
- parser.m_declAttributeType:=@atypeIDREF[0 ];
-
- goto checkAttListDeclHandler;
-
- end;
-
- XML_ROLE_ATTRIBUTE_TYPE_IDREFS :
- begin
- parser.m_declAttributeType:=@atypeIDREFS[0 ];
-
- goto checkAttListDeclHandler;
-
- end;
-
- XML_ROLE_ATTRIBUTE_TYPE_ENTITY :
- begin
- parser.m_declAttributeType:=@atypeENTITY[0 ];
-
- goto checkAttListDeclHandler;
-
- end;
-
- XML_ROLE_ATTRIBUTE_TYPE_ENTITIES :
- begin
- parser.m_declAttributeType:=@atypeENTITIES[0 ];
-
- goto checkAttListDeclHandler;
-
- end;
-
- XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN :
- begin
- parser.m_declAttributeType:=@atypeNMTOKEN[0 ];
-
- goto checkAttListDeclHandler;
-
- end;
-
- XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS :
- begin
- parser.m_declAttributeType:=@atypeNMTOKENS[0 ];
-
- checkAttListDeclHandler:
- if (dtd.keepProcessing <> 0 ) and
- (@parser.m_attlistDeclHandler <> NIL ) then
- handleDefault:=XML_FALSE;
-
- end;
-
- XML_ROLE_ATTRIBUTE_ENUM_VALUE ,XML_ROLE_ATTRIBUTE_NOTATION_VALUE :
- if (dtd.keepProcessing <> 0 ) and
- (@parser.m_attlistDeclHandler <> NIL ) then
- begin
- if parser.m_declAttributeType <> NIL then
- prefix:=@enumValueSep[0 ]
-
- else
- if role = XML_ROLE_ATTRIBUTE_NOTATION_VALUE then
- prefix:=@notationPrefix[0 ]
- else
- prefix:=@enumValueStart[0 ];
-
- if poolAppendString(@parser.m_tempPool ,prefix ) = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- if poolAppend(@parser.m_tempPool ,enc ,s ,next ) = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- parser.m_declAttributeType:=parser.m_tempPool.start;
-
- handleDefault:=XML_FALSE;
-
- end;
-
- XML_ROLE_IMPLIED_ATTRIBUTE_VALUE ,XML_ROLE_REQUIRED_ATTRIBUTE_VALUE :
- if dtd.keepProcessing <> 0 then
- begin
- if defineAttribute(
- parser.m_declElementType ,parser.m_declAttributeId ,
- parser.m_declAttributeIsCdata ,parser.m_declAttributeIsId ,
- 0 ,parser ) = 0 then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- if (@parser.m_attlistDeclHandler <> NIL ) and
- (parser.m_declAttributeType <> NIL ) then
- begin
- if (parser.m_declAttributeType^ = XML_T('(' ) ) or
- ((parser.m_declAttributeType^ = XML_T('N' ) ) and
- (XML_Char_ptr(ptrcomp(parser.m_declAttributeType ) + 1 )^ = XML_T('O' ) ) ) then
- begin
- { Enumerated or Notation type }
- if (poolAppendChar(@parser.m_tempPool ,XML_T(')' ) ) = 0 ) or
- (poolAppendChar(@parser.m_tempPool ,XML_T(#0 ) ) = 0 ) then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- parser.m_declAttributeType:=parser.m_tempPool.start;
-
- poolFinish(@parser.m_tempPool );
-
- end;
-
- eventEndPP^:=s;
-
- parser.m_attlistDeclHandler(
- parser.m_handlerArg ,parser.m_declElementType.name ,
- parser.m_declAttributeId.name ,parser.m_declAttributeType ,
- 0 ,int(role = XML_ROLE_REQUIRED_ATTRIBUTE_VALUE ) );
-
- poolClear(@parser.m_tempPool );
-
- handleDefault:=XML_FALSE;
-
- end;
-
- end;
-
- XML_ROLE_DEFAULT_ATTRIBUTE_VALUE ,XML_ROLE_FIXED_ATTRIBUTE_VALUE :
- if dtd.keepProcessing <> 0 then
- begin
- result_:=
- storeAttributeValue(
- parser ,enc ,parser.m_declAttributeIsCdata ,
- char_ptr(ptrcomp(s ) + enc.minBytesPerChar ) ,
- char_ptr(ptrcomp(next ) - enc.minBytesPerChar ) ,
- @dtd.pool );
-
- if result_ <> XML_Error(0 ) then
- begin
- result:=result_;
-
- exit;
-
- end;
-
- attVal:=poolStart(@dtd.pool );
-
- poolFinish(@dtd.pool );
-
- { ID attributes aren't allowed to have a default }
- if defineAttribute(
- parser.m_declElementType ,parser.m_declAttributeId ,
- parser.m_declAttributeIsCdata ,XML_FALSE ,attVal ,parser ) = 0 then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- if (@parser.m_attlistDeclHandler <> NIL ) and
- (parser.m_declAttributeType <> NIL ) then
- begin
- if (parser.m_declAttributeType^ = XML_T('(' ) ) or
- ((parser.m_declAttributeType^ = XML_T('N' ) ) and
- (XML_Char_ptr(ptrcomp(parser.m_declAttributeType ) + 1 )^ = XML_T('O' ) ) ) then
- begin
- { Enumerated or Notation type }
- if (poolAppendChar(@parser.m_tempPool ,XML_T(')' ) ) = 0 ) or
- (poolAppendChar(@parser.m_tempPool ,XML_T(#0 ) ) = 0 ) then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- parser.m_declAttributeType:=parser.m_tempPool.start;
-
- poolFinish(@parser.m_tempPool );
-
- end;
-
- eventEndPP^:=s;
-
- parser.m_attlistDeclHandler(
- parser.m_handlerArg ,parser.m_declElementType.name ,
- parser.m_declAttributeId.name ,parser.m_declAttributeType ,
- attVal ,int(role = XML_ROLE_FIXED_ATTRIBUTE_VALUE ) );
-
- poolClear(@parser.m_tempPool );
-
- handleDefault:=XML_FALSE;
-
- end;
-
- end;
-
- XML_ROLE_ENTITY_VALUE :
- if dtd.keepProcessing <> 0 then
- begin
- result_:=
- storeEntityValue(
- parser ,enc ,
- char_ptr(ptrcomp(s ) + enc.minBytesPerChar ) ,
- char_ptr(ptrcomp(next ) - enc.minBytesPerChar ) );
-
- if parser.m_declEntity <> NIL then
- begin
- parser.m_declEntity.textPtr:=poolStart(@dtd.entityValuePool );
- parser.m_declEntity.textLen:=poolLength(@dtd.entityValuePool );
-
- poolFinish(@dtd.entityValuePool );
-
- if @parser.m_entityDeclHandler <> NIL then
- begin
- eventEndPP^:=s;
-
- parser.m_entityDeclHandler(
- parser.m_handlerArg ,
- parser.m_declEntity.name,
- parser.m_declEntity.is_param,
- parser.m_declEntity.textPtr,
- parser.m_declEntity.textLen,
- parser.m_curBase ,0 ,0 ,0 );
-
- handleDefault:=XML_FALSE;
-
- end;
-
- end
- else
- poolDiscard(@dtd.entityValuePool );
-
- if result_ <> XML_ERROR_NONE then
- begin
- result:=result_;
-
- exit;
-
- end;
-
- end;
-
- XML_ROLE_DOCTYPE_SYSTEM_ID :
- begin
- {$IFDEF XML_DTD }
- parser.m_useForeignDTD:=XML_FALSE;
-
- {$ENDIF }
-
- dtd.hasParamEntityRefs:=XML_TRUE;
-
- if @parser.m_startDoctypeDeclHandler <> NIL then
- begin
- parser.m_doctypeSysid:=
- poolStoreString(
- @parser.m_tempPool ,enc ,
- char_ptr(ptrcomp(s ) + enc.minBytesPerChar ) ,
- char_ptr(ptrcomp(next ) - enc.minBytesPerChar ) );
-
- if parser.m_doctypeSysid = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- poolFinish(@parser.m_tempPool );
-
- handleDefault:=XML_FALSE;
-
- end
- {$IFDEF XML_DTD }
- else
- { use externalSubsetName to make doctypeSysid non-NULL
- for the case where no startDoctypeDeclHandler is set }
- parser.m_doctypeSysid:=@externalSubsetName[0 ];
-
- {$ELSE }; {$ENDIF }
-
- if (dtd.standalone = 0 ) and
- {$IFDEF XML_DTD }
- (parser.m_paramEntityParsing = XML_ParamEntityParsing(0 ) ) and
- {$ENDIF }
- (@parser.m_notStandaloneHandler <> NIL ) and
- (parser.m_notStandaloneHandler(parser.m_handlerArg ) = 0 ) then
- begin
- result:=XML_ERROR_NOT_STANDALONE;
-
- exit;
-
- end;
-
- {$IFNDEF XML_DTD }
- {$ELSE }
- if parser.m_declEntity = NIL then
- begin
- parser.m_declEntity:=
- ENTITY_ptr(
- lookup(
- @dtd.paramEntities ,@externalSubsetName[0 ] ,sizeof(expat.ENTITY ) ) );
-
- if parser.m_declEntity = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- parser.m_declEntity.publicId:=NIL;
-
- end;
-
- {$ENDIF }
- { fall through }
- goto _go1;
-
- end;
-
- XML_ROLE_ENTITY_SYSTEM_ID :
- _go1:
- if (dtd.keepProcessing <> 0 ) and
- (parser.m_declEntity <> NIL ) then
- begin
- parser.m_declEntity.systemId:=
- poolStoreString(
- @dtd.pool ,enc ,
- char_ptr(ptrcomp(s ) + enc.minBytesPerChar ) ,
- char_ptr(ptrcomp(next ) - enc.minBytesPerChar ) );
-
- if parser.m_declEntity.systemId = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- parser.m_declEntity.base:=parser.m_curBase;
-
- poolFinish(@dtd.pool );
-
- if @parser.m_entityDeclHandler <> NIL then
- handleDefault:=XML_FALSE;
-
- end;
-
- XML_ROLE_ENTITY_COMPLETE :
- if (dtd.keepProcessing <> 0 ) and
- (parser.m_declEntity <> NIL ) and
- (@parser.m_entityDeclHandler <> NIL ) then
- begin
- eventEndPP^:=s;
-
- parser.m_entityDeclHandler(
- parser.m_handlerArg ,
- parser.m_declEntity.name ,
- parser.m_declEntity.is_param ,
- 0 ,0 ,
- parser.m_declEntity.base ,
- parser.m_declEntity.systemId ,
- parser.m_declEntity.publicId ,
- 0 );
-
- handleDefault:=XML_FALSE;
-
- end;
-
- XML_ROLE_ENTITY_NOTATION_NAME :
- if (dtd.keepProcessing <> 0 ) and
- (parser.m_declEntity <> NIL ) then
- begin
- parser.m_declEntity.notation:=poolStoreString(@dtd.pool ,enc ,s ,next );
-
- if parser.m_declEntity.notation = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- poolFinish(@dtd.pool );
-
- if @parser.m_unparsedEntityDeclHandler <> NIL then
- begin
- eventEndPP^:=s;
-
- parser.m_unparsedEntityDeclHandler(
- parser.m_handlerArg ,
- parser.m_declEntity.name ,
- parser.m_declEntity.base ,
- parser.m_declEntity.systemId ,
- parser.m_declEntity.publicId ,
- parser.m_declEntity.notation );
-
- handleDefault:=XML_FALSE;
-
- end
- else
- if @parser.m_entityDeclHandler <> NIL then
- begin
- eventEndPP^:=s;
-
- parser.m_entityDeclHandler(
- parser.m_handlerArg ,
- parser.m_declEntity.name ,
- 0 ,0 ,0 ,
- parser.m_declEntity.base,
- parser.m_declEntity.systemId ,
- parser.m_declEntity.publicId ,
- parser.m_declEntity.notation );
-
- handleDefault:=XML_FALSE;
-
- end;
-
- end;
-
- XML_ROLE_GENERAL_ENTITY_NAME :
- begin
- if XmlPredefinedEntityName(enc ,pointer(s ) ,pointer(next ) ) <> 0 then
- begin
- parser.m_declEntity:=NIL;
-
- goto _break;
-
- end;
-
- if dtd.keepProcessing <> 0 then
- begin
- name:=poolStoreString(@dtd.pool ,enc ,s ,next );
-
- if name = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- parser.m_declEntity:=
- ENTITY_ptr(
- lookup(@dtd.generalEntities ,name ,sizeof(expat.ENTITY ) ) );
-
- if parser.m_declEntity = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- if parser.m_declEntity.name <> name then
- begin
- poolDiscard(@dtd.pool );
-
- parser.m_declEntity:=NIL;
-
- end
- else
- begin
- poolFinish(@dtd.pool );
-
- parser.m_declEntity.publicId:=NIL;
- parser.m_declEntity.is_param:=XML_FALSE;
-
- { if we have a parent parser or are reading an internal parameter
- entity, then the entity declaration is not considered "internal" }
- parser.m_declEntity.is_internal:=
- XML_Bool(
- not ((parser.m_parentParser <> NIL ) or
- (parser.m_openInternalEntities <> NIL ) ) );
-
- if @parser.m_entityDeclHandler <> NIL then
- handleDefault:=XML_FALSE;
-
- end;
-
- end
- else
- begin
- poolDiscard(@dtd.pool );
-
- parser.m_declEntity:=NIL;
-
- end;
-
- end;
-
- XML_ROLE_PARAM_ENTITY_NAME :
- {$IFDEF XML_DTD }
- if dtd.keepProcessing <> 0 then
- begin
- name:=poolStoreString(@dtd.pool ,enc ,s ,next );
-
- if name <> NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- parser.m_declEntity:=
- ENTITY_ptr(
- lookup(@dtd.paramEntities ,name ,sizeof(expat.ENTITY ) ) );
-
- if parser.m_declEntity = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- if parser.m_declEntity.name <> name then
- begin
- poolDiscard(@dtd.pool );
-
- parser.m_declEntity:=NIL;
-
- end
- else
- begin
- poolFinish(@dtd.pool );
-
- parser.m_declEntity.publicId:=NIL;
- parser.m_declEntity.is_param:=XML_TRUE;
-
- { if we have a parent parser or are reading an internal parameter
- entity, then the entity declaration is not considered "internal" }
- parser.m_declEntity.is_internal:=
- XML_Bool(
- not((parser.m_parentParser <> NIL ) or
- (parser.m_openInternalEntities <> NIL ) ) );
-
- if @parser.m_entityDeclHandler <> NIL then
- handleDefault:=XML_FALSE;
-
- end;
-
- end
- else
- begin
- poolDiscard(@dtd.pool );
-
- parser.m_declEntity:=NIL;
-
- end;
-
- {$ELSE }
- parser.m_declEntity:=NIL;
-
- {$ENDIF }
-
- XML_ROLE_NOTATION_NAME :
- begin
- parser.m_declNotationPublicId:=NIL;
- parser.m_declNotationName :=NIL;
-
- if @parser.m_notationDeclHandler <> NIL then
- begin
- parser.m_declNotationName:=poolStoreString(@parser.m_tempPool ,enc ,s ,next );
-
- if parser.m_declNotationName = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- poolFinish(@parser.m_tempPool );
-
- handleDefault:=XML_FALSE;
-
- end;
-
- end;
-
- XML_ROLE_NOTATION_PUBLIC_ID :
- begin
- if XmlIsPublicId(enc ,pointer(s ) ,pointer(next ) ,pointer(eventPP ) ) = 0 then
- begin
- result:=XML_ERROR_PUBLICID;
-
- exit;
-
- end;
-
- if parser.m_declNotationName <> NIL then { means notationDeclHandler <> NIL }
- begin
- tem:=
- poolStoreString(
- @parser.m_tempPool ,
- enc ,
- char_ptr(ptrcomp(s ) + enc.minBytesPerChar ) ,
- char_ptr(ptrcomp(next ) - enc.minBytesPerChar ) );
-
- if tem = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- normalizePublicId(tem );
-
- parser.m_declNotationPublicId:=tem;
-
- poolFinish(@parser.m_tempPool );
-
- handleDefault:=XML_FALSE;
-
- end;
-
- end;
-
- XML_ROLE_NOTATION_SYSTEM_ID :
- begin
- if (parser.m_declNotationName <> NIL ) and
- (@parser.m_notationDeclHandler <> NIL ) then
- begin
- systemId:=
- poolStoreString(
- @parser.m_tempPool ,enc ,
- char_ptr(ptrcomp(s ) + enc.minBytesPerChar ) ,
- char_ptr(ptrcomp(next ) - enc.minBytesPerChar ) );
-
- if systemId = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- eventEndPP^:=s;
-
- parser.m_notationDeclHandler(
- parser.m_handlerArg ,
- parser.m_declNotationName ,
- parser.m_curBase ,
- systemId ,
- parser.m_declNotationPublicId );
-
- handleDefault:=XML_FALSE;
-
- end;
-
- poolClear(@parser.m_tempPool );
-
- end;
-
- XML_ROLE_NOTATION_NO_SYSTEM_ID :
- begin
- if (parser.m_declNotationPublicId <> NIL ) and
- (@parser.m_notationDeclHandler <> NIL ) then
- begin
- eventEndPP^:=s;
-
- parser.m_notationDeclHandler(
- parser.m_handlerArg ,
- parser.m_declNotationName ,
- parser.m_curBase ,
- 0 ,
- parser.m_declNotationPublicId );
-
- handleDefault:=XML_FALSE;
-
- end;
-
- poolClear(@parser.m_tempPool );
-
- end;
-
- XML_ROLE_ERROR :
- case tok of
- XML_TOK_PARAM_ENTITY_REF :
- { PE references in internal subset are
- not allowed within declarations. }
- begin
- result:=XML_ERROR_PARAM_ENTITY_REF;
-
- exit;
-
- end;
-
- XML_TOK_XML_DECL :
- begin
- result:=XML_ERROR_MISPLACED_XML_PI;
-
- exit;
-
- end;
-
- else
- begin
- result:=XML_ERROR_SYNTAX;
-
- exit;
-
- end;
-
- end;
-
- {$IFDEF XML_DTD }
- XML_ROLE_IGNORE_SECT :
- begin
- if @parser.m_defaultHandler <> NIL then
- reportDefault(parser ,enc ,s ,next );
-
- handleDefault:=XML_FALSE;
-
- result_:=doIgnoreSection(parser ,enc ,@next ,end_ ,nextPtr ,haveMore );
-
- if result_ <> XML_ERROR_NONE then
- begin
- result:=result_;
-
- exit;
-
- end
- else
- if next = NIL then
- begin
- parser.m_processor:=@ignoreSectionProcessor;
-
- result:=result_;
-
- exit;
-
- end;
-
- end;
-
- {$ENDIF }
-
- XML_ROLE_GROUP_OPEN :
- begin
- if parser.m_prologState.level >= parser.m_groupSize then
- if parser.m_groupSize <> 0 then
- begin
- parser.m_groupSize:=parser.m_groupSize * 2;
-
- if parser.m_mem.realloc_fcn(
- pointer(parser.m_groupConnector ) ,
- parser.m_groupAlloc ,
- parser.m_groupSize ) then
- parser.m_groupAlloc:=parser.m_groupSize
-
- else
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- if dtd.scaffIndex <> NIL then
- if parser.m_mem.realloc_fcn(
- pointer(dtd.scaffIndex ) ,
- dtd.scaffAlloc ,
- parser.m_groupSize * sizeof(int ) ) then
- dtd.scaffAlloc:=parser.m_groupSize * sizeof(int )
-
- else
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- end
- else
- begin
- parser.m_groupSize:=32;
-
- if parser.m_mem.malloc_fcn(
- pointer(parser.m_groupConnector ) ,
- parser.m_groupSize ) then
- parser.m_groupAlloc:=parser.m_groupSize
-
- else
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- end;
-
- char_ptr(ptrcomp(parser.m_groupConnector ) + parser.m_prologState.level )^:=#0;
-
- if dtd.in_eldecl <> 0 then
- begin
- myindex:=nextScaffoldPart(parser );
-
- if myindex < 0 then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- int_ptr(ptrcomp(dtd.scaffIndex ) + dtd.scaffLevel * sizeof(int ) )^:=myindex;
-
- inc(dtd.scaffLevel );
-
- CONTENT_SCAFFOLD_ptr(ptrcomp(dtd.scaffold ) + myindex * sizeof(CONTENT_SCAFFOLD ) )^.type_:=XML_CTYPE_SEQ;
-
- if @parser.m_elementDeclHandler <> NIL then
- handleDefault:=XML_FALSE;
-
- end;
-
- end;
-
- XML_ROLE_GROUP_SEQUENCE :
- begin
- if char_ptr(ptrcomp(parser.m_groupConnector ) + parser.m_prologState.level )^ = '|' then
- begin
- result:=XML_ERROR_SYNTAX;
-
- exit;
-
- end;
-
- char_ptr(ptrcomp(parser.m_groupConnector ) + parser.m_prologState.level )^:=',';
-
- if (dtd.in_eldecl <> 0 ) and
- (@parser.m_elementDeclHandler <> NIL ) then
- handleDefault:=XML_FALSE;
-
- end;
-
- XML_ROLE_GROUP_CHOICE :
- begin
- if char_ptr(ptrcomp(parser.m_groupConnector ) + parser.m_prologState.level )^ = ',' then
- begin
- result:=XML_ERROR_SYNTAX;
-
- exit;
-
- end;
-
- if (dtd.in_eldecl <> 0 ) and
- (char_ptr(ptrcomp(parser.m_groupConnector ) + parser.m_prologState.level )^ <> #0 ) and
- (CONTENT_SCAFFOLD_ptr(
- ptrcomp(dtd.scaffold ) +
- int_ptr(ptrcomp(dtd.scaffIndex ) + (dtd.scaffLevel - 1 ) * sizeof(int ) )^ *
- sizeof(CONTENT_SCAFFOLD ) )^.type_ <> XML_CTYPE_MIXED ) then
- begin
- CONTENT_SCAFFOLD_ptr(
- ptrcomp(dtd.scaffold ) +
- int_ptr(ptrcomp(dtd.scaffIndex ) + (dtd.scaffLevel - 1 ) * sizeof(int ) )^ *
- sizeof(CONTENT_SCAFFOLD ) )^.type_:=XML_CTYPE_CHOICE;
-
- if @parser.m_elementDeclHandler <> NIL then
- handleDefault:=XML_FALSE;
-
- end;
-
- char_ptr(ptrcomp(parser.m_groupConnector ) + parser.m_prologState.level )^:='|';
-
- end;
-
- XML_ROLE_PARAM_ENTITY_REF {$IFDEF XML_DTD } ,XML_ROLE_INNER_PARAM_ENTITY_REF : {$ELSE }: {$ENDIF }
- begin
- {$IFDEF XML_DTD }
- dtd.hasParamEntityRefs:=XML_TRUE;
-
- if parser.m_paramEntityParsing = XML_ParamEntityParsing(0 ) then
- dtd.keepProcessing:=dtd.standalone
-
- else
- begin
- name:=
- poolStoreString(
- @dtd.pool ,enc ,
- char_ptr(ptrcomp(s ) + enc.minBytesPerChar ) ,
- char_ptr(ptrcomp(next ) - enc.minBytesPerChar ) );
-
- if name = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- entity:=ENTITY_ptr(lookup(@dtd.paramEntities ,name ,0 ) );
-
- poolDiscard(@dtd.pool );
-
- { first, determine if a check for an existing declaration is needed;
- if yes, check that the entity exists, and that it is internal,
- otherwise call the skipped entity handler }
- if dtd.standalone <> 0 then
- ok:=XML_Bool(parser.m_openInternalEntities = NIL )
- else
- ok:=XML_Bool(dtd.hasParamEntityRefs = 0 );
-
- if (parser.m_prologState.documentEntity <> 0 ) and
- (ok <> 0 ) then
- if entity = NIL then
- begin
- result:=XML_ERROR_UNDEFINED_ENTITY;
-
- exit;
-
- end
- else
- if entity.is_internal = 0 then
- begin
- result:=XML_ERROR_ENTITY_DECLARED_IN_PE;
-
- exit;
-
- end
- else
- else
- if entity = NIL then
- begin
- dtd.keepProcessing:=dtd.standalone;
-
- { cannot report skipped entities in declarations }
- if (role = XML_ROLE_PARAM_ENTITY_REF ) and
- (@parser.m_skippedEntityHandler <> NIL ) then
- begin
- parser.m_skippedEntityHandler(parser.m_handlerArg ,name ,1 );
-
- handleDefault:=XML_FALSE;
-
- end;
-
- goto _break;
-
- end;
-
- if entity.open <> 0 then
- begin
- result:=XML_ERROR_RECURSIVE_ENTITY_REF;
-
- exit;
-
- end;
-
- if entity.textPtr <> NIL then
- begin
- if role = XML_ROLE_PARAM_ENTITY_REF then
- betweenDecl:=XML_TRUE
- else
- betweenDecl:=XML_FALSE;
-
- result_:=processInternalEntity(parser ,entity ,betweenDecl );
-
- if result_ <> XML_ERROR_NONE then
- begin
- result:=result_;
-
- exit;
-
- end;
-
- handleDefault:=XML_FALSE;
-
- goto _break;
-
- end;
-
- if @parser.m_externalEntityRefHandler <> NIL then
- begin
- dtd.paramEntityRead:=XML_FALSE;
- entity.open :=XML_TRUE;
-
- if parser.m_externalEntityRefHandler(
- parser.m_externalEntityRefHandlerArg ,
- 0 ,
- entity.base ,
- entity.systemId ,
- entity.publicId ) = 0 then
- begin
- entity.open:=XML_FALSE;
-
- result:=XML_ERROR_EXTERNAL_ENTITY_HANDLING;
-
- exit;
-
- end;
-
- entity.open :=XML_FALSE;
- handleDefault:=XML_FALSE;
-
- if dtd.paramEntityRead = 0 then
- begin
- dtd.keepProcessing:=dtd.standalone;
-
- goto _break;
-
- end;
-
- end
- else
- begin
- dtd.keepProcessing:=dtd.standalone;
-
- goto _break;
-
- end;
-
- end;
-
- {$ENDIF }
-
- if (dtd.standalone = 0 ) and
- (@parser.m_notStandaloneHandler <> NIL ) and
- (parser.m_notStandaloneHandler(parser.m_handlerArg ) = 0 ) then
- begin
- result:=XML_ERROR_NOT_STANDALONE;
-
- exit;
-
- end;
-
- end;
-
- { Element declaration stuff }
- XML_ROLE_ELEMENT_NAME :
- if @parser.m_elementDeclHandler <> NIL then
- begin
- parser.m_declElementType:=getElementType(parser ,enc ,s ,next );
-
- if parser.m_declElementType = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- dtd.scaffLevel:=0;
- dtd.scaffCount:=0;
- dtd.in_eldecl :=XML_TRUE;
- handleDefault :=XML_FALSE;
-
- end;
-
- XML_ROLE_CONTENT_ANY ,XML_ROLE_CONTENT_EMPTY :
- if dtd.in_eldecl <> 0 then
- begin
- if @parser.m_elementDeclHandler <> NIL then
- begin
- parser.m_mem.malloc_fcn(pointer(content ) ,sizeof(XML_Content ) );
-
- if content = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- content.quant :=XML_CQUANT_NONE;
- content.name :=NIL;
- content.numchildren:=0;
- content.children :=NIL;
-
- if role = XML_ROLE_CONTENT_ANY then
- content.type_:=XML_CTYPE_ANY
- else
- content.type_:=XML_CTYPE_EMPTY;
-
- eventEndPP^:=s;
-
- parser.m_elementDeclHandler(
- parser.m_handlerArg ,parser.m_declElementType.name ,content );
-
- handleDefault:=XML_FALSE;
-
- end;
-
- dtd.in_eldecl:=XML_FALSE;
-
- end;
-
- XML_ROLE_CONTENT_PCDATA :
- if dtd.in_eldecl <> 0 then
- begin
- CONTENT_SCAFFOLD_ptr(
- ptrcomp(dtd.scaffold ) +
- int_ptr(ptrcomp(dtd.scaffIndex ) + (dtd.scaffLevel - 1 ) * sizeof(int ) )^ *
- sizeof(CONTENT_SCAFFOLD ) )^.type_:=XML_CTYPE_MIXED;
-
- if @parser.m_elementDeclHandler <> NIL then
- handleDefault:=XML_FALSE;
-
- end;
-
- XML_ROLE_CONTENT_ELEMENT :
- begin
- quant:=XML_CQUANT_NONE;
-
- goto elementContent;
-
- end;
-
- XML_ROLE_CONTENT_ELEMENT_OPT :
- begin
- quant:=XML_CQUANT_OPT;
-
- goto elementContent;
-
- end;
-
- XML_ROLE_CONTENT_ELEMENT_REP :
- begin
- quant:=XML_CQUANT_REP;
-
- goto elementContent;
-
- end;
-
- XML_ROLE_CONTENT_ELEMENT_PLUS :
- begin
- quant:=XML_CQUANT_PLUS;
-
- elementContent:
- if dtd.in_eldecl <> 0 then
- begin
- if quant = XML_CQUANT_NONE then
- nxt:=next
- else
- nxt:=char_ptr(ptrcomp(next ) - enc.minBytesPerChar );
-
- myindex:=nextScaffoldPart(parser );
-
- if myindex < 0 then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- CONTENT_SCAFFOLD_ptr(
- ptrcomp(dtd.scaffold ) +
- myindex * sizeof(CONTENT_SCAFFOLD ) )^.type_:=XML_CTYPE_NAME;
-
- CONTENT_SCAFFOLD_ptr(
- ptrcomp(dtd.scaffold ) +
- myindex * sizeof(CONTENT_SCAFFOLD ) )^.quant:=quant;
-
- el:=getElementType(parser ,enc ,s ,nxt );
-
- if el = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- name:=el.name;
-
- CONTENT_SCAFFOLD_ptr(
- ptrcomp(dtd.scaffold ) +
- myindex * sizeof(CONTENT_SCAFFOLD ) )^.name:=name;
-
- nameLen:=0;
-
- while XML_Char_ptr(ptrcomp(name ) + nameLen )^ <> XML_Char(0 ) do
- inc(nameLen );
-
- inc(dtd.contentStringLen ,nameLen );
-
- if @parser.m_elementDeclHandler <> NIL then
- handleDefault:=XML_FALSE;
-
- end;
-
- end;
-
- XML_ROLE_GROUP_CLOSE :
- begin
- quant:=XML_CQUANT_NONE;
-
- goto closeGroup;
-
- end;
-
- XML_ROLE_GROUP_CLOSE_OPT :
- begin
- quant:=XML_CQUANT_OPT;
-
- goto closeGroup;
-
- end;
-
- XML_ROLE_GROUP_CLOSE_REP :
- begin
- quant:=XML_CQUANT_REP;
-
- goto closeGroup;
-
- end;
-
- XML_ROLE_GROUP_CLOSE_PLUS :
- begin
- quant:=XML_CQUANT_PLUS;
-
- closeGroup:
- if dtd.in_eldecl <> 0 then
- begin
- if @parser.m_elementDeclHandler <> NIL then
- handleDefault:=XML_FALSE;
-
- dec(dtd.scaffLevel );
-
- CONTENT_SCAFFOLD_ptr(
- ptrcomp(dtd.scaffold ) +
- int_ptr(ptrcomp(dtd.scaffIndex ) + dtd.scaffLevel * sizeof(int ) )^ *
- sizeof(CONTENT_SCAFFOLD) )^.quant:=quant;
-
- if dtd.scaffLevel = 0 then
- begin
- if handleDefault = 0 then
- begin
- model:=build_model(parser );
-
- if model = NIL then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- eventEndPP^:=s;
-
- parser.m_elementDeclHandler(
- parser.m_handlerArg ,
- parser.m_declElementType.name ,model );
-
- end;
-
- dtd.in_eldecl :=XML_FALSE;
- dtd.contentStringLen:=0;
-
- end;
-
- end;
-
- end; { End element declaration stuff }
-
- XML_ROLE_PI :
- begin
- if reportProcessingInstruction(parser ,enc ,s ,next ) = 0 then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- handleDefault:=XML_FALSE;
-
- end;
-
- XML_ROLE_COMMENT :
- begin
- if reportComment(parser ,enc ,s ,next ) = 0 then
- begin
- result:=XML_ERROR_NO_MEMORY;
-
- exit;
-
- end;
-
- handleDefault:=XML_FALSE;
-
- end;
-
- XML_ROLE_NONE :
- case tok of
- XML_TOK_BOM :
- handleDefault:=XML_FALSE;
-
- end;
-
- XML_ROLE_DOCTYPE_NONE :
- if @parser.m_startDoctypeDeclHandler <> NIL then
- handleDefault:=XML_FALSE;
-
- XML_ROLE_ENTITY_NONE :
- if (dtd.keepProcessing <> 0 ) and
- (@parser.m_entityDeclHandler <> NIL ) then
- handleDefault:=XML_FALSE;
-
- XML_ROLE_NOTATION_NONE :
- if @parser.m_notationDeclHandler <> NIL then
- handleDefault:=XML_FALSE;
-
- XML_ROLE_ATTLIST_NONE :
- if (dtd.keepProcessing <> 0 ) and
- (@parser.m_attlistDeclHandler <> NIL ) then
- handleDefault:=XML_FALSE;
-
- XML_ROLE_ELEMENT_NONE :
- if @parser.m_elementDeclHandler <> NIL then
- handleDefault:=XML_FALSE;
-
- end; { end of big case }
-
- _break:
- if (handleDefault = XML_TRUE ) and
- (@parser.m_defaultHandler <> NIL ) then
- reportDefault(parser ,enc ,s ,next );
-
- case parser.m_parsingStatus.parsing of
- XML_SUSPENDED :
- begin
- nextPtr^:=next;
- result :=XML_ERROR_NONE;
-
- exit;
-
- end;
-
- XML_FINISHED :
- begin
- result:=XML_ERROR_ABORTED;
-
- exit;
-
- end;
-
- else
- begin
- s :=next;
- tok:=XmlPrologTok(enc ,pointer(s ) ,pointer(end_ ) ,@next );
-
- end;
-
- end;
-
- until false;
-
-{ not reached }
-
-end;
-
-{ prologProcessor }
-function prologProcessor(parser : XML_Parser; s ,end_ : char_ptr; nextPtr : char_ptr_ptr ) : XML_Error;
-var
- next : char_ptr;
- tok : int;
-
-begin
- next:=s;
- tok :=XmlPrologTok(parser.m_encoding ,pointer(s ) ,pointer(end_ ) ,@next );
-
- result:=
- doProlog(
- parser ,parser.m_encoding ,s ,end_ ,tok ,next ,
- nextPtr ,XML_Bool(not parser.m_parsingStatus.finalBuffer ) );
-
-end;
-
-{ prologInitProcessor }
-function prologInitProcessor(parser : XML_Parser; s ,end_ : char_ptr; nextPtr : char_ptr_ptr ) : XML_Error;
-var
- result_ : XML_Error;
-
-begin
- result_:=initializeEncoding(parser );
-
- if result_ <> XML_ERROR_NONE then
- begin
- result:=result_;
-
- exit;
-
- end;
-
- parser.m_processor:=@prologProcessor;
-
- result:=prologProcessor(parser ,s ,end_ ,nextPtr );
-
-end;
-
-{ parserInit }
-procedure parserInit(parser : XML_Parser; encodingName : XML_Char_ptr );
-begin
- parser.m_processor:=@prologInitProcessor;
-
- XmlPrologStateInit(@parser.m_prologState );
-
- if encodingName <> NIL then
- parser.m_protocolEncodingName:=poolCopyString(@parser.m_tempPool ,encodingName )
- else
- parser.m_protocolEncodingName:=NIL;
-
- parser.m_curBase:=NIL;
-
- XmlInitEncoding(@parser.m_initEncoding ,@parser.m_encoding ,0 );
-
- parser.m_userData :=NIL;
- parser.m_handlerArg:=NIL;
-
- parser.m_startElementHandler :=NIL;
- parser.m_endElementHandler :=NIL;
- parser.m_characterDataHandler :=NIL;
- parser.m_processingInstructionHandler:=NIL;
- parser.m_commentHandler :=NIL;
- parser.m_startCdataSectionHandler :=NIL;
- parser.m_endCdataSectionHandler :=NIL;
- parser.m_defaultHandler :=NIL;
- parser.m_startDoctypeDeclHandler :=NIL;
- parser.m_endDoctypeDeclHandler :=NIL;
- parser.m_unparsedEntityDeclHandler :=NIL;
- parser.m_notationDeclHandler :=NIL;
- parser.m_startNamespaceDeclHandler :=NIL;
- parser.m_endNamespaceDeclHandler :=NIL;
- parser.m_notStandaloneHandler :=NIL;
- parser.m_externalEntityRefHandler :=NIL;
- parser.m_externalEntityRefHandlerArg :=parser;
- parser.m_skippedEntityHandler :=NIL;
- parser.m_elementDeclHandler :=NIL;
- parser.m_attlistDeclHandler :=NIL;
- parser.m_entityDeclHandler :=NIL;
- parser.m_xmlDeclHandler :=NIL;
-
- parser.m_bufferPtr:=parser.m_buffer;
- parser.m_bufferEnd:=parser.m_buffer;
-
- parser.m_parseEndByteIndex:=0;
- parser.m_parseEndPtr :=NIL;
-
- parser.m_declElementType:=NIL;
- parser.m_declAttributeId:=NIL;
- parser.m_declEntity :=NIL;
-
- parser.m_doctypeName :=NIL;
- parser.m_doctypeSysid:=NIL;
- parser.m_doctypePubid:=NIL;
-
- parser.m_declAttributeType :=NIL;
- parser.m_declNotationName :=NIL;
- parser.m_declNotationPublicId:=NIL;
- parser.m_declAttributeIsCdata:=XML_FALSE;
- parser.m_declAttributeIsId :=XML_FALSE;
-
- fillchar(parser.m_position ,sizeof(POSITION ) ,0 );
-
- parser.m_errorCode:=XML_ERROR_NONE;
-
- parser.m_eventPtr :=NIL;
- parser.m_eventEndPtr:=NIL;
- parser.m_positionPtr:=NIL;
-
- parser.m_openInternalEntities :=NIL;
- parser.m_defaultExpandInternalEntities:=XML_TRUE;
-
- parser.m_tagLevel :=0;
- parser.m_tagStack :=NIL;
- parser.m_inheritedBindings:=NIL;
- parser.m_nSpecifiedAtts :=0;
-
- parser.m_unknownEncodingMem :=NIL;
- parser.m_unknownEncodingRelease:=NIL;
- parser.m_unknownEncodingData :=NIL;
- parser.m_unknownEncodingAlloc :=0;
-
- parser.m_parentParser :=NIL;
- parser.m_parsingStatus.parsing:=XML_INITIALIZED;
-
-{$IFDEF XML_DTD }
- parser.m_isParamEntity:=XML_FALSE;
- parser.m_useForeignDTD:=XML_FALSE;
-
- parser.m_paramEntityParsing:=XML_PARAM_ENTITY_PARSING_NEVER;
-
-{$ENDIF }
-
-end;
-
-{ parserCreate }
-function parserCreate(
- encodingName : XML_Char_ptr;
- memsuite : XML_Memory_Handling_Suite_ptr;
- nameSep : XML_Char_ptr;
- dtd : DTD_ptr ) : XML_Parser;
-var
- parser : XML_Parser;
- mtemp : XML_Memory_Handling_Suite_ptr;
-
-begin
- parser:=NIL;
-
- if memsuite <> NIL then
- begin
- memsuite.malloc_fcn(pointer(parser ) ,sizeof(XML_ParserStruct ) );
-
- if parser <> NIL then
- begin
- mtemp:=@parser.m_mem;
-
- mtemp.malloc_fcn :=memsuite.malloc_fcn;
- mtemp.realloc_fcn:=memsuite.realloc_fcn;
- mtemp.free_fcn :=memsuite.free_fcn;
-
- end;
-
- end
- else
- begin
- expat_getmem(pointer(parser ) ,sizeof(XML_ParserStruct ) );
-
- if parser <> NIL then
- begin
- mtemp:=@parser.m_mem;
-
- mtemp.malloc_fcn :=@expat_getmem;
- mtemp.realloc_fcn:=@expat_realloc;
- mtemp.free_fcn :=@expat_freemem;
-
- end;
-
- end;
-
- if parser = NIL then
- begin
- result:=NIL;
-
- exit;
-
- end;
-
- parser.m_buffer :=NIL;
- parser.m_bufferLim:=NIL;
- parser.m_attsSize :=INIT_ATTS_SIZE;
-
- parser.m_attsAlloc :=0;
- parser.m_nsAttsAlloc:=0;
-
- parser.m_mem.malloc_fcn(pointer(parser.m_atts ) ,parser.m_attsSize * sizeof(ATTRIBUTE ) );
-
- if parser.m_atts = NIL then
- begin
- parser.m_mem.free_fcn(pointer(parser ) ,sizeof(XML_ParserStruct ) );
-
- result:=NIL;
-
- exit;
-
- end
- else
- parser.m_attsAlloc:=parser.m_attsSize * sizeof(ATTRIBUTE );
-
- parser.m_mem.malloc_fcn(pointer(parser.m_dataBuf ) ,INIT_DATA_BUF_SIZE * sizeof(XML_Char ) );
-
- if parser.m_dataBuf = NIL then
- begin
- parser.m_mem.free_fcn(pointer(parser.m_atts ) ,parser.m_attsAlloc );
- parser.m_mem.free_fcn(pointer(parser ) ,sizeof(XML_ParserStruct ) );
-
- result:=NIL;
-
- exit;
-
- end;
-
- parser.m_dataBufEnd:=XML_Char_ptr(ptrcomp(parser.m_dataBuf ) + INIT_DATA_BUF_SIZE );
-
- if dtd <> NIL then
- parser.m_dtd:=dtd
- else
- begin
- parser.m_dtd:=dtdCreate(@parser.m_mem );
-
- if parser.m_dtd = NIL then
- begin
- parser.m_mem.free_fcn(pointer(parser.m_dataBuf ) ,INIT_DATA_BUF_SIZE * sizeof(XML_Char ) );
- parser.m_mem.free_fcn(pointer(parser.m_atts ) ,parser.m_attsAlloc );
- parser.m_mem.free_fcn(pointer(parser ) ,sizeof(XML_ParserStruct ) );
-
- result:=NIL;
-
- exit;
-
- end;
-
- end;
-
- parser.m_freeBindingList :=NIL;
- parser.m_freeTagList :=NIL;
- parser.m_freeInternalEntities:=NIL;
-
- parser.m_groupSize :=0;
- parser.m_groupAlloc :=0;
- parser.m_groupConnector:=NIL;
-
- parser.m_unknownEncodingHandler :=NIL;
- parser.m_unknownEncodingHandlerData:=NIL;
-
- parser.m_namespaceSeparator:='!';
-
- parser.m_ns :=XML_FALSE;
- parser.m_ns_triplets:=XML_FALSE;
-
- parser.m_nsAtts :=NIL;
- parser.m_nsAttsVersion:=0;
- parser.m_nsAttsPower :=0;
-
- poolInit (@parser.m_tempPool ,@parser.m_mem );
- poolInit (@parser.m_temp2Pool ,@parser.m_mem );
- parserInit(parser ,encodingName );
-
- if (encodingName <> NIL ) and
- (parser.m_protocolEncodingName = NIL ) then
- begin
- XML_ParserFree(parser );
-
- result:=NIL;
-
- exit;
-
- end;
-
- if nameSep <> NIL then
- begin
- parser.m_ns:=XML_TRUE;
-
- parser.m_internalEncoding :=XmlGetInternalEncodingNS;
- parser.m_namespaceSeparator:=nameSep^;
-
- end
- else
- parser.m_internalEncoding:=XmlGetInternalEncoding;
-
- result:=parser;
-
-end;
-
-{ setContext {..}
-function setContext(parser : XML_Parser; context : XML_Char_ptr ) : XML_Bool;
-begin
-end;
-
-{ XML_PARSERCREATE }
-function XML_ParserCreate;
-begin
- result:=XML_ParserCreate_MM(encoding ,NIL ,NIL );
-
-end;
-
-{ XML_PARSER_CREATE_MM }
-function XML_ParserCreate_MM;
-var
- parser : XML_Parser;
-
-begin
- parser:=parserCreate(encoding ,memsuite ,namespaceSeparator ,NIL );
-
- if (parser <> NIL ) and
- (parser.m_ns <> 0 ) then
- { implicit context only set for root parser, since child
- parsers (i.e. external entity parsers) will inherit it }
- if not setContext(parser ,@implicitContext[0 ] ) <> 0 then
- begin
- XML_ParserFree(parser );
-
- result:=NIL;
-
- exit;
-
- end;
-
- result:=parser;
-
-end;
-
-{ XML_SETUSERDATA }
-procedure XML_SetUserData;
-begin
- if parser.m_handlerArg = parser.m_userData then
- begin
- parser.m_handlerArg:=userData;
- parser.m_userData :=userData;
-
- end
- else
- parser.m_userData:=userData;
-
-end;
-
-{ XML_SETELEMENTHANDLER }
-procedure XML_SetElementHandler;
-begin
- parser.m_startElementHandler:=start;
- parser.m_endElementHandler :=end_;
-
-end;
-
-{ XML_SETCHARACTERDATAHANDLER }
-procedure XML_SetCharacterDataHandler;
-begin
- parser.m_characterDataHandler:=handler;
-
-end;
-
-{ XML_GetBuffer }
-function XML_GetBuffer(parser : XML_Parser; len : int ) : pointer;
-var
- neededSize ,keep ,offset ,bufferSize : int;
-
- newBuf : char_ptr;
-
-begin
- case parser.m_parsingStatus.parsing of
- XML_SUSPENDED :
- begin
- parser.m_errorCode:=XML_ERROR_SUSPENDED;
-
- result:=NIL;
-
- exit;
-
- end;
-
- XML_FINISHED :
- begin
- parser.m_errorCode:=XML_ERROR_FINISHED;
-
- result:=NIL;
-
- exit;
-
- end;
-
- end;
-
- if len > ptrcomp(parser.m_bufferLim ) - ptrcomp(parser.m_bufferEnd ) then
- begin
- { FIXME avoid integer overflow }
- neededSize:=len + (ptrcomp(parser.m_bufferEnd ) - ptrcomp(parser.m_bufferPtr ) );
-
- {$IFDEF XML_CONTEXT_BYTES }
- keep:=ptrcomp(parser.m_bufferPtr ) - ptrcomp(parser.m_buffer );
-
- if keep > _XML_CONTEXT_BYTES then
- keep:=_XML_CONTEXT_BYTES;
-
- inc(neededSize ,keep );
-
- {$ENDIF }
-
- if neededSize <= ptrcomp(parser.m_bufferLim ) - ptrcomp(parser.m_buffer ) then
- begin
- {$IFDEF XML_CONTEXT_BYTES }
- if keep < ptrcomp(parser.m_bufferPtr ) - ptrcomp(parser.m_buffer ) then
- begin
- offset:=ptrcomp(parser.m_bufferPtr ) - ptrcomp(parser.m_buffer ) - keep;
-
- move(
- char_ptr(ptrcomp(parser.m_buffer ) + offset )^ ,
- parser.m_buffer^ ,
- ptrcomp(parser.m_bufferEnd ) - ptrcomp(parser.m_bufferPtr ) + keep );
-
- dec(ptrcomp(parser.m_bufferEnd ) ,offset );
- dec(ptrcomp(parser.m_bufferPtr ) ,offset );
-
- end;
-
- {$ELSE }
- move(
- parser.m_bufferPtr^ ,
- parser.m_buffer^ ,
- ptrcomp(parser.m_bufferEnd ) - ptrcomp(parser.m_bufferPtr ) );
-
- parser.m_bufferEnd:=char_ptr(ptrcomp(parser.m_buffer ) + (ptrcomp(parser.m_bufferEnd ) - ptrcomp(parser.m_bufferPtr ) ) );
- parser.m_bufferPtr:=parser.m_buffer;
-
- {$ENDIF }
-
- end
- else
- begin
- bufferSize:=ptrcomp(parser.m_bufferLim ) - ptrcomp(parser.m_bufferPtr );
-
- if bufferSize = 0 then
- bufferSize:=INIT_BUFFER_SIZE;
-
- repeat
- bufferSize:=bufferSize * 2;
-
- until bufferSize >= neededSize;
-
- parser.m_mem.malloc_fcn(pointer(newBuf ) ,bufferSize );
-
- if newBuf = NIL then
- begin
- parser.m_errorCode:=XML_ERROR_NO_MEMORY;
-
- result:=NIL;
-
- exit;
-
- end;
-
- parser.m_bufferLim :=char_ptr(ptrcomp(newBuf ) + bufferSize );
-
- {$IFDEF XML_CONTEXT_BYTES }
- if parser.m_bufferPtr <> NIL then
- begin
- keep:=ptrcomp(parser.m_bufferPtr ) - ptrcomp(parser.m_buffer );
-
- if keep > _XML_CONTEXT_BYTES then
- keep:=_XML_CONTEXT_BYTES;
-
- move(
- char_ptr(ptrcomp(parser.m_bufferPtr ) - keep )^ ,
- newBuf^ ,
- ptrcomp(parser.m_bufferEnd ) - ptrcomp(parser.m_bufferPtr ) + keep );
-
- expat_freemem(pointer(parser.m_buffer ) ,parser.m_bufferAloc );
-
- parser.m_buffer :=newBuf;
- parser.m_bufferAloc:=bufferSize;
-
- parser.m_bufferEnd:=
- char_ptr(
- ptrcomp(parser.m_buffer ) +
- (ptrcomp(parser.m_bufferEnd ) - ptrcomp(parser.m_bufferPtr ) ) +
- keep );
-
- parser.m_bufferPtr:=char_ptr(ptrcomp(parser.m_buffer ) + keep );
-
- end
- else
- begin
- parser.m_bufferEnd :=char_ptr(ptrcomp(newBuf ) + (ptrcomp(parser.m_bufferEnd ) - ptrcomp(parser.m_bufferPtr ) ) );
- parser.m_buffer :=newBuf;
- parser.m_bufferPtr :=newBuf;
- parser.m_bufferAloc:=bufferSize;
-
- end;
-
- {$ELSE }
- if parser.m_bufferPtr <> NIL then
- begin
- move(
- parser.m_bufferPtr^ ,
- newBuf^ ,
- ptrcomp(parser.m_bufferEnd ) - ptrcomp(parser.m_bufferPtr ) );
-
- expat_freemem(pointer(parser.m_buffer ) ,parser.m_bufferAloc );
-
- end;
-
- parser.m_bufferEnd :=char_ptr(ptrcomp(newBuf ) + (ptrcomp(parser.m_bufferEnd ) - ptrcomp(parser.m_bufferPtr ) ) );
- parser.m_buffer :=newBuf;
- parser.m_bufferPtr :=newBuf;
- parser.m_bufferAloc:=bufferSize;
-
- {$ENDIF }
-
- end;
-
- end;
-
- result:=parser.m_bufferEnd;
-
-end;
-
-{ errorProcessor }
-function errorProcessor(parser : XML_Parser; s ,end_ : char_ptr; nextPtr : char_ptr_ptr ) : XML_Error;
-begin
- result:=parser.m_errorCode;
-
-end;
-
-{ XML_ParseBuffer }
-function XML_ParseBuffer(parser : XML_Parser; len ,isFinal : int ) : XML_Status;
-var
- start : char_ptr;
- result_ : XML_Status;
-
-begin
- result_:=XML_STATUS_OK;
-
- case parser.m_parsingStatus.parsing of
- XML_SUSPENDED :
- begin
- parser.m_errorCode:=XML_ERROR_SUSPENDED;
-
- result:=XML_STATUS_ERROR;
-
- exit;
-
- end;
-
- XML_FINISHED :
- begin
- parser.m_errorCode:=XML_ERROR_FINISHED;
-
- result:=XML_STATUS_ERROR;
-
- exit;
-
- end;
-
- else
- parser.m_parsingStatus.parsing:=XML_PARSING_;
-
- end;
-
- start :=parser.m_bufferPtr;
- parser.m_positionPtr:=start;
-
- inc(ptrcomp(parser.m_bufferEnd ) ,len );
-
- parser.m_parseEndPtr:=parser.m_bufferEnd;
-
- inc(ptrcomp(parser.m_parseEndByteIndex ) ,len );
-
- parser.m_parsingStatus.finalBuffer:=XML_Bool(isFinal );
-
- parser.m_errorCode:=parser.m_processor(parser ,start ,parser.m_parseEndPtr ,@parser.m_bufferPtr );
-
- if parser.m_errorCode <> XML_ERROR_NONE then
- begin
- parser.m_eventEndPtr:=parser.m_eventPtr;
- parser.m_processor :=@errorProcessor;
-
- result:=XML_STATUS_ERROR;
-
- exit;
-
- end
- else
- case parser.m_parsingStatus.parsing of
- XML_SUSPENDED :
- result_:=XML_STATUS_SUSPENDED;
-
- XML_INITIALIZED ,XML_PARSING_ :
- if isFinal <> 0 then
- begin
- parser.m_parsingStatus.parsing:=XML_FINISHED;
-
- result:=result_;
-
- exit;
-
- end;
-
- else
- { should not happen }
- NoP;
-
- end;
-
- parser.m_encoding.updatePosition(
- parser.m_encoding ,
- pointer(parser.m_positionPtr ) ,
- pointer(parser.m_bufferPtr ) ,@parser.m_position );
-
- parser.m_positionPtr:=parser.m_bufferPtr;
-
- result:=result_;
-
-end;
-
-{ XML_PARSE {..}
-function XML_Parse;
-var
- buff : pointer;
-
-begin
- case parser.m_parsingStatus.parsing of
- XML_SUSPENDED :
- begin
- parser.m_errorCode:=XML_ERROR_SUSPENDED;
-
- result:=XML_STATUS_ERROR;
-
- exit;
-
- end;
-
- XML_FINISHED :
- begin
- parser.m_errorCode:=XML_ERROR_FINISHED;
-
- result:=XML_STATUS_ERROR;
-
- exit;
-
- end;
-
- else
- parser.m_parsingStatus.parsing:=XML_PARSING_;
-
- end;
-
- if len = 0 then
- begin
- NoP;
-
- end
-{$IFNDEF XML_CONTEXT_BYTES }
- else
- if parser.m_bufferPtr = parser.m_bufferEnd then
- begin
- NoP;
-
- end
-
-{$ENDIF }
- else
- begin
- buff:=XML_GetBuffer(parser ,len );
-
- if buff = NIL then
- result:=XML_STATUS_ERROR
-
- else
- begin
- move(s^ ,buff^ ,len );
-
- result:=XML_ParseBuffer(parser ,len ,isFinal );
-
- end;
-
- end;
-
-end;
-
-{ XML_GETERRORCODE {..}
-function XML_GetErrorCode;
-begin
-end;
-
-{ XML_ERRORSTRING {..}
-function XML_ErrorString;
-begin
-end;
-
-{ XML_GETCURRENTLINENUMBER {..}
-function XML_GetCurrentLineNumber;
-begin
-end;
-
-{ destroyBindings }
-procedure destroyBindings(bindings : BINDING_ptr; parser : XML_Parser );
-var
- b : BINDING_ptr;
-
-begin
- repeat
- b:=bindings;
-
- if b = NIL then
- break;
-
- bindings:=b.nextTagBinding;
-
- parser.m_mem.free_fcn(pointer(b.uri ) ,b.uriAlloc );
- parser.m_mem.free_fcn(pointer(b ) ,sizeof(expat.BINDING ) );
-
- until false;
-
-end;
-
-{ XML_PARSERFREE }
-procedure XML_ParserFree;
-var
- tagList ,p : TAG_ptr;
-
- entityList ,openEntity : OPEN_INTERNAL_ENTITY_ptr;
-
-begin
- if parser = NIL then
- exit;
-
-{ free tagStack and freeTagList }
- tagList:=parser.m_tagStack;
-
- repeat
- if tagList = NIL then
- begin
- if parser.m_freeTagList = NIL then
- break;
-
- tagList:=parser.m_freeTagList;
-
- parser.m_freeTagList:=NIL;
-
- end;
-
- p :=tagList;
- tagList:=tagList.parent;
-
- parser.m_mem.free_fcn(pointer(p.buf ) ,p.alloc );
- destroyBindings (p.bindings ,parser );
- parser.m_mem.free_fcn(pointer(p ) ,sizeof(expat.TAG ) );
-
- until false;
-
-{ free openInternalEntities and freeInternalEntities }
- entityList:=parser.m_openInternalEntities;
-
- repeat
- if entityList = NIL then
- begin
- if parser.m_freeInternalEntities = NIL then
- break;
-
- entityList:=parser.m_freeInternalEntities;
-
- parser.m_freeInternalEntities:=NIL;
-
- end;
-
- openEntity:=entityList;
- entityList:=entityList.next;
-
- parser.m_mem.free_fcn(pointer(openEntity ) ,sizeof(OPEN_INTERNAL_ENTITY ) );
-
- until false;
-
- destroyBindings(parser.m_freeBindingList ,parser );
- destroyBindings(parser.m_inheritedBindings ,parser );
-
- poolDestroy(@parser.m_tempPool );
- poolDestroy(@parser.m_temp2Pool );
-
-{$IFDEF XML_DTD }
-{ external parameter entity parsers share the DTD structure
- parser->m_dtd with the root parser, so we must not destroy it }
- if (parser.m_isParamEntity = 0 ) and
- (parser.m_dtd <> NIL ) then
-{$ELSE }
- if parser.m_dtd <> NIL then{$ENDIF }
- dtdDestroy(parser.m_dtd ,XML_Bool(parser.m_parentParser = NIL ),@parser.m_mem );
-
- parser.m_mem.free_fcn(pointer(parser.m_atts ) ,parser.m_attsAlloc );
- parser.m_mem.free_fcn(pointer(parser.m_groupConnector ) ,parser.m_groupAlloc );
- parser.m_mem.free_fcn(pointer(parser.m_buffer ) ,parser.m_bufferAloc );
- parser.m_mem.free_fcn(pointer(parser.m_dataBuf ) ,INIT_DATA_BUF_SIZE * sizeof(XML_Char ) );
- parser.m_mem.free_fcn(pointer(parser.m_nsAtts ) ,parser.m_nsAttsAlloc );
- parser.m_mem.free_fcn(pointer(parser.m_unknownEncodingMem ) ,parser.m_unknownEncodingAlloc );
-
- if @parser.m_unknownEncodingRelease <> NIL then
- parser.m_unknownEncodingRelease(parser.m_unknownEncodingData );
-
- parser.m_mem.free_fcn(pointer(parser ) ,sizeof(XML_ParserStruct ) );
-
-end;
-
+//----------------------------------------------------------------------------
+// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+// and Clark Cooper
+// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
+//
+// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
+// Pascal Port By: Milan Marusinec alias Milano
+// milan@marusinec.sk
+// http://www.pasports.org/pasexpat
+// Copyright (c) 2006
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// [Pascal Port History] -----------------------------------------------------
+//
+// 03.05.2006-Milano: Unit port establishment
+// 02.06.2006-Milano: porting
+// 06.06.2006-Milano: -"-
+// 07.06.2006-Milano: doProlog
+// 08.06.2006-Milano: doProlog finished, porting
+// 09.06.2006-Milano: porting
+// 12.06.2006-Milano: -"-
+// 14.06.2006-Milano: -"-
+// 15.06.2006-Milano: doContent
+// 16.06.2006-Milano: porting, storeAtts
+// 17.06.2006-Milano: -"-
+// 20.06.2006-Milano: epilogProcessor, porting
+// 22.06.2006-Milano: appendAttributeValue
+//
+{ xmlparse.inc }
+{$Q- }
+{$R- }
+function poolStoreString(pool : STRING_POOL_ptr; enc : ENCODING_ptr; ptr ,end_ : char_ptr ) : XML_Char_ptr; forward;
+procedure poolFinish (pool : STRING_POOL_ptr ); forward;
+procedure poolClear (pool : STRING_POOL_ptr ); forward;
+procedure poolDestroy (pool : STRING_POOL_ptr ); forward;
+function poolAppendChar (pool : STRING_POOL_ptr; c : char ) : int; forward;
+
+function reportProcessingInstruction(parser : XML_Parser; enc : ENCODING_ptr; start ,end_ : char_ptr ) : int; forward;
+function reportComment (parser : XML_Parser; enc : ENCODING_ptr; start ,end_ : char_ptr ) : int; forward;
+
+function getAttributeId(parser : XML_Parser; enc : ENCODING_ptr; start ,end_ : char_ptr ) : ATTRIBUTE_ID_ptr; forward;
+
+function storeAttributeValue(
+ parser : XML_Parser; enc : ENCODING_ptr; isCdata : XML_Bool;
+ ptr ,end_ : char_ptr; pool : STRING_POOL_ptr ) : XML_Error; forward;
+
+const
+ implicitContext : array[0..40 ] of XML_Char = (
+ 'x' ,'m' ,'l' ,'=' ,'h' ,'t' ,'t' ,'p' ,':' ,'/' ,'/' ,
+ 'w' ,'w' ,'w' ,'.' ,'w' ,'3' ,'.' ,'o' ,'r' ,'g' ,'/' ,
+ 'X' ,'M' ,'L' ,'/' ,'1' ,'9' ,'9' ,'8' ,'/' ,
+ 'n' ,'a' ,'m' ,'e' ,'s' ,'p' ,'a' ,'c' ,'e' ,#0 );
+
+ INIT_TAG_BUF_SIZE = 32; { must be a multiple of sizeof(XML_Char) }
+ INIT_DATA_BUF_SIZE = 1024;
+ INIT_ATTS_SIZE = 16;
+ INIT_ATTS_VERSION = $FFFFFFFF;
+ INIT_BLOCK_SIZE = 1024;
+ INIT_BUFFER_SIZE = 1024;
+
+ EXPAND_SPARE = 24;
+
+ INIT_SCAFFOLD_ELEMENTS = 32;
+
+ INIT_POWER = 6;
+
+type
+ ICHAR_ptr_ptr = ^ICHAR_ptr;
+ ICHAR_ptr = ^ICHAR;
+
+{$IFDEF XML_UNICODE }
+ ICHAR = int16u;
+
+{$ELSE }
+ ICHAR = char;
+
+{$ENDIF }
+
+ HASH_TABLE_ITER_ptr = ^HASH_TABLE_ITER;
+ HASH_TABLE_ITER = record
+ p ,
+ end_ : NAMED_ptr_ptr;
+
+ end;
+
+const
+{$IFDEF XML_UNICODE }
+ XML_ENCODE_MAX = XML_UTF16_ENCODE_MAX;
+
+{$ELSE }
+ XML_ENCODE_MAX = XML_UTF8_ENCODE_MAX;
+
+{$ENDIF }
+
+{ memcmp }
+function memcmp(p1 ,p2 : int8u_ptr; l : int ) : int;
+begin
+ while l > 0 do
+ begin
+ if p1^ <> p2^ then
+ begin
+ result:=p1^ - p2^;
+
+ exit;
+
+ end;
+
+ dec(l );
+ inc(ptrcomp(p1 ) );
+ inc(ptrcomp(p2 ) );
+
+ end;
+
+ result:=0;
+
+end;
+
+{ CHAR_HASH }
+{ Basic character hash algorithm, taken from Python's string hash:
+ h = h * 1000003 ^ character, the constant being a prime number. }
+function CHAR_HASH(h : int32u; c : XML_Char ) : int32u;
+begin
+{$IFDEF XML_UNICODE }
+ result:=(h * $F4243 ) xor int16u(c );
+
+{$ELSE }
+ result:=(h * $F4243 ) xor int8u(c );
+
+{$ENDIF }
+
+end;
+
+{ MUST_CONVERT }
+function MUST_CONVERT(enc : ENCODING_ptr; s : char_ptr ) : int;
+begin
+{$IFDEF XML_UNICODE }
+ result:=
+ int(
+ not boolean(enc.isUtf16 ) or
+ boolean(int32u(s ) and 1 ) );
+
+{$ELSE }
+ result:=int(not boolean(enc.isUtf8 ) );
+
+{$ENDIF }
+
+end;
+
+{ For probing (after a collision) we need a step size relative prime
+ to the hash table size, which is a power of 2. We use double-hashing,
+ since we can calculate a second hash value cheaply by taking those bits
+ of the first hash value that were discarded (masked out) when the table
+ index was calculated: index:=hash and mask, where mask:=table.size - 1.
+ We limit the maximum step size to table.size div 4 (mask shr 2 ) and make
+ it odd, since odd numbers are always relative prime to a power of 2. }
+{ SECOND_HASH }
+function SECOND_HASH(hash ,mask : int32u; power : int8u ) : int8u;
+begin
+ result:=((hash and not mask ) shr (power - 1 ) ) and (mask shr 2 );
+
+end;
+
+{ PROBE_STEP }
+function PROBE_STEP(hash ,mask : int32u; power : int8u ) : int8u;
+begin
+ result:=SECOND_HASH(hash, mask, power) or 1;
+
+end;
+
+{ XML_T }
+function XML_T(x : char ) : XML_Char;
+begin
+ result:=x;
+
+end;
+
+{ XML_L }
+function XML_L(x : char ) : XML_Char;
+begin
+ result:=x;
+
+end;
+
+{ ROUND_UP }
+{ Round up n to be a multiple of sz, where sz is a power of 2. }
+function ROUND_UP(n ,sz : int ) : int;
+begin
+ result:=(n + (sz - 1 ) ) and not(sz - 1 );
+
+end;
+
+{ XmlConvert }
+procedure XmlConvert(enc : ENCODING_ptr; fromP ,fromLim ,toP ,toLim : pointer );
+begin
+{$IFDEF XML_UNICODE }
+ XmlUtf16Convert(enc ,fromP ,fromLim ,toP ,toLim );
+
+{$ELSE }
+ XmlUtf8Convert(enc ,fromP ,fromLim ,toP ,toLim );
+
+{$ENDIF }
+
+end;
+
+{ XmlEncode }
+function XmlEncode(charNumber : int; buf : pointer ) : int;
+begin
+{$IFDEF XML_UNICODE }
+ result:=XmlUtf16Encode(charNumber ,buf );
+
+{$ELSE }
+ result:=XmlUtf8Encode(charNumber ,buf );
+
+{$ENDIF }
+
+end;
+
+{ poolInit }
+procedure poolInit(pool : STRING_POOL_ptr; ms : XML_Memory_Handling_Suite_ptr );
+begin
+ pool.blocks :=NIL;
+ pool.freeBlocks:=NIL;
+ pool.start :=NIL;
+ pool.ptr :=NIL;
+ pool.end_ :=NIL;
+ pool.mem :=ms;
+
+end;
+
+{ hashTableDestroy }
+procedure hashTableDestroy(table : HASH_TABLE_ptr );
+var
+ i : size_t;
+
+begin
+ i:=0;
+
+ while i < table.size do
+ begin
+ if NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^ <> NIL then
+ table.mem.free_fcn(
+ pointer(NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^ ) ,
+ NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^^.alloc );
+
+ inc(i );
+
+ end;
+
+ table.mem.free_fcn(pointer(table.v ) ,table.a );
+
+end;
+
+{ hashTableInit }
+procedure hashTableInit(p : HASH_TABLE_ptr; ms : XML_Memory_Handling_Suite_ptr );
+begin
+ p.power:=0;
+ p.size :=0;
+ p.used :=0;
+ p.v :=NIL;
+ p.mem :=ms;
+
+end;
+
+{ hashTableIterInit }
+procedure hashTableIterInit(iter : HASH_TABLE_ITER_ptr; table : HASH_TABLE_ptr );
+begin
+ iter.p :=table.v;
+ iter.end_:=NAMED_ptr_ptr(ptrcomp(iter.p ) + table.size * sizeof(NAMED_ptr ) );
+
+end;
+
+{ hashTableIterNext }
+function hashTableIterNext(iter : HASH_TABLE_ITER_ptr ) : NAMED_ptr;
+var
+ tem : NAMED_ptr;
+
+begin
+ while iter.p <> iter.end_ do
+ begin
+ tem:=iter.p^;
+
+ inc(ptrcomp(iter.p ) ,sizeof(NAMED_ptr ) );
+
+ if tem <> NIL then
+ begin
+ result:=tem;
+
+ exit;
+
+ end;
+
+ end;
+
+ result:=NIL;
+
+end;
+
+{ dtdCreate }
+function dtdCreate(ms : XML_Memory_Handling_Suite_ptr ) : DTD_ptr;
+var
+ p : DTD_ptr;
+
+begin
+ ms.malloc_fcn(pointer(p ) ,sizeof(DTD ) );
+
+ if p = NIL then
+ begin
+ result:=p;
+
+ exit;
+
+ end;
+
+ poolInit(@p.pool ,ms );
+ poolInit(@p.entityValuePool ,ms );
+
+ hashTableInit(@p.generalEntities ,ms );
+ hashTableInit(@p.elementTypes ,ms );
+ hashTableInit(@p.attributeIds ,ms );
+ hashTableInit(@p.prefixes ,ms );
+
+{$IFDEF XML_DTD }
+ p.paramEntityRead:=XML_FALSE;
+
+ hashTableInit(@p.paramEntities ,ms );
+
+{$ENDIF }
+
+ p.defaultPrefix.name :=NIL;
+ p.defaultPrefix.binding:=NIL;
+
+ p.in_eldecl :=XML_FALSE;
+ p.scaffIndex :=NIL;
+ p.scaffAlloc :=0;
+ p.scaffold :=NIL;
+ p.scaffLevel :=0;
+ p.scaffSize :=0;
+ p.scaffCount :=0;
+ p.contentStringLen:=0;
+
+ p.keepProcessing :=XML_TRUE;
+ p.hasParamEntityRefs:=XML_FALSE;
+ p.standalone :=XML_FALSE;
+
+ result:=p;
+
+end;
+
+{ dtdDestroy }
+procedure dtdDestroy(p : DTD_ptr; isDocEntity : XML_Bool; ms : XML_Memory_Handling_Suite_ptr );
+var
+ iter : HASH_TABLE_ITER;
+
+ e : ELEMENT_TYPE_ptr;
+
+begin
+ hashTableIterInit(@iter ,@p.elementTypes );
+
+ repeat
+ e:=ELEMENT_TYPE_ptr(hashTableIterNext(@iter ) );
+
+ if e = NIL then
+ break;
+
+ if e.allocDefaultAtts <> 0 then
+ ms.free_fcn(pointer(e.defaultAtts ) ,e.defaultAttsAlloc );
+
+ until false;
+
+ hashTableDestroy(@p.generalEntities );
+
+{$IFDEF XML_DTD }
+ hashTableDestroy(@p.paramEntities );
+
+{$ENDIF }
+
+ hashTableDestroy(@p.elementTypes );
+ hashTableDestroy(@p.attributeIds );
+ hashTableDestroy(@p.prefixes );
+
+ poolDestroy(@p.pool );
+ poolDestroy(@p.entityValuePool );
+
+ if isDocEntity <> 0 then
+ begin
+ ms.free_fcn(pointer(p.scaffIndex ) ,p.scaffAlloc );
+ ms.free_fcn(pointer(p.scaffold ) ,sizeof(CONTENT_SCAFFOLD ) );
+
+ end;
+
+ ms.free_fcn(pointer(p ) ,sizeof(DTD ) );
+
+end;
+
+{ handleUnknownEncoding {..}
+function handleUnknownEncoding(parser : XML_Parser; encodingName : XML_Char_ptr ) : XML_Error;
+begin
+end;
+
+{ initializeEncoding }
+function initializeEncoding(parser : XML_Parser ) : XML_Error;
+var
+ s : char_ptr;
+ ok : int;
+
+begin
+{$IFDEF XML_UNICODE {..}
+
+
+{$ELSE }
+ s:=pointer(parser.m_protocolEncodingName );
+
+{$ENDIF }
+
+ if parser.m_ns <> 0 then
+ ok:=XmlInitEncodingNS(@parser.m_initEncoding ,@parser.m_encoding ,pointer(s ) )
+ else
+ ok:=XmlInitEncoding(@parser.m_initEncoding ,@parser.m_encoding ,pointer(s ) );
+
+ if ok <> 0 then
+ result:=XML_ERROR_NONE
+ else
+ result:=handleUnknownEncoding(parser ,parser.m_protocolEncodingName );
+
+end;
+
+{ reportDefault {..}
+procedure reportDefault(parser : XML_Parser; enc : ENCODING_ptr; start ,end_ : char_ptr );
+begin
+end;
+
+{ getContext {..}
+function getContext(parser : XML_Parser ) : XML_Char_ptr;
+begin
+end;
+
+{ processXmlDecl }
+function processXmlDecl(parser : XML_Parser; isGeneralTextEntity : int; s ,next : char_ptr ) : XML_Error;
+var
+ encodingName ,version ,versionend : char_ptr;
+
+ storedEncName ,storedversion : XML_Char_ptr;
+
+ newEncoding : ENCODING_ptr;
+
+ standalone ,ok : int;
+
+ result_ : XML_Error;
+
+begin
+ encodingName :=NIL;
+ storedEncName:=NIL;
+ newEncoding :=NIL;
+ version :=NIL;
+ storedversion:=NIL;
+ standalone :=-1;
+
+ if parser.m_ns <> 0 then
+ ok:=
+ XmlParseXmlDeclNS(
+ isGeneralTextEntity ,parser.m_encoding ,pointer(s ) ,pointer(next ) ,
+ @parser.m_eventPtr ,@version ,@versionend ,@encodingName ,
+ @newEncoding ,@standalone )
+ else
+ ok:=
+ XmlParseXmlDecl(
+ isGeneralTextEntity ,parser.m_encoding ,pointer(s ) ,pointer(next ) ,
+ @parser.m_eventPtr ,@version ,@versionend ,@encodingName ,
+ @newEncoding ,@standalone );
+
+ if ok = 0 then
+ if isGeneralTextEntity <> 0 then
+ begin
+ result:=XML_ERROR_TEXT_DECL;
+
+ exit;
+
+ end
+ else
+ begin
+ result:=XML_ERROR_XML_DECL;
+
+ exit;
+
+ end;
+
+ if (isGeneralTextEntity = 0 ) and
+ (standalone = 1 ) then
+ begin
+ parser.m_dtd.standalone:=XML_TRUE;
+
+ {$IFDEF XML_DTD }
+ if parser.m_paramEntityParsing = XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE then
+ parser.m_paramEntityParsing:=XML_PARAM_ENTITY_PARSING_NEVER;
+
+ {$ENDIF }
+
+ end;
+
+ if @parser.m_xmlDeclHandler <> NIL then
+ begin
+ if encodingName <> NIL then
+ begin
+ storedEncName:=
+ poolStoreString(
+ @parser.m_temp2Pool ,
+ parser.m_encoding ,
+ encodingName,
+ char_ptr(ptrcomp(encodingName ) + XmlNameLength(parser.m_encoding ,pointer(encodingName ) ) ) );
+
+ if storedEncName = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ poolFinish(@parser.m_temp2Pool );
+
+ end;
+
+ if version <> NIL then
+ begin
+ storedversion:=
+ poolStoreString(
+ @parser.m_temp2Pool ,
+ parser.m_encoding ,
+ version ,
+ char_ptr(ptrcomp(versionend ) - parser.m_encoding.minBytesPerChar ) );
+
+ if storedversion = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ end;
+
+ parser.m_xmlDeclHandler(
+ parser.m_handlerArg ,storedversion ,storedEncName ,standalone );
+
+ end
+ else
+ if @parser.m_defaultHandler <> NIL then
+ reportDefault(parser ,parser.m_encoding ,s ,next );
+
+ if parser.m_protocolEncodingName = NIL then
+ begin
+ if newEncoding <> NIL then
+ begin
+ if newEncoding.minBytesPerChar <> parser.m_encoding.minBytesPerChar then
+ begin
+ parser.m_eventPtr:=encodingName;
+
+ result:=XML_ERROR_INCORRECT_ENCODING;
+
+ exit;
+
+ end;
+
+ parser.m_encoding:=newEncoding;
+
+ end
+ else
+ if encodingName <> NIL then
+ begin
+ if storedEncName = NIL then
+ begin
+ storedEncName:=
+ poolStoreString(
+ @parser.m_temp2Pool ,parser.m_encoding ,encodingName ,
+ char_ptr(ptrcomp(encodingName ) + XmlNameLength(parser.m_encoding ,pointer(encodingName ) ) ) );
+
+ if storedEncName = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ end;
+
+ result_:=handleUnknownEncoding(parser ,storedEncName );
+
+ poolClear(@parser.m_temp2Pool );
+
+ if result_ = XML_ERROR_UNKNOWN_ENCODING then
+ parser.m_eventPtr:=encodingName;
+
+ result:=result_;
+
+ exit;
+
+ end;
+
+ end;
+
+ if (storedEncName <> NIL ) or
+ (storedversion <> NIL ) then
+ poolClear(@parser.m_temp2Pool );
+
+ result:=XML_ERROR_NONE;
+
+end;
+
+{ poolClear }
+procedure poolClear(pool : STRING_POOL_ptr );
+var
+ p ,tem : BLOCK_ptr;
+
+begin
+ if pool.freeBlocks = NIL then
+ pool.freeBlocks:=pool.blocks
+
+ else
+ begin
+ p:=pool.blocks;
+
+ while p <> NIL do
+ begin
+ tem :=p.next;
+ p.next :=pool.freeBlocks;
+ pool.freeBlocks:=p;
+ p :=tem;
+
+ end;
+
+ end;
+
+ pool.blocks:=NIL;
+ pool.start :=NIL;
+ pool.ptr :=NIL;
+ pool.end_ :=NIL;
+
+end;
+
+{ poolDestroy }
+procedure poolDestroy(pool : STRING_POOL_ptr );
+var
+ p ,tem : BLOCK_ptr;
+
+begin
+ p:=pool.blocks;
+
+ while p <> NIL do
+ begin
+ tem:=p.next;
+
+ pool.mem.free_fcn(pointer(p ) ,p.alloc );
+
+ p:=tem;
+
+ end;
+
+ p:=pool.freeBlocks;
+
+ while p <> NIL do
+ begin
+ tem:=p.next;
+
+ pool.mem.free_fcn(pointer(p ) ,p.alloc );
+
+ p:=tem;
+
+ end;
+
+end;
+
+{ poolGrow }
+function poolGrow(pool : STRING_POOL_ptr ) : XML_Bool;
+var
+ tem : BLOCK_ptr;
+
+ blockSize : int;
+
+begin
+ if pool.freeBlocks <> NIL then
+ begin
+ if pool.start = NIL then
+ begin
+ pool.blocks :=pool.freeBlocks;
+ pool.freeBlocks :=pool.freeBlocks.next;
+ pool.blocks.next:=NIL;
+
+ pool.start:=@pool.blocks.s;
+ pool.end_ :=XML_Char_ptr(ptrcomp(pool.start ) + pool.blocks.size * sizeof(XML_Char ) );
+ pool.ptr :=pool.start;
+
+ result:=XML_TRUE;
+
+ exit;
+
+ end;
+
+ if ptrcomp(pool.end_ ) - ptrcomp(pool.start ) < pool.freeBlocks.size then
+ begin
+ tem:=pool.freeBlocks.next;
+
+ pool.freeBlocks.next:=pool.blocks;
+ pool.blocks :=pool.freeBlocks;
+ pool.freeBlocks :=tem;
+
+ move(
+ pool.start^ ,
+ pointer(@pool.blocks.s )^ ,
+ ptrcomp(pool.end_ ) - ptrcomp(pool.start ) );
+
+ pool.ptr :=XML_Char_ptr(ptrcomp(@pool.blocks.s ) + ptrcomp(pool.ptr ) - ptrcomp(pool.start ) );
+ pool.start:=@pool.blocks.s;
+ pool.end_ :=XML_Char_ptr(ptrcomp(pool.start ) + pool.blocks.size * sizeof(XML_Char ) );
+
+ result:=XML_TRUE;
+
+ exit;
+
+ end;
+
+ end;
+
+ if (pool.blocks <> NIL ) and
+ (pool.start = @pool.blocks.s ) then
+ begin
+ blockSize:=(ptrcomp(pool.end_ ) - ptrcomp(pool.start ) ) * 2 div sizeof(XML_Char );
+
+ pool.mem.realloc_fcn(
+ pointer(pool.blocks ) ,
+ pool.blocks.alloc ,
+ (sizeof(BLOCK_ptr ) + sizeof(int ) * 2 ) + blockSize * sizeof(XML_Char ) );
+
+ if pool.blocks = NIL then
+ begin
+ result:=XML_FALSE;
+
+ exit;
+
+ end
+ else
+ pool.blocks.alloc:=(sizeof(BLOCK_ptr ) + sizeof(int ) * 2 ) + blockSize * sizeof(XML_Char );
+
+ pool.blocks.size:=blockSize;
+
+ pool.ptr :=XML_Char_ptr(ptrcomp(@pool.blocks.s ) + (ptrcomp(pool.ptr ) - ptrcomp(pool.start ) ) );
+ pool.start:=@pool.blocks.s;
+ pool.end_ :=XML_Char_ptr(ptrcomp(pool.start ) + blockSize * sizeof(XML_Char ) );
+
+ end
+ else
+ begin
+ blockSize:=(ptrcomp(pool.end_ ) - ptrcomp(pool.start ) ) div sizeof(XML_Char );
+
+ if blockSize < INIT_BLOCK_SIZE then
+ blockSize:=INIT_BLOCK_SIZE
+ else
+ blockSize:=blockSize * 2;
+
+ pool.mem.malloc_fcn(
+ pointer(tem ) ,
+ (sizeof(BLOCK_ptr ) + sizeof(int ) * 2 ) + blockSize * sizeof(XML_Char ) );
+
+ if tem = NIL then
+ begin
+ result:=XML_FALSE;
+
+ exit;
+
+ end;
+
+ tem.size :=blockSize;
+ tem.alloc:=(sizeof(BLOCK_ptr ) + sizeof(int ) * 2 ) + blockSize * sizeof(XML_Char );
+ tem.next :=pool.blocks;
+
+ pool.blocks:=tem;
+
+ if pool.ptr <> pool.start then
+ move(
+ pool.start^ ,
+ pointer(@tem.s )^ ,
+ ptrcomp(pool.ptr ) - ptrcomp(pool.start ) );
+
+ pool.ptr :=XML_Char_ptr(ptrcomp(@tem.s ) + (ptrcomp(pool.ptr ) - ptrcomp(pool.start ) ) * sizeof(XML_Char ) );
+ pool.start:=@tem.s;
+ pool.end_ :=XML_Char_ptr(ptrcomp(@tem.s ) + blockSize * sizeof(XML_Char ) );
+
+ end;
+
+ result:=XML_TRUE;
+
+end;
+
+{ poolAppend }
+function poolAppend(pool : STRING_POOL_ptr; enc : ENCODING_ptr; ptr ,end_ : char_ptr ) : XML_Char_ptr;
+begin
+ if (pool.ptr = NIL ) and
+ (poolGrow(pool ) = 0 ) then
+ begin
+ result:=NIL;
+
+ exit;
+
+ end;
+
+ repeat
+ XmlConvert(
+ enc ,@ptr ,end_ ,
+ ICHAR_ptr_ptr(@pool.ptr ) ,
+ ICHAR_ptr(pool.end_ ) );
+
+ if ptr = end_ then
+ break;
+
+ if poolGrow(pool ) = 0 then
+ result:=NIL;
+
+ until false;
+
+ result:=pool.start;
+
+end;
+
+{ poolStoreString }
+function poolStoreString(pool : STRING_POOL_ptr; enc : ENCODING_ptr; ptr ,end_ : char_ptr ) : XML_Char_ptr;
+begin
+ if poolAppend(pool ,enc ,ptr ,end_ ) = NIL then
+ begin
+ result:=NIL;
+
+ exit;
+
+ end;
+
+ if (pool.ptr = pool.end_ ) and
+ (poolGrow(pool ) = 0 ) then
+ begin
+ result:=NIL;
+
+ exit;
+
+ end;
+
+ pool.ptr^:=XML_Char(0 );
+
+ inc(ptrcomp(pool.ptr ) );
+
+ result:=pool.start;
+
+end;
+
+{ poolCopyString }
+function poolCopyString(pool : STRING_POOL_ptr; s : XML_Char_ptr ) : XML_Char_ptr;
+label
+ _w0 ;
+
+begin
+ goto _w0;
+
+ while s^ <> XML_Char(0 ) do
+ begin
+ _w0:
+ if poolAppendChar(pool ,s^ ) = 0 then
+ begin
+ result:=NIL;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(s ) ,sizeof(XML_Char ) );
+
+ end;
+
+ s:=pool.start;
+
+ poolFinish(pool );
+
+ result:=s;
+
+end;
+
+{ poolAppendString {..}
+function poolAppendString(pool : STRING_POOL_ptr; s : XML_Char_ptr ) : XML_Char_ptr;
+begin
+end;
+
+{ poolStart }
+function poolStart(pool : STRING_POOL_ptr ) : XML_Char_ptr;
+begin
+ result:=pool.start;
+
+end;
+
+{ poolLength }
+function poolLength(pool : STRING_POOL_ptr ) : int;
+begin
+ result:=ptrcomp(pool.ptr ) - ptrcomp(pool.start );
+
+end;
+
+{ poolChop }
+procedure poolChop(pool : STRING_POOL_ptr );
+begin
+ dec(ptrcomp(pool.ptr ) ,sizeof(XML_Char ) );
+
+end;
+
+{ poolLastChar }
+function poolLastChar(pool : STRING_POOL_ptr ) : XML_Char;
+begin
+ result:=XML_Char_ptr(ptrcomp(pool.ptr ) - 1 * sizeof(XML_Char ) )^;
+
+end;
+
+{ poolDiscard }
+procedure poolDiscard(pool : STRING_POOL_ptr );
+begin
+ pool.ptr:=pool.start;
+
+end;
+
+{ poolFinish }
+procedure poolFinish(pool : STRING_POOL_ptr );
+begin
+ pool.start:=pool.ptr;
+
+end;
+
+{ poolAppendChar }
+function poolAppendChar(pool : STRING_POOL_ptr; c : char ) : int;
+begin
+ if (pool.ptr = pool.end_ ) and
+ (poolGrow(pool ) = 0 ) then
+ result:=0
+ else
+ begin
+ pool.ptr^:=c;
+
+ inc(ptrcomp(pool.ptr ) );
+
+ result:=1;
+
+ end;
+
+end;
+
+{ keyeq }
+function keyeq(s1 ,s2 : KEY ) : XML_Bool;
+begin
+ while s1^ = s2^ do
+ begin
+ if s1^ = #0 then
+ begin
+ result:=XML_TRUE;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(s1 ) ,sizeof(XML_Char ) );
+ inc(ptrcomp(s2 ) ,sizeof(XML_Char ) );
+
+ end;
+
+ result:=XML_FALSE;
+
+end;
+
+{ hash }
+function hash(s : KEY ) : int32u;
+var
+ h : int32u;
+
+begin
+ h:=0;
+
+ while s^ <> XML_Char(0 ) do
+ begin
+ h:=CHAR_HASH(h ,s^ );
+
+ inc(ptrcomp(s ) ,sizeof(XML_Char ) );
+
+ end;
+
+ result:=h;
+
+end;
+
+{ lookup }
+function lookup(table : HASH_TABLE_ptr; name : KEY; createSize : size_t ) : NAMED_ptr;
+var
+ i ,tsize ,newSize ,j : size_t;
+
+ h ,mask ,newMask ,newHash : int32u;
+
+ step ,newPower : int8u;
+
+ newV : NAMED_ptr_ptr;
+
+begin
+ if table.size = 0 then
+ begin
+ if createSize = 0 then
+ begin
+ result:=NIL;
+
+ exit;
+
+ end;
+
+ table.power:=INIT_POWER;
+
+ { table->size is a power of 2 }
+ table.size:=size_t(1 shl INIT_POWER );
+
+ tsize:=table.size * sizeof(NAMED_ptr );
+
+ table.mem.malloc_fcn(pointer(table.v ) ,tsize );
+
+ if table.v = NIL then
+ begin
+ table.size:=0;
+
+ result:=NIL;
+
+ exit;
+
+ end
+ else
+ table.a:=tsize;
+
+ fillchar(table.v^ ,tsize ,0 );
+
+ i:=hash(name ) and (table.size - 1 );
+
+ end
+ else
+ begin
+ h :=hash(name );
+ mask:=table.size - 1;
+ step:=0;
+ i :=h and mask;
+
+ while NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^ <> NIL do
+ begin
+ if keyeq(
+ name ,
+ NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^^.name ) <> 0 then
+ begin
+ result:=NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^;
+
+ exit;
+
+ end;
+
+ if step = 0 then
+ step:=PROBE_STEP(h ,mask ,table.power );
+
+ if i < step then
+ inc(i ,table.size - step )
+ else
+ dec(i ,step );
+
+ end;
+
+ if createSize = 0 then
+ begin
+ result:=NIL;
+
+ exit;
+
+ end;
+
+ { check for overflow (table is half full) }
+ if table.used shr (table.power - 1 ) <> 0 then
+ begin
+ newPower:=table.power + 1;
+ newSize :=size_t(1 shl newPower );
+ newMask :=newSize - 1;
+ tsize :=newSize * sizeof(NAMED_ptr );
+
+ table.mem.malloc_fcn(pointer(newV ) ,tsize );
+
+ if newV = NIL then
+ begin
+ result:=NIL;
+
+ exit;
+
+ end;
+
+ fillchar(newV^ ,tsize ,0 );
+
+ i:=0;
+
+ while i < table.size do
+ begin
+ if NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^ <> NIL then
+ begin
+ newHash:=hash(NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^^.name );
+ j :=newHash and newMask;
+ step :=0;
+
+ while NAMED_ptr_ptr(ptrcomp(newV ) + j * sizeof(NAMED_ptr ) )^ <> NIL do
+ begin
+ if step = 0 then
+ step:=PROBE_STEP(newHash ,newMask ,newPower );
+
+ if j < step then
+ inc(j ,newSize - step )
+ else
+ dec(j ,step );
+
+ end;
+
+ NAMED_ptr_ptr(ptrcomp(newV ) + j * sizeof(NAMED_ptr ) )^:=
+ NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^;
+
+ end;
+
+ inc(i );
+
+ end;
+
+ table.mem.free_fcn(pointer(table.v ) ,table.a );
+
+ table.v :=newV;
+ table.a :=tsize;
+ table.power:=newPower;
+ table.size :=newSize;
+
+ i :=h and newMask;
+ step:=0;
+
+ while NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^ <> NIL do
+ begin
+ if step = 0 then
+ step:=PROBE_STEP(h ,newMask ,newPower );
+
+ if i < step then
+ inc(i ,newSize - step )
+ else
+ dec(i ,step );
+
+ end;
+
+ end;
+
+ end;
+
+ table.mem.malloc_fcn(
+ pointer(NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^ ) ,
+ createSize );
+
+ if NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^ = NIL then
+ begin
+ result:=NIL;
+
+ exit;
+
+ end;
+
+ fillchar(NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^^ ,createSize ,0 );
+
+ NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^^.name :=name;
+ NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^^.alloc:=createSize;
+
+ inc(table.used );
+
+ result:=NAMED_ptr_ptr(ptrcomp(table.v ) + i * sizeof(NAMED_ptr ) )^;
+
+end;
+
+{ normalizePublicId }
+procedure normalizePublicId(publicId : XML_Char_ptr );
+var
+ p ,s : XML_Char_ptr;
+
+begin
+ p:=publicId;
+ s:=publicId;
+
+ while s^ <> XML_Char(0 ) do
+ begin
+ case s^ of
+ XML_Char($20 ) ,XML_Char($D ) ,XML_Char($A ) :
+ if (p <> publicId ) and
+ (XML_Char_ptr(ptrcomp(p ) -1 * sizeof(XML_Char ) )^ <> XML_Char($20 ) ) then
+ begin
+ p^:=XML_Char($20 );
+
+ inc(ptrcomp(p ) ,sizeof(XML_Char ) );
+
+ end;
+
+ else
+ begin
+ p^:=s^;
+
+ inc(ptrcomp(p ) ,sizeof(XML_Char ) );
+
+ end;
+
+ end;
+
+ inc(ptrcomp(s ) ,sizeof(XML_Char ) );
+
+ end;
+
+ if (p <> publicId ) and
+ (XML_Char_ptr(ptrcomp(p ) -1 * sizeof(XML_Char ) )^ = XML_Char($20 ) ) then
+ dec(ptrcomp(p ) ,sizeof(XML_Char ) );
+
+ p^:=XML_T(#0 );
+
+end;
+
+{ setElementTypePrefix {..}
+function setElementTypePrefix(parser : XML_Parser; elementType : ELEMENT_TYPE_ptr ) : int;
+begin
+end;
+
+{ addBinding {..}
+{ addBinding overwrites the value of prefix.binding without checking.
+ Therefore one must keep track of the old value outside of addBinding. }
+function addBinding(
+ parser : XML_Parser; prefix : PREFIX_ptr; attId : ATTRIBUTE_ID_ptr;
+ uri : XML_Char_ptr; bindingsPtr : BINDING_ptr_ptr ) : XML_Error;
+begin
+end;
+
+{ storeRawNames }
+{ Initially tag.rawName always points into the parse buffer;
+ for those TAG instances opened while the current parse buffer was
+ processed, and not yet closed, we need to store tag.rawName in a more
+ permanent location, since the parse buffer is about to be discarded. }
+function storeRawNames(parser : XML_Parser ) : XML_Bool;
+var
+ tag : TAG_ptr;
+
+ bufSize ,nameLen : int;
+
+ rawNameBuf ,temp : char_ptr;
+
+begin
+ tag:=parser.m_tagStack;
+
+ while tag <> NIL do
+ begin
+ nameLen :=sizeof(XML_Char ) * (tag.name.strLen + 1 );
+ rawNameBuf:=char_ptr(ptrcomp(tag.buf ) + nameLen );
+
+ { Stop if already stored. Since tagStack is a stack, we can stop
+ at the first entry that has already been copied; everything
+ below it in the stack is already been accounted for in a
+ previous call to this function. }
+ if tag.rawName = rawNameBuf then
+ break;
+
+ { For re-use purposes we need to ensure that the
+ size of tag.buf is a multiple of sizeof(XML_Char ). }
+ bufSize:=nameLen + ROUND_UP(tag.rawNameLength ,sizeof(XML_Char ) );
+
+ if bufSize > ptrcomp(tag.bufEnd ) - ptrcomp(tag.buf ) then
+ begin
+ if parser.m_mem.realloc_fcn(pointer(tag.buf ) ,tag.alloc ,bufSize ) then
+ temp:=tag.buf
+ else
+ temp:=NIL;
+
+ if temp = NIL then
+ begin
+ result:=XML_FALSE;
+
+ exit;
+
+ end;
+
+ tag.alloc:=bufSize;
+
+ { if tag.name.str points to tag.buf (only when namespace
+ processing is off) then we have to update it }
+ if tag.name.str = XML_Char_ptr(tag.buf ) then
+ tag.name.str:=XML_Char_ptr(temp );
+
+ { if tag->name.localPart is set (when namespace processing is on)
+ then update it as well, since it will always point into tag->buf }
+ if tag.name.localPart <> NIL then
+ tag.name.localPart:=
+ XML_Char_ptr(
+ ptrcomp(temp ) +
+ (ptrcomp(tag.name.localPart ) - ptrcomp(tag.buf ) ) );
+
+ tag.buf :=temp;
+ tag.bufEnd:=char_ptr(ptrcomp(temp ) + bufSize );
+ rawNameBuf:=char_ptr(ptrcomp(temp ) + nameLen );
+
+ end;
+
+ move(tag.rawName^ ,rawNameBuf^ ,tag.rawNameLength );
+
+ tag.rawName:=rawNameBuf;
+ tag :=tag.parent;
+
+ end;
+
+ result:=XML_TRUE;
+
+end;
+
+{ storeAtts }
+{ Precondition: all arguments must be non-NULL;
+ Purpose:
+ - normalize attributes
+ - check attributes for well-formedness
+ - generate namespace aware attribute names (URI, prefix)
+ - build list of attributes for startElementHandler
+ - default attributes
+ - process namespace declarations (check and report them)
+ - generate namespace aware element name (URI, prefix) }
+function storeAtts(
+ parser : XML_Parser; enc : ENCODING_ptr;
+ attStr : char_ptr; tagNamePtr : TAG_NAME_ptr;
+ bindingsPtr : BINDING_ptr_ptr ) : XML_Error;
+var
+ dtd : DTD_ptr;
+
+ elementType : ELEMENT_TYPE_ptr;
+
+ nDefaultAtts ,attIndex ,prefixLen ,i ,n ,nPrefixes ,oldAttsSize ,j ,nsAttsSize : int;
+
+ version ,uriHash ,mask : int32u;
+
+ step : int8u;
+
+ appAtts : XML_Char_ptr_ptr; { the attribute list for the application }
+
+ uri ,localPart ,name ,s ,s1 ,s2 : XML_Char_ptr;
+
+ c : XML_Char;
+
+ binding ,b : BINDING_ptr;
+
+ attId ,id : ATTRIBUTE_ID_ptr;
+
+ result_ : XML_Error;
+
+ isCdata : XML_Bool;
+
+ da : DEFAULT_ATTRIBUTE_ptr;
+
+ p : TAG_ptr;
+
+label
+ _w0 ,_w1 ;
+
+begin
+ dtd:=parser.m_dtd; { save one level of indirection }
+
+ attIndex :=0;
+ nPrefixes:=0;
+
+{ lookup the element type name }
+ elementType:=
+ ELEMENT_TYPE_ptr(lookup(
+ @dtd.elementTypes ,tagNamePtr.str ,0 ) );
+
+ if elementType = NIL then
+ begin
+ name:=poolCopyString(@dtd.pool ,tagNamePtr.str );
+
+ if name = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ elementType:=
+ ELEMENT_TYPE_ptr(lookup(
+ @dtd.elementTypes ,name ,sizeof(ELEMENT_TYPE ) ) );
+
+ if elementType = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ if (parser.m_ns <> 0 ) and
+ (setElementTypePrefix(parser ,elementType ) = 0 ) then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ end;
+
+ nDefaultAtts:=elementType.nDefaultAtts;
+
+{ get the attributes from the tokenizer }
+ n:=XmlGetAttributes(enc ,pointer(attStr ) ,parser.m_attsSize ,parser.m_atts );
+
+ if n + nDefaultAtts > parser.m_attsSize then
+ begin
+ oldAttsSize :=parser.m_attsSize;
+ parser.m_attsSize:=n + nDefaultAtts + INIT_ATTS_SIZE;
+
+ if not parser.m_mem.realloc_fcn(
+ pointer(parser.m_atts ) ,
+ parser.m_attsAlloc ,
+ parser.m_attsSize * sizeof(ATTRIBUTE ) ) then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end
+ else
+ parser.m_attsAlloc:=parser.m_attsSize * sizeof(ATTRIBUTE );
+
+ if n > oldAttsSize then
+ XmlGetAttributes(enc ,pointer(attStr ) ,n ,parser.m_atts );
+
+ end;
+
+ appAtts:=XML_Char_ptr_ptr(parser.m_atts );
+
+ i:=0;
+
+ while i < n do
+ begin
+ { add the name and value to the attribute list }
+ attId:=
+ getAttributeId(
+ parser ,enc ,
+ pointer(ATTRIBUTE_ptr(ptrcomp(parser.m_atts ) + i * sizeof(ATTRIBUTE ) )^.name ) ,
+ pointer(
+ ptrcomp(ATTRIBUTE_ptr(ptrcomp(parser.m_atts ) + i * sizeof(ATTRIBUTE ) )^.name ) +
+ XmlNameLength(enc ,ATTRIBUTE_ptr(ptrcomp(parser.m_atts ) + i * sizeof(ATTRIBUTE ) )^.name ) ) );
+
+ if attId = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ { Detect duplicate attributes by their QNames. This does not work when
+ namespace processing is turned on and different prefixes for the same
+ namespace are used. For this case we have a check further down. }
+ if XML_Char_ptr(ptrcomp(attId.name ) - 1 * sizeof(XML_Char ) )^ <> XML_Char(0 ) then
+ begin
+ if enc = parser.m_encoding then
+ parser.m_eventPtr:=pointer(ATTRIBUTE_ptr(ptrcomp(parser.m_atts ) + i * sizeof(ATTRIBUTE ) )^.name );
+
+ result:=XML_ERROR_DUPLICATE_ATTRIBUTE;
+
+ exit;
+
+ end;
+
+ XML_Char_ptr(ptrcomp(attId.name ) - 1 * sizeof(XML_Char ) )^:=XML_Char(1 );
+
+ XML_Char_ptr_ptr(ptrcomp(appAtts ) + attIndex * sizeof(XML_Char_ptr ) )^:=attId.name;
+
+ inc(attIndex );
+
+ if ATTRIBUTE_ptr(ptrcomp(parser.m_atts ) + i * sizeof(ATTRIBUTE ) )^.normalized = #0 then
+ begin
+ isCdata:=XML_TRUE;
+
+ { figure out whether declared as other than CDATA }
+ if attId.maybeTokenized <> 0 then
+ begin
+ j:=0;
+
+ while j < nDefaultAtts do
+ begin
+ if attId = DEFAULT_ATTRIBUTE_ptr(ptrcomp(elementType.defaultAtts ) + j * sizeof(DEFAULT_ATTRIBUTE ) )^.id then
+ begin
+ isCdata:=DEFAULT_ATTRIBUTE_ptr(ptrcomp(elementType.defaultAtts ) + j * sizeof(DEFAULT_ATTRIBUTE ) )^.isCdata;
+
+ break;
+
+ end;
+
+ inc(j );
+
+ end;
+
+ end;
+
+ { normalize the attribute value }
+ result_:=
+ storeAttributeValue(
+ parser ,enc ,isCdata ,
+ pointer(ATTRIBUTE_ptr(ptrcomp(parser.m_atts ) + i * sizeof(ATTRIBUTE ) )^.valuePtr ) ,
+ pointer(ATTRIBUTE_ptr(ptrcomp(parser.m_atts ) + i * sizeof(ATTRIBUTE ) )^.valueEnd ) ,
+ @parser.m_tempPool );
+
+ if result_ <> XML_Error(0 ) then
+ begin
+ result:=result_;
+
+ exit;
+
+ end;
+
+ XML_Char_ptr_ptr(ptrcomp(appAtts ) + attIndex * sizeof(XML_Char_ptr ) )^:=poolStart(@parser.m_tempPool );
+
+ poolFinish(@parser.m_tempPool );
+
+ end
+ else
+ begin
+ { the value did not need normalizing }
+ XML_Char_ptr_ptr(ptrcomp(appAtts ) + attIndex * sizeof(XML_Char_ptr ) )^:=
+ poolStoreString(
+ @parser.m_tempPool ,enc ,
+ pointer(ATTRIBUTE_ptr(ptrcomp(parser.m_atts ) + i * sizeof(ATTRIBUTE ) )^.valuePtr ) ,
+ pointer(ATTRIBUTE_ptr(ptrcomp(parser.m_atts ) + i * sizeof(ATTRIBUTE ) )^.valueEnd ) );
+
+ if XML_Char_ptr_ptr(ptrcomp(appAtts ) + attIndex * sizeof(XML_Char_ptr ) )^ = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ poolFinish(@parser.m_tempPool );
+
+ end;
+
+ { handle prefixed attribute names }
+ if attId.prefix <> NIL then
+ if attId.xmlns <> 0 then
+ begin
+ { deal with namespace declarations here }
+ result_:=
+ addBinding(
+ parser ,attId.prefix ,attId ,
+ XML_Char_ptr_ptr(ptrcomp(appAtts ) + attIndex * sizeof(XML_Char_ptr ) )^ ,
+ bindingsPtr );
+
+ if result_ <> XML_Error(0 ) then
+ begin
+ result:=result_;
+
+ exit;
+
+ end;
+
+ dec(attIndex );
+
+ end
+ else
+ begin
+ { deal with other prefixed names later }
+ inc(attIndex );
+ inc(nPrefixes );
+
+ XML_Char_ptr(ptrcomp(attId.name ) - 1 * sizeof(XML_Char ) )^:=XML_Char(2 );
+
+ end
+ else
+ inc(attIndex );
+
+ inc(i );
+
+ end;
+
+{ set-up for XML_GetSpecifiedAttributeCount and XML_GetIdAttributeIndex }
+ parser.m_nSpecifiedAtts:=attIndex;
+
+ if (elementType.idAtt <> NIL ) and
+ (XML_Char_ptr(ptrcomp(elementType.idAtt.name ) - 1 * sizeof(XML_Char ) )^ <> XML_Char(0 ) ) then
+ begin
+ i:=0;
+
+ while i < attIndex do
+ begin
+ if XML_Char_ptr_ptr(ptrcomp(appAtts ) + i * sizeof(XML_Char_ptr ) )^ = elementType.idAtt.name then
+ begin
+ parser.m_idAttIndex:=i;
+
+ break;
+
+ end;
+
+ inc(i ,2 );
+
+ end;
+
+ end
+ else
+ parser.m_idAttIndex:=-1;
+
+{ do attribute defaulting }
+ i:=0;
+
+ while i < nDefaultAtts do
+ begin
+ da:=DEFAULT_ATTRIBUTE_ptr(ptrcomp(elementType.defaultAtts ) + i * sizeof(DEFAULT_ATTRIBUTE ) );
+
+ if (XML_Char_ptr(ptrcomp(da.id.name ) - 1 * sizeof(XML_Char ) )^ = XML_Char(0 ) ) and
+ (da.value <> NIL ) then
+ if da.id.prefix <> NIL then
+ if da.id.xmlns <> 0 then
+ begin
+ result_:=
+ addBinding(
+ parser ,da.id.prefix ,da.id ,
+ da.value ,bindingsPtr );
+
+ if result_ <> XML_Error(0 ) then
+ begin
+ result:=result_;
+
+ exit;
+
+ end;
+
+ end
+ else
+ begin
+ XML_Char_ptr(ptrcomp(da.id.name ) - 1 * sizeof(XML_Char ) )^:=XML_Char(2 );
+
+ inc(nPrefixes );
+
+ XML_Char_ptr_ptr(ptrcomp(appAtts ) + attIndex * sizeof(XML_Char_ptr ) )^:=da.id.name;
+
+ inc(attIndex );
+
+ XML_Char_ptr_ptr(ptrcomp(appAtts ) + attIndex * sizeof(XML_Char_ptr ) )^:=da.value;
+
+ inc(attIndex );
+
+ end
+ else
+ begin
+ XML_Char_ptr(ptrcomp(da.id.name ) - 1 * sizeof(XML_Char ) )^:=XML_Char(1 );
+
+ XML_Char_ptr_ptr(ptrcomp(appAtts ) + attIndex * sizeof(XML_Char_ptr ) )^:=da.id.name;
+
+ inc(attIndex );
+
+ XML_Char_ptr_ptr(ptrcomp(appAtts ) + attIndex * sizeof(XML_Char_ptr ) )^:=da.value;
+
+ inc(attIndex );
+
+ end;
+
+ inc(i );
+
+ end;
+
+ XML_Char_ptr_ptr(ptrcomp(appAtts ) + attIndex * sizeof(XML_Char_ptr ) )^:=NIL;
+
+{ expand prefixed attribute names, check for duplicates,
+ and clear flags that say whether attributes were specified }
+ i:=0;
+
+ if nPrefixes <> 0 then
+ begin
+ { j = hash table index }
+ version :=parser.m_nsAttsVersion;
+ nsAttsSize:=1 shl parser.m_nsAttsPower;
+
+ { size of hash table must be at least 2 * (# of prefixed attributes) }
+ if shr_int32(nPrefixes shl 1 ,parser.m_nsAttsPower ) <> 0 then{ true for nsAttsPower = 0 }
+ begin
+ { hash table size must also be a power of 2 and >= 8 }
+ while shr_int32(nPrefixes ,parser.m_nsAttsPower ) <> 0 do
+ inc(parser.m_nsAttsPower );
+
+ if parser.m_nsAttsPower < 3 then
+ parser.m_nsAttsPower:=3;
+
+ nsAttsSize:=1 shl parser.m_nsAttsPower;
+
+ if not parser.m_mem.realloc_fcn(
+ pointer(parser.m_nsAtts ) ,
+ parser.m_nsAttsAlloc ,
+ nsAttsSize * sizeof(NS_ATT ) ) then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end
+ else
+ parser.m_nsAttsAlloc:=nsAttsSize * sizeof(NS_ATT );
+
+ version:=0; { force re-initialization of nsAtts hash table }
+
+ end;
+
+ { using a version flag saves us from initializing nsAtts every time }
+ if version = 0 then { initialize version flags when version wraps around }
+ begin
+ version:=INIT_ATTS_VERSION;
+
+ j:=nsAttsSize;
+
+ while j <> 0 do
+ begin
+ dec(j );
+
+ NS_ATT_ptr(ptrcomp(parser.m_nsAtts ) + j * sizeof(NS_ATT ) )^.version:=version;
+
+ end;
+
+ end;
+
+ dec(version );
+
+ parser.m_nsAttsVersion:=version;
+
+ { expand prefixed names and check for duplicates }
+ while i < attIndex do
+ begin
+ s:=XML_Char_ptr_ptr(ptrcomp(appAtts ) + i * sizeof(XML_Char_ptr ) )^;
+
+ if XML_Char_ptr(ptrcomp(s ) - 1 * sizeof(XML_Char ) )^ = XML_Char(2 ) then { prefixed }
+ begin
+ uriHash:=0;
+
+ XML_Char_ptr(ptrcomp(s ) - 1 * sizeof(XML_Char ) )^:=XML_Char(0 ); { clear flag }
+
+ id:=ATTRIBUTE_ID_ptr(lookup(@dtd.attributeIds ,s ,0 ) );
+ b :=id.prefix.binding;
+
+ if b = NIL then
+ begin
+ result:=XML_ERROR_UNBOUND_PREFIX;
+
+ exit;
+
+ end;
+
+ { as we expand the name we also calculate its hash value }
+ j:=0;
+
+ while j < b.uriLen do
+ begin
+ c:=XML_Char_ptr(ptrcomp(b.uri ) + j * sizeof(XML_Char ) )^;
+
+ if poolAppendChar(@parser.m_tempPool ,c ) = 0 then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ uriHash:=CHAR_HASH(uriHash ,c );
+
+ inc(j );
+
+ end;
+
+ while s^ <> XML_T(':' ) do
+ inc(ptrcomp(s ) ,sizeof(XML_Char ) );
+
+ goto _w0;
+
+ while s^ <> XML_Char(0 ) do { copies null terminator }
+ begin
+ _w0:
+ c:=s^;
+
+ if poolAppendChar(@parser.m_tempPool ,s^ ) = 0 then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ uriHash:=CHAR_HASH(uriHash ,c );
+
+ inc(ptrcomp(s ) ,sizeof(XML_Char ) );
+
+ end;
+
+ { Check hash table for duplicate of expanded name (uriName).
+ Derived from code in lookup(HASH_TABLE *table, ...). }
+ step:=0;
+ mask:=nsAttsSize - 1;
+ j :=uriHash and mask; { index into hash table }
+
+ while NS_ATT_ptr(ptrcomp(parser.m_nsAtts ) + j * sizeof(NS_ATT ) )^.version = version do
+ begin
+ { for speed we compare stored hash values first }
+ if uriHash = NS_ATT_ptr(ptrcomp(parser.m_nsAtts ) + j * sizeof(NS_ATT ) )^.hash then
+ begin
+ s1:=poolStart(@parser.m_tempPool );
+ s2:=NS_ATT_ptr(ptrcomp(parser.m_nsAtts ) + j * sizeof(NS_ATT ) )^.uriName;
+
+ { s1 is null terminated, but not s2 }
+ while (s1^ = s2^ ) and
+ (s1^ <> XML_Char(0 ) ) do
+ begin
+ inc(ptrcomp(s1 ) ,sizeof(XML_Char ) );
+ inc(ptrcomp(s2 ) ,sizeof(XML_Char ) );
+
+ end;
+
+ if s1^ = XML_Char(0 ) then
+ begin
+ result:=XML_ERROR_DUPLICATE_ATTRIBUTE;
+
+ exit;
+
+ end;
+
+ end;
+
+ if step = 0 then
+ step:=PROBE_STEP(uriHash ,mask ,parser.m_nsAttsPower );
+
+ if j < step then
+ inc(j ,nsAttsSize - step )
+ else
+ dec(j ,step );
+
+ end;
+
+ if parser.m_ns_triplets <> 0 then { append namespace separator and prefix }
+ begin
+ XML_Char_ptr(ptrcomp(parser.m_tempPool.ptr ) - 1 * sizeof(XML_Char ) )^:=parser.m_namespaceSeparator;
+
+ s:=b.prefix.name;
+
+ goto _w1;
+
+ while s^ <> XML_Char(0 ) do
+ begin
+ _w1:
+ if poolAppendChar(@parser.m_tempPool ,s^ ) = 0 then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(s ) ,sizeof(XML_Char ) );
+
+ end;
+
+ end;
+
+ { store expanded name in attribute list }
+ s:=poolStart(@parser.m_tempPool );
+
+ poolFinish(@parser.m_tempPool );
+
+ XML_Char_ptr_ptr(ptrcomp(appAtts ) + i * sizeof(XML_Char_ptr ) )^:=s;
+
+ { fill empty slot with new version, uriName and hash value }
+ NS_ATT_ptr(ptrcomp(parser.m_nsAtts ) + j * sizeof(NS_ATT ) )^.version:=version;
+ NS_ATT_ptr(ptrcomp(parser.m_nsAtts ) + j * sizeof(NS_ATT ) )^.hash :=uriHash;
+ NS_ATT_ptr(ptrcomp(parser.m_nsAtts ) + j * sizeof(NS_ATT ) )^.uriName:=s;
+
+ dec(nPrefixes );
+
+ if nPrefixes = 0 then
+ begin
+ inc(i ,2 );
+
+ break;
+
+ end;
+
+ end
+ else { not prefixed }
+ XML_Char_ptr(ptrcomp(s ) - 1 * sizeof(XML_Char ) )^:=XML_Char(0 ); { clear flag }
+
+ inc(i ,2 );
+
+ end;
+
+ end;
+
+{ clear flags for the remaining attributes }
+ while i < attIndex do
+ begin
+ XML_Char_ptr(
+ ptrcomp(
+ XML_Char_ptr_ptr(ptrcomp(appAtts ) + i * sizeof(XML_Char_ptr ) )^ )
+ - 1 * sizeof(XML_Char ) )^:=XML_Char(0 );
+
+ inc(i ,2 );
+
+ end;
+
+ binding:=bindingsPtr^;
+
+ while binding <> NIL do
+ begin
+ XML_Char_ptr(ptrcomp(binding.attId.name ) - 1 * sizeof(XML_Char ) )^:=XML_Char(0 );
+
+ binding:=binding.nextTagBinding;
+
+ end;
+
+ if parser.m_ns = 0 then
+ begin
+ result:=XML_ERROR_NONE;
+
+ exit;
+
+ end;
+
+{ expand the element type name }
+ if elementType.prefix <> NIL then
+ begin
+ binding:=elementType.prefix.binding;
+
+ if binding = NIL then
+ begin
+ result:=XML_ERROR_UNBOUND_PREFIX;
+
+ exit;
+
+ end;
+
+ localPart:=tagNamePtr.str;
+
+ while localPart^ <> XML_T(':' ) do
+ inc(ptrcomp(localPart ) ,sizeof(XML_Char ) );
+
+ end
+ else
+ if dtd.defaultPrefix.binding <> NIL then
+ begin
+ binding :=dtd.defaultPrefix.binding;
+ localPart:=tagNamePtr.str;
+
+ end
+ else
+ begin
+ result:=XML_ERROR_NONE;
+
+ exit;
+
+ end;
+
+ prefixLen:=0;
+
+ if (parser.m_ns_triplets <> 0 ) and
+ (binding.prefix.name <> NIL ) then
+ begin
+ while XML_Char_ptr(ptrcomp(binding.prefix.name ) + prefixLen * sizeof(XML_Char ) )^ <> XML_Char(0 ) do
+ inc(prefixLen );
+
+ inc(prefixLen ); { prefixLen includes null terminator }
+
+ end;
+
+ tagNamePtr.localPart:=localPart;
+ tagNamePtr.uriLen :=binding.uriLen;
+ tagNamePtr.prefix :=binding.prefix.name;
+ tagNamePtr.prefixLen:=prefixLen;
+
+ i:=0;
+
+ while XML_Char_ptr(ptrcomp(localPart ) + i * sizeof(XML_Char ) )^ <> XML_Char(0 ) do
+ inc(i );
+
+ inc(i ); { i includes null terminator }
+
+ n:=i + binding.uriLen + prefixLen;
+
+ if n > binding.uriAlloc then
+ begin
+ parser.m_mem.malloc_fcn(pointer(uri ) ,(n + EXPAND_SPARE ) * sizeof(XML_Char ) );
+
+ if uri = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ j:=binding.uriAlloc;
+
+ binding.uriAlloc:=n + EXPAND_SPARE;
+
+ move(
+ binding.uri^ ,
+ uri^ ,
+ binding.uriLen * sizeof(XML_Char ) );
+
+ p:=parser.m_tagStack;
+
+ while p <> NIL do
+ begin
+ if p.name.str = binding.uri then
+ p.name.str:=uri;
+
+ p:=p.parent;
+
+ end;
+
+ parser.m_mem.free_fcn(pointer(binding.uri ) ,j * sizeof(XML_Char ) );
+
+ binding.uri:=uri;
+
+ end;
+
+{ if namespaceSeparator != '\0' then uri includes it already }
+ uri:=XML_Char_ptr(ptrcomp(binding.uri ) + binding.uriLen * sizeof(XML_Char ) );
+
+ move(
+ localPart^ ,
+ uri^ ,
+ i * sizeof(XML_Char ) );
+
+{ we always have a namespace separator between localPart and prefix }
+ if prefixLen <> 0 then
+ begin
+ inc(ptrcomp(uri ) ,(i - 1 ) * sizeof(XML_Char ) );
+
+ uri^:=parser.m_namespaceSeparator; { replace null terminator }
+
+ move(
+ binding.prefix.name^ ,
+ XML_Char_ptr(ptrcomp(uri ) + 1 * sizeof(XML_Char ) )^ ,
+ prefixLen * sizeof(XML_Char ) );
+
+ end;
+
+ tagNamePtr.str:=binding.uri;
+
+ result:=XML_ERROR_NONE;
+
+end;
+
+{ processInternalEntity {..}
+function processInternalEntity(parser : XML_Parser; entity : ENTITY_ptr; betweenDecl : XML_Bool ) : XML_Error;
+begin
+end;
+
+{ epilogProcessor }
+function epilogProcessor(parser : XML_Parser; s ,end_ : char_ptr; nextPtr : char_ptr_ptr ) : XML_Error;
+var
+ next : char_ptr;
+
+ tok : int;
+
+begin
+ parser.m_processor:=@epilogProcessor;
+ parser.m_eventPtr :=s;
+
+ repeat
+ next:=NIL;
+ tok :=XmlPrologTok(parser.m_encoding ,pointer(s ) ,pointer(end_ ) ,@next );
+
+ parser.m_eventEndPtr:=next;
+
+ case tok of
+ -XML_TOK_PROLOG_S :
+ begin
+ if @parser.m_defaultHandler <> NIL then
+ begin
+ reportDefault(parser ,parser.m_encoding ,s ,next );
+
+ if parser.m_parsingStatus.parsing = XML_FINISHED then
+ begin
+ result:=XML_ERROR_ABORTED;
+
+ exit;
+
+ end;
+
+ end;
+
+ nextPtr^:=next;
+ result :=XML_ERROR_NONE;
+
+ exit;
+
+ end;
+
+ XML_TOK_NONE :
+ begin
+ nextPtr^:=s;
+ result :=XML_ERROR_NONE;
+
+ exit;
+
+ end;
+
+ XML_TOK_PROLOG_S :
+ if @parser.m_defaultHandler <> NIL then
+ reportDefault(parser ,parser.m_encoding ,s ,next );
+
+ XML_TOK_PI :
+ if reportProcessingInstruction(parser ,parser.m_encoding ,s ,next ) = 0 then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ XML_TOK_COMMENT :
+ if reportComment(parser ,parser.m_encoding ,s ,next ) = 0 then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ XML_TOK_INVALID :
+ begin
+ parser.m_eventPtr:=next;
+
+ result:=XML_ERROR_INVALID_TOKEN;
+
+ exit;
+
+ end;
+
+ XML_TOK_PARTIAL :
+ begin
+ if parser.m_parsingStatus.finalBuffer = 0 then
+ begin
+ nextPtr^:=s;
+ result :=XML_ERROR_NONE;
+
+ exit;
+
+ end;
+
+ result:=XML_ERROR_UNCLOSED_TOKEN;
+
+ exit;
+
+ end;
+
+ XML_TOK_PARTIAL_CHAR :
+ begin
+ if parser.m_parsingStatus.finalBuffer = 0 then
+ begin
+ nextPtr^:=s;
+ result :=XML_ERROR_NONE;
+
+ exit;
+
+ end;
+
+ result:=XML_ERROR_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ else
+ begin
+ result:=XML_ERROR_JUNK_AFTER_DOC_ELEMENT;
+
+ exit;
+
+ end;
+
+ end;
+
+ parser.m_eventPtr:=next;
+
+ s:=next;
+
+ case parser.m_parsingStatus.parsing of
+ XML_SUSPENDED :
+ begin
+ nextPtr^:=next;
+ result :=XML_ERROR_NONE;
+
+ exit;
+
+ end;
+
+ XML_FINISHED :
+ begin
+ result:=XML_ERROR_ABORTED;
+
+ exit;
+
+ end;
+
+ end;
+
+ until false;
+
+end;
+
+{ doCdataSection {..}
+{ startPtr gets set to non-null if the section is closed, and to null if
+ the section is not yet closed. }
+function doCdataSection(
+ parser : XML_Parser;
+ enc : ENCODING_ptr;
+ startPtr : char_ptr_ptr;
+ end_ : char_ptr;
+ nextPtr : char_ptr_ptr;
+ haveMore : XML_Bool ) : XML_Error;
+begin
+end;
+
+{ cdataSectionProcessor {..}
+{ The idea here is to avoid using stack for each CDATA section when
+ the whole file is parsed with one call. }
+function cdataSectionProcessor(parser : XML_Parser; start ,end_ : char_ptr; endPtr : char_ptr_ptr ) : XML_Error;
+begin
+end;
+
+{ doContent }
+function doContent(
+ parser : XML_Parser;
+ startTagLevel : int;
+ enc : ENCODING_ptr;
+ s ,end_ : char_ptr;
+ nextPtr : char_ptr_ptr;
+ haveMore : XML_Bool ) : XML_Error;
+var
+ dtd : DTD_ptr;
+
+ eventPP ,eventEndPP : char_ptr_ptr;
+
+ next ,rawNameEnd ,fromPtr ,temp ,rawName : char_ptr;
+
+ tok ,bufSize ,convLen ,len ,n : int;
+
+ c ,ch : XML_Char;
+
+ name ,context ,toPtr ,localPart ,prefix ,uri : XML_Char_ptr;
+
+ entity : ENTITY_ptr;
+
+ result_ : XML_Error;
+
+ tag : TAG_ptr;
+
+ bindings ,b : BINDING_ptr;
+
+ noElmHandlers : XML_Bool;
+
+ name_ : TAG_NAME;
+
+ buf : array[0..XML_ENCODE_MAX - 1 ] of XML_Char;
+
+ dataPtr : ICHAR_ptr;
+
+label
+ _break ;
+
+begin
+{ save one level of indirection }
+ dtd:=parser.m_dtd;
+
+ if enc = parser.m_encoding then
+ begin
+ eventPP :=@parser.m_eventPtr;
+ eventEndPP:=@parser.m_eventEndPtr;
+
+ end
+ else
+ begin
+ eventPP :=@parser.m_openInternalEntities.internalEventPtr;
+ eventEndPP:=@parser.m_openInternalEntities.internalEventEndPtr;
+
+ end;
+
+ eventPP^:=s;
+
+ repeat
+ next:=s; { XmlContentTok doesn't always set the last arg }
+
+ tok:=XmlContentTok(enc ,pointer(s ) ,pointer(end_ ) ,@next );
+
+ eventEndPP^:=next;
+
+ case tok of
+ XML_TOK_TRAILING_CR :
+ begin
+ if haveMore <> 0 then
+ begin
+ nextPtr^:=s;
+ result :=XML_ERROR_NONE;
+
+ exit;
+
+ end;
+
+ eventEndPP^:=end_;
+
+ if @parser.m_characterDataHandler <> NIL then
+ begin
+ c:=XML_Char($A );
+
+ parser.m_characterDataHandler(parser.m_handlerArg ,@c ,1 );
+
+ end
+ else
+ if @parser.m_defaultHandler <> NIL then
+ reportDefault(parser ,enc ,s ,end_ );
+
+ { We are at the end of the final buffer, should we check for
+ XML_SUSPENDED, XML_FINISHED? }
+ if startTagLevel = 0 then
+ begin
+ result:=XML_ERROR_NO_ELEMENTS;
+
+ exit;
+
+ end;
+
+ if parser.m_tagLevel <> startTagLevel then
+ begin
+ result:=XML_ERROR_ASYNC_ENTITY;
+
+ exit;
+
+ end;
+
+ nextPtr^:=end_;
+ result :=XML_ERROR_NONE;
+
+ exit;
+
+ end;
+
+ XML_TOK_NONE :
+ begin
+ if haveMore <> 0 then
+ begin
+ nextPtr^:=s;
+ result :=XML_ERROR_NONE;
+
+ exit;
+
+ end;
+
+ if startTagLevel > 0 then
+ begin
+ if parser.m_tagLevel <> startTagLevel then
+ begin
+ result:=XML_ERROR_ASYNC_ENTITY;
+
+ exit;
+
+ end;
+
+ nextPtr^:=s;
+ result :=XML_ERROR_NONE;
+
+ exit;
+
+ end;
+
+ result:=XML_ERROR_NO_ELEMENTS;
+
+ exit;
+
+ end;
+
+ XML_TOK_INVALID :
+ begin
+ eventPP^:=next;
+ result :=XML_ERROR_INVALID_TOKEN;
+
+ exit;
+
+ end;
+
+ XML_TOK_PARTIAL :
+ begin
+ if haveMore <> 0 then
+ begin
+ nextPtr^:=s;
+ result :=XML_ERROR_NONE;
+
+ exit;
+
+ end;
+
+ result:=XML_ERROR_UNCLOSED_TOKEN;
+
+ exit;
+
+ end;
+
+ XML_TOK_PARTIAL_CHAR :
+ begin
+ if haveMore <> 0 then
+ begin
+ nextPtr^:=s;
+ result :=XML_ERROR_NONE;
+
+ exit;
+
+ end;
+
+ result:=XML_ERROR_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ XML_TOK_ENTITY_REF :
+ begin
+ ch:=
+ XML_Char(XmlPredefinedEntityName(
+ enc ,
+ pointer(ptrcomp(s ) + enc.minBytesPerChar ) ,
+ pointer(ptrcomp(next ) - enc.minBytesPerChar ) ) );
+
+ if ch <> XML_Char(0 ) then
+ begin
+ if @parser.m_characterDataHandler <> NIL then
+ parser.m_characterDataHandler(parser.m_handlerArg ,@ch ,1 )
+ else
+ if @parser.m_defaultHandler <> NIL then
+ reportDefault(parser ,enc ,s ,next );
+
+ goto _break;
+
+ end;
+
+ name:=
+ poolStoreString(
+ @dtd.pool ,enc ,
+ char_ptr(ptrcomp(s ) + enc.minBytesPerChar ) ,
+ char_ptr(ptrcomp(next ) - enc.minBytesPerChar ) );
+
+ if name = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ entity:=ENTITY_ptr(lookup(@dtd.generalEntities ,name ,0 ) );
+
+ poolDiscard(@dtd.pool );
+
+ { First, determine if a check for an existing declaration is needed;
+ if yes, check that the entity exists, and that it is internal,
+ otherwise call the skipped entity or default handler. }
+ if (dtd.hasParamEntityRefs = 0 ) or
+ (dtd.standalone <> 0 ) then
+ if entity = NIL then
+ begin
+ result:=XML_ERROR_UNDEFINED_ENTITY;
+
+ exit;
+
+ end
+ else
+ if entity.is_internal = 0 then
+ begin
+ result:=XML_ERROR_ENTITY_DECLARED_IN_PE;
+
+ exit;
+
+ end
+ else
+ else
+ if entity = NIL then
+ begin
+ if @parser.m_skippedEntityHandler <> NIL then
+ parser.m_skippedEntityHandler(parser.m_handlerArg ,name ,0 )
+ else
+ if @parser.m_defaultHandler <> NIL then
+ reportDefault(parser ,enc ,s ,next );
+
+ goto _break;
+
+ end;
+
+ if entity.open <> 0 then
+ begin
+ result:=XML_ERROR_RECURSIVE_ENTITY_REF;
+
+ exit;
+
+ end;
+
+ if entity.notation <> NIL then
+ begin
+ result:=XML_ERROR_BINARY_ENTITY_REF;
+
+ exit;
+
+ end;
+
+ if entity.textPtr <> NIL then
+ begin
+ if parser.m_defaultExpandInternalEntities <> 0 then
+ begin
+ if @parser.m_skippedEntityHandler <> NIL then
+ parser.m_skippedEntityHandler(parser.m_handlerArg ,entity.name ,0 )
+ else
+ if @parser.m_defaultHandler <> NIL then
+ reportDefault(parser ,enc ,s ,next );
+
+ goto _break;
+
+ end;
+
+ result_:=processInternalEntity(parser ,entity ,XML_FALSE );
+
+ if result_ <> XML_ERROR_NONE then
+ begin
+ result:=result_;
+
+ exit;
+
+ end;
+
+ end
+ else
+ if @parser.m_externalEntityRefHandler <> NIL then
+ begin
+ entity.open:=XML_TRUE;
+ context :=getContext(parser );
+ entity.open:=XML_FALSE;
+
+ if context = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ if parser.m_externalEntityRefHandler(
+ parser.m_externalEntityRefHandlerArg ,
+ context ,
+ entity.base ,
+ entity.systemId ,
+ entity.publicId ) = 0 then
+ begin
+ result:=XML_ERROR_EXTERNAL_ENTITY_HANDLING;
+
+ exit;
+
+ end;
+
+ poolDiscard(@parser.m_tempPool );
+
+ end
+ else
+ if @parser.m_defaultHandler <> NIL then
+ reportDefault(parser ,enc ,s ,next );
+
+ end;
+
+ XML_TOK_START_TAG_NO_ATTS ,XML_TOK_START_TAG_WITH_ATTS :
+ begin
+ if parser.m_freeTagList <> NIL then
+ begin
+ tag:=parser.m_freeTagList;
+
+ parser.m_freeTagList:=parser.m_freeTagList.parent;
+
+ end
+ else
+ begin
+ parser.m_mem.malloc_fcn(pointer(tag ) ,sizeof(expat.TAG ) );
+
+ if tag = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ parser.m_mem.malloc_fcn(pointer(tag.buf ) ,INIT_TAG_BUF_SIZE );
+
+ if tag.buf = NIL then
+ begin
+ parser.m_mem.free_fcn(pointer(tag ) ,sizeof(expat.TAG ) );
+
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end
+ else
+ tag.alloc:=INIT_TAG_BUF_SIZE;
+
+ tag.bufEnd:=char_ptr(ptrcomp(tag.buf ) + INIT_TAG_BUF_SIZE );
+
+ end;
+
+ tag.bindings :=NIL;
+ tag.parent :=parser.m_tagStack;
+ parser.m_tagStack :=tag;
+ tag.name.localPart:=NIL;
+ tag.name.prefix :=NIL;
+ tag.rawName :=char_ptr(ptrcomp(s ) + enc.minBytesPerChar );
+ tag.rawNameLength :=XmlNameLength(enc ,pointer(tag.rawName ) );
+
+ inc(parser.m_tagLevel );
+
+ rawNameEnd:=char_ptr(ptrcomp(tag.rawName ) + tag.rawNameLength );
+ fromPtr :=tag.rawName;
+ toPtr :=XML_Char_ptr(tag.buf );
+
+ repeat
+ XmlConvert(
+ enc ,
+ @fromPtr ,rawNameEnd ,
+ ICHAR_ptr_ptr(@toPtr ) ,ICHAR_ptr(ptrcomp(tag.bufEnd ) - 1 ) );
+
+ convLen:=(ptrcomp(toPtr ) - ptrcomp(tag.buf ) ) div sizeof(XML_Char );
+
+ if fromPtr = rawNameEnd then
+ begin
+ tag.name.strLen:=convLen;
+
+ break;
+
+ end;
+
+ bufSize:=(ptrcomp(tag.bufEnd ) - ptrcomp(tag.buf ) ) shl 1;
+
+ parser.m_mem.realloc_fcn(pointer(tag.buf ) ,tag.alloc ,bufSize );
+
+ if temp = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end
+ else
+ tag.alloc:=bufSize;
+
+ tag.buf :=temp;
+ tag.bufEnd:=char_ptr(ptrcomp(temp ) + bufSize );
+
+ toPtr:=XML_Char_ptr(ptrcomp(temp ) + convLen );
+
+ until false;
+
+ tag.name.str:=XML_Char_ptr(tag.buf );
+
+ toPtr^ :=XML_T(#0 );
+ result_:=storeAtts(parser ,enc ,s ,@tag.name ,@tag.bindings );
+
+ if result_ <> XML_Error(0 ) then
+ begin
+ result:=result_;
+
+ exit;
+
+ end;
+
+ if @parser.m_startElementHandler <> NIL then
+ parser.m_startElementHandler(
+ parser.m_handlerArg ,tag.name.str ,
+ XML_Char_ptr_ptr(parser.m_atts ) )
+ else
+ if @parser.m_defaultHandler <> NIL then
+ reportDefault(parser ,enc ,s ,next );
+
+ poolClear(@parser.m_tempPool );
+
+ end;
+
+ XML_TOK_EMPTY_ELEMENT_NO_ATTS ,XML_TOK_EMPTY_ELEMENT_WITH_ATTS :
+ begin
+ rawName :=char_ptr(ptrcomp(s ) + enc.minBytesPerChar );
+ bindings :=NIL;
+ noElmHandlers:=XML_TRUE;
+
+ name_.str:=
+ poolStoreString(
+ @parser.m_tempPool ,enc ,rawName ,
+ char_ptr(ptrcomp(rawName ) + XmlNameLength(enc ,pointer(rawName ) ) ) );
+
+ if name_.str = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ poolFinish(@parser.m_tempPool );
+
+ result_:=storeAtts(parser ,enc ,s ,@name_ ,@bindings );
+
+ if result_ <> XML_Error(0 ) then
+ begin
+ result:=result_;
+
+ exit;
+
+ end;
+
+ poolFinish(@parser.m_tempPool );
+
+ if @parser.m_startElementHandler <> NIL then
+ begin
+ parser.m_startElementHandler(
+ parser.m_handlerArg ,name_.str ,XML_Char_ptr_ptr(parser.m_atts ) );
+
+ noElmHandlers:=XML_FALSE;
+
+ end;
+
+ if @parser.m_endElementHandler <> NIL then
+ begin
+ if @parser.m_startElementHandler <> NIL then
+ eventPP^:=eventEndPP^;
+
+ parser.m_endElementHandler(parser.m_handlerArg ,name_.str );
+
+ noElmHandlers:=XML_FALSE;
+
+ end;
+
+ if (noElmHandlers <> 0 ) and
+ (@parser.m_defaultHandler <> NIL ) then
+ reportDefault(parser ,enc ,s ,next );
+
+ poolClear(@parser.m_tempPool );
+
+ while bindings <> NIL do
+ begin
+ b:=bindings;
+
+ if @parser.m_endNamespaceDeclHandler <> NIL then
+ parser.m_endNamespaceDeclHandler(parser.m_handlerArg ,b.prefix.name );
+
+ bindings :=bindings.nextTagBinding;
+ b.nextTagBinding:=parser.m_freeBindingList;
+
+ parser.m_freeBindingList:=b;
+ b.prefix.binding :=b.prevPrefixBinding;
+
+ end;
+
+ if parser.m_tagLevel = 0 then
+ begin
+ result:=epilogProcessor(parser ,next ,end_ ,nextPtr );
+
+ exit;
+
+ end;
+
+ end;
+
+ XML_TOK_END_TAG :
+ if parser.m_tagLevel = startTagLevel then
+ begin
+ result:=XML_ERROR_ASYNC_ENTITY;
+
+ exit;
+
+ end
+ else
+ begin
+ tag :=parser.m_tagStack;
+ parser.m_tagStack :=tag.parent;
+ tag.parent :=parser.m_freeTagList;
+ parser.m_freeTagList:=tag;
+
+ rawName:=char_ptr(ptrcomp(s ) + enc.minBytesPerChar * 2 );
+ len :=XmlNameLength(enc ,pointer(rawName ) );
+
+ if (len <> tag.rawNameLength ) or
+ (memcmp(pointer(tag.rawName ) ,pointer(rawName ) ,len ) <> 0 ) then
+ begin
+ eventPP^:=rawName;
+ result :=XML_ERROR_TAG_MISMATCH;
+
+ exit;
+
+ end;
+
+ dec(parser.m_tagLevel );
+
+ if @parser.m_endElementHandler <> NIL then
+ begin
+ localPart:=tag.name.localPart;
+
+ if (parser.m_ns <> 0 ) and
+ (localPart <> NIL ) then
+ begin
+ { localPart and prefix may have been overwritten in
+ tag->name.str, since this points to the binding->uri
+ buffer which gets re-used; so we have to add them again }
+ uri:=XML_Char_ptr(ptrcomp(tag.name.str ) + tag.name.uriLen );
+
+ { don't need to check for space - already done in storeAtts() }
+ while localPart^ <> XML_Char(0 ) do
+ begin
+ uri^:=localPart^;
+
+ inc(ptrcomp(uri ) ,sizeof(XML_Char ) );
+ inc(ptrcomp(localPart ) ,sizeof(XML_Char ) );
+
+ end;
+
+ prefix:=XML_Char_ptr(tag.name.prefix );
+
+ if (parser.m_ns_triplets <> 0 ) and
+ (prefix <> NIL ) then
+ begin
+ uri^:=parser.m_namespaceSeparator;
+
+ inc(ptrcomp(uri ) ,sizeof(XML_Char ) );
+
+ while prefix^ <> XML_Char(0 ) do
+ begin
+ uri^:=prefix^;
+
+ inc(ptrcomp(uri ) ,sizeof(XML_Char ) );
+ inc(ptrcomp(prefix ) ,sizeof(XML_Char ) );
+
+ end;
+
+ end;
+
+ uri^:=XML_T(#0 );
+
+ end;
+
+ parser.m_endElementHandler(parser.m_handlerArg ,tag.name.str );
+
+ end
+ else
+ if @parser.m_defaultHandler <> NIL then
+ reportDefault(parser ,enc ,s ,next );
+
+ while tag.bindings <> NIL do
+ begin
+ b:=tag.bindings;
+
+ if @parser.m_endNamespaceDeclHandler <> NIL then
+ parser.m_endNamespaceDeclHandler(parser.m_handlerArg ,b.prefix.name );
+
+ tag.bindings :=tag.bindings.nextTagBinding;
+ b.nextTagBinding :=parser.m_freeBindingList;
+ parser.m_freeBindingList:=b;
+ b.prefix.binding :=b.prevPrefixBinding;
+
+ end;
+
+ if parser.m_tagLevel = 0 then
+ begin
+ result:=epilogProcessor(parser ,next ,end_ ,nextPtr );
+
+ exit;
+
+ end;
+
+ end;
+
+ XML_TOK_CHAR_REF :
+ begin
+ n:=XmlCharRefNumber(enc ,pointer(s ) );
+
+ if n < 0 then
+ begin
+ result:=XML_ERROR_BAD_CHAR_REF;
+
+ exit;
+
+ end;
+
+ if @parser.m_characterDataHandler <> NIL then
+ parser.m_characterDataHandler(
+ parser.m_handlerArg ,@buf[0 ] ,
+ XmlEncode(n ,ICHAR_ptr(@buf ) ) )
+ else
+ if @parser.m_defaultHandler <> NIL then
+ reportDefault(parser ,enc ,s ,next );
+
+ end;
+
+ XML_TOK_XML_DECL :
+ begin
+ result:=XML_ERROR_MISPLACED_XML_PI;
+
+ exit;
+
+ end;
+
+ XML_TOK_DATA_NEWLINE :
+ if @parser.m_characterDataHandler <> NIL then
+ begin
+ c:=XML_Char($A );
+
+ parser.m_characterDataHandler(parser.m_handlerArg ,@c ,1 );
+
+ end
+ else
+ if @parser.m_defaultHandler <> NIL then
+ reportDefault(parser ,enc ,s ,next );
+
+ XML_TOK_CDATA_SECT_OPEN :
+ begin
+ if @parser.m_startCdataSectionHandler <> NIL then
+ parser.m_startCdataSectionHandler(parser.m_handlerArg )
+ {$IFDEF 0 }
+ { Suppose you doing a transformation on a document that involves
+ changing only the character data. You set up a defaultHandler
+ and a characterDataHandler. The defaultHandler simply copies
+ characters through. The characterDataHandler does the
+ transformation and writes the characters out escaping them as
+ necessary. This case will fail to work if we leave out the
+ following two lines (because & and < inside CDATA sections will
+ be incorrectly escaped).
+
+ However, now we have a start/endCdataSectionHandler, so it seems
+ easier to let the user deal with this. }
+ else
+ if @parser.m_characterDataHandler <> NIL then
+ parser.m_characterDataHandler(parser.m_handlerArg ,parser.m_dataBuf ,0 )
+ {$ENDIF }
+ else
+ if @parser.m_defaultHandler <> NIL then
+ reportDefault(parser ,enc ,s ,next );
+
+ result_:=doCdataSection(parser ,enc ,@next ,end_ ,nextPtr ,haveMore );
+
+ if result_ <> XML_ERROR_NONE then
+ begin
+ result:=result_;
+
+ exit;
+
+ end
+ else
+ if next = NIL then
+ begin
+ parser.m_processor:=@cdataSectionProcessor;
+
+ result:=result_;
+
+ exit;
+
+ end;
+
+ end;
+
+ XML_TOK_TRAILING_RSQB :
+ begin
+ if haveMore <> 0 then
+ begin
+ nextPtr^:=s;
+ result :=XML_ERROR_NONE;
+
+ exit;
+
+ end;
+
+ if @parser.m_characterDataHandler <> NIL then
+ if MUST_CONVERT(enc ,s ) <> 0 then
+ begin
+ dataPtr:=ICHAR_ptr(parser.m_dataBuf );
+
+ XmlConvert(enc ,@s ,end_ ,@dataPtr ,ICHAR_ptr(parser.m_dataBufEnd ) );
+
+ parser.m_characterDataHandler(
+ parser.m_handlerArg ,
+ parser.m_dataBuf ,
+ (ptrcomp(dataPtr ) - ptrcomp(parser.m_dataBuf ) ) div sizeof(ICHAR ) );
+
+ end
+ else
+ parser.m_characterDataHandler(
+ parser.m_handlerArg ,
+ XML_Char_ptr(s ) ,
+ (ptrcomp(end_ ) - ptrcomp(s ) ) div sizeof(XML_Char ) )
+ else
+ if @parser.m_defaultHandler <> NIL then
+ reportDefault(parser ,enc ,s ,end_ );
+
+ { We are at the end of the final buffer, should we check for
+ XML_SUSPENDED, XML_FINISHED? }
+ if startTagLevel = 0 then
+ begin
+ eventPP^:=end_;
+ result :=XML_ERROR_NO_ELEMENTS;
+
+ exit;
+
+ end;
+
+ if parser.m_tagLevel <> startTagLevel then
+ begin
+ eventPP^:=end_;
+ result :=XML_ERROR_ASYNC_ENTITY;
+
+ exit;
+
+ end;
+
+ nextPtr^:=end_;
+ result :=XML_ERROR_NONE;
+
+ exit;
+
+ end;
+
+ XML_TOK_DATA_CHARS :
+ if @parser.m_characterDataHandler <> NIL then
+ if MUST_CONVERT(enc ,s ) <> 0 then
+ repeat
+ dataPtr:=ICHAR_ptr(parser.m_dataBuf );
+
+ XmlConvert(enc ,@s ,next ,@dataPtr ,ICHAR_ptr(parser.m_dataBufEnd ) );
+
+ eventEndPP^:=s;
+
+ parser.m_characterDataHandler(
+ parser.m_handlerArg ,
+ parser.m_dataBuf ,
+ (ptrcomp(dataPtr ) - ptrcomp(parser.m_dataBuf ) ) div sizeof(ICHAR ) );
+
+ if s = next then
+ break;
+
+ eventPP^:=s;
+
+ until false
+ else
+ parser.m_characterDataHandler(
+ parser.m_handlerArg ,
+ XML_Char_ptr(s ) ,
+ (ptrcomp(next ) - ptrcomp(s ) ) div sizeof(XML_Char ) )
+
+ else
+ if @parser.m_defaultHandler <> NIL then
+ reportDefault(parser ,enc ,s ,next );
+
+ XML_TOK_PI :
+ if reportProcessingInstruction(parser ,enc ,s ,next ) = 0 then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ XML_TOK_COMMENT :
+ if reportComment(parser ,enc ,s ,next ) = 0 then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ else
+ if @parser.m_defaultHandler <> NIL then
+ reportDefault(parser ,enc ,s ,next );
+
+ end;
+
+ _break:
+ eventPP^:=next;
+ s :=next;
+
+ case parser.m_parsingStatus.parsing of
+ XML_SUSPENDED:
+ begin
+ nextPtr^:=next;
+ result :=XML_ERROR_NONE;
+
+ exit;
+
+ end;
+
+ XML_FINISHED:
+ begin
+ result:=XML_ERROR_ABORTED;
+
+ exit;
+
+ end;
+
+ end;
+
+ until false;
+
+{ not reached }
+
+end;
+
+{ contentProcessor }
+function contentProcessor(parser : XML_Parser; start ,end_ : char_ptr; endPtr : char_ptr_ptr ) : XML_Error;
+var
+ result_ : XML_Error;
+
+begin
+ result_:=
+ doContent(
+ parser ,0 ,parser.m_encoding ,start ,end_ ,
+ endPtr ,XML_Bool(not parser.m_parsingStatus.finalBuffer ) );
+
+ if result_ = XML_ERROR_NONE then
+ if storeRawNames(parser ) = 0 then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ result:=result_;
+
+end;
+
+{ getElementType {..}
+function getElementType(parser : XML_Parser; enc : ENCODING_ptr; ptr ,end_ : char_ptr ) : ELEMENT_TYPE_ptr;
+begin
+end;
+
+{ getAttributeId }
+function getAttributeId(parser : XML_Parser; enc : ENCODING_ptr; start ,end_ : char_ptr ) : ATTRIBUTE_ID_ptr;
+var
+ dtd : DTD_ptr;
+
+ id : ATTRIBUTE_ID_ptr;
+
+ name : XML_Char_ptr;
+
+ i ,j : int;
+
+begin
+{ save one level of indirection }
+ dtd:=parser.m_dtd;
+
+ if poolAppendChar(@dtd.pool ,XML_T(#0 ) ) = 0 then
+ begin
+ result:=NIL;
+
+ exit;
+
+ end;
+
+ name:=poolStoreString(@dtd.pool ,enc ,start ,end_ );
+
+ if name = NIL then
+ begin
+ result:=NIL;
+
+ exit;
+
+ end;
+
+{ skip quotation mark - its storage will be re-used (like in name[-1]) }
+ inc(ptrcomp(name ) ,sizeof(XML_Char ) );
+
+ id:=ATTRIBUTE_ID_ptr(lookup(@dtd.attributeIds ,name ,sizeof(ATTRIBUTE_ID ) ) );
+
+ if id = NIL then
+ begin
+ result:=NIL;
+
+ exit;
+
+ end;
+
+ if id.name <> name then
+ poolDiscard(@dtd.pool )
+
+ else
+ begin
+ poolFinish(@dtd.pool );
+
+ if parser.m_ns = 0 then
+ else
+ if (XML_Char_ptr(ptrcomp(name ) + 0 * sizeof(XML_Char ) )^ = XML_T('x' ) ) and
+ (XML_Char_ptr(ptrcomp(name ) + 1 * sizeof(XML_Char ) )^ = XML_T('m' ) ) and
+ (XML_Char_ptr(ptrcomp(name ) + 2 * sizeof(XML_Char ) )^ = XML_T('l' ) ) and
+ (XML_Char_ptr(ptrcomp(name ) + 3 * sizeof(XML_Char ) )^ = XML_T('n' ) ) and
+ (XML_Char_ptr(ptrcomp(name ) + 4 * sizeof(XML_Char ) )^ = XML_T('s' ) ) and
+ ((XML_Char_ptr(ptrcomp(name ) + 5 * sizeof(XML_Char ) )^ = XML_T(#0 ) ) or
+ (XML_Char_ptr(ptrcomp(name ) + 5 * sizeof(XML_Char ) )^ = XML_T(':' ) ) ) then
+ begin
+ if XML_Char_ptr(ptrcomp(name ) + 5 * sizeof(XML_Char ) )^ = XML_T(#0 ) then
+ id.prefix:=@dtd.defaultPrefix
+ else
+ id.prefix:=PREFIX_ptr(lookup(@dtd.prefixes ,XML_Char_ptr(ptrcomp(name ) + 6 * sizeof(XML_Char ) ) ,sizeof(PREFIX ) ) );
+
+ id.xmlns:=XML_TRUE;
+
+ end
+ else
+ begin
+ i:=0;
+
+ while XML_Char_ptr(ptrcomp(name ) + i * sizeof(XML_Char ) )^ <> XML_Char(0 ) do
+ begin
+ { attributes without prefix are *not* in the default namespace }
+ if XML_Char_ptr(ptrcomp(name ) + i * sizeof(XML_Char ) )^ = XML_T(':' ) then
+ begin
+ j:=0;
+
+ while j < i do
+ begin
+ if poolAppendChar(@dtd.pool ,XML_Char_ptr(ptrcomp(name ) + j * sizeof(XML_Char ) )^ ) = 0 then
+ begin
+ result:=NIL;
+
+ exit;
+
+ end;
+
+ inc(j );
+
+ end;
+
+ if poolAppendChar(@dtd.pool ,XML_T(#0 ) ) = 0 then
+ begin
+ result:=NIL;
+
+ exit;
+
+ end;
+
+ id.prefix:=
+ PREFIX_ptr(
+ lookup(@dtd.prefixes ,poolStart(@dtd.pool ) ,sizeof(PREFIX ) ) );
+
+ if id.prefix.name = poolStart(@dtd.pool ) then
+ poolFinish(@dtd.pool )
+ else
+ poolDiscard(@dtd.pool );
+
+ break;
+
+ end;
+
+ inc(i );
+
+ end;
+
+ end;
+
+ end;
+
+ result:=id;
+
+end;
+
+{ defineAttribute {..}
+function defineAttribute(
+ type_ : ELEMENT_TYPE_ptr; attId : ATTRIBUTE_ID_ptr;
+ isCdata ,isId : XML_Bool; value : XML_Char_ptr; parser : XML_Parser ) : int;
+begin
+end;
+
+{ appendAttributeValue }
+function appendAttributeValue(
+ parser : XML_Parser; enc : ENCODING_ptr; isCdata : XML_Bool;
+ ptr ,end_ : char_ptr; pool : STRING_POOL_ptr ) : XML_Error;
+var
+ dtd : DTD_ptr;
+
+ next : char_ptr;
+
+ tok ,i ,n : int;
+
+ buf : array[0..XML_ENCODE_MAX - 1 ] of XML_Char;
+
+ name ,textEnd : XML_Char_ptr;
+
+ entity : ENTITY_ptr;
+
+ checkEntityDecl : char;
+
+ ch : XML_Char;
+
+ result_ : XML_Error;
+
+label
+ _break ,_go0 ;
+
+begin
+{ save one level of indirection }
+ dtd:=parser.m_dtd;
+
+ repeat
+ tok:=XmlAttributeValueTok(enc ,pointer(ptr ) ,pointer(end_ ) ,@next );
+
+ case tok of
+ XML_TOK_NONE :
+ begin
+ result:=XML_ERROR_NONE;
+
+ exit;
+
+ end;
+
+ XML_TOK_INVALID :
+ begin
+ if enc = parser.m_encoding then
+ parser.m_eventPtr:=next;
+
+ result:=XML_ERROR_INVALID_TOKEN;
+
+ end;
+
+ XML_TOK_PARTIAL :
+ begin
+ if enc = parser.m_encoding then
+ parser.m_eventPtr:=ptr;
+
+ result:=XML_ERROR_INVALID_TOKEN;
+
+ end;
+
+ XML_TOK_CHAR_REF :
+ begin
+ n:=XmlCharRefNumber(enc ,pointer(ptr ) );
+
+ if n < 0 then
+ begin
+ if enc = parser.m_encoding then
+ parser.m_eventPtr:=ptr;
+
+ result:=XML_ERROR_BAD_CHAR_REF;
+
+ end;
+
+ if (isCdata = 0 ) and
+ (n = $20 ) and { space }
+ ((poolLength(pool ) = 0 ) or
+ (poolLastChar(pool ) = XML_Char($20 ) ) ) then
+ goto _break;
+
+ n:=XmlEncode(n ,ICHAR_ptr(buf ) );
+
+ if n = 0 then
+ begin
+ if enc = parser.m_encoding then
+ parser.m_eventPtr:=ptr;
+
+ result:=XML_ERROR_BAD_CHAR_REF;
+
+ exit;
+
+ end;
+
+ i:=0;
+
+ while i < n do
+ begin
+ if poolAppendChar(pool ,buf[i ] ) = 0 then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ inc(i );
+
+ end;
+
+ end;
+
+ XML_TOK_DATA_CHARS :
+ if poolAppend(pool ,enc ,ptr ,next ) = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ XML_TOK_TRAILING_CR :
+ begin
+ next:=char_ptr(ptrcomp(ptr ) + enc.minBytesPerChar );
+
+ goto _go0;
+
+ end;
+
+ XML_TOK_ATTRIBUTE_VALUE_S ,XML_TOK_DATA_NEWLINE :
+ _go0:
+ begin
+ if (isCdata = 0 ) and
+ ((poolLength(pool ) = 0 ) or
+ (poolLastChar(pool ) = XML_Char($20 ) ) ) then
+ goto _break;
+
+ if poolAppendChar(pool ,char($20 ) ) = 0 then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ end;
+
+ XML_TOK_ENTITY_REF :
+ begin
+ ch:=
+ XML_Char(
+ XmlPredefinedEntityName(
+ enc ,
+ pointer(char_ptr(ptrcomp(ptr ) + enc.minBytesPerChar ) ) ,
+ pointer(char_ptr(ptrcomp(next ) - enc.minBytesPerChar ) ) ) );
+
+ if ch <> XML_Char(0 ) then
+ begin
+ if poolAppendChar(pool, ch) = 0 then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ goto _break;
+
+ end;
+
+ name:=
+ poolStoreString(
+ @parser.m_temp2Pool ,enc ,
+ char_ptr(ptrcomp(ptr ) + enc.minBytesPerChar ) ,
+ char_ptr(ptrcomp(next ) - enc.minBytesPerChar ) );
+
+ if name = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ entity:=ENTITY_ptr(lookup(@parser.m_dtd.generalEntities ,name ,0 ) );
+
+ poolDiscard(@parser.m_temp2Pool );
+
+ { First, determine if a check for an existing declaration is needed;
+ if yes, check that the entity exists, and that it is internal. }
+ if pool = @parser.m_dtd.pool then { are we called from prolog? }
+ begin
+ if dtd.standalone <> 0 then
+ checkEntityDecl:=char(parser.m_openInternalEntities = NIL )
+ else
+ checkEntityDecl:=char(dtd.hasParamEntityRefs = 0 );
+
+ {$IFDEF XML_DTD }
+ checkEntityDecl:=char((checkEntityDecl <> #0 ) and (parser.m_prologState.documentEntity <> 0 ) )
+
+ {$ENDIF }
+
+ end
+ else { if pool = @tempPool: we are called from content }
+ checkEntityDecl:=char((dtd.hasParamEntityRefs = 0 ) or (dtd.standalone <> 0 ) );
+
+ if checkEntityDecl <> #0 then
+ if entity = NIL then
+ begin
+ result:=XML_ERROR_UNDEFINED_ENTITY;
+
+ exit;
+
+ end
+ else
+ if entity.is_internal = 0 then
+ begin
+ result:=XML_ERROR_ENTITY_DECLARED_IN_PE;
+
+ exit;
+
+ end
+ else
+ else
+ if entity = NIL then
+ { Cannot report skipped entity here - see comments on
+ skippedEntityHandler.
+ if @parser.m_skippedEntityHandler <> NIL then
+ parser.m_skippedEntityHandler(parser.m_handlerArg ,name ,0 ); }
+ { Cannot call the default handler because this would be
+ out of sync with the call to the startElementHandler.
+ if (pool = @parser.m_tempPool ) and
+ (@parser.m_defaultHandler <> NIL ) then
+ reportDefault(parser ,enc ,ptr ,next ); }
+ goto _break;
+
+ if entity.open <> 0 then
+ begin
+ if enc = parser.m_encoding then
+ parser.m_eventPtr:=ptr;
+
+ result:=XML_ERROR_RECURSIVE_ENTITY_REF;
+
+ exit;
+
+ end;
+
+ if entity.notation <> NIL then
+ begin
+ if enc = parser.m_encoding then
+ parser.m_eventPtr:=ptr;
+
+ result:=XML_ERROR_BINARY_ENTITY_REF;
+
+ exit;
+
+ end;
+
+ if entity.textPtr = NIL then
+ begin
+ if enc = parser.m_encoding then
+ parser.m_eventPtr:=ptr;
+
+ result:=XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF;
+
+ exit;
+
+ end
+ else
+ begin
+ textEnd:=XML_Char_ptr(ptrcomp(entity.textPtr ) + entity.textLen * sizeof(XML_Char ) );
+
+ entity.open:=XML_TRUE;
+
+ result_:=
+ appendAttributeValue(
+ parser ,parser.m_internalEncoding ,isCdata ,
+ char_ptr(entity.textPtr ) ,
+ char_ptr(textEnd ) ,pool );
+
+ entity.open:=XML_FALSE;
+
+ if result_ <> XML_Error(0 ) then
+ begin
+ result:=result_;
+
+ exit;
+
+ end;
+
+ end;
+
+ end;
+
+ else
+ begin
+ if enc = parser.m_encoding then
+ parser.m_eventPtr:=ptr;
+
+ result:=XML_ERROR_UNEXPECTED_STATE;
+
+ exit;
+
+ end;
+
+ end;
+
+ _break:
+ ptr:=next;
+
+ until false;
+
+{ not reached }
+
+end;
+
+{ storeAttributeValue }
+function storeAttributeValue(
+ parser : XML_Parser; enc : ENCODING_ptr; isCdata : XML_Bool;
+ ptr ,end_ : char_ptr; pool : STRING_POOL_ptr ) : XML_Error;
+var
+ result_ : XML_Error;
+
+begin
+ result_:=appendAttributeValue(parser ,enc ,isCdata ,ptr ,end_ ,pool );
+
+ if result_ <> XML_Error(0 ) then
+ begin
+ result:=result_;
+
+ exit;
+
+ end;
+
+ if (isCdata = 0 ) and
+ (poolLength(pool ) <> 0 ) and
+ (poolLastChar(pool ) = XML_Char($20 ) ) then
+ poolChop(pool );
+
+ if poolAppendChar(pool ,XML_T(#0 ) ) = 0 then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ result:=XML_ERROR_NONE;
+
+end;
+
+{ storeEntityValue {..}
+function storeEntityValue(parser : XML_Parser; enc : ENCODING_ptr; start ,end_ : char_ptr ) : XML_Error;
+begin
+end;
+
+{ doIgnoreSection {..}
+{ startPtr gets set to non-null is the section is closed, and to null
+ if the section is not yet closed. }
+function doIgnoreSection(
+ parser : XML_Parser;
+ enc : ENCODING_ptr;
+ startPtr : char_ptr_ptr;
+ end_ : char_ptr;
+ nextPtr : char_ptr_ptr;
+ haveMore : XML_Bool ) : XML_Error;
+begin
+end;
+
+{ ignoreSectionProcessor {..}
+{ The idea here is to avoid using stack for each IGNORE section when
+ the whole file is parsed with one call. }
+function ignoreSectionProcessor(parser : XML_Parser; start ,end_ : char_ptr; endPtr : char_ptr_ptr ) : XML_Error;
+begin
+end;
+
+{ nextScaffoldPart {..}
+function nextScaffoldPart(parser : XML_Parser ) : int;
+begin
+end;
+
+{ build_model {..}
+function build_model(parser : XML_Parser ) : XML_Content_ptr;
+begin
+end;
+
+{ reportProcessingInstruction {..}
+function reportProcessingInstruction(parser : XML_Parser; enc : ENCODING_ptr; start ,end_ : char_ptr ) : int;
+begin
+end;
+
+{ normalizeLines {..}
+procedure normalizeLines(s : XML_Char_ptr );
+begin
+end;
+
+{ reportComment }
+function reportComment(parser : XML_Parser; enc : ENCODING_ptr; start ,end_ : char_ptr ) : int;
+var
+ data : XML_Char_ptr;
+
+begin
+ if @parser.m_commentHandler = NIL then
+ begin
+ if @parser.m_defaultHandler <> NIL then
+ reportDefault(parser ,enc ,start ,end_ );
+
+ result:=1;
+
+ exit;
+
+ end;
+
+ data:=
+ poolStoreString(
+ @parser.m_tempPool ,enc ,
+ char_ptr(ptrcomp(start ) + enc.minBytesPerChar * 4 ) ,
+ char_ptr(ptrcomp(end_ ) - enc.minBytesPerChar * 3 ) );
+
+ if data = NIL then
+ begin
+ result:=0;
+
+ exit;
+
+ end;
+
+ normalizeLines(data );
+
+ parser.m_commentHandler(parser.m_handlerArg ,data );
+
+ poolClear(@parser.m_tempPool );
+
+ result:=1;
+
+end;
+
+{ doProlog }
+function doProlog(
+ parser : XML_Parser;
+ enc : ENCODING_ptr;
+ s ,end_ : char_ptr;
+ tok : int;
+ next : char_ptr;
+ nextPtr : char_ptr_ptr;
+ haveMore : XML_Bool ) : XML_Error;
+const
+{$IFDEF XML_DTD }
+ externalSubsetName : array[0..1 ] of XML_Char = ('#' ,#0 );
+
+{$ENDIF }
+
+ atypeCDATA : array[0..5 ] of XML_Char = ('C' ,'D' ,'A' ,'T' ,'A' ,#0 );
+ atypeID : array[0..2 ] of XML_Char = ('I' ,'D' ,#0 );
+ atypeIDREF : array[0..5 ] of XML_Char = ('I' ,'D' ,'R' ,'E' ,'F' ,#0 );
+ atypeIDREFS : array[0..6 ] of XML_Char = ('I' ,'D' ,'R' ,'E' ,'F' ,'S' ,#0 );
+ atypeENTITY : array[0..6 ] of XML_Char = ('E' ,'N' ,'T' ,'I' ,'T' ,'Y' ,#0 );
+ atypeENTITIES : array[0..8 ] of XML_Char = ('E' ,'N' ,'T' ,'I' ,'T' ,'I' ,'E' ,'S',#0 );
+ atypeNMTOKEN : array[0..7 ] of XML_Char = ('N' ,'M' ,'T' ,'O' ,'K' ,'E' ,'N' ,#0 );
+ atypeNMTOKENS : array[0..8 ] of XML_Char = ('N' ,'M' ,'T' ,'O' ,'K' ,'E' ,'N' ,'S',#0 );
+ notationPrefix : array[0..8 ] of XML_Char = ('N' ,'O' ,'T' ,'A' ,'T' ,'I' ,'O' ,'N',#0 );
+ enumValueSep : array[0..1 ] of XML_Char = ('|' ,#0 );
+ enumValueStart : array[0..1 ] of XML_Char = ('(' ,#0 );
+
+var
+ dtd : DTD_ptr;
+
+ eventPP ,eventEndPP : char_ptr_ptr;
+
+ quant : XML_Content_Quant;
+
+ role ,myindex ,nameLen : int;
+
+ handleDefault ,hadParamEntityRefs ,ok ,betweenDecl : XML_Bool;
+
+ result_ : XML_Error;
+
+ tem ,prefix ,attVal ,name ,systemId : XML_Char_ptr;
+
+ entity : ENTITY_ptr;
+
+ ctemp ,nxt : char_ptr;
+
+ itemp : int_ptr;
+
+ content ,model : XML_Content_ptr;
+
+ el : ELEMENT_TYPE_ptr;
+
+label
+ _break ,_go0 ,_go1 ,
+ alreadyChecked ,checkAttListDeclHandler ,elementContent ,closeGroup ;
+
+begin
+{ save one level of indirection }
+ dtd:=parser.m_dtd;
+
+ if enc = parser.m_encoding then
+ begin
+ eventPP :=@parser.m_eventPtr;
+ eventEndPP:=@parser.m_eventEndPtr;
+
+ end
+ else
+ begin
+ eventPP :=@parser.m_openInternalEntities.internalEventPtr;
+ eventEndPP:=@parser.m_openInternalEntities.internalEventEndPtr;
+
+ end;
+
+ repeat
+ handleDefault:=XML_TRUE;
+ eventPP^ :=s;
+ eventEndPP^ :=next;
+
+ if tok <= 0 then
+ begin
+ if (haveMore <> 0 ) and
+ (tok <> XML_TOK_INVALID ) then
+ begin
+ nextPtr^:=s;
+ result :=XML_ERROR_NONE;
+
+ exit;
+
+ end;
+
+ case tok of
+ XML_TOK_INVALID :
+ begin
+ eventPP^:=next;
+ result :=XML_ERROR_INVALID_TOKEN;
+
+ exit;
+
+ end;
+
+ XML_TOK_PARTIAL :
+ begin
+ result:=XML_ERROR_UNCLOSED_TOKEN;
+
+ exit;
+
+ end;
+
+ XML_TOK_PARTIAL_CHAR :
+ begin
+ result:=XML_ERROR_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ XML_TOK_NONE :
+ begin
+ {$IFDEF XML_DTD }
+ { for internal PE NOT referenced between declarations }
+ if (enc <> parser.m_encoding ) and
+ (parser.m_openInternalEntities.betweenDecl = 0 ) then
+ begin
+ nextPtr^:=s;
+ result :=XML_ERROR_NONE;
+
+ exit;
+
+ end;
+
+ { WFC: PE Between Declarations - must check that PE contains
+ complete markup, not only for external PEs, but also for
+ internal PEs if the reference occurs between declarations. }
+ if (parser.m_isParamEntity <> 0 ) or
+ (enc <> parser.m_encoding ) then
+ begin
+ if XmlTokenRole(@parser.m_prologState ,XML_TOK_NONE ,pointer(end_ ) ,pointer(end_ ) ,enc ) = XML_ROLE_ERROR then
+ begin
+ result:=XML_ERROR_INCOMPLETE_PE;
+
+ exit;
+
+ end;
+
+ nextPtr^:=s;
+ result :=XML_ERROR_NONE;
+
+ exit;
+
+ end;
+
+ {$ENDIF }
+
+ result:=XML_ERROR_NO_ELEMENTS;
+
+ exit;
+
+ end;
+
+ else
+ begin
+ tok :=-tok;
+ next:=end_;
+
+ end;
+
+ end;
+
+ end;
+
+ role:=XmlTokenRole(@parser.m_prologState ,tok ,pointer(s ) ,pointer(next ) ,enc );
+
+ case role of
+ XML_ROLE_XML_DECL :
+ begin
+ result_:=processXmlDecl(parser ,0 ,s ,next );
+
+ if result_ <> XML_ERROR_NONE then
+ begin
+ result:=result_;
+
+ exit;
+
+ end;
+
+ enc:=parser.m_encoding;
+
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ XML_ROLE_DOCTYPE_NAME :
+ begin
+ if @parser.m_startDoctypeDeclHandler <> NIL then
+ begin
+ parser.m_doctypeName:=poolStoreString(@parser.m_tempPool ,enc ,s ,next );
+
+ if parser.m_doctypeName = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ poolFinish(@parser.m_tempPool );
+
+ parser.m_doctypePubid:=NIL;
+ handleDefault :=XML_FALSE;
+
+ end;
+
+ parser.m_doctypeSysid:=NIL; { always initialize to NULL }
+
+ end;
+
+ XML_ROLE_DOCTYPE_INTERNAL_SUBSET :
+ if @parser.m_startDoctypeDeclHandler <> NIL then
+ begin
+ parser.m_startDoctypeDeclHandler(
+ parser.m_handlerArg ,parser.m_doctypeName ,
+ parser.m_doctypeSysid ,parser.m_doctypePubid ,1 );
+
+ parser.m_doctypeName:=NIL;
+
+ poolClear(@parser.m_tempPool );
+
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ {$IFDEF XML_DTD }
+ XML_ROLE_TEXT_DECL :
+ begin
+ result_:=processXmlDecl(parser ,1 ,s ,next );
+
+ if result_ <> XML_ERROR_NONE then
+ begin
+ result:=result_;
+
+ exit;
+
+ end;
+
+ enc :=parser.m_encoding;
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ {$ENDIF }
+
+ XML_ROLE_DOCTYPE_PUBLIC_ID :
+ begin
+ {$IFDEF XML_DTD }
+ parser.m_useForeignDTD:=XML_FALSE;
+ parser.m_declEntity :=
+ ENTITY_ptr(
+ lookup(@dtd.paramEntities ,@externalSubsetName[0 ] ,sizeof(expat.ENTITY ) ) );
+
+ if parser.m_declEntity = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ {$ENDIF }
+ dtd.hasParamEntityRefs:=XML_TRUE;
+
+ if @parser.m_startDoctypeDeclHandler <> NIL then
+ begin
+ if XmlIsPublicId(enc ,pointer(s ) ,pointer(next ) ,pointer(eventPP ) ) = 0 then
+ begin
+ result:=XML_ERROR_PUBLICID;
+
+ exit;
+
+ end;
+
+ parser.m_doctypePubid:=
+ poolStoreString(
+ @parser.m_tempPool ,enc ,
+ char_ptr(ptrcomp(s ) + enc.minBytesPerChar ) ,
+ char_ptr(ptrcomp(next ) - enc.minBytesPerChar ) );
+
+ if parser.m_doctypePubid = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ normalizePublicId(XML_Char_ptr(parser.m_doctypePubid ) );
+ poolFinish (@parser.m_tempPool );
+
+ handleDefault:=XML_FALSE;
+
+ goto alreadyChecked;
+
+ end;
+
+ { fall through }
+ goto _go0;
+
+ end;
+
+ XML_ROLE_ENTITY_PUBLIC_ID :
+ _go0:
+ begin
+ if XmlIsPublicId(enc ,pointer(s ) ,pointer(next ) ,pointer(eventPP ) ) = 0 then
+ begin
+ result:=XML_ERROR_PUBLICID;
+
+ exit;
+
+ end;
+
+ alreadyChecked:
+ if (dtd.keepProcessing <> 0 ) and
+ (parser.m_declEntity <> NIL ) then
+ begin
+ tem:=
+ poolStoreString(
+ @dtd.pool ,enc ,
+ char_ptr(ptrcomp(s ) + enc.minBytesPerChar ) ,
+ char_ptr(ptrcomp(next ) - enc.minBytesPerChar ) );
+
+ if tem = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ normalizePublicId(tem );
+
+ parser.m_declEntity.publicId:=tem;
+
+ poolFinish(@dtd.pool );
+
+ if @parser.m_entityDeclHandler <> NIL then
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ end;
+
+ XML_ROLE_DOCTYPE_CLOSE :
+ begin
+ if parser.m_doctypeName <> NIL then
+ begin
+ parser.m_startDoctypeDeclHandler(
+ parser.m_handlerArg ,parser.m_doctypeName ,
+ parser.m_doctypeSysid ,parser.m_doctypePubid ,0 );
+
+ poolClear(@parser.m_tempPool );
+
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ { doctypeSysid will be non-NULL in the case of a previous
+ XML_ROLE_DOCTYPE_SYSTEM_ID, even if startDoctypeDeclHandler
+ was not set, indicating an external subset }
+ {$IFDEF XML_DTD }
+ if (parser.m_doctypeSysid <> NIL ) or
+ (parser.m_useForeignDTD <> 0 ) then
+ begin
+ hadParamEntityRefs :=dtd.hasParamEntityRefs;
+ dtd.hasParamEntityRefs:=XML_TRUE;
+
+ if (parser.m_paramEntityParsing <> XML_ParamEntityParsing(0 ) ) and
+ (@parser.m_externalEntityRefHandler <> NIL ) then
+ begin
+ entity:=
+ ENTITY_ptr(
+ lookup(@dtd.paramEntities ,@externalSubsetName[0 ] ,sizeof(expat.ENTITY ) ) );
+
+ if entity = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ if parser.m_useForeignDTD <> 0 then
+ entity.base:=parser.m_curBase;
+
+ dtd.paramEntityRead:=XML_FALSE;
+
+ if parser.m_externalEntityRefHandler(
+ parser.m_externalEntityRefHandlerArg ,0 ,
+ entity.base ,
+ entity.systemId ,
+ entity.publicId ) = 0 then
+ begin
+ result:=XML_ERROR_EXTERNAL_ENTITY_HANDLING;
+
+ exit;
+
+ end;
+
+ if dtd.paramEntityRead <> 0 then
+ if (dtd.standalone = 0 ) and
+ (@parser.m_notStandaloneHandler <> NIL ) and
+ (parser.m_notStandaloneHandler(parser.m_handlerArg ) = 0 ) then
+ begin
+ result:=XML_ERROR_NOT_STANDALONE;
+
+ exit;
+
+ end
+ else
+ else
+ { if we didn't read the foreign DTD then this means that there
+ is no external subset and we must reset dtd.hasParamEntityRefs }
+ if parser.m_doctypeSysid = NIL then
+ dtd.hasParamEntityRefs:=hadParamEntityRefs;
+
+ { end of DTD - no need to update dtd.keepProcessing }
+
+ end;
+
+ parser.m_useForeignDTD:=XML_FALSE;
+
+ end;
+
+ {$ENDIF }
+ if @parser.m_endDoctypeDeclHandler <> NIL then
+ begin
+ parser.m_endDoctypeDeclHandler(parser.m_handlerArg );
+
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ end;
+
+ XML_ROLE_INSTANCE_START :
+ begin
+ {$IFDEF XML_DTD }
+ { if there is no DOCTYPE declaration then now is the
+ last chance to read the foreign DTD }
+ if parser.m_useForeignDTD <> 0 then
+ begin
+ hadParamEntityRefs :=dtd.hasParamEntityRefs;
+ dtd.hasParamEntityRefs:=XML_TRUE;
+
+ if (parser.m_paramEntityParsing <> XML_ParamEntityParsing(0 ) ) and
+ (@parser.m_externalEntityRefHandler <> NIL ) then
+ begin
+ entity:=
+ ENTITY_ptr(
+ lookup(@dtd.paramEntities ,@externalSubsetName[0 ] ,sizeof(expat.ENTITY ) ) );
+
+ if entity = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ entity.base :=parser.m_curBase;
+ dtd.paramEntityRead:=XML_FALSE;
+
+ if parser.m_externalEntityRefHandler(
+ parser.m_externalEntityRefHandlerArg ,0 ,
+ entity.base ,
+ entity.systemId ,
+ entity.publicId ) = 0 then
+ begin
+ result:=XML_ERROR_EXTERNAL_ENTITY_HANDLING;
+
+ exit;
+
+ end;
+
+ if dtd.paramEntityRead <> 0 then
+ if (dtd.standalone = 0 ) and
+ (@parser.m_notStandaloneHandler <> NIL ) and
+ (parser.m_notStandaloneHandler(parser.m_handlerArg ) = 0 ) then
+ begin
+ result:=XML_ERROR_NOT_STANDALONE;
+
+ exit;
+
+ end
+ else
+ else
+ { if we didn't read the foreign DTD then this means that there
+ is no external subset and we must reset dtd.hasParamEntityRefs }
+ dtd.hasParamEntityRefs:=hadParamEntityRefs;
+
+ { end of DTD - no need to update dtd.keepProcessing }
+
+ end;
+
+ end;
+
+ {$ENDIF }
+ parser.m_processor:=@contentProcessor;
+
+ result:=contentProcessor(parser ,s ,end_ ,nextPtr );
+
+ exit;
+
+ end;
+
+ XML_ROLE_ATTLIST_ELEMENT_NAME :
+ begin
+ parser.m_declElementType:=getElementType(parser ,enc ,s ,next );
+
+ if parser.m_declElementType = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ goto checkAttListDeclHandler;
+
+ end;
+
+ XML_ROLE_ATTRIBUTE_NAME :
+ begin
+ parser.m_declAttributeId:=getAttributeId(parser ,enc ,s ,next );
+
+ if parser.m_declAttributeId = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ parser.m_declAttributeIsCdata:=XML_FALSE;
+ parser.m_declAttributeType :=NIL;
+ parser.m_declAttributeIsId :=XML_FALSE;
+
+ goto checkAttListDeclHandler;
+
+ end;
+
+ XML_ROLE_ATTRIBUTE_TYPE_CDATA :
+ begin
+ parser.m_declAttributeIsCdata:=XML_TRUE;
+ parser.m_declAttributeType :=@atypeCDATA[0 ];
+
+ goto checkAttListDeclHandler;
+
+ end;
+
+ XML_ROLE_ATTRIBUTE_TYPE_ID :
+ begin
+ parser.m_declAttributeIsId:=XML_TRUE;
+ parser.m_declAttributeType:=@atypeID[0 ];
+
+ goto checkAttListDeclHandler;
+
+ end;
+
+ XML_ROLE_ATTRIBUTE_TYPE_IDREF :
+ begin
+ parser.m_declAttributeType:=@atypeIDREF[0 ];
+
+ goto checkAttListDeclHandler;
+
+ end;
+
+ XML_ROLE_ATTRIBUTE_TYPE_IDREFS :
+ begin
+ parser.m_declAttributeType:=@atypeIDREFS[0 ];
+
+ goto checkAttListDeclHandler;
+
+ end;
+
+ XML_ROLE_ATTRIBUTE_TYPE_ENTITY :
+ begin
+ parser.m_declAttributeType:=@atypeENTITY[0 ];
+
+ goto checkAttListDeclHandler;
+
+ end;
+
+ XML_ROLE_ATTRIBUTE_TYPE_ENTITIES :
+ begin
+ parser.m_declAttributeType:=@atypeENTITIES[0 ];
+
+ goto checkAttListDeclHandler;
+
+ end;
+
+ XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN :
+ begin
+ parser.m_declAttributeType:=@atypeNMTOKEN[0 ];
+
+ goto checkAttListDeclHandler;
+
+ end;
+
+ XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS :
+ begin
+ parser.m_declAttributeType:=@atypeNMTOKENS[0 ];
+
+ checkAttListDeclHandler:
+ if (dtd.keepProcessing <> 0 ) and
+ (@parser.m_attlistDeclHandler <> NIL ) then
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ XML_ROLE_ATTRIBUTE_ENUM_VALUE ,XML_ROLE_ATTRIBUTE_NOTATION_VALUE :
+ if (dtd.keepProcessing <> 0 ) and
+ (@parser.m_attlistDeclHandler <> NIL ) then
+ begin
+ if parser.m_declAttributeType <> NIL then
+ prefix:=@enumValueSep[0 ]
+
+ else
+ if role = XML_ROLE_ATTRIBUTE_NOTATION_VALUE then
+ prefix:=@notationPrefix[0 ]
+ else
+ prefix:=@enumValueStart[0 ];
+
+ if poolAppendString(@parser.m_tempPool ,prefix ) = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ if poolAppend(@parser.m_tempPool ,enc ,s ,next ) = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ parser.m_declAttributeType:=parser.m_tempPool.start;
+
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ XML_ROLE_IMPLIED_ATTRIBUTE_VALUE ,XML_ROLE_REQUIRED_ATTRIBUTE_VALUE :
+ if dtd.keepProcessing <> 0 then
+ begin
+ if defineAttribute(
+ parser.m_declElementType ,parser.m_declAttributeId ,
+ parser.m_declAttributeIsCdata ,parser.m_declAttributeIsId ,
+ 0 ,parser ) = 0 then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ if (@parser.m_attlistDeclHandler <> NIL ) and
+ (parser.m_declAttributeType <> NIL ) then
+ begin
+ if (parser.m_declAttributeType^ = XML_T('(' ) ) or
+ ((parser.m_declAttributeType^ = XML_T('N' ) ) and
+ (XML_Char_ptr(ptrcomp(parser.m_declAttributeType ) + 1 )^ = XML_T('O' ) ) ) then
+ begin
+ { Enumerated or Notation type }
+ if (poolAppendChar(@parser.m_tempPool ,XML_T(')' ) ) = 0 ) or
+ (poolAppendChar(@parser.m_tempPool ,XML_T(#0 ) ) = 0 ) then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ parser.m_declAttributeType:=parser.m_tempPool.start;
+
+ poolFinish(@parser.m_tempPool );
+
+ end;
+
+ eventEndPP^:=s;
+
+ parser.m_attlistDeclHandler(
+ parser.m_handlerArg ,parser.m_declElementType.name ,
+ parser.m_declAttributeId.name ,parser.m_declAttributeType ,
+ 0 ,int(role = XML_ROLE_REQUIRED_ATTRIBUTE_VALUE ) );
+
+ poolClear(@parser.m_tempPool );
+
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ end;
+
+ XML_ROLE_DEFAULT_ATTRIBUTE_VALUE ,XML_ROLE_FIXED_ATTRIBUTE_VALUE :
+ if dtd.keepProcessing <> 0 then
+ begin
+ result_:=
+ storeAttributeValue(
+ parser ,enc ,parser.m_declAttributeIsCdata ,
+ char_ptr(ptrcomp(s ) + enc.minBytesPerChar ) ,
+ char_ptr(ptrcomp(next ) - enc.minBytesPerChar ) ,
+ @dtd.pool );
+
+ if result_ <> XML_Error(0 ) then
+ begin
+ result:=result_;
+
+ exit;
+
+ end;
+
+ attVal:=poolStart(@dtd.pool );
+
+ poolFinish(@dtd.pool );
+
+ { ID attributes aren't allowed to have a default }
+ if defineAttribute(
+ parser.m_declElementType ,parser.m_declAttributeId ,
+ parser.m_declAttributeIsCdata ,XML_FALSE ,attVal ,parser ) = 0 then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ if (@parser.m_attlistDeclHandler <> NIL ) and
+ (parser.m_declAttributeType <> NIL ) then
+ begin
+ if (parser.m_declAttributeType^ = XML_T('(' ) ) or
+ ((parser.m_declAttributeType^ = XML_T('N' ) ) and
+ (XML_Char_ptr(ptrcomp(parser.m_declAttributeType ) + 1 )^ = XML_T('O' ) ) ) then
+ begin
+ { Enumerated or Notation type }
+ if (poolAppendChar(@parser.m_tempPool ,XML_T(')' ) ) = 0 ) or
+ (poolAppendChar(@parser.m_tempPool ,XML_T(#0 ) ) = 0 ) then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ parser.m_declAttributeType:=parser.m_tempPool.start;
+
+ poolFinish(@parser.m_tempPool );
+
+ end;
+
+ eventEndPP^:=s;
+
+ parser.m_attlistDeclHandler(
+ parser.m_handlerArg ,parser.m_declElementType.name ,
+ parser.m_declAttributeId.name ,parser.m_declAttributeType ,
+ attVal ,int(role = XML_ROLE_FIXED_ATTRIBUTE_VALUE ) );
+
+ poolClear(@parser.m_tempPool );
+
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ end;
+
+ XML_ROLE_ENTITY_VALUE :
+ if dtd.keepProcessing <> 0 then
+ begin
+ result_:=
+ storeEntityValue(
+ parser ,enc ,
+ char_ptr(ptrcomp(s ) + enc.minBytesPerChar ) ,
+ char_ptr(ptrcomp(next ) - enc.minBytesPerChar ) );
+
+ if parser.m_declEntity <> NIL then
+ begin
+ parser.m_declEntity.textPtr:=poolStart(@dtd.entityValuePool );
+ parser.m_declEntity.textLen:=poolLength(@dtd.entityValuePool );
+
+ poolFinish(@dtd.entityValuePool );
+
+ if @parser.m_entityDeclHandler <> NIL then
+ begin
+ eventEndPP^:=s;
+
+ parser.m_entityDeclHandler(
+ parser.m_handlerArg ,
+ parser.m_declEntity.name,
+ parser.m_declEntity.is_param,
+ parser.m_declEntity.textPtr,
+ parser.m_declEntity.textLen,
+ parser.m_curBase ,0 ,0 ,0 );
+
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ end
+ else
+ poolDiscard(@dtd.entityValuePool );
+
+ if result_ <> XML_ERROR_NONE then
+ begin
+ result:=result_;
+
+ exit;
+
+ end;
+
+ end;
+
+ XML_ROLE_DOCTYPE_SYSTEM_ID :
+ begin
+ {$IFDEF XML_DTD }
+ parser.m_useForeignDTD:=XML_FALSE;
+
+ {$ENDIF }
+
+ dtd.hasParamEntityRefs:=XML_TRUE;
+
+ if @parser.m_startDoctypeDeclHandler <> NIL then
+ begin
+ parser.m_doctypeSysid:=
+ poolStoreString(
+ @parser.m_tempPool ,enc ,
+ char_ptr(ptrcomp(s ) + enc.minBytesPerChar ) ,
+ char_ptr(ptrcomp(next ) - enc.minBytesPerChar ) );
+
+ if parser.m_doctypeSysid = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ poolFinish(@parser.m_tempPool );
+
+ handleDefault:=XML_FALSE;
+
+ end
+ {$IFDEF XML_DTD }
+ else
+ { use externalSubsetName to make doctypeSysid non-NULL
+ for the case where no startDoctypeDeclHandler is set }
+ parser.m_doctypeSysid:=@externalSubsetName[0 ];
+
+ {$ELSE }; {$ENDIF }
+
+ if (dtd.standalone = 0 ) and
+ {$IFDEF XML_DTD }
+ (parser.m_paramEntityParsing = XML_ParamEntityParsing(0 ) ) and
+ {$ENDIF }
+ (@parser.m_notStandaloneHandler <> NIL ) and
+ (parser.m_notStandaloneHandler(parser.m_handlerArg ) = 0 ) then
+ begin
+ result:=XML_ERROR_NOT_STANDALONE;
+
+ exit;
+
+ end;
+
+ {$IFNDEF XML_DTD }
+ {$ELSE }
+ if parser.m_declEntity = NIL then
+ begin
+ parser.m_declEntity:=
+ ENTITY_ptr(
+ lookup(
+ @dtd.paramEntities ,@externalSubsetName[0 ] ,sizeof(expat.ENTITY ) ) );
+
+ if parser.m_declEntity = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ parser.m_declEntity.publicId:=NIL;
+
+ end;
+
+ {$ENDIF }
+ { fall through }
+ goto _go1;
+
+ end;
+
+ XML_ROLE_ENTITY_SYSTEM_ID :
+ _go1:
+ if (dtd.keepProcessing <> 0 ) and
+ (parser.m_declEntity <> NIL ) then
+ begin
+ parser.m_declEntity.systemId:=
+ poolStoreString(
+ @dtd.pool ,enc ,
+ char_ptr(ptrcomp(s ) + enc.minBytesPerChar ) ,
+ char_ptr(ptrcomp(next ) - enc.minBytesPerChar ) );
+
+ if parser.m_declEntity.systemId = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ parser.m_declEntity.base:=parser.m_curBase;
+
+ poolFinish(@dtd.pool );
+
+ if @parser.m_entityDeclHandler <> NIL then
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ XML_ROLE_ENTITY_COMPLETE :
+ if (dtd.keepProcessing <> 0 ) and
+ (parser.m_declEntity <> NIL ) and
+ (@parser.m_entityDeclHandler <> NIL ) then
+ begin
+ eventEndPP^:=s;
+
+ parser.m_entityDeclHandler(
+ parser.m_handlerArg ,
+ parser.m_declEntity.name ,
+ parser.m_declEntity.is_param ,
+ 0 ,0 ,
+ parser.m_declEntity.base ,
+ parser.m_declEntity.systemId ,
+ parser.m_declEntity.publicId ,
+ 0 );
+
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ XML_ROLE_ENTITY_NOTATION_NAME :
+ if (dtd.keepProcessing <> 0 ) and
+ (parser.m_declEntity <> NIL ) then
+ begin
+ parser.m_declEntity.notation:=poolStoreString(@dtd.pool ,enc ,s ,next );
+
+ if parser.m_declEntity.notation = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ poolFinish(@dtd.pool );
+
+ if @parser.m_unparsedEntityDeclHandler <> NIL then
+ begin
+ eventEndPP^:=s;
+
+ parser.m_unparsedEntityDeclHandler(
+ parser.m_handlerArg ,
+ parser.m_declEntity.name ,
+ parser.m_declEntity.base ,
+ parser.m_declEntity.systemId ,
+ parser.m_declEntity.publicId ,
+ parser.m_declEntity.notation );
+
+ handleDefault:=XML_FALSE;
+
+ end
+ else
+ if @parser.m_entityDeclHandler <> NIL then
+ begin
+ eventEndPP^:=s;
+
+ parser.m_entityDeclHandler(
+ parser.m_handlerArg ,
+ parser.m_declEntity.name ,
+ 0 ,0 ,0 ,
+ parser.m_declEntity.base,
+ parser.m_declEntity.systemId ,
+ parser.m_declEntity.publicId ,
+ parser.m_declEntity.notation );
+
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ end;
+
+ XML_ROLE_GENERAL_ENTITY_NAME :
+ begin
+ if XmlPredefinedEntityName(enc ,pointer(s ) ,pointer(next ) ) <> 0 then
+ begin
+ parser.m_declEntity:=NIL;
+
+ goto _break;
+
+ end;
+
+ if dtd.keepProcessing <> 0 then
+ begin
+ name:=poolStoreString(@dtd.pool ,enc ,s ,next );
+
+ if name = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ parser.m_declEntity:=
+ ENTITY_ptr(
+ lookup(@dtd.generalEntities ,name ,sizeof(expat.ENTITY ) ) );
+
+ if parser.m_declEntity = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ if parser.m_declEntity.name <> name then
+ begin
+ poolDiscard(@dtd.pool );
+
+ parser.m_declEntity:=NIL;
+
+ end
+ else
+ begin
+ poolFinish(@dtd.pool );
+
+ parser.m_declEntity.publicId:=NIL;
+ parser.m_declEntity.is_param:=XML_FALSE;
+
+ { if we have a parent parser or are reading an internal parameter
+ entity, then the entity declaration is not considered "internal" }
+ parser.m_declEntity.is_internal:=
+ XML_Bool(
+ not ((parser.m_parentParser <> NIL ) or
+ (parser.m_openInternalEntities <> NIL ) ) );
+
+ if @parser.m_entityDeclHandler <> NIL then
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ end
+ else
+ begin
+ poolDiscard(@dtd.pool );
+
+ parser.m_declEntity:=NIL;
+
+ end;
+
+ end;
+
+ XML_ROLE_PARAM_ENTITY_NAME :
+ {$IFDEF XML_DTD }
+ if dtd.keepProcessing <> 0 then
+ begin
+ name:=poolStoreString(@dtd.pool ,enc ,s ,next );
+
+ if name <> NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ parser.m_declEntity:=
+ ENTITY_ptr(
+ lookup(@dtd.paramEntities ,name ,sizeof(expat.ENTITY ) ) );
+
+ if parser.m_declEntity = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ if parser.m_declEntity.name <> name then
+ begin
+ poolDiscard(@dtd.pool );
+
+ parser.m_declEntity:=NIL;
+
+ end
+ else
+ begin
+ poolFinish(@dtd.pool );
+
+ parser.m_declEntity.publicId:=NIL;
+ parser.m_declEntity.is_param:=XML_TRUE;
+
+ { if we have a parent parser or are reading an internal parameter
+ entity, then the entity declaration is not considered "internal" }
+ parser.m_declEntity.is_internal:=
+ XML_Bool(
+ not((parser.m_parentParser <> NIL ) or
+ (parser.m_openInternalEntities <> NIL ) ) );
+
+ if @parser.m_entityDeclHandler <> NIL then
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ end
+ else
+ begin
+ poolDiscard(@dtd.pool );
+
+ parser.m_declEntity:=NIL;
+
+ end;
+
+ {$ELSE }
+ parser.m_declEntity:=NIL;
+
+ {$ENDIF }
+
+ XML_ROLE_NOTATION_NAME :
+ begin
+ parser.m_declNotationPublicId:=NIL;
+ parser.m_declNotationName :=NIL;
+
+ if @parser.m_notationDeclHandler <> NIL then
+ begin
+ parser.m_declNotationName:=poolStoreString(@parser.m_tempPool ,enc ,s ,next );
+
+ if parser.m_declNotationName = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ poolFinish(@parser.m_tempPool );
+
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ end;
+
+ XML_ROLE_NOTATION_PUBLIC_ID :
+ begin
+ if XmlIsPublicId(enc ,pointer(s ) ,pointer(next ) ,pointer(eventPP ) ) = 0 then
+ begin
+ result:=XML_ERROR_PUBLICID;
+
+ exit;
+
+ end;
+
+ if parser.m_declNotationName <> NIL then { means notationDeclHandler <> NIL }
+ begin
+ tem:=
+ poolStoreString(
+ @parser.m_tempPool ,
+ enc ,
+ char_ptr(ptrcomp(s ) + enc.minBytesPerChar ) ,
+ char_ptr(ptrcomp(next ) - enc.minBytesPerChar ) );
+
+ if tem = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ normalizePublicId(tem );
+
+ parser.m_declNotationPublicId:=tem;
+
+ poolFinish(@parser.m_tempPool );
+
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ end;
+
+ XML_ROLE_NOTATION_SYSTEM_ID :
+ begin
+ if (parser.m_declNotationName <> NIL ) and
+ (@parser.m_notationDeclHandler <> NIL ) then
+ begin
+ systemId:=
+ poolStoreString(
+ @parser.m_tempPool ,enc ,
+ char_ptr(ptrcomp(s ) + enc.minBytesPerChar ) ,
+ char_ptr(ptrcomp(next ) - enc.minBytesPerChar ) );
+
+ if systemId = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ eventEndPP^:=s;
+
+ parser.m_notationDeclHandler(
+ parser.m_handlerArg ,
+ parser.m_declNotationName ,
+ parser.m_curBase ,
+ systemId ,
+ parser.m_declNotationPublicId );
+
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ poolClear(@parser.m_tempPool );
+
+ end;
+
+ XML_ROLE_NOTATION_NO_SYSTEM_ID :
+ begin
+ if (parser.m_declNotationPublicId <> NIL ) and
+ (@parser.m_notationDeclHandler <> NIL ) then
+ begin
+ eventEndPP^:=s;
+
+ parser.m_notationDeclHandler(
+ parser.m_handlerArg ,
+ parser.m_declNotationName ,
+ parser.m_curBase ,
+ 0 ,
+ parser.m_declNotationPublicId );
+
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ poolClear(@parser.m_tempPool );
+
+ end;
+
+ XML_ROLE_ERROR :
+ case tok of
+ XML_TOK_PARAM_ENTITY_REF :
+ { PE references in internal subset are
+ not allowed within declarations. }
+ begin
+ result:=XML_ERROR_PARAM_ENTITY_REF;
+
+ exit;
+
+ end;
+
+ XML_TOK_XML_DECL :
+ begin
+ result:=XML_ERROR_MISPLACED_XML_PI;
+
+ exit;
+
+ end;
+
+ else
+ begin
+ result:=XML_ERROR_SYNTAX;
+
+ exit;
+
+ end;
+
+ end;
+
+ {$IFDEF XML_DTD }
+ XML_ROLE_IGNORE_SECT :
+ begin
+ if @parser.m_defaultHandler <> NIL then
+ reportDefault(parser ,enc ,s ,next );
+
+ handleDefault:=XML_FALSE;
+
+ result_:=doIgnoreSection(parser ,enc ,@next ,end_ ,nextPtr ,haveMore );
+
+ if result_ <> XML_ERROR_NONE then
+ begin
+ result:=result_;
+
+ exit;
+
+ end
+ else
+ if next = NIL then
+ begin
+ parser.m_processor:=@ignoreSectionProcessor;
+
+ result:=result_;
+
+ exit;
+
+ end;
+
+ end;
+
+ {$ENDIF }
+
+ XML_ROLE_GROUP_OPEN :
+ begin
+ if parser.m_prologState.level >= parser.m_groupSize then
+ if parser.m_groupSize <> 0 then
+ begin
+ parser.m_groupSize:=parser.m_groupSize * 2;
+
+ if parser.m_mem.realloc_fcn(
+ pointer(parser.m_groupConnector ) ,
+ parser.m_groupAlloc ,
+ parser.m_groupSize ) then
+ parser.m_groupAlloc:=parser.m_groupSize
+
+ else
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ if dtd.scaffIndex <> NIL then
+ if parser.m_mem.realloc_fcn(
+ pointer(dtd.scaffIndex ) ,
+ dtd.scaffAlloc ,
+ parser.m_groupSize * sizeof(int ) ) then
+ dtd.scaffAlloc:=parser.m_groupSize * sizeof(int )
+
+ else
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ end
+ else
+ begin
+ parser.m_groupSize:=32;
+
+ if parser.m_mem.malloc_fcn(
+ pointer(parser.m_groupConnector ) ,
+ parser.m_groupSize ) then
+ parser.m_groupAlloc:=parser.m_groupSize
+
+ else
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ end;
+
+ char_ptr(ptrcomp(parser.m_groupConnector ) + parser.m_prologState.level )^:=#0;
+
+ if dtd.in_eldecl <> 0 then
+ begin
+ myindex:=nextScaffoldPart(parser );
+
+ if myindex < 0 then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ int_ptr(ptrcomp(dtd.scaffIndex ) + dtd.scaffLevel * sizeof(int ) )^:=myindex;
+
+ inc(dtd.scaffLevel );
+
+ CONTENT_SCAFFOLD_ptr(ptrcomp(dtd.scaffold ) + myindex * sizeof(CONTENT_SCAFFOLD ) )^.type_:=XML_CTYPE_SEQ;
+
+ if @parser.m_elementDeclHandler <> NIL then
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ end;
+
+ XML_ROLE_GROUP_SEQUENCE :
+ begin
+ if char_ptr(ptrcomp(parser.m_groupConnector ) + parser.m_prologState.level )^ = '|' then
+ begin
+ result:=XML_ERROR_SYNTAX;
+
+ exit;
+
+ end;
+
+ char_ptr(ptrcomp(parser.m_groupConnector ) + parser.m_prologState.level )^:=',';
+
+ if (dtd.in_eldecl <> 0 ) and
+ (@parser.m_elementDeclHandler <> NIL ) then
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ XML_ROLE_GROUP_CHOICE :
+ begin
+ if char_ptr(ptrcomp(parser.m_groupConnector ) + parser.m_prologState.level )^ = ',' then
+ begin
+ result:=XML_ERROR_SYNTAX;
+
+ exit;
+
+ end;
+
+ if (dtd.in_eldecl <> 0 ) and
+ (char_ptr(ptrcomp(parser.m_groupConnector ) + parser.m_prologState.level )^ <> #0 ) and
+ (CONTENT_SCAFFOLD_ptr(
+ ptrcomp(dtd.scaffold ) +
+ int_ptr(ptrcomp(dtd.scaffIndex ) + (dtd.scaffLevel - 1 ) * sizeof(int ) )^ *
+ sizeof(CONTENT_SCAFFOLD ) )^.type_ <> XML_CTYPE_MIXED ) then
+ begin
+ CONTENT_SCAFFOLD_ptr(
+ ptrcomp(dtd.scaffold ) +
+ int_ptr(ptrcomp(dtd.scaffIndex ) + (dtd.scaffLevel - 1 ) * sizeof(int ) )^ *
+ sizeof(CONTENT_SCAFFOLD ) )^.type_:=XML_CTYPE_CHOICE;
+
+ if @parser.m_elementDeclHandler <> NIL then
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ char_ptr(ptrcomp(parser.m_groupConnector ) + parser.m_prologState.level )^:='|';
+
+ end;
+
+ XML_ROLE_PARAM_ENTITY_REF {$IFDEF XML_DTD } ,XML_ROLE_INNER_PARAM_ENTITY_REF : {$ELSE }: {$ENDIF }
+ begin
+ {$IFDEF XML_DTD }
+ dtd.hasParamEntityRefs:=XML_TRUE;
+
+ if parser.m_paramEntityParsing = XML_ParamEntityParsing(0 ) then
+ dtd.keepProcessing:=dtd.standalone
+
+ else
+ begin
+ name:=
+ poolStoreString(
+ @dtd.pool ,enc ,
+ char_ptr(ptrcomp(s ) + enc.minBytesPerChar ) ,
+ char_ptr(ptrcomp(next ) - enc.minBytesPerChar ) );
+
+ if name = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ entity:=ENTITY_ptr(lookup(@dtd.paramEntities ,name ,0 ) );
+
+ poolDiscard(@dtd.pool );
+
+ { first, determine if a check for an existing declaration is needed;
+ if yes, check that the entity exists, and that it is internal,
+ otherwise call the skipped entity handler }
+ if dtd.standalone <> 0 then
+ ok:=XML_Bool(parser.m_openInternalEntities = NIL )
+ else
+ ok:=XML_Bool(dtd.hasParamEntityRefs = 0 );
+
+ if (parser.m_prologState.documentEntity <> 0 ) and
+ (ok <> 0 ) then
+ if entity = NIL then
+ begin
+ result:=XML_ERROR_UNDEFINED_ENTITY;
+
+ exit;
+
+ end
+ else
+ if entity.is_internal = 0 then
+ begin
+ result:=XML_ERROR_ENTITY_DECLARED_IN_PE;
+
+ exit;
+
+ end
+ else
+ else
+ if entity = NIL then
+ begin
+ dtd.keepProcessing:=dtd.standalone;
+
+ { cannot report skipped entities in declarations }
+ if (role = XML_ROLE_PARAM_ENTITY_REF ) and
+ (@parser.m_skippedEntityHandler <> NIL ) then
+ begin
+ parser.m_skippedEntityHandler(parser.m_handlerArg ,name ,1 );
+
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ goto _break;
+
+ end;
+
+ if entity.open <> 0 then
+ begin
+ result:=XML_ERROR_RECURSIVE_ENTITY_REF;
+
+ exit;
+
+ end;
+
+ if entity.textPtr <> NIL then
+ begin
+ if role = XML_ROLE_PARAM_ENTITY_REF then
+ betweenDecl:=XML_TRUE
+ else
+ betweenDecl:=XML_FALSE;
+
+ result_:=processInternalEntity(parser ,entity ,betweenDecl );
+
+ if result_ <> XML_ERROR_NONE then
+ begin
+ result:=result_;
+
+ exit;
+
+ end;
+
+ handleDefault:=XML_FALSE;
+
+ goto _break;
+
+ end;
+
+ if @parser.m_externalEntityRefHandler <> NIL then
+ begin
+ dtd.paramEntityRead:=XML_FALSE;
+ entity.open :=XML_TRUE;
+
+ if parser.m_externalEntityRefHandler(
+ parser.m_externalEntityRefHandlerArg ,
+ 0 ,
+ entity.base ,
+ entity.systemId ,
+ entity.publicId ) = 0 then
+ begin
+ entity.open:=XML_FALSE;
+
+ result:=XML_ERROR_EXTERNAL_ENTITY_HANDLING;
+
+ exit;
+
+ end;
+
+ entity.open :=XML_FALSE;
+ handleDefault:=XML_FALSE;
+
+ if dtd.paramEntityRead = 0 then
+ begin
+ dtd.keepProcessing:=dtd.standalone;
+
+ goto _break;
+
+ end;
+
+ end
+ else
+ begin
+ dtd.keepProcessing:=dtd.standalone;
+
+ goto _break;
+
+ end;
+
+ end;
+
+ {$ENDIF }
+
+ if (dtd.standalone = 0 ) and
+ (@parser.m_notStandaloneHandler <> NIL ) and
+ (parser.m_notStandaloneHandler(parser.m_handlerArg ) = 0 ) then
+ begin
+ result:=XML_ERROR_NOT_STANDALONE;
+
+ exit;
+
+ end;
+
+ end;
+
+ { Element declaration stuff }
+ XML_ROLE_ELEMENT_NAME :
+ if @parser.m_elementDeclHandler <> NIL then
+ begin
+ parser.m_declElementType:=getElementType(parser ,enc ,s ,next );
+
+ if parser.m_declElementType = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ dtd.scaffLevel:=0;
+ dtd.scaffCount:=0;
+ dtd.in_eldecl :=XML_TRUE;
+ handleDefault :=XML_FALSE;
+
+ end;
+
+ XML_ROLE_CONTENT_ANY ,XML_ROLE_CONTENT_EMPTY :
+ if dtd.in_eldecl <> 0 then
+ begin
+ if @parser.m_elementDeclHandler <> NIL then
+ begin
+ parser.m_mem.malloc_fcn(pointer(content ) ,sizeof(XML_Content ) );
+
+ if content = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ content.quant :=XML_CQUANT_NONE;
+ content.name :=NIL;
+ content.numchildren:=0;
+ content.children :=NIL;
+
+ if role = XML_ROLE_CONTENT_ANY then
+ content.type_:=XML_CTYPE_ANY
+ else
+ content.type_:=XML_CTYPE_EMPTY;
+
+ eventEndPP^:=s;
+
+ parser.m_elementDeclHandler(
+ parser.m_handlerArg ,parser.m_declElementType.name ,content );
+
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ dtd.in_eldecl:=XML_FALSE;
+
+ end;
+
+ XML_ROLE_CONTENT_PCDATA :
+ if dtd.in_eldecl <> 0 then
+ begin
+ CONTENT_SCAFFOLD_ptr(
+ ptrcomp(dtd.scaffold ) +
+ int_ptr(ptrcomp(dtd.scaffIndex ) + (dtd.scaffLevel - 1 ) * sizeof(int ) )^ *
+ sizeof(CONTENT_SCAFFOLD ) )^.type_:=XML_CTYPE_MIXED;
+
+ if @parser.m_elementDeclHandler <> NIL then
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ XML_ROLE_CONTENT_ELEMENT :
+ begin
+ quant:=XML_CQUANT_NONE;
+
+ goto elementContent;
+
+ end;
+
+ XML_ROLE_CONTENT_ELEMENT_OPT :
+ begin
+ quant:=XML_CQUANT_OPT;
+
+ goto elementContent;
+
+ end;
+
+ XML_ROLE_CONTENT_ELEMENT_REP :
+ begin
+ quant:=XML_CQUANT_REP;
+
+ goto elementContent;
+
+ end;
+
+ XML_ROLE_CONTENT_ELEMENT_PLUS :
+ begin
+ quant:=XML_CQUANT_PLUS;
+
+ elementContent:
+ if dtd.in_eldecl <> 0 then
+ begin
+ if quant = XML_CQUANT_NONE then
+ nxt:=next
+ else
+ nxt:=char_ptr(ptrcomp(next ) - enc.minBytesPerChar );
+
+ myindex:=nextScaffoldPart(parser );
+
+ if myindex < 0 then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ CONTENT_SCAFFOLD_ptr(
+ ptrcomp(dtd.scaffold ) +
+ myindex * sizeof(CONTENT_SCAFFOLD ) )^.type_:=XML_CTYPE_NAME;
+
+ CONTENT_SCAFFOLD_ptr(
+ ptrcomp(dtd.scaffold ) +
+ myindex * sizeof(CONTENT_SCAFFOLD ) )^.quant:=quant;
+
+ el:=getElementType(parser ,enc ,s ,nxt );
+
+ if el = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ name:=el.name;
+
+ CONTENT_SCAFFOLD_ptr(
+ ptrcomp(dtd.scaffold ) +
+ myindex * sizeof(CONTENT_SCAFFOLD ) )^.name:=name;
+
+ nameLen:=0;
+
+ while XML_Char_ptr(ptrcomp(name ) + nameLen )^ <> XML_Char(0 ) do
+ inc(nameLen );
+
+ inc(dtd.contentStringLen ,nameLen );
+
+ if @parser.m_elementDeclHandler <> NIL then
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ end;
+
+ XML_ROLE_GROUP_CLOSE :
+ begin
+ quant:=XML_CQUANT_NONE;
+
+ goto closeGroup;
+
+ end;
+
+ XML_ROLE_GROUP_CLOSE_OPT :
+ begin
+ quant:=XML_CQUANT_OPT;
+
+ goto closeGroup;
+
+ end;
+
+ XML_ROLE_GROUP_CLOSE_REP :
+ begin
+ quant:=XML_CQUANT_REP;
+
+ goto closeGroup;
+
+ end;
+
+ XML_ROLE_GROUP_CLOSE_PLUS :
+ begin
+ quant:=XML_CQUANT_PLUS;
+
+ closeGroup:
+ if dtd.in_eldecl <> 0 then
+ begin
+ if @parser.m_elementDeclHandler <> NIL then
+ handleDefault:=XML_FALSE;
+
+ dec(dtd.scaffLevel );
+
+ CONTENT_SCAFFOLD_ptr(
+ ptrcomp(dtd.scaffold ) +
+ int_ptr(ptrcomp(dtd.scaffIndex ) + dtd.scaffLevel * sizeof(int ) )^ *
+ sizeof(CONTENT_SCAFFOLD) )^.quant:=quant;
+
+ if dtd.scaffLevel = 0 then
+ begin
+ if handleDefault = 0 then
+ begin
+ model:=build_model(parser );
+
+ if model = NIL then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ eventEndPP^:=s;
+
+ parser.m_elementDeclHandler(
+ parser.m_handlerArg ,
+ parser.m_declElementType.name ,model );
+
+ end;
+
+ dtd.in_eldecl :=XML_FALSE;
+ dtd.contentStringLen:=0;
+
+ end;
+
+ end;
+
+ end; { End element declaration stuff }
+
+ XML_ROLE_PI :
+ begin
+ if reportProcessingInstruction(parser ,enc ,s ,next ) = 0 then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ XML_ROLE_COMMENT :
+ begin
+ if reportComment(parser ,enc ,s ,next ) = 0 then
+ begin
+ result:=XML_ERROR_NO_MEMORY;
+
+ exit;
+
+ end;
+
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ XML_ROLE_NONE :
+ case tok of
+ XML_TOK_BOM :
+ handleDefault:=XML_FALSE;
+
+ end;
+
+ XML_ROLE_DOCTYPE_NONE :
+ if @parser.m_startDoctypeDeclHandler <> NIL then
+ handleDefault:=XML_FALSE;
+
+ XML_ROLE_ENTITY_NONE :
+ if (dtd.keepProcessing <> 0 ) and
+ (@parser.m_entityDeclHandler <> NIL ) then
+ handleDefault:=XML_FALSE;
+
+ XML_ROLE_NOTATION_NONE :
+ if @parser.m_notationDeclHandler <> NIL then
+ handleDefault:=XML_FALSE;
+
+ XML_ROLE_ATTLIST_NONE :
+ if (dtd.keepProcessing <> 0 ) and
+ (@parser.m_attlistDeclHandler <> NIL ) then
+ handleDefault:=XML_FALSE;
+
+ XML_ROLE_ELEMENT_NONE :
+ if @parser.m_elementDeclHandler <> NIL then
+ handleDefault:=XML_FALSE;
+
+ end; { end of big case }
+
+ _break:
+ if (handleDefault = XML_TRUE ) and
+ (@parser.m_defaultHandler <> NIL ) then
+ reportDefault(parser ,enc ,s ,next );
+
+ case parser.m_parsingStatus.parsing of
+ XML_SUSPENDED :
+ begin
+ nextPtr^:=next;
+ result :=XML_ERROR_NONE;
+
+ exit;
+
+ end;
+
+ XML_FINISHED :
+ begin
+ result:=XML_ERROR_ABORTED;
+
+ exit;
+
+ end;
+
+ else
+ begin
+ s :=next;
+ tok:=XmlPrologTok(enc ,pointer(s ) ,pointer(end_ ) ,@next );
+
+ end;
+
+ end;
+
+ until false;
+
+{ not reached }
+
+end;
+
+{ prologProcessor }
+function prologProcessor(parser : XML_Parser; s ,end_ : char_ptr; nextPtr : char_ptr_ptr ) : XML_Error;
+var
+ next : char_ptr;
+ tok : int;
+
+begin
+ next:=s;
+ tok :=XmlPrologTok(parser.m_encoding ,pointer(s ) ,pointer(end_ ) ,@next );
+
+ result:=
+ doProlog(
+ parser ,parser.m_encoding ,s ,end_ ,tok ,next ,
+ nextPtr ,XML_Bool(not parser.m_parsingStatus.finalBuffer ) );
+
+end;
+
+{ prologInitProcessor }
+function prologInitProcessor(parser : XML_Parser; s ,end_ : char_ptr; nextPtr : char_ptr_ptr ) : XML_Error;
+var
+ result_ : XML_Error;
+
+begin
+ result_:=initializeEncoding(parser );
+
+ if result_ <> XML_ERROR_NONE then
+ begin
+ result:=result_;
+
+ exit;
+
+ end;
+
+ parser.m_processor:=@prologProcessor;
+
+ result:=prologProcessor(parser ,s ,end_ ,nextPtr );
+
+end;
+
+{ parserInit }
+procedure parserInit(parser : XML_Parser; encodingName : XML_Char_ptr );
+begin
+ parser.m_processor:=@prologInitProcessor;
+
+ XmlPrologStateInit(@parser.m_prologState );
+
+ if encodingName <> NIL then
+ parser.m_protocolEncodingName:=poolCopyString(@parser.m_tempPool ,encodingName )
+ else
+ parser.m_protocolEncodingName:=NIL;
+
+ parser.m_curBase:=NIL;
+
+ XmlInitEncoding(@parser.m_initEncoding ,@parser.m_encoding ,0 );
+
+ parser.m_userData :=NIL;
+ parser.m_handlerArg:=NIL;
+
+ parser.m_startElementHandler :=NIL;
+ parser.m_endElementHandler :=NIL;
+ parser.m_characterDataHandler :=NIL;
+ parser.m_processingInstructionHandler:=NIL;
+ parser.m_commentHandler :=NIL;
+ parser.m_startCdataSectionHandler :=NIL;
+ parser.m_endCdataSectionHandler :=NIL;
+ parser.m_defaultHandler :=NIL;
+ parser.m_startDoctypeDeclHandler :=NIL;
+ parser.m_endDoctypeDeclHandler :=NIL;
+ parser.m_unparsedEntityDeclHandler :=NIL;
+ parser.m_notationDeclHandler :=NIL;
+ parser.m_startNamespaceDeclHandler :=NIL;
+ parser.m_endNamespaceDeclHandler :=NIL;
+ parser.m_notStandaloneHandler :=NIL;
+ parser.m_externalEntityRefHandler :=NIL;
+ parser.m_externalEntityRefHandlerArg :=parser;
+ parser.m_skippedEntityHandler :=NIL;
+ parser.m_elementDeclHandler :=NIL;
+ parser.m_attlistDeclHandler :=NIL;
+ parser.m_entityDeclHandler :=NIL;
+ parser.m_xmlDeclHandler :=NIL;
+
+ parser.m_bufferPtr:=parser.m_buffer;
+ parser.m_bufferEnd:=parser.m_buffer;
+
+ parser.m_parseEndByteIndex:=0;
+ parser.m_parseEndPtr :=NIL;
+
+ parser.m_declElementType:=NIL;
+ parser.m_declAttributeId:=NIL;
+ parser.m_declEntity :=NIL;
+
+ parser.m_doctypeName :=NIL;
+ parser.m_doctypeSysid:=NIL;
+ parser.m_doctypePubid:=NIL;
+
+ parser.m_declAttributeType :=NIL;
+ parser.m_declNotationName :=NIL;
+ parser.m_declNotationPublicId:=NIL;
+ parser.m_declAttributeIsCdata:=XML_FALSE;
+ parser.m_declAttributeIsId :=XML_FALSE;
+
+ fillchar(parser.m_position ,sizeof(POSITION ) ,0 );
+
+ parser.m_errorCode:=XML_ERROR_NONE;
+
+ parser.m_eventPtr :=NIL;
+ parser.m_eventEndPtr:=NIL;
+ parser.m_positionPtr:=NIL;
+
+ parser.m_openInternalEntities :=NIL;
+ parser.m_defaultExpandInternalEntities:=XML_TRUE;
+
+ parser.m_tagLevel :=0;
+ parser.m_tagStack :=NIL;
+ parser.m_inheritedBindings:=NIL;
+ parser.m_nSpecifiedAtts :=0;
+
+ parser.m_unknownEncodingMem :=NIL;
+ parser.m_unknownEncodingRelease:=NIL;
+ parser.m_unknownEncodingData :=NIL;
+ parser.m_unknownEncodingAlloc :=0;
+
+ parser.m_parentParser :=NIL;
+ parser.m_parsingStatus.parsing:=XML_INITIALIZED;
+
+{$IFDEF XML_DTD }
+ parser.m_isParamEntity:=XML_FALSE;
+ parser.m_useForeignDTD:=XML_FALSE;
+
+ parser.m_paramEntityParsing:=XML_PARAM_ENTITY_PARSING_NEVER;
+
+{$ENDIF }
+
+end;
+
+{ parserCreate }
+function parserCreate(
+ encodingName : XML_Char_ptr;
+ memsuite : XML_Memory_Handling_Suite_ptr;
+ nameSep : XML_Char_ptr;
+ dtd : DTD_ptr ) : XML_Parser;
+var
+ parser : XML_Parser;
+ mtemp : XML_Memory_Handling_Suite_ptr;
+
+begin
+ parser:=NIL;
+
+ if memsuite <> NIL then
+ begin
+ memsuite.malloc_fcn(pointer(parser ) ,sizeof(XML_ParserStruct ) );
+
+ if parser <> NIL then
+ begin
+ mtemp:=@parser.m_mem;
+
+ mtemp.malloc_fcn :=memsuite.malloc_fcn;
+ mtemp.realloc_fcn:=memsuite.realloc_fcn;
+ mtemp.free_fcn :=memsuite.free_fcn;
+
+ end;
+
+ end
+ else
+ begin
+ expat_getmem(pointer(parser ) ,sizeof(XML_ParserStruct ) );
+
+ if parser <> NIL then
+ begin
+ mtemp:=@parser.m_mem;
+
+ mtemp.malloc_fcn :=@expat_getmem;
+ mtemp.realloc_fcn:=@expat_realloc;
+ mtemp.free_fcn :=@expat_freemem;
+
+ end;
+
+ end;
+
+ if parser = NIL then
+ begin
+ result:=NIL;
+
+ exit;
+
+ end;
+
+ parser.m_buffer :=NIL;
+ parser.m_bufferLim:=NIL;
+ parser.m_attsSize :=INIT_ATTS_SIZE;
+
+ parser.m_attsAlloc :=0;
+ parser.m_nsAttsAlloc:=0;
+
+ parser.m_mem.malloc_fcn(pointer(parser.m_atts ) ,parser.m_attsSize * sizeof(ATTRIBUTE ) );
+
+ if parser.m_atts = NIL then
+ begin
+ parser.m_mem.free_fcn(pointer(parser ) ,sizeof(XML_ParserStruct ) );
+
+ result:=NIL;
+
+ exit;
+
+ end
+ else
+ parser.m_attsAlloc:=parser.m_attsSize * sizeof(ATTRIBUTE );
+
+ parser.m_mem.malloc_fcn(pointer(parser.m_dataBuf ) ,INIT_DATA_BUF_SIZE * sizeof(XML_Char ) );
+
+ if parser.m_dataBuf = NIL then
+ begin
+ parser.m_mem.free_fcn(pointer(parser.m_atts ) ,parser.m_attsAlloc );
+ parser.m_mem.free_fcn(pointer(parser ) ,sizeof(XML_ParserStruct ) );
+
+ result:=NIL;
+
+ exit;
+
+ end;
+
+ parser.m_dataBufEnd:=XML_Char_ptr(ptrcomp(parser.m_dataBuf ) + INIT_DATA_BUF_SIZE );
+
+ if dtd <> NIL then
+ parser.m_dtd:=dtd
+ else
+ begin
+ parser.m_dtd:=dtdCreate(@parser.m_mem );
+
+ if parser.m_dtd = NIL then
+ begin
+ parser.m_mem.free_fcn(pointer(parser.m_dataBuf ) ,INIT_DATA_BUF_SIZE * sizeof(XML_Char ) );
+ parser.m_mem.free_fcn(pointer(parser.m_atts ) ,parser.m_attsAlloc );
+ parser.m_mem.free_fcn(pointer(parser ) ,sizeof(XML_ParserStruct ) );
+
+ result:=NIL;
+
+ exit;
+
+ end;
+
+ end;
+
+ parser.m_freeBindingList :=NIL;
+ parser.m_freeTagList :=NIL;
+ parser.m_freeInternalEntities:=NIL;
+
+ parser.m_groupSize :=0;
+ parser.m_groupAlloc :=0;
+ parser.m_groupConnector:=NIL;
+
+ parser.m_unknownEncodingHandler :=NIL;
+ parser.m_unknownEncodingHandlerData:=NIL;
+
+ parser.m_namespaceSeparator:='!';
+
+ parser.m_ns :=XML_FALSE;
+ parser.m_ns_triplets:=XML_FALSE;
+
+ parser.m_nsAtts :=NIL;
+ parser.m_nsAttsVersion:=0;
+ parser.m_nsAttsPower :=0;
+
+ poolInit (@parser.m_tempPool ,@parser.m_mem );
+ poolInit (@parser.m_temp2Pool ,@parser.m_mem );
+ parserInit(parser ,encodingName );
+
+ if (encodingName <> NIL ) and
+ (parser.m_protocolEncodingName = NIL ) then
+ begin
+ XML_ParserFree(parser );
+
+ result:=NIL;
+
+ exit;
+
+ end;
+
+ if nameSep <> NIL then
+ begin
+ parser.m_ns:=XML_TRUE;
+
+ parser.m_internalEncoding :=XmlGetInternalEncodingNS;
+ parser.m_namespaceSeparator:=nameSep^;
+
+ end
+ else
+ parser.m_internalEncoding:=XmlGetInternalEncoding;
+
+ result:=parser;
+
+end;
+
+{ setContext {..}
+function setContext(parser : XML_Parser; context : XML_Char_ptr ) : XML_Bool;
+begin
+end;
+
+{ XML_PARSERCREATE }
+function XML_ParserCreate;
+begin
+ result:=XML_ParserCreate_MM(encoding ,NIL ,NIL );
+
+end;
+
+{ XML_PARSER_CREATE_MM }
+function XML_ParserCreate_MM;
+var
+ parser : XML_Parser;
+
+begin
+ parser:=parserCreate(encoding ,memsuite ,namespaceSeparator ,NIL );
+
+ if (parser <> NIL ) and
+ (parser.m_ns <> 0 ) then
+ { implicit context only set for root parser, since child
+ parsers (i.e. external entity parsers) will inherit it }
+ if not setContext(parser ,@implicitContext[0 ] ) <> 0 then
+ begin
+ XML_ParserFree(parser );
+
+ result:=NIL;
+
+ exit;
+
+ end;
+
+ result:=parser;
+
+end;
+
+{ XML_SETUSERDATA }
+procedure XML_SetUserData;
+begin
+ if parser.m_handlerArg = parser.m_userData then
+ begin
+ parser.m_handlerArg:=userData;
+ parser.m_userData :=userData;
+
+ end
+ else
+ parser.m_userData:=userData;
+
+end;
+
+{ XML_SETELEMENTHANDLER }
+procedure XML_SetElementHandler;
+begin
+ parser.m_startElementHandler:=start;
+ parser.m_endElementHandler :=end_;
+
+end;
+
+{ XML_SETCHARACTERDATAHANDLER }
+procedure XML_SetCharacterDataHandler;
+begin
+ parser.m_characterDataHandler:=handler;
+
+end;
+
+{ XML_GetBuffer }
+function XML_GetBuffer(parser : XML_Parser; len : int ) : pointer;
+var
+ neededSize ,keep ,offset ,bufferSize : int;
+
+ newBuf : char_ptr;
+
+begin
+ case parser.m_parsingStatus.parsing of
+ XML_SUSPENDED :
+ begin
+ parser.m_errorCode:=XML_ERROR_SUSPENDED;
+
+ result:=NIL;
+
+ exit;
+
+ end;
+
+ XML_FINISHED :
+ begin
+ parser.m_errorCode:=XML_ERROR_FINISHED;
+
+ result:=NIL;
+
+ exit;
+
+ end;
+
+ end;
+
+ if len > ptrcomp(parser.m_bufferLim ) - ptrcomp(parser.m_bufferEnd ) then
+ begin
+ { FIXME avoid integer overflow }
+ neededSize:=len + (ptrcomp(parser.m_bufferEnd ) - ptrcomp(parser.m_bufferPtr ) );
+
+ {$IFDEF XML_CONTEXT_BYTES }
+ keep:=ptrcomp(parser.m_bufferPtr ) - ptrcomp(parser.m_buffer );
+
+ if keep > _XML_CONTEXT_BYTES then
+ keep:=_XML_CONTEXT_BYTES;
+
+ inc(neededSize ,keep );
+
+ {$ENDIF }
+
+ if neededSize <= ptrcomp(parser.m_bufferLim ) - ptrcomp(parser.m_buffer ) then
+ begin
+ {$IFDEF XML_CONTEXT_BYTES }
+ if keep < ptrcomp(parser.m_bufferPtr ) - ptrcomp(parser.m_buffer ) then
+ begin
+ offset:=ptrcomp(parser.m_bufferPtr ) - ptrcomp(parser.m_buffer ) - keep;
+
+ move(
+ char_ptr(ptrcomp(parser.m_buffer ) + offset )^ ,
+ parser.m_buffer^ ,
+ ptrcomp(parser.m_bufferEnd ) - ptrcomp(parser.m_bufferPtr ) + keep );
+
+ dec(ptrcomp(parser.m_bufferEnd ) ,offset );
+ dec(ptrcomp(parser.m_bufferPtr ) ,offset );
+
+ end;
+
+ {$ELSE }
+ move(
+ parser.m_bufferPtr^ ,
+ parser.m_buffer^ ,
+ ptrcomp(parser.m_bufferEnd ) - ptrcomp(parser.m_bufferPtr ) );
+
+ parser.m_bufferEnd:=char_ptr(ptrcomp(parser.m_buffer ) + (ptrcomp(parser.m_bufferEnd ) - ptrcomp(parser.m_bufferPtr ) ) );
+ parser.m_bufferPtr:=parser.m_buffer;
+
+ {$ENDIF }
+
+ end
+ else
+ begin
+ bufferSize:=ptrcomp(parser.m_bufferLim ) - ptrcomp(parser.m_bufferPtr );
+
+ if bufferSize = 0 then
+ bufferSize:=INIT_BUFFER_SIZE;
+
+ repeat
+ bufferSize:=bufferSize * 2;
+
+ until bufferSize >= neededSize;
+
+ parser.m_mem.malloc_fcn(pointer(newBuf ) ,bufferSize );
+
+ if newBuf = NIL then
+ begin
+ parser.m_errorCode:=XML_ERROR_NO_MEMORY;
+
+ result:=NIL;
+
+ exit;
+
+ end;
+
+ parser.m_bufferLim :=char_ptr(ptrcomp(newBuf ) + bufferSize );
+
+ {$IFDEF XML_CONTEXT_BYTES }
+ if parser.m_bufferPtr <> NIL then
+ begin
+ keep:=ptrcomp(parser.m_bufferPtr ) - ptrcomp(parser.m_buffer );
+
+ if keep > _XML_CONTEXT_BYTES then
+ keep:=_XML_CONTEXT_BYTES;
+
+ move(
+ char_ptr(ptrcomp(parser.m_bufferPtr ) - keep )^ ,
+ newBuf^ ,
+ ptrcomp(parser.m_bufferEnd ) - ptrcomp(parser.m_bufferPtr ) + keep );
+
+ expat_freemem(pointer(parser.m_buffer ) ,parser.m_bufferAloc );
+
+ parser.m_buffer :=newBuf;
+ parser.m_bufferAloc:=bufferSize;
+
+ parser.m_bufferEnd:=
+ char_ptr(
+ ptrcomp(parser.m_buffer ) +
+ (ptrcomp(parser.m_bufferEnd ) - ptrcomp(parser.m_bufferPtr ) ) +
+ keep );
+
+ parser.m_bufferPtr:=char_ptr(ptrcomp(parser.m_buffer ) + keep );
+
+ end
+ else
+ begin
+ parser.m_bufferEnd :=char_ptr(ptrcomp(newBuf ) + (ptrcomp(parser.m_bufferEnd ) - ptrcomp(parser.m_bufferPtr ) ) );
+ parser.m_buffer :=newBuf;
+ parser.m_bufferPtr :=newBuf;
+ parser.m_bufferAloc:=bufferSize;
+
+ end;
+
+ {$ELSE }
+ if parser.m_bufferPtr <> NIL then
+ begin
+ move(
+ parser.m_bufferPtr^ ,
+ newBuf^ ,
+ ptrcomp(parser.m_bufferEnd ) - ptrcomp(parser.m_bufferPtr ) );
+
+ expat_freemem(pointer(parser.m_buffer ) ,parser.m_bufferAloc );
+
+ end;
+
+ parser.m_bufferEnd :=char_ptr(ptrcomp(newBuf ) + (ptrcomp(parser.m_bufferEnd ) - ptrcomp(parser.m_bufferPtr ) ) );
+ parser.m_buffer :=newBuf;
+ parser.m_bufferPtr :=newBuf;
+ parser.m_bufferAloc:=bufferSize;
+
+ {$ENDIF }
+
+ end;
+
+ end;
+
+ result:=parser.m_bufferEnd;
+
+end;
+
+{ errorProcessor }
+function errorProcessor(parser : XML_Parser; s ,end_ : char_ptr; nextPtr : char_ptr_ptr ) : XML_Error;
+begin
+ result:=parser.m_errorCode;
+
+end;
+
+{ XML_ParseBuffer }
+function XML_ParseBuffer(parser : XML_Parser; len ,isFinal : int ) : XML_Status;
+var
+ start : char_ptr;
+ result_ : XML_Status;
+
+begin
+ result_:=XML_STATUS_OK;
+
+ case parser.m_parsingStatus.parsing of
+ XML_SUSPENDED :
+ begin
+ parser.m_errorCode:=XML_ERROR_SUSPENDED;
+
+ result:=XML_STATUS_ERROR;
+
+ exit;
+
+ end;
+
+ XML_FINISHED :
+ begin
+ parser.m_errorCode:=XML_ERROR_FINISHED;
+
+ result:=XML_STATUS_ERROR;
+
+ exit;
+
+ end;
+
+ else
+ parser.m_parsingStatus.parsing:=XML_PARSING_;
+
+ end;
+
+ start :=parser.m_bufferPtr;
+ parser.m_positionPtr:=start;
+
+ inc(ptrcomp(parser.m_bufferEnd ) ,len );
+
+ parser.m_parseEndPtr:=parser.m_bufferEnd;
+
+ inc(ptrcomp(parser.m_parseEndByteIndex ) ,len );
+
+ parser.m_parsingStatus.finalBuffer:=XML_Bool(isFinal );
+
+ parser.m_errorCode:=parser.m_processor(parser ,start ,parser.m_parseEndPtr ,@parser.m_bufferPtr );
+
+ if parser.m_errorCode <> XML_ERROR_NONE then
+ begin
+ parser.m_eventEndPtr:=parser.m_eventPtr;
+ parser.m_processor :=@errorProcessor;
+
+ result:=XML_STATUS_ERROR;
+
+ exit;
+
+ end
+ else
+ case parser.m_parsingStatus.parsing of
+ XML_SUSPENDED :
+ result_:=XML_STATUS_SUSPENDED;
+
+ XML_INITIALIZED ,XML_PARSING_ :
+ if isFinal <> 0 then
+ begin
+ parser.m_parsingStatus.parsing:=XML_FINISHED;
+
+ result:=result_;
+
+ exit;
+
+ end;
+
+ else
+ { should not happen }
+ NoP;
+
+ end;
+
+ parser.m_encoding.updatePosition(
+ parser.m_encoding ,
+ pointer(parser.m_positionPtr ) ,
+ pointer(parser.m_bufferPtr ) ,@parser.m_position );
+
+ parser.m_positionPtr:=parser.m_bufferPtr;
+
+ result:=result_;
+
+end;
+
+{ XML_PARSE {..}
+function XML_Parse;
+var
+ buff : pointer;
+
+begin
+ case parser.m_parsingStatus.parsing of
+ XML_SUSPENDED :
+ begin
+ parser.m_errorCode:=XML_ERROR_SUSPENDED;
+
+ result:=XML_STATUS_ERROR;
+
+ exit;
+
+ end;
+
+ XML_FINISHED :
+ begin
+ parser.m_errorCode:=XML_ERROR_FINISHED;
+
+ result:=XML_STATUS_ERROR;
+
+ exit;
+
+ end;
+
+ else
+ parser.m_parsingStatus.parsing:=XML_PARSING_;
+
+ end;
+
+ if len = 0 then
+ begin
+ NoP;
+
+ end
+{$IFNDEF XML_CONTEXT_BYTES }
+ else
+ if parser.m_bufferPtr = parser.m_bufferEnd then
+ begin
+ NoP;
+
+ end
+
+{$ENDIF }
+ else
+ begin
+ buff:=XML_GetBuffer(parser ,len );
+
+ if buff = NIL then
+ result:=XML_STATUS_ERROR
+
+ else
+ begin
+ move(s^ ,buff^ ,len );
+
+ result:=XML_ParseBuffer(parser ,len ,isFinal );
+
+ end;
+
+ end;
+
+end;
+
+{ XML_GETERRORCODE {..}
+function XML_GetErrorCode;
+begin
+end;
+
+{ XML_ERRORSTRING {..}
+function XML_ErrorString;
+begin
+end;
+
+{ XML_GETCURRENTLINENUMBER {..}
+function XML_GetCurrentLineNumber;
+begin
+end;
+
+{ destroyBindings }
+procedure destroyBindings(bindings : BINDING_ptr; parser : XML_Parser );
+var
+ b : BINDING_ptr;
+
+begin
+ repeat
+ b:=bindings;
+
+ if b = NIL then
+ break;
+
+ bindings:=b.nextTagBinding;
+
+ parser.m_mem.free_fcn(pointer(b.uri ) ,b.uriAlloc );
+ parser.m_mem.free_fcn(pointer(b ) ,sizeof(expat.BINDING ) );
+
+ until false;
+
+end;
+
+{ XML_PARSERFREE }
+procedure XML_ParserFree;
+var
+ tagList ,p : TAG_ptr;
+
+ entityList ,openEntity : OPEN_INTERNAL_ENTITY_ptr;
+
+begin
+ if parser = NIL then
+ exit;
+
+{ free tagStack and freeTagList }
+ tagList:=parser.m_tagStack;
+
+ repeat
+ if tagList = NIL then
+ begin
+ if parser.m_freeTagList = NIL then
+ break;
+
+ tagList:=parser.m_freeTagList;
+
+ parser.m_freeTagList:=NIL;
+
+ end;
+
+ p :=tagList;
+ tagList:=tagList.parent;
+
+ parser.m_mem.free_fcn(pointer(p.buf ) ,p.alloc );
+ destroyBindings (p.bindings ,parser );
+ parser.m_mem.free_fcn(pointer(p ) ,sizeof(expat.TAG ) );
+
+ until false;
+
+{ free openInternalEntities and freeInternalEntities }
+ entityList:=parser.m_openInternalEntities;
+
+ repeat
+ if entityList = NIL then
+ begin
+ if parser.m_freeInternalEntities = NIL then
+ break;
+
+ entityList:=parser.m_freeInternalEntities;
+
+ parser.m_freeInternalEntities:=NIL;
+
+ end;
+
+ openEntity:=entityList;
+ entityList:=entityList.next;
+
+ parser.m_mem.free_fcn(pointer(openEntity ) ,sizeof(OPEN_INTERNAL_ENTITY ) );
+
+ until false;
+
+ destroyBindings(parser.m_freeBindingList ,parser );
+ destroyBindings(parser.m_inheritedBindings ,parser );
+
+ poolDestroy(@parser.m_tempPool );
+ poolDestroy(@parser.m_temp2Pool );
+
+{$IFDEF XML_DTD }
+{ external parameter entity parsers share the DTD structure
+ parser->m_dtd with the root parser, so we must not destroy it }
+ if (parser.m_isParamEntity = 0 ) and
+ (parser.m_dtd <> NIL ) then
+{$ELSE }
+ if parser.m_dtd <> NIL then{$ENDIF }
+ dtdDestroy(parser.m_dtd ,XML_Bool(parser.m_parentParser = NIL ),@parser.m_mem );
+
+ parser.m_mem.free_fcn(pointer(parser.m_atts ) ,parser.m_attsAlloc );
+ parser.m_mem.free_fcn(pointer(parser.m_groupConnector ) ,parser.m_groupAlloc );
+ parser.m_mem.free_fcn(pointer(parser.m_buffer ) ,parser.m_bufferAloc );
+ parser.m_mem.free_fcn(pointer(parser.m_dataBuf ) ,INIT_DATA_BUF_SIZE * sizeof(XML_Char ) );
+ parser.m_mem.free_fcn(pointer(parser.m_nsAtts ) ,parser.m_nsAttsAlloc );
+ parser.m_mem.free_fcn(pointer(parser.m_unknownEncodingMem ) ,parser.m_unknownEncodingAlloc );
+
+ if @parser.m_unknownEncodingRelease <> NIL then
+ parser.m_unknownEncodingRelease(parser.m_unknownEncodingData );
+
+ parser.m_mem.free_fcn(pointer(parser ) ,sizeof(XML_ParserStruct ) );
+
+end;
+
diff --git a/src/corelib/render/software/agg-demos/expat-pas/xmlrole.pas b/src/corelib/render/software/agg-demos/expat-pas/xmlrole.pas
index 0acdb28a..f4606bb6 100755..100644
--- a/src/corelib/render/software/agg-demos/expat-pas/xmlrole.pas
+++ b/src/corelib/render/software/agg-demos/expat-pas/xmlrole.pas
@@ -1,659 +1,659 @@
-//----------------------------------------------------------------------------
-// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
-// and Clark Cooper
-// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
-//
-// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
-// Pascal Port By: Milan Marusinec alias Milano
-// milan@marusinec.sk
-// http://www.pasports.org/pasexpat
-// Copyright (c) 2006
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// [Pascal Port History] -----------------------------------------------------
-//
-// 10.05.2006-Milano: Unit port establishment
-// 08.06.2006-Milano: porting
-//
-{ xmlrole.pas }
-unit
- xmlrole ;
-
-INTERFACE
-
-uses
- expat_basics ,
- expat_external ,
- xmltok ;
-
-{$I expat_mode.inc }
-
-{ TYPES DEFINITION }
-const
- XML_ROLE_ERROR = -1;
- XML_ROLE_NONE = 0;
- XML_ROLE_XML_DECL = XML_ROLE_NONE + 1;
- XML_ROLE_INSTANCE_START = XML_ROLE_XML_DECL + 1;
- XML_ROLE_DOCTYPE_NONE = XML_ROLE_INSTANCE_START + 1;
- XML_ROLE_DOCTYPE_NAME = XML_ROLE_DOCTYPE_NONE + 1;
- XML_ROLE_DOCTYPE_SYSTEM_ID = XML_ROLE_DOCTYPE_NAME + 1;
- XML_ROLE_DOCTYPE_PUBLIC_ID = XML_ROLE_DOCTYPE_SYSTEM_ID + 1;
- XML_ROLE_DOCTYPE_INTERNAL_SUBSET = XML_ROLE_DOCTYPE_PUBLIC_ID + 1;
- XML_ROLE_DOCTYPE_CLOSE = XML_ROLE_DOCTYPE_INTERNAL_SUBSET + 1;
- XML_ROLE_GENERAL_ENTITY_NAME = XML_ROLE_DOCTYPE_CLOSE + 1;
- XML_ROLE_PARAM_ENTITY_NAME = XML_ROLE_GENERAL_ENTITY_NAME + 1;
- XML_ROLE_ENTITY_NONE = XML_ROLE_PARAM_ENTITY_NAME + 1;
- XML_ROLE_ENTITY_VALUE = XML_ROLE_ENTITY_NONE + 1;
- XML_ROLE_ENTITY_SYSTEM_ID = XML_ROLE_ENTITY_VALUE + 1;
- XML_ROLE_ENTITY_PUBLIC_ID = XML_ROLE_ENTITY_SYSTEM_ID + 1;
- XML_ROLE_ENTITY_COMPLETE = XML_ROLE_ENTITY_PUBLIC_ID + 1;
- XML_ROLE_ENTITY_NOTATION_NAME = XML_ROLE_ENTITY_COMPLETE + 1;
- XML_ROLE_NOTATION_NONE = XML_ROLE_ENTITY_NOTATION_NAME + 1;
- XML_ROLE_NOTATION_NAME = XML_ROLE_NOTATION_NONE + 1;
- XML_ROLE_NOTATION_SYSTEM_ID = XML_ROLE_NOTATION_NAME + 1;
- XML_ROLE_NOTATION_NO_SYSTEM_ID = XML_ROLE_NOTATION_SYSTEM_ID + 1;
- XML_ROLE_NOTATION_PUBLIC_ID = XML_ROLE_NOTATION_NO_SYSTEM_ID + 1;
- XML_ROLE_ATTRIBUTE_NAME = XML_ROLE_NOTATION_PUBLIC_ID + 1;
- XML_ROLE_ATTRIBUTE_TYPE_CDATA = XML_ROLE_ATTRIBUTE_NAME + 1;
- XML_ROLE_ATTRIBUTE_TYPE_ID = XML_ROLE_ATTRIBUTE_TYPE_CDATA + 1;
- XML_ROLE_ATTRIBUTE_TYPE_IDREF = XML_ROLE_ATTRIBUTE_TYPE_ID + 1;
- XML_ROLE_ATTRIBUTE_TYPE_IDREFS = XML_ROLE_ATTRIBUTE_TYPE_IDREF + 1;
- XML_ROLE_ATTRIBUTE_TYPE_ENTITY = XML_ROLE_ATTRIBUTE_TYPE_IDREFS + 1;
- XML_ROLE_ATTRIBUTE_TYPE_ENTITIES = XML_ROLE_ATTRIBUTE_TYPE_ENTITY + 1;
- XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN = XML_ROLE_ATTRIBUTE_TYPE_ENTITIES + 1;
- XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS = XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN + 1;
- XML_ROLE_ATTRIBUTE_ENUM_VALUE = XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS + 1;
- XML_ROLE_ATTRIBUTE_NOTATION_VALUE = XML_ROLE_ATTRIBUTE_ENUM_VALUE + 1;
- XML_ROLE_ATTLIST_NONE = XML_ROLE_ATTRIBUTE_NOTATION_VALUE + 1;
- XML_ROLE_ATTLIST_ELEMENT_NAME = XML_ROLE_ATTLIST_NONE + 1;
- XML_ROLE_IMPLIED_ATTRIBUTE_VALUE = XML_ROLE_ATTLIST_ELEMENT_NAME + 1;
- XML_ROLE_REQUIRED_ATTRIBUTE_VALUE = XML_ROLE_IMPLIED_ATTRIBUTE_VALUE + 1;
- XML_ROLE_DEFAULT_ATTRIBUTE_VALUE = XML_ROLE_REQUIRED_ATTRIBUTE_VALUE + 1;
- XML_ROLE_FIXED_ATTRIBUTE_VALUE = XML_ROLE_DEFAULT_ATTRIBUTE_VALUE + 1;
- XML_ROLE_ELEMENT_NONE = XML_ROLE_FIXED_ATTRIBUTE_VALUE + 1;
- XML_ROLE_ELEMENT_NAME = XML_ROLE_ELEMENT_NONE + 1;
- XML_ROLE_CONTENT_ANY = XML_ROLE_ELEMENT_NAME + 1;
- XML_ROLE_CONTENT_EMPTY = XML_ROLE_CONTENT_ANY + 1;
- XML_ROLE_CONTENT_PCDATA = XML_ROLE_CONTENT_EMPTY + 1;
- XML_ROLE_GROUP_OPEN = XML_ROLE_CONTENT_PCDATA + 1;
- XML_ROLE_GROUP_CLOSE = XML_ROLE_GROUP_OPEN + 1;
- XML_ROLE_GROUP_CLOSE_REP = XML_ROLE_GROUP_CLOSE + 1;
- XML_ROLE_GROUP_CLOSE_OPT = XML_ROLE_GROUP_CLOSE_REP + 1;
- XML_ROLE_GROUP_CLOSE_PLUS = XML_ROLE_GROUP_CLOSE_OPT + 1;
- XML_ROLE_GROUP_CHOICE = XML_ROLE_GROUP_CLOSE_PLUS + 1;
- XML_ROLE_GROUP_SEQUENCE = XML_ROLE_GROUP_CHOICE + 1;
- XML_ROLE_CONTENT_ELEMENT = XML_ROLE_GROUP_SEQUENCE + 1;
- XML_ROLE_CONTENT_ELEMENT_REP = XML_ROLE_CONTENT_ELEMENT + 1;
- XML_ROLE_CONTENT_ELEMENT_OPT = XML_ROLE_CONTENT_ELEMENT_REP + 1;
- XML_ROLE_CONTENT_ELEMENT_PLUS = XML_ROLE_CONTENT_ELEMENT_OPT + 1;
- XML_ROLE_PI = XML_ROLE_CONTENT_ELEMENT_PLUS + 1;
- XML_ROLE_COMMENT = XML_ROLE_PI + 1;
-
-{$IFDEF XML_DTD }
- XML_ROLE_TEXT_DECL = XML_ROLE_COMMENT + 1;
- XML_ROLE_IGNORE_SECT = XML_ROLE_TEXT_DECL + 1;
- XML_ROLE_INNER_PARAM_ENTITY_REF = XML_ROLE_IGNORE_SECT + 1;
- XML_ROLE_PARAM_ENTITY_REF = XML_ROLE_INNER_PARAM_ENTITY_REF + 1;
-
-{$ELSE }
- XML_ROLE_PARAM_ENTITY_REF = XML_ROLE_COMMENT + 1;
-
-{$ENDIF }
-
-type
- PROLOG_STATE_ptr = ^PROLOG_STATE;
- PROLOG_STATE = record
- handler : function(state : PROLOG_STATE_ptr; tok : int; ptr ,end_ : char_ptr; enc : ENCODING_ptr ) : int;
-
- level : unsigned;
- role_none : int;
-
- {$IFDEF XML_DTD }
- includeLevel : unsigned;
- documentEntity ,
- inEntityValue : int;
-
- {$ENDIF }
-
- end;
-
-{ GLOBAL PROCEDURES }
- procedure XmlPrologStateInit(state : PROLOG_STATE_ptr );
- function XmlTokenRole (state : PROLOG_STATE_ptr; tok : int; ptr ,end_ : char_ptr; enc : ENCODING_ptr ) : int;
-
-
-IMPLEMENTATION
-{ LOCAL VARIABLES & CONSTANTS }
-const
-{$I ascii.inc }
-
-{ Doesn't check:
-
- that ,| are not mixed in a model group
- content of literals }
-
- KW_ANY : array[0..3 ] of char = (
- ASCII_A ,ASCII_N ,ASCII_Y ,#0 );
-
- KW_ATTLIST : array[0..7 ] of char = (
- ASCII_A ,ASCII_T ,ASCII_T ,ASCII_L ,ASCII_I ,ASCII_S ,ASCII_T ,#0 );
-
- KW_CDATA : array[0..5 ] of char = (
- ASCII_C ,ASCII_D ,ASCII_A ,ASCII_T ,ASCII_A ,#0 );
-
- KW_DOCTYPE : array[0..7 ] of char = (
- ASCII_D ,ASCII_O ,ASCII_C ,ASCII_T ,ASCII_Y ,ASCII_P ,ASCII_E ,#0 );
-
- KW_ELEMENT : array[0..7 ] of char = (
- ASCII_E ,ASCII_L ,ASCII_E ,ASCII_M ,ASCII_E ,ASCII_N ,ASCII_T ,#0 );
-
- KW_EMPTY : array[0..5 ] of char = (
- ASCII_E ,ASCII_M ,ASCII_P ,ASCII_T ,ASCII_Y ,#0 );
-
- KW_ENTITIES : array[0..8 ] of char = (
- ASCII_E ,ASCII_N ,ASCII_T ,ASCII_I ,ASCII_T ,ASCII_I ,ASCII_E ,ASCII_S ,
- #0 );
-
- KW_ENTITY : array[0..6 ] of char = (
- ASCII_E ,ASCII_N ,ASCII_T ,ASCII_I ,ASCII_T ,ASCII_Y ,#0 );
-
- KW_FIXED : array[0..5 ] of char = (
- ASCII_F ,ASCII_I ,ASCII_X ,ASCII_E ,ASCII_D ,#0 );
-
- KW_ID : array[0..2 ] of char = (
- ASCII_I ,ASCII_D ,#0 );
-
- KW_IDREF : array[0..5 ] of char = (
- ASCII_I ,ASCII_D ,ASCII_R ,ASCII_E ,ASCII_F ,#0 );
-
- KW_IDREFS : array[0..6 ] of char = (
- ASCII_I ,ASCII_D ,ASCII_R ,ASCII_E ,ASCII_F ,ASCII_S ,#0 );
-
- KW_IGNORE : array[0..6 ] of char = (
- ASCII_I ,ASCII_G ,ASCII_N ,ASCII_O ,ASCII_R ,ASCII_E ,#0 );
-
- KW_IMPLIED : array[0..7 ] of char = (
- ASCII_I ,ASCII_M ,ASCII_P ,ASCII_L ,ASCII_I ,ASCII_E ,ASCII_D ,#0 );
-
- KW_INCLUDE : array[0..7 ] of char = (
- ASCII_I ,ASCII_N ,ASCII_C ,ASCII_L ,ASCII_U ,ASCII_D ,ASCII_E ,#0 );
-
- KW_NDATA : array[0..5 ] of char = (
- ASCII_N ,ASCII_D ,ASCII_A ,ASCII_T ,ASCII_A ,#0 );
-
- KW_NMTOKEN : array[0..7 ] of char = (
- ASCII_N ,ASCII_M ,ASCII_T ,ASCII_O ,ASCII_K ,ASCII_E ,ASCII_N ,#0 );
-
- KW_NMTOKENS : array[0..8 ] of char = (
- ASCII_N ,ASCII_M ,ASCII_T ,ASCII_O ,ASCII_K ,ASCII_E ,ASCII_N ,ASCII_S ,
- #0 );
-
- KW_NOTATION : array[0..8 ] of char = (
- ASCII_N ,ASCII_O ,ASCII_T ,ASCII_A ,ASCII_T ,ASCII_I ,ASCII_O ,ASCII_N ,
- #0 );
-
- KW_PCDATA : array[0..6 ] of char = (
- ASCII_P ,ASCII_C ,ASCII_D ,ASCII_A ,ASCII_T ,ASCII_A ,#0 );
-
- KW_PUBLIC : array[0..6 ] of char = (
- ASCII_P ,ASCII_U ,ASCII_B ,ASCII_L ,ASCII_I ,ASCII_C ,#0 );
-
- KW_REQUIRED : array[0..8 ] of char = (
- ASCII_R ,ASCII_E ,ASCII_Q ,ASCII_U ,ASCII_I ,ASCII_R ,ASCII_E ,ASCII_D ,
- #0 );
-
- KW_SYSTEM : array[0..6 ] of char = (
- ASCII_S ,ASCII_Y ,ASCII_S ,ASCII_T ,ASCII_E ,ASCII_M ,#0 );
-
-
-{ UNIT IMPLEMENTATION }
-{ MIN_BYTES_PER_CHAR }
-function MIN_BYTES_PER_CHAR(enc : ENCODING_ptr ) : int;
-begin
- result:=enc.minBytesPerChar;
-
-end;
-
-{ error }
-function error(state : PROLOG_STATE_ptr; tok : int; ptr ,end_ : char_ptr; enc : ENCODING_ptr ) : int;
-begin
- result:=XML_ROLE_NONE;
-
-end;
-
-{ common {..}
-function common(state : PROLOG_STATE_ptr; tok : int ) : int;
-begin
-end;
-
-{ internalSubset {..}
-function internalSubset(state : PROLOG_STATE_ptr; tok : int; ptr ,end_ : char_ptr; enc : ENCODING_ptr ) : int;
-begin
-end;
-
-{ prolog2 }
-function prolog2(state : PROLOG_STATE_ptr; tok : int; ptr ,end_ : char_ptr; enc : ENCODING_ptr ) : int;
-begin
- case tok of
- XML_TOK_PROLOG_S :
- begin
- result:=XML_ROLE_NONE;
-
- exit;
-
- end;
-
- XML_TOK_PI :
- begin
- result:=XML_ROLE_PI;
-
- exit;
-
- end;
-
- XML_TOK_COMMENT :
- begin
- result:=XML_ROLE_COMMENT;
-
- exit;
-
- end;
-
- XML_TOK_INSTANCE_START :
- begin
- state.handler:=@error;
-
- result:=XML_ROLE_INSTANCE_START;
-
- exit;
-
- end;
-
- end;
-
- result:=common(state ,tok );
-
-end;
-
-{ doctype4 }
-function doctype4(state : PROLOG_STATE_ptr; tok : int; ptr ,end_ : char_ptr; enc : ENCODING_ptr ) : int;
-begin
- case tok of
- XML_TOK_PROLOG_S :
- begin
- result:=XML_ROLE_DOCTYPE_NONE;
-
- exit;
-
- end;
-
- XML_TOK_OPEN_BRACKET :
- begin
- state.handler:=@internalSubset;
-
- result:=XML_ROLE_DOCTYPE_INTERNAL_SUBSET;
-
- exit;
-
- end;
-
- XML_TOK_DECL_CLOSE :
- begin
- state.handler:=@prolog2;
-
- result:=XML_ROLE_DOCTYPE_CLOSE;
-
- exit;
-
- end;
-
- end;
-
- result:=common(state ,tok );
-
-end;
-
-{ doctype3 }
-function doctype3(state : PROLOG_STATE_ptr; tok : int; ptr ,end_ : char_ptr; enc : ENCODING_ptr ) : int;
-begin
- case tok of
- XML_TOK_PROLOG_S :
- begin
- result:=XML_ROLE_DOCTYPE_NONE;
-
- exit;
-
- end;
-
- XML_TOK_LITERAL :
- begin
- state.handler:=@doctype4;
-
- result:=XML_ROLE_DOCTYPE_SYSTEM_ID;
-
- exit;
-
- end;
-
- end;
-
- result:=common(state ,tok );
-
-end;
-
-{ doctype2 }
-function doctype2(state : PROLOG_STATE_ptr; tok : int; ptr ,end_ : char_ptr; enc : ENCODING_ptr ) : int;
-begin
- case tok of
- XML_TOK_PROLOG_S :
- begin
- result:=XML_ROLE_DOCTYPE_NONE;
-
- exit;
-
- end;
-
- XML_TOK_LITERAL :
- begin
- state.handler:=@doctype3;
-
- result:=XML_ROLE_DOCTYPE_PUBLIC_ID;
-
- exit;
-
- end;
-
- end;
-
- result:=common(state ,tok );
-
-end;
-
-{ doctype1 }
-function doctype1(state : PROLOG_STATE_ptr; tok : int; ptr ,end_ : char_ptr; enc : ENCODING_ptr ) : int;
-begin
- case tok of
- XML_TOK_PROLOG_S :
- begin
- result:=XML_ROLE_DOCTYPE_NONE;
-
- exit;
-
- end;
-
- XML_TOK_OPEN_BRACKET :
- begin
- state.handler:=@internalSubset;
-
- result:=XML_ROLE_DOCTYPE_INTERNAL_SUBSET;
-
- exit;
-
- end;
-
- XML_TOK_DECL_CLOSE :
- begin
- state.handler:=@prolog2;
-
- result:=XML_ROLE_DOCTYPE_CLOSE;
-
- exit;
-
- end;
-
- XML_TOK_NAME :
- begin
- if XmlNameMatchesAscii(enc ,ptr ,end_ ,@KW_SYSTEM[0 ] ) <> 0 then
- begin
- state.handler:=@doctype3;
-
- result:=XML_ROLE_DOCTYPE_NONE;
-
- exit;
-
- end;
-
- if XmlNameMatchesAscii(enc ,ptr ,end_ ,@KW_PUBLIC[0 ] ) <> 0 then
- begin
- state.handler:=@doctype2;
-
- result:=XML_ROLE_DOCTYPE_NONE;
-
- exit;
-
- end;
-
- end;
-
- end;
-
- result:=common(state ,tok );
-
-end;
-
-{ doctype0 }
-function doctype0(state : PROLOG_STATE_ptr; tok : int; ptr ,end_ : char_ptr; enc : ENCODING_ptr ) : int;
-begin
- case tok of
- XML_TOK_PROLOG_S :
- begin
- result:=XML_ROLE_DOCTYPE_NONE;
-
- exit;
-
- end;
-
- XML_TOK_NAME ,XML_TOK_PREFIXED_NAME :
- begin
- state.handler:=@doctype1;
-
- result:=XML_ROLE_DOCTYPE_NAME;
-
- exit;
-
- end;
-
- end;
-
- result:=common(state ,tok );
-
-end;
-
-{ prolog1 }
-function prolog1(state : PROLOG_STATE_ptr; tok : int; ptr ,end_ : char_ptr; enc : ENCODING_ptr ) : int;
-begin
- case tok of
- XML_TOK_PROLOG_S :
- begin
- result:=XML_ROLE_NONE;
-
- exit;
-
- end;
-
- XML_TOK_PI :
- begin
- result:=XML_ROLE_PI;
-
- exit;
-
- end;
-
- XML_TOK_COMMENT :
- begin
- result:=XML_ROLE_COMMENT;
-
- exit;
-
- end;
-
- XML_TOK_BOM :
- begin
- result:=XML_ROLE_NONE;
-
- exit;
-
- end;
-
- XML_TOK_DECL_OPEN :
- if XmlNameMatchesAscii(
- enc ,
- char_ptr(ptrcomp(ptr ) + 2 * MIN_BYTES_PER_CHAR(enc ) ) ,
- end_ ,
- @KW_DOCTYPE[0 ] ) = 0 then
- else
- begin
- state.handler:=@doctype0;
-
- result:=XML_ROLE_DOCTYPE_NONE;
-
- exit;
-
- end;
-
- XML_TOK_INSTANCE_START :
- begin
- state.handler:=@error;
-
- result:=XML_ROLE_INSTANCE_START;
-
- exit;
-
- end;
-
- end;
-
- result:=common(state ,tok );
-
-end;
-
-{ prolog0 }
-function prolog0(state : PROLOG_STATE_ptr; tok : int; ptr ,end_ : char_ptr; enc : ENCODING_ptr ) : int;
-label
- _break ;
-
-begin
- case tok of
- XML_TOK_PROLOG_S :
- begin
- state.handler:=@prolog1;
-
- result:=XML_ROLE_NONE;
-
- exit;
-
- end;
-
- XML_TOK_XML_DECL :
- begin
- state.handler:=@prolog1;
-
- result:=XML_ROLE_XML_DECL;
-
- exit;
-
- end;
-
- XML_TOK_PI :
- begin
- state.handler:=@prolog1;
-
- result:=XML_ROLE_PI;
-
- exit;
-
- end;
-
- XML_TOK_COMMENT :
- begin
- state.handler:=@prolog1;
-
- result:=XML_ROLE_COMMENT;
-
- exit;
-
- end;
-
- XML_TOK_BOM :
- begin
- result:=XML_ROLE_NONE;
-
- exit;
-
- end;
-
- XML_TOK_DECL_OPEN :
- begin
- if XmlNameMatchesAscii(
- enc ,
- char_ptr(ptrcomp(ptr ) + 2 * MIN_BYTES_PER_CHAR(enc ) ) ,
- end_ ,
- @KW_DOCTYPE[0 ] ) = 0 then
- goto _break;
-
- state.handler:=@doctype0;
-
- result:=XML_ROLE_DOCTYPE_NONE;
-
- exit;
-
- end;
-
- XML_TOK_INSTANCE_START :
- begin
- state.handler:=@error;
-
- result:=XML_ROLE_INSTANCE_START;
-
- exit;
-
- end;
-
- end;
-
-_break:
- result:=common(state ,tok );
-
-end;
-
-{ XMLPROLOGSTATEINIT }
-procedure XmlPrologStateInit;
-begin
- state.handler:=@prolog0;
-
-{$IFDEF XML_DTD }
- state.documentEntity:=1;
- state.includeLevel :=0;
- state.inEntityValue :=0;
-
-{$ENDIF }
-
-end;
-
-{ XMLTOKENROLE }
-function XmlTokenRole;
-begin
- result:=state.handler(state ,tok ,ptr ,end_ ,enc );
-
-end;
-
-END.
-
+//----------------------------------------------------------------------------
+// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+// and Clark Cooper
+// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
+//
+// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
+// Pascal Port By: Milan Marusinec alias Milano
+// milan@marusinec.sk
+// http://www.pasports.org/pasexpat
+// Copyright (c) 2006
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// [Pascal Port History] -----------------------------------------------------
+//
+// 10.05.2006-Milano: Unit port establishment
+// 08.06.2006-Milano: porting
+//
+{ xmlrole.pas }
+unit
+ xmlrole ;
+
+INTERFACE
+
+uses
+ expat_basics ,
+ expat_external ,
+ xmltok ;
+
+{$I expat_mode.inc }
+
+{ TYPES DEFINITION }
+const
+ XML_ROLE_ERROR = -1;
+ XML_ROLE_NONE = 0;
+ XML_ROLE_XML_DECL = XML_ROLE_NONE + 1;
+ XML_ROLE_INSTANCE_START = XML_ROLE_XML_DECL + 1;
+ XML_ROLE_DOCTYPE_NONE = XML_ROLE_INSTANCE_START + 1;
+ XML_ROLE_DOCTYPE_NAME = XML_ROLE_DOCTYPE_NONE + 1;
+ XML_ROLE_DOCTYPE_SYSTEM_ID = XML_ROLE_DOCTYPE_NAME + 1;
+ XML_ROLE_DOCTYPE_PUBLIC_ID = XML_ROLE_DOCTYPE_SYSTEM_ID + 1;
+ XML_ROLE_DOCTYPE_INTERNAL_SUBSET = XML_ROLE_DOCTYPE_PUBLIC_ID + 1;
+ XML_ROLE_DOCTYPE_CLOSE = XML_ROLE_DOCTYPE_INTERNAL_SUBSET + 1;
+ XML_ROLE_GENERAL_ENTITY_NAME = XML_ROLE_DOCTYPE_CLOSE + 1;
+ XML_ROLE_PARAM_ENTITY_NAME = XML_ROLE_GENERAL_ENTITY_NAME + 1;
+ XML_ROLE_ENTITY_NONE = XML_ROLE_PARAM_ENTITY_NAME + 1;
+ XML_ROLE_ENTITY_VALUE = XML_ROLE_ENTITY_NONE + 1;
+ XML_ROLE_ENTITY_SYSTEM_ID = XML_ROLE_ENTITY_VALUE + 1;
+ XML_ROLE_ENTITY_PUBLIC_ID = XML_ROLE_ENTITY_SYSTEM_ID + 1;
+ XML_ROLE_ENTITY_COMPLETE = XML_ROLE_ENTITY_PUBLIC_ID + 1;
+ XML_ROLE_ENTITY_NOTATION_NAME = XML_ROLE_ENTITY_COMPLETE + 1;
+ XML_ROLE_NOTATION_NONE = XML_ROLE_ENTITY_NOTATION_NAME + 1;
+ XML_ROLE_NOTATION_NAME = XML_ROLE_NOTATION_NONE + 1;
+ XML_ROLE_NOTATION_SYSTEM_ID = XML_ROLE_NOTATION_NAME + 1;
+ XML_ROLE_NOTATION_NO_SYSTEM_ID = XML_ROLE_NOTATION_SYSTEM_ID + 1;
+ XML_ROLE_NOTATION_PUBLIC_ID = XML_ROLE_NOTATION_NO_SYSTEM_ID + 1;
+ XML_ROLE_ATTRIBUTE_NAME = XML_ROLE_NOTATION_PUBLIC_ID + 1;
+ XML_ROLE_ATTRIBUTE_TYPE_CDATA = XML_ROLE_ATTRIBUTE_NAME + 1;
+ XML_ROLE_ATTRIBUTE_TYPE_ID = XML_ROLE_ATTRIBUTE_TYPE_CDATA + 1;
+ XML_ROLE_ATTRIBUTE_TYPE_IDREF = XML_ROLE_ATTRIBUTE_TYPE_ID + 1;
+ XML_ROLE_ATTRIBUTE_TYPE_IDREFS = XML_ROLE_ATTRIBUTE_TYPE_IDREF + 1;
+ XML_ROLE_ATTRIBUTE_TYPE_ENTITY = XML_ROLE_ATTRIBUTE_TYPE_IDREFS + 1;
+ XML_ROLE_ATTRIBUTE_TYPE_ENTITIES = XML_ROLE_ATTRIBUTE_TYPE_ENTITY + 1;
+ XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN = XML_ROLE_ATTRIBUTE_TYPE_ENTITIES + 1;
+ XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS = XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN + 1;
+ XML_ROLE_ATTRIBUTE_ENUM_VALUE = XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS + 1;
+ XML_ROLE_ATTRIBUTE_NOTATION_VALUE = XML_ROLE_ATTRIBUTE_ENUM_VALUE + 1;
+ XML_ROLE_ATTLIST_NONE = XML_ROLE_ATTRIBUTE_NOTATION_VALUE + 1;
+ XML_ROLE_ATTLIST_ELEMENT_NAME = XML_ROLE_ATTLIST_NONE + 1;
+ XML_ROLE_IMPLIED_ATTRIBUTE_VALUE = XML_ROLE_ATTLIST_ELEMENT_NAME + 1;
+ XML_ROLE_REQUIRED_ATTRIBUTE_VALUE = XML_ROLE_IMPLIED_ATTRIBUTE_VALUE + 1;
+ XML_ROLE_DEFAULT_ATTRIBUTE_VALUE = XML_ROLE_REQUIRED_ATTRIBUTE_VALUE + 1;
+ XML_ROLE_FIXED_ATTRIBUTE_VALUE = XML_ROLE_DEFAULT_ATTRIBUTE_VALUE + 1;
+ XML_ROLE_ELEMENT_NONE = XML_ROLE_FIXED_ATTRIBUTE_VALUE + 1;
+ XML_ROLE_ELEMENT_NAME = XML_ROLE_ELEMENT_NONE + 1;
+ XML_ROLE_CONTENT_ANY = XML_ROLE_ELEMENT_NAME + 1;
+ XML_ROLE_CONTENT_EMPTY = XML_ROLE_CONTENT_ANY + 1;
+ XML_ROLE_CONTENT_PCDATA = XML_ROLE_CONTENT_EMPTY + 1;
+ XML_ROLE_GROUP_OPEN = XML_ROLE_CONTENT_PCDATA + 1;
+ XML_ROLE_GROUP_CLOSE = XML_ROLE_GROUP_OPEN + 1;
+ XML_ROLE_GROUP_CLOSE_REP = XML_ROLE_GROUP_CLOSE + 1;
+ XML_ROLE_GROUP_CLOSE_OPT = XML_ROLE_GROUP_CLOSE_REP + 1;
+ XML_ROLE_GROUP_CLOSE_PLUS = XML_ROLE_GROUP_CLOSE_OPT + 1;
+ XML_ROLE_GROUP_CHOICE = XML_ROLE_GROUP_CLOSE_PLUS + 1;
+ XML_ROLE_GROUP_SEQUENCE = XML_ROLE_GROUP_CHOICE + 1;
+ XML_ROLE_CONTENT_ELEMENT = XML_ROLE_GROUP_SEQUENCE + 1;
+ XML_ROLE_CONTENT_ELEMENT_REP = XML_ROLE_CONTENT_ELEMENT + 1;
+ XML_ROLE_CONTENT_ELEMENT_OPT = XML_ROLE_CONTENT_ELEMENT_REP + 1;
+ XML_ROLE_CONTENT_ELEMENT_PLUS = XML_ROLE_CONTENT_ELEMENT_OPT + 1;
+ XML_ROLE_PI = XML_ROLE_CONTENT_ELEMENT_PLUS + 1;
+ XML_ROLE_COMMENT = XML_ROLE_PI + 1;
+
+{$IFDEF XML_DTD }
+ XML_ROLE_TEXT_DECL = XML_ROLE_COMMENT + 1;
+ XML_ROLE_IGNORE_SECT = XML_ROLE_TEXT_DECL + 1;
+ XML_ROLE_INNER_PARAM_ENTITY_REF = XML_ROLE_IGNORE_SECT + 1;
+ XML_ROLE_PARAM_ENTITY_REF = XML_ROLE_INNER_PARAM_ENTITY_REF + 1;
+
+{$ELSE }
+ XML_ROLE_PARAM_ENTITY_REF = XML_ROLE_COMMENT + 1;
+
+{$ENDIF }
+
+type
+ PROLOG_STATE_ptr = ^PROLOG_STATE;
+ PROLOG_STATE = record
+ handler : function(state : PROLOG_STATE_ptr; tok : int; ptr ,end_ : char_ptr; enc : ENCODING_ptr ) : int;
+
+ level : unsigned;
+ role_none : int;
+
+ {$IFDEF XML_DTD }
+ includeLevel : unsigned;
+ documentEntity ,
+ inEntityValue : int;
+
+ {$ENDIF }
+
+ end;
+
+{ GLOBAL PROCEDURES }
+ procedure XmlPrologStateInit(state : PROLOG_STATE_ptr );
+ function XmlTokenRole (state : PROLOG_STATE_ptr; tok : int; ptr ,end_ : char_ptr; enc : ENCODING_ptr ) : int;
+
+
+IMPLEMENTATION
+{ LOCAL VARIABLES & CONSTANTS }
+const
+{$I ascii.inc }
+
+{ Doesn't check:
+
+ that ,| are not mixed in a model group
+ content of literals }
+
+ KW_ANY : array[0..3 ] of char = (
+ ASCII_A ,ASCII_N ,ASCII_Y ,#0 );
+
+ KW_ATTLIST : array[0..7 ] of char = (
+ ASCII_A ,ASCII_T ,ASCII_T ,ASCII_L ,ASCII_I ,ASCII_S ,ASCII_T ,#0 );
+
+ KW_CDATA : array[0..5 ] of char = (
+ ASCII_C ,ASCII_D ,ASCII_A ,ASCII_T ,ASCII_A ,#0 );
+
+ KW_DOCTYPE : array[0..7 ] of char = (
+ ASCII_D ,ASCII_O ,ASCII_C ,ASCII_T ,ASCII_Y ,ASCII_P ,ASCII_E ,#0 );
+
+ KW_ELEMENT : array[0..7 ] of char = (
+ ASCII_E ,ASCII_L ,ASCII_E ,ASCII_M ,ASCII_E ,ASCII_N ,ASCII_T ,#0 );
+
+ KW_EMPTY : array[0..5 ] of char = (
+ ASCII_E ,ASCII_M ,ASCII_P ,ASCII_T ,ASCII_Y ,#0 );
+
+ KW_ENTITIES : array[0..8 ] of char = (
+ ASCII_E ,ASCII_N ,ASCII_T ,ASCII_I ,ASCII_T ,ASCII_I ,ASCII_E ,ASCII_S ,
+ #0 );
+
+ KW_ENTITY : array[0..6 ] of char = (
+ ASCII_E ,ASCII_N ,ASCII_T ,ASCII_I ,ASCII_T ,ASCII_Y ,#0 );
+
+ KW_FIXED : array[0..5 ] of char = (
+ ASCII_F ,ASCII_I ,ASCII_X ,ASCII_E ,ASCII_D ,#0 );
+
+ KW_ID : array[0..2 ] of char = (
+ ASCII_I ,ASCII_D ,#0 );
+
+ KW_IDREF : array[0..5 ] of char = (
+ ASCII_I ,ASCII_D ,ASCII_R ,ASCII_E ,ASCII_F ,#0 );
+
+ KW_IDREFS : array[0..6 ] of char = (
+ ASCII_I ,ASCII_D ,ASCII_R ,ASCII_E ,ASCII_F ,ASCII_S ,#0 );
+
+ KW_IGNORE : array[0..6 ] of char = (
+ ASCII_I ,ASCII_G ,ASCII_N ,ASCII_O ,ASCII_R ,ASCII_E ,#0 );
+
+ KW_IMPLIED : array[0..7 ] of char = (
+ ASCII_I ,ASCII_M ,ASCII_P ,ASCII_L ,ASCII_I ,ASCII_E ,ASCII_D ,#0 );
+
+ KW_INCLUDE : array[0..7 ] of char = (
+ ASCII_I ,ASCII_N ,ASCII_C ,ASCII_L ,ASCII_U ,ASCII_D ,ASCII_E ,#0 );
+
+ KW_NDATA : array[0..5 ] of char = (
+ ASCII_N ,ASCII_D ,ASCII_A ,ASCII_T ,ASCII_A ,#0 );
+
+ KW_NMTOKEN : array[0..7 ] of char = (
+ ASCII_N ,ASCII_M ,ASCII_T ,ASCII_O ,ASCII_K ,ASCII_E ,ASCII_N ,#0 );
+
+ KW_NMTOKENS : array[0..8 ] of char = (
+ ASCII_N ,ASCII_M ,ASCII_T ,ASCII_O ,ASCII_K ,ASCII_E ,ASCII_N ,ASCII_S ,
+ #0 );
+
+ KW_NOTATION : array[0..8 ] of char = (
+ ASCII_N ,ASCII_O ,ASCII_T ,ASCII_A ,ASCII_T ,ASCII_I ,ASCII_O ,ASCII_N ,
+ #0 );
+
+ KW_PCDATA : array[0..6 ] of char = (
+ ASCII_P ,ASCII_C ,ASCII_D ,ASCII_A ,ASCII_T ,ASCII_A ,#0 );
+
+ KW_PUBLIC : array[0..6 ] of char = (
+ ASCII_P ,ASCII_U ,ASCII_B ,ASCII_L ,ASCII_I ,ASCII_C ,#0 );
+
+ KW_REQUIRED : array[0..8 ] of char = (
+ ASCII_R ,ASCII_E ,ASCII_Q ,ASCII_U ,ASCII_I ,ASCII_R ,ASCII_E ,ASCII_D ,
+ #0 );
+
+ KW_SYSTEM : array[0..6 ] of char = (
+ ASCII_S ,ASCII_Y ,ASCII_S ,ASCII_T ,ASCII_E ,ASCII_M ,#0 );
+
+
+{ UNIT IMPLEMENTATION }
+{ MIN_BYTES_PER_CHAR }
+function MIN_BYTES_PER_CHAR(enc : ENCODING_ptr ) : int;
+begin
+ result:=enc.minBytesPerChar;
+
+end;
+
+{ error }
+function error(state : PROLOG_STATE_ptr; tok : int; ptr ,end_ : char_ptr; enc : ENCODING_ptr ) : int;
+begin
+ result:=XML_ROLE_NONE;
+
+end;
+
+{ common {..}
+function common(state : PROLOG_STATE_ptr; tok : int ) : int;
+begin
+end;
+
+{ internalSubset {..}
+function internalSubset(state : PROLOG_STATE_ptr; tok : int; ptr ,end_ : char_ptr; enc : ENCODING_ptr ) : int;
+begin
+end;
+
+{ prolog2 }
+function prolog2(state : PROLOG_STATE_ptr; tok : int; ptr ,end_ : char_ptr; enc : ENCODING_ptr ) : int;
+begin
+ case tok of
+ XML_TOK_PROLOG_S :
+ begin
+ result:=XML_ROLE_NONE;
+
+ exit;
+
+ end;
+
+ XML_TOK_PI :
+ begin
+ result:=XML_ROLE_PI;
+
+ exit;
+
+ end;
+
+ XML_TOK_COMMENT :
+ begin
+ result:=XML_ROLE_COMMENT;
+
+ exit;
+
+ end;
+
+ XML_TOK_INSTANCE_START :
+ begin
+ state.handler:=@error;
+
+ result:=XML_ROLE_INSTANCE_START;
+
+ exit;
+
+ end;
+
+ end;
+
+ result:=common(state ,tok );
+
+end;
+
+{ doctype4 }
+function doctype4(state : PROLOG_STATE_ptr; tok : int; ptr ,end_ : char_ptr; enc : ENCODING_ptr ) : int;
+begin
+ case tok of
+ XML_TOK_PROLOG_S :
+ begin
+ result:=XML_ROLE_DOCTYPE_NONE;
+
+ exit;
+
+ end;
+
+ XML_TOK_OPEN_BRACKET :
+ begin
+ state.handler:=@internalSubset;
+
+ result:=XML_ROLE_DOCTYPE_INTERNAL_SUBSET;
+
+ exit;
+
+ end;
+
+ XML_TOK_DECL_CLOSE :
+ begin
+ state.handler:=@prolog2;
+
+ result:=XML_ROLE_DOCTYPE_CLOSE;
+
+ exit;
+
+ end;
+
+ end;
+
+ result:=common(state ,tok );
+
+end;
+
+{ doctype3 }
+function doctype3(state : PROLOG_STATE_ptr; tok : int; ptr ,end_ : char_ptr; enc : ENCODING_ptr ) : int;
+begin
+ case tok of
+ XML_TOK_PROLOG_S :
+ begin
+ result:=XML_ROLE_DOCTYPE_NONE;
+
+ exit;
+
+ end;
+
+ XML_TOK_LITERAL :
+ begin
+ state.handler:=@doctype4;
+
+ result:=XML_ROLE_DOCTYPE_SYSTEM_ID;
+
+ exit;
+
+ end;
+
+ end;
+
+ result:=common(state ,tok );
+
+end;
+
+{ doctype2 }
+function doctype2(state : PROLOG_STATE_ptr; tok : int; ptr ,end_ : char_ptr; enc : ENCODING_ptr ) : int;
+begin
+ case tok of
+ XML_TOK_PROLOG_S :
+ begin
+ result:=XML_ROLE_DOCTYPE_NONE;
+
+ exit;
+
+ end;
+
+ XML_TOK_LITERAL :
+ begin
+ state.handler:=@doctype3;
+
+ result:=XML_ROLE_DOCTYPE_PUBLIC_ID;
+
+ exit;
+
+ end;
+
+ end;
+
+ result:=common(state ,tok );
+
+end;
+
+{ doctype1 }
+function doctype1(state : PROLOG_STATE_ptr; tok : int; ptr ,end_ : char_ptr; enc : ENCODING_ptr ) : int;
+begin
+ case tok of
+ XML_TOK_PROLOG_S :
+ begin
+ result:=XML_ROLE_DOCTYPE_NONE;
+
+ exit;
+
+ end;
+
+ XML_TOK_OPEN_BRACKET :
+ begin
+ state.handler:=@internalSubset;
+
+ result:=XML_ROLE_DOCTYPE_INTERNAL_SUBSET;
+
+ exit;
+
+ end;
+
+ XML_TOK_DECL_CLOSE :
+ begin
+ state.handler:=@prolog2;
+
+ result:=XML_ROLE_DOCTYPE_CLOSE;
+
+ exit;
+
+ end;
+
+ XML_TOK_NAME :
+ begin
+ if XmlNameMatchesAscii(enc ,ptr ,end_ ,@KW_SYSTEM[0 ] ) <> 0 then
+ begin
+ state.handler:=@doctype3;
+
+ result:=XML_ROLE_DOCTYPE_NONE;
+
+ exit;
+
+ end;
+
+ if XmlNameMatchesAscii(enc ,ptr ,end_ ,@KW_PUBLIC[0 ] ) <> 0 then
+ begin
+ state.handler:=@doctype2;
+
+ result:=XML_ROLE_DOCTYPE_NONE;
+
+ exit;
+
+ end;
+
+ end;
+
+ end;
+
+ result:=common(state ,tok );
+
+end;
+
+{ doctype0 }
+function doctype0(state : PROLOG_STATE_ptr; tok : int; ptr ,end_ : char_ptr; enc : ENCODING_ptr ) : int;
+begin
+ case tok of
+ XML_TOK_PROLOG_S :
+ begin
+ result:=XML_ROLE_DOCTYPE_NONE;
+
+ exit;
+
+ end;
+
+ XML_TOK_NAME ,XML_TOK_PREFIXED_NAME :
+ begin
+ state.handler:=@doctype1;
+
+ result:=XML_ROLE_DOCTYPE_NAME;
+
+ exit;
+
+ end;
+
+ end;
+
+ result:=common(state ,tok );
+
+end;
+
+{ prolog1 }
+function prolog1(state : PROLOG_STATE_ptr; tok : int; ptr ,end_ : char_ptr; enc : ENCODING_ptr ) : int;
+begin
+ case tok of
+ XML_TOK_PROLOG_S :
+ begin
+ result:=XML_ROLE_NONE;
+
+ exit;
+
+ end;
+
+ XML_TOK_PI :
+ begin
+ result:=XML_ROLE_PI;
+
+ exit;
+
+ end;
+
+ XML_TOK_COMMENT :
+ begin
+ result:=XML_ROLE_COMMENT;
+
+ exit;
+
+ end;
+
+ XML_TOK_BOM :
+ begin
+ result:=XML_ROLE_NONE;
+
+ exit;
+
+ end;
+
+ XML_TOK_DECL_OPEN :
+ if XmlNameMatchesAscii(
+ enc ,
+ char_ptr(ptrcomp(ptr ) + 2 * MIN_BYTES_PER_CHAR(enc ) ) ,
+ end_ ,
+ @KW_DOCTYPE[0 ] ) = 0 then
+ else
+ begin
+ state.handler:=@doctype0;
+
+ result:=XML_ROLE_DOCTYPE_NONE;
+
+ exit;
+
+ end;
+
+ XML_TOK_INSTANCE_START :
+ begin
+ state.handler:=@error;
+
+ result:=XML_ROLE_INSTANCE_START;
+
+ exit;
+
+ end;
+
+ end;
+
+ result:=common(state ,tok );
+
+end;
+
+{ prolog0 }
+function prolog0(state : PROLOG_STATE_ptr; tok : int; ptr ,end_ : char_ptr; enc : ENCODING_ptr ) : int;
+label
+ _break ;
+
+begin
+ case tok of
+ XML_TOK_PROLOG_S :
+ begin
+ state.handler:=@prolog1;
+
+ result:=XML_ROLE_NONE;
+
+ exit;
+
+ end;
+
+ XML_TOK_XML_DECL :
+ begin
+ state.handler:=@prolog1;
+
+ result:=XML_ROLE_XML_DECL;
+
+ exit;
+
+ end;
+
+ XML_TOK_PI :
+ begin
+ state.handler:=@prolog1;
+
+ result:=XML_ROLE_PI;
+
+ exit;
+
+ end;
+
+ XML_TOK_COMMENT :
+ begin
+ state.handler:=@prolog1;
+
+ result:=XML_ROLE_COMMENT;
+
+ exit;
+
+ end;
+
+ XML_TOK_BOM :
+ begin
+ result:=XML_ROLE_NONE;
+
+ exit;
+
+ end;
+
+ XML_TOK_DECL_OPEN :
+ begin
+ if XmlNameMatchesAscii(
+ enc ,
+ char_ptr(ptrcomp(ptr ) + 2 * MIN_BYTES_PER_CHAR(enc ) ) ,
+ end_ ,
+ @KW_DOCTYPE[0 ] ) = 0 then
+ goto _break;
+
+ state.handler:=@doctype0;
+
+ result:=XML_ROLE_DOCTYPE_NONE;
+
+ exit;
+
+ end;
+
+ XML_TOK_INSTANCE_START :
+ begin
+ state.handler:=@error;
+
+ result:=XML_ROLE_INSTANCE_START;
+
+ exit;
+
+ end;
+
+ end;
+
+_break:
+ result:=common(state ,tok );
+
+end;
+
+{ XMLPROLOGSTATEINIT }
+procedure XmlPrologStateInit;
+begin
+ state.handler:=@prolog0;
+
+{$IFDEF XML_DTD }
+ state.documentEntity:=1;
+ state.includeLevel :=0;
+ state.inEntityValue :=0;
+
+{$ENDIF }
+
+end;
+
+{ XMLTOKENROLE }
+function XmlTokenRole;
+begin
+ result:=state.handler(state ,tok ,ptr ,end_ ,enc );
+
+end;
+
+END.
+
diff --git a/src/corelib/render/software/agg-demos/expat-pas/xmltok.pas b/src/corelib/render/software/agg-demos/expat-pas/xmltok.pas
index 4f501777..be714e75 100755..100644
--- a/src/corelib/render/software/agg-demos/expat-pas/xmltok.pas
+++ b/src/corelib/render/software/agg-demos/expat-pas/xmltok.pas
@@ -1,1598 +1,1598 @@
-//----------------------------------------------------------------------------
-// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
-// and Clark Cooper
-// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
-//
-// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
-// Pascal Port By: Milan Marusinec alias Milano
-// milan@marusinec.sk
-// http://www.pasports.org/pasexpat
-// Copyright (c) 2006
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// [Pascal Port History] -----------------------------------------------------
-//
-// 10.05.2006-Milano: Unit port establishment
-// 17.05.2006-Milano: Interface part
-// 06.06.2006-Milano: porting
-// 07.06.2006-Milano: -"-
-// 09.06.2006-Milano: -"-
-// 22.06.2006-Milano: -"-
-//
-{ xmltok.pas }
-unit
- xmltok ;
-
-INTERFACE
-
-uses
- expat_basics ,
- expat_external ;
-
-{$I expat_mode.inc }
-
-{ CONSTANTS DEFINITION }
-const
-{ The following token may be returned by XmlContentTok }
- XML_TOK_TRAILING_RSQB = -5; { ] or ]] at the end of the scan; might be
- start of illegal ]]> sequence }
-
-{ The following tokens may be returned by both XmlPrologTok and XmlContentTok. }
- XML_TOK_NONE = -4; { The string to be scanned is empty }
- XML_TOK_TRAILING_CR = -3; { A CR at the end of the scan;
- might be part of CRLF sequence }
- XML_TOK_PARTIAL_CHAR = -2; { only part of a multibyte sequence }
- XML_TOK_PARTIAL = -1; { only part of a token }
- XML_TOK_INVALID = 0;
-
-{ The following tokens are returned by XmlContentTok; some are also
- returned by XmlAttributeValueTok, XmlEntityTok, XmlCdataSectionTok. }
- XML_TOK_START_TAG_WITH_ATTS = 1;
- XML_TOK_START_TAG_NO_ATTS = 2;
- XML_TOK_EMPTY_ELEMENT_WITH_ATTS = 3; { empty element tag <e/> }
- XML_TOK_EMPTY_ELEMENT_NO_ATTS = 4;
- XML_TOK_END_TAG = 5;
- XML_TOK_DATA_CHARS = 6;
- XML_TOK_DATA_NEWLINE = 7;
- XML_TOK_CDATA_SECT_OPEN = 8;
- XML_TOK_ENTITY_REF = 9;
- XML_TOK_CHAR_REF = 10; { numeric character reference }
-
-{ The following tokens may be returned by both XmlPrologTok and XmlContentTok. }
- XML_TOK_PI = 11; { processing instruction }
- XML_TOK_XML_DECL = 12; { XML decl or text decl }
- XML_TOK_COMMENT = 13;
- XML_TOK_BOM = 14; { Byte order mark }
-
-{ The following tokens are returned only by XmlPrologTok }
- XML_TOK_PROLOG_S = 15;
- XML_TOK_DECL_OPEN = 16; { <!foo }
- XML_TOK_DECL_CLOSE = 17; { > }
- XML_TOK_NAME = 18;
- XML_TOK_NMTOKEN = 19;
- XML_TOK_POUND_NAME = 20; { #name }
- XML_TOK_OR = 21; { | }
- XML_TOK_PERCENT = 22;
- XML_TOK_OPEN_PAREN = 23;
- XML_TOK_CLOSE_PAREN = 24;
- XML_TOK_OPEN_BRACKET = 25;
- XML_TOK_CLOSE_BRACKET = 26;
- XML_TOK_LITERAL = 27;
- XML_TOK_PARAM_ENTITY_REF = 28;
- XML_TOK_INSTANCE_START = 29;
-
-{ The following occur only in element type declarations }
- XML_TOK_NAME_QUESTION = 30; { name? }
- XML_TOK_NAME_ASTERISK = 31; { name* }
- XML_TOK_NAME_PLUS = 32; { name+ }
- XML_TOK_COND_SECT_OPEN = 33; { <![ }
- XML_TOK_COND_SECT_CLOSE = 34; { ]]> }
- XML_TOK_CLOSE_PAREN_QUESTION = 35; { )? }
- XML_TOK_CLOSE_PAREN_ASTERISK = 36; { )* }
- XML_TOK_CLOSE_PAREN_PLUS = 37; { )+ }
- XML_TOK_COMMA = 38;
-
-{ The following token is returned only by XmlAttributeValueTok }
- XML_TOK_ATTRIBUTE_VALUE_S = 39;
-
-{ The following token is returned only by XmlCdataSectionTok }
- XML_TOK_CDATA_SECT_CLOSE = 40;
-
-{ With namespace processing this is returned by XmlPrologTok for a
- name with a colon. }
- XML_TOK_PREFIXED_NAME = 41;
-
-{$IFDEF XML_DTD }
- XML_TOK_IGNORE_SECT = 42;
-
-{$ENDIF }
-
-{$IFDEF XML_DTD }
- XML_N_STATES = 4;
-
-{$ELSE }
- XML_N_STATES = 3;
-
-{$ENDIF }
-
- XML_PROLOG_STATE = 0;
- XML_CONTENT_STATE = 1;
- XML_CDATA_SECTION_STATE = 2;
-
-{$IFDEF XML_DTD }
- XML_IGNORE_SECTION_STATE = 3;
-
-{$ENDIF }
-
- XML_N_LITERAL_TYPES = 2;
- XML_ATTRIBUTE_VALUE_LITERAL = 0;
- XML_ENTITY_VALUE_LITERAL = 1;
-
-{ The size of the buffer passed to XmlUtf8Encode must be at least this. }
- XML_UTF8_ENCODE_MAX = 4;
-
-{ The size of the buffer passed to XmlUtf16Encode must be at least this. }
- XML_UTF16_ENCODE_MAX = 2;
-
-{ TYPES DEFINITION }
-type
- POSITION_ptr = ^POSITION;
- POSITION = record
- { first line and first column are 0 not 1 }
- lineNumber ,
- columnNumber : XML_Size;
-
- end;
-
- ATTRIBUTE_ptr = ^ATTRIBUTE;
- ATTRIBUTE = record
- name ,
- valuePtr ,
- valueEnd : char_ptr;
- normalized : char;
-
- end;
-
- ENCODING_ptr_ptr = ^ENCODING_ptr;
- ENCODING_ptr = ^ENCODING;
-
- SCANNER = function(p1 : ENCODING_ptr; p2 ,p3 : char_ptr; p4 : char_ptr_ptr ) : int;
-
- ENCODING = record
- scanners : array[0..XML_N_STATES - 1 ] of SCANNER;
- literalScanners : array[0..XML_N_LITERAL_TYPES - 1 ] of SCANNER;
-
- sameName : function (p1 : ENCODING_ptr; p2 ,p3 : char_ptr ) : int;
- nameMatchesAscii : function (p1 : ENCODING_ptr; p2 ,p3 ,p4 : char_ptr ) : int;
- nameLength : function (p1 : ENCODING_ptr; p2 : char_ptr ) : int;
- skipS : function (p1 : ENCODING_ptr; p2 : char_ptr ) : char_ptr;
- getAtts : function (enc : ENCODING_ptr; ptr : char_ptr; attsMax : int; atts : ATTRIBUTE_ptr ) : int;
- charRefNumber : function (enc : ENCODING_ptr; ptr : char_ptr ) : int;
- predefinedEntityName : function (p1 : ENCODING_ptr; p2 ,p3 : char_ptr ) : int;
- updatePosition : procedure(p1 : ENCODING_ptr; ptr ,end_ : char_ptr; p4 : POSITION_ptr );
- isPublicId : function (enc : ENCODING_ptr; ptr ,end_ : char_ptr; badPtr : char_ptr_ptr ) : int;
- utf8Convert : procedure(enc : ENCODING_ptr; fromP : char_ptr_ptr; fromLim : char_ptr; toP : char_ptr_ptr; toLim : char_ptr );
- utf16Convert : procedure(enc : ENCODING_ptr; fromP : char_ptr_ptr; fromLim : char_ptr; toP : int16u_ptr_ptr; toLim : int16u_ptr );
-
- minBytesPerChar : int;
-
- isUtf8 ,
- isUtf16 : char;
-
- end;
-
- INIT_ENCODING_ptr = ^INIT_ENCODING;
- INIT_ENCODING = record
- initEnc : ENCODING;
- encPtr : ENCODING_ptr_ptr;
-
- end;
-
-{ GLOBAL PROCEDURES }
- function XmlInitEncoding (p : INIT_ENCODING_ptr; encPtr : ENCODING_ptr_ptr; name : char_ptr ) : int;
- function XmlInitEncodingNS(p : INIT_ENCODING_ptr; encPtr : ENCODING_ptr_ptr; name : char_ptr ) : int;
-
- function XmlGetInternalEncoding : ENCODING_ptr;
- function XmlGetInternalEncodingNS : ENCODING_ptr;
-
- function XmlTok_ (enc : ENCODING_ptr; state : int; ptr, end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
- function XmlPrologTok (enc : ENCODING_ptr; ptr, end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
- function XmlContentTok(enc : ENCODING_ptr; ptr, end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
- function XmlIsPublicId(enc : ENCODING_ptr; ptr ,end_ : char_ptr; badPtr : char_ptr_ptr ) : int;
-
- procedure XmlUtf8Convert (enc : ENCODING_ptr; fromP : char_ptr_ptr; fromLim : char_ptr; toP : char_ptr_ptr; toLim : char_ptr );
- procedure XmlUtf16Convert(enc : ENCODING_ptr; fromP : char_ptr_ptr; fromLim : char_ptr; toP : int16u_ptr_ptr; toLim : int16u_ptr );
-
- function XmlUtf8Encode (charNumber : int; buf : char_ptr ) : int;
- function XmlUtf16Encode(charNumber : int; buf : int16u_ptr ) : int;
-
-{ This is used for performing a 2nd-level tokenization on the content
- of a literal that has already been returned by XmlTok. }
- function XmlLiteralTok (enc : ENCODING_ptr; literalType : int; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
- function XmlAttributeValueTok (enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
- function XmlEntityValueTok (enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
- function XmlSameName (enc : ENCODING_ptr; ptr1 ,ptr2 : char_ptr ) : int;
- function XmlNameMatchesAscii (enc : ENCODING_ptr; ptr1 ,end1 ,ptr2 : char_ptr ) : int;
- function XmlNameLength (enc : ENCODING_ptr; ptr : char_ptr ) : int;
- function XmlGetAttributes (enc : ENCODING_ptr; ptr : char_ptr; attsMax : int; atts : ATTRIBUTE_ptr ) : int;
- function XmlCharRefNumber (enc : ENCODING_ptr; ptr : char_ptr ) : int;
- function XmlPredefinedEntityName(enc : ENCODING_ptr; ptr ,end_ : char_ptr ) : int;
-
- function XmlParseXmlDecl(
- isGeneralTextEntity : int;
- enc : ENCODING_ptr;
- ptr ,end_ : char_ptr;
- badPtr ,versionPtr ,versionEndPtr ,encodingNamePtr : char_ptr_ptr;
- namedEncodingPtr : ENCODING_ptr_ptr;
- standalonePtr : int_ptr ) : int;
-
- function XmlParseXmlDeclNS(
- isGeneralTextEntity : int;
- enc : ENCODING_ptr;
- ptr ,end_ : char_ptr;
- badPtr ,versionPtr ,versionEndPtr ,encodingNamePtr : char_ptr_ptr;
- namedEncodingPtr : ENCODING_ptr_ptr;
- standalonePtr : int_ptr ) : int;
-
-IMPLEMENTATION
-{ LOCAL VARIABLES & CONSTANTS }
-type
- encodingFinder_func = function(enc : ENCODING_ptr; ptr ,end_ : char_ptr ) : ENCODING_ptr;
-
-const
-{$I ascii.inc }
-
- KW_version : array[0..7 ] of char = (
- ASCII_vl ,ASCII_el ,ASCII_rl ,ASCII_sl ,ASCII_il ,ASCII_ol ,ASCII_nl ,#0 );
-
- KW_encoding : array[0..8 ] of char = (
- ASCII_el ,ASCII_nl ,ASCII_cl ,ASCII_ol ,ASCII_dl ,ASCII_il ,ASCII_nl ,ASCII_gl ,#0 );
-
- KW_standalone : array[0..10 ] of char = (
- ASCII_sl ,ASCII_tl ,ASCII_al ,ASCII_nl ,ASCII_dl ,ASCII_al ,ASCII_ll ,ASCII_ol ,
- ASCII_nl ,ASCII_el ,#0 );
-
- KW_yes : array[0..3 ] of char = (ASCII_yl ,ASCII_el ,ASCII_sl ,#0 );
-
- KW_no : array[0..2 ] of char = (ASCII_nl ,ASCII_ol ,#0 );
-
-{ MINBPC }
-function MINBPC(enc : ENCODING_ptr ) : int;
-begin
-{$IFDEF XML_MIN_SIZE }
- result:=enc.minBytesPerChar;
-
-{$ELSE }
- result:=1;
-
-{$ENDIF }
-
-end;
-
-{ utf8_toUtf8 }{unicode}
-procedure utf8_toUtf8(enc : ENCODING_ptr; fromP : char_ptr_ptr; fromLim : char_ptr; toP : char_ptr_ptr; toLim : char_ptr );
-var
- to_ ,from : char_ptr;
-
-begin
-{ Avoid copying partial characters. }
- if ptrcomp(fromLim ) - ptrcomp(fromP^ ) > ptrcomp(toLim ) - ptrcomp(toP^) then
- begin
- fromLim:=char_ptr(ptrcomp(fromP^ ) + (ptrcomp(toLim ) - ptrcomp(toP^ ) ) );
-
- while ptrcomp(fromLim ) > ptrcomp(fromP^ ) do
- begin
- if int8u(char_ptr(ptrcomp(fromLim ) -1 )^ ) and $c0 <> $80 then
- break;
-
- dec(ptrcomp(fromLim ) );
-
- end;
-
- end;
-
- to_ :=toP^;
- from:=fromP^;
-
- while ptrcomp(from ) <> ptrcomp(fromLim ) do
- begin
- to_^:=from^;
-
- inc(ptrcomp(from ) );
- inc(ptrcomp(to_ ) );
-
- end;
-
- fromP^:=from;
- toP^ :=to_;
-
-end;
-
-{ utf8_toUtf16 {..}{unicode}
-procedure utf8_toUtf16(enc : ENCODING_ptr; fromP : char_ptr_ptr; fromLim : char_ptr; toP : int16u_ptr_ptr; toLim : int16u_ptr );
-begin
-end;
-
-{ sb_byteType {..}
-function sb_byteType(enc : ENCODING_ptr; p : char_ptr ) : int;
-begin
-end;
-
-{ isNever }
-function isNever(enc : ENCODING_ptr; p : char_ptr ) : int;
-begin
- result:=0;
-
-end;
-
-{ sb_byteToAscii }
-function sb_byteToAscii(enc : ENCODING_ptr; p : char_ptr ) : int;
-begin
- result:=int(p^ );
-
-end;
-
-{ sb_charMatches }
-function sb_charMatches(enc : ENCODING_ptr; p : char_ptr; c : int ) : int;
-begin
- result:=int(int(p^ ) = c );
-
-end;
-
-{ utf8_isName2 {..}
-function utf8_isName2(enc : ENCODING_ptr; p : char_ptr ) : int;
-begin
-end;
-
-{ utf8_isName3 {..}
-function utf8_isName3(enc : ENCODING_ptr; p : char_ptr ) : int;
-begin
-end;
-
-{ utf8_isNmstrt2 {..}
-function utf8_isNmstrt2(enc : ENCODING_ptr; p : char_ptr ) : int;
-begin
-end;
-
-{ utf8_isNmstrt3 {..}
-function utf8_isNmstrt3(enc : ENCODING_ptr; p : char_ptr ) : int;
-begin
-end;
-
-{ utf8_isInvalid2 {..}
-function utf8_isInvalid2(enc : ENCODING_ptr; p : char_ptr ) : int;
-begin
-end;
-
-{ utf8_isInvalid3 {..}
-function utf8_isInvalid3(enc : ENCODING_ptr; p : char_ptr ) : int;
-begin
-end;
-
-{ utf8_isInvalid4 {..}
-function utf8_isInvalid4(enc : ENCODING_ptr; p : char_ptr ) : int;
-begin
-end;
-
-{ LOCAL VARIABLES & CONSTANTS }
-type
- normal_encoding_ptr = ^normal_encoding;
- normal_encoding = record
- enc : ENCODING;
- type_ : array[0..255 ] of int8u;
-
- {$IFDEF XML_MIN_SIZE }
- byteType : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
- isNameMin : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
- isNmstrtMin : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
- byteToAscii : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
- charMatches : function(p1 : ENCODING_ptr; p2 : char_ptr; p3 : int ) : int;
-
- {$ENDIF }
- isName2 : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
- isName3 : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
- isName4 : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
- isNmstrt2 : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
- isNmstrt3 : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
- isNmstrt4 : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
- isInvalid2 : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
- isInvalid3 : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
- isInvalid4 : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
-
- end;
-
-const
- BT_NONXML = 0;
- BT_MALFORM = 1;
- BT_LT = 2;
- BT_AMP = 3;
- BT_RSQB = 4;
- BT_LEAD2 = 5;
- BT_LEAD3 = 6;
- BT_LEAD4 = 7;
- BT_TRAIL = 8;
- BT_CR = 9;
- BT_LF = 10;
- BT_GT = 11;
- BT_QUOT = 12;
- BT_APOS = 13;
- BT_EQUALS = 14;
- BT_QUEST = 15;
- BT_EXCL = 16;
- BT_SOL = 17;
- BT_SEMI = 18;
- BT_NUM = 19;
- BT_LSQB = 20;
- BT_S = 21;
- BT_NMSTRT = 22;
- BT_COLON = 23;
- BT_HEX = 24;
- BT_DIGIT = 25;
- BT_NAME = 26;
- BT_MINUS = 27;
- BT_OTHER = 28; { known not to be a name or name start character }
- BT_NONASCII = 29; { might be a name or name start character }
- BT_PERCNT = 30;
- BT_LPAR = 31;
- BT_RPAR = 32;
- BT_AST = 33;
- BT_PLUS = 34;
- BT_COMMA = 35;
- BT_VERBAR = 36;
-
- BT_COLON_ = BT_NMSTRT;
-
-{ BYTE_TYPE }
-function BYTE_TYPE(enc : ENCODING_ptr; p : char_ptr ) : int;
-begin
-{$IFDEF XML_MIN_SIZE }
- result:=normal_encoding_ptr(enc ).byteType(enc ,p );
-
-{$ELSE }
- result:=normal_encoding_ptr(enc ).type_[int8u(p^ ) ];
-
-{$ENDIF }
-
-end;
-
-{ BYTE_TO_ASCII }
-function BYTE_TO_ASCII(enc : ENCODING_ptr; p : char_ptr ) : int;
-begin
-{$IFDEF XML_MIN_SIZE }
- result:=normal_encoding_ptr(enc ).byteToAscii(enc ,p );
-
-{$ELSE }
- result:=int8u_ptr(p )^;
-
-{$ENDIF }
-
-end;
-
-{ CHAR_MATCHES }
-function CHAR_MATCHES(enc : ENCODING_ptr; p : char_ptr; c : int ) : int;
-begin
-{$IFDEF XML_MIN_SIZE }
- result:=normal_encoding_ptr(enc ).charMatches(enc ,p ,c );
-
-{$ELSE }
- result:=int(int8u_ptr(p )^ = c );
-
-{$ENDIF }
-
-end;
-
-{ IS_NAME_CHAR }
-function IS_NAME_CHAR(enc : ENCODING_ptr; p : char_ptr; n : int ) : int;
-begin
- case n of
- 2 : result:=normal_encoding_ptr(enc ).isName2(enc ,p );
- 3 : result:=normal_encoding_ptr(enc ).isName3(enc ,p );
- 4 : result:=normal_encoding_ptr(enc ).isName4(enc ,p );
-
- end;
-
-end;
-
-{ IS_NMSTRT_CHAR }
-function IS_NMSTRT_CHAR(enc : ENCODING_ptr; p : char_ptr; n : int ) : int;
-begin
- case n of
- 2 : result:=normal_encoding_ptr(enc ).isNmstrt2(enc ,p );
- 3 : result:=normal_encoding_ptr(enc ).isNmstrt3(enc ,p );
- 4 : result:=normal_encoding_ptr(enc ).isNmstrt4(enc ,p );
-
- end;
-
-end;
-
-{ IS_INVALID_CHAR }
-function IS_INVALID_CHAR(enc : ENCODING_ptr; p : char_ptr; n : int ) : int;
-begin
- case n of
- 2 : result:=normal_encoding_ptr(enc ).isInvalid2(enc ,p );
- 3 : result:=normal_encoding_ptr(enc ).isInvalid3(enc ,p );
- 4 : result:=normal_encoding_ptr(enc ).isInvalid4(enc ,p );
-
- end;
-
-end;
-
-{ IS_NAME_CHAR_MINBPC }
-function IS_NAME_CHAR_MINBPC(enc : ENCODING_ptr; p : char_ptr ) : int;
-begin
-{$IFDEF XML_MIN_SIZE }
- result:=normal_encoding_ptr(enc ).isNameMin(enc ,p );
-
-{$ELSE }
- result:=0;
-
-{$ENDIF }
-
-end;
-
-{ IS_NMSTRT_CHAR_MINBPC }
-function IS_NMSTRT_CHAR_MINBPC(enc : ENCODING_ptr; p : char_ptr ) : int;
-begin
-{$IFDEF XML_MIN_SIZE }
- result:=normal_encoding_ptr(enc ).isNmstrtMin(enc ,p );
-
-{$ELSE }
- result:=0;
-
-{$ENDIF }
-
-end;
-
-{ INIT_ENC_INDEX }
-function INIT_ENC_INDEX(enc : INIT_ENCODING_ptr ) : int;
-begin
- result:=int(enc.initEnc.isUtf16 );
-
-end;
-
-{ SET_INIT_ENC_INDEX }
-procedure SET_INIT_ENC_INDEX(enc : INIT_ENCODING_ptr; i : int );
-begin
- enc.initEnc.isUtf16:=char(i );
-
-end;
-
-{$I xmltok_impl.inc }
-
-const
-{$IFDEF XML_NS }
- utf8_encoding_ns : normal_encoding = (
- enc:(scanners :(normal_prologTok ,normal_contentTok ,normal_cdataSectionTok {$IFDEF XML_DTD },normal_ignoreSectionTok {$ENDIF } );
- literalScanners:(normal_attributeValueTok ,normal_entityValueTok );
-
- sameName :normal_sameName;
- nameMatchesAscii :normal_nameMatchesAscii;
- nameLength :normal_nameLength;
- skipS :normal_skipS;
- getAtts :normal_getAtts;
- charRefNumber :normal_charRefNumber;
- predefinedEntityName:normal_predefinedEntityName;
- updatePosition :normal_updatePosition;
- isPublicId :normal_isPublicId;
- utf8Convert :utf8_toUtf8;
- utf16Convert :utf8_toUtf16;
-
- minBytesPerChar:1;
-
- isUtf8 :#1;
- isUtf16:#0 );
- type_:({$I asciitab.inc}
- {$I utf8tab.inc});
-
- {$IFDEF XML_MIN_SIZE }
- byteType :sb_byteType;
- isNameMin :isNever;
- isNmstrtMin:isNever;
- byteToAscii:sb_byteToAscii;
- charMatches:sb_charMatches;
-
- {$ENDIF }
-
- isName2 :utf8_isName2;
- isName3 :utf8_isName3;
- isName4 :isNever;
- isNmstrt2 :utf8_isNmstrt2;
- isNmstrt3 :utf8_isNmstrt3;
- isNmstrt4 :isNever;
- isInvalid2:utf8_isInvalid2;
- isInvalid3:utf8_isInvalid3;
- isInvalid4:utf8_isInvalid4 );
-
-{$ENDIF }
-
- utf8_encoding : normal_encoding = (
- enc:(scanners :(normal_prologTok ,normal_contentTok ,normal_cdataSectionTok {$IFDEF XML_DTD },normal_ignoreSectionTok {$ENDIF } );
- literalScanners:(normal_attributeValueTok ,normal_entityValueTok );
-
- sameName :normal_sameName;
- nameMatchesAscii :normal_nameMatchesAscii;
- nameLength :normal_nameLength;
- skipS :normal_skipS;
- getAtts :normal_getAtts;
- charRefNumber :normal_charRefNumber;
- predefinedEntityName:normal_predefinedEntityName;
- updatePosition :normal_updatePosition;
- isPublicId :normal_isPublicId;
- utf8Convert :utf8_toUtf8;
- utf16Convert :utf8_toUtf16;
-
- minBytesPerChar:1;
-
- isUtf8 :#1;
- isUtf16:#0 );
- type_:({$I asciitab_bt_colon_.inc}
- {$I utf8tab.inc});
-
- {$IFDEF XML_MIN_SIZE }
- byteType :sb_byteType;
- isNameMin :isNever;
- isNmstrtMin:isNever;
- byteToAscii:sb_byteToAscii;
- charMatches:sb_charMatches;
-
- {$ENDIF }
-
- isName2 :utf8_isName2;
- isName3 :utf8_isName3;
- isName4 :isNever;
- isNmstrt2 :utf8_isNmstrt2;
- isNmstrt3 :utf8_isNmstrt3;
- isNmstrt4 :isNever;
- isInvalid2:utf8_isInvalid2;
- isInvalid3:utf8_isInvalid3;
- isInvalid4:utf8_isInvalid4 );
-
-{$IFDEF XML_NS }
- internal_utf8_encoding_ns : normal_encoding = (
- enc:(scanners :(normal_prologTok ,normal_contentTok ,normal_cdataSectionTok {$IFDEF XML_DTD },normal_ignoreSectionTok {$ENDIF } );
- literalScanners:(normal_attributeValueTok ,normal_entityValueTok );
-
- sameName :normal_sameName;
- nameMatchesAscii :normal_nameMatchesAscii;
- nameLength :normal_nameLength;
- skipS :normal_skipS;
- getAtts :normal_getAtts;
- charRefNumber :normal_charRefNumber;
- predefinedEntityName:normal_predefinedEntityName;
- updatePosition :normal_updatePosition;
- isPublicId :normal_isPublicId;
- utf8Convert :utf8_toUtf8;
- utf16Convert :utf8_toUtf16;
-
- minBytesPerChar:1;
-
- isUtf8 :#1;
- isUtf16:#0 );
- type_:({$I iasciitab.inc}
- {$I utf8tab.inc});
-
- {$IFDEF XML_MIN_SIZE }
- byteType :sb_byteType;
- isNameMin :isNever;
- isNmstrtMin:isNever;
- byteToAscii:sb_byteToAscii;
- charMatches:sb_charMatches;
-
- {$ENDIF }
-
- isName2 :utf8_isName2;
- isName3 :utf8_isName3;
- isName4 :isNever;
- isNmstrt2 :utf8_isNmstrt2;
- isNmstrt3 :utf8_isNmstrt3;
- isNmstrt4 :isNever;
- isInvalid2:utf8_isInvalid2;
- isInvalid3:utf8_isInvalid3;
- isInvalid4:utf8_isInvalid4 );
-
-{$ENDIF }
-
- internal_utf8_encoding : normal_encoding = (
- enc:(scanners :(normal_prologTok ,normal_contentTok ,normal_cdataSectionTok {$IFDEF XML_DTD },normal_ignoreSectionTok {$ENDIF } );
- literalScanners:(normal_attributeValueTok ,normal_entityValueTok );
-
- sameName :normal_sameName;
- nameMatchesAscii :normal_nameMatchesAscii;
- nameLength :normal_nameLength;
- skipS :normal_skipS;
- getAtts :normal_getAtts;
- charRefNumber :normal_charRefNumber;
- predefinedEntityName:normal_predefinedEntityName;
- updatePosition :normal_updatePosition;
- isPublicId :normal_isPublicId;
- utf8Convert :utf8_toUtf8;
- utf16Convert :utf8_toUtf16;
-
- minBytesPerChar:1;
-
- isUtf8 :#1;
- isUtf16:#0 );
- type_:({$I iasciitab_bt_colon_.inc}
- {$I utf8tab.inc});
-
- {$IFDEF XML_MIN_SIZE }
- byteType :sb_byteType;
- isNameMin :isNever;
- isNmstrtMin:isNever;
- byteToAscii:sb_byteToAscii;
- charMatches:sb_charMatches;
-
- {$ENDIF }
-
- isName2 :utf8_isName2;
- isName3 :utf8_isName3;
- isName4 :isNever;
- isNmstrt2 :utf8_isNmstrt2;
- isNmstrt3 :utf8_isNmstrt3;
- isNmstrt4 :isNever;
- isInvalid2:utf8_isInvalid2;
- isInvalid3:utf8_isInvalid3;
- isInvalid4:utf8_isInvalid4 );
-
-{$IFDEF XML_NS }
- latin1_encoding_ns : normal_encoding = ();{..}
-
-{$ENDIF }
-
- latin1_encoding : normal_encoding = ();{..}
-
-{$IFDEF XML_NS }
- ascii_encoding_ns : normal_encoding = ();{..}
-
-{$ENDIF }
-
- ascii_encoding : normal_encoding = ();{..}
-
-{$IFDEF XML_NS }
- little2_encoding_ns : normal_encoding = ();{..}
-
-{$ENDIF }
-
- little2_encoding : normal_encoding = ();{..}
-
-{$IFDEF XML_NS }
- big2_encoding_ns : normal_encoding = ();{..}
-
-{$ENDIF }
-
- big2_encoding : normal_encoding = ();{..}
-
-{ If this enumeration is changed, getEncodingIndex and encodings
- must also be changed. }
- UNKNOWN_ENC = -1;
- ISO_8859_1_ENC = 0;
- US_ASCII_ENC = 1;
- UTF_8_ENC = 2;
- UTF_16_ENC = 3;
- UTF_16BE_ENC = 4;
- UTF_16LE_ENC = 5;
- NO_ENC = 6; { must match encodingNames up to here }
-
- KW_ISO_8859_1 : array[0..10 ] of char = (
- ASCII_I ,ASCII_S ,ASCII_O ,ASCII_MINUS ,ASCII_8 ,ASCII_8 ,ASCII_5 ,ASCII_9 ,
- ASCII_MINUS ,ASCII_1 ,#0 );
-
- KW_US_ASCII : array[0..8 ] of char = (
- ASCII_U ,ASCII_S ,ASCII_MINUS ,ASCII_A ,ASCII_S ,ASCII_C ,ASCII_I ,ASCII_I ,
- #0 );
-
- KW_UTF_8 : array[0..5 ] of char = (
- ASCII_U ,ASCII_T ,ASCII_F ,ASCII_MINUS ,ASCII_8 ,#0 );
-
- KW_UTF_16 : array[0..6 ] of char = (
- ASCII_U ,ASCII_T ,ASCII_F ,ASCII_MINUS ,ASCII_1 ,ASCII_6 ,#0 );
-
- KW_UTF_16BE : array[0..8 ] of char = (
- ASCII_U ,ASCII_T ,ASCII_F ,ASCII_MINUS ,ASCII_1 ,ASCII_6 ,ASCII_B ,ASCII_E ,
- #0 );
-
- KW_UTF_16LE : array[0..8 ] of char = (
- ASCII_U ,ASCII_T ,ASCII_F ,ASCII_MINUS ,ASCII_1 ,ASCII_6 ,ASCII_L ,ASCII_E ,
- #0 );
-
-{ UNIT IMPLEMENTATION }
-{ streqci }
-function streqci(s1 ,s2 : char_ptr ) : int;
-var
- c1 ,c2 : char;
-
-begin
- repeat
- c1:=s1^;
- c2:=s2^;
-
- inc(ptrcomp(s1 ) );
- inc(ptrcomp(s2 ) );
-
- if (ASCII_al <= c1 ) and
- (c1 <= ASCII_zl ) then
- inc(byte(c1 ) ,byte(ASCII_A ) - byte(ASCII_al ) );
-
- if (ASCII_al <= c2 ) and
- (c2 <= ASCII_zl ) then
- inc(byte(c2 ) ,byte(ASCII_A ) - byte(ASCII_al ) );
-
- if c1 <> c2 then
- begin
- result:=0;
-
- exit;
-
- end;
-
- if (c1 = #0 ) or
- (c2 = #0 ) then
- break;
-
- until false;
-
- result:=1;
-
-end;
-
-{ initUpdatePosition {..}
-procedure initUpdatePosition(enc : ENCODING_ptr; ptr ,end_ : char_ptr; pos : POSITION_ptr );
-begin
-end;
-
-{ getEncodingIndex }
-function getEncodingIndex(name : char_ptr ) : int;
-const
- encodingNames : array[0..5 ] of char_ptr = (
- @KW_ISO_8859_1 ,
- @KW_US_ASCII ,
- @KW_UTF_8 ,
- @KW_UTF_16 ,
- @KW_UTF_16BE ,
- @KW_UTF_16LE );
-
-var
- i : int;
-
-begin
- if name = NIL then
- result:=NO_ENC
- else
- begin
- i:=0;
-
- while i < sizeof(encodingNames ) div sizeof(encodingNames[0 ] ) do
- begin
- if streqci(name ,encodingNames[i ] ) <> 0 then
- begin
- result:=i;
-
- exit;
-
- end;
-
- inc(i );
-
- end;
-
- result:=UNKNOWN_ENC;
-
- end;
-
-end;
-
-{ initScan }
-{ This is what detects the encoding. encodingTable maps from
- encoding indices to encodings; int8u(enc.initEnc.isUtf16 ) is the index of
- the external (protocol) specified encoding; state is
- XML_CONTENT_STATE if we're parsing an external text entity, and
- XML_PROLOG_STATE otherwise. }
-function initScan(
- encodingTable : ENCODING_ptr_ptr;
- enc : INIT_ENCODING_ptr;
- state : int;
- ptr ,end_ : char_ptr;
- nextTokPtr : char_ptr_ptr ) : int;
-var
- encPtr : ENCODING_ptr_ptr;
-
- e : int;
-
-label
- _003C ,_esc ;
-
-begin
- if ptr = end_ then
- begin
- result:=XML_TOK_NONE;
-
- exit;
-
- end;
-
- encPtr:=enc.encPtr;
-
-{ only a single byte available for auto-detection }
- if ptrcomp(ptr ) + 1 = ptrcomp(end_ ) then
- begin
- {$IFNDEF XML_DTD } { FIXME }
- { a well-formed document entity must have more than one byte }
- if state <> XML_CONTENT_STATE then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- {$ENDIF }
- { so we're parsing an external text entity... }
- { if UTF-16 was externally specified, then we need at least 2 bytes }
- case INIT_ENC_INDEX(enc ) of
- UTF_16_ENC ,UTF_16LE_ENC ,UTF_16BE_ENC :
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- end;
-
- case int8u(ptr^ ) of
- $FE ,$FF ,$EF : { possibly first byte of UTF-8 BOM }
- if (INIT_ENC_INDEX(enc ) = ISO_8859_1_ENC ) and
- (state = XML_CONTENT_STATE ) then
- else
- goto _003C;
-
- $00 ,$3C : { fall through }
- _003C:
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- end;
-
- end
- else
- case (ptrcomp(ptr^ ) shl 8 ) or int8u_ptr(ptrcomp(ptr ) + 1 )^ of
- $FEFF :
- if (INIT_ENC_INDEX(enc ) = ISO_8859_1_ENC ) and
- (state = XML_CONTENT_STATE ) then
- else
- begin
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + 2 );
- encPtr^ :=ENCODING_ptr_ptr(ptrcomp(encodingTable ) + UTF_16BE_ENC * sizeof(ENCODING_ptr ) )^;
-
- result:=XML_TOK_BOM;
-
- exit;
-
- end;
-
- { 00 3C is handled in the default case }
- $3C00 :
- if ((INIT_ENC_INDEX(enc ) = UTF_16BE_ENC ) or
- (INIT_ENC_INDEX(enc ) = UTF_16_ENC ) ) and
- (state = XML_CONTENT_STATE ) then
- else
- begin
- encPtr^:=ENCODING_ptr_ptr(ptrcomp(encodingTable ) + UTF_16LE_ENC * sizeof(ENCODING_ptr ) )^;
- result :=XmlTok_(encPtr^ ,state ,ptr ,end_ ,nextTokPtr );
-
- exit;
-
- end;
-
- $FFFE :
- if (INIT_ENC_INDEX(enc ) = ISO_8859_1_ENC ) and
- (state = XML_CONTENT_STATE ) then
- else
- begin
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + 2 );
- encPtr^ :=ENCODING_ptr_ptr(ptrcomp(encodingTable ) + UTF_16LE_ENC * sizeof(ENCODING_ptr ) )^;
-
- result:=XML_TOK_BOM;
-
- exit;
-
- end;
-
- { Maybe a UTF-8 BOM (EF BB BF) }
- { If there's an explicitly specified (external) encoding
- of ISO-8859-1 or some flavour of UTF-16
- and this is an external text entity,
- don't look for the BOM,
- because it might be a legal data. }
- $EFBB :
- begin
- if state = XML_CONTENT_STATE then
- begin
- e:=INIT_ENC_INDEX(enc );
-
- if (e = ISO_8859_1_ENC ) or
- (e = UTF_16BE_ENC ) or
- (e = UTF_16LE_ENC ) or
- (e = UTF_16_ENC ) then
- goto _esc;
-
- end;
-
- if ptrcomp(ptr ) + 2 = ptrcomp(end_ ) then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- if int8u_ptr(ptrcomp(ptr ) + 2 )^ = $BF then
- begin
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + 3 );
- encPtr^ :=ENCODING_ptr_ptr(ptrcomp(encodingTable ) + UTF_8_ENC * sizeof(ENCODING_ptr ) )^;
-
- result:=XML_TOK_BOM;
-
- exit;
-
- end;
-
- end;
-
- else
- { 0 isn't a legal data character. Furthermore a document
- entity can only start with ASCII characters. So the only
- way this can fail to be big-endian UTF-16 if it it's an
- external parsed general entity that's labelled as
- UTF-16LE. }
- if ptr^ = #0 then
- begin
- if (state = XML_CONTENT_STATE ) and
- (INIT_ENC_INDEX(enc ) = UTF_16LE_ENC ) then
- goto _esc;
-
- encPtr^:=ENCODING_ptr_ptr(ptrcomp(encodingTable ) + UTF_16BE_ENC * sizeof(ENCODING_ptr ) )^;
- result :=XmlTok_(encPtr^ ,state ,ptr ,end_ ,nextTokPtr );
-
- exit;
-
- end
- else
- { We could recover here in the case:
- - parsing an external entity
- - second byte is 0
- - no externally specified encoding
- - no encoding declaration
- by assuming UTF-16LE. But we don't, because this would mean when
- presented just with a single byte, we couldn't reliably determine
- whether we needed further bytes. }
- if int8u_ptr(ptrcomp(ptr ) + 1 )^ = 0 then
- begin
- if state = XML_CONTENT_STATE then
- goto _esc;
-
- encPtr^:=ENCODING_ptr_ptr(ptrcomp(encodingTable ) + UTF_16LE_ENC * sizeof(ENCODING_ptr ) )^;
- result :=XmlTok_(encPtr^ ,state ,ptr ,end_ ,nextTokPtr );
-
- end;
-
- end;
-
-_esc:
- encPtr^:=ENCODING_ptr_ptr(ptrcomp(encodingTable ) + INIT_ENC_INDEX(enc ) * sizeof(ENCODING_ptr ) )^;
- result :=XmlTok_(encPtr^ ,state ,ptr ,end_ ,nextTokPtr );
-
-end;
-
-{ toAscii }
-function toAscii(enc : ENCODING_ptr; ptr ,end_ : char_ptr ) : int;
-var
- buf : array[0..0 ] of char;
-
- p : char_ptr;
-
-begin
- p:=@buf[0 ];
-
- XmlUtf8Convert(enc ,@ptr ,end_ ,@p ,char_ptr(ptrcomp(p ) + 1 ) );
-
- if p = @buf[0 ] then
- result:=-1
- else
- result:=int(buf[0 ] );
-
-end;
-
-{ isSpace }
-function isSpace(c : int ) : int;
-begin
- case c of
- $20 ,$D ,$A ,$9 :
- result:=1;
-
- else
- result:=0;
-
- end;
-
-end;
-
-{ parsePseudoAttribute }
-{ Return 1 if there's just optional white space or there's an S
- followed by name=val. }
-function parsePseudoAttribute(
- enc : ENCODING_ptr;
- ptr ,end_ : char_ptr;
- namePtr ,nameEndPtr ,valPtr ,nextTokPtr : char_ptr_ptr ) : int;
-var
- c : int;
-
- open : char;
-
-begin
- if ptr = end_ then
- begin
- namePtr^:=NIL;
- result :=1;
-
- exit;
-
- end;
-
- if isSpace(toAscii(enc ,ptr ,end_ ) ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=0;
-
- exit;
-
- end;
-
- repeat
- inc(ptrcomp(ptr ) ,enc.minBytesPerChar );
-
- until isSpace(toAscii(enc ,ptr ,end_ ) ) = 0;
-
- if ptr = end_ then
- begin
- namePtr^:=NIL;
- result :=1;
-
- exit;
-
- end;
-
- namePtr^:=ptr;
-
- repeat
- c:=toAscii(enc ,ptr ,end_ );
-
- if c = -1 then
- begin
- nextTokPtr^:=ptr;
-
- result:=0;
-
- exit;
-
- end;
-
- if c = int(ASCII_EQUALS ) then
- begin
- nameEndPtr^:=ptr;
-
- break;
-
- end;
-
- if isSpace(c ) <> 0 then
- begin
- nameEndPtr^:=ptr;
-
- repeat
- inc(ptrcomp(ptr ) ,enc.minBytesPerChar );
-
- c:=toAscii(enc ,ptr ,end_ );
-
- until isSpace(c ) = 0;
-
- if c <> int(ASCII_EQUALS ) then
- begin
- nextTokPtr^:=ptr;
-
- result:=0;
-
- exit;
-
- end;
-
- break;
-
- end;
-
- inc(ptrcomp(ptr ) ,enc.minBytesPerChar );
-
- until false;
-
- if ptr = namePtr^ then
- begin
- nextTokPtr^:=ptr;
-
- result:=0;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,enc.minBytesPerChar );
-
- c:=toAscii(enc ,ptr ,end_ );
-
- while isSpace(c ) <> 0 do
- begin
- inc(ptrcomp(ptr ) ,enc.minBytesPerChar );
-
- c:=toAscii(enc ,ptr ,end_ );
-
- end;
-
- if (c <> int(ASCII_QUOT ) ) and
- (c <> int(ASCII_APOS ) ) then
- begin
- nextTokPtr^:=ptr;
-
- result:=0;
-
- exit;
-
- end;
-
- open:=char(c );
-
- inc(ptrcomp(ptr ) ,enc.minBytesPerChar );
-
- valPtr^:=ptr;
-
- repeat
- c:=toAscii(enc ,ptr ,end_ );
-
- if c = int(open ) then
- break;
-
- if not((int(ASCII_al ) <= c ) and (c <= int(ASCII_zl ) ) ) and
- not((int(ASCII_A ) <= c ) and (c <= int(ASCII_Z ) ) ) and
- not((int(ASCII_0 ) <= c ) and (c <= int(ASCII_9 ) ) ) and
- (c <> int(ASCII_PERIOD ) ) and
- (c <> int(ASCII_MINUS ) ) and
- (c <> int(ASCII_UNDERSCORE ) ) then
- begin
- nextTokPtr^:=ptr;
-
- result:=0;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,enc.minBytesPerChar );
-
- until false;
-
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + enc.minBytesPerChar );
-
- result:=1;
-
-end;
-
-{ doParseXmlDecl }
-function doParseXmlDecl(
- encodingFinder : encodingFinder_func;
- isGeneralTextEntity : int;
- enc : ENCODING_ptr;
- ptr ,end_ : char_ptr;
- badPtr ,versionPtr ,versionEndPtr ,encodingName : char_ptr_ptr;
- encoding : ENCODING_ptr_ptr;
- standalone : int_ptr ) : int;
-var
- val ,name ,nameEnd : char_ptr;
-
- c : int;
-
-begin
- val :=NIL;
- name :=NIL;
- nameEnd:=NIL;
-
- inc(ptrcomp(ptr ) ,5 * enc.minBytesPerChar );
- dec(ptrcomp(end_ ) ,2 * enc.minBytesPerChar );
-
- if (parsePseudoAttribute(enc ,ptr ,end_ ,@name ,@nameEnd ,@val ,@ptr ) = 0 ) or
- (name = NIL ) then
- begin
- badPtr^:=ptr;
- result :=0;
-
- exit;
-
- end;
-
- if XmlNameMatchesAscii(enc ,name ,nameEnd ,@KW_version[0 ] ) = 0 then
- if isGeneralTextEntity = 0 then
- begin
- badPtr^:=name;
- result :=0;
-
- exit;
-
- end
- else
- else
- begin
- if versionPtr <> NIL then
- versionPtr^:=val;
-
- if versionEndPtr <> NIL then
- versionEndPtr^:=ptr;
-
- if parsePseudoAttribute(enc ,ptr ,end_ ,@name ,@nameEnd ,@val ,@ptr ) = 0 then
- begin
- badPtr^:=ptr;
- result :=0;
-
- exit;
-
- end;
-
- if name = NIL then
- begin
- if isGeneralTextEntity <> 0 then
- begin
- { a TextDecl must have an EncodingDecl }
-
- badPtr^:=ptr;
- result :=0;
-
- exit;
-
- end;
-
- result:=1;
-
- exit;
-
- end;
-
- end;
-
- if XmlNameMatchesAscii(enc ,name ,nameEnd ,@KW_encoding[0 ] ) <> 0 then
- begin
- c:=toAscii(enc ,val ,end_ );
-
- if not((int(ASCII_al ) <= c ) and (c <= int(ASCII_zl ) ) ) and
- not((int(ASCII_A ) <= c ) and (c <= int(ASCII_Z ) ) ) then
- begin
- badPtr^:=val;
- result :=0;
-
- exit;
-
- end;
-
- if encodingName <> NIL then
- encodingName^:=val;
-
- if encoding <> NIL then
- encoding^:=encodingFinder(enc ,val ,char_ptr(ptrcomp(ptr ) - enc.minBytesPerChar ) );
-
- if parsePseudoAttribute(enc ,ptr ,end_ ,@name ,@nameEnd ,@val ,@ptr ) = 0 then
- begin
- badPtr^:=ptr;
- result :=0;
-
- exit;
-
- end;
-
- if name <> NIL then
- begin
- result:=1;
-
- exit;
-
- end;
-
- end;
-
- if (XmlNameMatchesAscii(enc ,name ,nameEnd ,@KW_standalone[0 ] ) = 0 ) or
- (isGeneralTextEntity <> 0 ) then
- begin
- badPtr^:=name;
- result :=0;
-
- exit;
-
- end;
-
- if XmlNameMatchesAscii(enc ,val ,char_ptr(ptrcomp(ptr ) - enc.minBytesPerChar ) ,@KW_yes[0 ] ) <> 0 then
- if standalone <> NIL then
- standalone^:=1
- else
- else
- if XmlNameMatchesAscii(enc ,val ,char_ptr(ptrcomp(ptr ) - enc.minBytesPerChar ) ,@KW_no[0 ] ) <> 0 then
- if standalone <> NIL then
- standalone^:=0
- else
- else
- begin
- badPtr^:=val;
- result :=0;
-
- exit;
-
- end;
-
- while isSpace(toAscii(enc ,ptr ,end_ ) ) <> 0 do
- inc(ptrcomp(ptr ) ,enc.minBytesPerChar );
-
- if ptr <> end_ then
- begin
- badPtr^:=ptr;
- result :=0;
-
- exit;
-
- end;
-
- result:=1;
-
-end;
-
-{$I xmltok_ns.inc }
-
-{ XMLTOK_ }
-function XmlTok_;
-begin
- result:=enc.scanners[state ](enc ,ptr ,end_ ,nextTokPtr );
-
-end;
-
-{ XMLPROLOGTOK }
-function XmlPrologTok;
-begin
- result:=XmlTok_(enc ,XML_PROLOG_STATE ,ptr ,end_ ,nextTokPtr );
-
-end;
-
-{ XMLCONTENTTOK }
-function XmlContentTok;
-begin
- result:=XmlTok_(enc ,XML_CONTENT_STATE ,ptr ,end_ ,nextTokPtr );
-
-end;
-
-{ XMLISPUBLICID }
-function XmlIsPublicId;
-begin
- result:=enc.isPublicId(enc ,ptr ,end_ ,badPtr );
-
-end;
-
-{ XMLUTF8CONVERT }
-procedure XmlUtf8Convert;
-begin
- enc.utf8Convert(enc ,fromP ,fromLim ,toP ,toLim );
-
-end;
-
-{ XMLUTF16CONVERT }
-procedure XmlUtf16Convert;
-begin
- enc.utf16Convert(enc ,fromP ,fromLim ,toP ,toLim );
-
-end;
-
-{ XMLUTF8ENCODE {..}{unicode}
-function XmlUtf8Encode;
-begin
-end;
-
-{ XMLUTF16ENCODE {..}{unicode}
-function XmlUtf16Encode;
-begin
-end;
-
-{ XMLLITERALTOK }
-function XmlLiteralTok;
-begin
- result:=enc.literalScanners[literalType ](enc ,ptr ,end_ ,nextTokPtr );
-
-end;
-
-{ XMLATTRIBUTEVALUETOK }
-function XmlAttributeValueTok;
-begin
- result:=XmlLiteralTok(enc ,XML_ATTRIBUTE_VALUE_LITERAL ,ptr ,end_ ,nextTokPtr );
-
-end;
-
-{ XMLENTITYVALUETOK }
-function XmlEntityValueTok;
-begin
- result:=XmlLiteralTok(enc ,XML_ENTITY_VALUE_LITERAL ,ptr ,end_ ,nextTokPtr );
-
-end;
-
-{ XMLSAMENAME }
-function XmlSameName;
-begin
- result:=enc.sameName(enc ,ptr1 ,ptr2 );
-
-end;
-
-{ XMLNAMEMATCHESASCII }
-function XmlNameMatchesAscii;
-begin
- result:=enc.nameMatchesAscii(enc ,ptr1 ,end1 ,ptr2 );
-
-end;
-
-{ XMLNAMELENGTH }
-function XmlNameLength;
-begin
- result:=enc.nameLength(enc ,ptr );
-
-end;
-
-{ XMLGETATTRIBUTES }
-function XmlGetAttributes;
-begin
- result:=enc.getAtts(enc ,ptr ,attsMax ,atts );
-
-end;
-
-{ XMLCHARREFNUMBER }
-function XmlCharRefNumber;
-begin
- result:=enc.charRefNumber(enc ,ptr );
-
-end;
-
-{ XMLPREDEFINEDENTITYNAME }
-function XmlPredefinedEntityName;
-begin
- result:=enc.predefinedEntityName(enc ,ptr ,end_ );
-
-end;
-
-{ XMLPARSEXMLDECLNS {..}
-function XmlParseXmlDeclNS;
-begin
-end;
-
-END.
-
-{unicode}
-
+//----------------------------------------------------------------------------
+// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+// and Clark Cooper
+// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
+//
+// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
+// Pascal Port By: Milan Marusinec alias Milano
+// milan@marusinec.sk
+// http://www.pasports.org/pasexpat
+// Copyright (c) 2006
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// [Pascal Port History] -----------------------------------------------------
+//
+// 10.05.2006-Milano: Unit port establishment
+// 17.05.2006-Milano: Interface part
+// 06.06.2006-Milano: porting
+// 07.06.2006-Milano: -"-
+// 09.06.2006-Milano: -"-
+// 22.06.2006-Milano: -"-
+//
+{ xmltok.pas }
+unit
+ xmltok ;
+
+INTERFACE
+
+uses
+ expat_basics ,
+ expat_external ;
+
+{$I expat_mode.inc }
+
+{ CONSTANTS DEFINITION }
+const
+{ The following token may be returned by XmlContentTok }
+ XML_TOK_TRAILING_RSQB = -5; { ] or ]] at the end of the scan; might be
+ start of illegal ]]> sequence }
+
+{ The following tokens may be returned by both XmlPrologTok and XmlContentTok. }
+ XML_TOK_NONE = -4; { The string to be scanned is empty }
+ XML_TOK_TRAILING_CR = -3; { A CR at the end of the scan;
+ might be part of CRLF sequence }
+ XML_TOK_PARTIAL_CHAR = -2; { only part of a multibyte sequence }
+ XML_TOK_PARTIAL = -1; { only part of a token }
+ XML_TOK_INVALID = 0;
+
+{ The following tokens are returned by XmlContentTok; some are also
+ returned by XmlAttributeValueTok, XmlEntityTok, XmlCdataSectionTok. }
+ XML_TOK_START_TAG_WITH_ATTS = 1;
+ XML_TOK_START_TAG_NO_ATTS = 2;
+ XML_TOK_EMPTY_ELEMENT_WITH_ATTS = 3; { empty element tag <e/> }
+ XML_TOK_EMPTY_ELEMENT_NO_ATTS = 4;
+ XML_TOK_END_TAG = 5;
+ XML_TOK_DATA_CHARS = 6;
+ XML_TOK_DATA_NEWLINE = 7;
+ XML_TOK_CDATA_SECT_OPEN = 8;
+ XML_TOK_ENTITY_REF = 9;
+ XML_TOK_CHAR_REF = 10; { numeric character reference }
+
+{ The following tokens may be returned by both XmlPrologTok and XmlContentTok. }
+ XML_TOK_PI = 11; { processing instruction }
+ XML_TOK_XML_DECL = 12; { XML decl or text decl }
+ XML_TOK_COMMENT = 13;
+ XML_TOK_BOM = 14; { Byte order mark }
+
+{ The following tokens are returned only by XmlPrologTok }
+ XML_TOK_PROLOG_S = 15;
+ XML_TOK_DECL_OPEN = 16; { <!foo }
+ XML_TOK_DECL_CLOSE = 17; { > }
+ XML_TOK_NAME = 18;
+ XML_TOK_NMTOKEN = 19;
+ XML_TOK_POUND_NAME = 20; { #name }
+ XML_TOK_OR = 21; { | }
+ XML_TOK_PERCENT = 22;
+ XML_TOK_OPEN_PAREN = 23;
+ XML_TOK_CLOSE_PAREN = 24;
+ XML_TOK_OPEN_BRACKET = 25;
+ XML_TOK_CLOSE_BRACKET = 26;
+ XML_TOK_LITERAL = 27;
+ XML_TOK_PARAM_ENTITY_REF = 28;
+ XML_TOK_INSTANCE_START = 29;
+
+{ The following occur only in element type declarations }
+ XML_TOK_NAME_QUESTION = 30; { name? }
+ XML_TOK_NAME_ASTERISK = 31; { name* }
+ XML_TOK_NAME_PLUS = 32; { name+ }
+ XML_TOK_COND_SECT_OPEN = 33; { <![ }
+ XML_TOK_COND_SECT_CLOSE = 34; { ]]> }
+ XML_TOK_CLOSE_PAREN_QUESTION = 35; { )? }
+ XML_TOK_CLOSE_PAREN_ASTERISK = 36; { )* }
+ XML_TOK_CLOSE_PAREN_PLUS = 37; { )+ }
+ XML_TOK_COMMA = 38;
+
+{ The following token is returned only by XmlAttributeValueTok }
+ XML_TOK_ATTRIBUTE_VALUE_S = 39;
+
+{ The following token is returned only by XmlCdataSectionTok }
+ XML_TOK_CDATA_SECT_CLOSE = 40;
+
+{ With namespace processing this is returned by XmlPrologTok for a
+ name with a colon. }
+ XML_TOK_PREFIXED_NAME = 41;
+
+{$IFDEF XML_DTD }
+ XML_TOK_IGNORE_SECT = 42;
+
+{$ENDIF }
+
+{$IFDEF XML_DTD }
+ XML_N_STATES = 4;
+
+{$ELSE }
+ XML_N_STATES = 3;
+
+{$ENDIF }
+
+ XML_PROLOG_STATE = 0;
+ XML_CONTENT_STATE = 1;
+ XML_CDATA_SECTION_STATE = 2;
+
+{$IFDEF XML_DTD }
+ XML_IGNORE_SECTION_STATE = 3;
+
+{$ENDIF }
+
+ XML_N_LITERAL_TYPES = 2;
+ XML_ATTRIBUTE_VALUE_LITERAL = 0;
+ XML_ENTITY_VALUE_LITERAL = 1;
+
+{ The size of the buffer passed to XmlUtf8Encode must be at least this. }
+ XML_UTF8_ENCODE_MAX = 4;
+
+{ The size of the buffer passed to XmlUtf16Encode must be at least this. }
+ XML_UTF16_ENCODE_MAX = 2;
+
+{ TYPES DEFINITION }
+type
+ POSITION_ptr = ^POSITION;
+ POSITION = record
+ { first line and first column are 0 not 1 }
+ lineNumber ,
+ columnNumber : XML_Size;
+
+ end;
+
+ ATTRIBUTE_ptr = ^ATTRIBUTE;
+ ATTRIBUTE = record
+ name ,
+ valuePtr ,
+ valueEnd : char_ptr;
+ normalized : char;
+
+ end;
+
+ ENCODING_ptr_ptr = ^ENCODING_ptr;
+ ENCODING_ptr = ^ENCODING;
+
+ SCANNER = function(p1 : ENCODING_ptr; p2 ,p3 : char_ptr; p4 : char_ptr_ptr ) : int;
+
+ ENCODING = record
+ scanners : array[0..XML_N_STATES - 1 ] of SCANNER;
+ literalScanners : array[0..XML_N_LITERAL_TYPES - 1 ] of SCANNER;
+
+ sameName : function (p1 : ENCODING_ptr; p2 ,p3 : char_ptr ) : int;
+ nameMatchesAscii : function (p1 : ENCODING_ptr; p2 ,p3 ,p4 : char_ptr ) : int;
+ nameLength : function (p1 : ENCODING_ptr; p2 : char_ptr ) : int;
+ skipS : function (p1 : ENCODING_ptr; p2 : char_ptr ) : char_ptr;
+ getAtts : function (enc : ENCODING_ptr; ptr : char_ptr; attsMax : int; atts : ATTRIBUTE_ptr ) : int;
+ charRefNumber : function (enc : ENCODING_ptr; ptr : char_ptr ) : int;
+ predefinedEntityName : function (p1 : ENCODING_ptr; p2 ,p3 : char_ptr ) : int;
+ updatePosition : procedure(p1 : ENCODING_ptr; ptr ,end_ : char_ptr; p4 : POSITION_ptr );
+ isPublicId : function (enc : ENCODING_ptr; ptr ,end_ : char_ptr; badPtr : char_ptr_ptr ) : int;
+ utf8Convert : procedure(enc : ENCODING_ptr; fromP : char_ptr_ptr; fromLim : char_ptr; toP : char_ptr_ptr; toLim : char_ptr );
+ utf16Convert : procedure(enc : ENCODING_ptr; fromP : char_ptr_ptr; fromLim : char_ptr; toP : int16u_ptr_ptr; toLim : int16u_ptr );
+
+ minBytesPerChar : int;
+
+ isUtf8 ,
+ isUtf16 : char;
+
+ end;
+
+ INIT_ENCODING_ptr = ^INIT_ENCODING;
+ INIT_ENCODING = record
+ initEnc : ENCODING;
+ encPtr : ENCODING_ptr_ptr;
+
+ end;
+
+{ GLOBAL PROCEDURES }
+ function XmlInitEncoding (p : INIT_ENCODING_ptr; encPtr : ENCODING_ptr_ptr; name : char_ptr ) : int;
+ function XmlInitEncodingNS(p : INIT_ENCODING_ptr; encPtr : ENCODING_ptr_ptr; name : char_ptr ) : int;
+
+ function XmlGetInternalEncoding : ENCODING_ptr;
+ function XmlGetInternalEncodingNS : ENCODING_ptr;
+
+ function XmlTok_ (enc : ENCODING_ptr; state : int; ptr, end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
+ function XmlPrologTok (enc : ENCODING_ptr; ptr, end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
+ function XmlContentTok(enc : ENCODING_ptr; ptr, end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
+ function XmlIsPublicId(enc : ENCODING_ptr; ptr ,end_ : char_ptr; badPtr : char_ptr_ptr ) : int;
+
+ procedure XmlUtf8Convert (enc : ENCODING_ptr; fromP : char_ptr_ptr; fromLim : char_ptr; toP : char_ptr_ptr; toLim : char_ptr );
+ procedure XmlUtf16Convert(enc : ENCODING_ptr; fromP : char_ptr_ptr; fromLim : char_ptr; toP : int16u_ptr_ptr; toLim : int16u_ptr );
+
+ function XmlUtf8Encode (charNumber : int; buf : char_ptr ) : int;
+ function XmlUtf16Encode(charNumber : int; buf : int16u_ptr ) : int;
+
+{ This is used for performing a 2nd-level tokenization on the content
+ of a literal that has already been returned by XmlTok. }
+ function XmlLiteralTok (enc : ENCODING_ptr; literalType : int; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
+ function XmlAttributeValueTok (enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
+ function XmlEntityValueTok (enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
+ function XmlSameName (enc : ENCODING_ptr; ptr1 ,ptr2 : char_ptr ) : int;
+ function XmlNameMatchesAscii (enc : ENCODING_ptr; ptr1 ,end1 ,ptr2 : char_ptr ) : int;
+ function XmlNameLength (enc : ENCODING_ptr; ptr : char_ptr ) : int;
+ function XmlGetAttributes (enc : ENCODING_ptr; ptr : char_ptr; attsMax : int; atts : ATTRIBUTE_ptr ) : int;
+ function XmlCharRefNumber (enc : ENCODING_ptr; ptr : char_ptr ) : int;
+ function XmlPredefinedEntityName(enc : ENCODING_ptr; ptr ,end_ : char_ptr ) : int;
+
+ function XmlParseXmlDecl(
+ isGeneralTextEntity : int;
+ enc : ENCODING_ptr;
+ ptr ,end_ : char_ptr;
+ badPtr ,versionPtr ,versionEndPtr ,encodingNamePtr : char_ptr_ptr;
+ namedEncodingPtr : ENCODING_ptr_ptr;
+ standalonePtr : int_ptr ) : int;
+
+ function XmlParseXmlDeclNS(
+ isGeneralTextEntity : int;
+ enc : ENCODING_ptr;
+ ptr ,end_ : char_ptr;
+ badPtr ,versionPtr ,versionEndPtr ,encodingNamePtr : char_ptr_ptr;
+ namedEncodingPtr : ENCODING_ptr_ptr;
+ standalonePtr : int_ptr ) : int;
+
+IMPLEMENTATION
+{ LOCAL VARIABLES & CONSTANTS }
+type
+ encodingFinder_func = function(enc : ENCODING_ptr; ptr ,end_ : char_ptr ) : ENCODING_ptr;
+
+const
+{$I ascii.inc }
+
+ KW_version : array[0..7 ] of char = (
+ ASCII_vl ,ASCII_el ,ASCII_rl ,ASCII_sl ,ASCII_il ,ASCII_ol ,ASCII_nl ,#0 );
+
+ KW_encoding : array[0..8 ] of char = (
+ ASCII_el ,ASCII_nl ,ASCII_cl ,ASCII_ol ,ASCII_dl ,ASCII_il ,ASCII_nl ,ASCII_gl ,#0 );
+
+ KW_standalone : array[0..10 ] of char = (
+ ASCII_sl ,ASCII_tl ,ASCII_al ,ASCII_nl ,ASCII_dl ,ASCII_al ,ASCII_ll ,ASCII_ol ,
+ ASCII_nl ,ASCII_el ,#0 );
+
+ KW_yes : array[0..3 ] of char = (ASCII_yl ,ASCII_el ,ASCII_sl ,#0 );
+
+ KW_no : array[0..2 ] of char = (ASCII_nl ,ASCII_ol ,#0 );
+
+{ MINBPC }
+function MINBPC(enc : ENCODING_ptr ) : int;
+begin
+{$IFDEF XML_MIN_SIZE }
+ result:=enc.minBytesPerChar;
+
+{$ELSE }
+ result:=1;
+
+{$ENDIF }
+
+end;
+
+{ utf8_toUtf8 }{unicode}
+procedure utf8_toUtf8(enc : ENCODING_ptr; fromP : char_ptr_ptr; fromLim : char_ptr; toP : char_ptr_ptr; toLim : char_ptr );
+var
+ to_ ,from : char_ptr;
+
+begin
+{ Avoid copying partial characters. }
+ if ptrcomp(fromLim ) - ptrcomp(fromP^ ) > ptrcomp(toLim ) - ptrcomp(toP^) then
+ begin
+ fromLim:=char_ptr(ptrcomp(fromP^ ) + (ptrcomp(toLim ) - ptrcomp(toP^ ) ) );
+
+ while ptrcomp(fromLim ) > ptrcomp(fromP^ ) do
+ begin
+ if int8u(char_ptr(ptrcomp(fromLim ) -1 )^ ) and $c0 <> $80 then
+ break;
+
+ dec(ptrcomp(fromLim ) );
+
+ end;
+
+ end;
+
+ to_ :=toP^;
+ from:=fromP^;
+
+ while ptrcomp(from ) <> ptrcomp(fromLim ) do
+ begin
+ to_^:=from^;
+
+ inc(ptrcomp(from ) );
+ inc(ptrcomp(to_ ) );
+
+ end;
+
+ fromP^:=from;
+ toP^ :=to_;
+
+end;
+
+{ utf8_toUtf16 {..}{unicode}
+procedure utf8_toUtf16(enc : ENCODING_ptr; fromP : char_ptr_ptr; fromLim : char_ptr; toP : int16u_ptr_ptr; toLim : int16u_ptr );
+begin
+end;
+
+{ sb_byteType {..}
+function sb_byteType(enc : ENCODING_ptr; p : char_ptr ) : int;
+begin
+end;
+
+{ isNever }
+function isNever(enc : ENCODING_ptr; p : char_ptr ) : int;
+begin
+ result:=0;
+
+end;
+
+{ sb_byteToAscii }
+function sb_byteToAscii(enc : ENCODING_ptr; p : char_ptr ) : int;
+begin
+ result:=int(p^ );
+
+end;
+
+{ sb_charMatches }
+function sb_charMatches(enc : ENCODING_ptr; p : char_ptr; c : int ) : int;
+begin
+ result:=int(int(p^ ) = c );
+
+end;
+
+{ utf8_isName2 {..}
+function utf8_isName2(enc : ENCODING_ptr; p : char_ptr ) : int;
+begin
+end;
+
+{ utf8_isName3 {..}
+function utf8_isName3(enc : ENCODING_ptr; p : char_ptr ) : int;
+begin
+end;
+
+{ utf8_isNmstrt2 {..}
+function utf8_isNmstrt2(enc : ENCODING_ptr; p : char_ptr ) : int;
+begin
+end;
+
+{ utf8_isNmstrt3 {..}
+function utf8_isNmstrt3(enc : ENCODING_ptr; p : char_ptr ) : int;
+begin
+end;
+
+{ utf8_isInvalid2 {..}
+function utf8_isInvalid2(enc : ENCODING_ptr; p : char_ptr ) : int;
+begin
+end;
+
+{ utf8_isInvalid3 {..}
+function utf8_isInvalid3(enc : ENCODING_ptr; p : char_ptr ) : int;
+begin
+end;
+
+{ utf8_isInvalid4 {..}
+function utf8_isInvalid4(enc : ENCODING_ptr; p : char_ptr ) : int;
+begin
+end;
+
+{ LOCAL VARIABLES & CONSTANTS }
+type
+ normal_encoding_ptr = ^normal_encoding;
+ normal_encoding = record
+ enc : ENCODING;
+ type_ : array[0..255 ] of int8u;
+
+ {$IFDEF XML_MIN_SIZE }
+ byteType : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
+ isNameMin : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
+ isNmstrtMin : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
+ byteToAscii : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
+ charMatches : function(p1 : ENCODING_ptr; p2 : char_ptr; p3 : int ) : int;
+
+ {$ENDIF }
+ isName2 : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
+ isName3 : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
+ isName4 : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
+ isNmstrt2 : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
+ isNmstrt3 : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
+ isNmstrt4 : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
+ isInvalid2 : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
+ isInvalid3 : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
+ isInvalid4 : function(p1 : ENCODING_ptr; p2 : char_ptr ) : int;
+
+ end;
+
+const
+ BT_NONXML = 0;
+ BT_MALFORM = 1;
+ BT_LT = 2;
+ BT_AMP = 3;
+ BT_RSQB = 4;
+ BT_LEAD2 = 5;
+ BT_LEAD3 = 6;
+ BT_LEAD4 = 7;
+ BT_TRAIL = 8;
+ BT_CR = 9;
+ BT_LF = 10;
+ BT_GT = 11;
+ BT_QUOT = 12;
+ BT_APOS = 13;
+ BT_EQUALS = 14;
+ BT_QUEST = 15;
+ BT_EXCL = 16;
+ BT_SOL = 17;
+ BT_SEMI = 18;
+ BT_NUM = 19;
+ BT_LSQB = 20;
+ BT_S = 21;
+ BT_NMSTRT = 22;
+ BT_COLON = 23;
+ BT_HEX = 24;
+ BT_DIGIT = 25;
+ BT_NAME = 26;
+ BT_MINUS = 27;
+ BT_OTHER = 28; { known not to be a name or name start character }
+ BT_NONASCII = 29; { might be a name or name start character }
+ BT_PERCNT = 30;
+ BT_LPAR = 31;
+ BT_RPAR = 32;
+ BT_AST = 33;
+ BT_PLUS = 34;
+ BT_COMMA = 35;
+ BT_VERBAR = 36;
+
+ BT_COLON_ = BT_NMSTRT;
+
+{ BYTE_TYPE }
+function BYTE_TYPE(enc : ENCODING_ptr; p : char_ptr ) : int;
+begin
+{$IFDEF XML_MIN_SIZE }
+ result:=normal_encoding_ptr(enc ).byteType(enc ,p );
+
+{$ELSE }
+ result:=normal_encoding_ptr(enc ).type_[int8u(p^ ) ];
+
+{$ENDIF }
+
+end;
+
+{ BYTE_TO_ASCII }
+function BYTE_TO_ASCII(enc : ENCODING_ptr; p : char_ptr ) : int;
+begin
+{$IFDEF XML_MIN_SIZE }
+ result:=normal_encoding_ptr(enc ).byteToAscii(enc ,p );
+
+{$ELSE }
+ result:=int8u_ptr(p )^;
+
+{$ENDIF }
+
+end;
+
+{ CHAR_MATCHES }
+function CHAR_MATCHES(enc : ENCODING_ptr; p : char_ptr; c : int ) : int;
+begin
+{$IFDEF XML_MIN_SIZE }
+ result:=normal_encoding_ptr(enc ).charMatches(enc ,p ,c );
+
+{$ELSE }
+ result:=int(int8u_ptr(p )^ = c );
+
+{$ENDIF }
+
+end;
+
+{ IS_NAME_CHAR }
+function IS_NAME_CHAR(enc : ENCODING_ptr; p : char_ptr; n : int ) : int;
+begin
+ case n of
+ 2 : result:=normal_encoding_ptr(enc ).isName2(enc ,p );
+ 3 : result:=normal_encoding_ptr(enc ).isName3(enc ,p );
+ 4 : result:=normal_encoding_ptr(enc ).isName4(enc ,p );
+
+ end;
+
+end;
+
+{ IS_NMSTRT_CHAR }
+function IS_NMSTRT_CHAR(enc : ENCODING_ptr; p : char_ptr; n : int ) : int;
+begin
+ case n of
+ 2 : result:=normal_encoding_ptr(enc ).isNmstrt2(enc ,p );
+ 3 : result:=normal_encoding_ptr(enc ).isNmstrt3(enc ,p );
+ 4 : result:=normal_encoding_ptr(enc ).isNmstrt4(enc ,p );
+
+ end;
+
+end;
+
+{ IS_INVALID_CHAR }
+function IS_INVALID_CHAR(enc : ENCODING_ptr; p : char_ptr; n : int ) : int;
+begin
+ case n of
+ 2 : result:=normal_encoding_ptr(enc ).isInvalid2(enc ,p );
+ 3 : result:=normal_encoding_ptr(enc ).isInvalid3(enc ,p );
+ 4 : result:=normal_encoding_ptr(enc ).isInvalid4(enc ,p );
+
+ end;
+
+end;
+
+{ IS_NAME_CHAR_MINBPC }
+function IS_NAME_CHAR_MINBPC(enc : ENCODING_ptr; p : char_ptr ) : int;
+begin
+{$IFDEF XML_MIN_SIZE }
+ result:=normal_encoding_ptr(enc ).isNameMin(enc ,p );
+
+{$ELSE }
+ result:=0;
+
+{$ENDIF }
+
+end;
+
+{ IS_NMSTRT_CHAR_MINBPC }
+function IS_NMSTRT_CHAR_MINBPC(enc : ENCODING_ptr; p : char_ptr ) : int;
+begin
+{$IFDEF XML_MIN_SIZE }
+ result:=normal_encoding_ptr(enc ).isNmstrtMin(enc ,p );
+
+{$ELSE }
+ result:=0;
+
+{$ENDIF }
+
+end;
+
+{ INIT_ENC_INDEX }
+function INIT_ENC_INDEX(enc : INIT_ENCODING_ptr ) : int;
+begin
+ result:=int(enc.initEnc.isUtf16 );
+
+end;
+
+{ SET_INIT_ENC_INDEX }
+procedure SET_INIT_ENC_INDEX(enc : INIT_ENCODING_ptr; i : int );
+begin
+ enc.initEnc.isUtf16:=char(i );
+
+end;
+
+{$I xmltok_impl.inc }
+
+const
+{$IFDEF XML_NS }
+ utf8_encoding_ns : normal_encoding = (
+ enc:(scanners :(normal_prologTok ,normal_contentTok ,normal_cdataSectionTok {$IFDEF XML_DTD },normal_ignoreSectionTok {$ENDIF } );
+ literalScanners:(normal_attributeValueTok ,normal_entityValueTok );
+
+ sameName :normal_sameName;
+ nameMatchesAscii :normal_nameMatchesAscii;
+ nameLength :normal_nameLength;
+ skipS :normal_skipS;
+ getAtts :normal_getAtts;
+ charRefNumber :normal_charRefNumber;
+ predefinedEntityName:normal_predefinedEntityName;
+ updatePosition :normal_updatePosition;
+ isPublicId :normal_isPublicId;
+ utf8Convert :utf8_toUtf8;
+ utf16Convert :utf8_toUtf16;
+
+ minBytesPerChar:1;
+
+ isUtf8 :#1;
+ isUtf16:#0 );
+ type_:({$I asciitab.inc}
+ {$I utf8tab.inc});
+
+ {$IFDEF XML_MIN_SIZE }
+ byteType :sb_byteType;
+ isNameMin :isNever;
+ isNmstrtMin:isNever;
+ byteToAscii:sb_byteToAscii;
+ charMatches:sb_charMatches;
+
+ {$ENDIF }
+
+ isName2 :utf8_isName2;
+ isName3 :utf8_isName3;
+ isName4 :isNever;
+ isNmstrt2 :utf8_isNmstrt2;
+ isNmstrt3 :utf8_isNmstrt3;
+ isNmstrt4 :isNever;
+ isInvalid2:utf8_isInvalid2;
+ isInvalid3:utf8_isInvalid3;
+ isInvalid4:utf8_isInvalid4 );
+
+{$ENDIF }
+
+ utf8_encoding : normal_encoding = (
+ enc:(scanners :(normal_prologTok ,normal_contentTok ,normal_cdataSectionTok {$IFDEF XML_DTD },normal_ignoreSectionTok {$ENDIF } );
+ literalScanners:(normal_attributeValueTok ,normal_entityValueTok );
+
+ sameName :normal_sameName;
+ nameMatchesAscii :normal_nameMatchesAscii;
+ nameLength :normal_nameLength;
+ skipS :normal_skipS;
+ getAtts :normal_getAtts;
+ charRefNumber :normal_charRefNumber;
+ predefinedEntityName:normal_predefinedEntityName;
+ updatePosition :normal_updatePosition;
+ isPublicId :normal_isPublicId;
+ utf8Convert :utf8_toUtf8;
+ utf16Convert :utf8_toUtf16;
+
+ minBytesPerChar:1;
+
+ isUtf8 :#1;
+ isUtf16:#0 );
+ type_:({$I asciitab_bt_colon_.inc}
+ {$I utf8tab.inc});
+
+ {$IFDEF XML_MIN_SIZE }
+ byteType :sb_byteType;
+ isNameMin :isNever;
+ isNmstrtMin:isNever;
+ byteToAscii:sb_byteToAscii;
+ charMatches:sb_charMatches;
+
+ {$ENDIF }
+
+ isName2 :utf8_isName2;
+ isName3 :utf8_isName3;
+ isName4 :isNever;
+ isNmstrt2 :utf8_isNmstrt2;
+ isNmstrt3 :utf8_isNmstrt3;
+ isNmstrt4 :isNever;
+ isInvalid2:utf8_isInvalid2;
+ isInvalid3:utf8_isInvalid3;
+ isInvalid4:utf8_isInvalid4 );
+
+{$IFDEF XML_NS }
+ internal_utf8_encoding_ns : normal_encoding = (
+ enc:(scanners :(normal_prologTok ,normal_contentTok ,normal_cdataSectionTok {$IFDEF XML_DTD },normal_ignoreSectionTok {$ENDIF } );
+ literalScanners:(normal_attributeValueTok ,normal_entityValueTok );
+
+ sameName :normal_sameName;
+ nameMatchesAscii :normal_nameMatchesAscii;
+ nameLength :normal_nameLength;
+ skipS :normal_skipS;
+ getAtts :normal_getAtts;
+ charRefNumber :normal_charRefNumber;
+ predefinedEntityName:normal_predefinedEntityName;
+ updatePosition :normal_updatePosition;
+ isPublicId :normal_isPublicId;
+ utf8Convert :utf8_toUtf8;
+ utf16Convert :utf8_toUtf16;
+
+ minBytesPerChar:1;
+
+ isUtf8 :#1;
+ isUtf16:#0 );
+ type_:({$I iasciitab.inc}
+ {$I utf8tab.inc});
+
+ {$IFDEF XML_MIN_SIZE }
+ byteType :sb_byteType;
+ isNameMin :isNever;
+ isNmstrtMin:isNever;
+ byteToAscii:sb_byteToAscii;
+ charMatches:sb_charMatches;
+
+ {$ENDIF }
+
+ isName2 :utf8_isName2;
+ isName3 :utf8_isName3;
+ isName4 :isNever;
+ isNmstrt2 :utf8_isNmstrt2;
+ isNmstrt3 :utf8_isNmstrt3;
+ isNmstrt4 :isNever;
+ isInvalid2:utf8_isInvalid2;
+ isInvalid3:utf8_isInvalid3;
+ isInvalid4:utf8_isInvalid4 );
+
+{$ENDIF }
+
+ internal_utf8_encoding : normal_encoding = (
+ enc:(scanners :(normal_prologTok ,normal_contentTok ,normal_cdataSectionTok {$IFDEF XML_DTD },normal_ignoreSectionTok {$ENDIF } );
+ literalScanners:(normal_attributeValueTok ,normal_entityValueTok );
+
+ sameName :normal_sameName;
+ nameMatchesAscii :normal_nameMatchesAscii;
+ nameLength :normal_nameLength;
+ skipS :normal_skipS;
+ getAtts :normal_getAtts;
+ charRefNumber :normal_charRefNumber;
+ predefinedEntityName:normal_predefinedEntityName;
+ updatePosition :normal_updatePosition;
+ isPublicId :normal_isPublicId;
+ utf8Convert :utf8_toUtf8;
+ utf16Convert :utf8_toUtf16;
+
+ minBytesPerChar:1;
+
+ isUtf8 :#1;
+ isUtf16:#0 );
+ type_:({$I iasciitab_bt_colon_.inc}
+ {$I utf8tab.inc});
+
+ {$IFDEF XML_MIN_SIZE }
+ byteType :sb_byteType;
+ isNameMin :isNever;
+ isNmstrtMin:isNever;
+ byteToAscii:sb_byteToAscii;
+ charMatches:sb_charMatches;
+
+ {$ENDIF }
+
+ isName2 :utf8_isName2;
+ isName3 :utf8_isName3;
+ isName4 :isNever;
+ isNmstrt2 :utf8_isNmstrt2;
+ isNmstrt3 :utf8_isNmstrt3;
+ isNmstrt4 :isNever;
+ isInvalid2:utf8_isInvalid2;
+ isInvalid3:utf8_isInvalid3;
+ isInvalid4:utf8_isInvalid4 );
+
+{$IFDEF XML_NS }
+ latin1_encoding_ns : normal_encoding = ();{..}
+
+{$ENDIF }
+
+ latin1_encoding : normal_encoding = ();{..}
+
+{$IFDEF XML_NS }
+ ascii_encoding_ns : normal_encoding = ();{..}
+
+{$ENDIF }
+
+ ascii_encoding : normal_encoding = ();{..}
+
+{$IFDEF XML_NS }
+ little2_encoding_ns : normal_encoding = ();{..}
+
+{$ENDIF }
+
+ little2_encoding : normal_encoding = ();{..}
+
+{$IFDEF XML_NS }
+ big2_encoding_ns : normal_encoding = ();{..}
+
+{$ENDIF }
+
+ big2_encoding : normal_encoding = ();{..}
+
+{ If this enumeration is changed, getEncodingIndex and encodings
+ must also be changed. }
+ UNKNOWN_ENC = -1;
+ ISO_8859_1_ENC = 0;
+ US_ASCII_ENC = 1;
+ UTF_8_ENC = 2;
+ UTF_16_ENC = 3;
+ UTF_16BE_ENC = 4;
+ UTF_16LE_ENC = 5;
+ NO_ENC = 6; { must match encodingNames up to here }
+
+ KW_ISO_8859_1 : array[0..10 ] of char = (
+ ASCII_I ,ASCII_S ,ASCII_O ,ASCII_MINUS ,ASCII_8 ,ASCII_8 ,ASCII_5 ,ASCII_9 ,
+ ASCII_MINUS ,ASCII_1 ,#0 );
+
+ KW_US_ASCII : array[0..8 ] of char = (
+ ASCII_U ,ASCII_S ,ASCII_MINUS ,ASCII_A ,ASCII_S ,ASCII_C ,ASCII_I ,ASCII_I ,
+ #0 );
+
+ KW_UTF_8 : array[0..5 ] of char = (
+ ASCII_U ,ASCII_T ,ASCII_F ,ASCII_MINUS ,ASCII_8 ,#0 );
+
+ KW_UTF_16 : array[0..6 ] of char = (
+ ASCII_U ,ASCII_T ,ASCII_F ,ASCII_MINUS ,ASCII_1 ,ASCII_6 ,#0 );
+
+ KW_UTF_16BE : array[0..8 ] of char = (
+ ASCII_U ,ASCII_T ,ASCII_F ,ASCII_MINUS ,ASCII_1 ,ASCII_6 ,ASCII_B ,ASCII_E ,
+ #0 );
+
+ KW_UTF_16LE : array[0..8 ] of char = (
+ ASCII_U ,ASCII_T ,ASCII_F ,ASCII_MINUS ,ASCII_1 ,ASCII_6 ,ASCII_L ,ASCII_E ,
+ #0 );
+
+{ UNIT IMPLEMENTATION }
+{ streqci }
+function streqci(s1 ,s2 : char_ptr ) : int;
+var
+ c1 ,c2 : char;
+
+begin
+ repeat
+ c1:=s1^;
+ c2:=s2^;
+
+ inc(ptrcomp(s1 ) );
+ inc(ptrcomp(s2 ) );
+
+ if (ASCII_al <= c1 ) and
+ (c1 <= ASCII_zl ) then
+ inc(byte(c1 ) ,byte(ASCII_A ) - byte(ASCII_al ) );
+
+ if (ASCII_al <= c2 ) and
+ (c2 <= ASCII_zl ) then
+ inc(byte(c2 ) ,byte(ASCII_A ) - byte(ASCII_al ) );
+
+ if c1 <> c2 then
+ begin
+ result:=0;
+
+ exit;
+
+ end;
+
+ if (c1 = #0 ) or
+ (c2 = #0 ) then
+ break;
+
+ until false;
+
+ result:=1;
+
+end;
+
+{ initUpdatePosition {..}
+procedure initUpdatePosition(enc : ENCODING_ptr; ptr ,end_ : char_ptr; pos : POSITION_ptr );
+begin
+end;
+
+{ getEncodingIndex }
+function getEncodingIndex(name : char_ptr ) : int;
+const
+ encodingNames : array[0..5 ] of char_ptr = (
+ @KW_ISO_8859_1 ,
+ @KW_US_ASCII ,
+ @KW_UTF_8 ,
+ @KW_UTF_16 ,
+ @KW_UTF_16BE ,
+ @KW_UTF_16LE );
+
+var
+ i : int;
+
+begin
+ if name = NIL then
+ result:=NO_ENC
+ else
+ begin
+ i:=0;
+
+ while i < sizeof(encodingNames ) div sizeof(encodingNames[0 ] ) do
+ begin
+ if streqci(name ,encodingNames[i ] ) <> 0 then
+ begin
+ result:=i;
+
+ exit;
+
+ end;
+
+ inc(i );
+
+ end;
+
+ result:=UNKNOWN_ENC;
+
+ end;
+
+end;
+
+{ initScan }
+{ This is what detects the encoding. encodingTable maps from
+ encoding indices to encodings; int8u(enc.initEnc.isUtf16 ) is the index of
+ the external (protocol) specified encoding; state is
+ XML_CONTENT_STATE if we're parsing an external text entity, and
+ XML_PROLOG_STATE otherwise. }
+function initScan(
+ encodingTable : ENCODING_ptr_ptr;
+ enc : INIT_ENCODING_ptr;
+ state : int;
+ ptr ,end_ : char_ptr;
+ nextTokPtr : char_ptr_ptr ) : int;
+var
+ encPtr : ENCODING_ptr_ptr;
+
+ e : int;
+
+label
+ _003C ,_esc ;
+
+begin
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_NONE;
+
+ exit;
+
+ end;
+
+ encPtr:=enc.encPtr;
+
+{ only a single byte available for auto-detection }
+ if ptrcomp(ptr ) + 1 = ptrcomp(end_ ) then
+ begin
+ {$IFNDEF XML_DTD } { FIXME }
+ { a well-formed document entity must have more than one byte }
+ if state <> XML_CONTENT_STATE then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ {$ENDIF }
+ { so we're parsing an external text entity... }
+ { if UTF-16 was externally specified, then we need at least 2 bytes }
+ case INIT_ENC_INDEX(enc ) of
+ UTF_16_ENC ,UTF_16LE_ENC ,UTF_16BE_ENC :
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ end;
+
+ case int8u(ptr^ ) of
+ $FE ,$FF ,$EF : { possibly first byte of UTF-8 BOM }
+ if (INIT_ENC_INDEX(enc ) = ISO_8859_1_ENC ) and
+ (state = XML_CONTENT_STATE ) then
+ else
+ goto _003C;
+
+ $00 ,$3C : { fall through }
+ _003C:
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ end;
+
+ end
+ else
+ case (ptrcomp(ptr^ ) shl 8 ) or int8u_ptr(ptrcomp(ptr ) + 1 )^ of
+ $FEFF :
+ if (INIT_ENC_INDEX(enc ) = ISO_8859_1_ENC ) and
+ (state = XML_CONTENT_STATE ) then
+ else
+ begin
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + 2 );
+ encPtr^ :=ENCODING_ptr_ptr(ptrcomp(encodingTable ) + UTF_16BE_ENC * sizeof(ENCODING_ptr ) )^;
+
+ result:=XML_TOK_BOM;
+
+ exit;
+
+ end;
+
+ { 00 3C is handled in the default case }
+ $3C00 :
+ if ((INIT_ENC_INDEX(enc ) = UTF_16BE_ENC ) or
+ (INIT_ENC_INDEX(enc ) = UTF_16_ENC ) ) and
+ (state = XML_CONTENT_STATE ) then
+ else
+ begin
+ encPtr^:=ENCODING_ptr_ptr(ptrcomp(encodingTable ) + UTF_16LE_ENC * sizeof(ENCODING_ptr ) )^;
+ result :=XmlTok_(encPtr^ ,state ,ptr ,end_ ,nextTokPtr );
+
+ exit;
+
+ end;
+
+ $FFFE :
+ if (INIT_ENC_INDEX(enc ) = ISO_8859_1_ENC ) and
+ (state = XML_CONTENT_STATE ) then
+ else
+ begin
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + 2 );
+ encPtr^ :=ENCODING_ptr_ptr(ptrcomp(encodingTable ) + UTF_16LE_ENC * sizeof(ENCODING_ptr ) )^;
+
+ result:=XML_TOK_BOM;
+
+ exit;
+
+ end;
+
+ { Maybe a UTF-8 BOM (EF BB BF) }
+ { If there's an explicitly specified (external) encoding
+ of ISO-8859-1 or some flavour of UTF-16
+ and this is an external text entity,
+ don't look for the BOM,
+ because it might be a legal data. }
+ $EFBB :
+ begin
+ if state = XML_CONTENT_STATE then
+ begin
+ e:=INIT_ENC_INDEX(enc );
+
+ if (e = ISO_8859_1_ENC ) or
+ (e = UTF_16BE_ENC ) or
+ (e = UTF_16LE_ENC ) or
+ (e = UTF_16_ENC ) then
+ goto _esc;
+
+ end;
+
+ if ptrcomp(ptr ) + 2 = ptrcomp(end_ ) then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ if int8u_ptr(ptrcomp(ptr ) + 2 )^ = $BF then
+ begin
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + 3 );
+ encPtr^ :=ENCODING_ptr_ptr(ptrcomp(encodingTable ) + UTF_8_ENC * sizeof(ENCODING_ptr ) )^;
+
+ result:=XML_TOK_BOM;
+
+ exit;
+
+ end;
+
+ end;
+
+ else
+ { 0 isn't a legal data character. Furthermore a document
+ entity can only start with ASCII characters. So the only
+ way this can fail to be big-endian UTF-16 if it it's an
+ external parsed general entity that's labelled as
+ UTF-16LE. }
+ if ptr^ = #0 then
+ begin
+ if (state = XML_CONTENT_STATE ) and
+ (INIT_ENC_INDEX(enc ) = UTF_16LE_ENC ) then
+ goto _esc;
+
+ encPtr^:=ENCODING_ptr_ptr(ptrcomp(encodingTable ) + UTF_16BE_ENC * sizeof(ENCODING_ptr ) )^;
+ result :=XmlTok_(encPtr^ ,state ,ptr ,end_ ,nextTokPtr );
+
+ exit;
+
+ end
+ else
+ { We could recover here in the case:
+ - parsing an external entity
+ - second byte is 0
+ - no externally specified encoding
+ - no encoding declaration
+ by assuming UTF-16LE. But we don't, because this would mean when
+ presented just with a single byte, we couldn't reliably determine
+ whether we needed further bytes. }
+ if int8u_ptr(ptrcomp(ptr ) + 1 )^ = 0 then
+ begin
+ if state = XML_CONTENT_STATE then
+ goto _esc;
+
+ encPtr^:=ENCODING_ptr_ptr(ptrcomp(encodingTable ) + UTF_16LE_ENC * sizeof(ENCODING_ptr ) )^;
+ result :=XmlTok_(encPtr^ ,state ,ptr ,end_ ,nextTokPtr );
+
+ end;
+
+ end;
+
+_esc:
+ encPtr^:=ENCODING_ptr_ptr(ptrcomp(encodingTable ) + INIT_ENC_INDEX(enc ) * sizeof(ENCODING_ptr ) )^;
+ result :=XmlTok_(encPtr^ ,state ,ptr ,end_ ,nextTokPtr );
+
+end;
+
+{ toAscii }
+function toAscii(enc : ENCODING_ptr; ptr ,end_ : char_ptr ) : int;
+var
+ buf : array[0..0 ] of char;
+
+ p : char_ptr;
+
+begin
+ p:=@buf[0 ];
+
+ XmlUtf8Convert(enc ,@ptr ,end_ ,@p ,char_ptr(ptrcomp(p ) + 1 ) );
+
+ if p = @buf[0 ] then
+ result:=-1
+ else
+ result:=int(buf[0 ] );
+
+end;
+
+{ isSpace }
+function isSpace(c : int ) : int;
+begin
+ case c of
+ $20 ,$D ,$A ,$9 :
+ result:=1;
+
+ else
+ result:=0;
+
+ end;
+
+end;
+
+{ parsePseudoAttribute }
+{ Return 1 if there's just optional white space or there's an S
+ followed by name=val. }
+function parsePseudoAttribute(
+ enc : ENCODING_ptr;
+ ptr ,end_ : char_ptr;
+ namePtr ,nameEndPtr ,valPtr ,nextTokPtr : char_ptr_ptr ) : int;
+var
+ c : int;
+
+ open : char;
+
+begin
+ if ptr = end_ then
+ begin
+ namePtr^:=NIL;
+ result :=1;
+
+ exit;
+
+ end;
+
+ if isSpace(toAscii(enc ,ptr ,end_ ) ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=0;
+
+ exit;
+
+ end;
+
+ repeat
+ inc(ptrcomp(ptr ) ,enc.minBytesPerChar );
+
+ until isSpace(toAscii(enc ,ptr ,end_ ) ) = 0;
+
+ if ptr = end_ then
+ begin
+ namePtr^:=NIL;
+ result :=1;
+
+ exit;
+
+ end;
+
+ namePtr^:=ptr;
+
+ repeat
+ c:=toAscii(enc ,ptr ,end_ );
+
+ if c = -1 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=0;
+
+ exit;
+
+ end;
+
+ if c = int(ASCII_EQUALS ) then
+ begin
+ nameEndPtr^:=ptr;
+
+ break;
+
+ end;
+
+ if isSpace(c ) <> 0 then
+ begin
+ nameEndPtr^:=ptr;
+
+ repeat
+ inc(ptrcomp(ptr ) ,enc.minBytesPerChar );
+
+ c:=toAscii(enc ,ptr ,end_ );
+
+ until isSpace(c ) = 0;
+
+ if c <> int(ASCII_EQUALS ) then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=0;
+
+ exit;
+
+ end;
+
+ break;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,enc.minBytesPerChar );
+
+ until false;
+
+ if ptr = namePtr^ then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=0;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,enc.minBytesPerChar );
+
+ c:=toAscii(enc ,ptr ,end_ );
+
+ while isSpace(c ) <> 0 do
+ begin
+ inc(ptrcomp(ptr ) ,enc.minBytesPerChar );
+
+ c:=toAscii(enc ,ptr ,end_ );
+
+ end;
+
+ if (c <> int(ASCII_QUOT ) ) and
+ (c <> int(ASCII_APOS ) ) then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=0;
+
+ exit;
+
+ end;
+
+ open:=char(c );
+
+ inc(ptrcomp(ptr ) ,enc.minBytesPerChar );
+
+ valPtr^:=ptr;
+
+ repeat
+ c:=toAscii(enc ,ptr ,end_ );
+
+ if c = int(open ) then
+ break;
+
+ if not((int(ASCII_al ) <= c ) and (c <= int(ASCII_zl ) ) ) and
+ not((int(ASCII_A ) <= c ) and (c <= int(ASCII_Z ) ) ) and
+ not((int(ASCII_0 ) <= c ) and (c <= int(ASCII_9 ) ) ) and
+ (c <> int(ASCII_PERIOD ) ) and
+ (c <> int(ASCII_MINUS ) ) and
+ (c <> int(ASCII_UNDERSCORE ) ) then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=0;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,enc.minBytesPerChar );
+
+ until false;
+
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + enc.minBytesPerChar );
+
+ result:=1;
+
+end;
+
+{ doParseXmlDecl }
+function doParseXmlDecl(
+ encodingFinder : encodingFinder_func;
+ isGeneralTextEntity : int;
+ enc : ENCODING_ptr;
+ ptr ,end_ : char_ptr;
+ badPtr ,versionPtr ,versionEndPtr ,encodingName : char_ptr_ptr;
+ encoding : ENCODING_ptr_ptr;
+ standalone : int_ptr ) : int;
+var
+ val ,name ,nameEnd : char_ptr;
+
+ c : int;
+
+begin
+ val :=NIL;
+ name :=NIL;
+ nameEnd:=NIL;
+
+ inc(ptrcomp(ptr ) ,5 * enc.minBytesPerChar );
+ dec(ptrcomp(end_ ) ,2 * enc.minBytesPerChar );
+
+ if (parsePseudoAttribute(enc ,ptr ,end_ ,@name ,@nameEnd ,@val ,@ptr ) = 0 ) or
+ (name = NIL ) then
+ begin
+ badPtr^:=ptr;
+ result :=0;
+
+ exit;
+
+ end;
+
+ if XmlNameMatchesAscii(enc ,name ,nameEnd ,@KW_version[0 ] ) = 0 then
+ if isGeneralTextEntity = 0 then
+ begin
+ badPtr^:=name;
+ result :=0;
+
+ exit;
+
+ end
+ else
+ else
+ begin
+ if versionPtr <> NIL then
+ versionPtr^:=val;
+
+ if versionEndPtr <> NIL then
+ versionEndPtr^:=ptr;
+
+ if parsePseudoAttribute(enc ,ptr ,end_ ,@name ,@nameEnd ,@val ,@ptr ) = 0 then
+ begin
+ badPtr^:=ptr;
+ result :=0;
+
+ exit;
+
+ end;
+
+ if name = NIL then
+ begin
+ if isGeneralTextEntity <> 0 then
+ begin
+ { a TextDecl must have an EncodingDecl }
+
+ badPtr^:=ptr;
+ result :=0;
+
+ exit;
+
+ end;
+
+ result:=1;
+
+ exit;
+
+ end;
+
+ end;
+
+ if XmlNameMatchesAscii(enc ,name ,nameEnd ,@KW_encoding[0 ] ) <> 0 then
+ begin
+ c:=toAscii(enc ,val ,end_ );
+
+ if not((int(ASCII_al ) <= c ) and (c <= int(ASCII_zl ) ) ) and
+ not((int(ASCII_A ) <= c ) and (c <= int(ASCII_Z ) ) ) then
+ begin
+ badPtr^:=val;
+ result :=0;
+
+ exit;
+
+ end;
+
+ if encodingName <> NIL then
+ encodingName^:=val;
+
+ if encoding <> NIL then
+ encoding^:=encodingFinder(enc ,val ,char_ptr(ptrcomp(ptr ) - enc.minBytesPerChar ) );
+
+ if parsePseudoAttribute(enc ,ptr ,end_ ,@name ,@nameEnd ,@val ,@ptr ) = 0 then
+ begin
+ badPtr^:=ptr;
+ result :=0;
+
+ exit;
+
+ end;
+
+ if name <> NIL then
+ begin
+ result:=1;
+
+ exit;
+
+ end;
+
+ end;
+
+ if (XmlNameMatchesAscii(enc ,name ,nameEnd ,@KW_standalone[0 ] ) = 0 ) or
+ (isGeneralTextEntity <> 0 ) then
+ begin
+ badPtr^:=name;
+ result :=0;
+
+ exit;
+
+ end;
+
+ if XmlNameMatchesAscii(enc ,val ,char_ptr(ptrcomp(ptr ) - enc.minBytesPerChar ) ,@KW_yes[0 ] ) <> 0 then
+ if standalone <> NIL then
+ standalone^:=1
+ else
+ else
+ if XmlNameMatchesAscii(enc ,val ,char_ptr(ptrcomp(ptr ) - enc.minBytesPerChar ) ,@KW_no[0 ] ) <> 0 then
+ if standalone <> NIL then
+ standalone^:=0
+ else
+ else
+ begin
+ badPtr^:=val;
+ result :=0;
+
+ exit;
+
+ end;
+
+ while isSpace(toAscii(enc ,ptr ,end_ ) ) <> 0 do
+ inc(ptrcomp(ptr ) ,enc.minBytesPerChar );
+
+ if ptr <> end_ then
+ begin
+ badPtr^:=ptr;
+ result :=0;
+
+ exit;
+
+ end;
+
+ result:=1;
+
+end;
+
+{$I xmltok_ns.inc }
+
+{ XMLTOK_ }
+function XmlTok_;
+begin
+ result:=enc.scanners[state ](enc ,ptr ,end_ ,nextTokPtr );
+
+end;
+
+{ XMLPROLOGTOK }
+function XmlPrologTok;
+begin
+ result:=XmlTok_(enc ,XML_PROLOG_STATE ,ptr ,end_ ,nextTokPtr );
+
+end;
+
+{ XMLCONTENTTOK }
+function XmlContentTok;
+begin
+ result:=XmlTok_(enc ,XML_CONTENT_STATE ,ptr ,end_ ,nextTokPtr );
+
+end;
+
+{ XMLISPUBLICID }
+function XmlIsPublicId;
+begin
+ result:=enc.isPublicId(enc ,ptr ,end_ ,badPtr );
+
+end;
+
+{ XMLUTF8CONVERT }
+procedure XmlUtf8Convert;
+begin
+ enc.utf8Convert(enc ,fromP ,fromLim ,toP ,toLim );
+
+end;
+
+{ XMLUTF16CONVERT }
+procedure XmlUtf16Convert;
+begin
+ enc.utf16Convert(enc ,fromP ,fromLim ,toP ,toLim );
+
+end;
+
+{ XMLUTF8ENCODE {..}{unicode}
+function XmlUtf8Encode;
+begin
+end;
+
+{ XMLUTF16ENCODE {..}{unicode}
+function XmlUtf16Encode;
+begin
+end;
+
+{ XMLLITERALTOK }
+function XmlLiteralTok;
+begin
+ result:=enc.literalScanners[literalType ](enc ,ptr ,end_ ,nextTokPtr );
+
+end;
+
+{ XMLATTRIBUTEVALUETOK }
+function XmlAttributeValueTok;
+begin
+ result:=XmlLiteralTok(enc ,XML_ATTRIBUTE_VALUE_LITERAL ,ptr ,end_ ,nextTokPtr );
+
+end;
+
+{ XMLENTITYVALUETOK }
+function XmlEntityValueTok;
+begin
+ result:=XmlLiteralTok(enc ,XML_ENTITY_VALUE_LITERAL ,ptr ,end_ ,nextTokPtr );
+
+end;
+
+{ XMLSAMENAME }
+function XmlSameName;
+begin
+ result:=enc.sameName(enc ,ptr1 ,ptr2 );
+
+end;
+
+{ XMLNAMEMATCHESASCII }
+function XmlNameMatchesAscii;
+begin
+ result:=enc.nameMatchesAscii(enc ,ptr1 ,end1 ,ptr2 );
+
+end;
+
+{ XMLNAMELENGTH }
+function XmlNameLength;
+begin
+ result:=enc.nameLength(enc ,ptr );
+
+end;
+
+{ XMLGETATTRIBUTES }
+function XmlGetAttributes;
+begin
+ result:=enc.getAtts(enc ,ptr ,attsMax ,atts );
+
+end;
+
+{ XMLCHARREFNUMBER }
+function XmlCharRefNumber;
+begin
+ result:=enc.charRefNumber(enc ,ptr );
+
+end;
+
+{ XMLPREDEFINEDENTITYNAME }
+function XmlPredefinedEntityName;
+begin
+ result:=enc.predefinedEntityName(enc ,ptr ,end_ );
+
+end;
+
+{ XMLPARSEXMLDECLNS {..}
+function XmlParseXmlDeclNS;
+begin
+end;
+
+END.
+
+{unicode}
+
diff --git a/src/corelib/render/software/agg-demos/expat-pas/xmltok_impl.inc b/src/corelib/render/software/agg-demos/expat-pas/xmltok_impl.inc
index 25403e96..6ae0d213 100755..100644
--- a/src/corelib/render/software/agg-demos/expat-pas/xmltok_impl.inc
+++ b/src/corelib/render/software/agg-demos/expat-pas/xmltok_impl.inc
@@ -1,4176 +1,4176 @@
-//----------------------------------------------------------------------------
-// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
-// and Clark Cooper
-// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
-//
-// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
-// Pascal Port By: Milan Marusinec alias Milano
-// milan@marusinec.sk
-// http://www.pasports.org/pasexpat
-// Copyright (c) 2006
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// [Pascal Port History] -----------------------------------------------------
-//
-// 17.05.2006-Milano: Unit port establishment
-// 02.06.2006-Milano: porting
-// 05.06.2006-Milano: -"-
-// 06.06.2006-Milano: -"-
-// 12.06.2006-Milano: -"-
-// 15.06.2006-Milano: normal_contentTok
-// 16.06.2006-Milano: -"-, porting
-// 17.06.2006-Milano: -"-
-// 21.06.2006-Milano: -"-
-// 22.06.2006-Milano: -"-
-//
-{ xmltok_impl.inc }
-{$Q- }
-{$R- }
-{ normal_scanRef {..}
-function normal_scanRef(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
-begin
-end;
-
-{ normal_scanAtts }
-function normal_scanAtts(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
-var
-{$IFDEF XML_NS }
- hadColon : int;
-
-{$ENDIF }
-
- t ,open ,tok : int;
-
-label
- _bt0 ,_bt1 ,_bte ,sol ,gt ,_bt2 ;
-
-begin
-{$IFDEF XML_NS }
- hadColon:=0;
-
-{$ENDIF }
-
- while ptr <> end_ do
- case BYTE_TYPE(enc ,ptr ) of
- {#define CHECK_NAME_CASES}
- BT_NONASCII :
- if IS_NAME_CHAR_MINBPC(enc ,ptr ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end
- else
- goto _bt0;
-
- BT_NMSTRT ,BT_HEX ,BT_DIGIT ,BT_NAME ,BT_MINUS :
- _bt0:
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- BT_LEAD2 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_NAME_CHAR(enc ,ptr ,2 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,2 );
-
- end;
-
- BT_LEAD3 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_NAME_CHAR(enc ,ptr ,3 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,3 );
-
- end;
-
- BT_LEAD4 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_NAME_CHAR(enc ,ptr ,4 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,4 );
-
- end;
-
- {CHECK_NAME_CASES #define}
-
- {$IFDEF XML_NS }
- BT_COLON :
- begin
- if hadColon <> 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- hadColon:=1;
-
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- if ptr <> end_ then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- case BYTE_TYPE(enc ,ptr ) of
- {#define CHECK_NMSTRT_CASES}
- BT_NONASCII :
- if IS_NMSTRT_CHAR_MINBPC(enc ,ptr ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end
- else
- goto _bt1;
-
- BT_NMSTRT ,BT_HEX :
- _bt1:
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- BT_LEAD2 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if not IS_NMSTRT_CHAR(enc ,ptr ,2 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- end;
-
- inc(ptrcomp(ptr ) ,2 );
-
- end;
-
- BT_LEAD3 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if not IS_NMSTRT_CHAR(enc ,ptr ,3 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- end;
-
- inc(ptrcomp(ptr ) ,3 );
-
- end;
-
- BT_LEAD4 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if not IS_NMSTRT_CHAR(enc ,ptr ,4 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- end;
-
- inc(ptrcomp(ptr ) ,4 );
-
- end;
-
- {CHECK_NMSTRT_CASES #define}
-
- else
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
- end;
-
- {$ENDIF }
-
- BT_S ,BT_CR ,BT_LF :
- begin
- repeat
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- if ptr <> end_ then
- result:=XML_TOK_PARTIAL;
-
- t:=BYTE_TYPE(enc ,ptr );
-
- if t = BT_EQUALS then
- break;
-
- case t of
- BT_S ,BT_LF ,BT_CR :
- break;
-
- else
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
- until false;
-
- { fall through }
- goto _bte;
-
- end;
-
- BT_EQUALS :
- _bte:
- begin
- {$IFDEF XML_NS }
- hadColon:=0;
-
- {$ENDIF }
-
- repeat
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- if ptr = end_ then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- open:=BYTE_TYPE(enc ,ptr );
-
- if (open = BT_QUOT ) or
- (open = BT_APOS ) then
- break;
-
- case open of
- BT_S ,BT_LF ,BT_CR :
- else
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
- until false;
-
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- { in attribute value }
- repeat
- if ptr = end_ then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- t:=BYTE_TYPE(enc ,ptr );
-
- if t = open then
- break;
-
- case t of
- {#define INVALID_CASES}
- BT_LEAD2 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_INVALID_CHAR(enc ,ptr ,2 ) <> 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,2 );
-
- end;
-
- BT_LEAD3 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_INVALID_CHAR(enc ,ptr ,3 ) <> 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,3 );
-
- end;
-
- BT_LEAD4 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_INVALID_CHAR(enc ,ptr ,4 ) <> 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,4 );
-
- end;
-
- BT_NONXML ,BT_MALFORM ,BT_TRAIL :
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- {INVALID_CASES #define}
-
- BT_AMP :
- begin
- tok:=normal_scanRef(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,@ptr );
-
- if tok <= 0 then
- begin
- if tok = XML_TOK_INVALID then
- nextTokPtr^:=ptr;
-
- result:=tok;
-
- exit;
-
- end;
-
- end;
-
- BT_LT :
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- else
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- end;
-
- until false;
-
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- if ptr = end_ then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- case BYTE_TYPE(enc ,ptr ) of
- BT_SOL :
- goto sol;
-
- BT_GT :
- goto gt;
-
- BT_S ,BT_CR ,BT_LF :
- else
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
- { ptr points to closing quote }
- repeat
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- if ptr = end_ then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- case BYTE_TYPE(enc ,ptr ) of
- {#define CHECK_NMSTRT_CASES}
- BT_NONASCII :
- if IS_NMSTRT_CHAR_MINBPC(enc ,ptr ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end
- else
- goto _bt2;
-
- BT_NMSTRT ,BT_HEX :
- _bt2:
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- BT_LEAD2 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if not IS_NMSTRT_CHAR(enc ,ptr ,2 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- end;
-
- inc(ptrcomp(ptr ) ,2 );
-
- end;
-
- BT_LEAD3 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if not IS_NMSTRT_CHAR(enc ,ptr ,3 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- end;
-
- inc(ptrcomp(ptr ) ,3 );
-
- end;
-
- BT_LEAD4 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if not IS_NMSTRT_CHAR(enc ,ptr ,4 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- end;
-
- inc(ptrcomp(ptr ) ,4 );
-
- end;
-
- {CHECK_NMSTRT_CASES #define}
-
- BT_S ,BT_CR ,BT_LF :
- continue;
-
- BT_GT :
- gt:
- begin
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- result:=XML_TOK_START_TAG_WITH_ATTS;
-
- exit;
-
- end;
-
- BT_SOL :
- sol:
- begin
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- if ptr = end_ then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- if CHAR_MATCHES(enc ,ptr ,int(ASCII_GT ) ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- result:=XML_TOK_EMPTY_ELEMENT_WITH_ATTS;
-
- exit;
-
- end;
-
- else
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
- break;
-
- until false;
-
- end;
-
- else
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
- result:=XML_TOK_PARTIAL;
-
-end;
-
-{ normal_scanEndTag }
-{ ptr points to character following "</" }
-function normal_scanEndTag(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
-label
- _bt0 ,_bt1 ;
-
-begin
- if ptr = end_ then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- case BYTE_TYPE(enc ,ptr ) of
- {#define CHECK_NMSTRT_CASES}
- BT_NONASCII :
- if IS_NMSTRT_CHAR_MINBPC(enc ,ptr ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end
- else
- goto _bt0;
-
- BT_NMSTRT ,BT_HEX :
- _bt0:
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- BT_LEAD2 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if not IS_NMSTRT_CHAR(enc ,ptr ,2 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- end;
-
- inc(ptrcomp(ptr ) ,2 );
-
- end;
-
- BT_LEAD3 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if not IS_NMSTRT_CHAR(enc ,ptr ,3 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- end;
-
- inc(ptrcomp(ptr ) ,3 );
-
- end;
-
- BT_LEAD4 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if not IS_NMSTRT_CHAR(enc ,ptr ,4 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- end;
-
- inc(ptrcomp(ptr ) ,4 );
-
- end;
-
- {CHECK_NMSTRT_CASES #define}
-
- else
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
- while ptr <> end_ do
- case BYTE_TYPE(enc ,ptr ) of
- {#define CHECK_NAME_CASES}
- BT_NONASCII :
- if IS_NAME_CHAR_MINBPC(enc ,ptr ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end
- else
- goto _bt1;
-
- BT_NMSTRT ,BT_HEX ,BT_DIGIT ,BT_NAME ,BT_MINUS :
- _bt1:
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- BT_LEAD2 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_NAME_CHAR(enc ,ptr ,2 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,2 );
-
- end;
-
- BT_LEAD3 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_NAME_CHAR(enc ,ptr ,3 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,3 );
-
- end;
-
- BT_LEAD4 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_NAME_CHAR(enc ,ptr ,4 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,4 );
-
- end;
-
- {CHECK_NAME_CASES #define}
-
- BT_S ,BT_CR ,BT_LF :
- begin
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- while ptr <> end_ do
- begin
- case BYTE_TYPE(enc ,ptr ) of
- BT_GT :
- begin
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- result:=XML_TOK_END_TAG;
-
- exit;
-
- end;
-
- BT_S ,BT_CR ,BT_LF :
- else
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- end;
-
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- {$IFDEF XML_NS }
- BT_COLON :
- { no need to check qname syntax here,
- since end-tag must match exactly }
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- {$ENDIF }
-
- BT_GT :
- begin
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- result:=XML_TOK_END_TAG;
-
- exit;
-
- end;
-
- else
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
- result:=XML_TOK_PARTIAL;
-
-end;
-
-{ normal_scanComment }
-{ ptr points to character following "<!-" }
-function normal_scanComment(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
-begin
- if ptr <> end_ then
- begin
- if CHAR_MATCHES(enc ,ptr ,int(ASCII_MINUS ) ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- while ptr <> end_ do
- case BYTE_TYPE(enc ,ptr ) of
- {#define INVALID_CASES}
- BT_LEAD2 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_INVALID_CHAR(enc ,ptr ,2 ) <> 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,2 );
-
- end;
-
- BT_LEAD3 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_INVALID_CHAR(enc ,ptr ,3 ) <> 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,3 );
-
- end;
-
- BT_LEAD4 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_INVALID_CHAR(enc ,ptr ,4 ) <> 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,4 );
-
- end;
-
- BT_NONXML ,BT_MALFORM ,BT_TRAIL :
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- {INVALID_CASES #define}
-
- BT_MINUS :
- begin
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- if ptr = end_ then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- if CHAR_MATCHES(enc ,ptr ,int(ASCII_MINUS ) ) <> 0 then
- begin
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- if ptr = end_ then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- if CHAR_MATCHES(enc ,ptr ,int(ASCII_GT ) ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- result:=XML_TOK_COMMENT;
-
- exit;
-
- end;
-
- end;
-
- else
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- end;
-
- end;
-
- result:=XML_TOK_PARTIAL;
-
-end;
-
-{ normal_scanCdataSection {..}
-function normal_scanCdataSection(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
-begin
-end;
-
-{ normal_checkPiTarget }
-function normal_checkPiTarget(enc : ENCODING_ptr; ptr ,end_ : char_ptr; tokPtr : int_ptr ) : int;
-var
- upper : int;
-
-begin
- upper :=0;
- tokPtr^:=XML_TOK_PI;
-
- if ptrcomp(end_ ) - ptrcomp(ptr ) <> MINBPC(enc ) * 3 then
- begin
- result:=1;
-
- exit;
-
- end;
-
- case BYTE_TO_ASCII(enc ,ptr ) of
- int(ASCII_X ) :
- upper:=1;
-
- int(ASCII_xl ) :
- else
- begin
- result:=1;
-
- exit;
-
- end;
-
- end;
-
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- case BYTE_TO_ASCII(enc ,ptr ) of
- int(ASCII_M ) :
- upper:=1;
-
- int(ASCII_ml ) :
- else
- begin
- result:=1;
-
- exit;
-
- end;
-
- end;
-
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- case BYTE_TO_ASCII(enc ,ptr ) of
- int(ASCII_L ) :
- upper:=1;
-
- int(ASCII_ll ) :
- else
- begin
- result:=1;
-
- exit;
-
- end;
-
- end;
-
- if upper <> 0 then
- begin
- result:=0;
-
- exit;
-
- end;
-
- tokPtr^:=XML_TOK_XML_DECL;
- result :=1;
-
-end;
-
-{ normal_scanPi }
-{ ptr points to character following "<?" }
-function normal_scanPi(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
-var
- tok : int;
-
- target : char_ptr;
-
-label
- _bt0 ,_bt1 ,_else ;
-
-begin
- target:=ptr;
-
- if ptr = end_ then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- case BYTE_TYPE(enc ,ptr ) of
- {#define CHECK_NMSTRT_CASES}
- BT_NONASCII :
- if IS_NMSTRT_CHAR_MINBPC(enc ,ptr ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end
- else
- goto _bt0;
-
- BT_NMSTRT ,BT_HEX :
- _bt0:
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- BT_LEAD2 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if not IS_NMSTRT_CHAR(enc ,ptr ,2 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- end;
-
- inc(ptrcomp(ptr ) ,2 );
-
- end;
-
- BT_LEAD3 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if not IS_NMSTRT_CHAR(enc ,ptr ,3 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- end;
-
- inc(ptrcomp(ptr ) ,3 );
-
- end;
-
- BT_LEAD4 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if not IS_NMSTRT_CHAR(enc ,ptr ,4 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- end;
-
- inc(ptrcomp(ptr ) ,4 );
-
- end;
-
- {CHECK_NMSTRT_CASES #define}
-
- else
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
- while ptr <> end_ do
- case BYTE_TYPE(enc ,ptr ) of
- {#define CHECK_NAME_CASES}
- BT_NONASCII :
- if IS_NAME_CHAR_MINBPC(enc ,ptr ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end
- else
- goto _bt1;
-
- BT_NMSTRT ,BT_HEX ,BT_DIGIT ,BT_NAME ,BT_MINUS :
- _bt1:
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- BT_LEAD2 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_NAME_CHAR(enc ,ptr ,2 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,2 );
-
- end;
-
- BT_LEAD3 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_NAME_CHAR(enc ,ptr ,3 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,3 );
-
- end;
-
- BT_LEAD4 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_NAME_CHAR(enc ,ptr ,4 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,4 );
-
- end;
-
- {CHECK_NAME_CASES #define}
-
- BT_S ,BT_CR ,BT_LF :
- begin
- if normal_checkPiTarget(enc ,target ,ptr ,@tok ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- while ptr <> end_ do
- case BYTE_TYPE(enc ,ptr ) of
- {#define INVALID_CASES}
- BT_LEAD2 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_INVALID_CHAR(enc ,ptr ,2 ) <> 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,2 );
-
- end;
-
- BT_LEAD3 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_INVALID_CHAR(enc ,ptr ,3 ) <> 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,3 );
-
- end;
-
- BT_LEAD4 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_INVALID_CHAR(enc ,ptr ,4 ) <> 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,4 );
-
- end;
-
- BT_NONXML ,BT_MALFORM ,BT_TRAIL :
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- {INVALID_CASES #define}
-
- BT_QUEST :
- begin
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- if ptr = end_ then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- if CHAR_MATCHES(enc ,ptr ,int(ASCII_GT ) ) <> 0 then
- begin
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- result:=tok;
-
- exit;
-
- end;
-
- end;
-
- else
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- end;
-
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- BT_QUEST :
- begin
- if normal_checkPiTarget(enc ,target ,ptr ,@tok ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- if ptr = end_ then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- if CHAR_MATCHES(enc ,ptr ,int(ASCII_GT ) ) <> 0 then
- begin
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- result:=tok;
-
- exit;
-
- end;
-
- { fall through }
- goto _else;
-
- end;
-
- else
- begin
- _else:
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
- result:=XML_TOK_PARTIAL;
-
-end;
-
-{ normal_scanLt }
-{ ptr points to character following "<" }
-function normal_scanLt(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
-{$IFDEF XML_NS }
-var
- hadColon : int;
-
-{$ENDIF }
-
-label
- _bt0 ,_bt1 ,_bt2 ,_bt3 ,gt ,sol ;
-
-begin
- if ptr = end_ then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- case BYTE_TYPE(enc ,ptr ) of
- {#define CHECK_NMSTRT_CASES}
- BT_NONASCII :
- if IS_NMSTRT_CHAR_MINBPC(enc ,ptr ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end
- else
- goto _bt0;
-
- BT_NMSTRT ,BT_HEX :
- _bt0:
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- BT_LEAD2 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if not IS_NMSTRT_CHAR(enc ,ptr ,2 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- end;
-
- inc(ptrcomp(ptr ) ,2 );
-
- end;
-
- BT_LEAD3 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if not IS_NMSTRT_CHAR(enc ,ptr ,3 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- end;
-
- inc(ptrcomp(ptr ) ,3 );
-
- end;
-
- BT_LEAD4 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if not IS_NMSTRT_CHAR(enc ,ptr ,4 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- end;
-
- inc(ptrcomp(ptr ) ,4 );
-
- end;
-
- {CHECK_NMSTRT_CASES #define}
-
- BT_EXCL :
- begin
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- if ptr = end_ then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- case BYTE_TYPE(enc ,ptr ) of
- BT_MINUS:
- begin
- result:=normal_scanComment(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
-
- exit;
-
- end;
-
- BT_LSQB:
- begin
- result:=normal_scanCdataSection(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
-
- exit;
-
- end;
-
- end;
-
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- BT_QUEST :
- begin
- result:=normal_scanPi(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
-
- exit;
-
- end;
-
- BT_SOL :
- begin
- result:=normal_scanEndTag(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
-
- exit;
-
- end;
-
- else
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
-{$IFDEF XML_NS }
- hadColon:=0;
-
-{$ENDIF }
-
-{ we have a start-tag }
- while ptr <> end_ do
- case BYTE_TYPE(enc ,ptr ) of
- {#define CHECK_NAME_CASES}
- BT_NONASCII :
- if IS_NAME_CHAR_MINBPC(enc ,ptr ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end
- else
- goto _bt1;
-
- BT_NMSTRT ,BT_HEX ,BT_DIGIT ,BT_NAME ,BT_MINUS :
- _bt1:
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- BT_LEAD2 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_NAME_CHAR(enc ,ptr ,2 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,2 );
-
- end;
-
- BT_LEAD3 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_NAME_CHAR(enc ,ptr ,3 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,3 );
-
- end;
-
- BT_LEAD4 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_NAME_CHAR(enc ,ptr ,4 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,4 );
-
- end;
-
- {CHECK_NAME_CASES #define}
-
- {$IFDEF XML_NS }
- BT_COLON :
- begin
- if hadColon <> 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- hadColon:=1;
-
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- if ptr = end_ then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- case BYTE_TYPE(enc ,ptr ) of
- {#define CHECK_NMSTRT_CASES}
- BT_NONASCII :
- if IS_NMSTRT_CHAR_MINBPC(enc ,ptr ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end
- else
- goto _bt2;
-
- BT_NMSTRT ,BT_HEX :
- _bt2:
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- BT_LEAD2 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if not IS_NMSTRT_CHAR(enc ,ptr ,2 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- end;
-
- inc(ptrcomp(ptr ) ,2 );
-
- end;
-
- BT_LEAD3 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if not IS_NMSTRT_CHAR(enc ,ptr ,3 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- end;
-
- inc(ptrcomp(ptr ) ,3 );
-
- end;
-
- BT_LEAD4 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if not IS_NMSTRT_CHAR(enc ,ptr ,4 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- end;
-
- inc(ptrcomp(ptr ) ,4 );
-
- end;
-
- {CHECK_NMSTRT_CASES #define}
-
- else
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
- end;
-
- {$ENDIF }
-
- BT_S ,BT_CR ,BT_LF :
- begin
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- while ptr <> end_ do
- begin
- case BYTE_TYPE(enc ,ptr ) of
- {#define CHECK_NMSTRT_CASES}
- BT_NONASCII :
- if IS_NMSTRT_CHAR_MINBPC(enc ,ptr ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end
- else
- goto _bt3;
-
- BT_NMSTRT ,BT_HEX :
- _bt3:
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- BT_LEAD2 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if not IS_NMSTRT_CHAR(enc ,ptr ,2 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- end;
-
- inc(ptrcomp(ptr ) ,2 );
-
- end;
-
- BT_LEAD3 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if not IS_NMSTRT_CHAR(enc ,ptr ,3 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- end;
-
- inc(ptrcomp(ptr ) ,3 );
-
- end;
-
- BT_LEAD4 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if not IS_NMSTRT_CHAR(enc ,ptr ,4 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- end;
-
- inc(ptrcomp(ptr ) ,4 );
-
- end;
-
- {CHECK_NMSTRT_CASES #define}
-
- BT_GT :
- goto gt;
-
- BT_SOL :
- goto sol;
-
- BT_S ,BT_CR ,BT_LF :
- begin
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- continue;
-
- end;
-
- else
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
- result:=normal_scanAtts(enc ,ptr ,end_ ,nextTokPtr );
-
- exit;
-
- end;
-
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- BT_GT :
- gt:
- begin
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- result:=XML_TOK_START_TAG_NO_ATTS;
-
- exit;
-
- end;
-
- BT_SOL :
- sol:
- begin
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- if ptr <> end_ then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- if CHAR_MATCHES(enc ,ptr ,int(ASCII_GT ) ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- result:=XML_TOK_EMPTY_ELEMENT_NO_ATTS;
-
- exit;
-
- end;
-
- else
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
- result:=XML_TOK_PARTIAL;
-
-end;
-
-{ normal_scanDecl }
-{ ptr points to character following "<!" }
-function normal_scanDecl(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
-label
- _fall0 ;
-
-begin
- if ptr = end_ then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- case BYTE_TYPE(enc ,ptr ) of
- BT_MINUS :
- begin
- result:=normal_scanComment(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
-
- exit;
-
- end;
-
- BT_LSQB :
- begin
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- result:=XML_TOK_COND_SECT_OPEN;
-
- exit;
-
- end;
-
- BT_NMSTRT ,BT_HEX:
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- else
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
- while ptr <> end_ do
- case BYTE_TYPE(enc ,ptr ) of
- BT_PERCNT :
- begin
- if ptrcomp(ptr ) + MINBPC(enc ) = ptrcomp(end_ ) then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- { don't allow <!ENTITY% foo "whatever"> }
- case BYTE_TYPE(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ) of
- BT_S ,BT_CR ,BT_LF ,BT_PERCNT :
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
- { fall through }
- goto _fall0;
-
- end;
-
- BT_S ,BT_CR ,BT_LF :
- _fall0:
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_DECL_OPEN;
-
- exit;
-
- end;
-
- BT_NMSTRT ,BT_HEX :
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- else
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
- result:=XML_TOK_PARTIAL;
-
-end;
-
-{ scanPercent {..}
-{ ptr points to character following "%" }
-function scanPercent(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
-begin
-end;
-
-{ scanPoundName {..}
-function scanPoundName(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
-begin
-end;
-
-{ normal_scanLit }
-function normal_scanLit(
- open : int; enc : ENCODING_ptr;
- ptr ,end_ : char_ptr;
- nextTokPtr : char_ptr_ptr ) : int;
-var
- t : int;
-
-label
- _break ;
-
-begin
- while ptr <> end_ do
- begin
- t:=BYTE_TYPE(enc ,ptr );
-
- case t of
- {#define INVALID_CASES}
- BT_LEAD2 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_INVALID_CHAR(enc ,ptr ,2 ) <> 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,2 );
-
- end;
-
- BT_LEAD3 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_INVALID_CHAR(enc ,ptr ,3 ) <> 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,3 );
-
- end;
-
- BT_LEAD4 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_INVALID_CHAR(enc ,ptr ,4 ) <> 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,4 );
-
- end;
-
- BT_NONXML ,BT_MALFORM ,BT_TRAIL :
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- {INVALID_CASES #define}
-
- BT_QUOT ,BT_APOS :
- begin
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- if t <> open then
- goto _break;
-
- if ptr = end_ then
- begin
- result:=-XML_TOK_LITERAL;
-
- exit;
-
- end;
-
- nextTokPtr^:=ptr;
-
- case BYTE_TYPE(enc ,ptr ) of
- BT_S ,BT_CR ,BT_LF ,BT_GT ,BT_PERCNT ,BT_LSQB :
- begin
- result:=XML_TOK_LITERAL;
-
- exit;
-
- end;
-
- else
- begin
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
- end;
-
- else
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- end;
-
- _break:
- end;
-
- result:=XML_TOK_PARTIAL;
-
-end;
-
-{ normal_prologTok }
-function normal_prologTok(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
-var
- tok : int;
-
- n : size_t;
-
-label
- _bt_s ,_else ,_else2 ,_bt0 ,_bt1 ;
-
-begin
- if ptr = end_ then
- begin
- result:=XML_TOK_NONE;
-
- exit;
-
- end;
-
- if MINBPC(enc ) > 1 then
- begin
- n:=ptrcomp(end_ ) - ptrcomp(ptr );
-
- if n and (MINBPC(enc ) - 1 ) <> 0 then
- begin
- n:=n and not(MINBPC(enc ) - 1 );
-
- if n = 0 then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- end_:=char_ptr(ptrcomp(ptr ) + n );
-
- end;
-
- end;
-
- case BYTE_TYPE(enc ,ptr ) of
- BT_QUOT :
- begin
- result:=normal_scanLit(BT_QUOT ,enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
-
- exit;
-
- end;
-
- BT_APOS :
- begin
- result:=normal_scanLit(BT_APOS ,enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
-
- exit;
-
- end;
-
- BT_LT :
- begin
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- if ptr = end_ then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- case BYTE_TYPE(enc ,ptr ) of
- BT_EXCL :
- begin
- result:=normal_scanDecl(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
-
- exit;
-
- end;
-
- BT_QUEST :
- begin
- result:=normal_scanPi(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
-
- exit;
-
- end;
-
- BT_NMSTRT ,BT_HEX ,BT_NONASCII ,BT_LEAD2 ,BT_LEAD3 ,BT_LEAD4 :
- begin
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) - MINBPC(enc ) );
-
- result:=XML_TOK_INSTANCE_START;
-
- exit;
-
- end;
-
- end;
-
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- BT_CR :
- if ptrcomp(ptr ) + MINBPC(enc ) = ptrcomp(end_ ) then
- begin
- nextTokPtr^:=end_;
-
- { indicate that this might be part of a CR/LF pair }
- result:=-XML_TOK_PROLOG_S;
-
- exit;
-
- end
- else
- { fall through }
- goto _bt_s;
-
- BT_S ,BT_LF :
- _bt_s:
- begin
- repeat
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- if ptr = end_ then
- break;
-
- case BYTE_TYPE(enc ,ptr ) of
- BT_CR :
- { don't split CR/LF pair }
- if ptrcomp(ptr ) + MINBPC(enc ) <> ptrcomp(end_ ) then
- else
- { fall through }
- goto _else;
-
- BT_S ,BT_LF :
- else
- begin
- _else:
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_PROLOG_S;
-
- exit;
-
- end;
-
- end;
-
- until false;
-
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_PROLOG_S;
-
- exit;
-
- end;
-
- BT_PERCNT :
- begin
- result:=scanPercent(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
-
- exit;
-
- end;
-
- BT_COMMA :
- begin
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- result:=XML_TOK_COMMA;
-
- exit;
-
- end;
-
- BT_LSQB :
- begin
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- result:=XML_TOK_OPEN_BRACKET;
-
- exit;
-
- end;
-
- BT_RSQB :
- begin
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- if ptr = end_ then
- begin
- result:=-XML_TOK_CLOSE_BRACKET;
-
- exit;
-
- end;
-
- if CHAR_MATCHES(enc ,ptr ,int(ASCII_RSQB ) ) <> 0 then
- begin
- if ptrcomp(ptr ) + MINBPC(enc ) = ptrcomp(end_ ) then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- if CHAR_MATCHES(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,int(ASCII_GT ) ) <> 0 then
- begin
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + 2 * MINBPC(enc ) );
-
- result:=XML_TOK_COND_SECT_CLOSE;
-
- exit;
-
- end;
-
- end;
-
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_CLOSE_BRACKET;
-
- exit;
-
- end;
-
- BT_LPAR :
- begin
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- result:=XML_TOK_OPEN_PAREN;
-
- exit;
-
- end;
-
- BT_RPAR :
- begin
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- if ptr = end_ then
- begin
- result:=-XML_TOK_CLOSE_PAREN;
-
- exit;
-
- end;
-
- case BYTE_TYPE(enc ,ptr ) of
- BT_AST :
- begin
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- result:=XML_TOK_CLOSE_PAREN_ASTERISK;
-
- exit;
-
- end;
-
- BT_QUEST :
- begin
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- result:=XML_TOK_CLOSE_PAREN_QUESTION;
-
- exit;
-
- end;
-
- BT_PLUS :
- begin
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- result:=XML_TOK_CLOSE_PAREN_PLUS;
-
- exit;
-
- end;
-
- BT_CR ,BT_LF ,BT_S ,BT_GT ,BT_COMMA ,BT_VERBAR ,BT_RPAR :
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_CLOSE_PAREN;
-
- exit;
-
- end;
-
- end;
-
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- BT_VERBAR :
- begin
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- result:=XML_TOK_OR;
-
- exit;
-
- end;
-
- BT_GT :
- begin
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- result:=XML_TOK_DECL_CLOSE;
-
- exit;
-
- end;
-
- BT_NUM :
- begin
- result:=scanPoundName(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
-
- exit;
-
- end;
-
- BT_LEAD2 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_NMSTRT_CHAR(enc ,ptr ,2 ) <> 0 then
- begin
- inc(ptrcomp(ptr ) ,2 );
-
- tok:=XML_TOK_NAME;
-
- end
- else
- if IS_NAME_CHAR(enc ,ptr ,2 ) <> 0 then
- begin
- inc(ptrcomp(ptr ) ,2 );
-
- tok:=XML_TOK_NMTOKEN;
-
- end
- else
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
- BT_LEAD3 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_NMSTRT_CHAR(enc ,ptr ,3 ) <> 0 then
- begin
- inc(ptrcomp(ptr ) ,3 );
-
- tok:=XML_TOK_NAME;
-
- end
- else
- if IS_NAME_CHAR(enc ,ptr ,3 ) <> 0 then
- begin
- inc(ptrcomp(ptr ) ,3 );
-
- tok:=XML_TOK_NMTOKEN;
-
- end
- else
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
- BT_LEAD4 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_NMSTRT_CHAR(enc ,ptr ,4 ) <> 0 then
- begin
- inc(ptrcomp(ptr ) ,4 );
-
- tok:=XML_TOK_NAME;
-
- end
- else
- if IS_NAME_CHAR(enc ,ptr ,4 ) <> 0 then
- begin
- inc(ptrcomp(ptr ) ,4 );
-
- tok:=XML_TOK_NMTOKEN;
-
- end
- else
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
- BT_NMSTRT ,BT_HEX :
- begin
- tok:=XML_TOK_NAME;
-
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- end;
-
- BT_DIGIT ,BT_NAME ,BT_MINUS {$IFDEF XML_NS } ,BT_COLON : {$ELSE }: {$ENDIF }
- begin
- tok:=XML_TOK_NMTOKEN;
-
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- end;
-
- BT_NONASCII :
- if IS_NMSTRT_CHAR_MINBPC(enc ,ptr ) <> 0 then
- begin
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- tok:=XML_TOK_NAME;
-
- end
- else
- if IS_NAME_CHAR_MINBPC(enc ,ptr ) <> 0 then
- begin
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- tok:=XML_TOK_NMTOKEN;
-
- end
- else
- { fall through }
- goto _else2;
-
- else
- begin
- _else2:
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
- while ptr <> end_ do
- case BYTE_TYPE(enc ,ptr ) of
- {#define CHECK_NAME_CASES}
- BT_NONASCII :
- if IS_NAME_CHAR_MINBPC(enc ,ptr ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end
- else
- goto _bt0;
-
- BT_NMSTRT ,BT_HEX ,BT_DIGIT ,BT_NAME ,BT_MINUS :
- _bt0:
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- BT_LEAD2 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_NAME_CHAR(enc ,ptr ,2 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,2 );
-
- end;
-
- BT_LEAD3 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_NAME_CHAR(enc ,ptr ,3 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,3 );
-
- end;
-
- BT_LEAD4 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_NAME_CHAR(enc ,ptr ,4 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,4 );
-
- end;
-
- {CHECK_NAME_CASES #define}
-
- BT_GT ,BT_RPAR ,BT_COMMA ,BT_VERBAR ,BT_LSQB ,BT_PERCNT ,
- BT_S ,BT_CR ,BT_LF :
- begin
- nextTokPtr^:=ptr;
-
- result:=tok;
-
- exit;
-
- end;
-
- {$IFDEF XML_NS }
- BT_COLON :
- begin
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- case tok of
- XML_TOK_NAME :
- begin
- if ptr = end_ then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- tok:=XML_TOK_PREFIXED_NAME;
-
- case BYTE_TYPE(enc ,ptr ) of
- {#define CHECK_NAME_CASES}
- BT_NONASCII :
- if IS_NAME_CHAR_MINBPC(enc ,ptr ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end
- else
- goto _bt1;
-
- BT_NMSTRT ,BT_HEX ,BT_DIGIT ,BT_NAME ,BT_MINUS :
- _bt1:
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- BT_LEAD2 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_NAME_CHAR(enc ,ptr ,2 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,2 );
-
- end;
-
- BT_LEAD3 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_NAME_CHAR(enc ,ptr ,3 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,3 );
-
- end;
-
- BT_LEAD4 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_NAME_CHAR(enc ,ptr ,4 ) = 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,4 );
-
- end;
-
- {CHECK_NAME_CASES #define}
-
- else
- tok:=XML_TOK_NMTOKEN;
-
- end;
-
- end;
-
- XML_TOK_PREFIXED_NAME :
- tok:=XML_TOK_NMTOKEN;
-
- end;
-
- end;
-
- {$ENDIF }
-
- BT_PLUS :
- begin
- if tok = XML_TOK_NMTOKEN then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- result:=XML_TOK_NAME_PLUS;
-
- exit;
-
- end;
-
- BT_AST :
- begin
- if tok = XML_TOK_NMTOKEN then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- result:=XML_TOK_NAME_ASTERISK;
-
- exit;
-
- end;
-
- BT_QUEST :
- begin
- if tok = XML_TOK_NMTOKEN then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- result:=XML_TOK_NAME_QUESTION;
-
- exit;
-
- end;
-
- else
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
- result:=-tok;
-
-end;
-
-{ normal_contentTok }
-function normal_contentTok(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
-var
- n : size_t;
-
-label
- _break ,_go0 ,_break2 ;
-
-begin
- if ptr = end_ then
- begin
- result:=XML_TOK_NONE;
-
- exit;
-
- end;
-
- if MINBPC(enc ) > 1 then
- begin
- n:=ptrcomp(end_ ) - ptrcomp(ptr );
-
- if n and (MINBPC(enc ) - 1 ) <> 0 then
- begin
- n:=n and not(MINBPC(enc ) - 1 );
-
- if n = 0 then
- begin
- result:=XML_TOK_PARTIAL;
-
- exit;
-
- end;
-
- end_:=char_ptr(ptrcomp(ptr ) + n );
-
- end;
-
- end;
-
- case BYTE_TYPE(enc ,ptr ) of
- BT_LT :
- begin
- result:=normal_scanLt(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
-
- exit;
-
- end;
-
- BT_AMP :
- begin
- result:=normal_scanRef(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
-
- exit;
-
- end;
-
- BT_CR :
- begin
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- if ptr = end_ then
- begin
- result:=XML_TOK_TRAILING_CR;
-
- exit;
-
- end;
-
- if BYTE_TYPE(enc ,ptr ) = BT_LF then
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_DATA_NEWLINE;
-
- exit;
-
- end;
-
- BT_LF :
- begin
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- result:=XML_TOK_DATA_NEWLINE;
-
- exit;
-
- end;
-
- BT_RSQB :
- begin
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- if ptr = end_ then
- begin
- result:=XML_TOK_TRAILING_RSQB;
-
- exit;
-
- end;
-
- if CHAR_MATCHES(enc ,ptr ,int(ASCII_RSQB ) ) = 0 then
- goto _break;
-
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- if ptr = end_ then
- begin
- result:=XML_TOK_TRAILING_RSQB;
-
- exit;
-
- end;
-
- if CHAR_MATCHES(enc ,ptr ,int(ASCII_GT ) ) = 0 then
- begin
- dec(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- goto _break;
-
- end;
-
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- {#define INVALID_CASES}
- BT_LEAD2 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_INVALID_CHAR(enc ,ptr ,2 ) <> 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,2 );
-
- end;
-
- BT_LEAD3 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_INVALID_CHAR(enc ,ptr ,3 ) <> 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,3 );
-
- end;
-
- BT_LEAD4 :
- begin
- if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
- begin
- result:=XML_TOK_PARTIAL_CHAR;
-
- exit;
-
- end;
-
- if IS_INVALID_CHAR(enc ,ptr ,4 ) <> 0 then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,4 );
-
- end;
-
- BT_NONXML ,BT_MALFORM ,BT_TRAIL :
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- {INVALID_CASES #define}
-
- else
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- end;
-
-_break:
- while ptr <> end_ do
- case BYTE_TYPE(enc ,ptr ) of
- BT_LEAD2 :
- begin
- if (ptrcomp(end_ ) - ptrcomp(ptr ) < 2 ) or
- (IS_INVALID_CHAR(enc ,ptr ,2 ) <> 0 ) then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_DATA_CHARS;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,2 );
-
- end;
-
- BT_LEAD3 :
- begin
- if (ptrcomp(end_ ) - ptrcomp(ptr ) < 3 ) or
- (IS_INVALID_CHAR(enc ,ptr ,3 ) <> 0 ) then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_DATA_CHARS;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,3 );
-
- end;
-
- BT_LEAD4 :
- begin
- if (ptrcomp(end_ ) - ptrcomp(ptr ) < 4 ) or
- (IS_INVALID_CHAR(enc ,ptr ,4 ) <> 0 ) then
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_DATA_CHARS;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr ) ,4 );
-
- end;
-
- BT_RSQB :
- begin
- if ptrcomp(ptr ) + MINBPC(enc ) <> ptrcomp(end_ ) then
- begin
- if CHAR_MATCHES(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,int(ASCII_RSQB ) ) = 0 then
- begin
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- goto _break2;
-
- end;
-
- if ptrcomp(ptr ) + 2 * MINBPC(enc ) <> ptrcomp(end_ ) then
- begin
- if CHAR_MATCHES(enc ,char_ptr(ptrcomp(ptr ) + 2 * MINBPC(enc ) ) ,int(ASCII_GT ) ) = 0 then
- begin
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- goto _break2;
-
- end;
-
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + 2 * MINBPC(enc ) );
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- end;
-
- { fall through }
- goto _go0;
-
- end;
-
- BT_AMP ,BT_LT ,BT_NONXML ,BT_MALFORM ,BT_TRAIL ,BT_CR ,BT_LF :
- _go0:
- begin
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_DATA_CHARS;
-
- exit;
-
- end;
-
- else
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- end;
-
-_break2:
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_DATA_CHARS;
-
-end;
-
-{ normal_cdataSectionTok {..}
-function normal_cdataSectionTok(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
-begin
-end;
-
-{ normal_ignoreSectionTok {..}
-function normal_ignoreSectionTok(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
-begin
-end;
-
-{ normal_attributeValueTok }
-function normal_attributeValueTok(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
-var
- start : char_ptr;
-
-begin
- if ptr = end_ then
- begin
- result:=XML_TOK_NONE;
-
- exit;
-
- end;
-
- start:=ptr;
-
- while ptr <> end_ do
- case BYTE_TYPE(enc ,ptr ) of
- BT_LEAD2 :
- inc(ptrcomp(ptr ) ,2 );
-
- BT_LEAD3 :
- inc(ptrcomp(ptr ) ,3 );
-
- BT_LEAD4 :
- inc(ptrcomp(ptr ) ,4 );
-
- BT_AMP :
- begin
- if ptr = start then
- begin
- result:=normal_scanRef(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
-
- exit;
-
- end;
-
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_DATA_CHARS;
-
- exit;
-
- end;
-
- BT_LT :
- begin
- { this is for inside entity references }
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_INVALID;
-
- exit;
-
- end;
-
- BT_LF :
- begin
- if ptr = start then
- begin
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- result:=XML_TOK_DATA_NEWLINE;
-
- exit;
-
- end;
-
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_DATA_CHARS;
-
- exit;
-
- end;
-
- BT_CR :
- begin
- if ptr = start then
- begin
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- if ptr = end_ then
- begin
- result:=XML_TOK_TRAILING_CR;
-
- exit;
-
- end;
-
- if BYTE_TYPE(enc ,ptr ) = BT_LF then
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_DATA_NEWLINE;
-
- exit;
-
- end;
-
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_DATA_CHARS;
-
- exit;
-
- end;
-
- BT_S :
- begin
- if ptr = start then
- begin
- nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- result:=XML_TOK_ATTRIBUTE_VALUE_S;
-
- exit;
-
- end;
-
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_DATA_CHARS;
-
- exit;
-
- end;
-
- else
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- end;
-
- nextTokPtr^:=ptr;
-
- result:=XML_TOK_DATA_CHARS;
-
-end;
-
-{ normal_entityValueTok {..}
-function normal_entityValueTok(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
-begin
-end;
-
-{ normal_sameName {..}
-function normal_sameName(enc : ENCODING_ptr; ptr1 ,ptr2 : char_ptr ) : int;
-begin
-end;
-
-{ normal_nameMatchesAscii }
-function normal_nameMatchesAscii(enc : ENCODING_ptr; ptr1 ,end1 ,ptr2 : char_ptr ) : int;
-begin
- while ptr2^ <> #0 do
- begin
- if ptr1 = end1 then
- begin
- result:=0;
-
- exit;
-
- end;
-
- if CHAR_MATCHES(enc ,ptr1 ,int(ptr2^ ) ) = 0 then
- begin
- result:=0;
-
- exit;
-
- end;
-
- inc(ptrcomp(ptr1 ) ,MINBPC(enc ) );
- inc(ptrcomp(ptr2 ) );
-
- end;
-
- result:=int(ptr1 = end1 );
-
-end;
-
-{ normal_nameLength }
-function normal_nameLength(enc : ENCODING_ptr; ptr : char_ptr ) : int;
-var
- start : char_ptr;
-
-begin
- start:=ptr;
-
- repeat
- case BYTE_TYPE(enc ,ptr ) of
- BT_LEAD2 :
- inc(ptrcomp(ptr ) ,2 );
-
- BT_LEAD3 :
- inc(ptrcomp(ptr ) ,3 );
-
- BT_LEAD4 :
- inc(ptrcomp(ptr ) ,4 );
-
- BT_NONASCII ,BT_NMSTRT ,{$IFDEF XML_NS }BT_COLON ,{$ENDIF }
- BT_HEX ,BT_DIGIT ,BT_NAME ,BT_MINUS :
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- else
- begin
- result:=ptrcomp(ptr ) - ptrcomp(start );
-
- exit;
-
- end;
-
- end;
-
- until false;
-
-end;
-
-{ normal_skipS {..}
-function normal_skipS(enc : ENCODING_ptr; ptr : char_ptr ) : char_ptr;
-begin
-end;
-
-{ normal_getAtts }
-{ This must only be called for a well-formed start-tag or empty
- element tag. Returns the number of attributes. Pointers to the
- first attsMax attributes are stored in atts. }
-function normal_getAtts(enc : ENCODING_ptr; ptr : char_ptr; attsMax : int; atts : ATTRIBUTE_ptr ) : int;
-type
- state_enum = (other ,inName ,inValue );
-
-var
- state : state_enum;
-
- nAtts ,open : int;
-
-begin
- state:=inName;
- nAtts:=0;
- open :=0; { defined when state = inValue;
- initialization just to shut up compilers }
-
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- repeat
- case BYTE_TYPE(enc ,ptr ) of
- BT_LEAD2 :
- begin
- if state = other then
- begin
- if nAtts < attsMax then
- begin
- ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.name :=ptr;
- ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.normalized:=#1;
-
- end;
-
- state:=inName;
-
- end;
-
- inc(ptrcomp(ptr ) ,2 - MINBPC(enc ) );
-
- end;
-
- BT_LEAD3 :
- begin
- if state = other then
- begin
- if nAtts < attsMax then
- begin
- ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.name :=ptr;
- ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.normalized:=#1;
-
- end;
-
- state:=inName;
-
- end;
-
- inc(ptrcomp(ptr ) ,3 - MINBPC(enc ) );
-
- end;
-
- BT_LEAD4 :
- begin
- if state = other then
- begin
- if nAtts < attsMax then
- begin
- ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.name :=ptr;
- ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.normalized:=#1;
-
- end;
-
- state:=inName;
-
- end;
-
- inc(ptrcomp(ptr ) ,4 - MINBPC(enc ) );
-
- end;
-
- BT_NONASCII ,BT_NMSTRT ,BT_HEX :
- if state = other then
- begin
- if nAtts < attsMax then
- begin
- ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.name :=ptr;
- ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.normalized:=#1;
-
- end;
-
- state:=inName;
-
- end;
-
- BT_QUOT :
- if state <> inValue then
- begin
- if nAtts < attsMax then
- ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.valuePtr:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- state:=inValue;
- open :=BT_QUOT;
-
- end
- else
- if open = BT_QUOT then
- begin
- state:=other;
-
- if nAtts < attsMax then
- ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.valueEnd:=ptr;
-
- inc(nAtts );
-
- end;
-
- BT_APOS :
- if state <> inValue then
- begin
- if nAtts < attsMax then
- ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.valuePtr:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
-
- state:=inValue;
- open :=BT_APOS;
-
- end
- else
- if open = BT_APOS then
- begin
- state:=other;
-
- if nAtts < attsMax then
- ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.valueEnd:=ptr;
-
- inc(nAtts );
-
- end;
-
- BT_AMP :
- if nAtts < attsMax then
- ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.normalized:=#0;
-
- BT_S :
- if state = inName then
- state:=other
- else
- if (state = inValue ) and
- (nAtts < attsMax ) and
- (ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.normalized <> #0 ) and
- ((ptr = ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.valuePtr ) or
- (BYTE_TO_ASCII(enc ,ptr ) <> int(ASCII_SPACE ) ) or
- (BYTE_TO_ASCII(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ) = int(ASCII_SPACE ) ) or
- (BYTE_TYPE(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ) = open ) ) then
- ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.normalized:=#0;
-
- BT_CR ,BT_LF :
- { This case ensures that the first attribute name is counted
- Apart from that we could just change state on the quote. }
- if state = inName then
- state:=other
- else
- if (state = inValue ) and
- (nAtts < attsMax ) then
- ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.normalized:=#0;
-
- BT_GT ,BT_SOL :
- if state <> inValue then
- begin
- result:=nAtts;
-
- exit;
-
- end;
-
- end;
-
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- until false;
-
-{ not reached }
-
-end;
-
-{ normal_charRefNumber {..}
-function normal_charRefNumber(enc : ENCODING_ptr; ptr : char_ptr ) : int;
-begin
-end;
-
-{ normal_predefinedEntityName {..}
-function normal_predefinedEntityName(enc : ENCODING_ptr; ptr ,end_ : char_ptr ) : int;
-begin
-end;
-
-{ normal_updatePosition }
-procedure normal_updatePosition(enc : ENCODING_ptr; ptr ,end_ : char_ptr; pos : POSITION_ptr );
-begin
- while ptr <> end_ do
- begin
- case BYTE_TYPE(enc ,ptr ) of
- BT_LEAD2 :
- inc(ptrcomp(ptr ) ,2 );
-
- BT_LEAD3 :
- inc(ptrcomp(ptr ) ,3 );
-
- BT_LEAD4 :
- inc(ptrcomp(ptr ) ,4 );
-
- BT_LF :
- begin
- pos.columnNumber:=XML_Size(-1 );
-
- inc(pos.lineNumber );
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- end;
-
- BT_CR :
- begin
- inc(pos.lineNumber );
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- if (ptr <> end_ ) and
- (BYTE_TYPE(enc ,ptr ) = BT_LF ) then
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- pos.columnNumber:=XML_Size(-1 );
-
- end;
-
- else
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- end;
-
- inc(pos.columnNumber );
-
- end;
-
-end;
-
-{ normal_isPublicId }
-function normal_isPublicId(enc : ENCODING_ptr; ptr ,end_ : char_ptr; badPtr : char_ptr_ptr ) : int;
-label
- _else ;
-
-begin
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
- dec(ptrcomp(end_ ) ,MINBPC(enc ) );
-
- while ptr <> end_ do
- begin
- case BYTE_TYPE(enc ,ptr ) of
- BT_S :
- if CHAR_MATCHES(enc ,ptr ,int(ASCII_TAB ) ) <> 0 then
- begin
- badPtr^:=ptr;
- result :=0;
-
- exit;
-
- end;
-
- BT_NAME ,BT_NMSTRT :
- if BYTE_TO_ASCII(enc ,ptr ) and not $7f = 0 then
- else
- goto _else;
-
- BT_DIGIT ,BT_HEX ,BT_MINUS ,BT_APOS ,BT_LPAR ,BT_RPAR ,BT_PLUS ,BT_COMMA ,
- BT_SOL ,BT_EQUALS ,BT_QUEST ,BT_CR ,BT_LF ,BT_SEMI ,BT_EXCL ,BT_AST ,BT_PERCNT ,
- BT_NUM {$IFDEF XML_NS } ,BT_COLON : {$ELSE } : {$ENDIF }
- else
- _else:
- case BYTE_TO_ASCII(enc ,ptr ) of
- $24 , { $ }
- $40 : { @ }
- else
- begin
- badPtr^:=ptr;
- result :=0;
-
- exit;
-
- end;
-
- end;
-
- end;
-
- inc(ptrcomp(ptr ) ,MINBPC(enc ) );
-
- end;
-
- result:=1;
-
-end;
-
+//----------------------------------------------------------------------------
+// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+// and Clark Cooper
+// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
+//
+// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
+// Pascal Port By: Milan Marusinec alias Milano
+// milan@marusinec.sk
+// http://www.pasports.org/pasexpat
+// Copyright (c) 2006
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// [Pascal Port History] -----------------------------------------------------
+//
+// 17.05.2006-Milano: Unit port establishment
+// 02.06.2006-Milano: porting
+// 05.06.2006-Milano: -"-
+// 06.06.2006-Milano: -"-
+// 12.06.2006-Milano: -"-
+// 15.06.2006-Milano: normal_contentTok
+// 16.06.2006-Milano: -"-, porting
+// 17.06.2006-Milano: -"-
+// 21.06.2006-Milano: -"-
+// 22.06.2006-Milano: -"-
+//
+{ xmltok_impl.inc }
+{$Q- }
+{$R- }
+{ normal_scanRef {..}
+function normal_scanRef(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
+begin
+end;
+
+{ normal_scanAtts }
+function normal_scanAtts(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
+var
+{$IFDEF XML_NS }
+ hadColon : int;
+
+{$ENDIF }
+
+ t ,open ,tok : int;
+
+label
+ _bt0 ,_bt1 ,_bte ,sol ,gt ,_bt2 ;
+
+begin
+{$IFDEF XML_NS }
+ hadColon:=0;
+
+{$ENDIF }
+
+ while ptr <> end_ do
+ case BYTE_TYPE(enc ,ptr ) of
+ {#define CHECK_NAME_CASES}
+ BT_NONASCII :
+ if IS_NAME_CHAR_MINBPC(enc ,ptr ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end
+ else
+ goto _bt0;
+
+ BT_NMSTRT ,BT_HEX ,BT_DIGIT ,BT_NAME ,BT_MINUS :
+ _bt0:
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ BT_LEAD2 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_NAME_CHAR(enc ,ptr ,2 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,2 );
+
+ end;
+
+ BT_LEAD3 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_NAME_CHAR(enc ,ptr ,3 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,3 );
+
+ end;
+
+ BT_LEAD4 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_NAME_CHAR(enc ,ptr ,4 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,4 );
+
+ end;
+
+ {CHECK_NAME_CASES #define}
+
+ {$IFDEF XML_NS }
+ BT_COLON :
+ begin
+ if hadColon <> 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ hadColon:=1;
+
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ if ptr <> end_ then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ case BYTE_TYPE(enc ,ptr ) of
+ {#define CHECK_NMSTRT_CASES}
+ BT_NONASCII :
+ if IS_NMSTRT_CHAR_MINBPC(enc ,ptr ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end
+ else
+ goto _bt1;
+
+ BT_NMSTRT ,BT_HEX :
+ _bt1:
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ BT_LEAD2 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if not IS_NMSTRT_CHAR(enc ,ptr ,2 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,2 );
+
+ end;
+
+ BT_LEAD3 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if not IS_NMSTRT_CHAR(enc ,ptr ,3 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,3 );
+
+ end;
+
+ BT_LEAD4 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if not IS_NMSTRT_CHAR(enc ,ptr ,4 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,4 );
+
+ end;
+
+ {CHECK_NMSTRT_CASES #define}
+
+ else
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+ end;
+
+ {$ENDIF }
+
+ BT_S ,BT_CR ,BT_LF :
+ begin
+ repeat
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ if ptr <> end_ then
+ result:=XML_TOK_PARTIAL;
+
+ t:=BYTE_TYPE(enc ,ptr );
+
+ if t = BT_EQUALS then
+ break;
+
+ case t of
+ BT_S ,BT_LF ,BT_CR :
+ break;
+
+ else
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+ until false;
+
+ { fall through }
+ goto _bte;
+
+ end;
+
+ BT_EQUALS :
+ _bte:
+ begin
+ {$IFDEF XML_NS }
+ hadColon:=0;
+
+ {$ENDIF }
+
+ repeat
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ open:=BYTE_TYPE(enc ,ptr );
+
+ if (open = BT_QUOT ) or
+ (open = BT_APOS ) then
+ break;
+
+ case open of
+ BT_S ,BT_LF ,BT_CR :
+ else
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+ until false;
+
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ { in attribute value }
+ repeat
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ t:=BYTE_TYPE(enc ,ptr );
+
+ if t = open then
+ break;
+
+ case t of
+ {#define INVALID_CASES}
+ BT_LEAD2 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_INVALID_CHAR(enc ,ptr ,2 ) <> 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,2 );
+
+ end;
+
+ BT_LEAD3 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_INVALID_CHAR(enc ,ptr ,3 ) <> 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,3 );
+
+ end;
+
+ BT_LEAD4 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_INVALID_CHAR(enc ,ptr ,4 ) <> 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,4 );
+
+ end;
+
+ BT_NONXML ,BT_MALFORM ,BT_TRAIL :
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ {INVALID_CASES #define}
+
+ BT_AMP :
+ begin
+ tok:=normal_scanRef(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,@ptr );
+
+ if tok <= 0 then
+ begin
+ if tok = XML_TOK_INVALID then
+ nextTokPtr^:=ptr;
+
+ result:=tok;
+
+ exit;
+
+ end;
+
+ end;
+
+ BT_LT :
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ else
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ end;
+
+ until false;
+
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ case BYTE_TYPE(enc ,ptr ) of
+ BT_SOL :
+ goto sol;
+
+ BT_GT :
+ goto gt;
+
+ BT_S ,BT_CR ,BT_LF :
+ else
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+ { ptr points to closing quote }
+ repeat
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ case BYTE_TYPE(enc ,ptr ) of
+ {#define CHECK_NMSTRT_CASES}
+ BT_NONASCII :
+ if IS_NMSTRT_CHAR_MINBPC(enc ,ptr ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end
+ else
+ goto _bt2;
+
+ BT_NMSTRT ,BT_HEX :
+ _bt2:
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ BT_LEAD2 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if not IS_NMSTRT_CHAR(enc ,ptr ,2 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,2 );
+
+ end;
+
+ BT_LEAD3 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if not IS_NMSTRT_CHAR(enc ,ptr ,3 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,3 );
+
+ end;
+
+ BT_LEAD4 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if not IS_NMSTRT_CHAR(enc ,ptr ,4 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,4 );
+
+ end;
+
+ {CHECK_NMSTRT_CASES #define}
+
+ BT_S ,BT_CR ,BT_LF :
+ continue;
+
+ BT_GT :
+ gt:
+ begin
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ result:=XML_TOK_START_TAG_WITH_ATTS;
+
+ exit;
+
+ end;
+
+ BT_SOL :
+ sol:
+ begin
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ if CHAR_MATCHES(enc ,ptr ,int(ASCII_GT ) ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ result:=XML_TOK_EMPTY_ELEMENT_WITH_ATTS;
+
+ exit;
+
+ end;
+
+ else
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+ break;
+
+ until false;
+
+ end;
+
+ else
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+ result:=XML_TOK_PARTIAL;
+
+end;
+
+{ normal_scanEndTag }
+{ ptr points to character following "</" }
+function normal_scanEndTag(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
+label
+ _bt0 ,_bt1 ;
+
+begin
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ case BYTE_TYPE(enc ,ptr ) of
+ {#define CHECK_NMSTRT_CASES}
+ BT_NONASCII :
+ if IS_NMSTRT_CHAR_MINBPC(enc ,ptr ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end
+ else
+ goto _bt0;
+
+ BT_NMSTRT ,BT_HEX :
+ _bt0:
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ BT_LEAD2 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if not IS_NMSTRT_CHAR(enc ,ptr ,2 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,2 );
+
+ end;
+
+ BT_LEAD3 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if not IS_NMSTRT_CHAR(enc ,ptr ,3 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,3 );
+
+ end;
+
+ BT_LEAD4 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if not IS_NMSTRT_CHAR(enc ,ptr ,4 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,4 );
+
+ end;
+
+ {CHECK_NMSTRT_CASES #define}
+
+ else
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+ while ptr <> end_ do
+ case BYTE_TYPE(enc ,ptr ) of
+ {#define CHECK_NAME_CASES}
+ BT_NONASCII :
+ if IS_NAME_CHAR_MINBPC(enc ,ptr ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end
+ else
+ goto _bt1;
+
+ BT_NMSTRT ,BT_HEX ,BT_DIGIT ,BT_NAME ,BT_MINUS :
+ _bt1:
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ BT_LEAD2 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_NAME_CHAR(enc ,ptr ,2 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,2 );
+
+ end;
+
+ BT_LEAD3 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_NAME_CHAR(enc ,ptr ,3 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,3 );
+
+ end;
+
+ BT_LEAD4 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_NAME_CHAR(enc ,ptr ,4 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,4 );
+
+ end;
+
+ {CHECK_NAME_CASES #define}
+
+ BT_S ,BT_CR ,BT_LF :
+ begin
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ while ptr <> end_ do
+ begin
+ case BYTE_TYPE(enc ,ptr ) of
+ BT_GT :
+ begin
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ result:=XML_TOK_END_TAG;
+
+ exit;
+
+ end;
+
+ BT_S ,BT_CR ,BT_LF :
+ else
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ end;
+
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ {$IFDEF XML_NS }
+ BT_COLON :
+ { no need to check qname syntax here,
+ since end-tag must match exactly }
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ {$ENDIF }
+
+ BT_GT :
+ begin
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ result:=XML_TOK_END_TAG;
+
+ exit;
+
+ end;
+
+ else
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+ result:=XML_TOK_PARTIAL;
+
+end;
+
+{ normal_scanComment }
+{ ptr points to character following "<!-" }
+function normal_scanComment(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
+begin
+ if ptr <> end_ then
+ begin
+ if CHAR_MATCHES(enc ,ptr ,int(ASCII_MINUS ) ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ while ptr <> end_ do
+ case BYTE_TYPE(enc ,ptr ) of
+ {#define INVALID_CASES}
+ BT_LEAD2 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_INVALID_CHAR(enc ,ptr ,2 ) <> 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,2 );
+
+ end;
+
+ BT_LEAD3 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_INVALID_CHAR(enc ,ptr ,3 ) <> 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,3 );
+
+ end;
+
+ BT_LEAD4 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_INVALID_CHAR(enc ,ptr ,4 ) <> 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,4 );
+
+ end;
+
+ BT_NONXML ,BT_MALFORM ,BT_TRAIL :
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ {INVALID_CASES #define}
+
+ BT_MINUS :
+ begin
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ if CHAR_MATCHES(enc ,ptr ,int(ASCII_MINUS ) ) <> 0 then
+ begin
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ if CHAR_MATCHES(enc ,ptr ,int(ASCII_GT ) ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ result:=XML_TOK_COMMENT;
+
+ exit;
+
+ end;
+
+ end;
+
+ else
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ end;
+
+ end;
+
+ result:=XML_TOK_PARTIAL;
+
+end;
+
+{ normal_scanCdataSection {..}
+function normal_scanCdataSection(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
+begin
+end;
+
+{ normal_checkPiTarget }
+function normal_checkPiTarget(enc : ENCODING_ptr; ptr ,end_ : char_ptr; tokPtr : int_ptr ) : int;
+var
+ upper : int;
+
+begin
+ upper :=0;
+ tokPtr^:=XML_TOK_PI;
+
+ if ptrcomp(end_ ) - ptrcomp(ptr ) <> MINBPC(enc ) * 3 then
+ begin
+ result:=1;
+
+ exit;
+
+ end;
+
+ case BYTE_TO_ASCII(enc ,ptr ) of
+ int(ASCII_X ) :
+ upper:=1;
+
+ int(ASCII_xl ) :
+ else
+ begin
+ result:=1;
+
+ exit;
+
+ end;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ case BYTE_TO_ASCII(enc ,ptr ) of
+ int(ASCII_M ) :
+ upper:=1;
+
+ int(ASCII_ml ) :
+ else
+ begin
+ result:=1;
+
+ exit;
+
+ end;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ case BYTE_TO_ASCII(enc ,ptr ) of
+ int(ASCII_L ) :
+ upper:=1;
+
+ int(ASCII_ll ) :
+ else
+ begin
+ result:=1;
+
+ exit;
+
+ end;
+
+ end;
+
+ if upper <> 0 then
+ begin
+ result:=0;
+
+ exit;
+
+ end;
+
+ tokPtr^:=XML_TOK_XML_DECL;
+ result :=1;
+
+end;
+
+{ normal_scanPi }
+{ ptr points to character following "<?" }
+function normal_scanPi(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
+var
+ tok : int;
+
+ target : char_ptr;
+
+label
+ _bt0 ,_bt1 ,_else ;
+
+begin
+ target:=ptr;
+
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ case BYTE_TYPE(enc ,ptr ) of
+ {#define CHECK_NMSTRT_CASES}
+ BT_NONASCII :
+ if IS_NMSTRT_CHAR_MINBPC(enc ,ptr ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end
+ else
+ goto _bt0;
+
+ BT_NMSTRT ,BT_HEX :
+ _bt0:
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ BT_LEAD2 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if not IS_NMSTRT_CHAR(enc ,ptr ,2 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,2 );
+
+ end;
+
+ BT_LEAD3 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if not IS_NMSTRT_CHAR(enc ,ptr ,3 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,3 );
+
+ end;
+
+ BT_LEAD4 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if not IS_NMSTRT_CHAR(enc ,ptr ,4 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,4 );
+
+ end;
+
+ {CHECK_NMSTRT_CASES #define}
+
+ else
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+ while ptr <> end_ do
+ case BYTE_TYPE(enc ,ptr ) of
+ {#define CHECK_NAME_CASES}
+ BT_NONASCII :
+ if IS_NAME_CHAR_MINBPC(enc ,ptr ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end
+ else
+ goto _bt1;
+
+ BT_NMSTRT ,BT_HEX ,BT_DIGIT ,BT_NAME ,BT_MINUS :
+ _bt1:
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ BT_LEAD2 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_NAME_CHAR(enc ,ptr ,2 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,2 );
+
+ end;
+
+ BT_LEAD3 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_NAME_CHAR(enc ,ptr ,3 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,3 );
+
+ end;
+
+ BT_LEAD4 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_NAME_CHAR(enc ,ptr ,4 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,4 );
+
+ end;
+
+ {CHECK_NAME_CASES #define}
+
+ BT_S ,BT_CR ,BT_LF :
+ begin
+ if normal_checkPiTarget(enc ,target ,ptr ,@tok ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ while ptr <> end_ do
+ case BYTE_TYPE(enc ,ptr ) of
+ {#define INVALID_CASES}
+ BT_LEAD2 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_INVALID_CHAR(enc ,ptr ,2 ) <> 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,2 );
+
+ end;
+
+ BT_LEAD3 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_INVALID_CHAR(enc ,ptr ,3 ) <> 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,3 );
+
+ end;
+
+ BT_LEAD4 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_INVALID_CHAR(enc ,ptr ,4 ) <> 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,4 );
+
+ end;
+
+ BT_NONXML ,BT_MALFORM ,BT_TRAIL :
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ {INVALID_CASES #define}
+
+ BT_QUEST :
+ begin
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ if CHAR_MATCHES(enc ,ptr ,int(ASCII_GT ) ) <> 0 then
+ begin
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ result:=tok;
+
+ exit;
+
+ end;
+
+ end;
+
+ else
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ end;
+
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ BT_QUEST :
+ begin
+ if normal_checkPiTarget(enc ,target ,ptr ,@tok ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ if CHAR_MATCHES(enc ,ptr ,int(ASCII_GT ) ) <> 0 then
+ begin
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ result:=tok;
+
+ exit;
+
+ end;
+
+ { fall through }
+ goto _else;
+
+ end;
+
+ else
+ begin
+ _else:
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+ result:=XML_TOK_PARTIAL;
+
+end;
+
+{ normal_scanLt }
+{ ptr points to character following "<" }
+function normal_scanLt(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
+{$IFDEF XML_NS }
+var
+ hadColon : int;
+
+{$ENDIF }
+
+label
+ _bt0 ,_bt1 ,_bt2 ,_bt3 ,gt ,sol ;
+
+begin
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ case BYTE_TYPE(enc ,ptr ) of
+ {#define CHECK_NMSTRT_CASES}
+ BT_NONASCII :
+ if IS_NMSTRT_CHAR_MINBPC(enc ,ptr ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end
+ else
+ goto _bt0;
+
+ BT_NMSTRT ,BT_HEX :
+ _bt0:
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ BT_LEAD2 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if not IS_NMSTRT_CHAR(enc ,ptr ,2 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,2 );
+
+ end;
+
+ BT_LEAD3 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if not IS_NMSTRT_CHAR(enc ,ptr ,3 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,3 );
+
+ end;
+
+ BT_LEAD4 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if not IS_NMSTRT_CHAR(enc ,ptr ,4 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,4 );
+
+ end;
+
+ {CHECK_NMSTRT_CASES #define}
+
+ BT_EXCL :
+ begin
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ case BYTE_TYPE(enc ,ptr ) of
+ BT_MINUS:
+ begin
+ result:=normal_scanComment(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
+
+ exit;
+
+ end;
+
+ BT_LSQB:
+ begin
+ result:=normal_scanCdataSection(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
+
+ exit;
+
+ end;
+
+ end;
+
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ BT_QUEST :
+ begin
+ result:=normal_scanPi(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
+
+ exit;
+
+ end;
+
+ BT_SOL :
+ begin
+ result:=normal_scanEndTag(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
+
+ exit;
+
+ end;
+
+ else
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+{$IFDEF XML_NS }
+ hadColon:=0;
+
+{$ENDIF }
+
+{ we have a start-tag }
+ while ptr <> end_ do
+ case BYTE_TYPE(enc ,ptr ) of
+ {#define CHECK_NAME_CASES}
+ BT_NONASCII :
+ if IS_NAME_CHAR_MINBPC(enc ,ptr ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end
+ else
+ goto _bt1;
+
+ BT_NMSTRT ,BT_HEX ,BT_DIGIT ,BT_NAME ,BT_MINUS :
+ _bt1:
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ BT_LEAD2 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_NAME_CHAR(enc ,ptr ,2 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,2 );
+
+ end;
+
+ BT_LEAD3 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_NAME_CHAR(enc ,ptr ,3 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,3 );
+
+ end;
+
+ BT_LEAD4 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_NAME_CHAR(enc ,ptr ,4 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,4 );
+
+ end;
+
+ {CHECK_NAME_CASES #define}
+
+ {$IFDEF XML_NS }
+ BT_COLON :
+ begin
+ if hadColon <> 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ hadColon:=1;
+
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ case BYTE_TYPE(enc ,ptr ) of
+ {#define CHECK_NMSTRT_CASES}
+ BT_NONASCII :
+ if IS_NMSTRT_CHAR_MINBPC(enc ,ptr ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end
+ else
+ goto _bt2;
+
+ BT_NMSTRT ,BT_HEX :
+ _bt2:
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ BT_LEAD2 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if not IS_NMSTRT_CHAR(enc ,ptr ,2 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,2 );
+
+ end;
+
+ BT_LEAD3 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if not IS_NMSTRT_CHAR(enc ,ptr ,3 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,3 );
+
+ end;
+
+ BT_LEAD4 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if not IS_NMSTRT_CHAR(enc ,ptr ,4 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,4 );
+
+ end;
+
+ {CHECK_NMSTRT_CASES #define}
+
+ else
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+ end;
+
+ {$ENDIF }
+
+ BT_S ,BT_CR ,BT_LF :
+ begin
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ while ptr <> end_ do
+ begin
+ case BYTE_TYPE(enc ,ptr ) of
+ {#define CHECK_NMSTRT_CASES}
+ BT_NONASCII :
+ if IS_NMSTRT_CHAR_MINBPC(enc ,ptr ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end
+ else
+ goto _bt3;
+
+ BT_NMSTRT ,BT_HEX :
+ _bt3:
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ BT_LEAD2 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if not IS_NMSTRT_CHAR(enc ,ptr ,2 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,2 );
+
+ end;
+
+ BT_LEAD3 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if not IS_NMSTRT_CHAR(enc ,ptr ,3 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,3 );
+
+ end;
+
+ BT_LEAD4 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if not IS_NMSTRT_CHAR(enc ,ptr ,4 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,4 );
+
+ end;
+
+ {CHECK_NMSTRT_CASES #define}
+
+ BT_GT :
+ goto gt;
+
+ BT_SOL :
+ goto sol;
+
+ BT_S ,BT_CR ,BT_LF :
+ begin
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ continue;
+
+ end;
+
+ else
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+ result:=normal_scanAtts(enc ,ptr ,end_ ,nextTokPtr );
+
+ exit;
+
+ end;
+
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ BT_GT :
+ gt:
+ begin
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ result:=XML_TOK_START_TAG_NO_ATTS;
+
+ exit;
+
+ end;
+
+ BT_SOL :
+ sol:
+ begin
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ if ptr <> end_ then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ if CHAR_MATCHES(enc ,ptr ,int(ASCII_GT ) ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ result:=XML_TOK_EMPTY_ELEMENT_NO_ATTS;
+
+ exit;
+
+ end;
+
+ else
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+ result:=XML_TOK_PARTIAL;
+
+end;
+
+{ normal_scanDecl }
+{ ptr points to character following "<!" }
+function normal_scanDecl(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
+label
+ _fall0 ;
+
+begin
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ case BYTE_TYPE(enc ,ptr ) of
+ BT_MINUS :
+ begin
+ result:=normal_scanComment(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
+
+ exit;
+
+ end;
+
+ BT_LSQB :
+ begin
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ result:=XML_TOK_COND_SECT_OPEN;
+
+ exit;
+
+ end;
+
+ BT_NMSTRT ,BT_HEX:
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ else
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+ while ptr <> end_ do
+ case BYTE_TYPE(enc ,ptr ) of
+ BT_PERCNT :
+ begin
+ if ptrcomp(ptr ) + MINBPC(enc ) = ptrcomp(end_ ) then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ { don't allow <!ENTITY% foo "whatever"> }
+ case BYTE_TYPE(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ) of
+ BT_S ,BT_CR ,BT_LF ,BT_PERCNT :
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+ { fall through }
+ goto _fall0;
+
+ end;
+
+ BT_S ,BT_CR ,BT_LF :
+ _fall0:
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_DECL_OPEN;
+
+ exit;
+
+ end;
+
+ BT_NMSTRT ,BT_HEX :
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ else
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+ result:=XML_TOK_PARTIAL;
+
+end;
+
+{ scanPercent {..}
+{ ptr points to character following "%" }
+function scanPercent(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
+begin
+end;
+
+{ scanPoundName {..}
+function scanPoundName(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
+begin
+end;
+
+{ normal_scanLit }
+function normal_scanLit(
+ open : int; enc : ENCODING_ptr;
+ ptr ,end_ : char_ptr;
+ nextTokPtr : char_ptr_ptr ) : int;
+var
+ t : int;
+
+label
+ _break ;
+
+begin
+ while ptr <> end_ do
+ begin
+ t:=BYTE_TYPE(enc ,ptr );
+
+ case t of
+ {#define INVALID_CASES}
+ BT_LEAD2 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_INVALID_CHAR(enc ,ptr ,2 ) <> 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,2 );
+
+ end;
+
+ BT_LEAD3 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_INVALID_CHAR(enc ,ptr ,3 ) <> 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,3 );
+
+ end;
+
+ BT_LEAD4 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_INVALID_CHAR(enc ,ptr ,4 ) <> 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,4 );
+
+ end;
+
+ BT_NONXML ,BT_MALFORM ,BT_TRAIL :
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ {INVALID_CASES #define}
+
+ BT_QUOT ,BT_APOS :
+ begin
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ if t <> open then
+ goto _break;
+
+ if ptr = end_ then
+ begin
+ result:=-XML_TOK_LITERAL;
+
+ exit;
+
+ end;
+
+ nextTokPtr^:=ptr;
+
+ case BYTE_TYPE(enc ,ptr ) of
+ BT_S ,BT_CR ,BT_LF ,BT_GT ,BT_PERCNT ,BT_LSQB :
+ begin
+ result:=XML_TOK_LITERAL;
+
+ exit;
+
+ end;
+
+ else
+ begin
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+ end;
+
+ else
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ end;
+
+ _break:
+ end;
+
+ result:=XML_TOK_PARTIAL;
+
+end;
+
+{ normal_prologTok }
+function normal_prologTok(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
+var
+ tok : int;
+
+ n : size_t;
+
+label
+ _bt_s ,_else ,_else2 ,_bt0 ,_bt1 ;
+
+begin
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_NONE;
+
+ exit;
+
+ end;
+
+ if MINBPC(enc ) > 1 then
+ begin
+ n:=ptrcomp(end_ ) - ptrcomp(ptr );
+
+ if n and (MINBPC(enc ) - 1 ) <> 0 then
+ begin
+ n:=n and not(MINBPC(enc ) - 1 );
+
+ if n = 0 then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ end_:=char_ptr(ptrcomp(ptr ) + n );
+
+ end;
+
+ end;
+
+ case BYTE_TYPE(enc ,ptr ) of
+ BT_QUOT :
+ begin
+ result:=normal_scanLit(BT_QUOT ,enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
+
+ exit;
+
+ end;
+
+ BT_APOS :
+ begin
+ result:=normal_scanLit(BT_APOS ,enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
+
+ exit;
+
+ end;
+
+ BT_LT :
+ begin
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ case BYTE_TYPE(enc ,ptr ) of
+ BT_EXCL :
+ begin
+ result:=normal_scanDecl(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
+
+ exit;
+
+ end;
+
+ BT_QUEST :
+ begin
+ result:=normal_scanPi(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
+
+ exit;
+
+ end;
+
+ BT_NMSTRT ,BT_HEX ,BT_NONASCII ,BT_LEAD2 ,BT_LEAD3 ,BT_LEAD4 :
+ begin
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) - MINBPC(enc ) );
+
+ result:=XML_TOK_INSTANCE_START;
+
+ exit;
+
+ end;
+
+ end;
+
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ BT_CR :
+ if ptrcomp(ptr ) + MINBPC(enc ) = ptrcomp(end_ ) then
+ begin
+ nextTokPtr^:=end_;
+
+ { indicate that this might be part of a CR/LF pair }
+ result:=-XML_TOK_PROLOG_S;
+
+ exit;
+
+ end
+ else
+ { fall through }
+ goto _bt_s;
+
+ BT_S ,BT_LF :
+ _bt_s:
+ begin
+ repeat
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ if ptr = end_ then
+ break;
+
+ case BYTE_TYPE(enc ,ptr ) of
+ BT_CR :
+ { don't split CR/LF pair }
+ if ptrcomp(ptr ) + MINBPC(enc ) <> ptrcomp(end_ ) then
+ else
+ { fall through }
+ goto _else;
+
+ BT_S ,BT_LF :
+ else
+ begin
+ _else:
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_PROLOG_S;
+
+ exit;
+
+ end;
+
+ end;
+
+ until false;
+
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_PROLOG_S;
+
+ exit;
+
+ end;
+
+ BT_PERCNT :
+ begin
+ result:=scanPercent(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
+
+ exit;
+
+ end;
+
+ BT_COMMA :
+ begin
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ result:=XML_TOK_COMMA;
+
+ exit;
+
+ end;
+
+ BT_LSQB :
+ begin
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ result:=XML_TOK_OPEN_BRACKET;
+
+ exit;
+
+ end;
+
+ BT_RSQB :
+ begin
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ if ptr = end_ then
+ begin
+ result:=-XML_TOK_CLOSE_BRACKET;
+
+ exit;
+
+ end;
+
+ if CHAR_MATCHES(enc ,ptr ,int(ASCII_RSQB ) ) <> 0 then
+ begin
+ if ptrcomp(ptr ) + MINBPC(enc ) = ptrcomp(end_ ) then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ if CHAR_MATCHES(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,int(ASCII_GT ) ) <> 0 then
+ begin
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + 2 * MINBPC(enc ) );
+
+ result:=XML_TOK_COND_SECT_CLOSE;
+
+ exit;
+
+ end;
+
+ end;
+
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_CLOSE_BRACKET;
+
+ exit;
+
+ end;
+
+ BT_LPAR :
+ begin
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ result:=XML_TOK_OPEN_PAREN;
+
+ exit;
+
+ end;
+
+ BT_RPAR :
+ begin
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ if ptr = end_ then
+ begin
+ result:=-XML_TOK_CLOSE_PAREN;
+
+ exit;
+
+ end;
+
+ case BYTE_TYPE(enc ,ptr ) of
+ BT_AST :
+ begin
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ result:=XML_TOK_CLOSE_PAREN_ASTERISK;
+
+ exit;
+
+ end;
+
+ BT_QUEST :
+ begin
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ result:=XML_TOK_CLOSE_PAREN_QUESTION;
+
+ exit;
+
+ end;
+
+ BT_PLUS :
+ begin
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ result:=XML_TOK_CLOSE_PAREN_PLUS;
+
+ exit;
+
+ end;
+
+ BT_CR ,BT_LF ,BT_S ,BT_GT ,BT_COMMA ,BT_VERBAR ,BT_RPAR :
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_CLOSE_PAREN;
+
+ exit;
+
+ end;
+
+ end;
+
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ BT_VERBAR :
+ begin
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ result:=XML_TOK_OR;
+
+ exit;
+
+ end;
+
+ BT_GT :
+ begin
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ result:=XML_TOK_DECL_CLOSE;
+
+ exit;
+
+ end;
+
+ BT_NUM :
+ begin
+ result:=scanPoundName(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
+
+ exit;
+
+ end;
+
+ BT_LEAD2 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_NMSTRT_CHAR(enc ,ptr ,2 ) <> 0 then
+ begin
+ inc(ptrcomp(ptr ) ,2 );
+
+ tok:=XML_TOK_NAME;
+
+ end
+ else
+ if IS_NAME_CHAR(enc ,ptr ,2 ) <> 0 then
+ begin
+ inc(ptrcomp(ptr ) ,2 );
+
+ tok:=XML_TOK_NMTOKEN;
+
+ end
+ else
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+ BT_LEAD3 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_NMSTRT_CHAR(enc ,ptr ,3 ) <> 0 then
+ begin
+ inc(ptrcomp(ptr ) ,3 );
+
+ tok:=XML_TOK_NAME;
+
+ end
+ else
+ if IS_NAME_CHAR(enc ,ptr ,3 ) <> 0 then
+ begin
+ inc(ptrcomp(ptr ) ,3 );
+
+ tok:=XML_TOK_NMTOKEN;
+
+ end
+ else
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+ BT_LEAD4 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_NMSTRT_CHAR(enc ,ptr ,4 ) <> 0 then
+ begin
+ inc(ptrcomp(ptr ) ,4 );
+
+ tok:=XML_TOK_NAME;
+
+ end
+ else
+ if IS_NAME_CHAR(enc ,ptr ,4 ) <> 0 then
+ begin
+ inc(ptrcomp(ptr ) ,4 );
+
+ tok:=XML_TOK_NMTOKEN;
+
+ end
+ else
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+ BT_NMSTRT ,BT_HEX :
+ begin
+ tok:=XML_TOK_NAME;
+
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ end;
+
+ BT_DIGIT ,BT_NAME ,BT_MINUS {$IFDEF XML_NS } ,BT_COLON : {$ELSE }: {$ENDIF }
+ begin
+ tok:=XML_TOK_NMTOKEN;
+
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ end;
+
+ BT_NONASCII :
+ if IS_NMSTRT_CHAR_MINBPC(enc ,ptr ) <> 0 then
+ begin
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ tok:=XML_TOK_NAME;
+
+ end
+ else
+ if IS_NAME_CHAR_MINBPC(enc ,ptr ) <> 0 then
+ begin
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ tok:=XML_TOK_NMTOKEN;
+
+ end
+ else
+ { fall through }
+ goto _else2;
+
+ else
+ begin
+ _else2:
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+ while ptr <> end_ do
+ case BYTE_TYPE(enc ,ptr ) of
+ {#define CHECK_NAME_CASES}
+ BT_NONASCII :
+ if IS_NAME_CHAR_MINBPC(enc ,ptr ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end
+ else
+ goto _bt0;
+
+ BT_NMSTRT ,BT_HEX ,BT_DIGIT ,BT_NAME ,BT_MINUS :
+ _bt0:
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ BT_LEAD2 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_NAME_CHAR(enc ,ptr ,2 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,2 );
+
+ end;
+
+ BT_LEAD3 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_NAME_CHAR(enc ,ptr ,3 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,3 );
+
+ end;
+
+ BT_LEAD4 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_NAME_CHAR(enc ,ptr ,4 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,4 );
+
+ end;
+
+ {CHECK_NAME_CASES #define}
+
+ BT_GT ,BT_RPAR ,BT_COMMA ,BT_VERBAR ,BT_LSQB ,BT_PERCNT ,
+ BT_S ,BT_CR ,BT_LF :
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=tok;
+
+ exit;
+
+ end;
+
+ {$IFDEF XML_NS }
+ BT_COLON :
+ begin
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ case tok of
+ XML_TOK_NAME :
+ begin
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ tok:=XML_TOK_PREFIXED_NAME;
+
+ case BYTE_TYPE(enc ,ptr ) of
+ {#define CHECK_NAME_CASES}
+ BT_NONASCII :
+ if IS_NAME_CHAR_MINBPC(enc ,ptr ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end
+ else
+ goto _bt1;
+
+ BT_NMSTRT ,BT_HEX ,BT_DIGIT ,BT_NAME ,BT_MINUS :
+ _bt1:
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ BT_LEAD2 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_NAME_CHAR(enc ,ptr ,2 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,2 );
+
+ end;
+
+ BT_LEAD3 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_NAME_CHAR(enc ,ptr ,3 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,3 );
+
+ end;
+
+ BT_LEAD4 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_NAME_CHAR(enc ,ptr ,4 ) = 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,4 );
+
+ end;
+
+ {CHECK_NAME_CASES #define}
+
+ else
+ tok:=XML_TOK_NMTOKEN;
+
+ end;
+
+ end;
+
+ XML_TOK_PREFIXED_NAME :
+ tok:=XML_TOK_NMTOKEN;
+
+ end;
+
+ end;
+
+ {$ENDIF }
+
+ BT_PLUS :
+ begin
+ if tok = XML_TOK_NMTOKEN then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ result:=XML_TOK_NAME_PLUS;
+
+ exit;
+
+ end;
+
+ BT_AST :
+ begin
+ if tok = XML_TOK_NMTOKEN then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ result:=XML_TOK_NAME_ASTERISK;
+
+ exit;
+
+ end;
+
+ BT_QUEST :
+ begin
+ if tok = XML_TOK_NMTOKEN then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ result:=XML_TOK_NAME_QUESTION;
+
+ exit;
+
+ end;
+
+ else
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+ result:=-tok;
+
+end;
+
+{ normal_contentTok }
+function normal_contentTok(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
+var
+ n : size_t;
+
+label
+ _break ,_go0 ,_break2 ;
+
+begin
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_NONE;
+
+ exit;
+
+ end;
+
+ if MINBPC(enc ) > 1 then
+ begin
+ n:=ptrcomp(end_ ) - ptrcomp(ptr );
+
+ if n and (MINBPC(enc ) - 1 ) <> 0 then
+ begin
+ n:=n and not(MINBPC(enc ) - 1 );
+
+ if n = 0 then
+ begin
+ result:=XML_TOK_PARTIAL;
+
+ exit;
+
+ end;
+
+ end_:=char_ptr(ptrcomp(ptr ) + n );
+
+ end;
+
+ end;
+
+ case BYTE_TYPE(enc ,ptr ) of
+ BT_LT :
+ begin
+ result:=normal_scanLt(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
+
+ exit;
+
+ end;
+
+ BT_AMP :
+ begin
+ result:=normal_scanRef(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
+
+ exit;
+
+ end;
+
+ BT_CR :
+ begin
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_TRAILING_CR;
+
+ exit;
+
+ end;
+
+ if BYTE_TYPE(enc ,ptr ) = BT_LF then
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_DATA_NEWLINE;
+
+ exit;
+
+ end;
+
+ BT_LF :
+ begin
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ result:=XML_TOK_DATA_NEWLINE;
+
+ exit;
+
+ end;
+
+ BT_RSQB :
+ begin
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_TRAILING_RSQB;
+
+ exit;
+
+ end;
+
+ if CHAR_MATCHES(enc ,ptr ,int(ASCII_RSQB ) ) = 0 then
+ goto _break;
+
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_TRAILING_RSQB;
+
+ exit;
+
+ end;
+
+ if CHAR_MATCHES(enc ,ptr ,int(ASCII_GT ) ) = 0 then
+ begin
+ dec(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ goto _break;
+
+ end;
+
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ {#define INVALID_CASES}
+ BT_LEAD2 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 2 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_INVALID_CHAR(enc ,ptr ,2 ) <> 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,2 );
+
+ end;
+
+ BT_LEAD3 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 3 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_INVALID_CHAR(enc ,ptr ,3 ) <> 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,3 );
+
+ end;
+
+ BT_LEAD4 :
+ begin
+ if ptrcomp(end_ ) - ptrcomp(ptr ) < 4 then
+ begin
+ result:=XML_TOK_PARTIAL_CHAR;
+
+ exit;
+
+ end;
+
+ if IS_INVALID_CHAR(enc ,ptr ,4 ) <> 0 then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,4 );
+
+ end;
+
+ BT_NONXML ,BT_MALFORM ,BT_TRAIL :
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ {INVALID_CASES #define}
+
+ else
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ end;
+
+_break:
+ while ptr <> end_ do
+ case BYTE_TYPE(enc ,ptr ) of
+ BT_LEAD2 :
+ begin
+ if (ptrcomp(end_ ) - ptrcomp(ptr ) < 2 ) or
+ (IS_INVALID_CHAR(enc ,ptr ,2 ) <> 0 ) then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_DATA_CHARS;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,2 );
+
+ end;
+
+ BT_LEAD3 :
+ begin
+ if (ptrcomp(end_ ) - ptrcomp(ptr ) < 3 ) or
+ (IS_INVALID_CHAR(enc ,ptr ,3 ) <> 0 ) then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_DATA_CHARS;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,3 );
+
+ end;
+
+ BT_LEAD4 :
+ begin
+ if (ptrcomp(end_ ) - ptrcomp(ptr ) < 4 ) or
+ (IS_INVALID_CHAR(enc ,ptr ,4 ) <> 0 ) then
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_DATA_CHARS;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,4 );
+
+ end;
+
+ BT_RSQB :
+ begin
+ if ptrcomp(ptr ) + MINBPC(enc ) <> ptrcomp(end_ ) then
+ begin
+ if CHAR_MATCHES(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,int(ASCII_RSQB ) ) = 0 then
+ begin
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ goto _break2;
+
+ end;
+
+ if ptrcomp(ptr ) + 2 * MINBPC(enc ) <> ptrcomp(end_ ) then
+ begin
+ if CHAR_MATCHES(enc ,char_ptr(ptrcomp(ptr ) + 2 * MINBPC(enc ) ) ,int(ASCII_GT ) ) = 0 then
+ begin
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ goto _break2;
+
+ end;
+
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + 2 * MINBPC(enc ) );
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ end;
+
+ { fall through }
+ goto _go0;
+
+ end;
+
+ BT_AMP ,BT_LT ,BT_NONXML ,BT_MALFORM ,BT_TRAIL ,BT_CR ,BT_LF :
+ _go0:
+ begin
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_DATA_CHARS;
+
+ exit;
+
+ end;
+
+ else
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ end;
+
+_break2:
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_DATA_CHARS;
+
+end;
+
+{ normal_cdataSectionTok {..}
+function normal_cdataSectionTok(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
+begin
+end;
+
+{ normal_ignoreSectionTok {..}
+function normal_ignoreSectionTok(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
+begin
+end;
+
+{ normal_attributeValueTok }
+function normal_attributeValueTok(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
+var
+ start : char_ptr;
+
+begin
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_NONE;
+
+ exit;
+
+ end;
+
+ start:=ptr;
+
+ while ptr <> end_ do
+ case BYTE_TYPE(enc ,ptr ) of
+ BT_LEAD2 :
+ inc(ptrcomp(ptr ) ,2 );
+
+ BT_LEAD3 :
+ inc(ptrcomp(ptr ) ,3 );
+
+ BT_LEAD4 :
+ inc(ptrcomp(ptr ) ,4 );
+
+ BT_AMP :
+ begin
+ if ptr = start then
+ begin
+ result:=normal_scanRef(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ,end_ ,nextTokPtr );
+
+ exit;
+
+ end;
+
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_DATA_CHARS;
+
+ exit;
+
+ end;
+
+ BT_LT :
+ begin
+ { this is for inside entity references }
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_INVALID;
+
+ exit;
+
+ end;
+
+ BT_LF :
+ begin
+ if ptr = start then
+ begin
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ result:=XML_TOK_DATA_NEWLINE;
+
+ exit;
+
+ end;
+
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_DATA_CHARS;
+
+ exit;
+
+ end;
+
+ BT_CR :
+ begin
+ if ptr = start then
+ begin
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ if ptr = end_ then
+ begin
+ result:=XML_TOK_TRAILING_CR;
+
+ exit;
+
+ end;
+
+ if BYTE_TYPE(enc ,ptr ) = BT_LF then
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_DATA_NEWLINE;
+
+ exit;
+
+ end;
+
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_DATA_CHARS;
+
+ exit;
+
+ end;
+
+ BT_S :
+ begin
+ if ptr = start then
+ begin
+ nextTokPtr^:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ result:=XML_TOK_ATTRIBUTE_VALUE_S;
+
+ exit;
+
+ end;
+
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_DATA_CHARS;
+
+ exit;
+
+ end;
+
+ else
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ end;
+
+ nextTokPtr^:=ptr;
+
+ result:=XML_TOK_DATA_CHARS;
+
+end;
+
+{ normal_entityValueTok {..}
+function normal_entityValueTok(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
+begin
+end;
+
+{ normal_sameName {..}
+function normal_sameName(enc : ENCODING_ptr; ptr1 ,ptr2 : char_ptr ) : int;
+begin
+end;
+
+{ normal_nameMatchesAscii }
+function normal_nameMatchesAscii(enc : ENCODING_ptr; ptr1 ,end1 ,ptr2 : char_ptr ) : int;
+begin
+ while ptr2^ <> #0 do
+ begin
+ if ptr1 = end1 then
+ begin
+ result:=0;
+
+ exit;
+
+ end;
+
+ if CHAR_MATCHES(enc ,ptr1 ,int(ptr2^ ) ) = 0 then
+ begin
+ result:=0;
+
+ exit;
+
+ end;
+
+ inc(ptrcomp(ptr1 ) ,MINBPC(enc ) );
+ inc(ptrcomp(ptr2 ) );
+
+ end;
+
+ result:=int(ptr1 = end1 );
+
+end;
+
+{ normal_nameLength }
+function normal_nameLength(enc : ENCODING_ptr; ptr : char_ptr ) : int;
+var
+ start : char_ptr;
+
+begin
+ start:=ptr;
+
+ repeat
+ case BYTE_TYPE(enc ,ptr ) of
+ BT_LEAD2 :
+ inc(ptrcomp(ptr ) ,2 );
+
+ BT_LEAD3 :
+ inc(ptrcomp(ptr ) ,3 );
+
+ BT_LEAD4 :
+ inc(ptrcomp(ptr ) ,4 );
+
+ BT_NONASCII ,BT_NMSTRT ,{$IFDEF XML_NS }BT_COLON ,{$ENDIF }
+ BT_HEX ,BT_DIGIT ,BT_NAME ,BT_MINUS :
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ else
+ begin
+ result:=ptrcomp(ptr ) - ptrcomp(start );
+
+ exit;
+
+ end;
+
+ end;
+
+ until false;
+
+end;
+
+{ normal_skipS {..}
+function normal_skipS(enc : ENCODING_ptr; ptr : char_ptr ) : char_ptr;
+begin
+end;
+
+{ normal_getAtts }
+{ This must only be called for a well-formed start-tag or empty
+ element tag. Returns the number of attributes. Pointers to the
+ first attsMax attributes are stored in atts. }
+function normal_getAtts(enc : ENCODING_ptr; ptr : char_ptr; attsMax : int; atts : ATTRIBUTE_ptr ) : int;
+type
+ state_enum = (other ,inName ,inValue );
+
+var
+ state : state_enum;
+
+ nAtts ,open : int;
+
+begin
+ state:=inName;
+ nAtts:=0;
+ open :=0; { defined when state = inValue;
+ initialization just to shut up compilers }
+
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ repeat
+ case BYTE_TYPE(enc ,ptr ) of
+ BT_LEAD2 :
+ begin
+ if state = other then
+ begin
+ if nAtts < attsMax then
+ begin
+ ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.name :=ptr;
+ ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.normalized:=#1;
+
+ end;
+
+ state:=inName;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,2 - MINBPC(enc ) );
+
+ end;
+
+ BT_LEAD3 :
+ begin
+ if state = other then
+ begin
+ if nAtts < attsMax then
+ begin
+ ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.name :=ptr;
+ ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.normalized:=#1;
+
+ end;
+
+ state:=inName;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,3 - MINBPC(enc ) );
+
+ end;
+
+ BT_LEAD4 :
+ begin
+ if state = other then
+ begin
+ if nAtts < attsMax then
+ begin
+ ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.name :=ptr;
+ ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.normalized:=#1;
+
+ end;
+
+ state:=inName;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,4 - MINBPC(enc ) );
+
+ end;
+
+ BT_NONASCII ,BT_NMSTRT ,BT_HEX :
+ if state = other then
+ begin
+ if nAtts < attsMax then
+ begin
+ ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.name :=ptr;
+ ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.normalized:=#1;
+
+ end;
+
+ state:=inName;
+
+ end;
+
+ BT_QUOT :
+ if state <> inValue then
+ begin
+ if nAtts < attsMax then
+ ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.valuePtr:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ state:=inValue;
+ open :=BT_QUOT;
+
+ end
+ else
+ if open = BT_QUOT then
+ begin
+ state:=other;
+
+ if nAtts < attsMax then
+ ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.valueEnd:=ptr;
+
+ inc(nAtts );
+
+ end;
+
+ BT_APOS :
+ if state <> inValue then
+ begin
+ if nAtts < attsMax then
+ ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.valuePtr:=char_ptr(ptrcomp(ptr ) + MINBPC(enc ) );
+
+ state:=inValue;
+ open :=BT_APOS;
+
+ end
+ else
+ if open = BT_APOS then
+ begin
+ state:=other;
+
+ if nAtts < attsMax then
+ ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.valueEnd:=ptr;
+
+ inc(nAtts );
+
+ end;
+
+ BT_AMP :
+ if nAtts < attsMax then
+ ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.normalized:=#0;
+
+ BT_S :
+ if state = inName then
+ state:=other
+ else
+ if (state = inValue ) and
+ (nAtts < attsMax ) and
+ (ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.normalized <> #0 ) and
+ ((ptr = ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.valuePtr ) or
+ (BYTE_TO_ASCII(enc ,ptr ) <> int(ASCII_SPACE ) ) or
+ (BYTE_TO_ASCII(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ) = int(ASCII_SPACE ) ) or
+ (BYTE_TYPE(enc ,char_ptr(ptrcomp(ptr ) + MINBPC(enc ) ) ) = open ) ) then
+ ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.normalized:=#0;
+
+ BT_CR ,BT_LF :
+ { This case ensures that the first attribute name is counted
+ Apart from that we could just change state on the quote. }
+ if state = inName then
+ state:=other
+ else
+ if (state = inValue ) and
+ (nAtts < attsMax ) then
+ ATTRIBUTE_ptr(ptrcomp(atts ) + nAtts * sizeof(ATTRIBUTE ) )^.normalized:=#0;
+
+ BT_GT ,BT_SOL :
+ if state <> inValue then
+ begin
+ result:=nAtts;
+
+ exit;
+
+ end;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ until false;
+
+{ not reached }
+
+end;
+
+{ normal_charRefNumber {..}
+function normal_charRefNumber(enc : ENCODING_ptr; ptr : char_ptr ) : int;
+begin
+end;
+
+{ normal_predefinedEntityName {..}
+function normal_predefinedEntityName(enc : ENCODING_ptr; ptr ,end_ : char_ptr ) : int;
+begin
+end;
+
+{ normal_updatePosition }
+procedure normal_updatePosition(enc : ENCODING_ptr; ptr ,end_ : char_ptr; pos : POSITION_ptr );
+begin
+ while ptr <> end_ do
+ begin
+ case BYTE_TYPE(enc ,ptr ) of
+ BT_LEAD2 :
+ inc(ptrcomp(ptr ) ,2 );
+
+ BT_LEAD3 :
+ inc(ptrcomp(ptr ) ,3 );
+
+ BT_LEAD4 :
+ inc(ptrcomp(ptr ) ,4 );
+
+ BT_LF :
+ begin
+ pos.columnNumber:=XML_Size(-1 );
+
+ inc(pos.lineNumber );
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ end;
+
+ BT_CR :
+ begin
+ inc(pos.lineNumber );
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ if (ptr <> end_ ) and
+ (BYTE_TYPE(enc ,ptr ) = BT_LF ) then
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ pos.columnNumber:=XML_Size(-1 );
+
+ end;
+
+ else
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ end;
+
+ inc(pos.columnNumber );
+
+ end;
+
+end;
+
+{ normal_isPublicId }
+function normal_isPublicId(enc : ENCODING_ptr; ptr ,end_ : char_ptr; badPtr : char_ptr_ptr ) : int;
+label
+ _else ;
+
+begin
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+ dec(ptrcomp(end_ ) ,MINBPC(enc ) );
+
+ while ptr <> end_ do
+ begin
+ case BYTE_TYPE(enc ,ptr ) of
+ BT_S :
+ if CHAR_MATCHES(enc ,ptr ,int(ASCII_TAB ) ) <> 0 then
+ begin
+ badPtr^:=ptr;
+ result :=0;
+
+ exit;
+
+ end;
+
+ BT_NAME ,BT_NMSTRT :
+ if BYTE_TO_ASCII(enc ,ptr ) and not $7f = 0 then
+ else
+ goto _else;
+
+ BT_DIGIT ,BT_HEX ,BT_MINUS ,BT_APOS ,BT_LPAR ,BT_RPAR ,BT_PLUS ,BT_COMMA ,
+ BT_SOL ,BT_EQUALS ,BT_QUEST ,BT_CR ,BT_LF ,BT_SEMI ,BT_EXCL ,BT_AST ,BT_PERCNT ,
+ BT_NUM {$IFDEF XML_NS } ,BT_COLON : {$ELSE } : {$ENDIF }
+ else
+ _else:
+ case BYTE_TO_ASCII(enc ,ptr ) of
+ $24 , { $ }
+ $40 : { @ }
+ else
+ begin
+ badPtr^:=ptr;
+ result :=0;
+
+ exit;
+
+ end;
+
+ end;
+
+ end;
+
+ inc(ptrcomp(ptr ) ,MINBPC(enc ) );
+
+ end;
+
+ result:=1;
+
+end;
+
diff --git a/src/corelib/render/software/agg-demos/expat-pas/xmltok_ns.inc b/src/corelib/render/software/agg-demos/expat-pas/xmltok_ns.inc
index d3196b15..0718b95b 100755..100644
--- a/src/corelib/render/software/agg-demos/expat-pas/xmltok_ns.inc
+++ b/src/corelib/render/software/agg-demos/expat-pas/xmltok_ns.inc
@@ -1,176 +1,176 @@
-//----------------------------------------------------------------------------
-// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
-// and Clark Cooper
-// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
-//
-// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
-// Pascal Port By: Milan Marusinec alias Milano
-// milan@marusinec.sk
-// http://www.pasports.org/pasexpat
-// Copyright (c) 2006
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// [Pascal Port History] -----------------------------------------------------
-//
-// 17.05.2006-Milano: Unit port establishment
-// 02.06.2006-Milano: porting
-// 09.06.2006-Milano: -"-
-//
-{ xmltok_ns.inc }
-const
-{$IFDEF XML_NS }
- encodingsNS : array[0..6 ] of ENCODING_ptr = (
- @latin1_encoding_ns.enc ,
- @ascii_encoding_ns.enc ,
- @utf8_encoding_ns.enc ,
- @big2_encoding_ns.enc ,
- @big2_encoding_ns.enc ,
- @little2_encoding_ns.enc ,
- @utf8_encoding_ns.enc ); { NO_ENC }
-
-{$ENDIF }
-
- encodings : array[0..6 ] of ENCODING_ptr = (
- @latin1_encoding.enc ,
- @ascii_encoding.enc ,
- @utf8_encoding.enc ,
- @big2_encoding.enc ,
- @big2_encoding.enc ,
- @little2_encoding.enc ,
- @utf8_encoding.enc ); { NO_ENC }
-
-{ initScanProlog }
-function initScanProlog(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
-begin
- result:=initScan(@encodings ,INIT_ENCODING_ptr(enc ) ,XML_PROLOG_STATE ,ptr ,end_ ,nextTokPtr );
-
-end;
-
-{ initScanContent {..}
-function initScanContent(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
-begin
-end;
-
-{ XMLINITENCODING }
-function XmlInitEncoding;
-var
- i : int;
-
-begin
- i:=getEncodingIndex(name );
-
- if i = UNKNOWN_ENC then
- begin
- result:=0;
-
- exit;
-
- end;
-
- SET_INIT_ENC_INDEX(p ,i );
-
- p.initEnc.scanners[XML_PROLOG_STATE ]:=@initScanProlog;
- p.initEnc.scanners[XML_CONTENT_STATE ]:=@initScanContent;
-
- p.initEnc.updatePosition:=@initUpdatePosition;
-
- p.encPtr:=encPtr;
- encPtr^ :=@p.initEnc;
-
- result:=1;
-
-end;
-
-{ XMLINITENCODINGNS }
-function XmlInitEncodingNS;
-begin
-end;
-
-{ XmlGetUtf8InternalEncoding }
-function XmlGetUtf8InternalEncoding : ENCODING_ptr;
-begin
- result:=@internal_utf8_encoding.enc;
-
-end;
-
-{ XmlGetUtf16InternalEncoding {..}
-function XmlGetUtf16InternalEncoding : ENCODING_ptr;
-begin
-end;
-
-{ XMLGETINTERNALENCODING }
-function XmlGetInternalEncoding;
-begin
-{$IFDEF XML_UNICODE }
- result:=XmlGetUtf16InternalEncoding;
-
-{$ELSE }
- result:=XmlGetUtf8InternalEncoding;
-
-{$ENDIF }
-
-end;
-
-{ XmlGetUtf8InternalEncodingNS {..}
-function XmlGetUtf8InternalEncodingNS : ENCODING_ptr;
-begin
-end;
-
-{ XmlGetUtf16InternalEncodingNS {..}
-function XmlGetUtf16InternalEncodingNS : ENCODING_ptr;
-begin
-end;
-
-{ XMLGETINTERNALENCODINGNS }
-function XmlGetInternalEncodingNS;
-begin
-{$IFDEF XML_UNICODE }
- result:=XmlGetUtf16InternalEncodingNS;
-
-{$ELSE }
- result:=XmlGetUtf8InternalEncodingNS;
-
-{$ENDIF }
-
-end;
-
-{ findEncoding {..}
-function findEncoding(enc : ENCODING_ptr; ptr ,end_ : char_ptr ) : ENCODING_ptr;
-begin
-end;
-
-{ XMLPARSEXMLDECL }
-function XmlParseXmlDecl;
-begin
- result:=
- doParseXmlDecl(
- @findEncoding ,
- isGeneralTextEntity ,
- enc ,ptr ,end_ ,
- badPtr ,
- versionPtr ,
- versionEndPtr ,
- encodingNamePtr ,
- namedEncodingPtr ,
- standalonePtr );
-
-end;
-
+//----------------------------------------------------------------------------
+// Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+// and Clark Cooper
+// Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
+//
+// Expat - Version 2.0.0 Release Milano 0.83 (PasExpat 2.0.0 RM0.83)
+// Pascal Port By: Milan Marusinec alias Milano
+// milan@marusinec.sk
+// http://www.pasports.org/pasexpat
+// Copyright (c) 2006
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// [Pascal Port History] -----------------------------------------------------
+//
+// 17.05.2006-Milano: Unit port establishment
+// 02.06.2006-Milano: porting
+// 09.06.2006-Milano: -"-
+//
+{ xmltok_ns.inc }
+const
+{$IFDEF XML_NS }
+ encodingsNS : array[0..6 ] of ENCODING_ptr = (
+ @latin1_encoding_ns.enc ,
+ @ascii_encoding_ns.enc ,
+ @utf8_encoding_ns.enc ,
+ @big2_encoding_ns.enc ,
+ @big2_encoding_ns.enc ,
+ @little2_encoding_ns.enc ,
+ @utf8_encoding_ns.enc ); { NO_ENC }
+
+{$ENDIF }
+
+ encodings : array[0..6 ] of ENCODING_ptr = (
+ @latin1_encoding.enc ,
+ @ascii_encoding.enc ,
+ @utf8_encoding.enc ,
+ @big2_encoding.enc ,
+ @big2_encoding.enc ,
+ @little2_encoding.enc ,
+ @utf8_encoding.enc ); { NO_ENC }
+
+{ initScanProlog }
+function initScanProlog(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
+begin
+ result:=initScan(@encodings ,INIT_ENCODING_ptr(enc ) ,XML_PROLOG_STATE ,ptr ,end_ ,nextTokPtr );
+
+end;
+
+{ initScanContent {..}
+function initScanContent(enc : ENCODING_ptr; ptr ,end_ : char_ptr; nextTokPtr : char_ptr_ptr ) : int;
+begin
+end;
+
+{ XMLINITENCODING }
+function XmlInitEncoding;
+var
+ i : int;
+
+begin
+ i:=getEncodingIndex(name );
+
+ if i = UNKNOWN_ENC then
+ begin
+ result:=0;
+
+ exit;
+
+ end;
+
+ SET_INIT_ENC_INDEX(p ,i );
+
+ p.initEnc.scanners[XML_PROLOG_STATE ]:=@initScanProlog;
+ p.initEnc.scanners[XML_CONTENT_STATE ]:=@initScanContent;
+
+ p.initEnc.updatePosition:=@initUpdatePosition;
+
+ p.encPtr:=encPtr;
+ encPtr^ :=@p.initEnc;
+
+ result:=1;
+
+end;
+
+{ XMLINITENCODINGNS }
+function XmlInitEncodingNS;
+begin
+end;
+
+{ XmlGetUtf8InternalEncoding }
+function XmlGetUtf8InternalEncoding : ENCODING_ptr;
+begin
+ result:=@internal_utf8_encoding.enc;
+
+end;
+
+{ XmlGetUtf16InternalEncoding {..}
+function XmlGetUtf16InternalEncoding : ENCODING_ptr;
+begin
+end;
+
+{ XMLGETINTERNALENCODING }
+function XmlGetInternalEncoding;
+begin
+{$IFDEF XML_UNICODE }
+ result:=XmlGetUtf16InternalEncoding;
+
+{$ELSE }
+ result:=XmlGetUtf8InternalEncoding;
+
+{$ENDIF }
+
+end;
+
+{ XmlGetUtf8InternalEncodingNS {..}
+function XmlGetUtf8InternalEncodingNS : ENCODING_ptr;
+begin
+end;
+
+{ XmlGetUtf16InternalEncodingNS {..}
+function XmlGetUtf16InternalEncodingNS : ENCODING_ptr;
+begin
+end;
+
+{ XMLGETINTERNALENCODINGNS }
+function XmlGetInternalEncodingNS;
+begin
+{$IFDEF XML_UNICODE }
+ result:=XmlGetUtf16InternalEncodingNS;
+
+{$ELSE }
+ result:=XmlGetUtf8InternalEncodingNS;
+
+{$ENDIF }
+
+end;
+
+{ findEncoding {..}
+function findEncoding(enc : ENCODING_ptr; ptr ,end_ : char_ptr ) : ENCODING_ptr;
+begin
+end;
+
+{ XMLPARSEXMLDECL }
+function XmlParseXmlDecl;
+begin
+ result:=
+ doParseXmlDecl(
+ @findEncoding ,
+ isGeneralTextEntity ,
+ enc ,ptr ,end_ ,
+ badPtr ,
+ versionPtr ,
+ versionEndPtr ,
+ encodingNamePtr ,
+ namedEncodingPtr ,
+ standalonePtr );
+
+end;
+