Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
e39b275c
Commit
e39b275c
authored
Sep 06, 2011
by
Paul Eggert
Browse files
Options
Browse Files
Download
Plain Diff
Merge from trunk.
parents
1c262cae
b2db44d9
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
199 additions
and
58 deletions
+199
-58
ChangeLog
ChangeLog
+15
-1
admin/ChangeLog
admin/ChangeLog
+1
-1
autogen/config.in
autogen/config.in
+3
-0
autogen/configure
autogen/configure
+12
-0
etc/ChangeLog
etc/ChangeLog
+5
-0
etc/grep.txt
etc/grep.txt
+1
-0
leim/ChangeLog
leim/ChangeLog
+1
-1
lib-src/ChangeLog
lib-src/ChangeLog
+1
-1
lisp/ChangeLog
lisp/ChangeLog
+27
-0
lisp/gnus/ChangeLog
lisp/gnus/ChangeLog
+12
-0
lisp/gnus/gnus-sum.el
lisp/gnus/gnus-sum.el
+2
-1
lisp/gnus/nnir.el
lisp/gnus/nnir.el
+8
-5
lisp/isearch.el
lisp/isearch.el
+5
-0
lisp/progmodes/grep.el
lisp/progmodes/grep.el
+11
-8
lisp/subr.el
lisp/subr.el
+1
-1
msdos/ChangeLog
msdos/ChangeLog
+1
-1
src/ChangeLog
src/ChangeLog
+24
-1
src/buffer.h
src/buffer.h
+1
-1
src/dbusbind.c
src/dbusbind.c
+6
-6
src/fileio.c
src/fileio.c
+62
-30
No files found.
ChangeLog
View file @
e39b275c
2011-09-0
4
Paul Eggert <eggert@cs.ucla.edu>
2011-09-0
6
Paul Eggert <eggert@cs.ucla.edu>
Merge from gnulib, using build-aux to remove clutter (Bug#9169).
This is to fix the following problems:
. On FreeBSD 6.4, HP-UX 11.31, and Solaris 9, and when Emacs is
configured not to use gtk or any other thread-using library,
signals aren't blocked correctly.
. On IRIX 6.5 it fixes an unwanted clash between Emacs's
and IRIX's signal handling.
. On Cygwin 1.7.5 it works around an incompatibility with
the system pthread_sigmask.
. On MacOS X 10.5 (32-bit), files whose inode numbers
exceed 2**31 cannot be read or manipulated.
. pthread_sigmask: Actually use results of gl_THREADLIB.
. strtoimax, strtoumax: Avoid link error on OSF/1 with DTK cc.
. find 'ar' program that fits with --host argument.
. Allow the user to override the choice of AR, ARFLAGS, RANLIB.
* autogen/README: Update destination list.
* autogen/copy_autogen, autogen/update_autogen, .bzrignore:
The autogenerated files compile, config.guess,
...
...
admin/ChangeLog
View file @
e39b275c
2011-09-0
3
Paul Eggert <eggert@cs.ucla.edu>
2011-09-0
6
Paul Eggert <eggert@cs.ucla.edu>
Merge from gnulib (Bug#9169).
* notes/copyright: The files compile, config.guess, config.sub,
...
...
autogen/config.in
View file @
e39b275c
...
...
@@ -672,6 +672,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if the system has the type `sigset_t'. */
#undef HAVE_SIGSET_T
/* Define to 1 if you have the `snprintf' function. */
#undef HAVE_SNPRINTF
/* Define to 1 if you have sound support. */
#undef HAVE_SOUND
...
...
autogen/configure
View file @
e39b275c
...
...
@@ -15312,6 +15312,18 @@ $as_echo "#define HAVE_WORKING_FORK 1" >>confdefs.h
fi
for ac_func in snprintf
do :
ac_fn_c_check_func "$LINENO" "snprintf" "ac_cv_func_snprintf"
if test "x$ac_cv_func_snprintf" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SNPRINTF 1
_ACEOF
fi
done
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_langinfo and CODESET" >&5
$as_echo_n "checking for nl_langinfo and CODESET... " >&6; }
if test "${emacs_cv_langinfo_codeset+set}" = set; then :
...
...
etc/ChangeLog
View file @
e39b275c
2011-09-05 Juri Linkov <juri@jurta.org>
* grep.txt: Add `eval' to the Local Variables section that
emulates `grep-filter'.
2011-08-30 Paul Eggert <eggert@cs.ucla.edu>
* MACHINES: Remove obsolete info and update a bit (Bug#9404).
...
...
etc/grep.txt
View file @
e39b275c
...
...
@@ -103,5 +103,6 @@ COPYING PERMISSIONS:
;;; Local Variables:
;;; eval: (let ((inhibit-read-only t) (compilation-filter-start (point-min))) (save-excursion (goto-char (point-max)) (grep-filter) (set-buffer-modified-p nil)))
;;; buffer-read-only: t
;;; End:
leim/ChangeLog
View file @
e39b275c
2011
-
09
-
0
3
Paul
Eggert
<
eggert
@
cs
.
ucla
.
edu
>
2011
-
09
-
0
6
Paul
Eggert
<
eggert
@
cs
.
ucla
.
edu
>
*
Makefile
.
in
(
install
):
install
-
sh
is
now
in
build
-
aux
(
Bug
#
9169
).
...
...
lib-src/ChangeLog
View file @
e39b275c
2011-09-0
4
Paul Eggert <eggert@cs.ucla.edu>
2011-09-0
6
Paul Eggert <eggert@cs.ucla.edu>
* Makefile.in ($(DESTDIR)${archlibdir}): install-sh moved
to build-aux (Bug#9169).
...
...
lisp/ChangeLog
View file @
e39b275c
2011-09-06 Alan Mackenzie <acm@muc.de>
* isearch.el (isearch-other-meta-char): Wherever a key list is
unread, "unread" the prefix arg, too. This fixes bug #8901.
2011-09-05 Oleksandr Gavenko <gavenkoa@gmail.com> (tiny change)
* progmodes/grep.el (rgrep): Add "-type d" (bug#9414).
2011-09-05 Juri Linkov <juri@jurta.org>
* progmodes/grep.el (grep-process-setup): Fix comments (bug#8084).
2011-09-05 Juri Linkov <juri@jurta.org>
* progmodes/grep.el (grep-filter): Avoid incomplete processing by
keeping point where processing of grep matches begins, and
continue to delete remaining escape sequences from the same point.
(grep-filter): Make leading zero optional in "0?1;31m" because
git-grep emits "\033[1;31m" escape sequences unlike expected
"\033[01;31m" as GNU Grep does (bug#9408).
(grep-process-setup): Replace obsolete "ml=" with newer "sl=".
2011-09-05 Juri Linkov <juri@jurta.org>
* subr.el (y-or-n-p): Capitalize "yes".
2011-09-04 Michael Albinus <michael.albinus@gmx.de>
* net/tramp.el (top): Require 'shell. Use `tramp-unload-hook' but
...
...
lisp/gnus/ChangeLog
View file @
e39b275c
2011-09-05 Andrew Cohen <cohen@andy.bu.edu>
* gnus-sum.el (gnus-summary-exit): Ensure we kill the proper
original-article-buffer.
2011-09-05 Kan-Ru Chen <kanru@kanru.info>
* nnir.el (nnir-compose-result): Fix matching of server type.
(nnir-run-swish++): Ditto.
(nnir-run-namazu): Ditto.
(nnir-run-notmuch): Ditto.
2011-09-04 Lars Magne Ingebrigtsen <larsi@gnus.org>
* gnus.el (gnus-home-directory): Add warning about setting in .gnus.el
...
...
lisp/gnus/gnus-sum.el
View file @
e39b275c
...
...
@@ -7214,6 +7214,7 @@ If FORCE (the prefix), also save the .newsrc file(s)."
(quit-config (gnus-group-quit-config gnus-newsgroup-name))
(gnus-group-is-exiting-p t)
(article-buffer gnus-article-buffer)
(original-article-buffer gnus-original-article-buffer)
(mode major-mode)
(group-point nil)
(buf (current-buffer))
...
...
@@ -7290,7 +7291,7 @@ If FORCE (the prefix), also save the .newsrc file(s)."
(unless (eq major-mode 'gnus-sticky-article-mode)
(gnus-kill-buffer article-buffer)
(setq gnus-article-current nil))))
(gnus-kill-buffer
gnus-
original-article-buffer))
(gnus-kill-buffer original-article-buffer))
;; Clear the current group name.
(unless quit-config
...
...
lisp/gnus/nnir.el
View file @
e39b275c
...
...
@@ -806,7 +806,7 @@ ready to be added to the list of search results."
;; remove trailing slash and, for nnmaildir, cur/new/tmp
(setq dirnam
(substring dirnam 0
(if (string
=
(gnus-group-server server)
"
nnmaildir
"
)
(if (string
-match "
^nnmaildir:
"
(gnus-group-server server))
-5 -1)))
;; Set group to dirnam without any leading dots or slashes,
...
...
@@ -816,7 +816,7 @@ ready to be added to the list of search results."
"
[/\\]
" "
.
" t)))
(vector (gnus-group-full-name group server)
(if (string
=
(gnus-group-server server)
"
nnmaildir
"
)
(if (string
-match "
^nnmaildir:
"
(gnus-group-server server))
(nnmaildir-base-name-to-article-number
(substring article 0 (string-match "
:
" article))
group nil)
...
...
@@ -1073,7 +1073,8 @@ Windows NT 4.0."
;; is sufficient. Note that we can't only use the value of
;; nnml-use-compressed-files because old articles might have been
;; saved with a different value.
(article-pattern (if (string= (gnus-group-server server) "
nnmaildir
")
(article-pattern (if (string-match "
^nnmaildir:
"
(gnus-group-server server))
"
:[0-9]+
"
"
^[0-9]+\\
(
\\.[a-z0-9]+\\
)
?$
"))
score artno dirnam filenam)
...
...
@@ -1315,7 +1316,8 @@ Tested with Namazu 2.0.6 on a GNU/Linux system."
;; (when group
;; (error "The Namazu backend cannot search specific groups"))
(
save-excursion
(
let
((
article-pattern
(
if
(
string=
(
gnus-group-server
server
)
"nnmaildir"
)
(
let
((
article-pattern
(
if
(
string-match
"^nnmaildir:"
(
gnus-group-server
server
))
":[0-9]+"
"^[0-9]+$"
))
artlist
...
...
@@ -1388,7 +1390,8 @@ actually)."
(
groupspec
(
cdr
(
assq
'group
query
)))
(
prefix
(
nnir-read-server-parm
'nnir-notmuch-remove-prefix
server
))
artlist
(
article-pattern
(
if
(
string=
(
gnus-group-server
server
)
"nnmaildir"
)
(
article-pattern
(
if
(
string-match
"^nnmaildir:"
(
gnus-group-server
server
))
":[0-9]+"
"^[0-9]+$"
))
artno
dirnam
filenam
)
...
...
lisp/isearch.el
View file @
e39b275c
...
...
@@ -1920,6 +1920,7 @@ Isearch mode."
(if (lookup-key global-map key)
(progn
(isearch-done)
(setq prefix-arg arg)
(apply 'isearch-unread keylist))
(setq keylist
(listify-key-sequence (lookup-key local-function-key-map key)))
...
...
@@ -1935,6 +1936,7 @@ Isearch mode."
(setq keylist (cdr keylist)))
;; As the remaining keys in KEYLIST can't be handled
;; here, we must reread them.
(setq prefix-arg arg)
(apply 'isearch-unread keylist)
(setq keylist nil)))))
(
...
...
@@ -1957,8 +1959,10 @@ Isearch mode."
isearch-other-control-char)))))
(setcar keylist (- main-event (- ?\C-\S-a ?\C-a)))
(cancel-kbd-macro-events)
(setq prefix-arg arg)
(apply 'isearch-unread keylist))
((eq search-exit-option 'edit)
(setq prefix-arg arg)
(apply 'isearch-unread keylist)
(isearch-edit-string))
;; Handle a scrolling function.
...
...
@@ -1987,6 +1991,7 @@ Isearch mode."
(isearch-edit-string))
(search-exit-option
(let (window)
(setq prefix-arg arg)
(isearch-unread-key-sequence keylist)
(setq main-event (car unread-command-events))
...
...
lisp/progmodes/grep.el
View file @
e39b275c
...
...
@@ -446,9 +446,10 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'."
(
when
(
eq
grep-highlight-matches
'auto-detect
)
(
grep-compute-defaults
))
(
unless
(
or
(
eq
grep-highlight-matches
'auto-detect
)
;; Uses font-lock to parse color escapes. (Bug#8084)
(
null
font-lock-mode
)
(
null
grep-highlight-matches
))
(
null
grep-highlight-matches
)
;; Don't output color escapes if they can't be
;; highlighted with `font-lock-face' by `grep-filter'.
(
null
font-lock-mode
))
;; `setenv' modifies `process-environment' let-bound in `compilation-start'
;; Any TERM except "dumb" allows GNU grep to use `--color=auto'
(
setenv
"TERM"
"emacs-grep"
)
...
...
@@ -459,7 +460,7 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'."
;; GREP_COLOR is used in GNU grep 2.5.1, but deprecated in later versions
(
setenv
"GREP_COLOR"
"01;31"
)
;; GREP_COLORS is used in GNU grep 2.5.2 and later versions
(
setenv
"GREP_COLORS"
"mt=01;31:fn=:ln=:bn=:se=:
m
l=:cx=:ne"
))
(
setenv
"GREP_COLORS"
"mt=01;31:fn=:ln=:bn=:se=:
s
l=:cx=:ne"
))
(
set
(
make-local-variable
'compilation-exit-message-function
)
(
lambda
(
status
code
msg
)
(
if
(
eq
status
'exit
)
...
...
@@ -480,20 +481,21 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'."
This function is called from `compilation-filter-hook'."
(
save-excursion
(
forward-line
0
)
(
let
((
end
(
point
)))
(
let
((
end
(
point
))
beg
)
(
goto-char
compilation-filter-start
)
(
forward-line
0
)
(
setq
beg
(
point
))
;; Only operate on whole lines so we don't get caught with part of an
;; escape sequence in one chunk and the rest in another.
(
when
(
<
(
point
)
end
)
(
setq
end
(
copy-marker
end
))
;; Highlight grep matches and delete marking sequences.
(
while
(
re-search-forward
"\033\\[01;31m\\(.*?\\)\033\\[[0-9]*m"
end
1
)
(
while
(
re-search-forward
"\033\\[0
?
1;31m\\(.*?\\)\033\\[[0-9]*m"
end
1
)
(
replace-match
(
propertize
(
match-string
1
)
'face
nil
'font-lock-face
grep-match-face
)
t
t
))
;; Delete all remaining escape sequences
(
goto-char
compilation-filter-start
)
(
goto-char
beg
)
(
while
(
re-search-forward
"\033\\[[0-9;]*[mK]"
end
1
)
(
replace-match
""
t
t
))))))
...
...
@@ -987,7 +989,8 @@ This command shares argument histories with \\[lgrep] and \\[grep-find]."
dir
(concat
(and grep-find-ignored-directories
(concat (shell-quote-argument "
(
")
(concat "
-type
d
"
(shell-quote-argument "
(
")
;; we should use shell-quote-argument here
"
-path
"
(mapconcat
...
...
lisp/subr.el
View file @
e39b275c
...
...
@@ -2254,7 +2254,7 @@ is nil and `use-dialog-box' is non-nil."
(
listp
last-nonmenu-event
)
use-dialog-box
)
(
setq
answer
(
x-popup-dialog
t
`
(
,
prompt
(
"
y
es"
.
act
)
(
"No"
.
skip
))))
(
x-popup-dialog
t
`
(
,
prompt
(
"
Y
es"
.
act
)
(
"No"
.
skip
))))
(
setq
prompt
(
concat
prompt
(
if
(
eq
?\s
(
aref
prompt
(
1-
(
length
prompt
))))
""
" "
)
...
...
msdos/ChangeLog
View file @
e39b275c
2011-0
7-25
Paul Eggert <eggert@cs.ucla.edu>
2011-0
9-06
Paul Eggert <eggert@cs.ucla.edu>
* sedlibmk.inp (CONFIG_CLEAN_VPATH_FILES): Adjust to snippet moves
from top level to build-aux/snippet (Bug#9169).
...
...
src/ChangeLog
View file @
e39b275c
2011-09-0
4
Paul Eggert <eggert@cs.ucla.edu>
2011-09-0
6
Paul Eggert <eggert@cs.ucla.edu>
* Makefile.in (gl-stamp): move-if-change now in build-aux (Bug#9169).
2011-09-06 Paul Eggert <eggert@cs.ucla.edu>
* fileio.c: Fix bugs with large file offsets (Bug#9428).
The previous code assumed that file offsets (off_t values) fit in
EMACS_INT variables, which is not true on typical 32-bit hosts.
The code messed up by falsely reporting buffer overflow in cases
such as (insert-file-contents "big" nil 1 2) into an empty buffer
when "big" contains more than 2**29 bytes, even though this
inserts just one byte and does not overflow the buffer.
(Finsert_file_contents): Store file offsets as off_t
values, not as EMACS_INT values. Check for overflow when
converting between EMACS_INT and off_t. When checking for
buffer overflow or for overlap, take the offsets into account.
Don't use EMACS_INT for small values where int suffices.
When checking for overlap, fix a typo: ZV was used where
ZV_BYTE was intended.
(Fwrite_region): Don't assume off_t fits into 'long'.
* buffer.h (struct buffer.modtime_size): Now off_t, not EMACS_INT.
2011-09-05 Michael Albinus <michael.albinus@gmx.de>
* dbusbind.c (xd_signature_cat): Rename from signature_cat.
2011-09-04 Paul Eggert <eggert@cs.ucla.edu>
sprintf-related integer and memory overflow issues (Bug#9412).
...
...
src/buffer.h
View file @
e39b275c
...
...
@@ -559,7 +559,7 @@ struct buffer
is still the same (since it's rounded up to seconds) but we're actually
not up-to-date. -1 means the size is unknown. Only meaningful if
modtime is actually set. */
EMACS_INT
modtime_size
;
off_t
modtime_size
;
/* The value of text->modiff at the last auto-save. */
int
auto_save_modified
;
/* The value of text->modiff at the last display error.
...
...
src/dbusbind.c
View file @
e39b275c
...
...
@@ -262,7 +262,7 @@ xd_symbol_to_dbus_type (Lisp_Object object)
/* Append to SIGNATURE a copy of X, making sure SIGNATURE does
not become too long. */
static
void
signature_cat
(
char
*
signature
,
char
const
*
x
)
xd_
signature_cat
(
char
*
signature
,
char
const
*
x
)
{
ptrdiff_t
siglen
=
strlen
(
signature
);
ptrdiff_t
xlen
=
strlen
(
x
);
...
...
@@ -401,10 +401,10 @@ xd_signature (char *signature, unsigned int dtype, unsigned int parent_type, Lis
{
subtype
=
XD_OBJECT_TO_DBUS_TYPE
(
CAR_SAFE
(
elt
));
xd_signature
(
x
,
subtype
,
dtype
,
CAR_SAFE
(
XD_NEXT_VALUE
(
elt
)));
signature_cat
(
signature
,
x
);
xd_
signature_cat
(
signature
,
x
);
elt
=
CDR_SAFE
(
XD_NEXT_VALUE
(
elt
));
}
signature_cat
(
signature
,
DBUS_STRUCT_END_CHAR_AS_STRING
);
xd_
signature_cat
(
signature
,
DBUS_STRUCT_END_CHAR_AS_STRING
);
break
;
case
DBUS_TYPE_DICT_ENTRY
:
...
...
@@ -425,7 +425,7 @@ xd_signature (char *signature, unsigned int dtype, unsigned int parent_type, Lis
elt
=
XD_NEXT_VALUE
(
elt
);
subtype
=
XD_OBJECT_TO_DBUS_TYPE
(
CAR_SAFE
(
elt
));
xd_signature
(
x
,
subtype
,
dtype
,
CAR_SAFE
(
XD_NEXT_VALUE
(
elt
)));
signature_cat
(
signature
,
x
);
xd_
signature_cat
(
signature
,
x
);
if
(
!
XD_BASIC_DBUS_TYPE
(
subtype
))
wrong_type_argument
(
intern
(
"D-Bus"
),
CAR_SAFE
(
XD_NEXT_VALUE
(
elt
)));
...
...
@@ -434,14 +434,14 @@ xd_signature (char *signature, unsigned int dtype, unsigned int parent_type, Lis
elt
=
CDR_SAFE
(
XD_NEXT_VALUE
(
elt
));
subtype
=
XD_OBJECT_TO_DBUS_TYPE
(
CAR_SAFE
(
elt
));
xd_signature
(
x
,
subtype
,
dtype
,
CAR_SAFE
(
XD_NEXT_VALUE
(
elt
)));
signature_cat
(
signature
,
x
);
xd_
signature_cat
(
signature
,
x
);
if
(
!
NILP
(
CDR_SAFE
(
XD_NEXT_VALUE
(
elt
))))
wrong_type_argument
(
intern
(
"D-Bus"
),
CAR_SAFE
(
CDR_SAFE
(
XD_NEXT_VALUE
(
elt
))));
/* Closing signature. */
signature_cat
(
signature
,
DBUS_DICT_ENTRY_END_CHAR_AS_STRING
);
xd_
signature_cat
(
signature
,
DBUS_DICT_ENTRY_END_CHAR_AS_STRING
);
break
;
default:
...
...
src/fileio.c
View file @
e39b275c
...
...
@@ -3179,6 +3179,7 @@ variable `last-coding-system-used' to the coding system actually used. */)
EMACS_INT
inserted
=
0
;
int
nochange
=
0
;
register
EMACS_INT
how_much
;
off_t
beg_offset
,
end_offset
;
register
EMACS_INT
unprocessed
;
int
count
=
SPECPDL_INDEX
();
struct
gcpro
gcpro1
,
gcpro2
,
gcpro3
,
gcpro4
,
gcpro5
;
...
...
@@ -3284,15 +3285,6 @@ variable `last-coding-system-used' to the coding system actually used. */)
record_unwind_protect
(
close_file_unwind
,
make_number
(
fd
));
/* Check whether the size is too large or negative, which can happen on a
platform that allows file sizes greater than the maximum off_t value. */
if
(
!
not_regular
&&
!
(
0
<=
st
.
st_size
&&
st
.
st_size
<=
BUF_BYTES_MAX
))
buffer_overflow
();
/* Prevent redisplay optimizations. */
current_buffer
->
clip_changed
=
1
;
if
(
!
NILP
(
visit
))
{
if
(
!
NILP
(
beg
)
||
!
NILP
(
end
))
...
...
@@ -3302,26 +3294,64 @@ variable `last-coding-system-used' to the coding system actually used. */)
}
if
(
!
NILP
(
beg
))
CHECK_NUMBER
(
beg
);
{
if
(
!
(
RANGED_INTEGERP
(
0
,
beg
,
TYPE_MAXIMUM
(
off_t
))))
wrong_type_argument
(
intern
(
"file-offset"
),
beg
);
beg_offset
=
XFASTINT
(
beg
);
}
else
XSETFASTINT
(
beg
,
0
)
;
beg_offset
=
0
;
if
(
!
NILP
(
end
))
CHECK_NUMBER
(
end
);
{
if
(
!
(
RANGED_INTEGERP
(
0
,
end
,
TYPE_MAXIMUM
(
off_t
))))
wrong_type_argument
(
intern
(
"file-offset"
),
end
);
end_offset
=
XFASTINT
(
end
);
}
else
{
if
(
!
not_regular
)
if
(
not_regular
)
end_offset
=
TYPE_MAXIMUM
(
off_t
);
else
{
XSETINT
(
end
,
st
.
st_size
);
end_offset
=
st
.
st_size
;
/* A negative size can happen on a platform that allows file
sizes greater than the maximum off_t value. */
if
(
end_offset
<
0
)
buffer_overflow
();
/* The file size returned from stat may be zero, but data
may be readable nonetheless, for example when this is a
file in the /proc filesystem. */
if
(
st
.
st_size
==
0
)
XSETINT
(
end
,
READ_BUF_SIZE
)
;
if
(
end_offset
==
0
)
end_offset
=
READ_BUF_SIZE
;
}
}
/* Check now whether the buffer will become too large,
in the likely case where the file's length is not changing.
This saves a lot of needless work before a buffer overflow. */
if
(
!
not_regular
)
{
/* The likely offset where we will stop reading. We could read
more (or less), if the file grows (or shrinks) as we read it. */
off_t
likely_end
=
min
(
end_offset
,
st
.
st_size
);
if
(
beg_offset
<
likely_end
)
{
ptrdiff_t
buf_bytes
=
Z_BYTE
-
(
!
NILP
(
replace
)
?
ZV_BYTE
-
BEGV_BYTE
:
0
);
ptrdiff_t
buf_growth_max
=
BUF_BYTES_MAX
-
buf_bytes
;
off_t
likely_growth
=
likely_end
-
beg_offset
;
if
(
buf_growth_max
<
likely_growth
)
buffer_overflow
();
}
}
/* Prevent redisplay optimizations. */
current_buffer
->
clip_changed
=
1
;
if
(
EQ
(
Vcoding_system_for_read
,
Qauto_save_coding
))
{
coding_system
=
coding_inherit_eol_type
(
Qutf_8_emacs
,
Qunix
);
...
...
@@ -3465,9 +3495,9 @@ variable `last-coding-system-used' to the coding system actually used. */)
give up on handling REPLACE in the optimized way. */
int
giveup_match_end
=
0
;
if
(
XINT
(
beg
)
!=
0
)
if
(
beg_offset
!=
0
)
{
if
(
emacs_
lseek
(
fd
,
XINT
(
beg
)
,
SEEK_SET
)
<
0
)
if
(
lseek
(
fd
,
beg_offset
,
SEEK_SET
)
<
0
)
report_file_error
(
"Setting file position"
,
Fcons
(
orig_filename
,
Qnil
));
}
...
...
@@ -3515,7 +3545,7 @@ variable `last-coding-system-used' to the coding system actually used. */)
immediate_quit
=
0
;
/* If the file matches the buffer completely,
there's no need to replace anything. */
if
(
same_at_start
-
BEGV_BYTE
==
XINT
(
end
)
)
if
(
same_at_start
-
BEGV_BYTE
==
end_offset
)
{
emacs_close
(
fd
);
specpdl_ptr
--
;
...
...
@@ -3530,16 +3560,17 @@ variable `last-coding-system-used' to the coding system actually used. */)
already found that decoding is necessary, don't waste time. */
while
(
!
giveup_match_end
)
{
EMACS_INT
total_read
,
nread
,
bufpos
,
curpos
,
trial
;
int
total_read
,
nread
,
bufpos
,
trial
;
off_t
curpos
;
/* At what file position are we now scanning? */
curpos
=
XINT
(
end
)
-
(
ZV_BYTE
-
same_at_end
);
curpos
=
end_offset
-
(
ZV_BYTE
-
same_at_end
);
/* If the entire file matches the buffer tail, stop the scan. */
if
(
curpos
==
0
)
break
;
/* How much can we scan in the next step? */
trial
=
min
(
curpos
,
sizeof
buffer
);
if
(
emacs_
lseek
(
fd
,
curpos
-
trial
,
SEEK_SET
)
<
0
)
if
(
lseek
(
fd
,
curpos
-
trial
,
SEEK_SET
)
<
0
)
report_file_error
(
"Setting file position"
,
Fcons
(
orig_filename
,
Qnil
));
...
...
@@ -3606,13 +3637,14 @@ variable `last-coding-system-used' to the coding system actually used. */)
/* Don't try to reuse the same piece of text twice. */
overlap
=
(
same_at_start
-
BEGV_BYTE
-
(
same_at_end
+
st
.
st_size
-
ZV
));
-
(
same_at_end
+
(
!
NILP
(
end
)
?
end_offset
:
st
.
st_size
)
-
ZV_BYTE
));
if
(
overlap
>
0
)
same_at_end
+=
overlap
;
/* Arrange to read only the nonmatching middle part of the file. */
XSETFASTINT
(
beg
,
XINT
(
beg
)
+
(
same_at_start
-
BEGV_BYTE
))
;
XSETFASTINT
(
end
,
XINT
(
end
)
-
(
ZV_BYTE
-
same_at_end
))
;
beg_offset
+=
same_at_start
-
BEGV_BYTE
;
end_offset
-=
ZV_BYTE
-
same_at_end
;
del_range_byte
(
same_at_start
,
same_at_end
,
0
);
/* Insert from the file at the proper position. */
...
...
@@ -3657,7 +3689,7 @@ variable `last-coding-system-used' to the coding system actually used. */)
/* First read the whole file, performing code conversion into
CONVERSION_BUFFER. */
if
(
emacs_
lseek
(
fd
,
XINT
(
beg
)
,
SEEK_SET
)
<
0
)
if
(
lseek
(
fd
,
beg_offset
,
SEEK_SET
)
<
0
)
report_file_error
(
"Setting file position"
,
Fcons
(
orig_filename
,
Qnil
));
...
...
@@ -3824,7 +3856,7 @@ variable `last-coding-system-used' to the coding system actually used. */)
}
if
(
!
not_regular
)
total
=
XINT
(
end
)
-
XINT
(
beg
)
;
total
=
end_offset
-
beg_offset
;
else
/* For a special file, all we can do is guess. */
total
=
READ_BUF_SIZE
;
...
...
@@ -3845,9 +3877,9 @@ variable `last-coding-system-used' to the coding system actually used. */)
if
(
GAP_SIZE
<
total
)
make_gap
(
total
-
GAP_SIZE
);
if
(
XINT
(
beg
)
!=
0
||
!
NILP
(
replace
))
if
(
beg_offset
!=
0
||
!
NILP
(
replace
))
{
if
(
emacs_
lseek
(
fd
,
XINT
(
beg
)
,
SEEK_SET
)
<
0
)
if
(
lseek
(
fd
,
beg_offset
,
SEEK_SET
)
<
0
)
report_file_error
(
"Setting file position"
,
Fcons
(
orig_filename
,
Qnil
));
}
...
...
@@ -4576,7 +4608,7 @@ This calls `write-region-annotate-functions' at the start, and
if
(
!
NILP
(
append
)
&&
!
NILP
(
Ffile_regular_p
(
filename
)))
{
long
ret
;
off_t
ret
;
if
(
NUMBERP
(
append
))
ret
=
emacs_lseek
(
desc
,
XINT
(
append
),
SEEK_CUR
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment