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

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

Sentinels

File size: 1.1 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  unsigned char * buf_ptr = xml_buf->GetBytePtr(newpos * CODE_UNIT_BYTES);
14  int avail_bytes = xml_buf->PrepareBytes(BYTE_STREAM_SIZE);
15  int new_blocks = min(BUFFER_BLOCKS, (avail_bytes + BLOCKSIZE - 1)/BLOCKSIZE);
16  int new_packs = new_blocks * 8 + 1;
17#ifdef BUFFER_PROFILING
18  start_BOM_interval(bitstream_timer);
19#endif
20  BytePack * src_data = (BytePack *) buf_ptr;
21  for (int pk = 0; pk < new_packs; pk++) {
22    parsing_engine_data->x8data[pk] = sisd_load_unaligned(&src_data[pk]);
23  }
24  ComputeLexicalItemStreams(new_blocks);
25  EstablishSentinels(avail_bytes/CODE_UNIT_BYTES);
26  return avail_bytes/CODE_UNIT_BYTES;
27}
28
29int Ext_ASCII_8_Lexer::BOM_size(int rel_pos) {
30  if (s3int32((unsigned char *) &parsing_engine_data->x8data) == c3int32(0xEF, 0xBB, 0xBF))
31    return 3;
32  else return 0;
33}
Note: See TracBrowser for help on using the repository browser.