[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r116162: When decoding, prefer ptrdiff_t to int for
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] trunk r116162: When decoding, prefer ptrdiff_t to int for buffer positions etc. |
Date: |
Sun, 26 Jan 2014 01:20:27 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 116162
revision-id: address@hidden
parent: address@hidden
author: Paul Eggert <address@hidden>
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Sat 2014-01-25 17:20:24 -0800
message:
When decoding, prefer ptrdiff_t to int for buffer positions etc.
* coding.c (detect_coding_utf_8, emacs_mule_char)
(detect_coding_iso_2022, encode_coding_iso_2022, check_ascii)
(check_utf_8, decode_coding):
* coding.h (struct coding_system.errors):
Use ptrdiff_t, not int, for integer values derived from buffer and
string positions.
modified:
src/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1438
src/coding.c coding.c-20091113204419-o5vbwnq5f7feedwu-1077
src/coding.h coding.h-20091113204419-o5vbwnq5f7feedwu-1078
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2014-01-26 00:32:30 +0000
+++ b/src/ChangeLog 2014-01-26 01:20:24 +0000
@@ -1,5 +1,13 @@
2014-01-26 Paul Eggert <address@hidden>
+ When decoding, prefer ptrdiff_t to int for buffer positions etc.
+ * coding.c (detect_coding_utf_8, emacs_mule_char)
+ (detect_coding_iso_2022, encode_coding_iso_2022, check_ascii)
+ (check_utf_8, decode_coding):
+ * coding.h (struct coding_system.errors):
+ Use ptrdiff_t, not int, for integer values derived from buffer and
+ string positions.
+
Fix crash with insert-file-contents and misdecoded text (Bug#16286).
* fileio.c (Finsert_file_contents): Set CODING_MODE_LAST_BLOCK
before invoking decode_coding_gap, since there's just one block.
=== modified file 'src/coding.c'
--- a/src/coding.c 2014-01-01 07:43:34 +0000
+++ b/src/coding.c 2014-01-26 01:20:24 +0000
@@ -1202,7 +1202,7 @@
bool multibytep = coding->src_multibyte;
ptrdiff_t consumed_chars = 0;
bool bom_found = 0;
- int nchars = coding->head_ascii;
+ ptrdiff_t nchars = coding->head_ascii;
int eol_seen = coding->eol_seen;
detect_info->checked |= CATEGORY_MASK_UTF_8;
@@ -2013,7 +2013,7 @@
int charset_ID;
unsigned code;
int c;
- int consumed_chars = 0;
+ ptrdiff_t consumed_chars = 0;
bool mseq_found = 0;
ONE_MORE_BYTE (c);
@@ -3190,7 +3190,7 @@
if (! single_shifting
&& ! (rejected & CATEGORY_MASK_ISO_8_2))
{
- int len = 1;
+ ptrdiff_t len = 1;
while (src < src_end)
{
src_base = src;
@@ -4456,7 +4456,7 @@
{
/* We have to produce designation sequences if any now. */
unsigned char desig_buf[16];
- int nbytes;
+ ptrdiff_t nbytes;
ptrdiff_t offset;
charset_map_loaded = 0;
@@ -6211,7 +6211,7 @@
EOL_SEEN_LF, EOL_SEEN_CR, and EOL_SEEN_CRLF, but the value is
reliable only when all the source bytes are ASCII. */
-static int
+static ptrdiff_t
check_ascii (struct coding_system *coding)
{
const unsigned char *src, *end;
@@ -6283,12 +6283,12 @@
the value is reliable only when all the source bytes are valid
UTF-8. */
-static int
+static ptrdiff_t
check_utf_8 (struct coding_system *coding)
{
const unsigned char *src, *end;
int eol_seen;
- int nchars = coding->head_ascii;
+ ptrdiff_t nchars = coding->head_ascii;
if (coding->head_ascii < 0)
check_ascii (coding);
@@ -7414,7 +7414,7 @@
coding->carryover_bytes = 0;
if (coding->consumed < coding->src_bytes)
{
- int nbytes = coding->src_bytes - coding->consumed;
+ ptrdiff_t nbytes = coding->src_bytes - coding->consumed;
const unsigned char *src;
coding_set_source (coding);
=== modified file 'src/coding.h'
--- a/src/coding.h 2014-01-01 07:43:34 +0000
+++ b/src/coding.h 2014-01-26 01:20:24 +0000
@@ -477,7 +477,7 @@
ptrdiff_t produced, produced_char, consumed, consumed_char;
/* Number of error source data found in a decoding routine. */
- int errors;
+ ptrdiff_t errors;
/* Store the positions of error source data. */
ptrdiff_t *error_positions;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r116162: When decoding, prefer ptrdiff_t to int for buffer positions etc.,
Paul Eggert <=