Changeset 100 for trunk/src/xmldecl.c


Ignore:
Timestamp:
Apr 14, 2008, 6:34:30 PM (11 years ago)
Author:
lindanl
Message:

Parsers for internal and external entities.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/xmldecl.c

    r91 r100  
    7474
    7575template <CodeUnit_Base C>
    76 int XML_Decl_Parser<C>::EncodingAction(Model_Info * m, int start_pos, int end_pos) {
    77         m->encoding = (unsigned char *) malloc(end_pos-start_pos+1);
    78         memcpy(m->encoding, &x8data[start_pos-buffer_base_pos], end_pos - start_pos);
    79         m->encoding[end_pos - start_pos] = '\0';
     76int XML_Decl_Parser<C>::EncodingAction(Entity_Info *e, int start_pos, int end_pos) {
     77        e->encoding = (unsigned char *) malloc(end_pos-start_pos+1);
     78        memcpy(e->encoding, &x8data[start_pos-buffer_base_pos], end_pos - start_pos);
     79        e->encoding[end_pos - start_pos] = '\0';
    8080}
    8181//
    8282template <CodeUnit_Base C>
    83 int XML_Decl_Parser<C>::ReadXMLInfo(Model_Info * m) {
    84         m->version = no_XML_version_value;
    85         m->has_encoding_decl = false;
    86         m->standalone = Standalone_no_value;
    87         buffer_rel_pos = m->BOM_units;
     83int XML_Decl_Parser<C>::ReadXMLInfo(Entity_Info *e) {
     84        e->version = no_XML_version_value;
     85        e->has_encoding_decl = false;
     86        e->standalone = Standalone_no_value;
     87        buffer_rel_pos = e->BOM_units;
    8888        // It is possible that there is no XML declaration.
    8989        if (!at_XmlDecl_start<C>(cur())) {
     
    100100        Advance(1);
    101101        Scan_WS();
    102         if (at_1_0<C>(cur())) m->version = XML_1_0;
    103         else if (at_1_1<C>(cur())) m->version = XML_1_1;
     102        if (at_1_0<C>(cur())) e->version = XML_1_0;
     103        else if (at_1_1<C>(cur())) e->version = XML_1_1;
    104104        else DeclarationError(AbsPos());
    105105        Advance(5);
     
    108108        Scan_WS();
    109109        if (at_encoding<C>(cur())) {
    110                 m->has_encoding_decl = true;
     110                e->has_encoding_decl = true;
    111111                Advance(8);
    112112                Scan_WS();
     
    120120                        ScanToQuote();
    121121                        if (cur()[0] != quoteCh) DeclarationError(AbsPos());
    122                         EncodingAction(m, encoding_start_pos, AbsPos());
     122                        EncodingAction(e, encoding_start_pos, AbsPos());
    123123                }
    124124                else DeclarationError(AbsPos());
     
    134134                Advance(1);
    135135                Scan_WS();
    136                 if (at_yes<C>(cur())) {Advance(5); m->standalone = Standalone_yes;}
    137                 else if (at_no<C>(cur())) {Advance(4); m->standalone = Standalone_no;}
     136                if (at_yes<C>(cur())) {Advance(5); e->standalone = Standalone_yes;}
     137                else if (at_no<C>(cur())) {Advance(4); e->standalone = Standalone_no;}
    138138                else DeclarationError(AbsPos());
    139139                Scan_WS();
     
    148148// processing.
    149149template <CodeUnit_Base C>
    150 int XML_Decl_Parser<C>::ReadTextDeclaration(Model_Info * m) {
    151         m->version = no_XML_version_value;
    152         m->has_encoding_decl = false;
    153         m->standalone = Standalone_no_value;
    154         buffer_rel_pos = m->BOM_units;
     150int XML_Decl_Parser<C>::ReadTextDeclaration(Entity_Info *e) {
     151        e->version = no_XML_version_value;
     152        e->has_encoding_decl = false;
     153        e->standalone = Standalone_no_value;
     154        buffer_rel_pos = e->BOM_units;
    155155        // It is possible that there is no XML declaration.
    156156        if (!at_XmlDecl_start<C>(cur())) {
     
    167167                Advance(1);
    168168                Scan_WS();
    169                 if (at_1_0<C>(cur())) m->version = XML_1_0;
    170                 else if (at_1_1<C>(cur())) m->version = XML_1_1;
     169                if (at_1_0<C>(cur())) e->version = XML_1_0;
     170                else if (at_1_1<C>(cur())) e->version = XML_1_1;
    171171                else DeclarationError(AbsPos());
    172172                Advance(5);
     
    176176        }
    177177        if (!at_encoding<C>(cur())) DeclarationError(AbsPos());
    178         m->has_encoding_decl = true;
     178        e->has_encoding_decl = true;
    179179        Advance(8);
    180180        Scan_WS();
     
    188188                ScanToQuote();
    189189                if (cur()[0] != quoteCh) DeclarationError(AbsPos());
    190                 EncodingAction(m, encoding_start_pos, AbsPos());
     190                EncodingAction(e, encoding_start_pos, AbsPos());
    191191        }
    192192        else DeclarationError(AbsPos());
Note: See TracChangeset for help on using the changeset viewer.