Changeset 595


Ignore:
Timestamp:
Aug 21, 2010, 2:13:54 PM (9 years ago)
Author:
lindanl
Message:

fixed tag matching error at buffer boundary

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/parabix2/src/tag_matcher.cpp

    r591 r595  
    102102              pos++;
    103103            pos = bitstream_scan(miscMarks,pos+1);
    104             if(pos!=chars_avail)
     104            if(pos!=chars_avail){
    105105              fprintf(stderr,"illegal content after root element at position = %i\n",buf_base+pos);
    106             exit(-1);       
     106              exit(-1);
     107            }
    107108          }
    108109          return rt_val;
     
    115116              pos++;
    116117            pos = bitstream_scan(miscMarks,pos+1);
    117             if(pos!=chars_avail)
     118            if(pos!=chars_avail){
    118119              fprintf(stderr,"illegal content after root element at position = %i\n",buf_base+pos);
    119             exit(-1);       
     120              exit(-1);     
     121            }
    120122          }
    121123        }
     
    209211      if (does_match(tag_stack[depth]+inTagPos,srcbuf,lgth-inTagPos) && ((srcbuf[lgth] == '>') ||(srcbuf[lgth] <= ' '))) return ;       
    210212      else {
     213         cout << "inTagPos = " << inTagPos << endl;
     214              cout << "end tag is " << string(srcbuf,lgth-inTagPos) << endl ;
     215              cout << "start tag is   " << string(tag_stack[depth]+inTagPos,lgth-inTagPos) << endl ;
     216              cout << "start tag[-1] is " << string(tag_stack[depth-1],tag_lgth_stack[depth-1]) << endl ;
    211217          fprintf(stderr,"tag name mismatch at position = %i\n",buf_base);
    212218          exit(-1);
     
    247253  for(int i=0; i< depth; i++){
    248254    if(&tags_buf[tags_buf_cur]!=tag_stack[i])
    249       memcpy(&tags_buf[tags_buf_cur],tag_stack[i],tag_lgth_stack[i]);         
     255      memcpy(&tags_buf[tags_buf_cur],tag_stack[i],tag_lgth_stack[i]);
    250256    tag_stack[i] = &tags_buf[tags_buf_cur];
    251257    tags_buf_cur += tag_lgth_stack[i];
     
    256262      tags_buf_cur += tag_lgth_stack[depth];
    257263  }
    258   if(state == InAttName) {
     264  else if(state == InEndTag) {
     265     memcpy(&tags_buf[tags_buf_cur],tag_stack[depth],tag_lgth_stack[depth]);
     266    tag_stack[depth] = &tags_buf[tags_buf_cur];
     267    tags_buf_cur += tag_lgth_stack[depth];
     268  }
     269  else if(state == InAttName) {
    259270      memcpy(&tags_buf[tags_buf_cur],InAtt.start,InAtt.lgth);
    260271      InAtt.start = &tags_buf[tags_buf_cur];
Note: See TracChangeset for help on using the changeset viewer.