#define MAX_BUFPOS_GAP_SIZE_3 (65535/3)
#define MAX_BYTIND_GAP_SIZE_3 (3 * MAX_BUFPOS_GAP_SIZE_3)
+#ifndef UTF2000
short three_to_one_table[1 + MAX_BYTIND_GAP_SIZE_3];
+#endif
/* Various macros modelled along the lines of those in buffer.h.
Purposefully omitted from buffer.h because files other than this
bufmax = buf->text->mule_bufmax;
bytmin = buf->text->mule_bytmin;
bytmax = buf->text->mule_bytmax;
+#ifdef UTF2000
+ size = buf->text->mule_size;
+#else
size = (1 << buf->text->mule_shifter) + !!buf->text->mule_three_p;
+#endif
/* The basic idea here is that we shift the "known region" up or down
until it overlaps the specified position. We do this by moving
discovered isn't too large, because we use a fixed-length
table to divide by 3. */
+#ifdef UTF2000
+ buf->text->mule_size = size;
+#endif
if (size == 3)
{
int gap = bytmax - bytmin;
+#ifndef UTF2000
buf->text->mule_three_p = 1;
buf->text->mule_shifter = 1;
+#endif
if (gap > MAX_BYTIND_GAP_SIZE_3)
{
}
else
{
+#ifndef UTF2000
buf->text->mule_three_p = 0;
if (size == 4)
buf->text->mule_shifter = 2;
else
buf->text->mule_shifter = size - 1;
+#endif
}
buf->text->mule_bufmin = bufmin;
bufmax = buf->text->mule_bufmax;
bytmin = buf->text->mule_bytmin;
bytmax = buf->text->mule_bytmax;
+#ifdef UTF2000
+ size = buf->text->mule_size;
+#else
size = (1 << buf->text->mule_shifter) + !!buf->text->mule_three_p;
+#endif
/* The basic idea here is that we shift the "known region" up or down
until it overlaps the specified position. We do this by moving
discovered isn't too large, because we use a fixed-length
table to divide by 3. */
+#ifdef UTF2000
+ buf->text->mule_size = size;
+ #endif
if (size == 3)
{
int gap = bytmax - bytmin;
+#ifndef UTF2000
buf->text->mule_three_p = 1;
buf->text->mule_shifter = 1;
+#endif
if (gap > MAX_BYTIND_GAP_SIZE_3)
{
}
else
{
+#ifndef UTF2000
buf->text->mule_three_p = 0;
if (size == 4)
buf->text->mule_shifter = 2;
else
buf->text->mule_shifter = size - 1;
+#endif
}
buf->text->mule_bufmin = bufmin;
Bytecount bytelength,
Charcount charlength)
{
+#ifdef UTF2000
+ int size = buf->text->mule_size;
+#else
int size = (1 << buf->text->mule_shifter) + !!buf->text->mule_three_p;
+#endif
int i;
/* Adjust the cache of known positions. */
Bytecount old_gap_size;
/* If we have to get more space, get enough to last a while. We use
- a geometric progession that saves on realloc space. */
+ a geometric progression that saves on realloc space. */
increment += 2000 + ((BI_BUF_Z (buf) - BI_BUF_BEG (buf)) / 8);
if (increment > BUF_END_GAP_SIZE (buf))
/* Make a string from a buffer. This needs to take into account the gap,
and add any necessary extents from the buffer. */
-Lisp_Object
-make_string_from_buffer (struct buffer *buf, Bufpos pos, Charcount length)
+static Lisp_Object
+make_string_from_buffer_1 (struct buffer *buf, Bufpos pos, Charcount length,
+ int no_extents)
{
/* This function can GC */
- Lisp_Object val;
- struct gcpro gcpro1;
- Bytind bi_ind;
- Bytecount bi_len;
-
- bi_ind = bufpos_to_bytind (buf, pos);
- bi_len = bufpos_to_bytind (buf, pos + length) - bi_ind;
+ Bytind bi_ind = bufpos_to_bytind (buf, pos);
+ Bytecount bi_len = bufpos_to_bytind (buf, pos + length) - bi_ind;
+ Lisp_Object val = make_uninit_string (bi_len);
- val = make_uninit_string (bi_len);
+ struct gcpro gcpro1;
GCPRO1 (val);
- add_string_extents (val, buf, bi_ind, bi_len);
+ if (!no_extents)
+ add_string_extents (val, buf, bi_ind, bi_len);
{
Bytecount len1 = BI_BUF_GPT (buf) - bi_ind;
return val;
}
+Lisp_Object
+make_string_from_buffer (struct buffer *buf, Bufpos pos, Charcount length)
+{
+ return make_string_from_buffer_1 (buf, pos, length, 0);
+}
+
+Lisp_Object
+make_string_from_buffer_no_extents (struct buffer *buf, Bufpos pos,
+ Charcount length)
+{
+ return make_string_from_buffer_1 (buf, pos, length, 1);
+}
+
void
barf_if_buffer_read_only (struct buffer *buf, Bufpos from, Bufpos to)
{
}
void
-find_charsets_in_bufbyte_string (unsigned char *charsets, CONST Bufbyte *str,
+find_charsets_in_bufbyte_string (Charset_ID *charsets, CONST Bufbyte *str,
Bytecount len)
{
#ifndef MULE
charsets[0] = 1;
#else
CONST Bufbyte *strend = str + len;
- memset (charsets, 0, NUM_LEADING_BYTES);
+ memset (charsets, 0, NUM_LEADING_BYTES * sizeof(Charset_ID));
while (str < strend)
{
- charsets[CHAR_LEADING_BYTE (charptr_emchar (str)) - 128] = 1;
+ charsets[CHAR_LEADING_BYTE (charptr_emchar (str))
+ - MIN_LEADING_BYTE] = 1;
INC_CHARPTR (str);
}
#endif
}
void
-find_charsets_in_emchar_string (unsigned char *charsets, CONST Emchar *str,
+find_charsets_in_emchar_string (Charset_ID *charsets, CONST Emchar *str,
Charcount len)
{
#ifndef MULE
#else
int i;
- memset (charsets, 0, NUM_LEADING_BYTES);
+ memset (charsets, 0, NUM_LEADING_BYTES * sizeof(Charset_ID));
for (i = 0; i < len; i++)
{
- charsets[CHAR_LEADING_BYTE (str[i]) - 128] = 1;
+ charsets[CHAR_LEADING_BYTE (str[i]) - MIN_LEADING_BYTE] = 1;
}
#endif
}
}
}
-int
+Charcount
convert_bufbyte_string_into_emchar_string (CONST Bufbyte *str, Bytecount len,
Emchar *arr)
{
void
vars_of_insdel (void)
{
+#ifndef UTF2000
int i;
+#endif
inside_change_hook = 0;
in_first_change = 0;
+#ifndef UTF2000
for (i = 0; i <= MAX_BYTIND_GAP_SIZE_3; i++)
three_to_one_table[i] = i / 3;
+#endif
}
void
b->text->mule_bufmin = b->text->mule_bufmax = 1;
b->text->mule_bytmin = b->text->mule_bytmax = 1;
+#ifdef UTF2000
+ b->text->mule_size = 0;
+#else
b->text->mule_shifter = 0;
b->text->mule_three_p = 0;
+#endif
for (i = 0; i < 16; i++)
{