unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#16286: 24.3.50; insert-file-contents may bring invisible garbage
@ 2013-12-29 14:05 Andrey Kotlarski
  2014-01-02 16:30 ` Eli Zaretskii
  2014-01-26  0:36 ` Paul Eggert
  0 siblings, 2 replies; 7+ messages in thread
From: Andrey Kotlarski @ 2013-12-29 14:05 UTC (permalink / raw)
  To: 16286

In trunk inserting few bytes from file may sometimes result in nothing
visible in the buffer while invisible artifacts are present and may
affect subsequent operations.  Moreover, there doesn't seem to be way to
recover from this.  Here's example session with emacs -Q:

(let ((file "test.txt"))
  (unless (file-exists-p file)
    (find-file file)
    (insert "абв")                      ;Cyrillic letters
    (save-buffer)
    (kill-buffer))

  (let ((buf (generate-new-buffer "test")))
    (switch-to-buffer buf)
    (insert-file-contents file nil 0 2) ;inserts а
    (goto-char (point-max))
    (insert-file-contents file nil 2 3) ;returns 0 bytes inserted, nothing visible in the buffer
                                        ;but actually there is
    (erase-buffer)                      ;and still is
    (insert-file-contents file nil 2 4) ;should insert б, instead let: Wrong type argument: inserted-chars, 1
    (message "%S" (buffer-string)) ;"бЀ" while buffer is visibly empty
    ))

Trying to insert multibyte characters now brings content length issues,
garbage inserted and at some point Emacs crashes.

In release 24.3 and earlier insert-file-contents seems to always insert
something, be it wrongly decoded or raw eight-bit characters.  But it is
visible and easy to deal with.  The above example works fine there.
This is useful for the vlf package (https://github.com/m00natic/vlfi) as
a way to detect insufficient amount of bytes requested and allows
further adjustment.


In GNU Emacs 24.3.50.1 (x86_64-pc-linux-gnu)
 of 2013-12-29 on andrexhe
Bzr revision: 115803 eggert@cs.ucla.edu-20131229075253-hmeofd1oihd5n3rk
Windowing system distributor `The X.Org Foundation', version 11.0.11405000
Configured using:
 `configure --build=x86_64-pc-linux-gnu --enable-link-time-optimization
 --with-x-toolkit=no --with-wide-int --without-toolkit-scroll-bars
 --without-xaw3d --without-gpm --without-gconf --without-gsettings
 build_alias=x86_64-pc-linux-gnu 'CFLAGS=-march=native -mtune=native -O2
 -pipe''

Important settings:
  value of $LC_COLLATE: C
  value of $LANG: bg_BG.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
M-x r e p o - e m - b u <tab> <return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
let: Wrong type argument: inserted-chars, 1

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util help-fns mail-prsvr mail-utils time-date tooltip electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list newcomment lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
dbusbind gfilenotify dynamic-setting font-render-setting x multi-tty
emacs)





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-01-29 13:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-29 14:05 bug#16286: 24.3.50; insert-file-contents may bring invisible garbage Andrey Kotlarski
2014-01-02 16:30 ` Eli Zaretskii
2014-01-04 22:42   ` Andrey Kotlarski
2014-01-26  0:36 ` Paul Eggert
2014-01-27 15:01   ` K. Handa
2014-01-27 17:01     ` Paul Eggert
2014-01-29 13:40       ` K. Handa

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).