source: trunk/src/charsets/ext_ascii_8.c @ 15

Last change on this file since 15 was 15, checked in by cameron, 11 years ago

Bytespace scanning in XML declarations; various updates

File size: 1.2 KB
Line 
1#include "ext_ascii_8.h"
2
3Ext_ASCII_8_Lexer::Ext_ASCII_8_Lexer(XML_Buffer *b, ParallelStreamSet *p) : Lexer(b, p) {
4}
5
6
7#define min(a,b) ((a) < (b) ? (a) : (b))
8
9const int CODE_UNIT_BYTES = 1;  /* 8-bit code units in this file. */
10const int BYTE_STREAM_SIZE = (BUFFER_BLOCKS * BLOCKSIZE + LOOKAHEAD_POSITIONS) * CODE_UNIT_BYTES;
11
12int Ext_ASCII_8_Lexer::AdvanceBuffer(int newpos) {
13  int byte_pos = newpos * CODE_UNIT_BYTES;
14  int avail_bytes = xml_buf->PrepareBytes(byte_pos, BYTE_STREAM_SIZE);
15  unsigned char * buf_ptr = xml_buf->BytePtr(byte_pos);
16  int new_blocks = min(BUFFER_BLOCKS, (avail_bytes + BLOCKSIZE - 1)/BLOCKSIZE);
17  int new_packs = new_blocks * 8 + 1;
18#ifdef BUFFER_PROFILING
19  start_BOM_interval(bitstream_timer);
20#endif
21  BytePack * src_data = (BytePack *) buf_ptr;
22  for (int pk = 0; pk < new_packs; pk++) {
23    parsing_engine_data->x8data[pk] = sisd_load_unaligned(&src_data[pk]);
24  }
25  ComputeLexicalItemStreams(new_blocks);
26  EstablishSentinels(avail_bytes/CODE_UNIT_BYTES);
27  return avail_bytes/CODE_UNIT_BYTES;
28}
29
30int Ext_ASCII_8_Lexer::BOM_size(int rel_pos) {
31  if (s3int32((unsigned char *) &parsing_engine_data->x8data) == c3int32(0xEF, 0xBB, 0xBF))
32    return 3;
33  else return 0;
34}
Note: See TracBrowser for help on using the repository browser.