#include "ccl.h"
#include "composite.h"
#include "coding.h"
-#include "window.h"
-#include "frame.h"
#include "termhooks.h"
Lisp_Object Vcoding_system_hash_table;
static void
coding_alloc_by_realloc (struct coding_system *coding, ptrdiff_t bytes)
{
- if (STRING_BYTES_BOUND - coding->dst_bytes < bytes)
+ ptrdiff_t newbytes;
+ if (INT_ADD_WRAPV (coding->dst_bytes, bytes, &newbytes)
+ || SIZE_MAX < newbytes)
string_overflow ();
- coding->destination = xrealloc (coding->destination,
- coding->dst_bytes + bytes);
- coding->dst_bytes += bytes;
+ coding->destination = xrealloc (coding->destination, newbytes);
+ coding->dst_bytes = newbytes;
}
static void
else
ENCODE_LOCKING_SHIFT_3;
break;
+
+ default:
+ break;
}
}
if (NILP (coding_system))
coding_system = Qraw_text;
+ else
+ CHECK_CODING_SYSTEM (coding_system);
spec = CODING_SYSTEM_SPEC (coding_system);
eol_type = AREF (spec, 2);
if (VECTORP (eol_type))
{
Lisp_Object parent_spec;
+ CHECK_CODING_SYSTEM (parent);
parent_spec = CODING_SYSTEM_SPEC (parent);
parent_eol_type = AREF (parent_spec, 2);
if (VECTORP (parent_eol_type))
if ((dst_end - dst) / MAX_MULTIBYTE_LENGTH < to_nchars)
{
eassert (growable_destination (coding));
- if (((min (PTRDIFF_MAX, SIZE_MAX) - (buf_end - buf))
- / MAX_MULTIBYTE_LENGTH)
- < to_nchars)
+ ptrdiff_t dst_size;
+ if (INT_MULTIPLY_WRAPV (to_nchars, MAX_MULTIBYTE_LENGTH,
+ &dst_size)
+ || INT_ADD_WRAPV (buf_end - buf, dst_size, &dst_size))
memory_full (SIZE_MAX);
- dst = alloc_destination (coding,
- buf_end - buf
- + MAX_MULTIBYTE_LENGTH * to_nchars,
- dst);
+ dst = alloc_destination (coding, dst_size, dst);
if (EQ (coding->src_object, coding->dst_object))
{
coding_set_source (coding);
case CODING_ANNOTATE_CHARSET_MASK:
produce_charset (coding, charbuf, pos);
break;
+ default:
+ break;
}
charbuf += len;
}
code_conversion_restore (Lisp_Object arg)
{
Lisp_Object current, workbuf;
- struct gcpro gcpro1;
- GCPRO1 (arg);
current = XCAR (arg);
workbuf = XCDR (arg);
if (! NILP (workbuf))
Fkill_buffer (workbuf);
}
set_buffer_internal (XBUFFER (current));
- UNGCPRO;
}
Lisp_Object
if (! NILP (CODING_ATTR_POST_READ (attrs)))
{
- struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
ptrdiff_t prev_Z = Z, prev_Z_BYTE = Z_BYTE;
Lisp_Object val;
TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte);
- GCPRO5 (coding->src_object, coding->dst_object, src_object, dst_object,
- old_deactivate_mark);
val = safe_call1 (CODING_ATTR_POST_READ (attrs),
make_number (coding->produced_char));
- UNGCPRO;
CHECK_NATNUM (val);
coding->produced_char += Z - prev_Z;
coding->produced += Z_BYTE - prev_Z_BYTE;
set_buffer_internal (XBUFFER (coding->src_object));
}
- {
- struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
-
- GCPRO5 (coding->src_object, coding->dst_object, src_object, dst_object,
- old_deactivate_mark);
- safe_call2 (CODING_ATTR_PRE_WRITE (attrs),
- make_number (BEG), make_number (Z));
- UNGCPRO;
- }
+ safe_call2 (CODING_ATTR_PRE_WRITE (attrs),
+ make_number (BEG), make_number (Z));
if (XBUFFER (coding->src_object) != current_buffer)
kill_src_buffer = 1;
coding->src_object = Fcurrent_buffer ();
doc: /* Choose a coding system for an operation based on the target name.
The value names a pair of coding systems: (DECODING-SYSTEM . ENCODING-SYSTEM).
DECODING-SYSTEM is the coding system to use for decoding
-\(in case OPERATION does decoding), and ENCODING-SYSTEM is the coding system
+(in case OPERATION does decoding), and ENCODING-SYSTEM is the coding system
for encoding (in case OPERATION does encoding).
The first argument OPERATION specifies an I/O primitive:
Table of extra Latin codes in the range 128..159 (inclusive).
This is a vector of length 256.
If Nth element is non-nil, the existence of code N in a file
-\(or output of subprocess) doesn't prevent it to be detected as
+(or output of subprocess) doesn't prevent it to be detected as
a coding system of ISO 2022 variant which has a flag
`accept-latin-extra-code' t (e.g. iso-latin-1) on reading a file
or reading output of a subprocess.