Subject: bug#79031: 31.0.50; Recent change breaks `insert-file-contents-literally'

From: Zhengyi Fu <[email-masked]>
Date: Wed, 16 Jul 2025 21:13:08 +0800

> commit c3f96d20eecdf0aa93f294a4f3fb96e16eec6a68 (HEAD)
> Author: Paul Eggert <[email-masked]>
> Date:   Sun Jul 13 12:52:43 2025 -0700

>     Avoid some tiny /proc file reads
    
>     * src/fileio.c (union read_non_regular):
>     New members buf and bufsize replace inserted and trytry.
>     (read_non_regular): Adjust to this new, simpler interface.
>     (Finsert_file_contents): If the gap is smaller than read_buf
>     and we want to read more than the gap, read into read_buf
>     first, to avoid lots of tiny reads from /proc files.

After this commit, the following code evaluates to a string of 16384
bytes!

(with-temp-buffer
  (insert-file-contents-literally "/dev/urandom" nil nil 21)
  (buffer-string))



In GNU Emacs 31.0.50 (build 20, x86_64-pc-linux-gnu, GTK+ Version
 3.24.49) of 2025-07-16 built on calliope
Repository revision: 55f41ca3aa8fe487d10730708a7396137a2c9d18
Repository branch: HEAD
System Description: Fedora Linux 42 (Sway)

Configured using:
 'configure --without-all 'CC=ccache gcc' 'CFLAGS=-O0 -g''

Configured features:
GLIB GMP PDUMPER SECCOMP X11 XIM XINERAMA XRANDR GTK3

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

Major mode: Lisp Interaction

Minor modes in effect:
  xterm-mouse-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-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
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug lisp-mnt message mailcap yank-media puny
dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg
rfc6068 epg-config gnus-util text-property-search time-date subr-x
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader cl-loaddefs cl-lib sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils xt-mouse term/xterm xterm byte-opt gv
bytecomp byte-compile china-util rmc iso-transl tooltip cconv eldoc
paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode
mwheel term/x-win x-win term/common-win x-dnd touch-screen tool-bar dnd
fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote dynamic-setting gtk x-toolkit x
multi-tty move-toolbar make-network-process tty-child-frames emacs)

Memory information:
((conses 16 52730 12168) (symbols 48 6171 0) (strings 32 14442 1585)
 (string-bytes 1 353806) (vectors 16 8063)
 (vector-slots 8 120952 7572) (floats 8 26 1) (intervals 56 220 10)
 (buffers 984 10))