diff options
Diffstat (limited to 'src/coding.c')
-rw-r--r-- | src/coding.c | 57 |
1 files changed, 23 insertions, 34 deletions
diff --git a/src/coding.c b/src/coding.c index 9f709bea24c..17cb77e28df 100644 --- a/src/coding.c +++ b/src/coding.c @@ -6814,39 +6814,29 @@ decode_eol (struct coding_system *coding) else if (EQ (eol_type, Qdos)) { ptrdiff_t n = 0; + ptrdiff_t pos = coding->dst_pos; + ptrdiff_t pos_byte = coding->dst_pos_byte; + ptrdiff_t pos_end = pos_byte + coding->produced - 1; - if (NILP (coding->dst_object)) - { - /* Start deleting '\r' from the tail to minimize the memory - movement. */ - for (p = pend - 2; p >= pbeg; p--) - if (*p == '\r') - { - memmove (p, p + 1, pend-- - p - 1); - n++; - } - } - else - { - ptrdiff_t pos = coding->dst_pos; - ptrdiff_t pos_byte = coding->dst_pos_byte; - ptrdiff_t pos_end = pos_byte + coding->produced - 1; + /* This assertion is here instead of code, now deleted, that + handled the NILP case, which no longer happens with the + current codebase. */ + eassert (!NILP (coding->dst_object)); - while (pos_byte < pos_end) + while (pos_byte < pos_end) + { + p = BYTE_POS_ADDR (pos_byte); + if (*p == '\r' && p[1] == '\n') { - p = BYTE_POS_ADDR (pos_byte); - if (*p == '\r' && p[1] == '\n') - { - del_range_2 (pos, pos_byte, pos + 1, pos_byte + 1, 0); - n++; - pos_end--; - } - pos++; - if (coding->dst_multibyte) - pos_byte += BYTES_BY_CHAR_HEAD (*p); - else - pos_byte++; + del_range_2 (pos, pos_byte, pos + 1, pos_byte + 1, 0); + n++; + pos_end--; } + pos++; + if (coding->dst_multibyte) + pos_byte += BYTES_BY_CHAR_HEAD (*p); + else + pos_byte++; } coding->produced -= n; coding->produced_char -= n; @@ -8429,11 +8419,10 @@ from_unicode (Lisp_Object str) Lisp_Object from_unicode_buffer (const wchar_t *wstr) { - return from_unicode ( - make_unibyte_string ( - (char *) wstr, - /* we get one of the two final 0 bytes for free. */ - 1 + sizeof (wchar_t) * wcslen (wstr))); + /* We get one of the two final null bytes for free. */ + ptrdiff_t len = 1 + sizeof (wchar_t) * wcslen (wstr); + AUTO_STRING_WITH_LEN (str, (char *) wstr, len); + return from_unicode (str); } wchar_t * |