aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Tromey2013-07-12 18:44:13 -0600
committerTom Tromey2013-07-12 18:44:13 -0600
commitb34a529f177a6ea32da5cb1254f91bf9d71838db (patch)
tree477131abc15d3107b30b635223d87a22550b480b
parente6f63071a3f7721f55220514b6d9a8ee8c1232d8 (diff)
parent5e301d7651c0691bb2bc7f3fbe711fdbe26ac471 (diff)
downloademacs-b34a529f177a6ea32da5cb1254f91bf9d71838db.tar.gz
emacs-b34a529f177a6ea32da5cb1254f91bf9d71838db.zip
Merge from trunk
-rw-r--r--ChangeLog61
-rw-r--r--Makefile.in2
-rw-r--r--admin/ChangeLog18
-rw-r--r--admin/admin.el2
-rwxr-xr-xadmin/merge-gnulib10
-rw-r--r--admin/notes/changelogs7
-rw-r--r--autogen/Makefile.in93
-rw-r--r--autogen/aclocal.m43
-rw-r--r--autogen/config.in18
-rwxr-xr-xautogen/configure300
-rw-r--r--configure.ac97
-rw-r--r--doc/lispref/ChangeLog5
-rw-r--r--doc/lispref/text.texi12
-rw-r--r--doc/misc/ChangeLog21
-rw-r--r--doc/misc/gnus-faq.texi7
-rw-r--r--doc/misc/gnus.texi26
-rw-r--r--etc/ChangeLog9
-rw-r--r--etc/NEWS58
-rw-r--r--lib-src/ChangeLog18
-rw-r--r--lib-src/ebrowse.c12
-rw-r--r--lib-src/emacsclient.c11
-rw-r--r--lib-src/make-docfile.c2
-rw-r--r--lib/binary-io.c3
-rw-r--r--lib/binary-io.h72
-rw-r--r--lib/fcntl.c311
-rw-r--r--lib/getdtablesize.c86
-rw-r--r--lib/gnulib.mk43
-rw-r--r--lib/ignore-value.h48
-rw-r--r--lib/pipe2.c168
-rw-r--r--lib/stdalign.in.h39
-rw-r--r--lib/verify.h112
-rw-r--r--lisp/ChangeLog238
-rw-r--r--lisp/cedet/ChangeLog2
-rw-r--r--lisp/desktop.el39
-rw-r--r--lisp/doc-view.el14
-rw-r--r--lisp/edmacro.el73
-rw-r--r--lisp/emacs-lisp/.gitignore2
-rw-r--r--lisp/emacs-lisp/cl-macs.el12
-rw-r--r--lisp/emacs-lisp/edebug.el26
-rw-r--r--lisp/emacs-lisp/ert.el173
-rw-r--r--lisp/emacs-lisp/map-ynp.el5
-rw-r--r--lisp/emacs-lisp/pcase.el17
-rw-r--r--lisp/emulation/viper-cmd.el101
-rw-r--r--lisp/emulation/viper-keym.el2
-rw-r--r--lisp/emulation/viper.el66
-rw-r--r--lisp/faces.el7
-rw-r--r--lisp/files.el6
-rw-r--r--lisp/filesets.el6
-rw-r--r--lisp/gnus/ChangeLog44
-rw-r--r--lisp/gnus/gnus-art.el3
-rw-r--r--lisp/gnus/gnus-msg.el1
-rw-r--r--lisp/gnus/gnus-registry.el23
-rw-r--r--lisp/gnus/gnus-start.el5
-rw-r--r--lisp/gnus/gnus.el4
-rw-r--r--lisp/gnus/message.el2
-rw-r--r--lisp/gnus/mm-view.el22
-rw-r--r--lisp/gnus/nnir.el6
-rw-r--r--lisp/gnus/nnml.el5
-rw-r--r--lisp/ido.el50
-rw-r--r--lisp/net/shr.el1
-rw-r--r--lisp/net/tramp-cache.el6
-rw-r--r--lisp/net/tramp-gvfs.el3
-rw-r--r--lisp/net/tramp-sh.el42
-rw-r--r--lisp/net/tramp.el138
-rw-r--r--lisp/progmodes/cfengine.el4
-rw-r--r--lisp/progmodes/ebrowse.el23
-rw-r--r--lisp/progmodes/gdb-mi.el23
-rw-r--r--lisp/progmodes/ruby-mode.el20
-rw-r--r--lisp/shadowfile.el23
-rw-r--r--lisp/simple.el128
-rw-r--r--lisp/subr.el9
-rw-r--r--lisp/thumbs.el18
-rw-r--r--lisp/vc/ediff.el73
-rw-r--r--lisp/wid-edit.el11
-rw-r--r--m4/fcntl.m495
-rw-r--r--m4/getdtablesize.m417
-rw-r--r--m4/gnulib-comp.m455
-rw-r--r--m4/pipe2.m418
-rw-r--r--m4/stdalign.m43
-rw-r--r--nt/ChangeLog14
-rw-r--r--nt/gnulib.mk3
-rw-r--r--nt/inc/ms-w32.h1
-rw-r--r--nt/inc/sys/socket.h4
-rw-r--r--nt/mingw-cfg.site5
-rw-r--r--src/ChangeLog308
-rw-r--r--src/alloc.c2
-rw-r--r--src/atimer.c2
-rw-r--r--src/buffer.c5
-rw-r--r--src/bytecode.c7
-rw-r--r--src/callproc.c115
-rw-r--r--src/dbusbind.c8
-rw-r--r--src/dired.c2
-rw-r--r--src/dispextern.h7
-rw-r--r--src/dispnew.c6
-rw-r--r--src/emacs.c89
-rw-r--r--src/eval.c71
-rw-r--r--src/fileio.c139
-rw-r--r--src/filelock.c20
-rw-r--r--src/fns.c26
-rw-r--r--src/frame.c2
-rw-r--r--src/gnutls.h2
-rw-r--r--src/image.c10
-rw-r--r--src/inotify.c33
-rw-r--r--src/keyboard.c2
-rw-r--r--src/lisp.h25
-rw-r--r--src/lread.c96
-rw-r--r--src/makefile.w32-in2
-rw-r--r--src/nsfns.m6
-rw-r--r--src/nsmenu.m6
-rw-r--r--src/nsterm.m16
-rw-r--r--src/print.c13
-rw-r--r--src/process.c157
-rw-r--r--src/process.h8
-rw-r--r--src/profiler.c12
-rw-r--r--src/regex.c33
-rw-r--r--src/regex.h46
-rw-r--r--src/search.c2
-rw-r--r--src/sheap.c4
-rw-r--r--src/sound.c2
-rw-r--r--src/syntax.c272
-rw-r--r--src/syntax.h296
-rw-r--r--src/sysdep.c235
-rw-r--r--src/systime.h23
-rw-r--r--src/term.c51
-rw-r--r--src/termcap.c108
-rw-r--r--src/termhooks.h2
-rw-r--r--src/terminal.c4
-rw-r--r--src/undo.c7
-rw-r--r--src/unexaix.c19
-rw-r--r--src/unexcoff.c15
-rw-r--r--src/unexcw.c4
-rw-r--r--src/unexelf.c6
-rw-r--r--src/unexhp9k800.c4
-rw-r--r--src/unexmacosx.c4
-rw-r--r--src/w32.c15
-rw-r--r--src/w32.h2
-rw-r--r--src/xdisp.c3
-rw-r--r--src/xrdb.c5
-rw-r--r--src/xsettings.c6
-rw-r--r--src/xterm.c125
-rw-r--r--test/ChangeLog67
-rw-r--r--test/automated/add-log-tests.el1
-rw-r--r--test/automated/advice-tests.el2
-rw-r--r--test/automated/cl-lib.el198
-rw-r--r--test/automated/decoder-tests.el5
-rw-r--r--test/automated/ert-tests.el171
-rw-r--r--test/automated/file-notify-tests.el151
-rw-r--r--test/automated/files.el3
-rw-r--r--test/automated/flymake-tests.el3
-rw-r--r--test/automated/icalendar-tests.el3
-rw-r--r--test/automated/imenu-test.el1
-rw-r--r--test/automated/inotify-test.el5
-rwxr-xr-xtest/automated/package-test.el7
-rwxr-xr-xtest/automated/package-x-test.el1
-rw-r--r--test/automated/python-tests.el5
-rw-r--r--test/automated/ruby-mode-tests.el24
-rw-r--r--test/automated/undo-tests.el26
-rw-r--r--test/automated/xml-parse-tests.el1
158 files changed, 4301 insertions, 2228 deletions
diff --git a/ChangeLog b/ChangeLog
index bd938539421..967284b485d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,62 @@
12013-07-13 Paul Eggert <eggert@cs.ucla.edu>
2
3 * configure.ac: Simplify --with-file-notification handling.
4
52013-07-12 Glenn Morris <rgm@gnu.org>
6
7 * configure.ac: If with-file-notification=yes, if gfile not found,
8 go on to try inotify (not on MS Windows or Nextstep).
9
102013-07-12 Paul Eggert <eggert@cs.ucla.edu>
11
12 Fix races with threads and file descriptors.
13 * configure.ac (PTY_TTY_NAME_SPRINTF): Use emacs_close, not close.
14
152013-07-10 Paul Eggert <eggert@cs.ucla.edu>
16
17 * Makefile.in (removenullpaths): Remove adjacent null paths (Bug#14835).
18
192013-07-09 Peter Rosin <peda@lysator.liu.se> (tiny change>
20
21 * configure.ac (HAVE_W32): Avoid nested functions (the second
22 argument of AC_LANG_PROGRAM is already expanded inside a
23 function). (Bug#14830)
24
252013-07-09 Paul Eggert <eggert@cs.ucla.edu>
26
27 Port recent close-on-exec changes to Cygwin (Bug#14821).
28 * lib/binary-io.c, lib/binary-io.h: New files.
29 Merge from gnulib, incorporating:
30 2013-07-09 accept4, dup3, pipe2: port to Cygwin
31 * lib/pipe2.c: Update from gnulib, as part of this merge.
32 * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
33
34 Handle errno and exit status a bit more carefully.
35 * lib/ignore-value.h: Remove this gnulib-imported file.
36 * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
37
382013-07-08 Magnus Henoch <magnus.henoch@gmail.com> (tiny change)
39
40 * configure.ac (HAVE_IMAGEMAGICK): Check on NS also (Bug#14798).
41
422013-07-08 Paul Eggert <eggert@cs.ucla.edu>
43
44 Try to fix FreeBSD 9.1 porting problem (Bug#14812).
45 This incorporates the following merge from gnulib:
46 2013-07-07 stdalign, verify: port to FreeBSD 9.1, to C11, and to C++11
47
482013-07-07 Paul Eggert <eggert@cs.ucla.edu>
49
50 Port to Ubuntu 10 (Bug#14803).
51 * configure.ac (accept4): New function to check for.
52
53 Make file descriptors close-on-exec when possible (Bug#14803).
54 * configure.ac (mkostemp): New function to check for.
55 (PTY_OPEN): Pass O_CLOEXEC to posix_openpt.
56 * lib/fcntl.c, lib/getdtablesize.c, lib/pipe2.c, m4/fcntl.m4:
57 * m4/getdtablesize.m4, m4/pipe2.m4: New files, taken from gnulib.
58 * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
59
12013-07-03 Christoph Egger <christoph@debian.org> (tiny change) 602013-07-03 Christoph Egger <christoph@debian.org> (tiny change)
2 61
3 * configure.ac (emacs_broken_SIGIO): Set on gnu-kfreebsd to avoid hang. 62 * configure.ac (emacs_broken_SIGIO): Set on gnu-kfreebsd to avoid hang.
@@ -36,7 +95,7 @@
36 * Makefile.in (install-arch-indep): Do not create directories passed 95 * Makefile.in (install-arch-indep): Do not create directories passed
37 with --enable-locallisppath. 96 with --enable-locallisppath.
38 97
392013-06-24 Glenn Morris <rgm@fencepost.gnu.org> 982013-06-24 Glenn Morris <rgm@gnu.org>
40 99
41 * configure.ac: Include X11/X.h when testing for Xft.h. (Bug#14684) 100 * configure.ac: Include X11/X.h when testing for Xft.h. (Bug#14684)
42 101
diff --git a/Makefile.in b/Makefile.in
index 4afe6746cfc..a5accbf04a9 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -293,7 +293,7 @@ all: ${SUBDIR}
293 293
294.PHONY: all ${SUBDIR} blessmail epaths-force epaths-force-w32 FRC 294.PHONY: all ${SUBDIR} blessmail epaths-force epaths-force-w32 FRC
295 295
296removenullpaths=sed -e 's/^://g' -e 's/:$$//g' -e 's/::/:/g' 296removenullpaths=sed -e 's/^:*//' -e 's/:*$$//g' -e 's/::*/:/g'
297 297
298# Generate epaths.h from epaths.in. This target is invoked by `configure'. 298# Generate epaths.h from epaths.in. This target is invoked by `configure'.
299# See comments in configure.ac for why it is done this way, as opposed 299# See comments in configure.ac for why it is done this way, as opposed
diff --git a/admin/ChangeLog b/admin/ChangeLog
index 592a41968db..cbcd698e8b1 100644
--- a/admin/ChangeLog
+++ b/admin/ChangeLog
@@ -1,3 +1,21 @@
12013-07-12 Glenn Morris <rgm@gnu.org>
2
3 * admin.el (manual-style-string): Use non-abbreviated url.
4
52013-07-09 Paul Eggert <eggert@cs.ucla.edu>
6
7 Port recent close-on-exec changes to Cygwin (Bug#14821).
8 * merge-gnulib (GNULIB_TOOL_FLAGS): Don't avoid binary-io.
9
10 Handle error numbers a bit more reliably.
11 * merge-gnulib (GNULIB_MODULES): Remove ignore-value.
12
132013-07-07 Paul Eggert <eggert@cs.ucla.edu>
14
15 Make file descriptors close-on-exec when possible (Bug#14803).
16 * merge-gnulib (GNULIB_MODULES): Add fcntl, pipe2.
17 (GNULIB_TOOL_FLAGS): Avoid binary-io, close. Do not avoid fcntl.
18
12013-07-06 Glenn Morris <rgm@gnu.org> 192013-07-06 Glenn Morris <rgm@gnu.org>
2 20
3 * admin.el (manual-misc-manuals): New function. 21 * admin.el (manual-misc-manuals): New function.
diff --git a/admin/admin.el b/admin/admin.el
index 927f68e978a..9c0015fc413 100644
--- a/admin/admin.el
+++ b/admin/admin.el
@@ -283,7 +283,7 @@ Optional argument TYPE is type of output (nil means all)."
283<meta name=\"DC.title\" content=\"gnu.org\">\n\n") 283<meta name=\"DC.title\" content=\"gnu.org\">\n\n")
284 284
285(defconst manual-style-string "<style type=\"text/css\"> 285(defconst manual-style-string "<style type=\"text/css\">
286@import url('/s/emacs/manual.css');\n</style>\n") 286@import url('/software/emacs/manual.css');\n</style>\n")
287 287
288(defun manual-misc-html (name root html-node-dir html-mono-dir) 288(defun manual-misc-html (name root html-node-dir html-mono-dir)
289 ;; Hack to deal with the cases where .texi creates a different .info. 289 ;; Hack to deal with the cases where .texi creates a different .info.
diff --git a/admin/merge-gnulib b/admin/merge-gnulib
index c8bfe0dacc3..82e0cd77fca 100755
--- a/admin/merge-gnulib
+++ b/admin/merge-gnulib
@@ -29,11 +29,11 @@ GNULIB_MODULES='
29 alloca-opt c-ctype c-strcase 29 alloca-opt c-ctype c-strcase
30 careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 30 careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512
31 dtoastr dtotimespec dup2 environ execinfo faccessat 31 dtoastr dtotimespec dup2 environ execinfo faccessat
32 fcntl-h fdatasync fdopendir filemode fstatat fsync 32 fcntl fcntl-h fdatasync fdopendir filemode fstatat fsync
33 getloadavg getopt-gnu gettime gettimeofday 33 getloadavg getopt-gnu gettime gettimeofday
34 ignore-value intprops largefile lstat 34 intprops largefile lstat
35 manywarnings memrchr mktime 35 manywarnings memrchr mktime
36 pselect pthread_sigmask putenv qacl readlink readlinkat 36 pipe2 pselect pthread_sigmask putenv qacl readlink readlinkat
37 sig2str socklen stat-time stdalign stdarg stdbool stdio 37 sig2str socklen stat-time stdalign stdarg stdbool stdio
38 strftime strtoimax strtoumax symlink sys_stat 38 strftime strtoimax strtoumax symlink sys_stat
39 sys_time time timer-time timespec-add timespec-sub unsetenv utimens 39 sys_time time timer-time timespec-add timespec-sub unsetenv utimens
@@ -41,8 +41,8 @@ GNULIB_MODULES='
41' 41'
42 42
43GNULIB_TOOL_FLAGS=' 43GNULIB_TOOL_FLAGS='
44 --avoid=dup 44 --avoid=close --avoid=dup
45 --avoid=fchdir --avoid=fcntl --avoid=fstat 45 --avoid=fchdir --avoid=fstat
46 --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow 46 --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow
47 --avoid=open --avoid=openat-die --avoid=opendir 47 --avoid=open --avoid=openat-die --avoid=opendir
48 --avoid=raise 48 --avoid=raise
diff --git a/admin/notes/changelogs b/admin/notes/changelogs
index ae9ce40aa0a..1025cfc217f 100644
--- a/admin/notes/changelogs
+++ b/admin/notes/changelogs
@@ -3,9 +3,10 @@ entry in their name, not yours.
3 3
4 4
5http://lists.gnu.org/archive/html/emacs-devel/2007-09/msg00793.html 5http://lists.gnu.org/archive/html/emacs-devel/2007-09/msg00793.html
6http://lists.gnu.org/archive/html/emacs-devel/2013-06/msg00485.html 6 There is no need to make change log entries for files such as NEWS,
7 There is no need to make trivial change log entries for files such 7 MAINTAINERS, and FOR-RELEASE.
8 as NEWS, MAINTAINERS, and FOR-RELEASE. 8"There is no need" means you don't have to, but you can if you want to.
9
9 10
10http://lists.gnu.org/archive/html/emacs-devel/2006-12/msg01135.html 11http://lists.gnu.org/archive/html/emacs-devel/2006-12/msg01135.html
11 There is no need to indicate regeneration of files such as configure 12 There is no need to indicate regeneration of files such as configure
diff --git a/autogen/Makefile.in b/autogen/Makefile.in
index 99805dd1fe8..d471a9eeb18 100644
--- a/autogen/Makefile.in
+++ b/autogen/Makefile.in
@@ -59,7 +59,7 @@
59# the same distribution terms as the rest of that program. 59# the same distribution terms as the rest of that program.
60# 60#
61# Generated by gnulib-tool. 61# Generated by gnulib-tool.
62# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=dup --avoid=fchdir --avoid=fcntl --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl-h fdatasync fdopendir filemode fstatat fsync getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings memrchr mktime pselect pthread_sigmask putenv qacl readlink readlinkat sig2str socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub unsetenv utimens warnings 62# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode fstatat fsync getloadavg getopt-gnu gettime gettimeofday intprops largefile lstat manywarnings memrchr mktime pipe2 pselect pthread_sigmask putenv qacl readlink readlinkat sig2str socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub unsetenv utimens warnings
63 63
64VPATH = @srcdir@ 64VPATH = @srcdir@
65pkgdatadir = $(datadir)/@PACKAGE@ 65pkgdatadir = $(datadir)/@PACKAGE@
@@ -192,19 +192,20 @@ DIST_COMMON = $(srcdir)/../nt/gnulib.mk $(srcdir)/Makefile.am \
192@BUILDING_FOR_WINDOWSNT_FALSE@ ftoastr.h dup2.c errno.in.h \ 192@BUILDING_FOR_WINDOWSNT_FALSE@ ftoastr.h dup2.c errno.in.h \
193@BUILDING_FOR_WINDOWSNT_FALSE@ euidaccess.c execinfo.c \ 193@BUILDING_FOR_WINDOWSNT_FALSE@ euidaccess.c execinfo.c \
194@BUILDING_FOR_WINDOWSNT_FALSE@ execinfo.in.h at-func.c \ 194@BUILDING_FOR_WINDOWSNT_FALSE@ execinfo.in.h at-func.c \
195@BUILDING_FOR_WINDOWSNT_FALSE@ faccessat.c fcntl.in.h \ 195@BUILDING_FOR_WINDOWSNT_FALSE@ faccessat.c fcntl.c fcntl.in.h \
196@BUILDING_FOR_WINDOWSNT_FALSE@ fdatasync.c fdopendir.c \ 196@BUILDING_FOR_WINDOWSNT_FALSE@ fdatasync.c fdopendir.c \
197@BUILDING_FOR_WINDOWSNT_FALSE@ filemode.h fpending.c fpending.h \ 197@BUILDING_FOR_WINDOWSNT_FALSE@ filemode.h fpending.c fpending.h \
198@BUILDING_FOR_WINDOWSNT_FALSE@ at-func.c fstatat.c fsync.c \ 198@BUILDING_FOR_WINDOWSNT_FALSE@ at-func.c fstatat.c fsync.c \
199@BUILDING_FOR_WINDOWSNT_FALSE@ getgroups.c getloadavg.c \ 199@BUILDING_FOR_WINDOWSNT_FALSE@ getdtablesize.c getgroups.c \
200@BUILDING_FOR_WINDOWSNT_FALSE@ getopt.c getopt.in.h getopt1.c \ 200@BUILDING_FOR_WINDOWSNT_FALSE@ getloadavg.c getopt.c \
201@BUILDING_FOR_WINDOWSNT_FALSE@ getopt.in.h getopt1.c \
201@BUILDING_FOR_WINDOWSNT_FALSE@ getopt_int.h gettimeofday.c \ 202@BUILDING_FOR_WINDOWSNT_FALSE@ getopt_int.h gettimeofday.c \
202@BUILDING_FOR_WINDOWSNT_FALSE@ group-member.c ignore-value.h \ 203@BUILDING_FOR_WINDOWSNT_FALSE@ group-member.c intprops.h \
203@BUILDING_FOR_WINDOWSNT_FALSE@ intprops.h inttypes.in.h lstat.c \ 204@BUILDING_FOR_WINDOWSNT_FALSE@ inttypes.in.h lstat.c memrchr.c \
204@BUILDING_FOR_WINDOWSNT_FALSE@ memrchr.c mktime-internal.h \ 205@BUILDING_FOR_WINDOWSNT_FALSE@ mktime-internal.h mktime.c \
205@BUILDING_FOR_WINDOWSNT_FALSE@ mktime.c openat.h pathmax.h \ 206@BUILDING_FOR_WINDOWSNT_FALSE@ openat.h pathmax.h pselect.c \
206@BUILDING_FOR_WINDOWSNT_FALSE@ pselect.c pthread_sigmask.c \ 207@BUILDING_FOR_WINDOWSNT_FALSE@ pthread_sigmask.c putenv.c \
207@BUILDING_FOR_WINDOWSNT_FALSE@ putenv.c acl-internal.h acl.h \ 208@BUILDING_FOR_WINDOWSNT_FALSE@ acl-internal.h acl.h \
208@BUILDING_FOR_WINDOWSNT_FALSE@ acl_entries.c readlink.c \ 209@BUILDING_FOR_WINDOWSNT_FALSE@ acl_entries.c readlink.c \
209@BUILDING_FOR_WINDOWSNT_FALSE@ at-func.c readlinkat.c \ 210@BUILDING_FOR_WINDOWSNT_FALSE@ at-func.c readlinkat.c \
210@BUILDING_FOR_WINDOWSNT_FALSE@ root-uid.h sig2str.c sig2str.h \ 211@BUILDING_FOR_WINDOWSNT_FALSE@ root-uid.h sig2str.c sig2str.h \
@@ -239,10 +240,11 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
239 $(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/euidaccess.m4 \ 240 $(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/euidaccess.m4 \
240 $(top_srcdir)/m4/execinfo.m4 $(top_srcdir)/m4/extensions.m4 \ 241 $(top_srcdir)/m4/execinfo.m4 $(top_srcdir)/m4/extensions.m4 \
241 $(top_srcdir)/m4/extern-inline.m4 \ 242 $(top_srcdir)/m4/extern-inline.m4 \
242 $(top_srcdir)/m4/faccessat.m4 $(top_srcdir)/m4/fcntl_h.m4 \ 243 $(top_srcdir)/m4/faccessat.m4 $(top_srcdir)/m4/fcntl.m4 \
243 $(top_srcdir)/m4/fdatasync.m4 $(top_srcdir)/m4/fdopendir.m4 \ 244 $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/fdatasync.m4 \
244 $(top_srcdir)/m4/filemode.m4 $(top_srcdir)/m4/fpending.m4 \ 245 $(top_srcdir)/m4/fdopendir.m4 $(top_srcdir)/m4/filemode.m4 \
245 $(top_srcdir)/m4/fstatat.m4 $(top_srcdir)/m4/fsync.m4 \ 246 $(top_srcdir)/m4/fpending.m4 $(top_srcdir)/m4/fstatat.m4 \
247 $(top_srcdir)/m4/fsync.m4 $(top_srcdir)/m4/getdtablesize.m4 \
246 $(top_srcdir)/m4/getgroups.m4 $(top_srcdir)/m4/getloadavg.m4 \ 248 $(top_srcdir)/m4/getgroups.m4 $(top_srcdir)/m4/getloadavg.m4 \
247 $(top_srcdir)/m4/getopt.m4 $(top_srcdir)/m4/gettime.m4 \ 249 $(top_srcdir)/m4/getopt.m4 $(top_srcdir)/m4/gettime.m4 \
248 $(top_srcdir)/m4/gettimeofday.m4 \ 250 $(top_srcdir)/m4/gettimeofday.m4 \
@@ -255,7 +257,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
255 $(top_srcdir)/m4/md5.m4 $(top_srcdir)/m4/memrchr.m4 \ 257 $(top_srcdir)/m4/md5.m4 $(top_srcdir)/m4/memrchr.m4 \
256 $(top_srcdir)/m4/mktime.m4 $(top_srcdir)/m4/multiarch.m4 \ 258 $(top_srcdir)/m4/mktime.m4 $(top_srcdir)/m4/multiarch.m4 \
257 $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/off_t.m4 \ 259 $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/off_t.m4 \
258 $(top_srcdir)/m4/pathmax.m4 $(top_srcdir)/m4/pselect.m4 \ 260 $(top_srcdir)/m4/pathmax.m4 $(top_srcdir)/m4/pipe2.m4 \
261 $(top_srcdir)/m4/pselect.m4 \
259 $(top_srcdir)/m4/pthread_sigmask.m4 $(top_srcdir)/m4/putenv.m4 \ 262 $(top_srcdir)/m4/pthread_sigmask.m4 $(top_srcdir)/m4/putenv.m4 \
260 $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/readlinkat.m4 \ 263 $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/readlinkat.m4 \
261 $(top_srcdir)/m4/setenv.m4 $(top_srcdir)/m4/sha1.m4 \ 264 $(top_srcdir)/m4/setenv.m4 $(top_srcdir)/m4/sha1.m4 \
@@ -288,16 +291,18 @@ CONFIG_CLEAN_VPATH_FILES =
288LIBRARIES = $(noinst_LIBRARIES) 291LIBRARIES = $(noinst_LIBRARIES)
289libgnu_a_AR = $(AR) $(ARFLAGS) 292libgnu_a_AR = $(AR) $(ARFLAGS)
290am__DEPENDENCIES_1 = 293am__DEPENDENCIES_1 =
291am__libgnu_a_SOURCES_DIST = allocator.c c-ctype.h c-ctype.c \ 294am__libgnu_a_SOURCES_DIST = allocator.c binary-io.h binary-io.c \
292 c-strcase.h c-strcasecmp.c c-strncasecmp.c careadlinkat.c \ 295 c-ctype.h c-ctype.c c-strcase.h c-strcasecmp.c c-strncasecmp.c \
293 close-stream.c md5.c sha1.c sha256.c sha512.c dtoastr.c \ 296 careadlinkat.c close-stream.c md5.c sha1.c sha256.c sha512.c \
294 dtotimespec.c filemode.c gettext.h gettime.c acl-errno-valid.c \ 297 dtoastr.c dtotimespec.c filemode.c gettext.h gettime.c pipe2.c \
295 file-has-acl.c qcopy-acl.c qset-acl.c stat-time.c strftime.c \ 298 acl-errno-valid.c file-has-acl.c qcopy-acl.c qset-acl.c \
296 timespec.c timespec-add.c timespec-sub.c u64.c unistd.c \ 299 stat-time.c strftime.c timespec.c timespec-add.c \
297 utimens.c openat-die.c save-cwd.c 300 timespec-sub.c u64.c unistd.c utimens.c openat-die.c \
301 save-cwd.c
298am__objects_1 = 302am__objects_1 =
299@BUILDING_FOR_WINDOWSNT_FALSE@am_libgnu_a_OBJECTS = \ 303@BUILDING_FOR_WINDOWSNT_FALSE@am_libgnu_a_OBJECTS = \
300@BUILDING_FOR_WINDOWSNT_FALSE@ allocator.$(OBJEXT) \ 304@BUILDING_FOR_WINDOWSNT_FALSE@ allocator.$(OBJEXT) \
305@BUILDING_FOR_WINDOWSNT_FALSE@ binary-io.$(OBJEXT) \
301@BUILDING_FOR_WINDOWSNT_FALSE@ c-ctype.$(OBJEXT) \ 306@BUILDING_FOR_WINDOWSNT_FALSE@ c-ctype.$(OBJEXT) \
302@BUILDING_FOR_WINDOWSNT_FALSE@ c-strcasecmp.$(OBJEXT) \ 307@BUILDING_FOR_WINDOWSNT_FALSE@ c-strcasecmp.$(OBJEXT) \
303@BUILDING_FOR_WINDOWSNT_FALSE@ c-strncasecmp.$(OBJEXT) \ 308@BUILDING_FOR_WINDOWSNT_FALSE@ c-strncasecmp.$(OBJEXT) \
@@ -311,6 +316,7 @@ am__objects_1 =
311@BUILDING_FOR_WINDOWSNT_FALSE@ filemode.$(OBJEXT) \ 316@BUILDING_FOR_WINDOWSNT_FALSE@ filemode.$(OBJEXT) \
312@BUILDING_FOR_WINDOWSNT_FALSE@ $(am__objects_1) \ 317@BUILDING_FOR_WINDOWSNT_FALSE@ $(am__objects_1) \
313@BUILDING_FOR_WINDOWSNT_FALSE@ gettime.$(OBJEXT) \ 318@BUILDING_FOR_WINDOWSNT_FALSE@ gettime.$(OBJEXT) \
319@BUILDING_FOR_WINDOWSNT_FALSE@ pipe2.$(OBJEXT) \
314@BUILDING_FOR_WINDOWSNT_FALSE@ acl-errno-valid.$(OBJEXT) \ 320@BUILDING_FOR_WINDOWSNT_FALSE@ acl-errno-valid.$(OBJEXT) \
315@BUILDING_FOR_WINDOWSNT_FALSE@ file-has-acl.$(OBJEXT) \ 321@BUILDING_FOR_WINDOWSNT_FALSE@ file-has-acl.$(OBJEXT) \
316@BUILDING_FOR_WINDOWSNT_FALSE@ qcopy-acl.$(OBJEXT) \ 322@BUILDING_FOR_WINDOWSNT_FALSE@ qcopy-acl.$(OBJEXT) \
@@ -346,13 +352,13 @@ am__objects_1 =
346@BUILDING_FOR_WINDOWSNT_TRUE@ u64.$(OBJEXT) utimens.$(OBJEXT) \ 352@BUILDING_FOR_WINDOWSNT_TRUE@ u64.$(OBJEXT) utimens.$(OBJEXT) \
347@BUILDING_FOR_WINDOWSNT_TRUE@ $(am__objects_1) 353@BUILDING_FOR_WINDOWSNT_TRUE@ $(am__objects_1)
348am__EXTRA_libgnu_a_SOURCES_DIST = openat-proc.c ftoastr.c dup2.c \ 354am__EXTRA_libgnu_a_SOURCES_DIST = openat-proc.c ftoastr.c dup2.c \
349 euidaccess.c execinfo.c at-func.c faccessat.c fdatasync.c \ 355 euidaccess.c execinfo.c at-func.c faccessat.c fcntl.c \
350 fdopendir.c fpending.c fstatat.c fsync.c getgroups.c \ 356 fdatasync.c fdopendir.c fpending.c fstatat.c fsync.c \
351 getloadavg.c getopt.c getopt1.c gettimeofday.c group-member.c \ 357 getdtablesize.c getgroups.c getloadavg.c getopt.c getopt1.c \
352 lstat.c memrchr.c mktime.c pselect.c pthread_sigmask.c \ 358 gettimeofday.c group-member.c lstat.c memrchr.c mktime.c \
353 putenv.c acl_entries.c readlink.c readlinkat.c sig2str.c \ 359 pselect.c pthread_sigmask.c putenv.c acl_entries.c readlink.c \
354 stat.c strtoimax.c strtol.c strtoll.c strtoul.c strtoull.c \ 360 readlinkat.c sig2str.c stat.c strtoimax.c strtol.c strtoll.c \
355 strtoumax.c symlink.c time_r.c unsetenv.c 361 strtoul.c strtoull.c strtoumax.c symlink.c time_r.c unsetenv.c
356libgnu_a_OBJECTS = $(am_libgnu_a_OBJECTS) 362libgnu_a_OBJECTS = $(am_libgnu_a_OBJECTS)
357depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp 363depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp
358am__depfiles_maybe = depfiles 364am__depfiles_maybe = depfiles
@@ -1230,20 +1236,22 @@ noinst_LIBRARIES = $(am__append_2) $(am__append_7)
1230SUFFIXES = 1236SUFFIXES =
1231AM_CFLAGS = $(PROFILING_CFLAGS) $(GNULIB_WARN_CFLAGS) $(WERROR_CFLAGS) 1237AM_CFLAGS = $(PROFILING_CFLAGS) $(GNULIB_WARN_CFLAGS) $(WERROR_CFLAGS)
1232DEFAULT_INCLUDES = -I. -I$(top_srcdir)/lib -I../src -I$(top_srcdir)/src 1238DEFAULT_INCLUDES = -I. -I$(top_srcdir)/lib -I../src -I$(top_srcdir)/src
1233@BUILDING_FOR_WINDOWSNT_FALSE@libgnu_a_SOURCES = allocator.c c-ctype.h \ 1239@BUILDING_FOR_WINDOWSNT_FALSE@libgnu_a_SOURCES = allocator.c \
1234@BUILDING_FOR_WINDOWSNT_FALSE@ c-ctype.c c-strcase.h \ 1240@BUILDING_FOR_WINDOWSNT_FALSE@ binary-io.h binary-io.c \
1241@BUILDING_FOR_WINDOWSNT_FALSE@ c-ctype.h c-ctype.c c-strcase.h \
1235@BUILDING_FOR_WINDOWSNT_FALSE@ c-strcasecmp.c c-strncasecmp.c \ 1242@BUILDING_FOR_WINDOWSNT_FALSE@ c-strcasecmp.c c-strncasecmp.c \
1236@BUILDING_FOR_WINDOWSNT_FALSE@ careadlinkat.c close-stream.c \ 1243@BUILDING_FOR_WINDOWSNT_FALSE@ careadlinkat.c close-stream.c \
1237@BUILDING_FOR_WINDOWSNT_FALSE@ md5.c sha1.c sha256.c sha512.c \ 1244@BUILDING_FOR_WINDOWSNT_FALSE@ md5.c sha1.c sha256.c sha512.c \
1238@BUILDING_FOR_WINDOWSNT_FALSE@ dtoastr.c dtotimespec.c \ 1245@BUILDING_FOR_WINDOWSNT_FALSE@ dtoastr.c dtotimespec.c \
1239@BUILDING_FOR_WINDOWSNT_FALSE@ filemode.c $(am__append_10) \ 1246@BUILDING_FOR_WINDOWSNT_FALSE@ filemode.c $(am__append_10) \
1240@BUILDING_FOR_WINDOWSNT_FALSE@ gettime.c acl-errno-valid.c \ 1247@BUILDING_FOR_WINDOWSNT_FALSE@ gettime.c pipe2.c \
1241@BUILDING_FOR_WINDOWSNT_FALSE@ file-has-acl.c qcopy-acl.c \ 1248@BUILDING_FOR_WINDOWSNT_FALSE@ acl-errno-valid.c file-has-acl.c \
1242@BUILDING_FOR_WINDOWSNT_FALSE@ qset-acl.c stat-time.c \ 1249@BUILDING_FOR_WINDOWSNT_FALSE@ qcopy-acl.c qset-acl.c \
1243@BUILDING_FOR_WINDOWSNT_FALSE@ strftime.c timespec.c \ 1250@BUILDING_FOR_WINDOWSNT_FALSE@ stat-time.c strftime.c \
1244@BUILDING_FOR_WINDOWSNT_FALSE@ timespec-add.c timespec-sub.c \ 1251@BUILDING_FOR_WINDOWSNT_FALSE@ timespec.c timespec-add.c \
1245@BUILDING_FOR_WINDOWSNT_FALSE@ u64.c unistd.c utimens.c \ 1252@BUILDING_FOR_WINDOWSNT_FALSE@ timespec-sub.c u64.c unistd.c \
1246@BUILDING_FOR_WINDOWSNT_FALSE@ openat-die.c save-cwd.c 1253@BUILDING_FOR_WINDOWSNT_FALSE@ utimens.c openat-die.c \
1254@BUILDING_FOR_WINDOWSNT_FALSE@ save-cwd.c
1247@BUILDING_FOR_WINDOWSNT_TRUE@libgnu_a_SOURCES = c-ctype.h c-ctype.c \ 1255@BUILDING_FOR_WINDOWSNT_TRUE@libgnu_a_SOURCES = c-ctype.h c-ctype.c \
1248@BUILDING_FOR_WINDOWSNT_TRUE@ c-strcase.h c-strcasecmp.c \ 1256@BUILDING_FOR_WINDOWSNT_TRUE@ c-strcase.h c-strcasecmp.c \
1249@BUILDING_FOR_WINDOWSNT_TRUE@ c-strncasecmp.c close-stream.c \ 1257@BUILDING_FOR_WINDOWSNT_TRUE@ c-strncasecmp.c close-stream.c \
@@ -1262,9 +1270,10 @@ DEFAULT_INCLUDES = -I. -I$(top_srcdir)/lib -I../src -I$(top_srcdir)/src
1262@BUILDING_FOR_WINDOWSNT_FALSE@EXTRA_libgnu_a_SOURCES = openat-proc.c \ 1270@BUILDING_FOR_WINDOWSNT_FALSE@EXTRA_libgnu_a_SOURCES = openat-proc.c \
1263@BUILDING_FOR_WINDOWSNT_FALSE@ ftoastr.c dup2.c euidaccess.c \ 1271@BUILDING_FOR_WINDOWSNT_FALSE@ ftoastr.c dup2.c euidaccess.c \
1264@BUILDING_FOR_WINDOWSNT_FALSE@ execinfo.c at-func.c faccessat.c \ 1272@BUILDING_FOR_WINDOWSNT_FALSE@ execinfo.c at-func.c faccessat.c \
1265@BUILDING_FOR_WINDOWSNT_FALSE@ fdatasync.c fdopendir.c \ 1273@BUILDING_FOR_WINDOWSNT_FALSE@ fcntl.c fdatasync.c fdopendir.c \
1266@BUILDING_FOR_WINDOWSNT_FALSE@ fpending.c at-func.c fstatat.c \ 1274@BUILDING_FOR_WINDOWSNT_FALSE@ fpending.c at-func.c fstatat.c \
1267@BUILDING_FOR_WINDOWSNT_FALSE@ fsync.c getgroups.c getloadavg.c \ 1275@BUILDING_FOR_WINDOWSNT_FALSE@ fsync.c getdtablesize.c \
1276@BUILDING_FOR_WINDOWSNT_FALSE@ getgroups.c getloadavg.c \
1268@BUILDING_FOR_WINDOWSNT_FALSE@ getopt.c getopt1.c \ 1277@BUILDING_FOR_WINDOWSNT_FALSE@ getopt.c getopt1.c \
1269@BUILDING_FOR_WINDOWSNT_FALSE@ gettimeofday.c group-member.c \ 1278@BUILDING_FOR_WINDOWSNT_FALSE@ gettimeofday.c group-member.c \
1270@BUILDING_FOR_WINDOWSNT_FALSE@ lstat.c memrchr.c mktime.c \ 1279@BUILDING_FOR_WINDOWSNT_FALSE@ lstat.c memrchr.c mktime.c \
@@ -1361,6 +1370,7 @@ distclean-compile:
1361@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/acl_entries.Po@am__quote@ 1370@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/acl_entries.Po@am__quote@
1362@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/allocator.Po@am__quote@ 1371@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/allocator.Po@am__quote@
1363@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/at-func.Po@am__quote@ 1372@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/at-func.Po@am__quote@
1373@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/binary-io.Po@am__quote@
1364@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c-ctype.Po@am__quote@ 1374@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c-ctype.Po@am__quote@
1365@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c-strcasecmp.Po@am__quote@ 1375@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c-strcasecmp.Po@am__quote@
1366@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c-strncasecmp.Po@am__quote@ 1376@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c-strncasecmp.Po@am__quote@
@@ -1372,6 +1382,7 @@ distclean-compile:
1372@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/euidaccess.Po@am__quote@ 1382@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/euidaccess.Po@am__quote@
1373@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/execinfo.Po@am__quote@ 1383@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/execinfo.Po@am__quote@
1374@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/faccessat.Po@am__quote@ 1384@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/faccessat.Po@am__quote@
1385@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fcntl.Po@am__quote@
1375@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdatasync.Po@am__quote@ 1386@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdatasync.Po@am__quote@
1376@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdopendir.Po@am__quote@ 1387@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdopendir.Po@am__quote@
1377@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file-has-acl.Po@am__quote@ 1388@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file-has-acl.Po@am__quote@
@@ -1380,6 +1391,7 @@ distclean-compile:
1380@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstatat.Po@am__quote@ 1391@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstatat.Po@am__quote@
1381@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fsync.Po@am__quote@ 1392@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fsync.Po@am__quote@
1382@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftoastr.Po@am__quote@ 1393@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftoastr.Po@am__quote@
1394@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getdtablesize.Po@am__quote@
1383@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getgroups.Po@am__quote@ 1395@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getgroups.Po@am__quote@
1384@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getloadavg.Po@am__quote@ 1396@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getloadavg.Po@am__quote@
1385@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@ 1397@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@
@@ -1393,6 +1405,7 @@ distclean-compile:
1393@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mktime.Po@am__quote@ 1405@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mktime.Po@am__quote@
1394@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openat-die.Po@am__quote@ 1406@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openat-die.Po@am__quote@
1395@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openat-proc.Po@am__quote@ 1407@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openat-proc.Po@am__quote@
1408@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pipe2.Po@am__quote@
1396@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pselect.Po@am__quote@ 1409@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pselect.Po@am__quote@
1397@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pthread_sigmask.Po@am__quote@ 1410@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pthread_sigmask.Po@am__quote@
1398@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/putenv.Po@am__quote@ 1411@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/putenv.Po@am__quote@
diff --git a/autogen/aclocal.m4 b/autogen/aclocal.m4
index eb324b06b37..c9e796a081f 100644
--- a/autogen/aclocal.m4
+++ b/autogen/aclocal.m4
@@ -999,6 +999,7 @@ m4_include([m4/execinfo.m4])
999m4_include([m4/extensions.m4]) 999m4_include([m4/extensions.m4])
1000m4_include([m4/extern-inline.m4]) 1000m4_include([m4/extern-inline.m4])
1001m4_include([m4/faccessat.m4]) 1001m4_include([m4/faccessat.m4])
1002m4_include([m4/fcntl.m4])
1002m4_include([m4/fcntl_h.m4]) 1003m4_include([m4/fcntl_h.m4])
1003m4_include([m4/fdatasync.m4]) 1004m4_include([m4/fdatasync.m4])
1004m4_include([m4/fdopendir.m4]) 1005m4_include([m4/fdopendir.m4])
@@ -1006,6 +1007,7 @@ m4_include([m4/filemode.m4])
1006m4_include([m4/fpending.m4]) 1007m4_include([m4/fpending.m4])
1007m4_include([m4/fstatat.m4]) 1008m4_include([m4/fstatat.m4])
1008m4_include([m4/fsync.m4]) 1009m4_include([m4/fsync.m4])
1010m4_include([m4/getdtablesize.m4])
1009m4_include([m4/getgroups.m4]) 1011m4_include([m4/getgroups.m4])
1010m4_include([m4/getloadavg.m4]) 1012m4_include([m4/getloadavg.m4])
1011m4_include([m4/getopt.m4]) 1013m4_include([m4/getopt.m4])
@@ -1027,6 +1029,7 @@ m4_include([m4/multiarch.m4])
1027m4_include([m4/nocrash.m4]) 1029m4_include([m4/nocrash.m4])
1028m4_include([m4/off_t.m4]) 1030m4_include([m4/off_t.m4])
1029m4_include([m4/pathmax.m4]) 1031m4_include([m4/pathmax.m4])
1032m4_include([m4/pipe2.m4])
1030m4_include([m4/pselect.m4]) 1033m4_include([m4/pselect.m4])
1031m4_include([m4/pthread_sigmask.m4]) 1034m4_include([m4/pthread_sigmask.m4])
1032m4_include([m4/putenv.m4]) 1035m4_include([m4/putenv.m4])
diff --git a/autogen/config.in b/autogen/config.in
index 89ad415f3b0..3fe82ce0f92 100644
--- a/autogen/config.in
+++ b/autogen/config.in
@@ -120,6 +120,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
120 enabled. */ 120 enabled. */
121#undef ENABLE_CHECKING 121#undef ENABLE_CHECKING
122 122
123/* Define this to 1 if F_DUPFD behavior does not match POSIX */
124#undef FCNTL_DUPFD_BUGGY
125
123/* Letter to use in finding device name of first PTY, if PTYs are supported. 126/* Letter to use in finding device name of first PTY, if PTYs are supported.
124 */ 127 */
125#undef FIRST_PTY_LETTER 128#undef FIRST_PTY_LETTER
@@ -206,6 +209,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
206 startup, if using GTK. */ 209 startup, if using GTK. */
207#undef G_SLICE_ALWAYS_MALLOC 210#undef G_SLICE_ALWAYS_MALLOC
208 211
212/* Define to 1 if you have the `accept4' function. */
213#undef HAVE_ACCEPT4
214
209/* Define to 1 if you have the `access' function. */ 215/* Define to 1 if you have the `access' function. */
210#undef HAVE_ACCESS 216#undef HAVE_ACCESS
211 217
@@ -439,6 +445,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
439/* Define to 1 if you have the `facl' function. */ 445/* Define to 1 if you have the `facl' function. */
440#undef HAVE_FACL 446#undef HAVE_FACL
441 447
448/* Define to 1 if you have the `fcntl' function. */
449#undef HAVE_FCNTL
450
442/* Define to 1 if you have the `fdatasync' function. */ 451/* Define to 1 if you have the `fdatasync' function. */
443#undef HAVE_FDATASYNC 452#undef HAVE_FDATASYNC
444 453
@@ -487,6 +496,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
487/* Define to 1 if you have the `getdelim' function. */ 496/* Define to 1 if you have the `getdelim' function. */
488#undef HAVE_GETDELIM 497#undef HAVE_GETDELIM
489 498
499/* Define to 1 if you have the `getdtablesize' function. */
500#undef HAVE_GETDTABLESIZE
501
490/* Define to 1 if you have the `getgrent' function. */ 502/* Define to 1 if you have the `getgrent' function. */
491#undef HAVE_GETGRENT 503#undef HAVE_GETGRENT
492 504
@@ -738,6 +750,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
738 systems that support xmenu.c. */ 750 systems that support xmenu.c. */
739#undef HAVE_MENUS 751#undef HAVE_MENUS
740 752
753/* Define to 1 if you have the `mkostemp' function. */
754#undef HAVE_MKOSTEMP
755
741/* Define to 1 if you have the `mkstemp' function. */ 756/* Define to 1 if you have the `mkstemp' function. */
742#undef HAVE_MKSTEMP 757#undef HAVE_MKSTEMP
743 758
@@ -769,6 +784,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
769/* Define to 1 if personality LINUX32 can be set. */ 784/* Define to 1 if personality LINUX32 can be set. */
770#undef HAVE_PERSONALITY_LINUX32 785#undef HAVE_PERSONALITY_LINUX32
771 786
787/* Define to 1 if you have the `pipe2' function. */
788#undef HAVE_PIPE2
789
772/* Define to 1 if you have the png library (-lpng). */ 790/* Define to 1 if you have the png library (-lpng). */
773#undef HAVE_PNG 791#undef HAVE_PNG
774 792
diff --git a/autogen/configure b/autogen/configure
index 463c5905a12..faa09d0e9c3 100755
--- a/autogen/configure
+++ b/autogen/configure
@@ -614,8 +614,6 @@ LIBGNU_LIBDEPS
614gltests_WITNESS 614gltests_WITNESS
615gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_FALSE 615gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_FALSE
616gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_TRUE 616gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_TRUE
617gl_GNULIB_ENABLED_verify_FALSE
618gl_GNULIB_ENABLED_verify_TRUE
619gl_GNULIB_ENABLED_strtoull_FALSE 617gl_GNULIB_ENABLED_strtoull_FALSE
620gl_GNULIB_ENABLED_strtoull_TRUE 618gl_GNULIB_ENABLED_strtoull_TRUE
621gl_GNULIB_ENABLED_strtoll_FALSE 619gl_GNULIB_ENABLED_strtoll_FALSE
@@ -634,6 +632,8 @@ gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36_FALSE
634gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36_TRUE 632gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36_TRUE
635gl_GNULIB_ENABLED_getgroups_FALSE 633gl_GNULIB_ENABLED_getgroups_FALSE
636gl_GNULIB_ENABLED_getgroups_TRUE 634gl_GNULIB_ENABLED_getgroups_TRUE
635gl_GNULIB_ENABLED_getdtablesize_FALSE
636gl_GNULIB_ENABLED_getdtablesize_TRUE
637gl_GNULIB_ENABLED_euidaccess_FALSE 637gl_GNULIB_ENABLED_euidaccess_FALSE
638gl_GNULIB_ENABLED_euidaccess_TRUE 638gl_GNULIB_ENABLED_euidaccess_TRUE
639gl_GNULIB_ENABLED_dosname_FALSE 639gl_GNULIB_ENABLED_dosname_FALSE
@@ -3373,6 +3373,7 @@ as_fn_append ac_func_list " readlinkat"
3373as_fn_append ac_header_list " dirent.h" 3373as_fn_append ac_header_list " dirent.h"
3374as_fn_append ac_header_list " execinfo.h" 3374as_fn_append ac_header_list " execinfo.h"
3375as_fn_append ac_func_list " faccessat" 3375as_fn_append ac_func_list " faccessat"
3376as_fn_append ac_func_list " fcntl"
3376as_fn_append ac_func_list " fdopendir" 3377as_fn_append ac_func_list " fdopendir"
3377as_fn_append ac_header_list " stdio_ext.h" 3378as_fn_append ac_header_list " stdio_ext.h"
3378as_fn_append ac_func_list " __fpending" 3379as_fn_append ac_func_list " __fpending"
@@ -3387,6 +3388,7 @@ as_fn_append ac_header_list " wchar.h"
3387as_fn_append ac_header_list " stdint.h" 3388as_fn_append ac_header_list " stdint.h"
3388as_fn_append ac_header_list " inttypes.h" 3389as_fn_append ac_header_list " inttypes.h"
3389as_fn_append ac_func_list " lstat" 3390as_fn_append ac_func_list " lstat"
3391as_fn_append ac_func_list " pipe2"
3390as_fn_append ac_header_list " sys/select.h" 3392as_fn_append ac_header_list " sys/select.h"
3391as_fn_append ac_func_list " pselect" 3393as_fn_append ac_func_list " pselect"
3392as_fn_append ac_func_list " pthread_sigmask" 3394as_fn_append ac_func_list " pthread_sigmask"
@@ -3402,6 +3404,7 @@ as_fn_append ac_func_list " futimesat"
3402as_fn_append ac_func_list " futimens" 3404as_fn_append ac_func_list " futimens"
3403as_fn_append ac_func_list " utimensat" 3405as_fn_append ac_func_list " utimensat"
3404as_fn_append ac_func_list " lutimes" 3406as_fn_append ac_func_list " lutimes"
3407as_fn_append ac_func_list " getdtablesize"
3405# Check that the precious variables saved in the cache have kept the same 3408# Check that the precious variables saved in the cache have kept the same
3406# value. 3409# value.
3407ac_cache_corrupted=false 3410ac_cache_corrupted=false
@@ -7225,6 +7228,7 @@ esac
7225 # Code from module alloca-opt: 7228 # Code from module alloca-opt:
7226 # Code from module allocator: 7229 # Code from module allocator:
7227 # Code from module at-internal: 7230 # Code from module at-internal:
7231 # Code from module binary-io:
7228 # Code from module c-ctype: 7232 # Code from module c-ctype:
7229 # Code from module c-strcase: 7233 # Code from module c-strcase:
7230 # Code from module careadlinkat: 7234 # Code from module careadlinkat:
@@ -7247,6 +7251,7 @@ esac
7247 7251
7248 # Code from module extern-inline: 7252 # Code from module extern-inline:
7249 # Code from module faccessat: 7253 # Code from module faccessat:
7254 # Code from module fcntl:
7250 # Code from module fcntl-h: 7255 # Code from module fcntl-h:
7251 # Code from module fdatasync: 7256 # Code from module fdatasync:
7252 # Code from module fdopendir: 7257 # Code from module fdopendir:
@@ -7254,6 +7259,7 @@ esac
7254 # Code from module fpending: 7259 # Code from module fpending:
7255 # Code from module fstatat: 7260 # Code from module fstatat:
7256 # Code from module fsync: 7261 # Code from module fsync:
7262 # Code from module getdtablesize:
7257 # Code from module getgroups: 7263 # Code from module getgroups:
7258 # Code from module getloadavg: 7264 # Code from module getloadavg:
7259 # Code from module getopt-gnu: 7265 # Code from module getopt-gnu:
@@ -7262,7 +7268,6 @@ esac
7262 # Code from module gettime: 7268 # Code from module gettime:
7263 # Code from module gettimeofday: 7269 # Code from module gettimeofday:
7264 # Code from module group-member: 7270 # Code from module group-member:
7265 # Code from module ignore-value:
7266 # Code from module include_next: 7271 # Code from module include_next:
7267 # Code from module intprops: 7272 # Code from module intprops:
7268 # Code from module inttypes-incomplete: 7273 # Code from module inttypes-incomplete:
@@ -7276,6 +7281,7 @@ esac
7276 # Code from module nocrash: 7281 # Code from module nocrash:
7277 # Code from module openat-h: 7282 # Code from module openat-h:
7278 # Code from module pathmax: 7283 # Code from module pathmax:
7284 # Code from module pipe2:
7279 # Code from module pselect: 7285 # Code from module pselect:
7280 # Code from module pthread_sigmask: 7286 # Code from module pthread_sigmask:
7281 # Code from module putenv: 7287 # Code from module putenv:
@@ -10079,8 +10085,8 @@ $as_echo_n "checking whether Windows API headers are recent enough... " >&6; }
10079int 10085int
10080main () 10086main ()
10081{ 10087{
10082void test(PIMAGE_NT_HEADERS pHeader) 10088PIMAGE_NT_HEADERS pHeader;
10083 {PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader);} 10089 PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader)
10084 ; 10090 ;
10085 return 0; 10091 return 0;
10086} 10092}
@@ -11177,7 +11183,7 @@ $as_echo "#define HAVE_RSVG 1" >>confdefs.h
11177fi 11183fi
11178 11184
11179HAVE_IMAGEMAGICK=no 11185HAVE_IMAGEMAGICK=no
11180if test "${HAVE_X11}" = "yes"; then 11186if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes"; then
11181 if test "${with_imagemagick}" != "no"; then 11187 if test "${with_imagemagick}" != "no"; then
11182 ## 6.2.8 is the earliest version known to work, but earlier versions 11188 ## 6.2.8 is the earliest version known to work, but earlier versions
11183 ## might work - let us know if you find one. 11189 ## might work - let us know if you find one.
@@ -14655,14 +14661,14 @@ esac
14655 14661
14656 14662
14657 14663
14658for ac_func in gethostname \ 14664for ac_func in accept4 gethostname \
14659getrusage get_current_dir_name \ 14665getrusage get_current_dir_name \
14660lrand48 \ 14666lrand48 \
14661select getpagesize setlocale \ 14667select getpagesize setlocale \
14662getrlimit setrlimit shutdown getaddrinfo \ 14668getrlimit setrlimit shutdown getaddrinfo \
14663strsignal setitimer \ 14669strsignal setitimer \
14664sendto recvfrom getsockname getpeername getifaddrs freeifaddrs \ 14670sendto recvfrom getsockname getpeername getifaddrs freeifaddrs \
14665gai_strerror mkstemp getline getdelim sync \ 14671gai_strerror mkostemp mkstemp getline getdelim sync \
14666difftime posix_memalign \ 14672difftime posix_memalign \
14667getpwent endpwent getgrent endgrent \ 14673getpwent endpwent getgrent endgrent \
14668touchlock \ 14674touchlock \
@@ -16430,10 +16436,10 @@ $as_echo "#define UNIX98_PTYS 1" >>confdefs.h
16430 16436
16431 $as_echo "#define PTY_ITERATION int i; for (i = 0; i < 1; i++)" >>confdefs.h 16437 $as_echo "#define PTY_ITERATION int i; for (i = 0; i < 1; i++)" >>confdefs.h
16432 16438
16433 $as_echo "#define PTY_TTY_NAME_SPRINTF { char *ptyname = 0; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); if (grantpt (fd) != -1 && unlockpt (fd) != -1) ptyname = ptsname(fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (!ptyname) { close (fd); return -1; } snprintf (pty_name, sizeof pty_name, \"%s\", ptyname); }" >>confdefs.h 16439 $as_echo "#define PTY_TTY_NAME_SPRINTF { char *ptyname = 0; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); if (grantpt (fd) != -1 && unlockpt (fd) != -1) ptyname = ptsname(fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (!ptyname) { emacs_close (fd); return -1; } snprintf (pty_name, sizeof pty_name, \"%s\", ptyname); }" >>confdefs.h
16434 16440
16435 if test "x$ac_cv_func_posix_openpt" = xyes; then 16441 if test "x$ac_cv_func_posix_openpt" = xyes; then
16436 $as_echo "#define PTY_OPEN fd = posix_openpt (O_RDWR | O_NOCTTY)" >>confdefs.h 16442 $as_echo "#define PTY_OPEN fd = posix_openpt (O_RDWR | O_CLOEXEC | O_NOCTTY)" >>confdefs.h
16437 16443
16438 $as_echo "#define PTY_NAME_SPRINTF /**/" >>confdefs.h 16444 $as_echo "#define PTY_NAME_SPRINTF /**/" >>confdefs.h
16439 16445
@@ -18402,6 +18408,8 @@ $as_echo "$gl_cv_header_errno_h_EOVERFLOW" >&6; }
18402 REPLACE_OPENAT=0; 18408 REPLACE_OPENAT=0;
18403 18409
18404 18410
18411
18412
18405ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default" 18413ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default"
18406if test "x$ac_cv_type_mode_t" = x""yes; then : 18414if test "x$ac_cv_type_mode_t" = x""yes; then :
18407 18415
@@ -20692,6 +20700,8 @@ cat >>confdefs.h <<_ACEOF
20692_ACEOF 20700_ACEOF
20693 20701
20694 20702
20703
20704
20695 GNULIB_PSELECT=0; 20705 GNULIB_PSELECT=0;
20696 GNULIB_SELECT=0; 20706 GNULIB_SELECT=0;
20697 HAVE_PSELECT=1; 20707 HAVE_PSELECT=1;
@@ -21891,6 +21901,8 @@ _ACEOF
21891 21901
21892 21902
21893 21903
21904
21905
21894 if false; then 21906 if false; then
21895 GL_COND_LIBTOOL_TRUE= 21907 GL_COND_LIBTOOL_TRUE=
21896 GL_COND_LIBTOOL_FALSE='#' 21908 GL_COND_LIBTOOL_FALSE='#'
@@ -22441,6 +22453,169 @@ _ACEOF
22441 22453
22442 22454
22443 22455
22456 if test $ac_cv_func_fcntl = no; then
22457
22458
22459
22460 if test $ac_cv_func_fcntl = no; then
22461 HAVE_FCNTL=0
22462 else
22463 REPLACE_FCNTL=1
22464 fi
22465
22466 else
22467 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fcntl handles F_DUPFD correctly" >&5
22468$as_echo_n "checking whether fcntl handles F_DUPFD correctly... " >&6; }
22469if test "${gl_cv_func_fcntl_f_dupfd_works+set}" = set; then :
22470 $as_echo_n "(cached) " >&6
22471else
22472 if test "$cross_compiling" = yes; then :
22473 # Guess that it works on glibc systems
22474 case $host_os in #((
22475 *-gnu*) gl_cv_func_fcntl_f_dupfd_works="guessing yes";;
22476 *) gl_cv_func_fcntl_f_dupfd_works="guessing no";;
22477 esac
22478else
22479 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
22480/* end confdefs.h. */
22481
22482#include <fcntl.h>
22483#include <errno.h>
22484
22485int
22486main ()
22487{
22488int result = 0;
22489 if (fcntl (0, F_DUPFD, -1) != -1) result |= 1;
22490 if (errno != EINVAL) result |= 2;
22491 return result;
22492
22493 ;
22494 return 0;
22495}
22496_ACEOF
22497if ac_fn_c_try_run "$LINENO"; then :
22498 gl_cv_func_fcntl_f_dupfd_works=yes
22499else
22500 gl_cv_func_fcntl_f_dupfd_works=no
22501fi
22502rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
22503 conftest.$ac_objext conftest.beam conftest.$ac_ext
22504fi
22505
22506fi
22507{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fcntl_f_dupfd_works" >&5
22508$as_echo "$gl_cv_func_fcntl_f_dupfd_works" >&6; }
22509 case $gl_cv_func_fcntl_f_dupfd_works in
22510 *yes) ;;
22511 *)
22512
22513
22514 if test $ac_cv_func_fcntl = no; then
22515 HAVE_FCNTL=0
22516 else
22517 REPLACE_FCNTL=1
22518 fi
22519
22520
22521$as_echo "#define FCNTL_DUPFD_BUGGY 1" >>confdefs.h
22522 ;;
22523 esac
22524
22525 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fcntl understands F_DUPFD_CLOEXEC" >&5
22526$as_echo_n "checking whether fcntl understands F_DUPFD_CLOEXEC... " >&6; }
22527if test "${gl_cv_func_fcntl_f_dupfd_cloexec+set}" = set; then :
22528 $as_echo_n "(cached) " >&6
22529else
22530 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
22531/* end confdefs.h. */
22532
22533#include <fcntl.h>
22534#ifndef F_DUPFD_CLOEXEC
22535choke me
22536#endif
22537
22538int
22539main ()
22540{
22541
22542 ;
22543 return 0;
22544}
22545_ACEOF
22546if ac_fn_c_try_compile "$LINENO"; then :
22547 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
22548/* end confdefs.h. */
22549
22550#ifdef __linux__
22551/* The Linux kernel only added F_DUPFD_CLOEXEC in 2.6.24, so we always replace
22552 it to support the semantics on older kernels that failed with EINVAL. */
22553choke me
22554#endif
22555
22556int
22557main ()
22558{
22559
22560 ;
22561 return 0;
22562}
22563_ACEOF
22564if ac_fn_c_try_compile "$LINENO"; then :
22565 gl_cv_func_fcntl_f_dupfd_cloexec=yes
22566else
22567 gl_cv_func_fcntl_f_dupfd_cloexec="needs runtime check"
22568fi
22569rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
22570else
22571 gl_cv_func_fcntl_f_dupfd_cloexec=no
22572fi
22573rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
22574fi
22575{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fcntl_f_dupfd_cloexec" >&5
22576$as_echo "$gl_cv_func_fcntl_f_dupfd_cloexec" >&6; }
22577 if test "$gl_cv_func_fcntl_f_dupfd_cloexec" != yes; then
22578
22579
22580
22581 if test $ac_cv_func_fcntl = no; then
22582 HAVE_FCNTL=0
22583 else
22584 REPLACE_FCNTL=1
22585 fi
22586
22587 fi
22588 fi
22589
22590
22591 if test $HAVE_FCNTL = 0 || test $REPLACE_FCNTL = 1; then
22592
22593
22594
22595
22596
22597
22598
22599
22600 gl_LIBOBJS="$gl_LIBOBJS fcntl.$ac_objext"
22601
22602 fi
22603
22604
22605
22606
22607
22608 GNULIB_FCNTL=1
22609
22610
22611
22612
22613
22614
22615
22616
22617
22618
22444 22619
22445 22620
22446 22621
@@ -24150,6 +24325,27 @@ $as_echo "$gl_cv_func_working_mktime" >&6; }
24150 24325
24151 24326
24152 24327
24328
24329 if test $ac_cv_func_pipe2 != yes; then
24330 HAVE_PIPE2=0
24331 fi
24332
24333
24334
24335
24336
24337
24338 GNULIB_PIPE2=1
24339
24340
24341
24342
24343
24344
24345
24346
24347
24348
24153 if test $ac_cv_func_pselect = yes; then 24349 if test $ac_cv_func_pselect = yes; then
24154 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether signature of pselect conforms to POSIX" >&5 24350 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether signature of pselect conforms to POSIX" >&5
24155$as_echo_n "checking whether signature of pselect conforms to POSIX... " >&6; } 24351$as_echo_n "checking whether signature of pselect conforms to POSIX... " >&6; }
@@ -25637,7 +25833,8 @@ else
25637 25833
25638 /* Test _Alignas only on platforms where gnulib can help. */ 25834 /* Test _Alignas only on platforms where gnulib can help. */
25639 #if \ 25835 #if \
25640 (__GNUC__ || __IBMC__ || __IBMCPP__ \ 25836 ((defined __cplusplus && 201103 <= __cplusplus) \
25837 || __GNUC__ || __IBMC__ || __IBMCPP__ || __ICC \
25641 || 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER) 25838 || 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER)
25642 struct alignas_test { char c; char alignas (8) alignas_8; }; 25839 struct alignas_test { char c; char alignas (8) alignas_8; };
25643 char test_alignas[offsetof (struct alignas_test, alignas_8) == 8 25840 char test_alignas[offsetof (struct alignas_test, alignas_8) == 8
@@ -27260,6 +27457,7 @@ $as_echo "#define FUTIMESAT_NULL_BUG 1" >>confdefs.h
27260 gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b=false 27457 gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b=false
27261 gl_gnulib_enabled_dosname=false 27458 gl_gnulib_enabled_dosname=false
27262 gl_gnulib_enabled_euidaccess=false 27459 gl_gnulib_enabled_euidaccess=false
27460 gl_gnulib_enabled_getdtablesize=false
27263 gl_gnulib_enabled_getgroups=false 27461 gl_gnulib_enabled_getgroups=false
27264 gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=false 27462 gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=false
27265 gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1=false 27463 gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1=false
@@ -27269,7 +27467,6 @@ $as_echo "#define FUTIMESAT_NULL_BUG 1" >>confdefs.h
27269 gl_gnulib_enabled_stat=false 27467 gl_gnulib_enabled_stat=false
27270 gl_gnulib_enabled_strtoll=false 27468 gl_gnulib_enabled_strtoll=false
27271 gl_gnulib_enabled_strtoull=false 27469 gl_gnulib_enabled_strtoull=false
27272 gl_gnulib_enabled_verify=false
27273 gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=false 27470 gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=false
27274 func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b () 27471 func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b ()
27275 { 27472 {
@@ -27549,6 +27746,43 @@ done
27549 fi 27746 fi
27550 fi 27747 fi
27551 } 27748 }
27749 func_gl_gnulib_m4code_getdtablesize ()
27750 {
27751 if ! $gl_gnulib_enabled_getdtablesize; then
27752
27753
27754
27755 if test $ac_cv_func_getdtablesize != yes; then
27756 HAVE_GETDTABLESIZE=0
27757 fi
27758
27759 if test $HAVE_GETDTABLESIZE = 0; then
27760
27761
27762
27763
27764
27765
27766
27767
27768 gl_LIBOBJS="$gl_LIBOBJS getdtablesize.$ac_objext"
27769
27770 :
27771 fi
27772
27773
27774
27775
27776
27777 GNULIB_GETDTABLESIZE=1
27778
27779
27780
27781
27782
27783 gl_gnulib_enabled_getdtablesize=true
27784 fi
27785 }
27552 func_gl_gnulib_m4code_getgroups () 27786 func_gl_gnulib_m4code_getgroups ()
27553 { 27787 {
27554 if ! $gl_gnulib_enabled_getgroups; then 27788 if ! $gl_gnulib_enabled_getgroups; then
@@ -27971,9 +28205,6 @@ $as_echo "#define REPLACE_FUNC_STAT_FILE 1" >>confdefs.h
27971 if test $REPLACE_STAT = 1; then 28205 if test $REPLACE_STAT = 1; then
27972 func_gl_gnulib_m4code_pathmax 28206 func_gl_gnulib_m4code_pathmax
27973 fi 28207 fi
27974 if test $REPLACE_STAT = 1; then
27975 func_gl_gnulib_m4code_verify
27976 fi
27977 fi 28208 fi
27978 } 28209 }
27979 func_gl_gnulib_m4code_strtoll () 28210 func_gl_gnulib_m4code_strtoll ()
@@ -28080,12 +28311,6 @@ done
28080 gl_gnulib_enabled_strtoull=true 28311 gl_gnulib_enabled_strtoull=true
28081 fi 28312 fi
28082 } 28313 }
28083 func_gl_gnulib_m4code_verify ()
28084 {
28085 if ! $gl_gnulib_enabled_verify; then
28086 gl_gnulib_enabled_verify=true
28087 fi
28088 }
28089 func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec () 28314 func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec ()
28090 { 28315 {
28091 if ! $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec; then 28316 if ! $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec; then
@@ -28104,6 +28329,9 @@ done
28104 if test $HAVE_FACCESSAT = 0; then 28329 if test $HAVE_FACCESSAT = 0; then
28105 func_gl_gnulib_m4code_03e0aaad4cb89ca757653bd367a6ccb7 28330 func_gl_gnulib_m4code_03e0aaad4cb89ca757653bd367a6ccb7
28106 fi 28331 fi
28332 if test $HAVE_FCNTL = 0 || test $REPLACE_FCNTL = 1; then
28333 func_gl_gnulib_m4code_getdtablesize
28334 fi
28107 if test $HAVE_FDOPENDIR = 0; then 28335 if test $HAVE_FDOPENDIR = 0; then
28108 func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b 28336 func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b
28109 fi 28337 fi
@@ -28140,15 +28368,9 @@ done
28140 if { test $HAVE_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; } && test $ac_cv_type_long_long_int = yes; then 28368 if { test $HAVE_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; } && test $ac_cv_type_long_long_int = yes; then
28141 func_gl_gnulib_m4code_strtoll 28369 func_gl_gnulib_m4code_strtoll
28142 fi 28370 fi
28143 if test $HAVE_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; then
28144 func_gl_gnulib_m4code_verify
28145 fi
28146 if test $ac_cv_func_strtoumax = no && test $ac_cv_type_unsigned_long_long_int = yes; then 28371 if test $ac_cv_func_strtoumax = no && test $ac_cv_type_unsigned_long_long_int = yes; then
28147 func_gl_gnulib_m4code_strtoull 28372 func_gl_gnulib_m4code_strtoull
28148 fi 28373 fi
28149 if test $ac_cv_func_strtoumax = no; then
28150 func_gl_gnulib_m4code_verify
28151 fi
28152 28374
28153 if $gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b; then 28375 if $gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b; then
28154 gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b_TRUE= 28376 gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b_TRUE=
@@ -28174,6 +28396,14 @@ else
28174 gl_GNULIB_ENABLED_euidaccess_FALSE= 28396 gl_GNULIB_ENABLED_euidaccess_FALSE=
28175fi 28397fi
28176 28398
28399 if $gl_gnulib_enabled_getdtablesize; then
28400 gl_GNULIB_ENABLED_getdtablesize_TRUE=
28401 gl_GNULIB_ENABLED_getdtablesize_FALSE='#'
28402else
28403 gl_GNULIB_ENABLED_getdtablesize_TRUE='#'
28404 gl_GNULIB_ENABLED_getdtablesize_FALSE=
28405fi
28406
28177 if $gl_gnulib_enabled_getgroups; then 28407 if $gl_gnulib_enabled_getgroups; then
28178 gl_GNULIB_ENABLED_getgroups_TRUE= 28408 gl_GNULIB_ENABLED_getgroups_TRUE=
28179 gl_GNULIB_ENABLED_getgroups_FALSE='#' 28409 gl_GNULIB_ENABLED_getgroups_FALSE='#'
@@ -28246,14 +28476,6 @@ else
28246 gl_GNULIB_ENABLED_strtoull_FALSE= 28476 gl_GNULIB_ENABLED_strtoull_FALSE=
28247fi 28477fi
28248 28478
28249 if $gl_gnulib_enabled_verify; then
28250 gl_GNULIB_ENABLED_verify_TRUE=
28251 gl_GNULIB_ENABLED_verify_FALSE='#'
28252else
28253 gl_GNULIB_ENABLED_verify_TRUE='#'
28254 gl_GNULIB_ENABLED_verify_FALSE=
28255fi
28256
28257 if $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec; then 28479 if $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec; then
28258 gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_TRUE= 28480 gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_TRUE=
28259 gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_FALSE='#' 28481 gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_FALSE='#'
@@ -28715,6 +28937,10 @@ if test -z "${gl_GNULIB_ENABLED_euidaccess_TRUE}" && test -z "${gl_GNULIB_ENABLE
28715 as_fn_error "conditional \"gl_GNULIB_ENABLED_euidaccess\" was never defined. 28937 as_fn_error "conditional \"gl_GNULIB_ENABLED_euidaccess\" was never defined.
28716Usually this means the macro was only invoked conditionally." "$LINENO" 5 28938Usually this means the macro was only invoked conditionally." "$LINENO" 5
28717fi 28939fi
28940if test -z "${gl_GNULIB_ENABLED_getdtablesize_TRUE}" && test -z "${gl_GNULIB_ENABLED_getdtablesize_FALSE}"; then
28941 as_fn_error "conditional \"gl_GNULIB_ENABLED_getdtablesize\" was never defined.
28942Usually this means the macro was only invoked conditionally." "$LINENO" 5
28943fi
28718if test -z "${gl_GNULIB_ENABLED_getgroups_TRUE}" && test -z "${gl_GNULIB_ENABLED_getgroups_FALSE}"; then 28944if test -z "${gl_GNULIB_ENABLED_getgroups_TRUE}" && test -z "${gl_GNULIB_ENABLED_getgroups_FALSE}"; then
28719 as_fn_error "conditional \"gl_GNULIB_ENABLED_getgroups\" was never defined. 28945 as_fn_error "conditional \"gl_GNULIB_ENABLED_getgroups\" was never defined.
28720Usually this means the macro was only invoked conditionally." "$LINENO" 5 28946Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -28751,10 +28977,6 @@ if test -z "${gl_GNULIB_ENABLED_strtoull_TRUE}" && test -z "${gl_GNULIB_ENABLED_
28751 as_fn_error "conditional \"gl_GNULIB_ENABLED_strtoull\" was never defined. 28977 as_fn_error "conditional \"gl_GNULIB_ENABLED_strtoull\" was never defined.
28752Usually this means the macro was only invoked conditionally." "$LINENO" 5 28978Usually this means the macro was only invoked conditionally." "$LINENO" 5
28753fi 28979fi
28754if test -z "${gl_GNULIB_ENABLED_verify_TRUE}" && test -z "${gl_GNULIB_ENABLED_verify_FALSE}"; then
28755 as_fn_error "conditional \"gl_GNULIB_ENABLED_verify\" was never defined.
28756Usually this means the macro was only invoked conditionally." "$LINENO" 5
28757fi
28758if test -z "${gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_TRUE}" && test -z "${gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_FALSE}"; then 28980if test -z "${gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_TRUE}" && test -z "${gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_FALSE}"; then
28759 as_fn_error "conditional \"gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec\" was never defined. 28981 as_fn_error "conditional \"gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec\" was never defined.
28760Usually this means the macro was only invoked conditionally." "$LINENO" 5 28982Usually this means the macro was only invoked conditionally." "$LINENO" 5
diff --git a/configure.ac b/configure.ac
index 90f9f3a4799..73dcdb06bee 100644
--- a/configure.ac
+++ b/configure.ac
@@ -211,7 +211,8 @@ AC_ARG_WITH([file-notification],[AS_HELP_STRING([--with-file-notification=LIB],
211 w | w3 | w32 ) val=w32 ;; 211 w | w3 | w32 ) val=w32 ;;
212 * ) AC_MSG_ERROR([`--with-file-notification=$withval' is invalid; 212 * ) AC_MSG_ERROR([`--with-file-notification=$withval' is invalid;
213this option's value should be `yes', `no', `gfile', `inotify' or `w32'. 213this option's value should be `yes', `no', `gfile', `inotify' or `w32'.
214`yes' is a synonym for `w32' on MS-Windows, and for `gfile' otherwise.]) 214`yes' is a synonym for `w32' on MS-Windows, for `no' on Nextstep,
215otherwise for the first of `gfile' or `inotify' that is usable.])
215 ;; 216 ;;
216 esac 217 esac
217 with_file_notification=$val 218 with_file_notification=$val
@@ -1635,8 +1636,8 @@ if test "${opsys}" = "mingw32"; then
1635 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1636 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1636 #include <windows.h> 1637 #include <windows.h>
1637 #include <usp10.h>]], 1638 #include <usp10.h>]],
1638 [[void test(PIMAGE_NT_HEADERS pHeader) 1639 [[PIMAGE_NT_HEADERS pHeader;
1639 {PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader);}]])], 1640 PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader)]])],
1640 [emacs_cv_w32api=yes 1641 [emacs_cv_w32api=yes
1641 HAVE_W32=yes], 1642 HAVE_W32=yes],
1642 emacs_cv_w32api=no) 1643 emacs_cv_w32api=no)
@@ -2041,7 +2042,7 @@ if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${opsys}" =
2041fi 2042fi
2042 2043
2043HAVE_IMAGEMAGICK=no 2044HAVE_IMAGEMAGICK=no
2044if test "${HAVE_X11}" = "yes"; then 2045if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes"; then
2045 if test "${with_imagemagick}" != "no"; then 2046 if test "${with_imagemagick}" != "no"; then
2046 ## 6.2.8 is the earliest version known to work, but earlier versions 2047 ## 6.2.8 is the earliest version known to work, but earlier versions
2047 ## might work - let us know if you find one. 2048 ## might work - let us know if you find one.
@@ -2312,51 +2313,57 @@ AC_SUBST(LIBGNUTLS_CFLAGS)
2312NOTIFY_OBJ= 2313NOTIFY_OBJ=
2313NOTIFY_SUMMARY=no 2314NOTIFY_SUMMARY=no
2314 2315
2315dnl Set defaults of $with_file_notification. 2316dnl FIXME? Don't auto-detect on NS, but do allow someone to specify
2316if test "${with_file_notification}" = "yes"; then 2317dnl a particular library. This doesn't make much sense?
2317 if test "${opsys}" = "mingw32"; then 2318if test "${with_ns}" = yes && test ${with_file_notification} = yes; then
2318 with_file_notification=w32 2319 with_file_notification=no
2319 else
2320 if test "${with_ns}" != yes; then
2321 with_file_notification=gfile
2322 fi
2323 fi
2324fi 2320fi
2325 2321
2322dnl MS Windows native file monitor is available for mingw32 only.
2323case $with_file_notification,$opsys in
2324 w32,* | yes,mingw32)
2325 AC_CHECK_HEADER(windows.h)
2326 if test "$ac_cv_header_windows_h" = yes ; then
2327 AC_DEFINE(HAVE_W32NOTIFY, 1, [Define to 1 to use w32notify.])
2328 NOTIFY_OBJ=w32notify.o
2329 NOTIFY_SUMMARY="yes (w32)"
2330 fi ;;
2331esac
2332
2326dnl g_file_monitor exists since glib 2.18. G_FILE_MONITOR_EVENT_MOVED 2333dnl g_file_monitor exists since glib 2.18. G_FILE_MONITOR_EVENT_MOVED
2327dnl has been added in glib 2.24. It has been tested under 2334dnl has been added in glib 2.24. It has been tested under
2328dnl GNU/Linux only. We take precedence over inotify, but this makes 2335dnl GNU/Linux only. We take precedence over inotify, but this makes
2329dnl only sense when glib has been compiled with inotify support. How 2336dnl only sense when glib has been compiled with inotify support. How
2330dnl to check? 2337dnl to check?
2331if test "${with_file_notification}" = "gfile"; then 2338case $with_file_notification,$NOTIFY_OBJ in
2332 PKG_CHECK_MODULES(GFILENOTIFY, gio-2.0 >= 2.24, HAVE_GFILENOTIFY=yes, HAVE_GFILENOTIFY=no) 2339 gfile, | yes,)
2333 if test "$HAVE_GFILENOTIFY" = "yes"; then 2340 PKG_CHECK_MODULES(GFILENOTIFY, gio-2.0 >= 2.24, HAVE_GFILENOTIFY=yes, HAVE_GFILENOTIFY=no)
2334 AC_DEFINE(HAVE_GFILENOTIFY, 1, [Define to 1 if using GFile.]) 2341 if test "$HAVE_GFILENOTIFY" = "yes"; then
2335 NOTIFY_OBJ=gfilenotify.o 2342 AC_DEFINE(HAVE_GFILENOTIFY, 1, [Define to 1 if using GFile.])
2336 NOTIFY_SUMMARY="yes -lgio (gfile)" 2343 NOTIFY_OBJ=gfilenotify.o
2337 fi 2344 NOTIFY_SUMMARY="yes -lgio (gfile)"
2338fi 2345 fi ;;
2346esac
2347
2339dnl inotify is only available on GNU/Linux. 2348dnl inotify is only available on GNU/Linux.
2340if test "${with_file_notification}" = "inotify"; then 2349case $with_file_notification,$NOTIFY_OBJ in
2341 AC_CHECK_HEADER(sys/inotify.h) 2350 inotify, | yes,)
2342 if test "$ac_cv_header_sys_inotify_h" = yes ; then 2351 AC_CHECK_HEADER(sys/inotify.h)
2343 AC_CHECK_FUNC(inotify_init1) 2352 if test "$ac_cv_header_sys_inotify_h" = yes ; then
2344 if test "$ac_cv_func_inotify_init1" = yes; then 2353 AC_CHECK_FUNC(inotify_init1)
2345 AC_DEFINE(HAVE_INOTIFY, 1, [Define to 1 to use inotify.]) 2354 if test "$ac_cv_func_inotify_init1" = yes; then
2346 NOTIFY_OBJ=inotify.o 2355 AC_DEFINE(HAVE_INOTIFY, 1, [Define to 1 to use inotify.])
2347 NOTIFY_SUMMARY="yes -lglibc (inotify)" 2356 NOTIFY_OBJ=inotify.o
2348 fi 2357 NOTIFY_SUMMARY="yes -lglibc (inotify)"
2349 fi 2358 fi
2350fi 2359 fi ;;
2351dnl MS Windows native file monitor is available for mingw32 only. 2360esac
2352if test "${with_file_notification}" = "w32"; then 2361
2353 AC_CHECK_HEADER(windows.h) 2362case $with_file_notification,$NOTIFY_OBJ in
2354 if test "$ac_cv_header_windows_h" = yes ; then 2363 yes,* | no,* | *,?*) ;;
2355 AC_DEFINE(HAVE_W32NOTIFY, 1, [Define to 1 to use w32notify.]) 2364 *) AC_MSG_ERROR([File notification `$with_file_notification' requested but requirements not found.]) ;;
2356 NOTIFY_OBJ=w32notify.o 2365esac
2357 NOTIFY_SUMMARY="yes (w32)" 2366
2358 fi
2359fi
2360if test -n "$NOTIFY_OBJ"; then 2367if test -n "$NOTIFY_OBJ"; then
2361 AC_DEFINE(USE_FILE_NOTIFY, 1, [Define to 1 if using file notifications.]) 2368 AC_DEFINE(USE_FILE_NOTIFY, 1, [Define to 1 if using file notifications.])
2362fi 2369fi
@@ -3237,14 +3244,14 @@ esac
3237AC_SUBST(BLESSMAIL_TARGET) 3244AC_SUBST(BLESSMAIL_TARGET)
3238 3245
3239 3246
3240AC_CHECK_FUNCS(gethostname \ 3247AC_CHECK_FUNCS(accept4 gethostname \
3241getrusage get_current_dir_name \ 3248getrusage get_current_dir_name \
3242lrand48 \ 3249lrand48 \
3243select getpagesize setlocale \ 3250select getpagesize setlocale \
3244getrlimit setrlimit shutdown getaddrinfo \ 3251getrlimit setrlimit shutdown getaddrinfo \
3245strsignal setitimer \ 3252strsignal setitimer \
3246sendto recvfrom getsockname getpeername getifaddrs freeifaddrs \ 3253sendto recvfrom getsockname getpeername getifaddrs freeifaddrs \
3247gai_strerror mkstemp getline getdelim sync \ 3254gai_strerror mkostemp mkstemp getline getdelim sync \
3248difftime posix_memalign \ 3255difftime posix_memalign \
3249getpwent endpwent getgrent endgrent \ 3256getpwent endpwent getgrent endgrent \
3250touchlock \ 3257touchlock \
@@ -3931,10 +3938,10 @@ case $opsys in
3931 AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)]) 3938 AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)])
3932 dnl Note that grantpt and unlockpt may fork. We must block SIGCHLD 3939 dnl Note that grantpt and unlockpt may fork. We must block SIGCHLD
3933 dnl to prevent sigchld_handler from intercepting the child's death. 3940 dnl to prevent sigchld_handler from intercepting the child's death.
3934 AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptyname = 0; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); if (grantpt (fd) != -1 && unlockpt (fd) != -1) ptyname = ptsname(fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (!ptyname) { close (fd); return -1; } snprintf (pty_name, sizeof pty_name, "%s", ptyname); }]) 3941 AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptyname = 0; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); if (grantpt (fd) != -1 && unlockpt (fd) != -1) ptyname = ptsname(fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (!ptyname) { emacs_close (fd); return -1; } snprintf (pty_name, sizeof pty_name, "%s", ptyname); }])
3935 dnl if HAVE_POSIX_OPENPT 3942 dnl if HAVE_POSIX_OPENPT
3936 if test "x$ac_cv_func_posix_openpt" = xyes; then 3943 if test "x$ac_cv_func_posix_openpt" = xyes; then
3937 AC_DEFINE(PTY_OPEN, [fd = posix_openpt (O_RDWR | O_NOCTTY)]) 3944 AC_DEFINE(PTY_OPEN, [fd = posix_openpt (O_RDWR | O_CLOEXEC | O_NOCTTY)])
3938 AC_DEFINE(PTY_NAME_SPRINTF, []) 3945 AC_DEFINE(PTY_NAME_SPRINTF, [])
3939 dnl if HAVE_GETPT 3946 dnl if HAVE_GETPT
3940 elif test "x$ac_cv_func_getpt" = xyes; then 3947 elif test "x$ac_cv_func_getpt" = xyes; then
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index e4bc6eb5bcc..f8b7406c427 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,8 @@
12013-07-10 Paul Eggert <eggert@cs.ucla.edu>
2
3 Timestamp fixes for undo (Bug#14824).
4 * text.texi (Undo): Document (t . 0) and (t . -1) in buffer-undo-list.
5
12013-07-06 Eli Zaretskii <eliz@gnu.org> 62013-07-06 Eli Zaretskii <eliz@gnu.org>
2 7
3 * nonascii.texi (Text Representations): Document that 8 * nonascii.texi (Text Representations): Document that
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index c10458b39ae..7cace70ad07 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -1250,14 +1250,18 @@ reinsert it is @code{(abs @var{position})}. If @var{position} is
1250positive, point was at the beginning of the deleted text, otherwise it 1250positive, point was at the beginning of the deleted text, otherwise it
1251was at the end. 1251was at the end.
1252 1252
1253@item (t @var{sec-high} @var{sec-low} @var{microsec} @var{picosec}) 1253@item (t . @var{time-flag})
1254This kind of element indicates that an unmodified buffer became 1254This kind of element indicates that an unmodified buffer became
1255modified. The list @code{(@var{sec-high} @var{sec-low} @var{microsec} 1255modified. A @var{time-flag} of the form
1256@code{(@var{sec-high} @var{sec-low} @var{microsec}
1256@var{picosec})} represents the visited file's modification time as of 1257@var{picosec})} represents the visited file's modification time as of
1257when it was previously visited or saved, using the same format as 1258when it was previously visited or saved, using the same format as
1258@code{current-time}; see @ref{Time of Day}. @code{primitive-undo} uses those 1259@code{current-time}; see @ref{Time of Day}.
1260A @var{time-flag} of 0 means the buffer does not correspond to any file;
1261@minus{}1 means the visited file previously did not exist.
1262@code{primitive-undo} uses these
1259values to determine whether to mark the buffer as unmodified once again; 1263values to determine whether to mark the buffer as unmodified once again;
1260it does so only if the file's modification time matches those numbers. 1264it does so only if the file's status matches that of @var{time-flag}.
1261 1265
1262@item (nil @var{property} @var{value} @var{beg} . @var{end}) 1266@item (nil @var{property} @var{value} @var{beg} . @var{end})
1263This kind of element records a change in a text property. 1267This kind of element records a change in a text property.
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog
index e4a66e19877..2fe1914f926 100644
--- a/doc/misc/ChangeLog
+++ b/doc/misc/ChangeLog
@@ -1,3 +1,24 @@
12013-07-08 Tassilo Horn <tsdh@gnu.org>
2
3 * gnus.texi (lines): Correct description of
4 `gnus-registry-track-extra's default value. Mention
5 `gnus-registry-remove-extra-data'.
6
72013-07-06 Lars Ingebrigtsen <larsi@gnus.org>
8
9 * gnus.texi (Group Parameters): Mention regexp
10 substitutions (bug#11688).
11
122013-07-06 Nathan Trapuzzano <nbtrap@nbtrap.com> (tiny change)
13
14 * gnus.texi (Generic Marking Commands): Fix grammar (bug#13368).
15
162013-07-06 Lars Ingebrigtsen <larsi@gnus.org>
17
18 * gnus.texi (Emacsen): Fix version.
19
20 * gnus-faq.texi (FAQ 1-6): Mention the correct Emacs version.
21
12013-07-06 Glenn Morris <rgm@gnu.org> 222013-07-06 Glenn Morris <rgm@gnu.org>
2 23
3 * mh-e.texi: Fix external links. 24 * mh-e.texi: Fix external links.
diff --git a/doc/misc/gnus-faq.texi b/doc/misc/gnus-faq.texi
index ff29647d166..1a0469c14f4 100644
--- a/doc/misc/gnus-faq.texi
+++ b/doc/misc/gnus-faq.texi
@@ -222,10 +222,9 @@ Which version of Emacs do I need?
222 222
223@subsubheading Answer 223@subsubheading Answer
224 224
225Gnus 5.10 requires an Emacs version that is greater than or equal 225Gnus 5.13 requires an Emacs version that is greater than or equal
226to Emacs 20.7 or XEmacs 21.1. 226to Emacs 23.1 or XEmacs 21.1, although there are some features that
227The development versions of Gnus (aka No Gnus) requires Emacs 21 227only work on Emacs 24.
228or XEmacs 21.4.
229 228
230@node FAQ 1-7 229@node FAQ 1-7
231@subsubheading Question 1.7 230@subsubheading Question 1.7
diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi
index 3d4bd378869..e5ba2c19eec 100644
--- a/doc/misc/gnus.texi
+++ b/doc/misc/gnus.texi
@@ -3091,6 +3091,12 @@ if address "sender" ["name@@one.org", "else@@two.org"] @{
3091@} 3091@}
3092@end example 3092@end example
3093 3093
3094You can also use regexp expansions in the rules:
3095
3096@example
3097(sieve header :regex "list-id" "<c++std-\\1.accu.org>")
3098@end example
3099
3094See @pxref{Sieve Commands} for commands and variables that might be of 3100See @pxref{Sieve Commands} for commands and variables that might be of
3095interest in relation to the sieve parameter. 3101interest in relation to the sieve parameter.
3096 3102
@@ -6380,10 +6386,10 @@ The default is @code{t}.
6380@node Generic Marking Commands 6386@node Generic Marking Commands
6381@subsection Generic Marking Commands 6387@subsection Generic Marking Commands
6382 6388
6383Some people would like the command that ticks an article (@kbd{!}) go to 6389Some people would like the command that ticks an article (@kbd{!}) to
6384the next article. Others would like it to go to the next unread 6390go to the next article. Others would like it to go to the next unread
6385article. Yet others would like it to stay on the current article. And 6391article. Yet others would like it to stay on the current article.
6386even though I haven't heard of anybody wanting it to go to the 6392And even though I haven't heard of anybody wanting it to go to the
6387previous (unread) article, I'm sure there are people that want that as 6393previous (unread) article, I'm sure there are people that want that as
6388well. 6394well.
6389 6395
@@ -26000,9 +26006,13 @@ following variables.
26000 26006
26001@defvar gnus-registry-track-extra 26007@defvar gnus-registry-track-extra
26002This is a list of symbols, so it's best to change it from the 26008This is a list of symbols, so it's best to change it from the
26003Customize interface. By default it's @code{(subject sender)}, which 26009Customize interface. By default it's @code{(subject sender recipient)},
26004may work for you. It can be annoying if your mail flow is large and 26010which may work for you. It can be annoying if your mail flow is large
26005people don't stick to the same groups. 26011and people don't stick to the same groups.
26012
26013When you decide to stop tracking any of those extra data, you can use
26014the command @code{gnus-registry-remove-extra-data} to purge it from
26015the existing registry entries.
26006@end defvar 26016@end defvar
26007 26017
26008@defvar gnus-registry-split-strategy 26018@defvar gnus-registry-split-strategy
@@ -26575,7 +26585,7 @@ This version of Gnus should work on:
26575@itemize @bullet 26585@itemize @bullet
26576 26586
26577@item 26587@item
26578Emacs 21.1 and up. 26588Emacs 23.1 and up.
26579 26589
26580@item 26590@item
26581XEmacs 21.4 and up. 26591XEmacs 21.4 and up.
diff --git a/etc/ChangeLog b/etc/ChangeLog
index 9dbcc70ee01..73bc76a1ff8 100644
--- a/etc/ChangeLog
+++ b/etc/ChangeLog
@@ -1,3 +1,12 @@
12013-07-10 Paul Eggert <eggert@cs.ucla.edu>
2
3 Timestamp fixes for undo (Bug#14824).
4 * NEWS: Changes to visited-file-modtime, set-visited-file-modtime.
5
62013-07-08 Jan Djärv <jan.h.d@swipnet.se>
7
8 * NEWS: NS can be built with ImageMagick.
9
12013-07-06 Juanma Barranquero <lekktu@gmail.com> 102013-07-06 Juanma Barranquero <lekktu@gmail.com>
2 11
3 * NEWS: Document new "generic commands" support. 12 * NEWS: Document new "generic commands" support.
diff --git a/etc/NEWS b/etc/NEWS
index d2aa27947cc..873af89a7a8 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -29,37 +29,22 @@ build time, like libacl on GNU/Linux. To prevent this, use the
29configure option `--disable-acl'. 29configure option `--disable-acl'.
30 30
31** Emacs can be compiled with file notification support. 31** Emacs can be compiled with file notification support.
32The configure option `--with-file-notification=LIB' enables file 32This happens by default if a suitable system library is found at
33notification support in Emacs. This option's value should be `yes', 33build time. To prevent this, use the configure option
34`no', `gfile', `inotify' or `w32'. `yes' is a synonym for `w32' on 34`--with-file-notification-no'. See below for file-notify features.
35MS-Windows, and for `gfile' otherwise. The default value is `yes'. 35FIXME? This feature is not available for the Nextstep port. (?)
36 36
37** The configure option --with-crt-dir has been removed. 37** The configure option --with-crt-dir has been removed.
38It is no longer needed, as the crt*.o files are no longer linked 38It is no longer needed, as the crt*.o files are no longer linked
39specially. 39specially.
40 40
41** Emacs for MS-Windows can now be built by running the configure script
42using the MSYS environment and MinGW development tools.
43This is from now on the preferred method of building Emacs on
44MS-Windows. The Windows-specific configure.bat and makefile.w32-in
45files are deprecated. See the file nt/INSTALL.MSYS for detailed
46instructions.
47
48Using the Posix configure script and Makefile's also means a change in
49the directory structure of the Emacs installation on Windows. It is
50now the same as on GNU and Unix systems. In particular, the auxiliary
51programs, such as cmdproxy.exe and hexl.exe, are in
52libexec/emacs/VERSION/i686-pc-mingw32 (where VERSION is the Emacs
53version), version-independent site-lisp is in share/emacs/site-lisp,
54version-specific Lisp files are in share/emacs/VERSION/lisp and in
55share/emacs/VERSION/site-lisp, Info docs are in share/info, and data
56files are in share/emacs/VERSION/etc. (Emacs knows about all these
57directories and will find the files in there automatically; there's no
58need to set any variables due to this change.)
59
60** Directories passed to configure option `--enable-locallisppath' are 41** Directories passed to configure option `--enable-locallisppath' are
61no longer created during installation. 42no longer created during installation.
62 43
44---
45** Emacs for NS (OSX, GNUStep) can be built with ImageMagick support.
46pkg-config is required to find ImageMagick libraries.
47
63 48
64* Startup Changes in Emacs 24.4 49* Startup Changes in Emacs 24.4
65 50
@@ -533,9 +518,14 @@ alist of extended attributes as returned by the new function
533`file-extended-attributes'. The attributes can be applied to another 518`file-extended-attributes'. The attributes can be applied to another
534file using `set-file-extended-attributes'. 519file using `set-file-extended-attributes'.
535 520
521** `visited-file-modtime' now returns -1 for nonexistent files.
522Formerly it returned a list (-1 LOW USEC PSEC), but this was ambiguous
523in the presence of files with negative time stamps.
536 524
537* Lisp Changes in Emacs 24.4 525* Lisp Changes in Emacs 24.4
538 526
527** New hook `tty-setup-hook'.
528
539+++ 529+++
540** New macro with-eval-after-load. Like eval-after-load, but better behaved. 530** New macro with-eval-after-load. Like eval-after-load, but better behaved.
541 531
@@ -607,6 +597,9 @@ Emacs uses `image-default-frame-delay'.
607*** New functions `image-current-frame' and `image-show-frame' for getting 597*** New functions `image-current-frame' and `image-show-frame' for getting
608and setting the current frame of a multi-frame image. 598and setting the current frame of a multi-frame image.
609 599
600** The function `set-visited-file-modtime' now accepts a 0 or -1 argument
601with the same interpretation as the returned value of `visited-file-modtime'.
602
610** time-to-seconds is not obsolete any more. 603** time-to-seconds is not obsolete any more.
611** New function special-form-p. 604** New function special-form-p.
612** Docstrings can be made dynamic by adding a `dynamic-docstring-function' 605** Docstrings can be made dynamic by adding a `dynamic-docstring-function'
@@ -650,6 +643,25 @@ meant to be used by other packages.
650 643
651* Changes in Emacs 24.4 on Non-Free Operating Systems 644* Changes in Emacs 24.4 on Non-Free Operating Systems
652 645
646** Emacs for MS-Windows can now be built by running the configure script
647using the MSYS environment and MinGW development tools.
648This is from now on the preferred method of building Emacs on
649MS-Windows. The Windows-specific configure.bat and makefile.w32-in
650files are deprecated. See the file nt/INSTALL.MSYS for detailed
651instructions.
652
653Using the Posix configure script and Makefile's also means a change in
654the directory structure of the Emacs installation on Windows. It is
655now the same as on GNU and Unix systems. In particular, the auxiliary
656programs, such as cmdproxy.exe and hexl.exe, are in
657libexec/emacs/VERSION/i686-pc-mingw32 (where VERSION is the Emacs
658version), version-independent site-lisp is in share/emacs/site-lisp,
659version-specific Lisp files are in share/emacs/VERSION/lisp and in
660share/emacs/VERSION/site-lisp, Info docs are in share/info, and data
661files are in share/emacs/VERSION/etc. (Emacs knows about all these
662directories and will find the files in there automatically; there's no
663need to set any variables due to this change.)
664
653+++ 665+++
654** The "generate a backtrace on fatal error" feature now works on MS Windows. 666** The "generate a backtrace on fatal error" feature now works on MS Windows.
655The backtrace is written to the 'emacs_backtrace.txt' file in the 667The backtrace is written to the 'emacs_backtrace.txt' file in the
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index 4a43a741e54..f41c23df5d2 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,3 +1,15 @@
12013-07-10 Paul Eggert <eggert@cs.ucla.edu>
2
3 Port to C89.
4 * ebrowse.c (USAGE): Remove macro with too-long string literal ...
5 (usage_message): ... and replace it with this new static constant
6 containing multiple literals. All uses changed.
7 * emacsclient.c (print_help_and_exit):
8 Rewrite to avoid string literals longer than the C89 limits.
9 (start_daemon_and_retry_set_socket):
10 Rewrite to avoid non-constant array initializer.
11 * make-docfile.c (enum global_type): Omit trailing comma.
12
12013-07-02 Paul Eggert <eggert@cs.ucla.edu> 132013-07-02 Paul Eggert <eggert@cs.ucla.edu>
2 14
3 Prefer plain 'static' to 'static inline' (Bug#12541). 15 Prefer plain 'static' to 'static inline' (Bug#12541).
@@ -6134,7 +6146,7 @@
6134 6146
61351995-06-13 Geoff Voelker <voelker@cs.washington.edu> 61471995-06-13 Geoff Voelker <voelker@cs.washington.edu>
6136 6148
6137 * etags.c (process_file,absolute_filename): Handle filenames 6149 * etags.c (process_file, absolute_filename): Handle filenames
6138 starting with a drive letter. 6150 starting with a drive letter.
6139 6151
6140 * makefile.nt (install): Copy wakeup.exe properly. 6152 * makefile.nt (install): Copy wakeup.exe properly.
@@ -6161,12 +6173,12 @@
61611995-05-25 Geoff Voelker <voelker@cs.washington.edu> 61731995-05-25 Geoff Voelker <voelker@cs.washington.edu>
6162 6174
6163 * makefile.nt (LIBS): Use BASE_LIBS. 6175 * makefile.nt (LIBS): Use BASE_LIBS.
6164 (make-docfile.exe,hexl.exe,wakeup.exe,etags.exe): Don't depend 6176 (make-docfile.exe, hexl.exe, wakeup.exe, etags.exe): Don't depend
6165 upon LIBS. 6177 upon LIBS.
6166 (DOC): Use del instead of rm. 6178 (DOC): Use del instead of rm.
6167 (DOC) [WINDOWS95]: Use DOC. 6179 (DOC) [WINDOWS95]: Use DOC.
6168 (clean): Handle MSVC aux files. 6180 (clean): Handle MSVC aux files.
6169 (config.h,paths.h): Use $(CP) instead of cp. 6181 (config.h, paths.h): Use $(CP) instead of cp.
6170 (config.h): Use $(CONFIG_H) 6182 (config.h): Use $(CONFIG_H)
6171 (make-docfile.obj): Depend upon config.h. 6183 (make-docfile.obj): Depend upon config.h.
6172 Clean up comments. 6184 Clean up comments.
diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c
index 407f769afc8..216865c3800 100644
--- a/lib-src/ebrowse.c
+++ b/lib-src/ebrowse.c
@@ -3481,7 +3481,9 @@ open_file (char *file)
3481 3481
3482/* Display usage information and exit program. */ 3482/* Display usage information and exit program. */
3483 3483
3484#define USAGE "\ 3484static char const *const usage_message[] =
3485 {
3486 "\
3485Usage: ebrowse [options] {files}\n\ 3487Usage: ebrowse [options] {files}\n\
3486\n\ 3488\n\
3487 -a, --append append output to existing file\n\ 3489 -a, --append append output to existing file\n\
@@ -3489,6 +3491,8 @@ Usage: ebrowse [options] {files}\n\
3489 -I, --search-path=LIST set search path for input files\n\ 3491 -I, --search-path=LIST set search path for input files\n\
3490 -m, --min-regexp-length=N set minimum regexp length to N\n\ 3492 -m, --min-regexp-length=N set minimum regexp length to N\n\
3491 -M, --max-regexp-length=N set maximum regexp length to N\n\ 3493 -M, --max-regexp-length=N set maximum regexp length to N\n\
3494",
3495 "\
3492 -n, --no-nested-classes exclude nested classes\n\ 3496 -n, --no-nested-classes exclude nested classes\n\
3493 -o, --output-file=FILE set output file name to FILE\n\ 3497 -o, --output-file=FILE set output file name to FILE\n\
3494 -p, --position-info print info about position in file\n\ 3498 -p, --position-info print info about position in file\n\
@@ -3498,12 +3502,16 @@ Usage: ebrowse [options] {files}\n\
3498 -x, --no-regexps don't record regular expressions\n\ 3502 -x, --no-regexps don't record regular expressions\n\
3499 --help display this help\n\ 3503 --help display this help\n\
3500 --version display version info\n\ 3504 --version display version info\n\
3505\n\
3501" 3506"
3507 };
3502 3508
3503static _Noreturn void 3509static _Noreturn void
3504usage (int error) 3510usage (int error)
3505{ 3511{
3506 puts (USAGE); 3512 int i;
3513 for (i = 0; i < sizeof usage_message / sizeof *usage_message; i++)
3514 fputs (usage_message[i], stdout);
3507 exit (error ? EXIT_FAILURE : EXIT_SUCCESS); 3515 exit (error ? EXIT_FAILURE : EXIT_SUCCESS);
3508} 3516}
3509 3517
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 898e8d69b07..74ccfa26259 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -630,7 +630,7 @@ print_help_and_exit (void)
630 Please try to preserve them; otherwise the output is very hard to read 630 Please try to preserve them; otherwise the output is very hard to read
631 when using emacsclientw. */ 631 when using emacsclientw. */
632 message (FALSE, 632 message (FALSE,
633 "Usage: %s [OPTIONS] FILE...\n\ 633 "Usage: %s [OPTIONS] FILE...\n%s%s%s", progname, "\
634Tell the Emacs server to visit the specified files.\n\ 634Tell the Emacs server to visit the specified files.\n\
635Every FILE can be either just a FILENAME or [+LINE[:COLUMN]] FILENAME.\n\ 635Every FILE can be either just a FILENAME or [+LINE[:COLUMN]] FILENAME.\n\
636\n\ 636\n\
@@ -640,6 +640,7 @@ The following OPTIONS are accepted:\n\
640-nw, -t, --tty Open a new Emacs frame on the current terminal\n\ 640-nw, -t, --tty Open a new Emacs frame on the current terminal\n\
641-c, --create-frame Create a new frame instead of trying to\n\ 641-c, --create-frame Create a new frame instead of trying to\n\
642 use the current Emacs frame\n\ 642 use the current Emacs frame\n\
643", "\
643-F ALIST, --frame-parameters=ALIST\n\ 644-F ALIST, --frame-parameters=ALIST\n\
644 Set the parameters of a new frame\n\ 645 Set the parameters of a new frame\n\
645-e, --eval Evaluate the FILE arguments as ELisp expressions\n\ 646-e, --eval Evaluate the FILE arguments as ELisp expressions\n\
@@ -647,6 +648,7 @@ The following OPTIONS are accepted:\n\
647-q, --quiet Don't display messages on success\n\ 648-q, --quiet Don't display messages on success\n\
648-d DISPLAY, --display=DISPLAY\n\ 649-d DISPLAY, --display=DISPLAY\n\
649 Visit the file in the given display\n\ 650 Visit the file in the given display\n\
651", "\
650--parent-id=ID Open in parent window ID, via XEmbed\n" 652--parent-id=ID Open in parent window ID, via XEmbed\n"
651#ifndef NO_SOCKETS_IN_FILE_SYSTEM 653#ifndef NO_SOCKETS_IN_FILE_SYSTEM
652"-s SOCKET, --socket-name=SOCKET\n\ 654"-s SOCKET, --socket-name=SOCKET\n\
@@ -661,7 +663,7 @@ The following OPTIONS are accepted:\n\
661 mode and try connecting again\n" 663 mode and try connecting again\n"
662#endif /* not WINDOWSNT */ 664#endif /* not WINDOWSNT */
663"\n\ 665"\n\
664Report bugs with M-x report-emacs-bug.\n", progname); 666Report bugs with M-x report-emacs-bug.\n");
665 exit (EXIT_SUCCESS); 667 exit (EXIT_SUCCESS);
666} 668}
667 669
@@ -1509,7 +1511,10 @@ start_daemon_and_retry_set_socket (void)
1509 { 1511 {
1510 char emacs[] = "emacs"; 1512 char emacs[] = "emacs";
1511 char daemon_option[] = "--daemon"; 1513 char daemon_option[] = "--daemon";
1512 char *d_argv[] = {emacs, daemon_option, 0 }; 1514 char *d_argv[3];
1515 d_argv[0] = emacs;
1516 d_argv[1] = daemon_option;
1517 d_argv[2] = 0;
1513 if (socket_name != NULL) 1518 if (socket_name != NULL)
1514 { 1519 {
1515 /* Pass --daemon=socket_name as argument. */ 1520 /* Pass --daemon=socket_name as argument. */
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c
index 9bc91bc4f77..73d1a0eb31d 100644
--- a/lib-src/make-docfile.c
+++ b/lib-src/make-docfile.c
@@ -555,7 +555,7 @@ enum global_type
555 LISP_OBJECT, 555 LISP_OBJECT,
556 EMACS_INTEGER, 556 EMACS_INTEGER,
557 BOOLEAN, 557 BOOLEAN,
558 FUNCTION, 558 FUNCTION
559}; 559};
560 560
561/* A single global. */ 561/* A single global. */
diff --git a/lib/binary-io.c b/lib/binary-io.c
new file mode 100644
index 00000000000..8bbdb44d121
--- /dev/null
+++ b/lib/binary-io.c
@@ -0,0 +1,3 @@
1#include <config.h>
2#define BINARY_IO_INLINE _GL_EXTERN_INLINE
3#include "binary-io.h"
diff --git a/lib/binary-io.h b/lib/binary-io.h
new file mode 100644
index 00000000000..317fe3d3c20
--- /dev/null
+++ b/lib/binary-io.h
@@ -0,0 +1,72 @@
1/* Binary mode I/O.
2 Copyright (C) 2001, 2003, 2005, 2008-2013 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17#ifndef _BINARY_H
18#define _BINARY_H
19
20/* For systems that distinguish between text and binary I/O.
21 O_BINARY is guaranteed by the gnulib <fcntl.h>. */
22#include <fcntl.h>
23
24/* The MSVC7 <stdio.h> doesn't like to be included after '#define fileno ...',
25 so we include it here first. */
26#include <stdio.h>
27
28_GL_INLINE_HEADER_BEGIN
29#ifndef BINARY_IO_INLINE
30# define BINARY_IO_INLINE _GL_INLINE
31#endif
32
33/* set_binary_mode (fd, mode)
34 sets the binary/text I/O mode of file descriptor fd to the given mode
35 (must be O_BINARY or O_TEXT) and returns the previous mode. */
36#if O_BINARY
37# if defined __EMX__ || defined __DJGPP__ || defined __CYGWIN__
38# include <io.h> /* declares setmode() */
39# define set_binary_mode setmode
40# else
41# define set_binary_mode _setmode
42# undef fileno
43# define fileno _fileno
44# endif
45#else
46 /* On reasonable systems, binary I/O is the only choice. */
47 /* Use a function rather than a macro, to avoid gcc warnings
48 "warning: statement with no effect". */
49BINARY_IO_INLINE int
50set_binary_mode (int fd, int mode)
51{
52 (void) fd;
53 (void) mode;
54 return O_BINARY;
55}
56#endif
57
58/* SET_BINARY (fd);
59 changes the file descriptor fd to perform binary I/O. */
60#ifdef __DJGPP__
61# include <unistd.h> /* declares isatty() */
62 /* Avoid putting stdin/stdout in binary mode if it is connected to
63 the console, because that would make it impossible for the user
64 to interrupt the program through Ctrl-C or Ctrl-Break. */
65# define SET_BINARY(fd) ((void) (!isatty (fd) ? (set_binary_mode (fd, O_BINARY), 0) : 0))
66#else
67# define SET_BINARY(fd) ((void) set_binary_mode (fd, O_BINARY))
68#endif
69
70_GL_INLINE_HEADER_END
71
72#endif /* _BINARY_H */
diff --git a/lib/fcntl.c b/lib/fcntl.c
new file mode 100644
index 00000000000..735fa66f4d7
--- /dev/null
+++ b/lib/fcntl.c
@@ -0,0 +1,311 @@
1/* Provide file descriptor control.
2
3 Copyright (C) 2009-2013 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18/* Written by Eric Blake <ebb9@byu.net>. */
19
20#include <config.h>
21
22/* Specification. */
23#include <fcntl.h>
24
25#include <errno.h>
26#include <limits.h>
27#include <stdarg.h>
28#include <unistd.h>
29
30#if !HAVE_FCNTL
31# define rpl_fcntl fcntl
32#endif
33#undef fcntl
34
35#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
36/* Get declarations of the native Windows API functions. */
37# define WIN32_LEAN_AND_MEAN
38# include <windows.h>
39
40/* Get _get_osfhandle. */
41# include "msvc-nothrow.h"
42
43/* Upper bound on getdtablesize(). See lib/getdtablesize.c. */
44# define OPEN_MAX_MAX 0x10000
45
46/* Duplicate OLDFD into the first available slot of at least NEWFD,
47 which must be positive, with FLAGS determining whether the duplicate
48 will be inheritable. */
49static int
50dupfd (int oldfd, int newfd, int flags)
51{
52 /* Mingw has no way to create an arbitrary fd. Iterate until all
53 file descriptors less than newfd are filled up. */
54 HANDLE curr_process = GetCurrentProcess ();
55 HANDLE old_handle = (HANDLE) _get_osfhandle (oldfd);
56 unsigned char fds_to_close[OPEN_MAX_MAX / CHAR_BIT];
57 unsigned int fds_to_close_bound = 0;
58 int result;
59 BOOL inherit = flags & O_CLOEXEC ? FALSE : TRUE;
60 int mode;
61
62 if (newfd < 0 || getdtablesize () <= newfd)
63 {
64 errno = EINVAL;
65 return -1;
66 }
67 if (old_handle == INVALID_HANDLE_VALUE
68 || (mode = setmode (oldfd, O_BINARY)) == -1)
69 {
70 /* oldfd is not open, or is an unassigned standard file
71 descriptor. */
72 errno = EBADF;
73 return -1;
74 }
75 setmode (oldfd, mode);
76 flags |= mode;
77
78 for (;;)
79 {
80 HANDLE new_handle;
81 int duplicated_fd;
82 unsigned int index;
83
84 if (!DuplicateHandle (curr_process, /* SourceProcessHandle */
85 old_handle, /* SourceHandle */
86 curr_process, /* TargetProcessHandle */
87 (PHANDLE) &new_handle, /* TargetHandle */
88 (DWORD) 0, /* DesiredAccess */
89 inherit, /* InheritHandle */
90 DUPLICATE_SAME_ACCESS)) /* Options */
91 {
92 /* TODO: Translate GetLastError () into errno. */
93 errno = EMFILE;
94 result = -1;
95 break;
96 }
97 duplicated_fd = _open_osfhandle ((intptr_t) new_handle, flags);
98 if (duplicated_fd < 0)
99 {
100 CloseHandle (new_handle);
101 errno = EMFILE;
102 result = -1;
103 break;
104 }
105 if (newfd <= duplicated_fd)
106 {
107 result = duplicated_fd;
108 break;
109 }
110
111 /* Set the bit duplicated_fd in fds_to_close[]. */
112 index = (unsigned int) duplicated_fd / CHAR_BIT;
113 if (fds_to_close_bound <= index)
114 {
115 if (sizeof fds_to_close <= index)
116 /* Need to increase OPEN_MAX_MAX. */
117 abort ();
118 memset (fds_to_close + fds_to_close_bound, '\0',
119 index + 1 - fds_to_close_bound);
120 fds_to_close_bound = index + 1;
121 }
122 fds_to_close[index] |= 1 << ((unsigned int) duplicated_fd % CHAR_BIT);
123 }
124
125 /* Close the previous fds that turned out to be too small. */
126 {
127 int saved_errno = errno;
128 unsigned int duplicated_fd;
129
130 for (duplicated_fd = 0;
131 duplicated_fd < fds_to_close_bound * CHAR_BIT;
132 duplicated_fd++)
133 if ((fds_to_close[duplicated_fd / CHAR_BIT]
134 >> (duplicated_fd % CHAR_BIT))
135 & 1)
136 close (duplicated_fd);
137
138 errno = saved_errno;
139 }
140
141# if REPLACE_FCHDIR
142 if (0 <= result)
143 result = _gl_register_dup (oldfd, result);
144# endif
145 return result;
146}
147#endif /* W32 */
148
149/* Perform the specified ACTION on the file descriptor FD, possibly
150 using the argument ARG further described below. This replacement
151 handles the following actions, and forwards all others on to the
152 native fcntl. An unrecognized ACTION returns -1 with errno set to
153 EINVAL.
154
155 F_DUPFD - duplicate FD, with int ARG being the minimum target fd.
156 If successful, return the duplicate, which will be inheritable;
157 otherwise return -1 and set errno.
158
159 F_DUPFD_CLOEXEC - duplicate FD, with int ARG being the minimum
160 target fd. If successful, return the duplicate, which will not be
161 inheritable; otherwise return -1 and set errno.
162
163 F_GETFD - ARG need not be present. If successful, return a
164 non-negative value containing the descriptor flags of FD (only
165 FD_CLOEXEC is portable, but other flags may be present); otherwise
166 return -1 and set errno. */
167
168int
169rpl_fcntl (int fd, int action, /* arg */...)
170{
171 va_list arg;
172 int result = -1;
173 va_start (arg, action);
174 switch (action)
175 {
176
177#if !HAVE_FCNTL
178 case F_DUPFD:
179 {
180 int target = va_arg (arg, int);
181 result = dupfd (fd, target, 0);
182 break;
183 }
184#elif FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR
185 case F_DUPFD:
186 {
187 int target = va_arg (arg, int);
188 /* Detect invalid target; needed for cygwin 1.5.x. */
189 if (target < 0 || getdtablesize () <= target)
190 errno = EINVAL;
191 else
192 {
193 /* Haiku alpha 2 loses fd flags on original. */
194 int flags = fcntl (fd, F_GETFD);
195 if (flags < 0)
196 {
197 result = -1;
198 break;
199 }
200 result = fcntl (fd, action, target);
201 if (0 <= result && fcntl (fd, F_SETFD, flags) == -1)
202 {
203 int saved_errno = errno;
204 close (result);
205 result = -1;
206 errno = saved_errno;
207 }
208# if REPLACE_FCHDIR
209 if (0 <= result)
210 result = _gl_register_dup (fd, result);
211# endif
212 }
213 break;
214 } /* F_DUPFD */
215#endif /* FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR */
216
217 case F_DUPFD_CLOEXEC:
218 {
219 int target = va_arg (arg, int);
220
221#if !HAVE_FCNTL
222 result = dupfd (fd, target, O_CLOEXEC);
223 break;
224#else /* HAVE_FCNTL */
225 /* Try the system call first, if the headers claim it exists
226 (that is, if GNULIB_defined_F_DUPFD_CLOEXEC is 0), since we
227 may be running with a glibc that has the macro but with an
228 older kernel that does not support it. Cache the
229 information on whether the system call really works, but
230 avoid caching failure if the corresponding F_DUPFD fails
231 for any reason. 0 = unknown, 1 = yes, -1 = no. */
232 static int have_dupfd_cloexec = GNULIB_defined_F_DUPFD_CLOEXEC ? -1 : 0;
233 if (0 <= have_dupfd_cloexec)
234 {
235 result = fcntl (fd, action, target);
236 if (0 <= result || errno != EINVAL)
237 {
238 have_dupfd_cloexec = 1;
239# if REPLACE_FCHDIR
240 if (0 <= result)
241 result = _gl_register_dup (fd, result);
242# endif
243 }
244 else
245 {
246 result = rpl_fcntl (fd, F_DUPFD, target);
247 if (result < 0)
248 break;
249 have_dupfd_cloexec = -1;
250 }
251 }
252 else
253 result = rpl_fcntl (fd, F_DUPFD, target);
254 if (0 <= result && have_dupfd_cloexec == -1)
255 {
256 int flags = fcntl (result, F_GETFD);
257 if (flags < 0 || fcntl (result, F_SETFD, flags | FD_CLOEXEC) == -1)
258 {
259 int saved_errno = errno;
260 close (result);
261 errno = saved_errno;
262 result = -1;
263 }
264 }
265 break;
266#endif /* HAVE_FCNTL */
267 } /* F_DUPFD_CLOEXEC */
268
269#if !HAVE_FCNTL
270 case F_GETFD:
271 {
272# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
273 HANDLE handle = (HANDLE) _get_osfhandle (fd);
274 DWORD flags;
275 if (handle == INVALID_HANDLE_VALUE
276 || GetHandleInformation (handle, &flags) == 0)
277 errno = EBADF;
278 else
279 result = (flags & HANDLE_FLAG_INHERIT) ? 0 : FD_CLOEXEC;
280# else /* !W32 */
281 /* Use dup2 to reject invalid file descriptors. No way to
282 access this information, so punt. */
283 if (0 <= dup2 (fd, fd))
284 result = 0;
285# endif /* !W32 */
286 break;
287 } /* F_GETFD */
288#endif /* !HAVE_FCNTL */
289
290 /* Implementing F_SETFD on mingw is not trivial - there is no
291 API for changing the O_NOINHERIT bit on an fd, and merely
292 changing the HANDLE_FLAG_INHERIT bit on the underlying handle
293 can lead to odd state. It may be possible by duplicating the
294 handle, using _open_osfhandle with the right flags, then
295 using dup2 to move the duplicate onto the original, but that
296 is not supported for now. */
297
298 default:
299 {
300#if HAVE_FCNTL
301 void *p = va_arg (arg, void *);
302 result = fcntl (fd, action, p);
303#else
304 errno = EINVAL;
305#endif
306 break;
307 }
308 }
309 va_end (arg);
310 return result;
311}
diff --git a/lib/getdtablesize.c b/lib/getdtablesize.c
new file mode 100644
index 00000000000..9947405af61
--- /dev/null
+++ b/lib/getdtablesize.c
@@ -0,0 +1,86 @@
1/* getdtablesize() function for platforms that don't have it.
2 Copyright (C) 2008-2013 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include <unistd.h>
22
23#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
24
25#include <stdio.h>
26
27#include "msvc-inval.h"
28
29#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
30static int
31_setmaxstdio_nothrow (int newmax)
32{
33 int result;
34
35 TRY_MSVC_INVAL
36 {
37 result = _setmaxstdio (newmax);
38 }
39 CATCH_MSVC_INVAL
40 {
41 result = -1;
42 }
43 DONE_MSVC_INVAL;
44
45 return result;
46}
47# define _setmaxstdio _setmaxstdio_nothrow
48#endif
49
50/* Cache for the previous getdtablesize () result. */
51static int dtablesize;
52
53int
54getdtablesize (void)
55{
56 if (dtablesize == 0)
57 {
58 /* We are looking for the number N such that the valid file descriptors
59 are 0..N-1. It can be obtained through a loop as follows:
60 {
61 int fd;
62 for (fd = 3; fd < 65536; fd++)
63 if (dup2 (0, fd) == -1)
64 break;
65 return fd;
66 }
67 On Windows XP, the result is 2048.
68 The drawback of this loop is that it allocates memory for a libc
69 internal array that is never freed.
70
71 The number N can also be obtained as the upper bound for
72 _getmaxstdio (). _getmaxstdio () returns the maximum number of open
73 FILE objects. The sanity check in _setmaxstdio reveals the maximum
74 number of file descriptors. This too allocates memory, but it is
75 freed when we call _setmaxstdio with the original value. */
76 int orig_max_stdio = _getmaxstdio ();
77 unsigned int bound;
78 for (bound = 0x10000; _setmaxstdio (bound) < 0; bound = bound / 2)
79 ;
80 _setmaxstdio (orig_max_stdio);
81 dtablesize = bound;
82 }
83 return dtablesize;
84}
85
86#endif
diff --git a/lib/gnulib.mk b/lib/gnulib.mk
index 4a84b1db261..d053e15efc1 100644
--- a/lib/gnulib.mk
+++ b/lib/gnulib.mk
@@ -21,7 +21,7 @@
21# the same distribution terms as the rest of that program. 21# the same distribution terms as the rest of that program.
22# 22#
23# Generated by gnulib-tool. 23# Generated by gnulib-tool.
24# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=dup --avoid=fchdir --avoid=fcntl --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl-h fdatasync fdopendir filemode fstatat fsync getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings memrchr mktime pselect pthread_sigmask putenv qacl readlink readlinkat sig2str socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub unsetenv utimens warnings 24# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode fstatat fsync getloadavg getopt-gnu gettime gettimeofday intprops largefile lstat manywarnings memrchr mktime pipe2 pselect pthread_sigmask putenv qacl readlink readlinkat sig2str socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub unsetenv utimens warnings
25 25
26 26
27MOSTLYCLEANFILES += core *.stackdump 27MOSTLYCLEANFILES += core *.stackdump
@@ -75,6 +75,12 @@ EXTRA_libgnu_a_SOURCES += openat-proc.c
75 75
76## end gnulib module at-internal 76## end gnulib module at-internal
77 77
78## begin gnulib module binary-io
79
80libgnu_a_SOURCES += binary-io.h binary-io.c
81
82## end gnulib module binary-io
83
78## begin gnulib module c-ctype 84## begin gnulib module c-ctype
79 85
80libgnu_a_SOURCES += c-ctype.h c-ctype.c 86libgnu_a_SOURCES += c-ctype.h c-ctype.c
@@ -296,6 +302,15 @@ EXTRA_libgnu_a_SOURCES += at-func.c faccessat.c
296 302
297## end gnulib module faccessat 303## end gnulib module faccessat
298 304
305## begin gnulib module fcntl
306
307
308EXTRA_DIST += fcntl.c
309
310EXTRA_libgnu_a_SOURCES += fcntl.c
311
312## end gnulib module fcntl
313
299## begin gnulib module fcntl-h 314## begin gnulib module fcntl-h
300 315
301BUILT_SOURCES += fcntl.h 316BUILT_SOURCES += fcntl.h
@@ -384,6 +399,17 @@ EXTRA_libgnu_a_SOURCES += fsync.c
384 399
385## end gnulib module fsync 400## end gnulib module fsync
386 401
402## begin gnulib module getdtablesize
403
404if gl_GNULIB_ENABLED_getdtablesize
405
406endif
407EXTRA_DIST += getdtablesize.c
408
409EXTRA_libgnu_a_SOURCES += getdtablesize.c
410
411## end gnulib module getdtablesize
412
387## begin gnulib module getgroups 413## begin gnulib module getgroups
388 414
389if gl_GNULIB_ENABLED_getgroups 415if gl_GNULIB_ENABLED_getgroups
@@ -465,13 +491,6 @@ EXTRA_libgnu_a_SOURCES += group-member.c
465 491
466## end gnulib module group-member 492## end gnulib module group-member
467 493
468## begin gnulib module ignore-value
469
470
471EXTRA_DIST += ignore-value.h
472
473## end gnulib module ignore-value
474
475## begin gnulib module intprops 494## begin gnulib module intprops
476 495
477 496
@@ -568,6 +587,12 @@ EXTRA_DIST += pathmax.h
568 587
569## end gnulib module pathmax 588## end gnulib module pathmax
570 589
590## begin gnulib module pipe2
591
592libgnu_a_SOURCES += pipe2.c
593
594## end gnulib module pipe2
595
571## begin gnulib module pselect 596## begin gnulib module pselect
572 597
573 598
@@ -1704,9 +1729,7 @@ EXTRA_DIST += utimens.h
1704 1729
1705## begin gnulib module verify 1730## begin gnulib module verify
1706 1731
1707if gl_GNULIB_ENABLED_verify
1708 1732
1709endif
1710EXTRA_DIST += verify.h 1733EXTRA_DIST += verify.h
1711 1734
1712## end gnulib module verify 1735## end gnulib module verify
diff --git a/lib/ignore-value.h b/lib/ignore-value.h
deleted file mode 100644
index ebd6bf42f56..00000000000
--- a/lib/ignore-value.h
+++ /dev/null
@@ -1,48 +0,0 @@
1/* ignore a function return without a compiler warning
2
3 Copyright (C) 2008-2013 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18/* Written by Jim Meyering, Eric Blake and Pádraig Brady. */
19
20/* Use "ignore_value" to avoid a warning when using a function declared with
21 gcc's warn_unused_result attribute, but for which you really do want to
22 ignore the result. Traditionally, people have used a "(void)" cast to
23 indicate that a function's return value is deliberately unused. However,
24 if the function is declared with __attribute__((warn_unused_result)),
25 gcc issues a warning even with the cast.
26
27 Caution: most of the time, you really should heed gcc's warning, and
28 check the return value. However, in those exceptional cases in which
29 you're sure you know what you're doing, use this function.
30
31 For the record, here's one of the ignorable warnings:
32 "copy.c:233: warning: ignoring return value of 'fchown',
33 declared with attribute warn_unused_result". */
34
35#ifndef _GL_IGNORE_VALUE_H
36#define _GL_IGNORE_VALUE_H
37
38/* The __attribute__((__warn_unused_result__)) feature
39 is available in gcc versions 3.4 and newer,
40 while the typeof feature has been available since 2.7 at least. */
41#if 3 < __GNUC__ + (4 <= __GNUC_MINOR__)
42# define ignore_value(x) \
43 (__extension__ ({ __typeof__ (x) __x = (x); (void) __x; }))
44#else
45# define ignore_value(x) ((void) (x))
46#endif
47
48#endif
diff --git a/lib/pipe2.c b/lib/pipe2.c
new file mode 100644
index 00000000000..211d75545c0
--- /dev/null
+++ b/lib/pipe2.c
@@ -0,0 +1,168 @@
1/* Create a pipe, with specific opening flags.
2 Copyright (C) 2009-2013 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, see <http://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <unistd.h>
21
22#include <errno.h>
23#include <fcntl.h>
24
25#include "binary-io.h"
26#include "verify.h"
27
28#if GNULIB_defined_O_NONBLOCK
29# include "nonblocking.h"
30#endif
31
32#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
33/* Native Windows API. */
34
35# include <io.h>
36
37#endif
38
39int
40pipe2 (int fd[2], int flags)
41{
42 /* Mingw _pipe() corrupts fd on failure; also, if we succeed at
43 creating the pipe but later fail at changing fcntl, we want
44 to leave fd unchanged: http://austingroupbugs.net/view.php?id=467 */
45 int tmp[2];
46 tmp[0] = fd[0];
47 tmp[1] = fd[1];
48
49#if HAVE_PIPE2
50# undef pipe2
51 /* Try the system call first, if it exists. (We may be running with a glibc
52 that has the function but with an older kernel that lacks it.) */
53 {
54 /* Cache the information whether the system call really exists. */
55 static int have_pipe2_really; /* 0 = unknown, 1 = yes, -1 = no */
56 if (have_pipe2_really >= 0)
57 {
58 int result = pipe2 (fd, flags);
59 if (!(result < 0 && errno == ENOSYS))
60 {
61 have_pipe2_really = 1;
62 return result;
63 }
64 have_pipe2_really = -1;
65 }
66 }
67#endif
68
69 /* Check the supported flags. */
70 if ((flags & ~(O_CLOEXEC | O_NONBLOCK | O_BINARY | O_TEXT)) != 0)
71 {
72 errno = EINVAL;
73 return -1;
74 }
75
76#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
77/* Native Windows API. */
78
79 if (_pipe (fd, 4096, flags & ~O_NONBLOCK) < 0)
80 {
81 fd[0] = tmp[0];
82 fd[1] = tmp[1];
83 return -1;
84 }
85
86 /* O_NONBLOCK handling.
87 On native Windows platforms, O_NONBLOCK is defined by gnulib. Use the
88 functions defined by the gnulib module 'nonblocking'. */
89# if GNULIB_defined_O_NONBLOCK
90 if (flags & O_NONBLOCK)
91 {
92 if (set_nonblocking_flag (fd[0], true) != 0
93 || set_nonblocking_flag (fd[1], true) != 0)
94 goto fail;
95 }
96# else
97 {
98 verify (O_NONBLOCK == 0);
99 }
100# endif
101
102 return 0;
103
104#else
105/* Unix API. */
106
107 if (pipe (fd) < 0)
108 return -1;
109
110 /* POSIX <http://www.opengroup.org/onlinepubs/9699919799/functions/pipe.html>
111 says that initially, the O_NONBLOCK and FD_CLOEXEC flags are cleared on
112 both fd[0] and fd[1]. */
113
114 /* O_NONBLOCK handling.
115 On Unix platforms, O_NONBLOCK is defined by the system. Use fcntl(). */
116 if (flags & O_NONBLOCK)
117 {
118 int fcntl_flags;
119
120 if ((fcntl_flags = fcntl (fd[1], F_GETFL, 0)) < 0
121 || fcntl (fd[1], F_SETFL, fcntl_flags | O_NONBLOCK) == -1
122 || (fcntl_flags = fcntl (fd[0], F_GETFL, 0)) < 0
123 || fcntl (fd[0], F_SETFL, fcntl_flags | O_NONBLOCK) == -1)
124 goto fail;
125 }
126
127 if (flags & O_CLOEXEC)
128 {
129 int fcntl_flags;
130
131 if ((fcntl_flags = fcntl (fd[1], F_GETFD, 0)) < 0
132 || fcntl (fd[1], F_SETFD, fcntl_flags | FD_CLOEXEC) == -1
133 || (fcntl_flags = fcntl (fd[0], F_GETFD, 0)) < 0
134 || fcntl (fd[0], F_SETFD, fcntl_flags | FD_CLOEXEC) == -1)
135 goto fail;
136 }
137
138# if O_BINARY
139 if (flags & O_BINARY)
140 {
141 set_binary_mode (fd[1], O_BINARY);
142 set_binary_mode (fd[0], O_BINARY);
143 }
144 else if (flags & O_TEXT)
145 {
146 set_binary_mode (fd[1], O_TEXT);
147 set_binary_mode (fd[0], O_TEXT);
148 }
149# endif
150
151 return 0;
152
153#endif
154
155#if GNULIB_defined_O_NONBLOCK || \
156 !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
157 fail:
158 {
159 int saved_errno = errno;
160 close (fd[0]);
161 close (fd[1]);
162 fd[0] = tmp[0];
163 fd[1] = tmp[1];
164 errno = saved_errno;
165 return -1;
166 }
167#endif
168}
diff --git a/lib/stdalign.in.h b/lib/stdalign.in.h
index c3a67321b0e..7254a3dec17 100644
--- a/lib/stdalign.in.h
+++ b/lib/stdalign.in.h
@@ -41,13 +41,28 @@
41 are 4 unless the option '-malign-double' is used. 41 are 4 unless the option '-malign-double' is used.
42 42
43 The result cannot be used as a value for an 'enum' constant, if you 43 The result cannot be used as a value for an 'enum' constant, if you
44 want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc. */ 44 want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc.
45
46 Include <stddef.h> for offsetof. */
45#include <stddef.h> 47#include <stddef.h>
46#if defined __cplusplus 48
49/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other
50 standard headers, defines conflicting implementations of _Alignas
51 and _Alignof that are no better than ours; override them. */
52#undef _Alignas
53#undef _Alignof
54
55#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
56# ifdef __cplusplus
57# if 201103 <= __cplusplus
58# define _Alignof(type) alignof (type)
59# else
47 template <class __t> struct __alignof_helper { char __a; __t __b; }; 60 template <class __t> struct __alignof_helper { char __a; __t __b; };
48# define _Alignof(type) offsetof (__alignof_helper<type>, __b) 61# define _Alignof(type) offsetof (__alignof_helper<type>, __b)
49#else 62# endif
50# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) 63# else
64# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b)
65# endif
51#endif 66#endif
52#define alignof _Alignof 67#define alignof _Alignof
53#define __alignof_is_defined 1 68#define __alignof_is_defined 1
@@ -77,12 +92,16 @@
77 92
78 */ 93 */
79 94
80#if __GNUC__ || __IBMC__ || __IBMCPP__ || 0x5110 <= __SUNPRO_C 95#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
81# define _Alignas(a) __attribute__ ((__aligned__ (a))) 96# if defined __cplusplus && 201103 <= __cplusplus
82#elif 1300 <= _MSC_VER 97# define _Alignas(a) alignas (a)
83# define _Alignas(a) __declspec (align (a)) 98# elif __GNUC__ || __IBMC__ || __IBMCPP__ || __ICC || 0x5110 <= __SUNPRO_C
99# define _Alignas(a) __attribute__ ((__aligned__ (a)))
100# elif 1300 <= _MSC_VER
101# define _Alignas(a) __declspec (align (a))
102# endif
84#endif 103#endif
85#ifdef _Alignas 104#if defined _Alignas || (defined __STDC_VERSION && 201112 <= __STDC_VERSION__)
86# define alignas _Alignas 105# define alignas _Alignas
87# define __alignas_is_defined 1 106# define __alignas_is_defined 1
88#endif 107#endif
diff --git a/lib/verify.h b/lib/verify.h
index 03492efcd3f..d42d0750ee1 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -18,7 +18,7 @@
18/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */ 18/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */
19 19
20#ifndef _GL_VERIFY_H 20#ifndef _GL_VERIFY_H
21# define _GL_VERIFY_H 21#define _GL_VERIFY_H
22 22
23 23
24/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert works as per C11. 24/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert works as per C11.
@@ -31,16 +31,24 @@
31 Use this only with GCC. If we were willing to slow 'configure' 31 Use this only with GCC. If we were willing to slow 'configure'
32 down we could also use it with other compilers, but since this 32 down we could also use it with other compilers, but since this
33 affects only the quality of diagnostics, why bother? */ 33 affects only the quality of diagnostics, why bother? */
34# if (4 < __GNUC__ + (6 <= __GNUC_MINOR__) \ 34#if (4 < __GNUC__ + (6 <= __GNUC_MINOR__) \
35 && (201112L <= __STDC_VERSION__ || !defined __STRICT_ANSI__) \ 35 && (201112L <= __STDC_VERSION__ || !defined __STRICT_ANSI__) \
36 && !defined __cplusplus) 36 && !defined __cplusplus)
37# define _GL_HAVE__STATIC_ASSERT 1 37# define _GL_HAVE__STATIC_ASSERT 1
38# endif 38#endif
39/* The condition (99 < __GNUC__) is temporary, until we know about the 39/* The condition (99 < __GNUC__) is temporary, until we know about the
40 first G++ release that supports static_assert. */ 40 first G++ release that supports static_assert. */
41# if (99 < __GNUC__) && defined __cplusplus 41#if (99 < __GNUC__) && defined __cplusplus
42# define _GL_HAVE_STATIC_ASSERT 1 42# define _GL_HAVE_STATIC_ASSERT 1
43# endif 43#endif
44
45/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other
46 system headers, defines a conflicting _Static_assert that is no
47 better than ours; override it. */
48#ifndef _GL_HAVE_STATIC_ASSERT
49# include <stddef.h>
50# undef _Static_assert
51#endif
44 52
45/* Each of these macros verifies that its argument R is nonzero. To 53/* Each of these macros verifies that its argument R is nonzero. To
46 be portable, R should be an integer constant expression. Unlike 54 be portable, R should be an integer constant expression. Unlike
@@ -143,50 +151,50 @@
143 Use a template type to work around the problem. */ 151 Use a template type to work around the problem. */
144 152
145/* Concatenate two preprocessor tokens. */ 153/* Concatenate two preprocessor tokens. */
146# define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y) 154#define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y)
147# define _GL_CONCAT0(x, y) x##y 155#define _GL_CONCAT0(x, y) x##y
148 156
149/* _GL_COUNTER is an integer, preferably one that changes each time we 157/* _GL_COUNTER is an integer, preferably one that changes each time we
150 use it. Use __COUNTER__ if it works, falling back on __LINE__ 158 use it. Use __COUNTER__ if it works, falling back on __LINE__
151 otherwise. __LINE__ isn't perfect, but it's better than a 159 otherwise. __LINE__ isn't perfect, but it's better than a
152 constant. */ 160 constant. */
153# if defined __COUNTER__ && __COUNTER__ != __COUNTER__ 161#if defined __COUNTER__ && __COUNTER__ != __COUNTER__
154# define _GL_COUNTER __COUNTER__ 162# define _GL_COUNTER __COUNTER__
155# else 163#else
156# define _GL_COUNTER __LINE__ 164# define _GL_COUNTER __LINE__
157# endif 165#endif
158 166
159/* Generate a symbol with the given prefix, making it unique if 167/* Generate a symbol with the given prefix, making it unique if
160 possible. */ 168 possible. */
161# define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER) 169#define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER)
162 170
163/* Verify requirement R at compile-time, as an integer constant expression 171/* Verify requirement R at compile-time, as an integer constant expression
164 that returns 1. If R is false, fail at compile-time, preferably 172 that returns 1. If R is false, fail at compile-time, preferably
165 with a diagnostic that includes the string-literal DIAGNOSTIC. */ 173 with a diagnostic that includes the string-literal DIAGNOSTIC. */
166 174
167# define _GL_VERIFY_TRUE(R, DIAGNOSTIC) \ 175#define _GL_VERIFY_TRUE(R, DIAGNOSTIC) \
168 (!!sizeof (_GL_VERIFY_TYPE (R, DIAGNOSTIC))) 176 (!!sizeof (_GL_VERIFY_TYPE (R, DIAGNOSTIC)))
169 177
170# ifdef __cplusplus 178#ifdef __cplusplus
171# if !GNULIB_defined_struct__gl_verify_type 179# if !GNULIB_defined_struct__gl_verify_type
172template <int w> 180template <int w>
173 struct _gl_verify_type { 181 struct _gl_verify_type {
174 unsigned int _gl_verify_error_if_negative: w; 182 unsigned int _gl_verify_error_if_negative: w;
175 }; 183 };
176# define GNULIB_defined_struct__gl_verify_type 1 184# define GNULIB_defined_struct__gl_verify_type 1
177# endif
178# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
179 _gl_verify_type<(R) ? 1 : -1>
180# elif defined _GL_HAVE__STATIC_ASSERT
181# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
182 struct { \
183 _Static_assert (R, DIAGNOSTIC); \
184 int _gl_dummy; \
185 }
186# else
187# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
188 struct { unsigned int _gl_verify_error_if_negative: (R) ? 1 : -1; }
189# endif 185# endif
186# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
187 _gl_verify_type<(R) ? 1 : -1>
188#elif defined _GL_HAVE__STATIC_ASSERT
189# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
190 struct { \
191 _Static_assert (R, DIAGNOSTIC); \
192 int _gl_dummy; \
193 }
194#else
195# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
196 struct { unsigned int _gl_verify_error_if_negative: (R) ? 1 : -1; }
197#endif
190 198
191/* Verify requirement R at compile-time, as a declaration without a 199/* Verify requirement R at compile-time, as a declaration without a
192 trailing ';'. If R is false, fail at compile-time, preferably 200 trailing ';'. If R is false, fail at compile-time, preferably
@@ -195,23 +203,23 @@ template <int w>
195 Unfortunately, unlike C11, this implementation must appear as an 203 Unfortunately, unlike C11, this implementation must appear as an
196 ordinary declaration, and cannot appear inside struct { ... }. */ 204 ordinary declaration, and cannot appear inside struct { ... }. */
197 205
198# ifdef _GL_HAVE__STATIC_ASSERT 206#ifdef _GL_HAVE__STATIC_ASSERT
199# define _GL_VERIFY _Static_assert 207# define _GL_VERIFY _Static_assert
200# else 208#else
201# define _GL_VERIFY(R, DIAGNOSTIC) \ 209# define _GL_VERIFY(R, DIAGNOSTIC) \
202 extern int (*_GL_GENSYM (_gl_verify_function) (void)) \ 210 extern int (*_GL_GENSYM (_gl_verify_function) (void)) \
203 [_GL_VERIFY_TRUE (R, DIAGNOSTIC)] 211 [_GL_VERIFY_TRUE (R, DIAGNOSTIC)]
204# endif 212#endif
205 213
206/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */ 214/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */
207# ifdef _GL_STATIC_ASSERT_H 215#ifdef _GL_STATIC_ASSERT_H
208# if !defined _GL_HAVE__STATIC_ASSERT && !defined _Static_assert 216# if !defined _GL_HAVE__STATIC_ASSERT && !defined _Static_assert
209# define _Static_assert(R, DIAGNOSTIC) _GL_VERIFY (R, DIAGNOSTIC) 217# define _Static_assert(R, DIAGNOSTIC) _GL_VERIFY (R, DIAGNOSTIC)
210# endif 218# endif
211# if !defined _GL_HAVE_STATIC_ASSERT && !defined static_assert 219# if !defined _GL_HAVE_STATIC_ASSERT && !defined static_assert
212# define static_assert _Static_assert /* C11 requires this #define. */ 220# define static_assert _Static_assert /* C11 requires this #define. */
213# endif
214# endif 221# endif
222#endif
215 223
216/* @assert.h omit start@ */ 224/* @assert.h omit start@ */
217 225
@@ -229,18 +237,18 @@ template <int w>
229 237
230 verify_true is obsolescent; please use verify_expr instead. */ 238 verify_true is obsolescent; please use verify_expr instead. */
231 239
232# define verify_true(R) _GL_VERIFY_TRUE (R, "verify_true (" #R ")") 240#define verify_true(R) _GL_VERIFY_TRUE (R, "verify_true (" #R ")")
233 241
234/* Verify requirement R at compile-time. Return the value of the 242/* Verify requirement R at compile-time. Return the value of the
235 expression E. */ 243 expression E. */
236 244
237# define verify_expr(R, E) \ 245#define verify_expr(R, E) \
238 (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E)) 246 (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E))
239 247
240/* Verify requirement R at compile-time, as a declaration without a 248/* Verify requirement R at compile-time, as a declaration without a
241 trailing ';'. */ 249 trailing ';'. */
242 250
243# define verify(R) _GL_VERIFY (R, "verify (" #R ")") 251#define verify(R) _GL_VERIFY (R, "verify (" #R ")")
244 252
245/* @assert.h omit end@ */ 253/* @assert.h omit end@ */
246 254
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2402ea0cd1f..81bcb1d033c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,237 @@
12013-07-12 Dmitry Gutov <dgutov@yandex.ru>
2
3 * progmodes/ruby-mode.el (ruby-percent-literals-beg-re):
4 (ruby-syntax-expansion-allowed-p): Support array of symbols, for
5 Ruby 2.0.
6 (ruby-font-lock-keywords): Distinguish calls to functions with
7 module-like names from module references. Highlight character
8 literals.
9
102013-07-12 Sergio Durigan Junior <sergiodj@riseup.net> (tiny change)
11
12 * progmodes/gdb-mi.el (gdb-strip-string-backslash): New function.
13 (gdb-send): Handle continued commands. (Bug#14847)
14
152013-07-12 Juanma Barranquero <lekktu@gmail.com>
16
17 * desktop.el (desktop--v2s): Remove unused local variable.
18 (desktop-save-buffer): Make defvar-local; adjust docstring.
19 (desktop-auto-save-timeout, desktop-owner): Use ignore-errors.
20 (desktop-clear, desktop-save-buffer-p): Use string-match-p.
21
222013-07-12 Andreas Schwab <schwab@linux-m68k.org>
23
24 * emacs-lisp/map-ynp.el (map-y-or-n-p): Fix last change.
25
262013-07-12 Eli Zaretskii <eliz@gnu.org>
27
28 * simple.el (next-line, previous-line): Document TRY-VSCROLL and ARG.
29 (Bug#14842)
30
312013-07-12 Glenn Morris <rgm@gnu.org>
32
33 * doc-view.el: Require cl-lib at runtime too.
34 (doc-view-remove-if): Remove.
35 (doc-view-search-next-match, doc-view-search-previous-match):
36 Use cl-remove-if.
37
38 * edmacro.el: Require cl-lib at runtime too.
39 (edmacro-format-keys, edmacro-parse-keys): Use cl-mismatch, cl-subseq.
40 (edmacro-mismatch, edmacro-subseq): Remove.
41
42 * shadowfile.el: Require cl-lib.
43 (shadow-remove-if): Remove.
44 (shadow-set-cluster, shadow-shadows-of-1, shadow-remove-from-todo):
45 Use cl-remove-if.
46
47 * wid-edit.el: Require cl-lib.
48 (widget-choose): Use cl-remove-if.
49 (widget-remove-if): Remove.
50
51 * progmodes/ebrowse.el: Require cl-lib at runtime too.
52 (ebrowse-delete-if-not): Remove.
53 (ebrowse-browser-buffer-list, ebrowse-member-buffer-list)
54 (ebrowse-tree-buffer-list, ebrowse-same-tree-member-buffer-list):
55 Use cl-delete-if-not.
56
572013-07-12 Juanma Barranquero <lekktu@gmail.com>
58
59 * emacs-lisp/cl-macs.el (cl-multiple-value-bind, cl-multiple-value-setq)
60 (cl-the, cl-declare, cl-defstruct): Fix typos in docstrings.
61
622013-07-12 Leo Liu <sdl.web@gmail.com>
63
64 * ido.el (dired-do-copy, dired): Set 'ido property. (Bug#11954)
65
662013-07-11 Glenn Morris <rgm@gnu.org>
67
68 * emacs-lisp/edebug.el: Require cl-lib at run-time too.
69 (edebug-gensym-index, edebug-gensym):
70 Remove reimplementation of cl-gensym.
71 (edebug-make-enter-wrapper, edebug-make-form-wrapper): Use cl-gensym.
72
73 * thumbs.el: Require cl-lib at run-time too.
74 (thumbs-gensym-counter, thumbs-gensym):
75 Remove reimplementation of cl-gensym.
76 (thumbs-temp-file): Use cl-gensym.
77
78 * emacs-lisp/ert.el: Require cl-lib at runtime too.
79 (ert--cl-do-remf, ert--remprop, ert--remove-if-not)
80 (ert--intersection, ert--set-difference, ert--set-difference-eq)
81 (ert--union, ert--gensym-counter, ert--gensym-counter)
82 (ert--coerce-to-vector, ert--remove*, ert--string-position)
83 (ert--mismatch, ert--subseq): Remove reimplementations of cl funcs.
84 (ert-make-test-unbound, ert--expand-should-1)
85 (ert--expand-should, ert--should-error-handle-error)
86 (should-error, ert--explain-equal-rec)
87 (ert--plist-difference-explanation, ert-select-tests)
88 (ert--make-stats, ert--remove-from-list, ert--string-first-line):
89 Use cl-lib functions rather than reimplementations.
90
912013-07-11 Michael Albinus <michael.albinus@gmx.de>
92
93 * net/tramp.el (tramp-methods): Extend docstring.
94 (tramp-connection-timeout): New defcustom.
95 (tramp-error-with-buffer): Reset timestamp only when appropriate.
96 (with-tramp-progress-reporter): Simplify.
97 (tramp-process-actions): Improve messages.
98
99 * net/tramp-gvfs.el (tramp-gvfs-maybe-open-connection):
100 * net/tramp-sh.el (tramp-maybe-open-connection):
101 Use `tramp-connection-timeout'.
102 (tramp-methods) [su, sudo, ksu]: Add method specific timeouts.
103 (Bug#14808)
104
1052013-07-11 Leo Liu <sdl.web@gmail.com>
106
107 * ido.el (ido-read-file-name): Conform to the requirements of
108 read-file-name. (Bug#11861)
109 (ido-read-directory-name): Conform to the requirements of
110 read-directory-name.
111
1122013-07-11 Juanma Barranquero <lekktu@gmail.com>
113
114 * subr.el (delay-warning): New function.
115
1162013-07-10 Eli Zaretskii <eliz@gnu.org>
117
118 * simple.el (default-line-height): New function.
119 (line-move-partial, line-move): Use it instead of computing the
120 line height inline.
121 (line-move-partial): Always compute ROWH. If the last line is
122 partially-visible, but its text is completely visible, allow
123 cursor to enter such a partially-visible line.
124
1252013-07-10 Michael Albinus <michael.albinus@gmx.de>
126
127 Improve error messages. (Bug#14808)
128
129 * net/tramp.el (tramp-current-connection): New defvar, moved from
130 tramp-sh.el.
131 (tramp-message-show-progress-reporter-message): Removed, not
132 needed anymore.
133 (tramp-error-with-buffer): Show message in minibuffer. Discard
134 input before waiting. Reset connection timestamp.
135 (with-tramp-progress-reporter): Improve messages.
136 (tramp-process-actions): Use progress reporter. Delete process in
137 case of error. Improve messages.
138
139 * net/tramp-sh.el (tramp-barf-if-no-shell-prompt): Use
140 condition-case. Call `tramp-error-with-buffer' with vector and buffer.
141 (tramp-current-connection): Removed.
142 (tramp-maybe-open-connection): The car of
143 `tramp-current-connection' are the first 3 slots of the vector.
144
1452013-07-10 Teodor Zlatanov <tzz@lifelogs.com>
146
147 * progmodes/cfengine.el (cfengine3-indent-line): Do not indent
148 inside continued strings.
149
1502013-07-10 Paul Eggert <eggert@cs.ucla.edu>
151
152 Timestamp fixes for undo (Bug#14824).
153 * files.el (clear-visited-file-modtime): Move here from fileio.c.
154
1552013-07-10 Leo Liu <sdl.web@gmail.com>
156
157 * files.el (require-final-newline): Allow safe local value.
158 (Bug#14834)
159
1602013-07-09 Leo Liu <sdl.web@gmail.com>
161
162 * ido.el (ido-read-directory-name): Handle fallback.
163 (ido-read-file-name): Update DIR to ido-current-directory.
164 (Bug#1516)
165 (ido-add-virtual-buffers-to-list): Robustify. (Bug#14552)
166
1672013-07-09 Dmitry Gutov <dgutov@yandex.ru>
168
169 * progmodes/ruby-mode.el (ruby-font-lock-keywords): Remove extra
170 "autoload". Remove "warn lower camel case" section, previously
171 commented out. Highlight negation char. Do not highlight the
172 target in singleton method definitions.
173
1742013-07-08 Stefan Monnier <monnier@iro.umontreal.ca>
175
176 * faces.el (tty-setup-hook): Declare the hook.
177
178 * emacs-lisp/pcase.el (pcase--split-pred): Add `vars' argument to try
179 and detect when a guard/pred depends on local vars (bug#14773).
180 (pcase--u1): Adjust caller.
181
1822013-07-08 Eli Zaretskii <eliz@gnu.org>
183
184 * simple.el (line-move-partial, line-move): Account for
185 line-spacing.
186 (line-move-partial): Avoid setting vscroll when the last
187 partially-visible line in window is of default height.
188
1892013-07-08 Lars Magne Ingebrigtsen <larsi@gnus.org>
190
191 * net/shr.el (shr-map): Reinstate the `u' key binding, since it's
192 been used a while.
193
1942013-07-07 Juanma Barranquero <lekktu@gmail.com>
195
196 * subr.el (read-quoted-char): Remove unused local variable `char'.
197
1982013-07-07 Michael Kifer <kifer@cs.stonybrook.edu>
199
200 * ediff.el (ediff-version): Version update.
201 (ediff-files-command, ediff3-files-command, ediff-merge-command)
202 (ediff-merge-with-ancestor-command, ediff-directories-command)
203 (ediff-directories3-command, ediff-merge-directories-command)
204 (ediff-merge-directories-with-ancestor-command): New functions.
205 All are command-line interfaces to ediff: to facilitate calling
206 Emacs with the appropriate ediff functions invoked.
207
208 * viper-cmd.el (viper-del-forward-char-in-insert): New function.
209 (viper-save-kill-buffer): Check if buffer is modified.
210
211 * viper.el (viper-version): Version update.
212 (viper-emacs-state-mode-list): Add egg-status-buffer-mode.
213
2142013-07-07 Stefan Monnier <monnier@iro.umontreal.ca>
215
216 * faces.el (tty-run-terminal-initialization): Run new tty-setup-hook.
217 * viper-cmd.el (viper-envelop-ESC-key): Remove function.
218 (viper-intercept-ESC-key): Simplify.
219 * viper-keym.el (viper-ESC-key): Make it a constant, don't use kbd.
220 * viper.el (viper--tty-ESC-filter, viper--lookup-key)
221 (viper-catch-tty-ESC, viper-uncatch-tty-ESC)
222 (viper-setup-ESC-to-escape): New functions.
223 (viper-go-away, viper-set-hooks): Call viper-setup-ESC-to-escape.
224 (viper-set-hooks): Do not modify flyspell-mode-hook. (Bug#13793)
225
2262013-07-07 Eli Zaretskii <eliz@gnu.org>
227
228 * simple.el (default-font-height, window-screen-lines):
229 New functions.
230 (line-move, line-move-partial): Use them instead of
231 frame-char-height and window-text-height. This makes scrolling
232 text smoother when the buffer's default face uses a font that is
233 different from the frame's default font.
234
12013-07-06 Jan Djärv <jan.h.d@swipnet.se> 2352013-07-06 Jan Djärv <jan.h.d@swipnet.se>
2 236
3 * files.el (write-file): Do not display confirm dialog for NS, 237 * files.el (write-file): Do not display confirm dialog for NS,
@@ -532,7 +766,7 @@
532 * emacs-lock.el (emacs-lock-mode, emacs-lock--old-mode) 766 * emacs-lock.el (emacs-lock-mode, emacs-lock--old-mode)
533 (emacs-lock--try-unlocking): Make defvar-local. 767 (emacs-lock--try-unlocking): Make defvar-local.
534 768
5352013-06-22 Glenn Morris <rgm@fencepost.gnu.org> 7692013-06-22 Glenn Morris <rgm@gnu.org>
536 770
537 * play/cookie1.el (cookie-apropos): Minor simplification. 771 * play/cookie1.el (cookie-apropos): Minor simplification.
538 772
@@ -998,7 +1232,7 @@
998 1232
999 * net/shr.el (shr-map): Bind [down-mouse-1] to browse URLs. 1233 * net/shr.el (shr-map): Bind [down-mouse-1] to browse URLs.
1000 1234
10012013-06-19 Glenn Morris <rgm@fencepost.gnu.org> 12352013-06-19 Glenn Morris <rgm@gnu.org>
1002 1236
1003 * emacs-lisp/eieio.el (defclass): Make it eval-and-compile once more. 1237 * emacs-lisp/eieio.el (defclass): Make it eval-and-compile once more.
1004 1238
diff --git a/lisp/cedet/ChangeLog b/lisp/cedet/ChangeLog
index 7a2c5755cc0..705277c97a0 100644
--- a/lisp/cedet/ChangeLog
+++ b/lisp/cedet/ChangeLog
@@ -2,7 +2,7 @@
2 2
3 * data-debug.el, cedet-idutils.el: Neuter the "Version:" header. 3 * data-debug.el, cedet-idutils.el: Neuter the "Version:" header.
4 4
52013-06-19 Glenn Morris <rgm@fencepost.gnu.org> 52013-06-19 Glenn Morris <rgm@gnu.org>
6 6
7 * semantic/idle.el (define-semantic-idle-service): 7 * semantic/idle.el (define-semantic-idle-service):
8 No need to use eval-and-compile, progn will do. 8 No need to use eval-and-compile, progn will do.
diff --git a/lisp/desktop.el b/lisp/desktop.el
index 2f4c2a8589c..322b95715a2 100644
--- a/lisp/desktop.el
+++ b/lisp/desktop.el
@@ -196,9 +196,7 @@ Zero or nil means disable timer-based auto-saving."
196 (integer :tag "Seconds")) 196 (integer :tag "Seconds"))
197 :set (lambda (symbol value) 197 :set (lambda (symbol value)
198 (set-default symbol value) 198 (set-default symbol value)
199 (condition-case nil 199 (ignore-errors (desktop-auto-save-set-timer)))
200 (desktop-auto-save-set-timer)
201 (error nil)))
202 :group 'desktop 200 :group 'desktop
203 :version "24.4") 201 :version "24.4")
204 202
@@ -416,9 +414,8 @@ See `desktop-restore-eager'."
416 :version "22.1") 414 :version "22.1")
417 415
418;;;###autoload 416;;;###autoload
419(defvar desktop-save-buffer nil 417(defvar-local desktop-save-buffer nil
420 "When non-nil, save buffer status in desktop file. 418 "When non-nil, save buffer status in desktop file.
421This variable becomes buffer local when set.
422 419
423If the value is a function, it is called by `desktop-save' with argument 420If the value is a function, it is called by `desktop-save' with argument
424DESKTOP-DIRNAME to obtain auxiliary information to save in the desktop 421DESKTOP-DIRNAME to obtain auxiliary information to save in the desktop
@@ -430,7 +427,6 @@ When file names are returned, they should be formatted using the call
430Later, when `desktop-read' evaluates the desktop file, auxiliary information 427Later, when `desktop-read' evaluates the desktop file, auxiliary information
431is passed as the argument DESKTOP-BUFFER-MISC to functions in 428is passed as the argument DESKTOP-BUFFER-MISC to functions in
432`desktop-buffer-mode-handlers'.") 429`desktop-buffer-mode-handlers'.")
433(make-variable-buffer-local 'desktop-save-buffer)
434(make-obsolete-variable 'desktop-buffer-modes-to-save 430(make-obsolete-variable 'desktop-buffer-modes-to-save
435 'desktop-save-buffer "22.1") 431 'desktop-save-buffer "22.1")
436(make-obsolete-variable 'desktop-buffer-misc-functions 432(make-obsolete-variable 'desktop-buffer-misc-functions
@@ -582,15 +578,15 @@ Used to detect desktop file conflicts.")
582 "Return the PID of the Emacs process that owns the desktop file in DIRNAME. 578 "Return the PID of the Emacs process that owns the desktop file in DIRNAME.
583Return nil if no desktop file found or no Emacs process is using it. 579Return nil if no desktop file found or no Emacs process is using it.
584DIRNAME omitted or nil means use `desktop-dirname'." 580DIRNAME omitted or nil means use `desktop-dirname'."
585 (let (owner) 581 (let (owner
586 (and (file-exists-p (desktop-full-lock-name dirname)) 582 (file (desktop-full-lock-name dirname)))
587 (condition-case nil 583 (and (file-exists-p file)
588 (with-temp-buffer 584 (ignore-errors
589 (insert-file-contents-literally (desktop-full-lock-name dirname)) 585 (with-temp-buffer
590 (goto-char (point-min)) 586 (insert-file-contents-literally file)
591 (setq owner (read (current-buffer))) 587 (goto-char (point-min))
592 (integerp owner)) 588 (setq owner (read (current-buffer)))
593 (error nil)) 589 (integerp owner)))
594 owner))) 590 owner)))
595 591
596(defun desktop-claim-lock (&optional dirname) 592(defun desktop-claim-lock (&optional dirname)
@@ -636,7 +632,7 @@ Furthermore, it clears the variables listed in `desktop-globals-to-clear'."
636 (let ((bufname (buffer-name (car buffers)))) 632 (let ((bufname (buffer-name (car buffers))))
637 (or 633 (or
638 (null bufname) 634 (null bufname)
639 (string-match preserve-regexp bufname) 635 (string-match-p preserve-regexp bufname)
640 ;; Don't kill buffers made for internal purposes. 636 ;; Don't kill buffers made for internal purposes.
641 (and (not (equal bufname "")) (eq (aref bufname 0) ?\s)) 637 (and (not (equal bufname "")) (eq (aref bufname 0) ?\s))
642 (kill-buffer (car buffers)))) 638 (kill-buffer (car buffers))))
@@ -758,8 +754,7 @@ QUOTE may be `may' (value may be quoted),
758 ((consp value) 754 ((consp value)
759 (let ((p value) 755 (let ((p value)
760 newlist 756 newlist
761 use-list* 757 use-list*)
762 anynil)
763 (while (consp p) 758 (while (consp p)
764 (let ((q.sexp (desktop--v2s (car p)))) 759 (let ((q.sexp (desktop--v2s (car p))))
765 (push q.sexp newlist)) 760 (push q.sexp newlist))
@@ -841,17 +836,17 @@ MODE is the major mode.
841 dired-skip) 836 dired-skip)
842 (and (not (and (stringp desktop-buffers-not-to-save) 837 (and (not (and (stringp desktop-buffers-not-to-save)
843 (not filename) 838 (not filename)
844 (string-match desktop-buffers-not-to-save bufname))) 839 (string-match-p desktop-buffers-not-to-save bufname)))
845 (not (memq mode desktop-modes-not-to-save)) 840 (not (memq mode desktop-modes-not-to-save))
846 ;; FIXME this is broken if desktop-files-not-to-save is nil. 841 ;; FIXME this is broken if desktop-files-not-to-save is nil.
847 (or (and filename 842 (or (and filename
848 (stringp desktop-files-not-to-save) 843 (stringp desktop-files-not-to-save)
849 (not (string-match desktop-files-not-to-save filename))) 844 (not (string-match-p desktop-files-not-to-save filename)))
850 (and (memq mode '(dired-mode vc-dir-mode)) 845 (and (memq mode '(dired-mode vc-dir-mode))
851 (with-current-buffer bufname 846 (with-current-buffer bufname
852 (not (setq dired-skip 847 (not (setq dired-skip
853 (string-match desktop-files-not-to-save 848 (string-match-p desktop-files-not-to-save
854 default-directory))))) 849 default-directory)))))
855 (and (null filename) 850 (and (null filename)
856 (null dired-skip) ; bug#5755 851 (null dired-skip) ; bug#5755
857 (with-current-buffer bufname desktop-save-buffer)))))) 852 (with-current-buffer bufname desktop-save-buffer))))))
diff --git a/lisp/doc-view.el b/lisp/doc-view.el
index e4434c3a0d8..10968f7f8dd 100644
--- a/lisp/doc-view.el
+++ b/lisp/doc-view.el
@@ -136,7 +136,7 @@
136 136
137;;; Code: 137;;; Code:
138 138
139(eval-when-compile (require 'cl-lib)) 139(require 'cl-lib)
140(require 'dired) 140(require 'dired)
141(require 'image-mode) 141(require 'image-mode)
142(require 'jka-compr) 142(require 'jka-compr)
@@ -698,14 +698,6 @@ It's a subdirectory of `doc-view-cache-directory'."
698 (md5 (current-buffer))))) 698 (md5 (current-buffer)))))
699 doc-view-cache-directory))))) 699 doc-view-cache-directory)))))
700 700
701(defun doc-view-remove-if (predicate list)
702 "Return LIST with all items removed that satisfy PREDICATE."
703 (let (new-list)
704 (dolist (item list)
705 (when (not (funcall predicate item))
706 (setq new-list (cons item new-list))))
707 (nreverse new-list)))
708
709;;;###autoload 701;;;###autoload
710(defun doc-view-mode-p (type) 702(defun doc-view-mode-p (type)
711 "Return non-nil if document type TYPE is available for `doc-view'. 703 "Return non-nil if document type TYPE is available for `doc-view'.
@@ -1488,7 +1480,7 @@ If BACKWARD is non-nil, jump to the previous match."
1488(defun doc-view-search-next-match (arg) 1480(defun doc-view-search-next-match (arg)
1489 "Go to the ARGth next matching page." 1481 "Go to the ARGth next matching page."
1490 (interactive "p") 1482 (interactive "p")
1491 (let* ((next-pages (doc-view-remove-if 1483 (let* ((next-pages (cl-remove-if
1492 (lambda (i) (<= (car i) (doc-view-current-page))) 1484 (lambda (i) (<= (car i) (doc-view-current-page)))
1493 doc-view--current-search-matches)) 1485 doc-view--current-search-matches))
1494 (page (car (nth (1- arg) next-pages)))) 1486 (page (car (nth (1- arg) next-pages))))
@@ -1502,7 +1494,7 @@ If BACKWARD is non-nil, jump to the previous match."
1502(defun doc-view-search-previous-match (arg) 1494(defun doc-view-search-previous-match (arg)
1503 "Go to the ARGth previous matching page." 1495 "Go to the ARGth previous matching page."
1504 (interactive "p") 1496 (interactive "p")
1505 (let* ((prev-pages (doc-view-remove-if 1497 (let* ((prev-pages (cl-remove-if
1506 (lambda (i) (>= (car i) (doc-view-current-page))) 1498 (lambda (i) (>= (car i) (doc-view-current-page)))
1507 doc-view--current-search-matches)) 1499 doc-view--current-search-matches))
1508 (page (car (nth (1- arg) (nreverse prev-pages))))) 1500 (page (car (nth (1- arg) (nreverse prev-pages)))))
diff --git a/lisp/edmacro.el b/lisp/edmacro.el
index 6ef2e29dc83..67992d16527 100644
--- a/lisp/edmacro.el
+++ b/lisp/edmacro.el
@@ -62,9 +62,8 @@
62;; macro in a more concise way that omits the comments. 62;; macro in a more concise way that omits the comments.
63 63
64;;; Code: 64;;; Code:
65
66(eval-when-compile (require 'cl-lib))
67 65
66(require 'cl-lib)
68(require 'kmacro) 67(require 'kmacro)
69 68
70;;; The user-level commands for editing macros. 69;;; The user-level commands for editing macros.
@@ -444,14 +443,14 @@ doubt, use whitespace."
444 (let* ((prefix 443 (let* ((prefix
445 (or (and (integerp (aref rest-mac 0)) 444 (or (and (integerp (aref rest-mac 0))
446 (memq (aref rest-mac 0) mdigs) 445 (memq (aref rest-mac 0) mdigs)
447 (memq (key-binding (edmacro-subseq rest-mac 0 1)) 446 (memq (key-binding (cl-subseq rest-mac 0 1))
448 '(digit-argument negative-argument)) 447 '(digit-argument negative-argument))
449 (let ((i 1)) 448 (let ((i 1))
450 (while (memq (aref rest-mac i) (cdr mdigs)) 449 (while (memq (aref rest-mac i) (cdr mdigs))
451 (cl-incf i)) 450 (cl-incf i))
452 (and (not (memq (aref rest-mac i) pkeys)) 451 (and (not (memq (aref rest-mac i) pkeys))
453 (prog1 (vconcat "M-" (edmacro-subseq rest-mac 0 i) " ") 452 (prog1 (vconcat "M-" (cl-subseq rest-mac 0 i) " ")
454 (cl-callf edmacro-subseq rest-mac i))))) 453 (cl-callf cl-subseq rest-mac i)))))
455 (and (eq (aref rest-mac 0) ?\C-u) 454 (and (eq (aref rest-mac 0) ?\C-u)
456 (eq (key-binding [?\C-u]) 'universal-argument) 455 (eq (key-binding [?\C-u]) 'universal-argument)
457 (let ((i 1)) 456 (let ((i 1))
@@ -459,7 +458,7 @@ doubt, use whitespace."
459 (cl-incf i)) 458 (cl-incf i))
460 (and (not (memq (aref rest-mac i) pkeys)) 459 (and (not (memq (aref rest-mac i) pkeys))
461 (prog1 (cl-loop repeat i concat "C-u ") 460 (prog1 (cl-loop repeat i concat "C-u ")
462 (cl-callf edmacro-subseq rest-mac i))))) 461 (cl-callf cl-subseq rest-mac i)))))
463 (and (eq (aref rest-mac 0) ?\C-u) 462 (and (eq (aref rest-mac 0) ?\C-u)
464 (eq (key-binding [?\C-u]) 'universal-argument) 463 (eq (key-binding [?\C-u]) 'universal-argument)
465 (let ((i 1)) 464 (let ((i 1))
@@ -469,18 +468,18 @@ doubt, use whitespace."
469 '(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9)) 468 '(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9))
470 (cl-incf i)) 469 (cl-incf i))
471 (and (not (memq (aref rest-mac i) pkeys)) 470 (and (not (memq (aref rest-mac i) pkeys))
472 (prog1 (vconcat "C-u " (edmacro-subseq rest-mac 1 i) " ") 471 (prog1 (vconcat "C-u " (cl-subseq rest-mac 1 i) " ")
473 (cl-callf edmacro-subseq rest-mac i))))))) 472 (cl-callf cl-subseq rest-mac i)))))))
474 (bind-len (apply 'max 1 473 (bind-len (apply 'max 1
475 (cl-loop for map in maps 474 (cl-loop for map in maps
476 for b = (lookup-key map rest-mac) 475 for b = (lookup-key map rest-mac)
477 when b collect b))) 476 when b collect b)))
478 (key (edmacro-subseq rest-mac 0 bind-len)) 477 (key (cl-subseq rest-mac 0 bind-len))
479 (fkey nil) tlen tkey 478 (fkey nil) tlen tkey
480 (bind (or (cl-loop for map in maps for b = (lookup-key map key) 479 (bind (or (cl-loop for map in maps for b = (lookup-key map key)
481 thereis (and (not (integerp b)) b)) 480 thereis (and (not (integerp b)) b))
482 (and (setq fkey (lookup-key local-function-key-map rest-mac)) 481 (and (setq fkey (lookup-key local-function-key-map rest-mac))
483 (setq tlen fkey tkey (edmacro-subseq rest-mac 0 tlen) 482 (setq tlen fkey tkey (cl-subseq rest-mac 0 tlen)
484 fkey (lookup-key local-function-key-map tkey)) 483 fkey (lookup-key local-function-key-map tkey))
485 (cl-loop for map in maps 484 (cl-loop for map in maps
486 for b = (lookup-key map fkey) 485 for b = (lookup-key map fkey)
@@ -507,7 +506,7 @@ doubt, use whitespace."
507 (> first 32) (<= first maxkey) (/= first 92) 506 (> first 32) (<= first maxkey) (/= first 92)
508 (progn 507 (progn
509 (if (> text 30) (setq text 30)) 508 (if (> text 30) (setq text 30))
510 (setq desc (concat (edmacro-subseq rest-mac 0 text))) 509 (setq desc (concat (cl-subseq rest-mac 0 text)))
511 (when (string-match "^[ACHMsS]-." desc) 510 (when (string-match "^[ACHMsS]-." desc)
512 (setq text 2) 511 (setq text 2)
513 (cl-callf substring desc 0 2)) 512 (cl-callf substring desc 0 2))
@@ -524,7 +523,7 @@ doubt, use whitespace."
524 (> text bind-len) 523 (> text bind-len)
525 (memq (aref rest-mac text) '(return 13)) 524 (memq (aref rest-mac text) '(return 13))
526 (progn 525 (progn
527 (setq desc (concat (edmacro-subseq rest-mac bind-len text))) 526 (setq desc (concat (cl-subseq rest-mac bind-len text)))
528 (commandp (intern-soft desc)))) 527 (commandp (intern-soft desc))))
529 (if (commandp (intern-soft desc)) (setq bind desc)) 528 (if (commandp (intern-soft desc)) (setq bind desc))
530 (setq desc (format "<<%s>>" desc)) 529 (setq desc (format "<<%s>>" desc))
@@ -562,14 +561,14 @@ doubt, use whitespace."
562 (setq desc (concat (edmacro-sanitize-for-string prefix) desc))) 561 (setq desc (concat (edmacro-sanitize-for-string prefix) desc)))
563 (unless (string-match " " desc) 562 (unless (string-match " " desc)
564 (let ((times 1) (pos bind-len)) 563 (let ((times 1) (pos bind-len))
565 (while (not (edmacro-mismatch rest-mac rest-mac 564 (while (not (cl-mismatch rest-mac rest-mac
566 0 bind-len pos (+ bind-len pos))) 565 0 bind-len pos (+ bind-len pos)))
567 (cl-incf times) 566 (cl-incf times)
568 (cl-incf pos bind-len)) 567 (cl-incf pos bind-len))
569 (when (> times 1) 568 (when (> times 1)
570 (setq desc (format "%d*%s" times desc)) 569 (setq desc (format "%d*%s" times desc))
571 (setq bind-len (* bind-len times))))) 570 (setq bind-len (* bind-len times)))))
572 (setq rest-mac (edmacro-subseq rest-mac bind-len)) 571 (setq rest-mac (cl-subseq rest-mac bind-len))
573 (if verbose 572 (if verbose
574 (progn 573 (progn
575 (unless (equal res "") (cl-callf concat res "\n")) 574 (unless (equal res "") (cl-callf concat res "\n"))
@@ -590,50 +589,6 @@ doubt, use whitespace."
590 (cl-incf len (length desc))))) 589 (cl-incf len (length desc)))))
591 res)) 590 res))
592 591
593(defun edmacro-mismatch (cl-seq1 cl-seq2 cl-start1 cl-end1 cl-start2 cl-end2)
594 "Compare SEQ1 with SEQ2, return index of first mismatching element.
595Return nil if the sequences match. If one sequence is a prefix of the
596other, the return value indicates the end of the shorted sequence.
597\n(fn SEQ1 SEQ2 START1 END1 START2 END2)"
598 (or cl-end1 (setq cl-end1 (length cl-seq1)))
599 (or cl-end2 (setq cl-end2 (length cl-seq2)))
600 (let ((cl-p1 (and (listp cl-seq1) (nthcdr cl-start1 cl-seq1)))
601 (cl-p2 (and (listp cl-seq2) (nthcdr cl-start2 cl-seq2))))
602 (while (and (< cl-start1 cl-end1) (< cl-start2 cl-end2)
603 (eql (if cl-p1 (car cl-p1)
604 (aref cl-seq1 cl-start1))
605 (if cl-p2 (car cl-p2)
606 (aref cl-seq2 cl-start2))))
607 (setq cl-p1 (cdr cl-p1) cl-p2 (cdr cl-p2)
608 cl-start1 (1+ cl-start1) cl-start2 (1+ cl-start2)))
609 (and (or (< cl-start1 cl-end1) (< cl-start2 cl-end2))
610 cl-start1)))
611
612(defun edmacro-subseq (seq start &optional end)
613 "Return the subsequence of SEQ from START to END.
614If END is omitted, it defaults to the length of the sequence.
615If START or END is negative, it counts from the end."
616 (if (stringp seq) (substring seq start end)
617 (let (len)
618 (and end (< end 0) (setq end (+ end (setq len (length seq)))))
619 (if (< start 0) (setq start (+ start (or len (setq len (length seq))))))
620 (cond ((listp seq)
621 (if (> start 0) (setq seq (nthcdr start seq)))
622 (if end
623 (let ((res nil))
624 (while (>= (setq end (1- end)) start)
625 (push (pop seq) res))
626 (nreverse res))
627 (copy-sequence seq)))
628 (t
629 (or end (setq end (or len (length seq))))
630 (let ((res (make-vector (max (- end start) 0) nil))
631 (i 0))
632 (while (< start end)
633 (aset res i (aref seq start))
634 (setq i (1+ i) start (1+ start)))
635 res))))))
636
637(defun edmacro-sanitize-for-string (seq) 592(defun edmacro-sanitize-for-string (seq)
638 "Convert a key sequence vector SEQ into a string. 593 "Convert a key sequence vector SEQ into a string.
639The string represents the same events; Meta is indicated by bit 7. 594The string represents the same events; Meta is indicated by bit 7.
@@ -760,7 +715,7 @@ This function assumes that the events can be stored in a string."
760 (eq (aref res 1) ?\() 715 (eq (aref res 1) ?\()
761 (eq (aref res (- (length res) 2)) ?\C-x) 716 (eq (aref res (- (length res) 2)) ?\C-x)
762 (eq (aref res (- (length res) 1)) ?\))) 717 (eq (aref res (- (length res) 1)) ?\)))
763 (setq res (edmacro-subseq res 2 -2))) 718 (setq res (cl-subseq res 2 -2)))
764 (if (and (not need-vector) 719 (if (and (not need-vector)
765 (cl-loop for ch across res 720 (cl-loop for ch across res
766 always (and (characterp ch) 721 always (and (characterp ch)
diff --git a/lisp/emacs-lisp/.gitignore b/lisp/emacs-lisp/.gitignore
deleted file mode 100644
index 133e79e817a..00000000000
--- a/lisp/emacs-lisp/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
1!*-loaddefs.el
2
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 3cf744f1245..c47c9b61030 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -1957,7 +1957,7 @@ by EXPANSION, and (setq NAME ...) will act like (setf EXPANSION ...).
1957 "Collect multiple return values. 1957 "Collect multiple return values.
1958FORM must return a list; the BODY is then executed with the first N elements 1958FORM must return a list; the BODY is then executed with the first N elements
1959of this list bound (`let'-style) to each of the symbols SYM in turn. This 1959of this list bound (`let'-style) to each of the symbols SYM in turn. This
1960is analogous to the Common Lisp `cl-multiple-value-bind' macro, using lists to 1960is analogous to the Common Lisp `multiple-value-bind' macro, using lists to
1961simulate true multiple return values. For compatibility, (cl-values A B C) is 1961simulate true multiple return values. For compatibility, (cl-values A B C) is
1962a synonym for (list A B C). 1962a synonym for (list A B C).
1963 1963
@@ -1975,7 +1975,7 @@ a synonym for (list A B C).
1975 "Collect multiple return values. 1975 "Collect multiple return values.
1976FORM must return a list; the first N elements of this list are stored in 1976FORM must return a list; the first N elements of this list are stored in
1977each of the symbols SYM in turn. This is analogous to the Common Lisp 1977each of the symbols SYM in turn. This is analogous to the Common Lisp
1978`cl-multiple-value-setq' macro, using lists to simulate true multiple return 1978`multiple-value-setq' macro, using lists to simulate true multiple return
1979values. For compatibility, (cl-values A B C) is a synonym for (list A B C). 1979values. For compatibility, (cl-values A B C) is a synonym for (list A B C).
1980 1980
1981\(fn (SYM...) FORM)" 1981\(fn (SYM...) FORM)"
@@ -2002,7 +2002,7 @@ values. For compatibility, (cl-values A B C) is a synonym for (list A B C).
2002 (cons 'progn body)) 2002 (cons 'progn body))
2003;;;###autoload 2003;;;###autoload
2004(defmacro cl-the (_type form) 2004(defmacro cl-the (_type form)
2005 "At present this ignores _TYPE and is simply equivalent to FORM." 2005 "At present this ignores TYPE and is simply equivalent to FORM."
2006 (declare (indent 1) (debug (cl-type-spec form))) 2006 (declare (indent 1) (debug (cl-type-spec form)))
2007 form) 2007 form)
2008 2008
@@ -2059,7 +2059,7 @@ values. For compatibility, (cl-values A B C) is a synonym for (list A B C).
2059 "Declare SPECS about the current function while compiling. 2059 "Declare SPECS about the current function while compiling.
2060For instance 2060For instance
2061 2061
2062 \(cl-declare (warn 0)) 2062 (cl-declare (warn 0))
2063 2063
2064will turn off byte-compile warnings in the function. 2064will turn off byte-compile warnings in the function.
2065See Info node `(cl)Declarations' for details." 2065See Info node `(cl)Declarations' for details."
@@ -2279,8 +2279,8 @@ KEYWORD can be one of :conc-name, :constructor, :copier, :predicate,
2279Each SLOT may instead take the form (SNAME SDEFAULT SOPTIONS...), where 2279Each SLOT may instead take the form (SNAME SDEFAULT SOPTIONS...), where
2280SDEFAULT is the default value of that slot and SOPTIONS are keyword-value 2280SDEFAULT is the default value of that slot and SOPTIONS are keyword-value
2281pairs for that slot. 2281pairs for that slot.
2282Currently, only one keyword is supported, `:read-only'. If this has a non-nil 2282Currently, only one keyword is supported, `:read-only'. If this has a
2283value, that slot cannot be set via `setf'. 2283non-nil value, that slot cannot be set via `setf'.
2284 2284
2285\(fn NAME SLOTS...)" 2285\(fn NAME SLOTS...)"
2286 (declare (doc-string 2) (indent 1) 2286 (declare (doc-string 2) (indent 1)
diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el
index 319af588eac..36c72f3a3bd 100644
--- a/lisp/emacs-lisp/edebug.el
+++ b/lisp/emacs-lisp/edebug.el
@@ -53,7 +53,7 @@
53;;; Code: 53;;; Code:
54 54
55(require 'macroexp) 55(require 'macroexp)
56(eval-when-compile (require 'cl-lib)) 56(require 'cl-lib)
57(eval-when-compile (require 'pcase)) 57(eval-when-compile (require 'pcase))
58 58
59;;; Options 59;;; Options
@@ -263,26 +263,6 @@ An extant spec symbol is a symbol that is not a function and has a
263 263
264;;; Utilities 264;;; Utilities
265 265
266;; Define edebug-gensym - from old cl.el
267(defvar edebug-gensym-index 0
268 "Integer used by `edebug-gensym' to produce new names.")
269
270(defun edebug-gensym (&optional prefix)
271 "Generate a fresh uninterned symbol.
272There is an optional argument, PREFIX. PREFIX is the string
273that begins the new name. Most people take just the default,
274except when debugging needs suggest otherwise."
275 (if (null prefix)
276 (setq prefix "G"))
277 (let ((newsymbol nil)
278 (newname ""))
279 (while (not newsymbol)
280 (setq newname (concat prefix (int-to-string edebug-gensym-index)))
281 (setq edebug-gensym-index (+ edebug-gensym-index 1))
282 (if (not (intern-soft newname))
283 (setq newsymbol (make-symbol newname))))
284 newsymbol))
285
286(defun edebug-lambda-list-keywordp (object) 266(defun edebug-lambda-list-keywordp (object)
287 "Return t if OBJECT is a lambda list keyword. 267 "Return t if OBJECT is a lambda list keyword.
288A lambda list keyword is a symbol that starts with `&'." 268A lambda list keyword is a symbol that starts with `&'."
@@ -1186,7 +1166,7 @@ Maybe clear the markers and delete the symbol's edebug property?"
1186 ;; Uses the dynamically bound vars edebug-def-name and edebug-def-args. 1166 ;; Uses the dynamically bound vars edebug-def-name and edebug-def-args.
1187 ;; Do this after parsing since that may find a name. 1167 ;; Do this after parsing since that may find a name.
1188 (setq edebug-def-name 1168 (setq edebug-def-name
1189 (or edebug-def-name edebug-old-def-name (edebug-gensym "edebug-anon"))) 1169 (or edebug-def-name edebug-old-def-name (cl-gensym "edebug-anon")))
1190 `(edebug-enter 1170 `(edebug-enter
1191 (quote ,edebug-def-name) 1171 (quote ,edebug-def-name)
1192 ,(if edebug-inside-func 1172 ,(if edebug-inside-func
@@ -1299,7 +1279,7 @@ expressions; a `progn' form will be returned enclosing these forms."
1299 1279
1300 ;; Set the name here if it was not set by edebug-make-enter-wrapper. 1280 ;; Set the name here if it was not set by edebug-make-enter-wrapper.
1301 (setq edebug-def-name 1281 (setq edebug-def-name
1302 (or edebug-def-name edebug-old-def-name (edebug-gensym "edebug-anon"))) 1282 (or edebug-def-name edebug-old-def-name (cl-gensym "edebug-anon")))
1303 1283
1304 ;; Add this def as a dependent of containing def. Buggy. 1284 ;; Add this def as a dependent of containing def. Buggy.
1305 '(if (and edebug-containing-def-name 1285 '(if (and edebug-containing-def-name
diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el
index 656cb0a6a14..1f5edefea08 100644
--- a/lisp/emacs-lisp/ert.el
+++ b/lisp/emacs-lisp/ert.el
@@ -54,7 +54,7 @@
54 54
55;;; Code: 55;;; Code:
56 56
57(eval-when-compile (require 'cl-lib)) 57(require 'cl-lib)
58(require 'button) 58(require 'button)
59(require 'debug) 59(require 'debug)
60(require 'easymenu) 60(require 'easymenu)
@@ -87,127 +87,6 @@
87 87
88;;; Copies/reimplementations of cl functions. 88;;; Copies/reimplementations of cl functions.
89 89
90(defun ert--cl-do-remf (plist tag)
91 "Copy of `cl-do-remf'. Modify PLIST by removing TAG."
92 (let ((p (cdr plist)))
93 (while (and (cdr p) (not (eq (car (cdr p)) tag))) (setq p (cdr (cdr p))))
94 (and (cdr p) (progn (setcdr p (cdr (cdr (cdr p)))) t))))
95
96(defun ert--remprop (sym tag)
97 "Copy of `cl-remprop'. Modify SYM's plist by removing TAG."
98 (let ((plist (symbol-plist sym)))
99 (if (and plist (eq tag (car plist)))
100 (progn (setplist sym (cdr (cdr plist))) t)
101 (ert--cl-do-remf plist tag))))
102
103(defun ert--remove-if-not (ert-pred ert-list)
104 "A reimplementation of `remove-if-not'.
105
106ERT-PRED is a predicate, ERT-LIST is the input list."
107 (cl-loop for ert-x in ert-list
108 if (funcall ert-pred ert-x)
109 collect ert-x))
110
111(defun ert--intersection (a b)
112 "A reimplementation of `intersection'. Intersect the sets A and B.
113
114Elements are compared using `eql'."
115 (cl-loop for x in a
116 if (memql x b)
117 collect x))
118
119(defun ert--set-difference (a b)
120 "A reimplementation of `set-difference'. Subtract the set B from the set A.
121
122Elements are compared using `eql'."
123 (cl-loop for x in a
124 unless (memql x b)
125 collect x))
126
127(defun ert--set-difference-eq (a b)
128 "A reimplementation of `set-difference'. Subtract the set B from the set A.
129
130Elements are compared using `eq'."
131 (cl-loop for x in a
132 unless (memq x b)
133 collect x))
134
135(defun ert--union (a b)
136 "A reimplementation of `union'. Compute the union of the sets A and B.
137
138Elements are compared using `eql'."
139 (append a (ert--set-difference b a)))
140
141(eval-and-compile
142 (defvar ert--gensym-counter 0))
143
144(eval-and-compile
145 (defun ert--gensym (&optional prefix)
146 "Only allows string PREFIX, not compatible with CL."
147 (unless prefix (setq prefix "G"))
148 (make-symbol (format "%s%s"
149 prefix
150 (prog1 ert--gensym-counter
151 (cl-incf ert--gensym-counter))))))
152
153(defun ert--coerce-to-vector (x)
154 "Coerce X to a vector."
155 (when (char-table-p x) (error "Not supported"))
156 (if (vectorp x)
157 x
158 (vconcat x)))
159
160(cl-defun ert--remove* (x list &key key test)
161 "Does not support all the keywords of remove*."
162 (unless key (setq key #'identity))
163 (unless test (setq test #'eql))
164 (cl-loop for y in list
165 unless (funcall test x (funcall key y))
166 collect y))
167
168(defun ert--string-position (c s)
169 "Return the position of the first occurrence of C in S, or nil if none."
170 (cl-loop for i from 0
171 for x across s
172 when (eql x c) return i))
173
174(defun ert--mismatch (a b)
175 "Return index of first element that differs between A and B.
176
177Like `mismatch'. Uses `equal' for comparison."
178 (cond ((or (listp a) (listp b))
179 (ert--mismatch (ert--coerce-to-vector a)
180 (ert--coerce-to-vector b)))
181 ((> (length a) (length b))
182 (ert--mismatch b a))
183 (t
184 (let ((la (length a))
185 (lb (length b)))
186 (cl-assert (arrayp a) t)
187 (cl-assert (arrayp b) t)
188 (cl-assert (<= la lb) t)
189 (cl-loop for i below la
190 when (not (equal (aref a i) (aref b i))) return i
191 finally (cl-return (if (/= la lb)
192 la
193 (cl-assert (equal a b) t)
194 nil)))))))
195
196(defun ert--subseq (seq start &optional end)
197 "Return a subsequence of SEQ from START to END."
198 (when (char-table-p seq) (error "Not supported"))
199 (let ((vector (substring (ert--coerce-to-vector seq) start end)))
200 (cl-etypecase seq
201 (vector vector)
202 (string (concat vector))
203 (list (append vector nil))
204 (bool-vector (cl-loop with result
205 = (make-bool-vector (length vector) nil)
206 for i below (length vector) do
207 (setf (aref result i) (aref vector i))
208 finally (cl-return result)))
209 (char-table (cl-assert nil)))))
210
211(defun ert-equal-including-properties (a b) 90(defun ert-equal-including-properties (a b)
212 "Return t if A and B have similar structure and contents. 91 "Return t if A and B have similar structure and contents.
213 92
@@ -258,7 +137,7 @@ Emacs bug 6581 at URL `http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6581'."
258 137
259(defun ert-make-test-unbound (symbol) 138(defun ert-make-test-unbound (symbol)
260 "Make SYMBOL name no test. Return SYMBOL." 139 "Make SYMBOL name no test. Return SYMBOL."
261 (ert--remprop symbol 'ert--test) 140 (cl-remprop symbol 'ert--test)
262 symbol) 141 symbol)
263 142
264(defun ert--parse-keys-and-body (keys-and-body) 143(defun ert--parse-keys-and-body (keys-and-body)
@@ -396,8 +275,8 @@ DATA is displayed to the user and should state the reason of the failure."
396 cl-macro-environment))))) 275 cl-macro-environment)))))
397 (cond 276 (cond
398 ((or (atom form) (ert--special-operator-p (car form))) 277 ((or (atom form) (ert--special-operator-p (car form)))
399 (let ((value (ert--gensym "value-"))) 278 (let ((value (cl-gensym "value-")))
400 `(let ((,value (ert--gensym "ert-form-evaluation-aborted-"))) 279 `(let ((,value (cl-gensym "ert-form-evaluation-aborted-")))
401 ,(funcall inner-expander 280 ,(funcall inner-expander
402 `(setq ,value ,form) 281 `(setq ,value ,form)
403 `(list ',whole :form ',form :value ,value) 282 `(list ',whole :form ',form :value ,value)
@@ -410,10 +289,10 @@ DATA is displayed to the user and should state the reason of the failure."
410 (and (consp fn-name) 289 (and (consp fn-name)
411 (eql (car fn-name) 'lambda) 290 (eql (car fn-name) 'lambda)
412 (listp (cdr fn-name))))) 291 (listp (cdr fn-name)))))
413 (let ((fn (ert--gensym "fn-")) 292 (let ((fn (cl-gensym "fn-"))
414 (args (ert--gensym "args-")) 293 (args (cl-gensym "args-"))
415 (value (ert--gensym "value-")) 294 (value (cl-gensym "value-"))
416 (default-value (ert--gensym "ert-form-evaluation-aborted-"))) 295 (default-value (cl-gensym "ert-form-evaluation-aborted-")))
417 `(let ((,fn (function ,fn-name)) 296 `(let ((,fn (function ,fn-name))
418 (,args (list ,@arg-forms))) 297 (,args (list ,@arg-forms)))
419 (let ((,value ',default-value)) 298 (let ((,value ',default-value))
@@ -450,7 +329,7 @@ FORM-DESCRIPTION-FORM before it has called INNER-FORM."
450 (ert--expand-should-1 329 (ert--expand-should-1
451 whole form 330 whole form
452 (lambda (inner-form form-description-form value-var) 331 (lambda (inner-form form-description-form value-var)
453 (let ((form-description (ert--gensym "form-description-"))) 332 (let ((form-description (cl-gensym "form-description-")))
454 `(let (,form-description) 333 `(let (,form-description)
455 ,(funcall inner-expander 334 ,(funcall inner-expander
456 `(unwind-protect 335 `(unwind-protect
@@ -491,7 +370,7 @@ and aborts the current test as failed if it doesn't."
491 (list type) 370 (list type)
492 (symbol (list type))))) 371 (symbol (list type)))))
493 (cl-assert signaled-conditions) 372 (cl-assert signaled-conditions)
494 (unless (ert--intersection signaled-conditions handled-conditions) 373 (unless (cl-intersection signaled-conditions handled-conditions)
495 (ert-fail (append 374 (ert-fail (append
496 (funcall form-description-fn) 375 (funcall form-description-fn)
497 (list 376 (list
@@ -528,8 +407,8 @@ failed."
528 `(should-error ,form ,@keys) 407 `(should-error ,form ,@keys)
529 form 408 form
530 (lambda (inner-form form-description-form value-var) 409 (lambda (inner-form form-description-form value-var)
531 (let ((errorp (ert--gensym "errorp")) 410 (let ((errorp (cl-gensym "errorp"))
532 (form-description-fn (ert--gensym "form-description-fn-"))) 411 (form-description-fn (cl-gensym "form-description-fn-")))
533 `(let ((,errorp nil) 412 `(let ((,errorp nil)
534 (,form-description-fn (lambda () ,form-description-form))) 413 (,form-description-fn (lambda () ,form-description-form)))
535 (condition-case -condition- 414 (condition-case -condition-
@@ -591,7 +470,7 @@ Returns nil if they are."
591 `(proper-lists-of-different-length ,(length a) ,(length b) 470 `(proper-lists-of-different-length ,(length a) ,(length b)
592 ,a ,b 471 ,a ,b
593 first-mismatch-at 472 first-mismatch-at
594 ,(ert--mismatch a b)) 473 ,(cl-mismatch a b :test 'equal))
595 (cl-loop for i from 0 474 (cl-loop for i from 0
596 for ai in a 475 for ai in a
597 for bi in b 476 for bi in b
@@ -611,7 +490,7 @@ Returns nil if they are."
611 ,a ,b 490 ,a ,b
612 ,@(unless (char-table-p a) 491 ,@(unless (char-table-p a)
613 `(first-mismatch-at 492 `(first-mismatch-at
614 ,(ert--mismatch a b)))) 493 ,(cl-mismatch a b :test 'equal))))
615 (cl-loop for i from 0 494 (cl-loop for i from 0
616 for ai across a 495 for ai across a
617 for bi across b 496 for bi across b
@@ -656,8 +535,8 @@ key/value pairs in each list does not matter."
656 ;; work, so let's punt on it for now. 535 ;; work, so let's punt on it for now.
657 (let* ((keys-a (ert--significant-plist-keys a)) 536 (let* ((keys-a (ert--significant-plist-keys a))
658 (keys-b (ert--significant-plist-keys b)) 537 (keys-b (ert--significant-plist-keys b))
659 (keys-in-a-not-in-b (ert--set-difference-eq keys-a keys-b)) 538 (keys-in-a-not-in-b (cl-set-difference keys-a keys-b :test 'eq))
660 (keys-in-b-not-in-a (ert--set-difference-eq keys-b keys-a))) 539 (keys-in-b-not-in-a (cl-set-difference keys-b keys-a :test 'eq)))
661 (cl-flet ((explain-with-key (key) 540 (cl-flet ((explain-with-key (key)
662 (let ((value-a (plist-get a key)) 541 (let ((value-a (plist-get a key))
663 (value-b (plist-get b key))) 542 (value-b (plist-get b key)))
@@ -1090,7 +969,7 @@ contained in UNIVERSE."
1090 (cl-etypecase universe 969 (cl-etypecase universe
1091 ((member t) (mapcar #'ert-get-test 970 ((member t) (mapcar #'ert-get-test
1092 (apropos-internal selector #'ert-test-boundp))) 971 (apropos-internal selector #'ert-test-boundp)))
1093 (list (ert--remove-if-not (lambda (test) 972 (list (cl-remove-if-not (lambda (test)
1094 (and (ert-test-name test) 973 (and (ert-test-name test)
1095 (string-match selector 974 (string-match selector
1096 (ert-test-name test)))) 975 (ert-test-name test))))
@@ -1123,13 +1002,13 @@ contained in UNIVERSE."
1123 (not 1002 (not
1124 (cl-assert (eql (length operands) 1)) 1003 (cl-assert (eql (length operands) 1))
1125 (let ((all-tests (ert-select-tests 't universe))) 1004 (let ((all-tests (ert-select-tests 't universe)))
1126 (ert--set-difference all-tests 1005 (cl-set-difference all-tests
1127 (ert-select-tests (car operands) 1006 (ert-select-tests (car operands)
1128 all-tests)))) 1007 all-tests))))
1129 (or 1008 (or
1130 (cl-case (length operands) 1009 (cl-case (length operands)
1131 (0 (ert-select-tests 'nil universe)) 1010 (0 (ert-select-tests 'nil universe))
1132 (t (ert--union (ert-select-tests (car operands) universe) 1011 (t (cl-union (ert-select-tests (car operands) universe)
1133 (ert-select-tests `(or ,@(cdr operands)) 1012 (ert-select-tests `(or ,@(cdr operands))
1134 universe))))) 1013 universe)))))
1135 (tag 1014 (tag
@@ -1141,7 +1020,7 @@ contained in UNIVERSE."
1141 universe))) 1020 universe)))
1142 (satisfies 1021 (satisfies
1143 (cl-assert (eql (length operands) 1)) 1022 (cl-assert (eql (length operands) 1))
1144 (ert--remove-if-not (car operands) 1023 (cl-remove-if-not (car operands)
1145 (ert-select-tests 't universe)))))))) 1024 (ert-select-tests 't universe))))))))
1146 1025
1147(defun ert--insert-human-readable-selector (selector) 1026(defun ert--insert-human-readable-selector (selector)
@@ -1285,7 +1164,7 @@ Also changes the counters in STATS to match."
1285 "Create a new `ert--stats' object for running TESTS. 1164 "Create a new `ert--stats' object for running TESTS.
1286 1165
1287SELECTOR is the selector that was used to select TESTS." 1166SELECTOR is the selector that was used to select TESTS."
1288 (setq tests (ert--coerce-to-vector tests)) 1167 (setq tests (cl-coerce tests 'vector))
1289 (let ((map (make-hash-table :size (length tests)))) 1168 (let ((map (make-hash-table :size (length tests))))
1290 (cl-loop for i from 0 1169 (cl-loop for i from 0
1291 for test across tests 1170 for test across tests
@@ -1548,10 +1427,10 @@ This can be used as an inverse of `add-to-list'."
1548 (unless key (setq key #'identity)) 1427 (unless key (setq key #'identity))
1549 (unless test (setq test #'equal)) 1428 (unless test (setq test #'equal))
1550 (setf (symbol-value list-var) 1429 (setf (symbol-value list-var)
1551 (ert--remove* element 1430 (cl-remove element
1552 (symbol-value list-var) 1431 (symbol-value list-var)
1553 :key key 1432 :key key
1554 :test test))) 1433 :test test)))
1555 1434
1556 1435
1557;;; Some basic interactive functions. 1436;;; Some basic interactive functions.
@@ -1810,7 +1689,7 @@ BEGIN and END specify a region in the current buffer."
1810 "Return the first line of S, or S if it contains no newlines. 1689 "Return the first line of S, or S if it contains no newlines.
1811 1690
1812The return value does not include the line terminator." 1691The return value does not include the line terminator."
1813 (substring s 0 (ert--string-position ?\n s))) 1692 (substring s 0 (cl-position ?\n s)))
1814 1693
1815(defun ert-face-for-test-result (expectedp) 1694(defun ert-face-for-test-result (expectedp)
1816 "Return a face that shows whether a test result was expected or unexpected. 1695 "Return a face that shows whether a test result was expected or unexpected.
diff --git a/lisp/emacs-lisp/map-ynp.el b/lisp/emacs-lisp/map-ynp.el
index 1919d47687b..56bfe04f9ce 100644
--- a/lisp/emacs-lisp/map-ynp.el
+++ b/lisp/emacs-lisp/map-ynp.el
@@ -131,8 +131,9 @@ Returns the number of actions taken."
131 (unwind-protect 131 (unwind-protect
132 (progn 132 (progn
133 (if (stringp prompter) 133 (if (stringp prompter)
134 (setq prompter (lambda (object) 134 (setq prompter (let ((prompter prompter))
135 (format prompter object)))) 135 (lambda (object)
136 (format prompter object)))))
136 (while (funcall next) 137 (while (funcall next)
137 (setq prompt (funcall prompter elt)) 138 (setq prompt (funcall prompter elt))
138 (cond ((stringp prompt) 139 (cond ((stringp prompt)
diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el
index e000c343721..511f1480099 100644
--- a/lisp/emacs-lisp/pcase.el
+++ b/lisp/emacs-lisp/pcase.el
@@ -482,12 +482,19 @@ MATCH is the pattern that needs to be matched, of the form:
482 all)) 482 all))
483 '(:pcase--succeed . nil)))) 483 '(:pcase--succeed . nil))))
484 484
485(defun pcase--split-pred (upat pat) 485(defun pcase--split-pred (vars upat pat)
486 ;; FIXME: For predicates like (pred (> a)), two such predicates may
487 ;; actually refer to different variables `a'.
488 (let (test) 486 (let (test)
489 (cond 487 (cond
490 ((equal upat pat) '(:pcase--succeed . :pcase--fail)) 488 ((and (equal upat pat)
489 ;; For predicates like (pred (> a)), two such predicates may
490 ;; actually refer to different variables `a'.
491 (or (and (eq 'pred (car upat)) (symbolp (cadr upat)))
492 ;; FIXME: `vars' gives us the environment in which `upat' will
493 ;; run, but we don't have the environment in which `pat' will
494 ;; run, so we can't do a reliable verification. But let's try
495 ;; and catch at least the easy cases such as (bug#14773).
496 (not (pcase--fgrep (mapcar #'car vars) (cadr upat)))))
497 '(:pcase--succeed . :pcase--fail))
491 ((and (eq 'pred (car upat)) 498 ((and (eq 'pred (car upat))
492 (eq 'pred (car-safe pat)) 499 (eq 'pred (car-safe pat))
493 (or (member (cons (cadr upat) (cadr pat)) 500 (or (member (cons (cadr upat) (cadr pat))
@@ -589,7 +596,7 @@ Otherwise, it defers to REST which is a list of branches of the form
589 (if (eq (car upat) 'pred) (pcase--mark-used sym)) 596 (if (eq (car upat) 'pred) (pcase--mark-used sym))
590 (let* ((splitrest 597 (let* ((splitrest
591 (pcase--split-rest 598 (pcase--split-rest
592 sym (lambda (pat) (pcase--split-pred upat pat)) rest)) 599 sym (lambda (pat) (pcase--split-pred vars upat pat)) rest))
593 (then-rest (car splitrest)) 600 (then-rest (car splitrest))
594 (else-rest (cdr splitrest))) 601 (else-rest (cdr splitrest)))
595 (pcase--if (if (and (eq (car upat) 'pred) (symbolp (cadr upat))) 602 (pcase--if (if (and (eq (car upat) 'pred) (symbolp (cadr upat)))
diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el
index e7b371365e4..c39d896f3d3 100644
--- a/lisp/emulation/viper-cmd.el
+++ b/lisp/emulation/viper-cmd.el
@@ -996,93 +996,7 @@ as a Meta key and any number of multiple escapes are allowed."
996 (suspend-emacs)) 996 (suspend-emacs))
997 (viper-change-state-to-emacs))) 997 (viper-change-state-to-emacs)))
998 998
999
1000;; Intercept ESC sequences on dumb terminals.
1001;; Based on the idea contributed by Marcelino Veiga Tuimil <mveiga@dit.upm.es>
1002
1003;; Check if last key was ESC and if so try to reread it as a function key.
1004;; But only if there are characters to read during a very short time.
1005;; Returns the last event, if any.
1006(defun viper-envelop-ESC-key ()
1007 (let ((event last-input-event)
1008 (keyseq [nil])
1009 (inhibit-quit t))
1010 (if (viper-ESC-event-p event)
1011 (progn
1012 ;; Some versions of Emacs (eg., 22.50.8 (?)) have a bug, which makes
1013 ;; even a single ESC into a fast keyseq. To guard against this, we
1014 ;; added a check if there are other events as well. Keep the next
1015 ;; line for the next time the bug reappears, so that will remember to
1016 ;; report it.
1017 ;;(if (and (viper-fast-keysequence-p) unread-command-events)
1018 (if (viper-fast-keysequence-p) ;; for Emacsen without the above bug
1019 (progn
1020 (let (minor-mode-map-alist emulation-mode-map-alists)
1021 (viper-set-unread-command-events event)
1022 (setq keyseq (read-key-sequence nil 'continue-echo))
1023 ) ; let
1024 ;; If keyseq translates into something that still has ESC
1025 ;; at the beginning, separate ESC from the rest of the seq.
1026 ;; In XEmacs we check for events that are keypress meta-key
1027 ;; and convert them into [escape key]
1028 ;;
1029 ;; This is needed for the following reason:
1030 ;; If ESC is the first symbol, we interpret it as if the
1031 ;; user typed ESC and then quickly some other symbols.
1032 ;; If ESC is not the first one, then the key sequence
1033 ;; entered was apparently translated into a function key or
1034 ;; something (e.g., one may have
1035 ;; (define-key function-key-map "\e[192z" [f11])
1036 ;; which would translate the escape-sequence generated by
1037 ;; f11 in an xterm window into the symbolic key f11.
1038 ;;
1039 ;; If `first-key' is not an ESC event, we make it into the
1040 ;; last-command-event in order to pretend that this key was
1041 ;; pressed. This is needed to allow arrow keys to be bound to
1042 ;; macros. Otherwise, viper-exec-mapped-kbd-macro will think
1043 ;; that the last event was ESC and so it'll execute whatever is
1044 ;; bound to ESC. (Viper macros can't be bound to
1045 ;; ESC-sequences).
1046 (let* ((first-key (elt keyseq 0))
1047 (key-mod (event-modifiers first-key)))
1048 (cond ((and (viper-ESC-event-p first-key)
1049 (not (viper-translate-all-ESC-keysequences)))
1050 ;; put keys following ESC on the unread list
1051 ;; and return ESC as the key-sequence
1052 (viper-set-unread-command-events (viper-subseq keyseq 1))
1053 (setq last-input-event event
1054 keyseq (if (featurep 'emacs)
1055 "\e"
1056 (vector (character-to-event ?\e)))))
1057 ((and (featurep 'xemacs)
1058 (key-press-event-p first-key)
1059 (equal '(meta) key-mod))
1060 (viper-set-unread-command-events
1061 (vconcat (vector
1062 (character-to-event (event-key first-key)))
1063 (viper-subseq keyseq 1)))
1064 (setq last-input-event event
1065 keyseq (vector (character-to-event ?\e))))
1066 ((eventp first-key)
1067 (setq last-command-event
1068 (viper-copy-event first-key)))
1069 ))
1070 ) ; end progn
1071
1072 ;; this is escape event with nothing after it
1073 ;; put in unread-command-event and then re-read
1074 (viper-set-unread-command-events event)
1075 (setq keyseq (read-key-sequence nil))
1076 ))
1077 ;; not an escape event
1078 (setq keyseq (vector event)))
1079 keyseq))
1080
1081
1082
1083;; Listen to ESC key. 999;; Listen to ESC key.
1084;; If a sequence of keys starting with ESC is issued with very short delays,
1085;; interpret these keys in Emacs mode, so ESC won't be interpreted as a Vi key.
1086(defun viper-intercept-ESC-key () 1000(defun viper-intercept-ESC-key ()
1087 "Function that implements ESC key in Viper emulation of Vi." 1001 "Function that implements ESC key in Viper emulation of Vi."
1088 (interactive) 1002 (interactive)
@@ -1090,13 +1004,7 @@ as a Meta key and any number of multiple escapes are allowed."
1090 ;; minor-mode map(s) have been temporarily disabled so the ESC 1004 ;; minor-mode map(s) have been temporarily disabled so the ESC
1091 ;; binding to viper-intercept-ESC-key doesn't hide the binding we're 1005 ;; binding to viper-intercept-ESC-key doesn't hide the binding we're
1092 ;; looking for (Bug#9146): 1006 ;; looking for (Bug#9146):
1093 (let* ((event (viper-envelop-ESC-key)) 1007 (let* ((cmd 'viper-intercept-ESC-key))
1094 (cmd (cond ((equal event viper-ESC-key)
1095 'viper-intercept-ESC-key)
1096 ((let ((emulation-mode-map-alists nil))
1097 (key-binding event)))
1098 (t
1099 (error "Viper bell")))))
1100 1008
1101 ;; call the actual function to execute ESC (if no other symbols followed) 1009 ;; call the actual function to execute ESC (if no other symbols followed)
1102 ;; or the key bound to the ESC sequence (if the sequence was issued 1010 ;; or the key bound to the ESC sequence (if the sequence was issued
@@ -4289,6 +4197,11 @@ cursor move past the beginning of line."
4289 (t 4197 (t
4290 (backward-char 1)))) 4198 (backward-char 1))))
4291 4199
4200(defun viper-del-forward-char-in-insert ()
4201 "Delete 1 char forward if in insert or replace state."
4202 (interactive)
4203 ;; don't put on kill ring
4204 (delete-char 1 nil))
4292 4205
4293 4206
4294;; join lines. 4207;; join lines.
@@ -4947,7 +4860,7 @@ Please, specify your level now: ")
4947 (interactive) 4860 (interactive)
4948 (if (< viper-expert-level 2) 4861 (if (< viper-expert-level 2)
4949 (save-buffers-kill-emacs) 4862 (save-buffers-kill-emacs)
4950 (save-buffer) 4863 (if (buffer-modified-p) (save-buffer))
4951 (kill-buffer (current-buffer)))) 4864 (kill-buffer (current-buffer))))
4952 4865
4953 4866
diff --git a/lisp/emulation/viper-keym.el b/lisp/emulation/viper-keym.el
index 0d9d300ab1a..d33b5f4ed58 100644
--- a/lisp/emulation/viper-keym.el
+++ b/lisp/emulation/viper-keym.el
@@ -192,7 +192,7 @@ Enter as a sexp. Examples: \"\\C-z\", [(control ?z)]."
192 :type 'string 192 :type 'string
193 :group 'viper) 193 :group 'viper)
194 194
195(defvar viper-ESC-key (kbd "ESC") 195(defconst viper-ESC-key [escape]
196 "Key used to ESC.") 196 "Key used to ESC.")
197 197
198 198
diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el
index 7f432cdc143..266af1abf2b 100644
--- a/lisp/emulation/viper.el
+++ b/lisp/emulation/viper.el
@@ -14,7 +14,7 @@
14;; filed in the Emacs bug reporting system against this file, a copy 14;; filed in the Emacs bug reporting system against this file, a copy
15;; of the bug report be sent to the maintainer's email address. 15;; of the bug report be sent to the maintainer's email address.
16 16
17(defconst viper-version "3.14.1 of August 15, 2009" 17(defconst viper-version "3.14.2 of July 4, 2013"
18 "The current version of Viper") 18 "The current version of Viper")
19 19
20;; This file is part of GNU Emacs. 20;; This file is part of GNU Emacs.
@@ -411,6 +411,7 @@ widget."
411 dired-mode 411 dired-mode
412 efs-mode 412 efs-mode
413 tar-mode 413 tar-mode
414 egg-status-buffer-mode
414 415
415 browse-kill-ring-mode 416 browse-kill-ring-mode
416 recentf-mode 417 recentf-mode
@@ -660,7 +661,7 @@ user customization, unrelated to Viper. For instance, if the user advised
660undone. 661undone.
661It also can't undo some Viper settings." 662It also can't undo some Viper settings."
662 (interactive) 663 (interactive)
663 664 (viper-setup-ESC-to-escape nil)
664 ;; restore non-viper vars 665 ;; restore non-viper vars
665 (setq-default 666 (setq-default
666 next-line-add-newlines 667 next-line-add-newlines
@@ -825,6 +826,58 @@ It also can't undo some Viper settings."
825 (add-hook 'viper-post-command-hooks 'set-viper-state-in-major-mode t)) 826 (add-hook 'viper-post-command-hooks 'set-viper-state-in-major-mode t))
826 827
827 828
829;;; Handling of tty's ESC event
830
831;; On a tty, an ESC event can either be the user hitting the escape key, or
832;; some element of a byte sequence used to encode for example cursor keys.
833;; So we try to recognize those events that correspond to the escape key and
834;; turn them into `escape' events (same as used under GUIs). The heuristic we
835;; use to distinguish the two cases is based, as usual, on a timeout, and on
836;; the fact that the special ESC=>escape mapping only takes place if the whole
837;; last key-sequence so far is just [?\e], i.e. either we're still in
838;; read-key-sequence, or the last read-key-sequence only read [?\e], which
839;; should ideally never happen because it should have been mapped to [escape].
840
841(defun viper--tty-ESC-filter (map)
842 (if (and (equal (this-single-command-keys) [?\e])
843 (sit-for (/ viper-fast-keyseq-timeout 1000)))
844 [escape] map))
845
846(defun viper--lookup-key (map key)
847 "Kind of like `lookup-key'.
848Two differences:
849- KEY is a single key, not a sequence.
850- the result is the \"raw\" binding, so it can be a `menu-item', rather than the
851 binding contained in that menu item."
852 (catch 'found
853 (map-keymap (lambda (k b) (if (equal key k) (throw 'found b))) map)))
854
855(defun viper-catch-tty-ESC ()
856 "Setup key mappings of current terminal to turn a tty's ESC into `escape'."
857 (when (memq (terminal-live-p (frame-terminal)) '(t pc))
858 (let ((esc-binding (viper-uncatch-tty-ESC)))
859 (define-key input-decode-map
860 [?\e] `(menu-item "" ,esc-binding :filter viper--tty-ESC-filter)))))
861
862(defun viper-uncatch-tty-ESC ()
863 "Don't hack ESC into `escape' any more."
864 (let ((b (viper--lookup-key input-decode-map ?\e)))
865 (and (eq 'menu-item (car-safe b))
866 (eq 'viper--tty-ESC-filter (nth 4 b))
867 (define-key input-decode-map [?\e] (setq b (nth 2 b))))
868 b))
869
870(defun viper-setup-ESC-to-escape (enable)
871 (if enable
872 (add-hook 'tty-setup-hook 'viper-catch-tty-ESC)
873 (remove-hook 'tty-setup-hook 'viper-catch-tty-ESC))
874 (let ((seen ()))
875 (dolist (frame (frame-list))
876 (let ((terminal (frame-terminal frame)))
877 (unless (memq terminal seen)
878 (push terminal seen)
879 (with-selected-frame frame
880 (if enable (viper-catch-tty-ESC) (viper-uncatch-tty-ESC))))))))
828 881
829;; This sets major mode hooks to make them come up in vi-state. 882;; This sets major mode hooks to make them come up in vi-state.
830(defun viper-set-hooks () 883(defun viper-set-hooks ()
@@ -837,6 +890,8 @@ It also can't undo some Viper settings."
837 (if (eq (default-value 'major-mode) 'fundamental-mode) 890 (if (eq (default-value 'major-mode) 'fundamental-mode)
838 (setq-default major-mode 'viper-mode)) 891 (setq-default major-mode 'viper-mode))
839 892
893 (viper-setup-ESC-to-escape t)
894
840 (add-hook 'change-major-mode-hook 'viper-major-mode-change-sentinel) 895 (add-hook 'change-major-mode-hook 'viper-major-mode-change-sentinel)
841 (add-hook 'find-file-hooks 'set-viper-state-in-major-mode) 896 (add-hook 'find-file-hooks 'set-viper-state-in-major-mode)
842 897
@@ -847,13 +902,6 @@ It also can't undo some Viper settings."
847 (defvar emerge-startup-hook) 902 (defvar emerge-startup-hook)
848 (add-hook 'emerge-startup-hook 'viper-change-state-to-emacs) 903 (add-hook 'emerge-startup-hook 'viper-change-state-to-emacs)
849 904
850 ;; Zap bad bindings in flyspell-mouse-map, which prevent ESC from working
851 ;; over misspelled words (due to the overlay keymaps)
852 (defvar flyspell-mode-hook)
853 (defvar flyspell-mouse-map)
854 (add-hook 'flyspell-mode-hook
855 (lambda ()
856 (define-key flyspell-mouse-map viper-ESC-key nil)))
857 ;; if viper is started from .emacs, it might be impossible to get certain 905 ;; if viper is started from .emacs, it might be impossible to get certain
858 ;; info about the display and windows until emacs initialization is complete 906 ;; info about the display and windows until emacs initialization is complete
859 ;; So do it via the window-setup-hook 907 ;; So do it via the window-setup-hook
diff --git a/lisp/faces.el b/lisp/faces.el
index 0a3f0551325..9a34aec2549 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -2097,6 +2097,10 @@ the above example."
2097 nil)))) 2097 nil))))
2098 type) 2098 type)
2099 2099
2100(defvar tty-setup-hook nil
2101 "Hook run after running the initialization function of a new text terminal.
2102This can be used to fine tune the `input-decode-map', for example.")
2103
2100(defun tty-run-terminal-initialization (frame &optional type) 2104(defun tty-run-terminal-initialization (frame &optional type)
2101 "Run the special initialization code for the terminal type of FRAME. 2105 "Run the special initialization code for the terminal type of FRAME.
2102The optional TYPE parameter may be used to override the autodetected 2106The optional TYPE parameter may be used to override the autodetected
@@ -2122,7 +2126,8 @@ terminal type to a different value."
2122 type) 2126 type)
2123 (when (fboundp term-init-func) 2127 (when (fboundp term-init-func)
2124 (funcall term-init-func)) 2128 (funcall term-init-func))
2125 (set-terminal-parameter frame 'terminal-initted term-init-func))))) 2129 (set-terminal-parameter frame 'terminal-initted term-init-func)
2130 (run-hooks 'tty-setup-hook)))))
2126 2131
2127;; Called from C function init_display to initialize faces of the 2132;; Called from C function init_display to initialize faces of the
2128;; dumped terminal frame on startup. 2133;; dumped terminal frame on startup.
diff --git a/lisp/files.el b/lisp/files.el
index 9b56dfa9693..ff4ccec2279 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -316,6 +316,7 @@ A value of nil means don't add newlines.
316 316
317Certain major modes set this locally to the value obtained 317Certain major modes set this locally to the value obtained
318from `mode-require-final-newline'." 318from `mode-require-final-newline'."
319 :safe #'symbolp
319 :type '(choice (const :tag "When visiting" visit) 320 :type '(choice (const :tag "When visiting" visit)
320 (const :tag "When saving" t) 321 (const :tag "When saving" t)
321 (const :tag "When visiting or saving" visit-save) 322 (const :tag "When visiting or saving" visit-save)
@@ -4916,6 +4917,11 @@ change the additional actions you can take on files."
4916 (length autosaved-buffers) 4917 (length autosaved-buffers)
4917 (mapconcat 'identity autosaved-buffers ", ")))))))) 4918 (mapconcat 'identity autosaved-buffers ", "))))))))
4918 4919
4920(defun clear-visited-file-modtime ()
4921 "Clear out records of last mod time of visited file.
4922Next attempt to save will certainly not complain of a discrepancy."
4923 (set-visited-file-modtime 0))
4924
4919(defun not-modified (&optional arg) 4925(defun not-modified (&optional arg)
4920 "Mark current buffer as unmodified, not needing to be saved. 4926 "Mark current buffer as unmodified, not needing to be saved.
4921With prefix ARG, mark buffer as modified, so \\[save-buffer] will save. 4927With prefix ARG, mark buffer as modified, so \\[save-buffer] will save.
diff --git a/lisp/filesets.el b/lisp/filesets.el
index 978512bd3a4..fbf28dbecbc 100644
--- a/lisp/filesets.el
+++ b/lisp/filesets.el
@@ -149,7 +149,7 @@ is loaded before custom.el, set this variable to t.")
149(defun filesets-filter-list (lst cond-fn) 149(defun filesets-filter-list (lst cond-fn)
150 "Remove all elements not conforming to COND-FN from list LST. 150 "Remove all elements not conforming to COND-FN from list LST.
151COND-FN takes one argument: the current element." 151COND-FN takes one argument: the current element."
152; (remove* 'dummy lst :test (lambda (dummy elt) 152; (cl-remove 'dummy lst :test (lambda (dummy elt)
153; (not (funcall cond-fn elt))))) 153; (not (funcall cond-fn elt)))))
154 (let ((rv nil)) 154 (let ((rv nil))
155 (dolist (elt lst rv) 155 (dolist (elt lst rv)
@@ -175,7 +175,7 @@ Like `some', return the first value of FSS-PRED that is non-nil."
175 (let ((fss-rv (funcall fss-pred fss-this))) 175 (let ((fss-rv (funcall fss-pred fss-this)))
176 (when fss-rv 176 (when fss-rv
177 (throw 'exit fss-rv)))))) 177 (throw 'exit fss-rv))))))
178;(fset 'filesets-some 'some) ;; or use the cl function 178;(fset 'filesets-some 'cl-some) ;; or use the cl function
179 179
180(defun filesets-member (fsm-item fsm-lst &rest fsm-keys) 180(defun filesets-member (fsm-item fsm-lst &rest fsm-keys)
181 "Find the first occurrence of FSM-ITEM in FSM-LST. 181 "Find the first occurrence of FSM-ITEM in FSM-LST.
@@ -186,7 +186,7 @@ key is supported."
186 (filesets-ormap (lambda (fsm-this) 186 (filesets-ormap (lambda (fsm-this)
187 (funcall fsm-test fsm-item fsm-this)) 187 (funcall fsm-test fsm-item fsm-this))
188 fsm-lst))) 188 fsm-lst)))
189;(fset 'filesets-member 'member*) ;; or use the cl function 189;(fset 'filesets-member 'cl-member) ;; or use the cl function
190 190
191(defun filesets-sublist (lst beg &optional end) 191(defun filesets-sublist (lst beg &optional end)
192 "Get the sublist of LST from BEG to END - 1." 192 "Get the sublist of LST from BEG to END - 1."
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 34eb28f0965..006b415b180 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,47 @@
12013-07-10 David Engster <deng@randomsample.de>
2
3 * gnus-start.el (gnus-clean-old-newsrc): Always remove 'unexist' marks
4 if `gnus-newsrc-file-version' does not match `gnus-version'. This
5 fixes a bug in Emacs trunk where the 'unexist' marks were always
6 removed at startup because "Gnus v5.13" was considered smaller than "Ma
7 Gnus v0.03".
8
92013-07-10 Tassilo Horn <tsdh@gnu.org>
10
11 * gnus.el (gnus-summary-line-format): Reference
12 `gnus-user-date-format-alist' for the &user-date; format, not
13 `gnus-summary-user-date-format-alist'.
14
152013-07-08 Lars Magne Ingebrigtsen <larsi@gnus.org>
16
17 * nnml.el (nnml-request-compact-group): Don't bug out if we can't
18 delete files (bug#13481).
19
202013-07-08 Tassilo Horn <tsdh@gnu.org>
21
22 * gnus-registry.el (gnus-registry-remove-extra-data): New function.
23
242013-07-06 Lars Ingebrigtsen <larsi@gnus.org>
25
26 * gnus-art.el (gnus-block-private-groups): Allow `global' methods to
27 display images.
28
29 * gnus.el (gnus-valid-select-methods): Mark nnrss as global.
30
31 * message.el (message-cancel-news): According to
32 <mailman.216.1372942181.12400.help-gnu-emacs@gnu.org>, "cancel" is
33 preferred over "cmsg cancel" in the Subject.
34
35 * nnir.el (nnir-engines): Note that the group specs are regexps
36 (bug#13238).
37
38 * gnus-msg.el (gnus-copy-article-buffer): If the article buffer has
39 gotten read-only text properties, ensure that those aren't heeded when
40 copying stuff over (bug#13434).
41
42 * mm-view.el (mm-inline-text-html): Don't bug out on multipart messages
43 (bug#13762).
44
12013-07-05 David Kastrup <dak@gnu.org> 452013-07-05 David Kastrup <dak@gnu.org>
2 46
3 * auth-source.el (auth-source-netrc-parse-one): Allow empty strings in 47 * auth-source.el (auth-source-netrc-parse-one): Allow empty strings in
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index 5840aacd7a3..b41ff9c0550 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -6947,7 +6947,8 @@ If given a prefix, show the hidden text instead."
6947 (set-buffer buf)))))) 6947 (set-buffer buf))))))
6948 6948
6949(defun gnus-block-private-groups (group) 6949(defun gnus-block-private-groups (group)
6950 (if (gnus-news-group-p group) 6950 (if (or (gnus-news-group-p group)
6951 (gnus-member-of-valid 'global group))
6951 ;; Block nothing in news groups. 6952 ;; Block nothing in news groups.
6952 nil 6953 nil
6953 ;; Block everything anywhere else. 6954 ;; Block everything anywhere else.
diff --git a/lisp/gnus/gnus-msg.el b/lisp/gnus/gnus-msg.el
index fce9a3633c2..e3f18662af4 100644
--- a/lisp/gnus/gnus-msg.el
+++ b/lisp/gnus/gnus-msg.el
@@ -920,6 +920,7 @@ header line with the old Message-ID."
920 (with-current-buffer article-buffer 920 (with-current-buffer article-buffer
921 (let ((gnus-newsgroup-charset (or gnus-article-charset 921 (let ((gnus-newsgroup-charset (or gnus-article-charset
922 gnus-newsgroup-charset)) 922 gnus-newsgroup-charset))
923 (inhibit-read-only t)
923 (gnus-newsgroup-ignored-charsets 924 (gnus-newsgroup-ignored-charsets
924 (or gnus-article-ignored-charsets 925 (or gnus-article-ignored-charsets
925 gnus-newsgroup-ignored-charsets))) 926 gnus-newsgroup-ignored-charsets)))
diff --git a/lisp/gnus/gnus-registry.el b/lisp/gnus/gnus-registry.el
index 5a7dfd82d28..6f2fe78c3d8 100644
--- a/lisp/gnus/gnus-registry.el
+++ b/lisp/gnus/gnus-registry.el
@@ -1186,6 +1186,29 @@ data stored in the registry."
1186 (gnus-select-group-with-message-id group message-id) t) 1186 (gnus-select-group-with-message-id group message-id) t)
1187 (throw 'found t)))))))) 1187 (throw 'found t))))))))
1188 1188
1189(defun gnus-registry-remove-extra-data (extra)
1190 "Remove tracked EXTRA data from the gnus registry.
1191EXTRA is a list of symbols. Valid symbols are those contained in
1192the docs of `gnus-registry-track-extra'. This command is useful
1193when you stop tracking some extra data and now want to purge it
1194from your existing entries."
1195 (interactive (list (mapcar 'intern
1196 (completing-read-multiple
1197 "Extra data: "
1198 '("subject" "sender" "recipient")))))
1199 (when extra
1200 (let ((db gnus-registry-db))
1201 (registry-reindex db)
1202 (loop for k being the hash-keys of (oref db :data)
1203 using (hash-value v)
1204 do (let ((newv (delq nil (mapcar #'(lambda (entry)
1205 (unless (member (car entry) extra)
1206 entry))
1207 v))))
1208 (registry-delete db (list k) nil)
1209 (gnus-registry-insert db k newv)))
1210 (registry-reindex db))))
1211
1189;; TODO: a few things 1212;; TODO: a few things
1190 1213
1191(provide 'gnus-registry) 1214(provide 'gnus-registry)
diff --git a/lisp/gnus/gnus-start.el b/lisp/gnus/gnus-start.el
index 084af884930..94803800e0b 100644
--- a/lisp/gnus/gnus-start.el
+++ b/lisp/gnus/gnus-start.el
@@ -2314,8 +2314,9 @@ If FORCE is non-nil, the .newsrc file is read."
2314 (gnus-info-set-marks 2314 (gnus-info-set-marks
2315 info (delete exist (gnus-info-marks info)))))) 2315 info (delete exist (gnus-info-marks info))))))
2316 (when (or force 2316 (when (or force
2317 (< (gnus-continuum-version gnus-newsrc-file-version) 2317 (not (string= gnus-newsrc-file-version gnus-version)))
2318 (gnus-continuum-version "Ma Gnus v0.03"))) 2318 (message (concat "Removing unexist marks because newsrc "
2319 "version does not match Gnus version."))
2319 ;; Remove old `exist' marks from old nnimap groups. 2320 ;; Remove old `exist' marks from old nnimap groups.
2320 (dolist (info (cdr gnus-newsrc-alist)) 2321 (dolist (info (cdr gnus-newsrc-alist))
2321 (let ((exist (assoc 'unexist (gnus-info-marks info)))) 2322 (let ((exist (assoc 'unexist (gnus-info-marks info))))
diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el
index 9a927a1cfab..8741a03b54d 100644
--- a/lisp/gnus/gnus.el
+++ b/lisp/gnus/gnus.el
@@ -1628,7 +1628,7 @@ slower."
1628 ("nnfolder" mail respool address) 1628 ("nnfolder" mail respool address)
1629 ("nngateway" post-mail address prompt-address physical-address) 1629 ("nngateway" post-mail address prompt-address physical-address)
1630 ("nnweb" none) 1630 ("nnweb" none)
1631 ("nnrss" none) 1631 ("nnrss" none global)
1632 ("nnagent" post-mail) 1632 ("nnagent" post-mail)
1633 ("nnimap" post-mail address prompt-address physical-address respool 1633 ("nnimap" post-mail address prompt-address physical-address respool
1634 server-marks) 1634 server-marks)
@@ -3007,7 +3007,7 @@ with some simple extensions.
3007 summary just like information from any other summary 3007 summary just like information from any other summary
3008 specifier. 3008 specifier.
3009&user-date; Age sensitive date format. Various date format is 3009&user-date; Age sensitive date format. Various date format is
3010 defined in `gnus-summary-user-date-format-alist'. 3010 defined in `gnus-user-date-format-alist'.
3011 3011
3012 3012
3013The %U (status), %R (replied) and %z (zcore) specs have to be handled 3013The %U (status), %R (replied) and %z (zcore) specs have to be handled
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index c6f5d904677..b35eb9dca12 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -7145,7 +7145,7 @@ If ARG, allow editing of the cancellation message."
7145 (erase-buffer) 7145 (erase-buffer)
7146 (insert "Newsgroups: " newsgroups "\n" 7146 (insert "Newsgroups: " newsgroups "\n"
7147 "From: " from "\n" 7147 "From: " from "\n"
7148 "Subject: cmsg cancel " message-id "\n" 7148 "Subject: cancel " message-id "\n"
7149 "Control: cancel " message-id "\n" 7149 "Control: cancel " message-id "\n"
7150 (if distribution 7150 (if distribution
7151 (concat "Distribution: " distribution "\n") 7151 (concat "Distribution: " distribution "\n")
diff --git a/lisp/gnus/mm-view.el b/lisp/gnus/mm-view.el
index b1cba27c335..9512a411d81 100644
--- a/lisp/gnus/mm-view.el
+++ b/lisp/gnus/mm-view.el
@@ -419,16 +419,18 @@
419 (buffer-string))))) 419 (buffer-string)))))
420 420
421(defun mm-inline-text-html (handle) 421(defun mm-inline-text-html (handle)
422 (let* ((func mm-text-html-renderer) 422 (if (stringp (car handle))
423 (entry (assq func mm-text-html-renderer-alist)) 423 (mapcar 'mm-inline-text-html (cdr handle))
424 (inhibit-read-only t)) 424 (let* ((func mm-text-html-renderer)
425 (if entry 425 (entry (assq func mm-text-html-renderer-alist))
426 (setq func (cdr entry))) 426 (inhibit-read-only t))
427 (cond 427 (if entry
428 ((functionp func) 428 (setq func (cdr entry)))
429 (funcall func handle)) 429 (cond
430 (t 430 ((functionp func)
431 (apply (car func) handle (cdr func)))))) 431 (funcall func handle))
432 (t
433 (apply (car func) handle (cdr func)))))))
432 434
433(defun mm-inline-text-vcard (handle) 435(defun mm-inline-text-vcard (handle)
434 (let ((inhibit-read-only t)) 436 (let ((inhibit-read-only t))
diff --git a/lisp/gnus/nnir.el b/lisp/gnus/nnir.el
index 22dee30e8fa..4dd123bf2c7 100644
--- a/lisp/gnus/nnir.el
+++ b/lisp/gnus/nnir.el
@@ -548,15 +548,15 @@ that it is for notmuch, not Namazu."
548 (gmane nnir-run-gmane 548 (gmane nnir-run-gmane
549 ((gmane-author . "Gmane Author: "))) 549 ((gmane-author . "Gmane Author: ")))
550 (swish++ nnir-run-swish++ 550 (swish++ nnir-run-swish++
551 ((swish++-group . "Swish++ Group spec: "))) 551 ((swish++-group . "Swish++ Group spec (regexp): ")))
552 (swish-e nnir-run-swish-e 552 (swish-e nnir-run-swish-e
553 ((swish-e-group . "Swish-e Group spec: "))) 553 ((swish-e-group . "Swish-e Group spec (regexp): ")))
554 (namazu nnir-run-namazu 554 (namazu nnir-run-namazu
555 ()) 555 ())
556 (notmuch nnir-run-notmuch 556 (notmuch nnir-run-notmuch
557 ()) 557 ())
558 (hyrex nnir-run-hyrex 558 (hyrex nnir-run-hyrex
559 ((hyrex-group . "Hyrex Group spec: "))) 559 ((hyrex-group . "Hyrex Group spec (regexp): ")))
560 (find-grep nnir-run-find-grep 560 (find-grep nnir-run-find-grep
561 ((grep-options . "Grep options: ")))) 561 ((grep-options . "Grep options: "))))
562 "Alist of supported search engines. 562 "Alist of supported search engines.
diff --git a/lisp/gnus/nnml.el b/lisp/gnus/nnml.el
index 64e1ee11977..05d0c902340 100644
--- a/lisp/gnus/nnml.el
+++ b/lisp/gnus/nnml.el
@@ -1094,7 +1094,10 @@ Use the nov database for the current group if available."
1094 (concat group ":" new-number-string))) 1094 (concat group ":" new-number-string)))
1095 ;; Save to the new file: 1095 ;; Save to the new file:
1096 (nnmail-write-region (point-min) (point-max) newfile)) 1096 (nnmail-write-region (point-min) (point-max) newfile))
1097 (funcall nnmail-delete-file-function oldfile)) 1097 (condition-case ()
1098 (funcall nnmail-delete-file-function oldfile)
1099 (file-error
1100 (message "Couldn't delete %s" oldfile))))
1098 ;; 2/ Update all marks for this article: 1101 ;; 2/ Update all marks for this article:
1099 ;; #### NOTE: it is possible that the new article number 1102 ;; #### NOTE: it is possible that the new article number
1100 ;; #### already belongs to a range, whereas the corresponding 1103 ;; #### already belongs to a range, whereas the corresponding
diff --git a/lisp/ido.el b/lisp/ido.el
index f695ec117f1..9c4e56544cb 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -3461,8 +3461,14 @@ This is to make them appear as if they were \"virtual buffers\"."
3461 (setq ido-virtual-buffers nil) 3461 (setq ido-virtual-buffers nil)
3462 (let (name) 3462 (let (name)
3463 (dolist (head recentf-list) 3463 (dolist (head recentf-list)
3464 (and (setq name (file-name-nondirectory head)) 3464 (setq name (file-name-nondirectory head))
3465 (null (get-file-buffer head)) 3465 ;; In case HEAD is a directory with trailing /. See bug#14552.
3466 (when (equal name "")
3467 (setq name (file-name-nondirectory (directory-file-name head))))
3468 (when (equal name "")
3469 (setq name head))
3470 (and (not (equal name ""))
3471 (null (get-file-buffer head))
3466 (not (assoc name ido-virtual-buffers)) 3472 (not (assoc name ido-virtual-buffers))
3467 (not (member name ido-temp-list)) 3473 (not (member name ido-temp-list))
3468 (not (ido-ignore-item-p name ido-ignore-buffers)) 3474 (not (ido-ignore-item-p name ido-ignore-buffers))
@@ -4721,9 +4727,12 @@ Modified from `icomplete-completions'."
4721 4727
4722;;; Helper functions for other programs 4728;;; Helper functions for other programs
4723 4729
4724(put 'dired-do-rename 'ido 'ignore)
4725(put 'ibuffer-find-file 'ido 'find-file) 4730(put 'ibuffer-find-file 'ido 'find-file)
4731(put 'dired 'ido 'dir)
4726(put 'dired-other-window 'ido 'dir) 4732(put 'dired-other-window 'ido 'dir)
4733;; See http://debbugs.gnu.org/11954 for reasons.
4734(put 'dired-do-copy 'ido 'ignore)
4735(put 'dired-do-rename 'ido 'ignore)
4727 4736
4728;;;###autoload 4737;;;###autoload
4729(defun ido-read-buffer (prompt &optional default require-match) 4738(defun ido-read-buffer (prompt &optional default require-match)
@@ -4754,9 +4763,7 @@ See `read-file-name' for additional parameters."
4754 (eq (get this-command 'ido) 'dir) 4763 (eq (get this-command 'ido) 'dir)
4755 (memq this-command ido-read-file-name-as-directory-commands)) 4764 (memq this-command ido-read-file-name-as-directory-commands))
4756 (setq filename 4765 (setq filename
4757 (ido-read-directory-name prompt dir default-filename mustmatch initial)) 4766 (ido-read-directory-name prompt dir default-filename mustmatch initial)))
4758 (if (eq ido-exit 'fallback)
4759 (setq filename 'fallback)))
4760 ((and (not (eq (get this-command 'ido) 'ignore)) 4767 ((and (not (eq (get this-command 'ido) 'ignore))
4761 (not (memq this-command ido-read-file-name-non-ido)) 4768 (not (memq this-command ido-read-file-name-non-ido))
4762 (or (null predicate) (eq predicate 'file-exists-p))) 4769 (or (null predicate) (eq predicate 'file-exists-p)))
@@ -4776,7 +4783,15 @@ See `read-file-name' for additional parameters."
4776 (ido-find-literal nil)) 4783 (ido-find-literal nil))
4777 (setq ido-exit nil) 4784 (setq ido-exit nil)
4778 (setq filename 4785 (setq filename
4779 (ido-read-internal 'file prompt 'ido-file-history default-filename mustmatch initial)) 4786 (ido-read-internal 'file prompt 'ido-file-history
4787 (cond ; Bug#11861.
4788 ((stringp default-filename) default-filename)
4789 ((consp default-filename) (car default-filename))
4790 ((and (not default-filename) initial)
4791 (expand-file-name initial dir))
4792 (buffer-file-name buffer-file-name))
4793 mustmatch initial))
4794 (setq dir ido-current-directory) ; See bug#1516.
4780 (cond 4795 (cond
4781 ((eq ido-exit 'fallback) 4796 ((eq ido-exit 'fallback)
4782 (setq filename 'fallback)) 4797 (setq filename 'fallback))
@@ -4808,12 +4823,21 @@ See `read-directory-name' for additional parameters."
4808 (ido-directory-too-big-p ido-current-directory))) 4823 (ido-directory-too-big-p ido-current-directory)))
4809 (ido-work-directory-index -1) 4824 (ido-work-directory-index -1)
4810 (ido-work-file-index -1)) 4825 (ido-work-file-index -1))
4811 (setq filename 4826 (setq filename (ido-read-internal
4812 (ido-read-internal 'dir prompt 'ido-file-history default-dirname mustmatch initial)) 4827 'dir prompt 'ido-file-history
4813 (if filename 4828 (or default-dirname ; Bug#11861.
4814 (if (and (stringp filename) (string-equal filename ".")) 4829 (if initial
4815 ido-current-directory 4830 (expand-file-name initial ido-current-directory)
4816 (concat ido-current-directory filename))))) 4831 ido-current-directory))
4832 mustmatch initial))
4833 (cond
4834 ((eq ido-exit 'fallback)
4835 (let ((read-file-name-function nil))
4836 (run-hook-with-args 'ido-before-fallback-functions 'read-directory-name)
4837 (read-directory-name prompt ido-current-directory
4838 default-dirname mustmatch initial)))
4839 ((equal filename ".") ido-current-directory)
4840 (t (concat ido-current-directory filename)))))
4817 4841
4818;;;###autoload 4842;;;###autoload
4819(defun ido-completing-read (prompt choices &optional _predicate require-match 4843(defun ido-completing-read (prompt choices &optional _predicate require-match
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index bdc30bc9292..4506ede8722 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -145,6 +145,7 @@ cid: URL as the argument.")
145 (define-key map [follow-link] 'mouse-face) 145 (define-key map [follow-link] 'mouse-face)
146 (define-key map "I" 'shr-insert-image) 146 (define-key map "I" 'shr-insert-image)
147 (define-key map "w" 'shr-copy-url) 147 (define-key map "w" 'shr-copy-url)
148 (define-key map "u" 'shr-copy-url)
148 (define-key map "v" 'shr-browse-url) 149 (define-key map "v" 'shr-browse-url)
149 (define-key map "o" 'shr-save-contents) 150 (define-key map "o" 'shr-save-contents)
150 (define-key map "\r" 'shr-browse-url) 151 (define-key map "\r" 'shr-browse-url)
diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el
index 4c6141fe42b..f7f570590c8 100644
--- a/lisp/net/tramp-cache.el
+++ b/lisp/net/tramp-cache.el
@@ -38,9 +38,11 @@
38;; 38;;
39;; - localname is a string. This are temporary properties, which are 39;; - localname is a string. This are temporary properties, which are
40;; related to the file localname is referring to. Examples: 40;; related to the file localname is referring to. Examples:
41;; "file-exists-p" is t or nile, depending on the file existence, or 41;; "file-exists-p" is t or nil, depending on the file existence, or
42;; "file-attributes" caches the result of the function 42;; "file-attributes" caches the result of the function
43;; `file-attributes'. 43;; `file-attributes'. These entries have a timestamp, and they
44;; expire after `remote-file-name-inhibit-cache' seconds if this
45;; variable is set.
44;; 46;;
45;; - The key is a process. This are temporary properties related to 47;; - The key is a process. This are temporary properties related to
46;; an open connection. Examples: "scripts" keeps shell script 48;; an open connection. Examples: "scripts" keeps shell script
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 6ba055b8bb8..c2fdc0491b6 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -1539,7 +1539,8 @@ connection if a previous connection has died for some reason."
1539 ;; indicated by the "mounted" signal, i.e. the "fuse-mountpoint" 1539 ;; indicated by the "mounted" signal, i.e. the "fuse-mountpoint"
1540 ;; file property. 1540 ;; file property.
1541 (with-timeout 1541 (with-timeout
1542 (60 1542 ((or (tramp-get-method-parameter method 'tramp-connection-timeout)
1543 tramp-connection-timeout)
1543 (if (zerop (length (tramp-file-name-user vec))) 1544 (if (zerop (length (tramp-file-name-user vec)))
1544 (tramp-error 1545 (tramp-error
1545 vec 'file-error 1546 vec 'file-error
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index d7316b8d2ea..281f497692d 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -222,21 +222,24 @@ detected as prompt when being sent on echoing hosts, therefore.")
222 (tramp-login-program "su") 222 (tramp-login-program "su")
223 (tramp-login-args (("-") ("%u"))) 223 (tramp-login-args (("-") ("%u")))
224 (tramp-remote-shell "/bin/sh") 224 (tramp-remote-shell "/bin/sh")
225 (tramp-remote-shell-args ("-c")))) 225 (tramp-remote-shell-args ("-c"))
226 (tramp-connection-timeout 10)))
226;;;###tramp-autoload 227;;;###tramp-autoload
227(add-to-list 'tramp-methods 228(add-to-list 'tramp-methods
228 '("sudo" 229 '("sudo"
229 (tramp-login-program "sudo") 230 (tramp-login-program "sudo")
230 (tramp-login-args (("-u" "%u") ("-s") ("-H") ("-p" "Password:"))) 231 (tramp-login-args (("-u" "%u") ("-s") ("-H") ("-p" "Password:")))
231 (tramp-remote-shell "/bin/sh") 232 (tramp-remote-shell "/bin/sh")
232 (tramp-remote-shell-args ("-c")))) 233 (tramp-remote-shell-args ("-c"))
234 (tramp-connection-timeout 10)))
233;;;###tramp-autoload 235;;;###tramp-autoload
234(add-to-list 'tramp-methods 236(add-to-list 'tramp-methods
235 '("ksu" 237 '("ksu"
236 (tramp-login-program "ksu") 238 (tramp-login-program "ksu")
237 (tramp-login-args (("%u") ("-q"))) 239 (tramp-login-args (("%u") ("-q")))
238 (tramp-remote-shell "/bin/sh") 240 (tramp-remote-shell "/bin/sh")
239 (tramp-remote-shell-args ("-c")))) 241 (tramp-remote-shell-args ("-c"))
242 (tramp-connection-timeout 10)))
240;;;###tramp-autoload 243;;;###tramp-autoload
241(add-to-list 'tramp-methods 244(add-to-list 'tramp-methods
242 '("krlogin" 245 '("krlogin"
@@ -3752,12 +3755,16 @@ file exists and nonzero exit status otherwise."
3752 "Wait for shell prompt and barf if none appears. 3755 "Wait for shell prompt and barf if none appears.
3753Looks at process PROC to see if a shell prompt appears in TIMEOUT 3756Looks at process PROC to see if a shell prompt appears in TIMEOUT
3754seconds. If not, it produces an error message with the given ERROR-ARGS." 3757seconds. If not, it produces an error message with the given ERROR-ARGS."
3755 (unless 3758 (let ((vec (tramp-get-connection-property proc "vector" nil)))
3756 (tramp-wait-for-regexp 3759 (condition-case err
3757 proc timeout 3760 (tramp-wait-for-regexp
3758 (format 3761 proc timeout
3759 "\\(%s\\|%s\\)\\'" shell-prompt-pattern tramp-shell-prompt-pattern)) 3762 (format
3760 (apply 'tramp-error-with-buffer nil proc 'file-error error-args))) 3763 "\\(%s\\|%s\\)\\'" shell-prompt-pattern tramp-shell-prompt-pattern))
3764 (error
3765 (delete-process proc)
3766 (apply 'tramp-error-with-buffer
3767 (tramp-get-connection-buffer vec) vec 'file-error error-args)))))
3761 3768
3762(defun tramp-open-connection-setup-interactive-shell (proc vec) 3769(defun tramp-open-connection-setup-interactive-shell (proc vec)
3763 "Set up an interactive shell. 3770 "Set up an interactive shell.
@@ -4332,9 +4339,6 @@ Gateway hops are already opened."
4332 ;; Result. 4339 ;; Result.
4333 target-alist)) 4340 target-alist))
4334 4341
4335(defvar tramp-current-connection nil
4336 "Last connection timestamp.")
4337
4338(defun tramp-maybe-open-connection (vec) 4342(defun tramp-maybe-open-connection (vec)
4339 "Maybe open a connection VEC. 4343 "Maybe open a connection VEC.
4340Does not do anything if a connection is already open, but re-opens the 4344Does not do anything if a connection is already open, but re-opens the
@@ -4348,7 +4352,7 @@ connection if a previous connection has died for some reason."
4348 ;; If Tramp opens the same connection within a short time frame, 4352 ;; If Tramp opens the same connection within a short time frame,
4349 ;; there is a problem. We shall signal this. 4353 ;; there is a problem. We shall signal this.
4350 (unless (or (and p (processp p) (memq (process-status p) '(run open))) 4354 (unless (or (and p (processp p) (memq (process-status p) '(run open)))
4351 (not (equal (butlast (append vec nil)) 4355 (not (equal (butlast (append vec nil) 2)
4352 (car tramp-current-connection))) 4356 (car tramp-current-connection)))
4353 (> (tramp-time-diff 4357 (> (tramp-time-diff
4354 (current-time) (cdr tramp-current-connection)) 4358 (current-time) (cdr tramp-current-connection))
@@ -4433,7 +4437,7 @@ connection if a previous connection has died for some reason."
4433 (set-process-sentinel p 'tramp-process-sentinel) 4437 (set-process-sentinel p 'tramp-process-sentinel)
4434 (tramp-compat-set-process-query-on-exit-flag p nil) 4438 (tramp-compat-set-process-query-on-exit-flag p nil)
4435 (setq tramp-current-connection 4439 (setq tramp-current-connection
4436 (cons (butlast (append vec nil)) (current-time)) 4440 (cons (butlast (append vec nil) 2) (current-time))
4437 tramp-current-host (system-name)) 4441 tramp-current-host (system-name))
4438 4442
4439 (tramp-message 4443 (tramp-message
@@ -4441,8 +4445,8 @@ connection if a previous connection has died for some reason."
4441 4445
4442 ;; Check whether process is alive. 4446 ;; Check whether process is alive.
4443 (tramp-barf-if-no-shell-prompt 4447 (tramp-barf-if-no-shell-prompt
4444 p 60 4448 p 10
4445 "Couldn't find local shell prompt %s" tramp-encoding-shell) 4449 "Couldn't find local shell prompt for %s" tramp-encoding-shell)
4446 4450
4447 ;; Now do all the connections as specified. 4451 ;; Now do all the connections as specified.
4448 (while target-alist 4452 (while target-alist
@@ -4460,6 +4464,9 @@ connection if a previous connection has died for some reason."
4460 (async-args 4464 (async-args
4461 (tramp-get-method-parameter 4465 (tramp-get-method-parameter
4462 l-method 'tramp-async-args)) 4466 l-method 'tramp-async-args))
4467 (connection-timeout
4468 (tramp-get-method-parameter
4469 l-method 'tramp-connection-timeout))
4463 (gw-args 4470 (gw-args
4464 (tramp-get-method-parameter l-method 'tramp-gw-args)) 4471 (tramp-get-method-parameter l-method 'tramp-gw-args))
4465 (gw (tramp-get-file-property hop "" "gateway" nil)) 4472 (gw (tramp-get-file-property hop "" "gateway" nil))
@@ -4542,7 +4549,8 @@ connection if a previous connection has died for some reason."
4542 (tramp-message vec 3 "Sending command `%s'" command) 4549 (tramp-message vec 3 "Sending command `%s'" command)
4543 (tramp-send-command vec command t t) 4550 (tramp-send-command vec command t t)
4544 (tramp-process-actions 4551 (tramp-process-actions
4545 p vec pos tramp-actions-before-shell 60) 4552 p vec pos tramp-actions-before-shell
4553 (or connection-timeout tramp-connection-timeout))
4546 (tramp-message 4554 (tramp-message
4547 vec 3 "Found remote shell prompt on `%s'" l-host)) 4555 vec 3 "Found remote shell prompt on `%s'" l-host))
4548 ;; Next hop. 4556 ;; Next hop.
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index f114c681fb7..3513701d20e 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -252,6 +252,11 @@ pair of the form (KEY VALUE). The following KEYs are defined:
252 * `tramp-tmpdir' 252 * `tramp-tmpdir'
253 A directory on the remote host for temporary files. If not 253 A directory on the remote host for temporary files. If not
254 specified, \"/tmp\" is taken as default. 254 specified, \"/tmp\" is taken as default.
255 * `tramp-connection-timeout'
256 This is the maximum time to be spent for establishing a connection.
257 In general, the global default value shall be used, but for
258 some methods, like \"su\" or \"sudo\", a shorter timeout
259 might be desirable.
255 260
256What does all this mean? Well, you should specify `tramp-login-program' 261What does all this mean? Well, you should specify `tramp-login-program'
257for all methods; this program is used to log in to the remote site. Then, 262for all methods; this program is used to log in to the remote site. Then,
@@ -1034,6 +1039,13 @@ opening a connection to a remote host."
1034 :group 'tramp 1039 :group 'tramp
1035 :type '(choice (const nil) (const t) (const pty))) 1040 :type '(choice (const nil) (const t) (const pty)))
1036 1041
1042(defcustom tramp-connection-timeout 60
1043 "Defines the max time to wait for establishing a connection (in seconds).
1044This can be overwritten for different connection types in `tramp-methods'."
1045 :group 'tramp
1046 :version "24.4"
1047 :type 'integer)
1048
1037(defcustom tramp-connection-min-time-diff 5 1049(defcustom tramp-connection-min-time-diff 5
1038 "Defines seconds between two consecutive connection attempts. 1050 "Defines seconds between two consecutive connection attempts.
1039This is necessary as self defense mechanism, in order to avoid 1051This is necessary as self defense mechanism, in order to avoid
@@ -1071,6 +1083,9 @@ means to use always cached values for the directory contents."
1071(defvar tramp-current-host nil 1083(defvar tramp-current-host nil
1072 "Remote host for this *tramp* buffer.") 1084 "Remote host for this *tramp* buffer.")
1073 1085
1086(defvar tramp-current-connection nil
1087 "Last connection timestamp.")
1088
1074;;;###autoload 1089;;;###autoload
1075(defconst tramp-completion-file-name-handler-alist 1090(defconst tramp-completion-file-name-handler-alist
1076 '((file-name-all-completions . tramp-completion-handle-file-name-all-completions) 1091 '((file-name-all-completions . tramp-completion-handle-file-name-all-completions)
@@ -1464,10 +1479,6 @@ ARGS to actually emit the message (if applicable)."
1464This variable is used to disable messages from `tramp-error'. 1479This variable is used to disable messages from `tramp-error'.
1465The messages are visible anyway, because an error is raised.") 1480The messages are visible anyway, because an error is raised.")
1466 1481
1467(defvar tramp-message-show-progress-reporter-message t
1468 "Show Tramp progress reporter message in the minibuffer.
1469This variable is used to disable recursive progress reporter messages.")
1470
1471(defsubst tramp-message (vec-or-proc level fmt-string &rest args) 1482(defsubst tramp-message (vec-or-proc level fmt-string &rest args)
1472 "Emit a message depending on verbosity level. 1483 "Emit a message depending on verbosity level.
1473VEC-OR-PROC identifies the Tramp buffer to use. It can be either a 1484VEC-OR-PROC identifies the Tramp buffer to use. It can be either a
@@ -1536,23 +1547,32 @@ signal identifier to be raised, remaining args passed to
1536If BUFFER is nil, show the connection buffer. Wait for 30\", or until 1547If BUFFER is nil, show the connection buffer. Wait for 30\", or until
1537an input event arrives. The other arguments are passed to `tramp-error'." 1548an input event arrives. The other arguments are passed to `tramp-error'."
1538 (save-window-excursion 1549 (save-window-excursion
1539 (unwind-protect 1550 (let* ((buf (or (and (bufferp buffer) buffer)
1540 (apply 'tramp-error vec-or-proc signal fmt-string args) 1551 (and (processp vec-or-proc) (process-buffer vec-or-proc))
1541 (when (and vec-or-proc 1552 (and (vectorp vec-or-proc)
1542 tramp-message-show-message 1553 (tramp-get-connection-buffer vec-or-proc))))
1543 (not (zerop tramp-verbose)) 1554 (vec (or (and (vectorp vec-or-proc) vec-or-proc)
1544 (not (tramp-completion-mode-p))) 1555 (and buf (with-current-buffer buf
1545 (let ((enable-recursive-minibuffers t)) 1556 (tramp-dissect-file-name default-directory))))))
1546 (pop-to-buffer 1557 (unwind-protect
1547 (or (and (bufferp buffer) buffer) 1558 (apply 'tramp-error vec-or-proc signal fmt-string args)
1548 (and (processp vec-or-proc) (process-buffer vec-or-proc)) 1559 ;; Save exit.
1549 (tramp-get-connection-buffer vec-or-proc))) 1560 (when (and buf
1550 (when (string-equal fmt-string "Process died") 1561 tramp-message-show-message
1551 (message 1562 (not (zerop tramp-verbose))
1552 "%s\n %s" 1563 (not (tramp-completion-mode-p)))
1553 "Tramp failed to connect. If this happens repeatedly, try" 1564 (let ((enable-recursive-minibuffers t))
1554 "`M-x tramp-cleanup-this-connection'")) 1565 ;; `tramp-error' does not show messages. So we must do it
1555 (sit-for 30)))))) 1566 ;; ourselves.
1567 (message fmt-string args)
1568 ;; Show buffer.
1569 (pop-to-buffer buf)
1570 (discard-input)
1571 (sit-for 30)))
1572 ;; Reset timestamp. It would be wrong after waiting for a while.
1573 (when (equal (butlast (append vec nil) 2)
1574 (car tramp-current-connection))
1575 (setcdr tramp-current-connection (current-time)))))))
1556 1576
1557(defmacro with-parsed-tramp-file-name (filename var &rest body) 1577(defmacro with-parsed-tramp-file-name (filename var &rest body)
1558 "Parse a Tramp filename and make components available in the body. 1578 "Parse a Tramp filename and make components available in the body.
@@ -1596,16 +1616,15 @@ If VAR is nil, then we bind `v' to the structure and `method', `user',
1596 1616
1597(defmacro with-tramp-progress-reporter (vec level message &rest body) 1617(defmacro with-tramp-progress-reporter (vec level message &rest body)
1598 "Executes BODY, spinning a progress reporter with MESSAGE. 1618 "Executes BODY, spinning a progress reporter with MESSAGE.
1599If LEVEL does not fit for visible messages, or if this is a 1619If LEVEL does not fit for visible messages, there are only traces
1600nested call of the macro, there are only traces without a visible 1620without a visible progress reporter."
1601progress reporter."
1602 (declare (indent 3) (debug t)) 1621 (declare (indent 3) (debug t))
1603 `(let (pr tm) 1622 `(let ((result "failed")
1623 pr tm)
1604 (tramp-message ,vec ,level "%s..." ,message) 1624 (tramp-message ,vec ,level "%s..." ,message)
1605 ;; We start a pulsing progress reporter after 3 seconds. Feature 1625 ;; We start a pulsing progress reporter after 3 seconds. Feature
1606 ;; introduced in Emacs 24.1. 1626 ;; introduced in Emacs 24.1.
1607 (when (and tramp-message-show-progress-reporter-message 1627 (when (and tramp-message-show-message
1608 tramp-message-show-message
1609 ;; Display only when there is a minimum level. 1628 ;; Display only when there is a minimum level.
1610 (<= ,level (min tramp-verbose 3))) 1629 (<= ,level (min tramp-verbose 3)))
1611 (ignore-errors 1630 (ignore-errors
@@ -1613,14 +1632,11 @@ progress reporter."
1613 tm (when pr 1632 tm (when pr
1614 (run-at-time 3 0.1 'tramp-progress-reporter-update pr))))) 1633 (run-at-time 3 0.1 'tramp-progress-reporter-update pr)))))
1615 (unwind-protect 1634 (unwind-protect
1616 ;; Execute the body. Suppress concurrent progress reporter 1635 ;; Execute the body.
1617 ;; messages. 1636 (prog1 (progn ,@body) (setq result "done"))
1618 (let ((tramp-message-show-progress-reporter-message
1619 (and tramp-message-show-progress-reporter-message (not tm))))
1620 ,@body)
1621 ;; Stop progress reporter. 1637 ;; Stop progress reporter.
1622 (if tm (tramp-compat-funcall 'cancel-timer tm)) 1638 (if tm (tramp-compat-funcall 'cancel-timer tm))
1623 (tramp-message ,vec ,level "%s...done" ,message)))) 1639 (tramp-message ,vec ,level "%s...%s" ,message result))))
1624 1640
1625(tramp-compat-font-lock-add-keywords 1641(tramp-compat-font-lock-add-keywords
1626 'emacs-lisp-mode '("\\<with-tramp-progress-reporter\\>")) 1642 'emacs-lisp-mode '("\\<with-tramp-progress-reporter\\>"))
@@ -3393,39 +3409,49 @@ The terminal type can be configured with `tramp-terminal-type'."
3393PROC and VEC indicate the remote connection to be used. POS, if 3409PROC and VEC indicate the remote connection to be used. POS, if
3394set, is the starting point of the region to be deleted in the 3410set, is the starting point of the region to be deleted in the
3395connection buffer." 3411connection buffer."
3396 ;; Preserve message for `progress-reporter'. 3412 ;; Enable `auth-source' and `password-cache'. We must use
3397 (tramp-compat-with-temp-message "" 3413 ;; tramp-current-* variables in case we have several hops.
3398 ;; Enable `auth-source' and `password-cache'. We must use 3414 (tramp-set-connection-property
3399 ;; tramp-current-* variables in case we have several hops. 3415 (tramp-dissect-file-name
3400 (tramp-set-connection-property 3416 (tramp-make-tramp-file-name
3401 (tramp-dissect-file-name 3417 tramp-current-method tramp-current-user tramp-current-host ""))
3402 (tramp-make-tramp-file-name 3418 "first-password-request" t)
3403 tramp-current-method tramp-current-user tramp-current-host "")) 3419 (save-restriction
3404 "first-password-request" t) 3420 (with-tramp-progress-reporter
3405 (save-restriction 3421 proc 3 "Waiting for prompts from remote shell"
3406 (let (exit) 3422 (let (exit)
3407 (while (not exit) 3423 (if timeout
3408 (tramp-message proc 3 "Waiting for prompts from remote shell") 3424 (with-timeout (timeout (setq exit 'timeout))
3409 (setq exit 3425 (while (not exit)
3410 (catch 'tramp-action 3426 (setq exit
3411 (if timeout 3427 (catch 'tramp-action
3412 (with-timeout (timeout) 3428 (tramp-process-one-action proc vec actions)))))
3413 (tramp-process-one-action proc vec actions)) 3429 (while (not exit)
3430 (setq exit
3431 (catch 'tramp-action
3414 (tramp-process-one-action proc vec actions))))) 3432 (tramp-process-one-action proc vec actions)))))
3415 (with-current-buffer (tramp-get-connection-buffer vec) 3433 (with-current-buffer (tramp-get-connection-buffer vec)
3416 (widen) 3434 (widen)
3417 (tramp-message vec 6 "\n%s" (buffer-string))) 3435 (tramp-message vec 6 "\n%s" (buffer-string)))
3418 (unless (eq exit 'ok) 3436 (unless (eq exit 'ok)
3419 (tramp-clear-passwd vec) 3437 (tramp-clear-passwd vec)
3438 (delete-process proc)
3420 (tramp-error-with-buffer 3439 (tramp-error-with-buffer
3421 nil vec 'file-error 3440 (tramp-get-connection-buffer vec) vec 'file-error
3422 (cond 3441 (cond
3423 ((eq exit 'permission-denied) "Permission denied") 3442 ((eq exit 'permission-denied) "Permission denied")
3424 ((eq exit 'process-died) "Process died") 3443 ((eq exit 'process-died)
3425 (t "Login failed")))) 3444 (concat
3426 (when (numberp pos) 3445 "Tramp failed to connect. If this happens repeatedly, try\n"
3427 (with-current-buffer (tramp-get-connection-buffer vec) 3446 " `M-x tramp-cleanup-this-connection'"))
3428 (let (buffer-read-only) (delete-region pos (point))))))))) 3447 ((eq exit 'timeout)
3448 (format
3449 "Timeout reached, see buffer `%s' for details"
3450 (tramp-get-connection-buffer vec)))
3451 (t "Login failed")))))
3452 (when (numberp pos)
3453 (with-current-buffer (tramp-get-connection-buffer vec)
3454 (let (buffer-read-only) (delete-region pos (point))))))))
3429 3455
3430:;; Utility functions: 3456:;; Utility functions:
3431 3457
diff --git a/lisp/progmodes/cfengine.el b/lisp/progmodes/cfengine.el
index 55d5b8b0be7..85a9074760d 100644
--- a/lisp/progmodes/cfengine.el
+++ b/lisp/progmodes/cfengine.el
@@ -387,10 +387,10 @@ Intended as the value of `indent-line-function'."
387 (skip-chars-forward " \t") 387 (skip-chars-forward " \t")
388 (current-column))) 388 (current-column)))
389 (error nil))) 389 (error nil)))
390 ;; Inside a string and it starts before this line. 390 ;; Inside a string and it starts before this line: do nothing.
391 ((and (nth 3 parse) 391 ((and (nth 3 parse)
392 (< (nth 8 parse) (save-excursion (beginning-of-line) (point)))) 392 (< (nth 8 parse) (save-excursion (beginning-of-line) (point))))
393 (indent-line-to 0)) 393 )
394 394
395 ;; Inside a defun, but not a nested list (depth is 1). This is 395 ;; Inside a defun, but not a nested list (depth is 1). This is
396 ;; a promise, usually. 396 ;; a promise, usually.
diff --git a/lisp/progmodes/ebrowse.el b/lisp/progmodes/ebrowse.el
index 4957b58d469..6a71ab330a8 100644
--- a/lisp/progmodes/ebrowse.el
+++ b/lisp/progmodes/ebrowse.el
@@ -33,12 +33,12 @@
33 33
34;;; Code: 34;;; Code:
35 35
36(require 'cl-lib)
36(require 'easymenu) 37(require 'easymenu)
37(require 'view) 38(require 'view)
38(require 'ebuff-menu) 39(require 'ebuff-menu)
39 40
40(eval-when-compile 41(eval-when-compile
41 (require 'cl-lib)
42 (require 'helper)) 42 (require 'helper))
43 43
44 44
@@ -233,19 +233,6 @@ Compare items with `eq' or TEST if specified."
233 found)) 233 found))
234 234
235 235
236(defun ebrowse-delete-if-not (predicate list)
237 "Remove elements not satisfying PREDICATE from LIST and return the result.
238This is a destructive operation."
239 (let (result)
240 (while list
241 (let ((next (cdr list)))
242 (when (funcall predicate (car list))
243 (setq result (nconc result list))
244 (setf (cdr list) nil))
245 (setq list next)))
246 result))
247
248
249(defmacro ebrowse-output (&rest body) 236(defmacro ebrowse-output (&rest body)
250 "Eval BODY with a writable current buffer. 237 "Eval BODY with a writable current buffer.
251Preserve buffer's modified state." 238Preserve buffer's modified state."
@@ -1310,17 +1297,17 @@ With PREFIX, insert that many filenames."
1310 1297
1311(defun ebrowse-browser-buffer-list () 1298(defun ebrowse-browser-buffer-list ()
1312 "Return a list of all tree or member buffers." 1299 "Return a list of all tree or member buffers."
1313 (ebrowse-delete-if-not 'ebrowse-buffer-p (buffer-list))) 1300 (cl-delete-if-not 'ebrowse-buffer-p (buffer-list)))
1314 1301
1315 1302
1316(defun ebrowse-member-buffer-list () 1303(defun ebrowse-member-buffer-list ()
1317 "Return a list of all member buffers." 1304 "Return a list of all member buffers."
1318 (ebrowse-delete-if-not 'ebrowse-member-buffer-p (buffer-list))) 1305 (cl-delete-if-not 'ebrowse-member-buffer-p (buffer-list)))
1319 1306
1320 1307
1321(defun ebrowse-tree-buffer-list () 1308(defun ebrowse-tree-buffer-list ()
1322 "Return a list of all tree buffers." 1309 "Return a list of all tree buffers."
1323 (ebrowse-delete-if-not 'ebrowse-tree-buffer-p (buffer-list))) 1310 (cl-delete-if-not 'ebrowse-tree-buffer-p (buffer-list)))
1324 1311
1325 1312
1326(defun ebrowse-known-class-trees-buffer-list () 1313(defun ebrowse-known-class-trees-buffer-list ()
@@ -1341,7 +1328,7 @@ one buffer. Prefer tree buffers over member buffers."
1341 1328
1342(defun ebrowse-same-tree-member-buffer-list () 1329(defun ebrowse-same-tree-member-buffer-list ()
1343 "Return a list of members buffers with same tree as current buffer." 1330 "Return a list of members buffers with same tree as current buffer."
1344 (ebrowse-delete-if-not 1331 (cl-delete-if-not
1345 (lambda (buffer) 1332 (lambda (buffer)
1346 (eq (buffer-local-value 'ebrowse--tree buffer) 1333 (eq (buffer-local-value 'ebrowse--tree buffer)
1347 ebrowse--tree)) 1334 ebrowse--tree))
diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index 2c4d6a0e3d7..10472ec5815 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -1759,6 +1759,9 @@ static char *magick[] = {
1759As long as GDB is in the recursive reading loop, it does not expect 1759As long as GDB is in the recursive reading loop, it does not expect
1760commands to be prefixed by \"-interpreter-exec console\".") 1760commands to be prefixed by \"-interpreter-exec console\".")
1761 1761
1762(defun gdb-strip-string-backslash (string)
1763 (replace-regexp-in-string "\\\\$" "" string))
1764
1762(defun gdb-send (proc string) 1765(defun gdb-send (proc string)
1763 "A comint send filter for gdb." 1766 "A comint send filter for gdb."
1764 (with-current-buffer gud-comint-buffer 1767 (with-current-buffer gud-comint-buffer
@@ -1766,10 +1769,15 @@ commands to be prefixed by \"-interpreter-exec console\".")
1766 (remove-text-properties (point-min) (point-max) '(face)))) 1769 (remove-text-properties (point-min) (point-max) '(face))))
1767 ;; mimic <RET> key to repeat previous command in GDB 1770 ;; mimic <RET> key to repeat previous command in GDB
1768 (if (not (string= "" string)) 1771 (if (not (string= "" string))
1769 (setq gdb-last-command string) 1772 (if gdb-continuation
1770 (if gdb-last-command (setq string gdb-last-command))) 1773 (setq gdb-last-command (concat gdb-continuation
1771 (if (or (string-match "^-" string) 1774 (gdb-strip-string-backslash string)
1772 (> gdb-control-level 0)) 1775 " "))
1776 (setq gdb-last-command (gdb-strip-string-backslash string)))
1777 (if gdb-last-command (setq string gdb-last-command))
1778 (setq gdb-continuation nil))
1779 (if (and (not gdb-continuation) (or (string-match "^-" string)
1780 (> gdb-control-level 0)))
1773 ;; Either MI command or we are feeding GDB's recursive reading loop. 1781 ;; Either MI command or we are feeding GDB's recursive reading loop.
1774 (progn 1782 (progn
1775 (setq gdb-first-done-or-error t) 1783 (setq gdb-first-done-or-error t)
@@ -1779,10 +1787,13 @@ commands to be prefixed by \"-interpreter-exec console\".")
1779 (setq gdb-control-level (1- gdb-control-level)))) 1787 (setq gdb-control-level (1- gdb-control-level))))
1780 ;; CLI command 1788 ;; CLI command
1781 (if (string-match "\\\\$" string) 1789 (if (string-match "\\\\$" string)
1782 (setq gdb-continuation (concat gdb-continuation string "\n")) 1790 (setq gdb-continuation
1791 (concat gdb-continuation (gdb-strip-string-backslash
1792 string)
1793 " "))
1783 (setq gdb-first-done-or-error t) 1794 (setq gdb-first-done-or-error t)
1784 (let ((to-send (concat "-interpreter-exec console " 1795 (let ((to-send (concat "-interpreter-exec console "
1785 (gdb-mi-quote string) 1796 (gdb-mi-quote (concat gdb-continuation string " "))
1786 "\n"))) 1797 "\n")))
1787 (if gdb-enable-debug 1798 (if gdb-enable-debug
1788 (push (cons 'mi-send to-send) gdb-debug-log)) 1799 (push (cons 'mi-send to-send) gdb-debug-log))
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 5f92d197a66..06dffd80d88 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -1351,7 +1351,7 @@ If the result is do-end block, it will always be multiline."
1351 (progn 1351 (progn
1352 (eval-and-compile 1352 (eval-and-compile
1353 (defconst ruby-percent-literal-beg-re 1353 (defconst ruby-percent-literal-beg-re
1354 "\\(%\\)[qQrswWx]?\\([[:punct:]]\\)" 1354 "\\(%\\)[qQrswWxIi]?\\([[:punct:]]\\)"
1355 "Regexp to match the beginning of percent literal.") 1355 "Regexp to match the beginning of percent literal.")
1356 1356
1357 (defconst ruby-syntax-methods-before-regexp 1357 (defconst ruby-syntax-methods-before-regexp
@@ -1387,7 +1387,7 @@ It will be properly highlighted even when the call omits parens.")
1387 (funcall 1387 (funcall
1388 (syntax-propertize-rules 1388 (syntax-propertize-rules
1389 ;; $' $" $` .... are variables. 1389 ;; $' $" $` .... are variables.
1390 ;; ?' ?" ?` are ascii codes. 1390 ;; ?' ?" ?` are character literals (one-char strings in 1.9+).
1391 ("\\([?$]\\)[#\"'`]" 1391 ("\\([?$]\\)[#\"'`]"
1392 (1 (unless (save-excursion 1392 (1 (unless (save-excursion
1393 ;; Not within a string. 1393 ;; Not within a string.
@@ -1518,7 +1518,7 @@ It will be properly highlighted even when the call omits parens.")
1518 (save-match-data 1518 (save-match-data
1519 (save-excursion 1519 (save-excursion
1520 (goto-char (nth 8 parse-state)) 1520 (goto-char (nth 8 parse-state))
1521 (looking-at "%\\(?:[QWrx]\\|\\W\\)"))))))) 1521 (looking-at "%\\(?:[QWrxI]\\|\\W\\)")))))))
1522 1522
1523 (defun ruby-syntax-propertize-expansions (start end) 1523 (defun ruby-syntax-propertize-expansions (start end)
1524 (save-excursion 1524 (save-excursion
@@ -1721,7 +1721,7 @@ See `font-lock-syntax-table'.")
1721(defconst ruby-font-lock-keywords 1721(defconst ruby-font-lock-keywords
1722 (list 1722 (list
1723 ;; functions 1723 ;; functions
1724 '("^\\s *def\\s +\\([^( \t\n]+\\)" 1724 '("^\\s *def\\s +\\(?:[^( \t\n.]*\\.\\)?\\([^( \t\n]+\\)"
1725 1 font-lock-function-name-face) 1725 1 font-lock-function-name-face)
1726 (list (concat 1726 (list (concat
1727 "\\(^\\|[^.@$]\\|\\.\\.\\)\\(" 1727 "\\(^\\|[^.@$]\\|\\.\\.\\)\\("
@@ -1809,7 +1809,6 @@ See `font-lock-syntax-table'.")
1809 "warn" 1809 "warn"
1810 ;; keyword-like private methods on Module 1810 ;; keyword-like private methods on Module
1811 "alias_method" 1811 "alias_method"
1812 "autoload"
1813 "attr" 1812 "attr"
1814 "attr_accessor" 1813 "attr_accessor"
1815 "attr_reader" 1814 "attr_reader"
@@ -1850,14 +1849,17 @@ See `font-lock-syntax-table'.")
1850 0 font-lock-variable-name-face) 1849 0 font-lock-variable-name-face)
1851 ;; constants 1850 ;; constants
1852 '("\\(?:\\_<\\|::\\)\\([A-Z]+\\(\\w\\|_\\)*\\)" 1851 '("\\(?:\\_<\\|::\\)\\([A-Z]+\\(\\w\\|_\\)*\\)"
1853 1 font-lock-type-face) 1852 1 (unless (eq ?\( (char-after)) font-lock-type-face))
1854 '("\\(^\\s *\\|[\[\{\(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+\\):[^:]" 2 font-lock-constant-face) 1853 '("\\(^\\s *\\|[\[\{\(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+\\):[^:]" 2 font-lock-constant-face)
1855 ;; expression expansion 1854 ;; expression expansion
1856 '(ruby-match-expression-expansion 1855 '(ruby-match-expression-expansion
1857 2 font-lock-variable-name-face t) 1856 2 font-lock-variable-name-face t)
1858 ;; warn lower camel case 1857 ;; negation char
1859 ;'("\\<[a-z]+[a-z0-9]*[A-Z][A-Za-z0-9]*\\([!?]?\\|\\>\\)" 1858 '("[^[:alnum:]_]\\(!\\)[^=]"
1860 ; 0 font-lock-warning-face) 1859 1 font-lock-negation-char-face)
1860 ;; character literals
1861 ;; FIXME: Support longer escape sequences.
1862 '("\\?\\\\?\\S " 0 font-lock-string-face)
1861 ) 1863 )
1862 "Additional expressions to highlight in Ruby mode.") 1864 "Additional expressions to highlight in Ruby mode.")
1863 1865
diff --git a/lisp/shadowfile.el b/lisp/shadowfile.el
index ec6e6e7ff10..3e7789069f9 100644
--- a/lisp/shadowfile.el
+++ b/lisp/shadowfile.el
@@ -74,6 +74,7 @@
74 74
75;;; Code: 75;;; Code:
76 76
77(require 'cl-lib)
77(require 'ange-ftp) 78(require 'ange-ftp)
78 79
79;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 80;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -180,15 +181,6 @@ created by `shadow-define-regexp-group'.")
180 (setq list (cdr list))) 181 (setq list (cdr list)))
181 (car list)) 182 (car list))
182 183
183(defun shadow-remove-if (func list)
184 "Remove elements satisfying FUNC from LIST.
185Nondestructive; actually returns a copy of the list with the elements removed."
186 (if list
187 (if (funcall func (car list))
188 (shadow-remove-if func (cdr list))
189 (cons (car list) (shadow-remove-if func (cdr list))))
190 nil))
191
192(defun shadow-regexp-superquote (string) 184(defun shadow-regexp-superquote (string)
193 "Like `regexp-quote', but includes the ^ and $. 185 "Like `regexp-quote', but includes the ^ and $.
194This makes sure regexp matches nothing but STRING." 186This makes sure regexp matches nothing but STRING."
@@ -238,9 +230,8 @@ instead."
238Replace old definition, if any. PRIMARY and REGEXP are the 230Replace old definition, if any. PRIMARY and REGEXP are the
239information defining the cluster. For interactive use, call 231information defining the cluster. For interactive use, call
240`shadow-define-cluster' instead." 232`shadow-define-cluster' instead."
241 (let ((rest (shadow-remove-if 233 (let ((rest (cl-remove-if (lambda (x) (equal name (car x)))
242 (function (lambda (x) (equal name (car x)))) 234 shadow-clusters)))
243 shadow-clusters)))
244 (setq shadow-clusters 235 (setq shadow-clusters
245 (cons (shadow-make-cluster name primary regexp) 236 (cons (shadow-make-cluster name primary regexp)
246 rest)))) 237 rest))))
@@ -602,9 +593,8 @@ and to are absolute file names."
602Consider them as regular expressions if third arg REGEXP is true." 593Consider them as regular expressions if third arg REGEXP is true."
603 (if groups 594 (if groups
604 (let ((nonmatching 595 (let ((nonmatching
605 (shadow-remove-if 596 (cl-remove-if (lambda (x) (shadow-file-match x file regexp))
606 (function (lambda (x) (shadow-file-match x file regexp))) 597 (car groups))))
607 (car groups))))
608 (append (cond ((equal nonmatching (car groups)) nil) 598 (append (cond ((equal nonmatching (car groups)) nil)
609 (regexp 599 (regexp
610 (let ((realname (nth 2 (shadow-parse-fullname file)))) 600 (let ((realname (nth 2 (shadow-parse-fullname file))))
@@ -635,8 +625,7 @@ Consider them as regular expressions if third arg REGEXP is true."
635 "Remove PAIR from `shadow-files-to-copy'. 625 "Remove PAIR from `shadow-files-to-copy'.
636PAIR must be `eq' to one of the elements of that list." 626PAIR must be `eq' to one of the elements of that list."
637 (setq shadow-files-to-copy 627 (setq shadow-files-to-copy
638 (shadow-remove-if (function (lambda (s) (eq s pair))) 628 (cl-remove-if (lambda (s) (eq s pair)) shadow-files-to-copy)))
639 shadow-files-to-copy)))
640 629
641(defun shadow-read-files () 630(defun shadow-read-files ()
642 "Visit and load `shadow-info-file' and `shadow-todo-file'. 631 "Visit and load `shadow-info-file' and `shadow-todo-file'.
diff --git a/lisp/simple.el b/lisp/simple.el
index b4b8ddfabed..9158452fd64 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -4602,6 +4602,12 @@ for it.")
4602(defun next-line (&optional arg try-vscroll) 4602(defun next-line (&optional arg try-vscroll)
4603 "Move cursor vertically down ARG lines. 4603 "Move cursor vertically down ARG lines.
4604Interactively, vscroll tall lines if `auto-window-vscroll' is enabled. 4604Interactively, vscroll tall lines if `auto-window-vscroll' is enabled.
4605Non-interactively, use TRY-VSCROLL to control whether to vscroll tall
4606lines: if either `auto-window-vscroll' or TRY-VSCROLL is nil, this
4607function will not vscroll.
4608
4609ARG defaults to 1.
4610
4605If there is no character in the target line exactly under the current column, 4611If there is no character in the target line exactly under the current column,
4606the cursor is positioned after the character in that line which spans this 4612the cursor is positioned after the character in that line which spans this
4607column, or at the end of the line if it is not long enough. 4613column, or at the end of the line if it is not long enough.
@@ -4646,6 +4652,12 @@ and more reliable (no dependence on goal column, etc.)."
4646(defun previous-line (&optional arg try-vscroll) 4652(defun previous-line (&optional arg try-vscroll)
4647 "Move cursor vertically up ARG lines. 4653 "Move cursor vertically up ARG lines.
4648Interactively, vscroll tall lines if `auto-window-vscroll' is enabled. 4654Interactively, vscroll tall lines if `auto-window-vscroll' is enabled.
4655Non-interactively, use TRY-VSCROLL to control whether to vscroll tall
4656lines: if either `auto-window-vscroll' or TRY-VSCROLL is nil, this
4657function will not vscroll.
4658
4659ARG defaults to 1.
4660
4649If there is no character in the target line exactly over the current column, 4661If there is no character in the target line exactly over the current column,
4650the cursor is positioned after the character in that line which spans this 4662the cursor is positioned after the character in that line which spans this
4651column, or at the end of the line if it is not long enough. 4663column, or at the end of the line if it is not long enough.
@@ -4725,33 +4737,76 @@ lines."
4725 :group 'editing-basics 4737 :group 'editing-basics
4726 :version "23.1") 4738 :version "23.1")
4727 4739
4740(defun default-font-height ()
4741 "Return the height in pixels of the current buffer's default face font."
4742 (cond
4743 ((display-multi-font-p)
4744 (aref (font-info (face-font 'default)) 3))
4745 (t (frame-char-height))))
4746
4747(defun default-line-height ()
4748 "Return the pixel height of current buffer's default-face text line.
4749
4750The value includes `line-spacing', if any, defined for the buffer
4751or the frame."
4752 (let ((dfh (default-font-height))
4753 (lsp (if (display-graphic-p)
4754 (or line-spacing
4755 (default-value 'line-spacing)
4756 (frame-parameter nil 'line-spacing)
4757 0)
4758 0)))
4759 (if (floatp lsp)
4760 (setq lsp (* dfh lsp)))
4761 (+ dfh lsp)))
4762
4763(defun window-screen-lines ()
4764 "Return the number of screen lines in the text area of the selected window.
4765
4766This is different from `window-text-height' in that this function counts
4767lines in units of the height of the font used by the default face displayed
4768in the window, not in units of the frame's default font, and also accounts
4769for `line-spacing', if any, defined for the window's buffer or frame.
4770
4771The value is a floating-point number."
4772 (let ((canonical (window-text-height))
4773 (fch (frame-char-height))
4774 (dlh (default-line-height)))
4775 (/ (* (float canonical) fch) dlh)))
4776
4728;; Returns non-nil if partial move was done. 4777;; Returns non-nil if partial move was done.
4729(defun line-move-partial (arg noerror to-end) 4778(defun line-move-partial (arg noerror to-end)
4730 (if (< arg 0) 4779 (if (< arg 0)
4731 ;; Move backward (up). 4780 ;; Move backward (up).
4732 ;; If already vscrolled, reduce vscroll 4781 ;; If already vscrolled, reduce vscroll
4733 (let ((vs (window-vscroll nil t))) 4782 (let ((vs (window-vscroll nil t))
4734 (when (> vs (frame-char-height)) 4783 (dlh (default-line-height)))
4735 (set-window-vscroll nil (- vs (frame-char-height)) t))) 4784 (when (> vs dlh)
4785 (set-window-vscroll nil (- vs dlh) t)))
4736 4786
4737 ;; Move forward (down). 4787 ;; Move forward (down).
4738 (let* ((lh (window-line-height -1)) 4788 (let* ((lh (window-line-height -1))
4789 (rowh (car lh))
4739 (vpos (nth 1 lh)) 4790 (vpos (nth 1 lh))
4740 (ypos (nth 2 lh)) 4791 (ypos (nth 2 lh))
4741 (rbot (nth 3 lh)) 4792 (rbot (nth 3 lh))
4742 (this-lh (window-line-height)) 4793 (this-lh (window-line-height))
4743 (this-height (nth 0 this-lh)) 4794 (this-height (car this-lh))
4744 (this-ypos (nth 2 this-lh)) 4795 (this-ypos (nth 2 this-lh))
4745 (fch (frame-char-height)) 4796 (dlh (default-line-height))
4746 py vs) 4797 (wslines (window-screen-lines))
4798 py vs last-line)
4799 (if (> (mod wslines 1.0) 0.0)
4800 (setq wslines (round (+ wslines 0.5))))
4747 (when (or (null lh) 4801 (when (or (null lh)
4748 (>= rbot fch) 4802 (>= rbot dlh)
4749 (<= ypos (- fch)) 4803 (<= ypos (- dlh))
4750 (null this-lh) 4804 (null this-lh)
4751 (<= this-ypos (- fch))) 4805 (<= this-ypos (- dlh)))
4752 (unless lh 4806 (unless lh
4753 (let ((wend (pos-visible-in-window-p t nil t))) 4807 (let ((wend (pos-visible-in-window-p t nil t)))
4754 (setq rbot (nth 3 wend) 4808 (setq rbot (nth 3 wend)
4809 rowh (nth 4 wend)
4755 vpos (nth 5 wend)))) 4810 vpos (nth 5 wend))))
4756 (unless this-lh 4811 (unless this-lh
4757 (let ((wstart (pos-visible-in-window-p nil nil t))) 4812 (let ((wstart (pos-visible-in-window-p nil nil t)))
@@ -4765,35 +4820,57 @@ lines."
4765 (if col-row 4820 (if col-row
4766 (- (cdr col-row) (window-vscroll)) 4821 (- (cdr col-row) (window-vscroll))
4767 (cdr (posn-col-row ppos)))))) 4822 (cdr (posn-col-row ppos))))))
4823 ;; VPOS > 0 means the last line is only partially visible.
4824 ;; But if the part that is visible is at least as tall as the
4825 ;; default font, that means the line is actually fully
4826 ;; readable, and something like line-spacing is hidden. So in
4827 ;; that case we accept the last line in the window as still
4828 ;; visible, and consider the margin as starting one line
4829 ;; later.
4830 (if (and vpos (> vpos 0))
4831 (if (and rowh
4832 (>= rowh (default-font-height))
4833 (< rowh dlh))
4834 (setq last-line (min (- wslines scroll-margin) vpos))
4835 (setq last-line (min (- wslines scroll-margin 1) (1- vpos)))))
4768 (cond 4836 (cond
4769 ;; If last line of window is fully visible, and vscrolling 4837 ;; If last line of window is fully visible, and vscrolling
4770 ;; more would make this line invisible, move forward. 4838 ;; more would make this line invisible, move forward.
4771 ((and (or (< (setq vs (window-vscroll nil t)) fch) 4839 ((and (or (< (setq vs (window-vscroll nil t)) dlh)
4772 (null this-height) 4840 (null this-height)
4773 (<= this-height fch)) 4841 (<= this-height dlh))
4774 (or (null rbot) (= rbot 0))) 4842 (or (null rbot) (= rbot 0)))
4775 nil) 4843 nil)
4776 ;; If cursor is not in the bottom scroll margin, and the 4844 ;; If cursor is not in the bottom scroll margin, and the
4777 ;; current line is is not too tall, move forward. 4845 ;; current line is is not too tall, move forward.
4778 ((and (or (null this-height) (<= this-height fch)) 4846 ((and (or (null this-height) (<= this-height dlh))
4779 vpos 4847 vpos
4780 (> vpos 0) 4848 (> vpos 0)
4781 (< py 4849 (< py last-line))
4782 (min (- (window-text-height) scroll-margin 1) (1- vpos))))
4783 nil) 4850 nil)
4784 ;; When already vscrolled, we vscroll some more if we can, 4851 ;; When already vscrolled, we vscroll some more if we can,
4785 ;; or clear vscroll and move forward at end of tall image. 4852 ;; or clear vscroll and move forward at end of tall image.
4786 ((> vs 0) 4853 ((> vs 0)
4787 (when (or (and rbot (> rbot 0)) 4854 (when (or (and rbot (> rbot 0))
4788 (and this-height (> this-height fch))) 4855 (and this-height (> this-height dlh)))
4789 (set-window-vscroll nil (+ vs fch) t))) 4856 (set-window-vscroll nil (+ vs dlh) t)))
4790 ;; If cursor just entered the bottom scroll margin, move forward, 4857 ;; If cursor just entered the bottom scroll margin, move forward,
4791 ;; but also vscroll one line so redisplay won't recenter. 4858 ;; but also optionally vscroll one line so redisplay won't recenter.
4792 ((and vpos 4859 ((and vpos
4793 (> vpos 0) 4860 (> vpos 0)
4794 (= py (min (- (window-text-height) scroll-margin 1) 4861 (= py last-line))
4795 (1- vpos)))) 4862 ;; Don't vscroll if the partially-visible line at window
4796 (set-window-vscroll nil (frame-char-height) t) 4863 ;; bottom has the default height (a.k.a. "just one more text
4864 ;; line"): in that case, we do want redisplay to behave
4865 ;; normally, i.e. recenter or whatever.
4866 ;;
4867 ;; Note: ROWH + RBOT from the value returned by
4868 ;; pos-visible-in-window-p give the total height of the
4869 ;; partially-visible glyph row at the end of the window. As
4870 ;; we are dealing with floats, we disregard sub-pixel
4871 ;; discrepancies between that and DLH.
4872 (if (and rowh rbot (>= (- (+ rowh rbot) dlh) 1))
4873 (set-window-vscroll nil dlh t))
4797 (line-move-1 arg noerror to-end) 4874 (line-move-1 arg noerror to-end)
4798 t) 4875 t)
4799 ;; If there are lines above the last line, scroll-up one line. 4876 ;; If there are lines above the last line, scroll-up one line.
@@ -4802,7 +4879,7 @@ lines."
4802 t) 4879 t)
4803 ;; Finally, start vscroll. 4880 ;; Finally, start vscroll.
4804 (t 4881 (t
4805 (set-window-vscroll nil (frame-char-height) t))))))) 4882 (set-window-vscroll nil dlh t)))))))
4806 4883
4807 4884
4808;; This is like line-move-1 except that it also performs 4885;; This is like line-move-1 except that it also performs
@@ -4835,11 +4912,14 @@ lines."
4835 (prog1 (line-move-visual arg noerror) 4912 (prog1 (line-move-visual arg noerror)
4836 ;; If we moved into a tall line, set vscroll to make 4913 ;; If we moved into a tall line, set vscroll to make
4837 ;; scrolling through tall images more smooth. 4914 ;; scrolling through tall images more smooth.
4838 (let ((lh (line-pixel-height))) 4915 (let ((lh (line-pixel-height))
4916 (dlh (default-line-height)))
4839 (if (and (< arg 0) 4917 (if (and (< arg 0)
4840 (< (point) (window-start)) 4918 (< (point) (window-start))
4841 (> lh (frame-char-height))) 4919 (> lh dlh))
4842 (set-window-vscroll nil (- lh (frame-char-height)) t)))) 4920 (set-window-vscroll
4921 nil
4922 (- lh dlh) t))))
4843 (line-move-1 arg noerror to-end))))) 4923 (line-move-1 arg noerror to-end)))))
4844 4924
4845;; Display-based alternative to line-move-1. 4925;; Display-based alternative to line-move-1.
diff --git a/lisp/subr.el b/lisp/subr.el
index b2918baf247..a2afe0768c4 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1980,7 +1980,7 @@ any other terminator is used itself as input.
1980The optional argument PROMPT specifies a string to use to prompt the user. 1980The optional argument PROMPT specifies a string to use to prompt the user.
1981The variable `read-quoted-char-radix' controls which radix to use 1981The variable `read-quoted-char-radix' controls which radix to use
1982for numeric input." 1982for numeric input."
1983 (let ((message-log-max nil) done (first t) (code 0) char translated) 1983 (let ((message-log-max nil) done (first t) (code 0) translated)
1984 (while (not done) 1984 (while (not done)
1985 (let ((inhibit-quit first) 1985 (let ((inhibit-quit first)
1986 ;; Don't let C-h get the help message--only help function keys. 1986 ;; Don't let C-h get the help message--only help function keys.
@@ -3853,6 +3853,7 @@ FILE should be the name of a library, with no directory name."
3853 (declare (obsolete eval-after-load "23.2")) 3853 (declare (obsolete eval-after-load "23.2"))
3854 (eval-after-load file (read))) 3854 (eval-after-load file (read)))
3855 3855
3856
3856(defun display-delayed-warnings () 3857(defun display-delayed-warnings ()
3857 "Display delayed warnings from `delayed-warnings-list'. 3858 "Display delayed warnings from `delayed-warnings-list'.
3858Used from `delayed-warnings-hook' (which see)." 3859Used from `delayed-warnings-hook' (which see)."
@@ -3886,6 +3887,12 @@ By default, this hook contains functions to consolidate the
3886warnings listed in `delayed-warnings-list', display them, and set 3887warnings listed in `delayed-warnings-list', display them, and set
3887`delayed-warnings-list' back to nil.") 3888`delayed-warnings-list' back to nil.")
3888 3889
3890(defun delay-warning (type message &optional level buffer-name)
3891 "Display a delayed warning.
3892Aside from going through `delayed-warnings-list', this is equivalent
3893to `display-warning'."
3894 (push (list type message level buffer-name) delayed-warnings-list))
3895
3889 3896
3890;;;; invisibility specs 3897;;;; invisibility specs
3891 3898
diff --git a/lisp/thumbs.el b/lisp/thumbs.el
index 3d591303414..8032de85b01 100644
--- a/lisp/thumbs.el
+++ b/lisp/thumbs.el
@@ -57,6 +57,7 @@
57;;; Code: 57;;; Code:
58 58
59(require 'dired) 59(require 'dired)
60(require 'cl-lib) ; for cl-gensym
60 61
61;; CUSTOMIZATIONS 62;; CUSTOMIZATIONS
62 63
@@ -179,21 +180,6 @@ this value can let another user see some of your images."
179(make-variable-buffer-local 'thumbs-marked-list) 180(make-variable-buffer-local 'thumbs-marked-list)
180(put 'thumbs-marked-list 'permanent-local t) 181(put 'thumbs-marked-list 'permanent-local t)
181 182
182(defalias 'thumbs-gensym
183 (if (fboundp 'gensym)
184 'gensym
185 ;; Copied from cl-macs.el
186 (defvar thumbs-gensym-counter 0)
187 (lambda (&optional prefix)
188 "Generate a new uninterned symbol.
189The name is made by appending a number to PREFIX, default \"G\"."
190 (let ((pfix (if (stringp prefix) prefix "G"))
191 (num (if (integerp prefix) prefix
192 (prog1 thumbs-gensym-counter
193 (setq thumbs-gensym-counter
194 (1+ thumbs-gensym-counter))))))
195 (make-symbol (format "%s%d" pfix num))))))
196
197(defsubst thumbs-temp-dir () 183(defsubst thumbs-temp-dir ()
198 (file-name-as-directory (expand-file-name thumbs-temp-dir))) 184 (file-name-as-directory (expand-file-name thumbs-temp-dir)))
199 185
@@ -202,7 +188,7 @@ The name is made by appending a number to PREFIX, default \"G\"."
202 (format "%s%s-%s.jpg" 188 (format "%s%s-%s.jpg"
203 (thumbs-temp-dir) 189 (thumbs-temp-dir)
204 thumbs-temp-prefix 190 thumbs-temp-prefix
205 (thumbs-gensym "T"))) 191 (cl-gensym "T")))
206 192
207(defun thumbs-thumbsdir () 193(defun thumbs-thumbsdir ()
208 "Return the current thumbnails directory (from `thumbs-thumbsdir'). 194 "Return the current thumbnails directory (from `thumbs-thumbsdir').
diff --git a/lisp/vc/ediff.el b/lisp/vc/ediff.el
index 7a8f399a6ce..e9a6a97409c 100644
--- a/lisp/vc/ediff.el
+++ b/lisp/vc/ediff.el
@@ -12,8 +12,8 @@
12;; filed in the Emacs bug reporting system against this file, a copy 12;; filed in the Emacs bug reporting system against this file, a copy
13;; of the bug report be sent to the maintainer's email address. 13;; of the bug report be sent to the maintainer's email address.
14 14
15(defconst ediff-version "2.81.4" "The current version of Ediff") 15(defconst ediff-version "2.81.5" "The current version of Ediff")
16(defconst ediff-date "December 7, 2009" "Date of last update") 16(defconst ediff-date "July 4, 2013" "Date of last update")
17 17
18 18
19;; This file is part of GNU Emacs. 19;; This file is part of GNU Emacs.
@@ -1560,6 +1560,75 @@ With optional NODE, goes to that node."
1560 (add-to-list 'debug-ignored-errors mess)) 1560 (add-to-list 'debug-ignored-errors mess))
1561 1561
1562 1562
1563
1564;;; Command line interface
1565
1566;;;###autoload
1567(defun ediff-files-command ()
1568 (let ((file-a (nth 0 command-line-args-left))
1569 (file-b (nth 1 command-line-args-left)))
1570 (setq command-line-args-left (nthcdr 2 command-line-args-left))
1571 (ediff file-a file-b)))
1572
1573;;;###autoload
1574(defun ediff3-files-command ()
1575 (let ((file-a (nth 0 command-line-args-left))
1576 (file-b (nth 1 command-line-args-left))
1577 (file-c (nth 2 command-line-args-left)))
1578 (setq command-line-args-left (nthcdr 3 command-line-args-left))
1579 (ediff3 file-a file-b file-c)))
1580
1581;;;###autoload
1582(defun ediff-merge-command ()
1583 (let ((file-a (nth 0 command-line-args-left))
1584 (file-b (nth 1 command-line-args-left)))
1585 (setq command-line-args-left (nthcdr 2 command-line-args-left))
1586 (ediff-merge-files file-a file-b)))
1587
1588;;;###autoload
1589(defun ediff-merge-with-ancestor-command ()
1590 (let ((file-a (nth 0 command-line-args-left))
1591 (file-b (nth 1 command-line-args-left))
1592 (ancestor (nth 2 command-line-args-left)))
1593 (setq command-line-args-left (nthcdr 3 command-line-args-left))
1594 (ediff-merge-files-with-ancestor file-a file-b ancestor)))
1595
1596;;;###autoload
1597(defun ediff-directories-command ()
1598 (let ((file-a (nth 0 command-line-args-left))
1599 (file-b (nth 1 command-line-args-left))
1600 (regexp (nth 2 command-line-args-left)))
1601 (setq command-line-args-left (nthcdr 3 command-line-args-left))
1602 (ediff-directories file-a file-b regexp)))
1603
1604;;;###autoload
1605(defun ediff-directories3-command ()
1606 (let ((file-a (nth 0 command-line-args-left))
1607 (file-b (nth 1 command-line-args-left))
1608 (file-c (nth 2 command-line-args-left))
1609 (regexp (nth 3 command-line-args-left)))
1610 (setq command-line-args-left (nthcdr 4 command-line-args-left))
1611 (ediff-directories3 file-a file-b file-c regexp)))
1612
1613;;;###autoload
1614(defun ediff-merge-directories-command ()
1615 (let ((file-a (nth 0 command-line-args-left))
1616 (file-b (nth 1 command-line-args-left))
1617 (regexp (nth 2 command-line-args-left)))
1618 (setq command-line-args-left (nthcdr 3 command-line-args-left))
1619 (ediff-merge-directories file-a file-b regexp)))
1620
1621;;;###autoload
1622(defun ediff-merge-directories-with-ancestor-command ()
1623 (let ((file-a (nth 0 command-line-args-left))
1624 (file-b (nth 1 command-line-args-left))
1625 (ancestor (nth 2 command-line-args-left))
1626 (regexp (nth 3 command-line-args-left)))
1627 (setq command-line-args-left (nthcdr 4 command-line-args-left))
1628 (ediff-merge-directories-with-ancestor file-a file-b ancestor regexp)))
1629
1630
1631
1563(require 'ediff-util) 1632(require 'ediff-util)
1564 1633
1565(run-hooks 'ediff-load-hook) 1634(run-hooks 'ediff-load-hook)
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index 2dc1e502171..b351d896911 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -55,6 +55,7 @@
55;; See `widget.el'. 55;; See `widget.el'.
56 56
57;;; Code: 57;;; Code:
58(require 'cl-lib)
58 59
59;;; Compatibility. 60;;; Compatibility.
60 61
@@ -221,7 +222,7 @@ minibuffer."
221 ((or widget-menu-minibuffer-flag 222 ((or widget-menu-minibuffer-flag
222 (> (length items) widget-menu-max-shortcuts)) 223 (> (length items) widget-menu-max-shortcuts))
223 ;; Read the choice of name from the minibuffer. 224 ;; Read the choice of name from the minibuffer.
224 (setq items (widget-remove-if 'stringp items)) 225 (setq items (cl-remove-if 'stringp items))
225 (let ((val (completing-read (concat title ": ") items nil t))) 226 (let ((val (completing-read (concat title ": ") items nil t)))
226 (if (stringp val) 227 (if (stringp val)
227 (let ((try (try-completion val items))) 228 (let ((try (try-completion val items)))
@@ -295,14 +296,6 @@ minibuffer."
295 (error "Canceled")) 296 (error "Canceled"))
296 value)))) 297 value))))
297 298
298(defun widget-remove-if (predicate list)
299 (let (result (tail list))
300 (while tail
301 (or (funcall predicate (car tail))
302 (setq result (cons (car tail) result)))
303 (setq tail (cdr tail)))
304 (nreverse result)))
305
306;;; Widget text specifications. 299;;; Widget text specifications.
307;; 300;;
308;; These functions are for specifying text properties. 301;; These functions are for specifying text properties.
diff --git a/m4/fcntl.m4 b/m4/fcntl.m4
new file mode 100644
index 00000000000..5481cae4d80
--- /dev/null
+++ b/m4/fcntl.m4
@@ -0,0 +1,95 @@
1# fcntl.m4 serial 5
2dnl Copyright (C) 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# For now, this module ensures that fcntl()
8# - supports F_DUPFD correctly
9# - supports or emulates F_DUPFD_CLOEXEC
10# - supports F_GETFD
11# Still to be ported to mingw:
12# - F_SETFD
13# - F_GETFL, F_SETFL
14# - F_GETOWN, F_SETOWN
15# - F_GETLK, F_SETLK, F_SETLKW
16AC_DEFUN([gl_FUNC_FCNTL],
17[
18 dnl Persuade glibc to expose F_DUPFD_CLOEXEC.
19 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
20 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
21 AC_REQUIRE([AC_CANONICAL_HOST])
22 AC_CHECK_FUNCS_ONCE([fcntl])
23 if test $ac_cv_func_fcntl = no; then
24 gl_REPLACE_FCNTL
25 else
26 dnl cygwin 1.5.x F_DUPFD has wrong errno, and allows negative target
27 dnl haiku alpha 2 F_DUPFD has wrong errno
28 AC_CACHE_CHECK([whether fcntl handles F_DUPFD correctly],
29 [gl_cv_func_fcntl_f_dupfd_works],
30 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
31#include <fcntl.h>
32#include <errno.h>
33]], [[int result = 0;
34 if (fcntl (0, F_DUPFD, -1) != -1) result |= 1;
35 if (errno != EINVAL) result |= 2;
36 return result;
37 ]])],
38 [gl_cv_func_fcntl_f_dupfd_works=yes],
39 [gl_cv_func_fcntl_f_dupfd_works=no],
40 [# Guess that it works on glibc systems
41 case $host_os in #((
42 *-gnu*) gl_cv_func_fcntl_f_dupfd_works="guessing yes";;
43 *) gl_cv_func_fcntl_f_dupfd_works="guessing no";;
44 esac])])
45 case $gl_cv_func_fcntl_f_dupfd_works in
46 *yes) ;;
47 *) gl_REPLACE_FCNTL
48 AC_DEFINE([FCNTL_DUPFD_BUGGY], [1], [Define this to 1 if F_DUPFD
49 behavior does not match POSIX]) ;;
50 esac
51
52 dnl Many systems lack F_DUPFD_CLOEXEC
53 AC_CACHE_CHECK([whether fcntl understands F_DUPFD_CLOEXEC],
54 [gl_cv_func_fcntl_f_dupfd_cloexec],
55 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
56#include <fcntl.h>
57#ifndef F_DUPFD_CLOEXEC
58choke me
59#endif
60 ]])],
61 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
62#ifdef __linux__
63/* The Linux kernel only added F_DUPFD_CLOEXEC in 2.6.24, so we always replace
64 it to support the semantics on older kernels that failed with EINVAL. */
65choke me
66#endif
67 ]])],
68 [gl_cv_func_fcntl_f_dupfd_cloexec=yes],
69 [gl_cv_func_fcntl_f_dupfd_cloexec="needs runtime check"])],
70 [gl_cv_func_fcntl_f_dupfd_cloexec=no])])
71 if test "$gl_cv_func_fcntl_f_dupfd_cloexec" != yes; then
72 gl_REPLACE_FCNTL
73 dnl No witness macro needed for this bug.
74 fi
75 fi
76 dnl Replace fcntl() for supporting the gnulib-defined fchdir() function,
77 dnl to keep fchdir's bookkeeping up-to-date.
78 m4_ifdef([gl_FUNC_FCHDIR], [
79 gl_TEST_FCHDIR
80 if test $HAVE_FCHDIR = 0; then
81 gl_REPLACE_FCNTL
82 fi
83 ])
84])
85
86AC_DEFUN([gl_REPLACE_FCNTL],
87[
88 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
89 AC_CHECK_FUNCS_ONCE([fcntl])
90 if test $ac_cv_func_fcntl = no; then
91 HAVE_FCNTL=0
92 else
93 REPLACE_FCNTL=1
94 fi
95])
diff --git a/m4/getdtablesize.m4 b/m4/getdtablesize.m4
new file mode 100644
index 00000000000..8f04b3b8c2a
--- /dev/null
+++ b/m4/getdtablesize.m4
@@ -0,0 +1,17 @@
1# getdtablesize.m4 serial 4
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_GETDTABLESIZE],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 AC_CHECK_FUNCS_ONCE([getdtablesize])
11 if test $ac_cv_func_getdtablesize != yes; then
12 HAVE_GETDTABLESIZE=0
13 fi
14])
15
16# Prerequisites of lib/getdtablesize.c.
17AC_DEFUN([gl_PREREQ_GETDTABLESIZE], [:])
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index 344b77642b9..d7062e862de 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -41,6 +41,7 @@ AC_DEFUN([gl_EARLY],
41 # Code from module alloca-opt: 41 # Code from module alloca-opt:
42 # Code from module allocator: 42 # Code from module allocator:
43 # Code from module at-internal: 43 # Code from module at-internal:
44 # Code from module binary-io:
44 # Code from module c-ctype: 45 # Code from module c-ctype:
45 # Code from module c-strcase: 46 # Code from module c-strcase:
46 # Code from module careadlinkat: 47 # Code from module careadlinkat:
@@ -63,6 +64,7 @@ AC_DEFUN([gl_EARLY],
63 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 64 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
64 # Code from module extern-inline: 65 # Code from module extern-inline:
65 # Code from module faccessat: 66 # Code from module faccessat:
67 # Code from module fcntl:
66 # Code from module fcntl-h: 68 # Code from module fcntl-h:
67 # Code from module fdatasync: 69 # Code from module fdatasync:
68 # Code from module fdopendir: 70 # Code from module fdopendir:
@@ -70,6 +72,7 @@ AC_DEFUN([gl_EARLY],
70 # Code from module fpending: 72 # Code from module fpending:
71 # Code from module fstatat: 73 # Code from module fstatat:
72 # Code from module fsync: 74 # Code from module fsync:
75 # Code from module getdtablesize:
73 # Code from module getgroups: 76 # Code from module getgroups:
74 # Code from module getloadavg: 77 # Code from module getloadavg:
75 # Code from module getopt-gnu: 78 # Code from module getopt-gnu:
@@ -78,7 +81,6 @@ AC_DEFUN([gl_EARLY],
78 # Code from module gettime: 81 # Code from module gettime:
79 # Code from module gettimeofday: 82 # Code from module gettimeofday:
80 # Code from module group-member: 83 # Code from module group-member:
81 # Code from module ignore-value:
82 # Code from module include_next: 84 # Code from module include_next:
83 # Code from module intprops: 85 # Code from module intprops:
84 # Code from module inttypes-incomplete: 86 # Code from module inttypes-incomplete:
@@ -92,6 +94,7 @@ AC_DEFUN([gl_EARLY],
92 # Code from module nocrash: 94 # Code from module nocrash:
93 # Code from module openat-h: 95 # Code from module openat-h:
94 # Code from module pathmax: 96 # Code from module pathmax:
97 # Code from module pipe2:
95 # Code from module pselect: 98 # Code from module pselect:
96 # Code from module pthread_sigmask: 99 # Code from module pthread_sigmask:
97 # Code from module putenv: 100 # Code from module putenv:
@@ -191,6 +194,11 @@ AC_DEFUN([gl_INIT],
191 fi 194 fi
192 gl_MODULE_INDICATOR([faccessat]) 195 gl_MODULE_INDICATOR([faccessat])
193 gl_UNISTD_MODULE_INDICATOR([faccessat]) 196 gl_UNISTD_MODULE_INDICATOR([faccessat])
197 gl_FUNC_FCNTL
198 if test $HAVE_FCNTL = 0 || test $REPLACE_FCNTL = 1; then
199 AC_LIBOBJ([fcntl])
200 fi
201 gl_FCNTL_MODULE_INDICATOR([fcntl])
194 gl_FCNTL_H 202 gl_FCNTL_H
195 gl_FUNC_FDATASYNC 203 gl_FUNC_FDATASYNC
196 if test $HAVE_FDATASYNC = 0; then 204 if test $HAVE_FDATASYNC = 0; then
@@ -273,6 +281,8 @@ AC_DEFUN([gl_INIT],
273 fi 281 fi
274 gl_TIME_MODULE_INDICATOR([mktime]) 282 gl_TIME_MODULE_INDICATOR([mktime])
275 gl_MULTIARCH 283 gl_MULTIARCH
284 gl_FUNC_PIPE2
285 gl_UNISTD_MODULE_INDICATOR([pipe2])
276 gl_FUNC_PSELECT 286 gl_FUNC_PSELECT
277 if test $HAVE_PSELECT = 0 || test $REPLACE_PSELECT = 1; then 287 if test $HAVE_PSELECT = 0 || test $REPLACE_PSELECT = 1; then
278 AC_LIBOBJ([pselect]) 288 AC_LIBOBJ([pselect])
@@ -364,6 +374,7 @@ AC_DEFUN([gl_INIT],
364 gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b=false 374 gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b=false
365 gl_gnulib_enabled_dosname=false 375 gl_gnulib_enabled_dosname=false
366 gl_gnulib_enabled_euidaccess=false 376 gl_gnulib_enabled_euidaccess=false
377 gl_gnulib_enabled_getdtablesize=false
367 gl_gnulib_enabled_getgroups=false 378 gl_gnulib_enabled_getgroups=false
368 gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=false 379 gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=false
369 gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1=false 380 gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1=false
@@ -373,7 +384,6 @@ AC_DEFUN([gl_INIT],
373 gl_gnulib_enabled_stat=false 384 gl_gnulib_enabled_stat=false
374 gl_gnulib_enabled_strtoll=false 385 gl_gnulib_enabled_strtoll=false
375 gl_gnulib_enabled_strtoull=false 386 gl_gnulib_enabled_strtoull=false
376 gl_gnulib_enabled_verify=false
377 gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=false 387 gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=false
378 func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b () 388 func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b ()
379 { 389 {
@@ -407,6 +417,18 @@ AC_DEFUN([gl_INIT],
407 fi 417 fi
408 fi 418 fi
409 } 419 }
420 func_gl_gnulib_m4code_getdtablesize ()
421 {
422 if ! $gl_gnulib_enabled_getdtablesize; then
423 gl_FUNC_GETDTABLESIZE
424 if test $HAVE_GETDTABLESIZE = 0; then
425 AC_LIBOBJ([getdtablesize])
426 gl_PREREQ_GETDTABLESIZE
427 fi
428 gl_UNISTD_MODULE_INDICATOR([getdtablesize])
429 gl_gnulib_enabled_getdtablesize=true
430 fi
431 }
410 func_gl_gnulib_m4code_getgroups () 432 func_gl_gnulib_m4code_getgroups ()
411 { 433 {
412 if ! $gl_gnulib_enabled_getgroups; then 434 if ! $gl_gnulib_enabled_getgroups; then
@@ -479,9 +501,6 @@ AC_DEFUN([gl_INIT],
479 if test $REPLACE_STAT = 1; then 501 if test $REPLACE_STAT = 1; then
480 func_gl_gnulib_m4code_pathmax 502 func_gl_gnulib_m4code_pathmax
481 fi 503 fi
482 if test $REPLACE_STAT = 1; then
483 func_gl_gnulib_m4code_verify
484 fi
485 fi 504 fi
486 } 505 }
487 func_gl_gnulib_m4code_strtoll () 506 func_gl_gnulib_m4code_strtoll ()
@@ -508,12 +527,6 @@ AC_DEFUN([gl_INIT],
508 gl_gnulib_enabled_strtoull=true 527 gl_gnulib_enabled_strtoull=true
509 fi 528 fi
510 } 529 }
511 func_gl_gnulib_m4code_verify ()
512 {
513 if ! $gl_gnulib_enabled_verify; then
514 gl_gnulib_enabled_verify=true
515 fi
516 }
517 func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec () 530 func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec ()
518 { 531 {
519 if ! $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec; then 532 if ! $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec; then
@@ -532,6 +545,9 @@ AC_DEFUN([gl_INIT],
532 if test $HAVE_FACCESSAT = 0; then 545 if test $HAVE_FACCESSAT = 0; then
533 func_gl_gnulib_m4code_03e0aaad4cb89ca757653bd367a6ccb7 546 func_gl_gnulib_m4code_03e0aaad4cb89ca757653bd367a6ccb7
534 fi 547 fi
548 if test $HAVE_FCNTL = 0 || test $REPLACE_FCNTL = 1; then
549 func_gl_gnulib_m4code_getdtablesize
550 fi
535 if test $HAVE_FDOPENDIR = 0; then 551 if test $HAVE_FDOPENDIR = 0; then
536 func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b 552 func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b
537 fi 553 fi
@@ -568,19 +584,14 @@ AC_DEFUN([gl_INIT],
568 if { test $HAVE_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; } && test $ac_cv_type_long_long_int = yes; then 584 if { test $HAVE_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; } && test $ac_cv_type_long_long_int = yes; then
569 func_gl_gnulib_m4code_strtoll 585 func_gl_gnulib_m4code_strtoll
570 fi 586 fi
571 if test $HAVE_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; then
572 func_gl_gnulib_m4code_verify
573 fi
574 if test $ac_cv_func_strtoumax = no && test $ac_cv_type_unsigned_long_long_int = yes; then 587 if test $ac_cv_func_strtoumax = no && test $ac_cv_type_unsigned_long_long_int = yes; then
575 func_gl_gnulib_m4code_strtoull 588 func_gl_gnulib_m4code_strtoull
576 fi 589 fi
577 if test $ac_cv_func_strtoumax = no; then
578 func_gl_gnulib_m4code_verify
579 fi
580 m4_pattern_allow([^gl_GNULIB_ENABLED_]) 590 m4_pattern_allow([^gl_GNULIB_ENABLED_])
581 AM_CONDITIONAL([gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b], [$gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b]) 591 AM_CONDITIONAL([gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b], [$gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b])
582 AM_CONDITIONAL([gl_GNULIB_ENABLED_dosname], [$gl_gnulib_enabled_dosname]) 592 AM_CONDITIONAL([gl_GNULIB_ENABLED_dosname], [$gl_gnulib_enabled_dosname])
583 AM_CONDITIONAL([gl_GNULIB_ENABLED_euidaccess], [$gl_gnulib_enabled_euidaccess]) 593 AM_CONDITIONAL([gl_GNULIB_ENABLED_euidaccess], [$gl_gnulib_enabled_euidaccess])
594 AM_CONDITIONAL([gl_GNULIB_ENABLED_getdtablesize], [$gl_gnulib_enabled_getdtablesize])
584 AM_CONDITIONAL([gl_GNULIB_ENABLED_getgroups], [$gl_gnulib_enabled_getgroups]) 595 AM_CONDITIONAL([gl_GNULIB_ENABLED_getgroups], [$gl_gnulib_enabled_getgroups])
585 AM_CONDITIONAL([gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36], [$gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36]) 596 AM_CONDITIONAL([gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36], [$gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36])
586 AM_CONDITIONAL([gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1], [$gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1]) 597 AM_CONDITIONAL([gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1], [$gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1])
@@ -590,7 +601,6 @@ AC_DEFUN([gl_INIT],
590 AM_CONDITIONAL([gl_GNULIB_ENABLED_stat], [$gl_gnulib_enabled_stat]) 601 AM_CONDITIONAL([gl_GNULIB_ENABLED_stat], [$gl_gnulib_enabled_stat])
591 AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoll], [$gl_gnulib_enabled_strtoll]) 602 AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoll], [$gl_gnulib_enabled_strtoll])
592 AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoull], [$gl_gnulib_enabled_strtoull]) 603 AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoull], [$gl_gnulib_enabled_strtoull])
593 AM_CONDITIONAL([gl_GNULIB_ENABLED_verify], [$gl_gnulib_enabled_verify])
594 AM_CONDITIONAL([gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec], [$gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec]) 604 AM_CONDITIONAL([gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec], [$gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec])
595 # End of code from modules 605 # End of code from modules
596 m4_ifval(gl_LIBSOURCES_LIST, [ 606 m4_ifval(gl_LIBSOURCES_LIST, [
@@ -745,6 +755,8 @@ AC_DEFUN([gl_FILE_LIST], [
745 lib/allocator.c 755 lib/allocator.c
746 lib/allocator.h 756 lib/allocator.h
747 lib/at-func.c 757 lib/at-func.c
758 lib/binary-io.c
759 lib/binary-io.h
748 lib/c-ctype.c 760 lib/c-ctype.c
749 lib/c-ctype.h 761 lib/c-ctype.h
750 lib/c-strcase.h 762 lib/c-strcase.h
@@ -764,6 +776,7 @@ AC_DEFUN([gl_FILE_LIST], [
764 lib/execinfo.c 776 lib/execinfo.c
765 lib/execinfo.in.h 777 lib/execinfo.in.h
766 lib/faccessat.c 778 lib/faccessat.c
779 lib/fcntl.c
767 lib/fcntl.in.h 780 lib/fcntl.in.h
768 lib/fdatasync.c 781 lib/fdatasync.c
769 lib/fdopendir.c 782 lib/fdopendir.c
@@ -776,6 +789,7 @@ AC_DEFUN([gl_FILE_LIST], [
776 lib/fsync.c 789 lib/fsync.c
777 lib/ftoastr.c 790 lib/ftoastr.c
778 lib/ftoastr.h 791 lib/ftoastr.h
792 lib/getdtablesize.c
779 lib/getgroups.c 793 lib/getgroups.c
780 lib/getloadavg.c 794 lib/getloadavg.c
781 lib/getopt.c 795 lib/getopt.c
@@ -786,7 +800,6 @@ AC_DEFUN([gl_FILE_LIST], [
786 lib/gettime.c 800 lib/gettime.c
787 lib/gettimeofday.c 801 lib/gettimeofday.c
788 lib/group-member.c 802 lib/group-member.c
789 lib/ignore-value.h
790 lib/intprops.h 803 lib/intprops.h
791 lib/inttypes.in.h 804 lib/inttypes.in.h
792 lib/lstat.c 805 lib/lstat.c
@@ -799,6 +812,7 @@ AC_DEFUN([gl_FILE_LIST], [
799 lib/openat-proc.c 812 lib/openat-proc.c
800 lib/openat.h 813 lib/openat.h
801 lib/pathmax.h 814 lib/pathmax.h
815 lib/pipe2.c
802 lib/pselect.c 816 lib/pselect.c
803 lib/pthread_sigmask.c 817 lib/pthread_sigmask.c
804 lib/putenv.c 818 lib/putenv.c
@@ -870,6 +884,7 @@ AC_DEFUN([gl_FILE_LIST], [
870 m4/extern-inline.m4 884 m4/extern-inline.m4
871 m4/faccessat.m4 885 m4/faccessat.m4
872 m4/fcntl-o.m4 886 m4/fcntl-o.m4
887 m4/fcntl.m4
873 m4/fcntl_h.m4 888 m4/fcntl_h.m4
874 m4/fdatasync.m4 889 m4/fdatasync.m4
875 m4/fdopendir.m4 890 m4/fdopendir.m4
@@ -877,6 +892,7 @@ AC_DEFUN([gl_FILE_LIST], [
877 m4/fpending.m4 892 m4/fpending.m4
878 m4/fstatat.m4 893 m4/fstatat.m4
879 m4/fsync.m4 894 m4/fsync.m4
895 m4/getdtablesize.m4
880 m4/getgroups.m4 896 m4/getgroups.m4
881 m4/getloadavg.m4 897 m4/getloadavg.m4
882 m4/getopt.m4 898 m4/getopt.m4
@@ -897,6 +913,7 @@ AC_DEFUN([gl_FILE_LIST], [
897 m4/nocrash.m4 913 m4/nocrash.m4
898 m4/off_t.m4 914 m4/off_t.m4
899 m4/pathmax.m4 915 m4/pathmax.m4
916 m4/pipe2.m4
900 m4/pselect.m4 917 m4/pselect.m4
901 m4/pthread_sigmask.m4 918 m4/pthread_sigmask.m4
902 m4/putenv.m4 919 m4/putenv.m4
diff --git a/m4/pipe2.m4 b/m4/pipe2.m4
new file mode 100644
index 00000000000..6ccee105239
--- /dev/null
+++ b/m4/pipe2.m4
@@ -0,0 +1,18 @@
1# pipe2.m4 serial 2
2dnl Copyright (C) 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_PIPE2],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10
11 dnl Persuade glibc <unistd.h> to declare pipe2().
12 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
13
14 AC_CHECK_FUNCS_ONCE([pipe2])
15 if test $ac_cv_func_pipe2 != yes; then
16 HAVE_PIPE2=0
17 fi
18])
diff --git a/m4/stdalign.m4 b/m4/stdalign.m4
index a866ff670b1..20be01aaf20 100644
--- a/m4/stdalign.m4
+++ b/m4/stdalign.m4
@@ -31,7 +31,8 @@ AC_DEFUN([gl_STDALIGN_H],
31 31
32 /* Test _Alignas only on platforms where gnulib can help. */ 32 /* Test _Alignas only on platforms where gnulib can help. */
33 #if \ 33 #if \
34 (__GNUC__ || __IBMC__ || __IBMCPP__ \ 34 ((defined __cplusplus && 201103 <= __cplusplus) \
35 || __GNUC__ || __IBMC__ || __IBMCPP__ || __ICC \
35 || 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER) 36 || 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER)
36 struct alignas_test { char c; char alignas (8) alignas_8; }; 37 struct alignas_test { char c; char alignas (8) alignas_8; };
37 char test_alignas[offsetof (struct alignas_test, alignas_8) == 8 38 char test_alignas[offsetof (struct alignas_test, alignas_8) == 8
diff --git a/nt/ChangeLog b/nt/ChangeLog
index 1a0746b3181..c0598dd5630 100644
--- a/nt/ChangeLog
+++ b/nt/ChangeLog
@@ -1,3 +1,17 @@
12013-07-07 Eli Zaretskii <eliz@gnu.org>
2
3 * inc/sys/socket.h (F_SETFD, O_CLOEXEC, F_DUPFD_CLOEXEC)
4 (FD_CLOEXEC): New macros.
5
62013-07-07 Paul Eggert <eggert@cs.ucla.edu>
7
8 Make file descriptors close-on-exec when possible (Bug#14803).
9 * gnulib.mk: Remove empty gl_GNULIB_ENABLED_verify section;
10 otherwise, gnulib-tool complains given close-on-exec changes.
11 * inc/ms-w32.h (pipe): Remove.
12 * mingw-cfg.site (ac_cv_func_fcntl, gl_cv_func_fcntl_f_dupfd_cloexec)
13 (gl_cv_func_fcntl_f_dupfd_works, ac_cv_func_pipe2): New vars.
14
12013-06-25 Juanma Barranquero <lekktu@gmail.com> 152013-06-25 Juanma Barranquero <lekktu@gmail.com>
2 16
3 * configure.bat: Add warning to the help text about using the 17 * configure.bat: Add warning to the help text about using the
diff --git a/nt/gnulib.mk b/nt/gnulib.mk
index ac4fc2768d9..df27dcf610c 100644
--- a/nt/gnulib.mk
+++ b/nt/gnulib.mk
@@ -876,9 +876,6 @@ EXTRA_DIST += utimens.h
876 876
877## begin gnulib module verify 877## begin gnulib module verify
878 878
879if gl_GNULIB_ENABLED_verify
880
881endif
882EXTRA_DIST += verify.h 879EXTRA_DIST += verify.h
883 880
884## end gnulib module verify 881## end gnulib module verify
diff --git a/nt/inc/ms-w32.h b/nt/inc/ms-w32.h
index 29c8e383893..3e50c78f145 100644
--- a/nt/inc/ms-w32.h
+++ b/nt/inc/ms-w32.h
@@ -211,7 +211,6 @@ extern struct tm * sys_localtime (const time_t *);
211#define mktemp sys_mktemp 211#define mktemp sys_mktemp
212#undef open 212#undef open
213#define open sys_open 213#define open sys_open
214#define pipe sys_pipe
215#undef read 214#undef read
216#define read sys_read 215#define read sys_read
217#define rename sys_rename 216#define rename sys_rename
diff --git a/nt/inc/sys/socket.h b/nt/inc/sys/socket.h
index 99227d75d28..93bf9f91665 100644
--- a/nt/inc/sys/socket.h
+++ b/nt/inc/sys/socket.h
@@ -123,7 +123,11 @@ int sys_sendto (int s, const char * buf, int len, int flags,
123 an fcntl function, for setting sockets to non-blocking mode. */ 123 an fcntl function, for setting sockets to non-blocking mode. */
124int fcntl (int s, int cmd, int options); 124int fcntl (int s, int cmd, int options);
125#define F_SETFL 4 125#define F_SETFL 4
126#define F_SETFD 2
126#define O_NONBLOCK 04000 127#define O_NONBLOCK 04000
128#define O_CLOEXEC O_NOINHERIT
129#define F_DUPFD_CLOEXEC 0x40000000
130#define FD_CLOEXEC 1
127 131
128/* we are providing a real h_errno variable */ 132/* we are providing a real h_errno variable */
129#undef h_errno 133#undef h_errno
diff --git a/nt/mingw-cfg.site b/nt/mingw-cfg.site
index 41e4f23784e..cf55fe04ed8 100644
--- a/nt/mingw-cfg.site
+++ b/nt/mingw-cfg.site
@@ -67,6 +67,10 @@ gl_cv_func_readlink_works=yes
67gl_cv_func_symlink_works=yes 67gl_cv_func_symlink_works=yes
68ac_cv_func_readlinkat=yes 68ac_cv_func_readlinkat=yes
69ac_cv_func_faccessat=yes 69ac_cv_func_faccessat=yes
70# Implemented in w32.c
71ac_cv_func_fcntl=yes
72gl_cv_func_fcntl_f_dupfd_cloexec=yes
73gl_cv_func_fcntl_f_dupfd_works=yes
70# We don't need fdopendir 74# We don't need fdopendir
71ac_cv_func_fdopendir="not-needed" 75ac_cv_func_fdopendir="not-needed"
72gl_cv_func_fdopendir_works="no-but-not-needed-so-yes" 76gl_cv_func_fdopendir_works="no-but-not-needed-so-yes"
@@ -95,6 +99,7 @@ ac_cv_func_getloadavg=yes
95# Avoid compiling gnulib mktime 99# Avoid compiling gnulib mktime
96gl_cv_func_working_mktime=yes 100gl_cv_func_working_mktime=yes
97# Implemented in w32.c 101# Implemented in w32.c
102ac_cv_func_pipe2=yes
98ac_cv_have_decl_unsetenv=yes 103ac_cv_have_decl_unsetenv=yes
99ac_cv_func_unsetenv=yes 104ac_cv_func_unsetenv=yes
100gt_cv_func_unsetenv_ret='int' 105gt_cv_func_unsetenv_ret='int'
diff --git a/src/ChangeLog b/src/ChangeLog
index b95488c1e70..60e7e376729 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,309 @@
12013-07-13 Paul Eggert <eggert@cs.ucla.edu>
2
3 Don't lose top specpdl entry when memory is exhausted.
4 * eval.c (grow_specpdl): Increment specpdl top by 1 and check for
5 specpdl overflow here, to simplify callers; all callers changed.
6 Always reserve an unused entry at the stack top; this avoids
7 losing the top entry's information when memory is exhausted.
8
92013-07-12 Paul Eggert <eggert@cs.ucla.edu>
10
11 Clean up errno reporting and fix some errno-reporting bugs.
12 * callproc.c (Fcall_process):
13 * fileio.c (Fcopy_file, Finsert_file_contents, Fwrite_region):
14 * process.c (create_process, Fmake_network_process):
15 * unexaix.c (report_error):
16 * unexcoff.c (report_error):
17 Be more careful about reporting the errno of failed operations.
18 The code previously reported the wrong errno sometimes.
19 Also, prefer report_file_errno to setting errno + report_file_error.
20 (Fcall_process): Look at openp return value rather than at path,
21 as that's a bit faster and clearer when there's a numeric predicate.
22 * fileio.c (report_file_errno): New function, with most of the
23 old contents of report_file_error.
24 (report_file_error): Use it.
25 (Ffile_exists_p, Ffile_accessible_directory_p):
26 Set errno to 0 when it is junk.
27 * fileio.c (Faccess_file):
28 * image.c (x_create_bitmap_from_file):
29 Use faccessat rather than opening the file, to avoid the hassle of
30 having a file descriptor open.
31 * lisp.h (report_file_errno): New decl.
32 * lread.c (Flocate_file_internal): File descriptor 0 is valid, too.
33
34 Minor EBADF fixes.
35 * process.c (create_process, wait_reading_process_output) [AIX]:
36 Remove obsolete SIGHUP-related code, as Emacs no longer disables
37 SIGHUP, so EBADF is no longer acceptable here (it wouldn't work in
38 a multithreaded environment anyway).
39 * sysdep.c (emacs_close): It's not dangerous to invoke emacs_close (-1).
40
412013-07-12 Andreas Schwab <schwab@linux-m68k.org>
42
43 * image.c (x_find_image_file): Don't close a remote file handle.
44
452013-07-12 Paul Eggert <eggert@cs.ucla.edu>
46
47 Fix races with threads and file descriptors.
48 * callproc.c (Fcall_process_region):
49 * dired.c (open_directory):
50 * emacs.c (main, Fdaemon_initialized):
51 * image.c (x_find_image_file):
52 * inotify.c (Finotify_rm_watch):
53 * lread.c (Flocate_file_internal):
54 * process.c (Fnetwork_interface_list, Fnetwork_interface_info):
55 * term.c (term_mouse_moveto, init_tty):
56 * termcap.c (tgetent):
57 * unexaix.c, unexcoff.c (report_error, report_error_1, adjust_lnnoptrs)
58 * unexaix.c, unexcoff.c, unexcw.c, unexelf.c (unexec):
59 * unexhp9k800.c, unexmacosx.c (unexec):
60 * callproc.c (Fcall_process_region):
61 Use emacs_close, not close.
62 * sysdep.c (POSIX_CLOSE_RESTART, posix_close) [!POSIX_CLOSE_RESTART]:
63 New macro and function, which emulates the POSIX_CLOSE_RESTART macro
64 and posix_close function on current platforms (which all lack them).
65 (emacs_close): Use it. This should fix the races on GNU/Linux and
66 on AIX and on future platforms that support POSIX_CLOSE_RESTART,
67 and it should avoid closing random victim file descriptors on
68 other platforms.
69
702013-07-11 Paul Eggert <eggert@cs.ucla.edu>
71
72 * inotify.c (uninitialized): Remove. All uses replaced by -1.
73 (Finotify_add_watch): Simplify, since -1 means uninitialized now.
74 Touch up doc a bit.
75
76 * eval.c (backtrace_function, backtrace_args): Now EXTERNALLY_VISIBLE.
77 This is for .gdbinit xbacktrace.
78
79 * sysdep.c, term.c, termcap.c, terminal.c: Integer-related minor fixes.
80 * sysdep.c (emacs_get_tty): Return void, since nobody uses the value.
81 (emacs_set_tty): Now static.
82 * sysdep.c (emacs_set_tty, tabs_safe_p, emacs_close):
83 * term.c (tty_capable_p, tty_default_color_capabilities)
84 (get_tty_terminal, term_mouse_movement)
85 (handle_one_term_event, init_tty, maybe_fatal):
86 * termcap.c (tgetst1, struct termcap_buffer, valid_filename_p)
87 (tgetent, scan_file, name_match, compare_contin):
88 * terminal.c (get_terminal):
89 Use bool for boolean.
90 * sysdep.c (init_system_name): Don't overflow stack on huge hostname.
91 Prefer char to unsigned char if either will do.
92 * term.c (OUTPUT, turn_on_face): Omit unnecessary casts to int.
93 (tty_write_glyphs): Prefer int to unsigned.
94 (produce_glyphless_glyph): Remove 2nd (unused) int arg.
95 All callers changed.
96 * termcap.c (tprint, main) [TEST]: Remove non-working test.
97
982013-07-10 Paul Eggert <eggert@cs.ucla.edu>
99
100 Port to C89.
101 * bytecode.c (BYTE_CODE_THREADED): Do not define if __STRICT_ANSI__.
102 (B__dummy__): New dummy symbol, to pacify C89.
103 * dbusbind.c (XD_DEBUG_MESSAGE): Omit debugging on C89 hosts, since
104 they can't grok varargs macros.
105 * dispnew.c (add_window_display_history)
106 (add_frame_display_history):
107 * print.c (print_object):
108 * xdisp.c (debug_method_add):
109 Use %p printf format only for void pointers.
110 * emacs.c (usage_message): New constant, replacing ...
111 (USAGE1, USAGE2, USAGE3): Remove; they were too long for C89.
112 (main): Adjust to usage reorg.
113 * fns.c (syms_of_fns):
114 * profiler.c (syms_of_profiler):
115 Don't use non-constant struct initializers.
116 * gnutls.h (gnutls_initstage_t):
117 * lisp.h (enum Lisp_Fwd_Type):
118 * lread.c (lisp_file_lexically_bound_p):
119 * xsettings.c (anonymous enum):
120 Remove trailing comma.
121 * xsettings.c (apply_xft_settings): Use %f, not %lf; %lf is a C99ism.
122 * lisp.h (ENUM_BF): Use unsigned if pedantic.
123 (DEFUN_FUNCTION_INIT): New macro, that falls back on a cast if pre-C99.
124 (DEFUN): Use it.
125 * regex.c (const_re_char): New type, to pacify strict C89.
126 All uses of 'const re_char' replaced to use it.
127 * regex.h (_Restrict_): Rename from __restrict, to avoid clash
128 with glibc when strict C89. This change is imported from gnulib.
129 All uses changed.
130 (_Restrict_arr_): Rename from __restrict_arr, similarly.
131 * sysdep.c (time_from_jiffies) [!HAVE_LONG_LONG_INT]:
132 Omit GNU_LINUX implementation, since it requires long long.
133 * xterm.c (x_draw_underwave):
134 Do not assume the traditional order of struct's members.
135 (x_term_init): Rewrite to avoid the need for non-constant structure
136 initializers.
137
138 Syntax cleanup, mostly replacing macros with functions.
139` This removes the need for the syntax_temp hack.
140 * search.c: Include syntax.h after buffer.h, since syntax.h uses BVAR.
141 * syntax.c (SYNTAX_INLINE): New macro.
142 (SYNTAX_FLAGS_COMSTART_FIRST, SYNTAX_FLAGS_COMSTART_SECOND)
143 (SYNTAX_FLAGS_COMEND_FIRST, SYNTAX_FLAGS_COMEND_SECOND)
144 (SYNTAX_FLAGS_PREFIX, SYNTAX_FLAGS_COMMENT_STYLEB)
145 (SYNTAX_FLAGS_COMMENT_STYLEC, SYNTAX_FLAGS_COMMENT_STYLEC2)
146 (SYNTAX_FLAGS_COMMENT_NESTED, SYNTAX_FLAGS_COMMENT_STYLE)
147 (SYNTAX_COMEND_FIRST): Now functions, not macros.
148 (ST_COMMENT_STYLE, ST_STRING_STYLE, INTERVALS_AT_ONCE):
149 Now constants, not macros.
150 (syntax_temp) [!__GNUC__]: Remove.
151 (SYNTAX_PREFIX): Remove; all uses replaced by syntax_prefix_flag_p.
152 (syntax_prefix_flag_p): Move implementation of SYNTAX_PREFIX here.
153 (SET_RAW_SYNTAX_ENTRY, SET_RAW_SYNTAX_ENTRY_RANGE, SYNTAX_MATCH)
154 (SETUP_SYNTAX_TABLE, SETUP_SYNTAX_TABLE_FOR_OBJECT):
155 Move here from syntax.h; now functions, not macros. Except for the
156 last function, these are static since only syntax.c uses them.
157 (syntax_multibyte): Rename from SYNTAX_WITH_MULTIBYTE_CHECK.
158 All uses changed. Now a function, not a macro; use this fact
159 to simplify the code.
160 (scan_lists, scan_sexps_forward): Remove workarounds for ancient
161 compiler bugs; no longer relevant.
162 * syntax.h: Use INLINE_HEADER_BEGIN, INLINE_HEADER_END.
163 (SYNTAX_INLINE): New macro.
164 (struct gl_state_s, gl_state): Move earlier, so that it's in scope
165 for the new functions. Use bool for boolean member.
166 (SYNTAX_ENTRY, SYNTAX, SYNTAX_WITH_FLAGS, SYNTAX_MATCH)
167 (SYNTAX_TABLE_BYTE_TO_CHAR, UPDATE_SYNTAX_TABLE_FORWARD)
168 (UPDATE_SYNTAX_TABLE_BACKWARD, UPDATE_SYNTAX_TABLE)
169 (SETUP_BUFFER_SYNTAX_TABLE):
170 Now extern inline functions, not macros.
171 (CURRENT_SYNTAX_TABLE, SYNTAX_ENTRY_INT):
172 Remove; all uses replaced by implementation.
173 (syntax_temp) [!__GNUC__]: Remove decl.
174 (SETUP_SYNTAX_TABLE_FOR_OBJECT): New decl.
175
1762013-07-10 Jan Djärv <jan.h.d@swipnet.se>
177
178 * emacs.c (main): Fix syntax error.
179
1802013-07-10 Paul Eggert <eggert@cs.ucla.edu>
181
182 Timestamp fixes for undo (Bug#14824).
183 * atimer.c (schedule_atimer):
184 * fileio.c (Ffile_newer_than_file_p):
185 Minor cleanup: use EMACS_TIME_LT so that we can remove EMACS_TIME_GT.
186 * buffer.c (buffer-undo-list): Document (t . 0) and (t . -1).
187 * fileio.c (Fclear_visited_file_modtime): Move to lisp/files.el.
188 (syms_of_fileio): Remove Sclear_visited_file_name.
189 (Fvisited_file_modtime): Return -1, not (-1 ...), when the visited
190 file doesn't exist; this avoids an ambiguity with negative timestamps.
191 (Fset_visited_file_modtime): Accept -1 and 0 as time-list arg.
192 * systime.h (make_emacs_time, invalid_emacs_time):
193 Don't assume struct timespec layout; POSIX doesn't guarantee it.
194 (EMACS_TIME_NE, EMACS_TIME_GT, EMACS_TIME_GE): Remove.
195 * undo.c (record_first_change): Push (visited-file-modtime) onto
196 undo list rather than reimplementing it by hand, incorrectly.
197
1982013-07-09 Ken Brown <kbrown@cornell.edu>
199
200 * sheap.c (STATIC_HEAP_SIZE) [__x86_64__]: Increase to 18MB.
201
2022013-07-09 Juanma Barranquero <lekktu@gmail.com>
203
204 * makefile.w32-in ($(BLD)/emacs.$(O), $(BLD)/sysdep.$(O)): Update.
205
2062013-07-09 Paul Eggert <eggert@cs.ucla.edu>
207
208 Handle errno and exit status a bit more carefully.
209 * callproc.c (child_setup) [!DOS_NT]: Don't try to stuff an error
210 number into an exit status. Instead, use EXIT_CANCELED.
211 (child_setup) [!MSDOS]: Avoid possible deadlock with vfork.
212 * callproc.c (relocate_fd):
213 * emacs.c (close_output_streams, main):
214 * process.c (create_process):
215 * sysdep.c (sys_subshell) [!DOS_NT || !WINDOWSNT]:
216 Use emacs_perror for simplicity.
217 * callproc.c (relocate_fd, main):
218 * sysdep.c (sys_subshell):
219 Exit with EXIT_CANCELED etc., not 1, when exec setup fails.
220 (shut_down_emacs): Use emacs_write, not write.
221 * emacs.c, sysdep.c: Don't include <ignore-value.h>.
222 * fileio.c (Fcopy_file, e_write):
223 * nsterm.m (ns_select):
224 * process.c (send_process):
225 * sound.c (vox_write):
226 Use emacs_write_sig, not emacs_write.
227 * lisp.h (emacs_write_sig, emacs_perror): New decls.
228 * process.h (EXIT_CANCELED), EXIT_CANNOT_INVOKE, EXIT_ENOENT):
229 New constants.
230 * sysdep.c (emacs_backtrace): Use emacs_write, not ignore_value
231 of write.
232 (emacs_full_write): New function.
233 (emacs_write): Rewrite to use it.
234 (emacswrite_sig, emacs_perror): New functions.
235 * xrdb.c (fatal): Don't invoke perror, since errno might be garbage.
236
2372013-07-08 Magnus Henoch <magnus.henoch@gmail.com> (tiny change).
238
239 * image.c (imagemagick_load_image): Do not use MagickExportImagePixels
240 on NS even if it is present. Pixmap on NS is a void*.
241
2422013-07-07 Paul Eggert <eggert@cs.ucla.edu>
243
244 Port to Ubuntu 10 (Bug#14803).
245 Problem reported by T.V. Raman.
246 * process.c (close_on_exec, accept4, process_socket):
247 Define these if !HAVE_ACCEPT4, not if !SOCK_CLOEXEC.
248
2492013-07-07 Eli Zaretskii <eliz@gnu.org>
250
251 * w32.c (sys_dup): Declare prototype.
252
253 * filelock.c:
254 * emacs.c:
255 * callproc.c [WINDOWSNT]: Include sys/socket.h.
256
2572013-07-07 Paul Eggert <eggert@cs.ucla.edu>
258
259 Make file descriptors close-on-exec when possible (Bug#14803).
260 This simplifies Emacs a bit, since it no longer needs to worry
261 about closing file descriptors by hand in some cases.
262 It also fixes some unlikely races. Not all such races, as
263 libraries often open files internally without setting
264 close-on-exec, but it's an improvement.
265 * alloc.c (valid_pointer_p) [!WINDOWSNT]:
266 * callproc.c (Fcall_process) [!MSDOS]:
267 * emacs.c (main) [!DOS_NT]:
268 * nsterm.m (ns_term_init):
269 * process.c (create_process):
270 Use 'pipe2' with O_CLOEXEC instead of 'pipe'.
271 * emacs.c (Fcall_process_region) [HAVE_MKOSTEMP]:
272 * filelock.c (create_lock_file) [HAVE_MKOSTEMP]:
273 Prefer mkostemp with O_CLOEXEC to mkstemp.
274 * callproc.c (relocate_fd) [!WINDOWSNT]:
275 * emacs.c (main): Use F_DUPFD_CLOEXEC, not plain F_DUPFD.
276 No need to use fcntl (..., F_SETFD, FD_CLOEXEC), since we're
277 now using pipe2.
278 * filelock.c (create_lock_file) [! HAVE_MKOSTEMP]:
279 Make the resulting file descriptor close-on-exec.
280 * lisp.h, lread.c, process.c (close_load_descs, close_process_descs):
281 * lread.c (load_descriptor_list, load_descriptor_unwind):
282 Remove; no longer needed. All uses removed.
283 * process.c (SOCK_CLOEXEC): Define to 0 if not supplied by system.
284 (close_on_exec, accept4, process_socket) [!SOCK_CLOEXEC]:
285 New functions.
286 (socket) [!SOCK_CLOEXEC]: Supply a substitute.
287 (Fmake_network_process, Fnetwork_interface_list):
288 (Fnetwork_interface_info, server_accept_connection):
289 Make newly-created socket close-on-exec.
290 * sysdep.c (emacs_open, emacs_fopen):
291 Make new-created descriptor close-on-exec.
292 * w32.c (fcntl): Support F_DUPFD_CLOEXEC well enough for Emacs.
293 * w32.c, w32.h (pipe2): Rename from 'pipe', with new flags arg.
294
2952013-07-07 Jan Djärv <jan.h.d@swipnet.se>
296
297 * nsterm.m (sendEvent:): Propagate keyboard events to modal windows
298 for NS_IMPL_GNUSTEP.
299
3002013-07-07 Paul Eggert <eggert@cs.ucla.edu>
301
302 Fix openp errno handling.
303 * callproc.c (Fcall_process): Preserve openp errno around close.
304 * lread.c (openp): Set errno when returning -1, as some callers
305 expect this.
306
12013-07-06 Jan Djärv <jan.h.d@swipnet.se> 3072013-07-06 Jan Djärv <jan.h.d@swipnet.se>
2 308
3 * nsterm.m (sendEvent:): Handle NSAPP_DATA2_RUNFILEDIALOG. 309 * nsterm.m (sendEvent:): Handle NSAPP_DATA2_RUNFILEDIALOG.
@@ -655,7 +961,7 @@
655 (VALMASK): Also a constant, for benefit of old GDB. 961 (VALMASK): Also a constant, for benefit of old GDB.
656 (LISP_INT_TAG_P): Remove; no longer needed as the only caller 962 (LISP_INT_TAG_P): Remove; no longer needed as the only caller
657 is INTEGERP, which can fold it in. 963 is INTEGERP, which can fold it in.
658 (XLI, XIL, XHASH, XTYPE,XINT, XFASTINT, XUINT) 964 (XLI, XIL, XHASH, XTYPE, XINT, XFASTINT, XUINT)
659 (make_number, XPNTR, XUNTAG, EQ, XCONS, XVECTOR, XSTRING, XSYMBOL) 965 (make_number, XPNTR, XUNTAG, EQ, XCONS, XVECTOR, XSTRING, XSYMBOL)
660 (XFLOAT, XPROCESS, XWINDOW, XTERMINAL, XSUBR, XBUFFER, XCHAR_TABLE) 966 (XFLOAT, XPROCESS, XWINDOW, XTERMINAL, XSUBR, XBUFFER, XCHAR_TABLE)
661 (XSUB_CHAR_TABLE, XBOOL_VECTOR, make_lisp_ptr, CHECK_TYPE) 967 (XSUB_CHAR_TABLE, XBOOL_VECTOR, make_lisp_ptr, CHECK_TYPE)
diff --git a/src/alloc.c b/src/alloc.c
index 230b3b614d7..6ef6af1e3a1 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -4750,7 +4750,7 @@ valid_pointer_p (void *p)
4750 Unfortunately, we cannot use NULL_DEVICE here, as emacs_write may 4750 Unfortunately, we cannot use NULL_DEVICE here, as emacs_write may
4751 not validate p in that case. */ 4751 not validate p in that case. */
4752 4752
4753 if (pipe (fd) == 0) 4753 if (pipe2 (fd, O_CLOEXEC) == 0)
4754 { 4754 {
4755 bool valid = emacs_write (fd[1], (char *) p, 16) == 16; 4755 bool valid = emacs_write (fd[1], (char *) p, 16) == 16;
4756 emacs_close (fd[1]); 4756 emacs_close (fd[1]);
diff --git a/src/atimer.c b/src/atimer.c
index 73c7aa5686b..bb5294670d3 100644
--- a/src/atimer.c
+++ b/src/atimer.c
@@ -336,7 +336,7 @@ schedule_atimer (struct atimer *t)
336 struct atimer *a = atimers, *prev = NULL; 336 struct atimer *a = atimers, *prev = NULL;
337 337
338 /* Look for the first atimer that is ripe after T. */ 338 /* Look for the first atimer that is ripe after T. */
339 while (a && EMACS_TIME_GT (t->expiration, a->expiration)) 339 while (a && EMACS_TIME_LT (a->expiration, t->expiration))
340 prev = a, a = a->next; 340 prev = a, a = a->next;
341 341
342 /* Insert T in front of the atimer found, if any. */ 342 /* Insert T in front of the atimer found, if any. */
diff --git a/src/buffer.c b/src/buffer.c
index 2555b5c17ac..19e3982a8a4 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -6096,6 +6096,11 @@ and is the visited file's modification time, as of that time. If the
6096modification time of the most recent save is different, this entry is 6096modification time of the most recent save is different, this entry is
6097obsolete. 6097obsolete.
6098 6098
6099An entry (t . 0) means means the buffer was previously unmodified but
6100its time stamp was unknown because it was not associated with a file.
6101An entry (t . -1) is similar, except that it means the buffer's visited
6102file did not exist.
6103
6099An entry (nil PROPERTY VALUE BEG . END) indicates that a text property 6104An entry (nil PROPERTY VALUE BEG . END) indicates that a text property
6100was modified between BEG and END. PROPERTY is the property name, 6105was modified between BEG and END. PROPERTY is the property name,
6101and VALUE is the old value. 6106and VALUE is the old value.
diff --git a/src/bytecode.c b/src/bytecode.c
index a22be984b44..f186f7d1bc3 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -59,7 +59,8 @@ by Hallvard:
59 indirect threaded, using GCC's computed goto extension. This code, 59 indirect threaded, using GCC's computed goto extension. This code,
60 as currently implemented, is incompatible with BYTE_CODE_SAFE and 60 as currently implemented, is incompatible with BYTE_CODE_SAFE and
61 BYTE_CODE_METER. */ 61 BYTE_CODE_METER. */
62#if defined (__GNUC__) && !defined (BYTE_CODE_SAFE) && !defined (BYTE_CODE_METER) 62#if (defined __GNUC__ && !defined __STRICT_ANSI__ \
63 && !defined BYTE_CODE_SAFE && !defined BYTE_CODE_METER)
63#define BYTE_CODE_THREADED 64#define BYTE_CODE_THREADED
64#endif 65#endif
65 66
@@ -285,8 +286,10 @@ enum byte_code_op
285 286
286#ifdef BYTE_CODE_SAFE 287#ifdef BYTE_CODE_SAFE
287 Bscan_buffer = 0153, /* No longer generated as of v18. */ 288 Bscan_buffer = 0153, /* No longer generated as of v18. */
288 Bset_mark = 0163 /* this loser is no longer generated as of v18 */ 289 Bset_mark = 0163, /* this loser is no longer generated as of v18 */
289#endif 290#endif
291
292 B__dummy__ = 0 /* Pacify C89. */
290}; 293};
291 294
292/* Whether to maintain a `top' and `bottom' field in the stack frame. */ 295/* Whether to maintain a `top' and `bottom' field in the stack frame. */
diff --git a/src/callproc.c b/src/callproc.c
index 6de8113dc14..30f9dc58d46 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -31,6 +31,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
31 31
32#ifdef WINDOWSNT 32#ifdef WINDOWSNT
33#define NOMINMAX 33#define NOMINMAX
34#include <sys/socket.h> /* for fcntl */
34#include <windows.h> 35#include <windows.h>
35#include "w32.h" 36#include "w32.h"
36#define _P_NOWAIT 1 /* from process.h */ 37#define _P_NOWAIT 1 /* from process.h */
@@ -418,9 +419,10 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
418 default_output_mode); 419 default_output_mode);
419 if (fd_output < 0) 420 if (fd_output < 0)
420 { 421 {
422 int open_errno = errno;
421 output_file = DECODE_FILE (output_file); 423 output_file = DECODE_FILE (output_file);
422 report_file_error ("Opening process output file", 424 report_file_errno ("Opening process output file",
423 Fcons (output_file, Qnil)); 425 Fcons (output_file, Qnil), open_errno);
424 } 426 }
425 if (STRINGP (error_file) || NILP (error_file)) 427 if (STRINGP (error_file) || NILP (error_file))
426 output_to_buffer = 0; 428 output_to_buffer = 0;
@@ -429,16 +431,19 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
429 /* Search for program; barf if not found. */ 431 /* Search for program; barf if not found. */
430 { 432 {
431 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 433 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
434 int ok;
432 435
433 GCPRO4 (infile, buffer, current_dir, error_file); 436 GCPRO4 (infile, buffer, current_dir, error_file);
434 openp (Vexec_path, args[0], Vexec_suffixes, &path, make_number (X_OK)); 437 ok = openp (Vexec_path, args[0], Vexec_suffixes, &path, make_number (X_OK));
435 UNGCPRO; 438 UNGCPRO;
439 if (ok < 0)
440 {
441 int openp_errno = errno;
442 emacs_close (filefd);
443 report_file_errno ("Searching for program",
444 Fcons (args[0], Qnil), openp_errno);
445 }
436 } 446 }
437 if (NILP (path))
438 {
439 emacs_close (filefd);
440 report_file_error ("Searching for program", Fcons (args[0], Qnil));
441 }
442 447
443 /* If program file name starts with /: for quoting a magic name, 448 /* If program file name starts with /: for quoting a magic name,
444 discard that. */ 449 discard that. */
@@ -496,11 +501,13 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
496 mktemp (tempfile); 501 mktemp (tempfile);
497 outfilefd = emacs_open (tempfile, O_WRONLY | O_CREAT | O_TRUNC, 502 outfilefd = emacs_open (tempfile, O_WRONLY | O_CREAT | O_TRUNC,
498 S_IREAD | S_IWRITE); 503 S_IREAD | S_IWRITE);
499 if (outfilefd < 0) { 504 if (outfilefd < 0)
500 emacs_close (filefd); 505 {
501 report_file_error ("Opening process output file", 506 int open_errno = errno;
502 Fcons (build_string (tempfile), Qnil)); 507 emacs_close (filefd);
503 } 508 report_file_errno ("Opening process output file",
509 Fcons (build_string (tempfile), Qnil), open_errno);
510 }
504 } 511 }
505 else 512 else
506 outfilefd = fd_output; 513 outfilefd = fd_output;
@@ -517,12 +524,11 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
517 { 524 {
518#ifndef MSDOS 525#ifndef MSDOS
519 int fd[2]; 526 int fd[2];
520 if (pipe (fd) == -1) 527 if (pipe2 (fd, O_CLOEXEC) != 0)
521 { 528 {
522 int pipe_errno = errno; 529 int pipe_errno = errno;
523 emacs_close (filefd); 530 emacs_close (filefd);
524 errno = pipe_errno; 531 report_file_errno ("Creating process pipe", Qnil, pipe_errno);
525 report_file_error ("Creating process pipe", Qnil);
526 } 532 }
527 fd0 = fd[0]; 533 fd0 = fd[0];
528 fd1 = fd[1]; 534 fd1 = fd[1];
@@ -544,6 +550,7 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
544 550
545 if (fd_error < 0) 551 if (fd_error < 0)
546 { 552 {
553 int open_errno = errno;
547 emacs_close (filefd); 554 emacs_close (filefd);
548 if (fd0 != filefd) 555 if (fd0 != filefd)
549 emacs_close (fd0); 556 emacs_close (fd0);
@@ -556,7 +563,8 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
556 error_file = build_string (NULL_DEVICE); 563 error_file = build_string (NULL_DEVICE);
557 else if (STRINGP (error_file)) 564 else if (STRINGP (error_file))
558 error_file = DECODE_FILE (error_file); 565 error_file = DECODE_FILE (error_file);
559 report_file_error ("Cannot redirect stderr", Fcons (error_file, Qnil)); 566 report_file_errno ("Cannot redirect stderr",
567 Fcons (error_file, Qnil), open_errno);
560 } 568 }
561 569
562#ifdef MSDOS /* MW, July 1993 */ 570#ifdef MSDOS /* MW, July 1993 */
@@ -584,10 +592,12 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
584 fd0 = emacs_open (tempfile, O_RDONLY | O_BINARY, 0); 592 fd0 = emacs_open (tempfile, O_RDONLY | O_BINARY, 0);
585 if (fd0 < 0) 593 if (fd0 < 0)
586 { 594 {
595 int open_errno = errno;
587 unlink (tempfile); 596 unlink (tempfile);
588 emacs_close (filefd); 597 emacs_close (filefd);
589 report_file_error ("Cannot re-open temporary file", 598 report_file_errno ("Cannot re-open temporary file",
590 Fcons (build_string (tempfile), Qnil)); 599 Fcons (build_string (tempfile), Qnil),
600 open_errno);
591 } 601 }
592 } 602 }
593 else 603 else
@@ -705,10 +715,7 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
705 } 715 }
706 716
707 if (pid < 0) 717 if (pid < 0)
708 { 718 report_file_errno ("Doing vfork", Qnil, child_errno);
709 errno = child_errno;
710 report_file_error ("Doing vfork", Qnil);
711 }
712 719
713 if (INTEGERP (buffer)) 720 if (INTEGERP (buffer))
714 return unbind_to (count, Qnil); 721 return unbind_to (count, Qnil);
@@ -1034,29 +1041,29 @@ usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &r
1034 memcpy (tempfile, SDATA (encoded_tem), SBYTES (encoded_tem) + 1); 1041 memcpy (tempfile, SDATA (encoded_tem), SBYTES (encoded_tem) + 1);
1035 coding_systems = Qt; 1042 coding_systems = Qt;
1036 1043
1037#ifdef HAVE_MKSTEMP 1044#if defined HAVE_MKOSTEMP || defined HAVE_MKSTEMP
1038 { 1045 {
1039 int fd; 1046 int fd, open_errno;
1040 1047
1041 block_input (); 1048 block_input ();
1049# ifdef HAVE_MKOSTEMP
1050 fd = mkostemp (tempfile, O_CLOEXEC);
1051# else
1042 fd = mkstemp (tempfile); 1052 fd = mkstemp (tempfile);
1053# endif
1054 open_errno = errno;
1043 unblock_input (); 1055 unblock_input ();
1044 if (fd == -1) 1056 if (fd < 0)
1045 report_file_error ("Failed to open temporary file", 1057 report_file_errno ("Failed to open temporary file",
1046 Fcons (build_string (tempfile), Qnil)); 1058 Fcons (build_string (tempfile), Qnil), open_errno);
1047 else 1059 emacs_close (fd);
1048 close (fd);
1049 } 1060 }
1050#else 1061#else
1051 errno = 0; 1062 errno = EEXIST;
1052 mktemp (tempfile); 1063 mktemp (tempfile);
1053 if (!*tempfile) 1064 if (!*tempfile)
1054 { 1065 report_file_error ("Failed to open temporary file using pattern",
1055 if (!errno) 1066 Fcons (pattern, Qnil));
1056 errno = EEXIST;
1057 report_file_error ("Failed to open temporary file using pattern",
1058 Fcons (pattern, Qnil));
1059 }
1060#endif 1067#endif
1061 1068
1062 filename_string = build_string (tempfile); 1069 filename_string = build_string (tempfile);
@@ -1182,15 +1189,6 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp,
1182 1189
1183 pid_t pid = getpid (); 1190 pid_t pid = getpid ();
1184 1191
1185 /* Close Emacs's descriptors that this process should not have. */
1186 close_process_descs ();
1187
1188 /* DOS_NT isn't in a vfork, so if we are in the middle of load-file,
1189 we will lose if we call close_load_descs here. */
1190#ifndef DOS_NT
1191 close_load_descs ();
1192#endif
1193
1194 /* Note that use of alloca is always safe here. It's obvious for systems 1192 /* Note that use of alloca is always safe here. It's obvious for systems
1195 that do not have true vfork or that have true (stack) alloca. 1193 that do not have true vfork or that have true (stack) alloca.
1196 If using vfork and C_ALLOCA (when Emacs used to include 1194 If using vfork and C_ALLOCA (when Emacs used to include
@@ -1223,7 +1221,7 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp,
1223 are changed between the check and this chdir, but we should 1221 are changed between the check and this chdir, but we should
1224 at least check. */ 1222 at least check. */
1225 if (chdir (temp) < 0) 1223 if (chdir (temp) < 0)
1226 _exit (errno); 1224 _exit (EXIT_CANCELED);
1227#else /* DOS_NT */ 1225#else /* DOS_NT */
1228 /* Get past the drive letter, so that d:/ is left alone. */ 1226 /* Get past the drive letter, so that d:/ is left alone. */
1229 if (i > 2 && IS_DEVICE_SEP (temp[1]) && IS_DIRECTORY_SEP (temp[2])) 1227 if (i > 2 && IS_DEVICE_SEP (temp[1]) && IS_DIRECTORY_SEP (temp[2]))
@@ -1352,9 +1350,11 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp,
1352 emacs_close (1); 1350 emacs_close (1);
1353 emacs_close (2); 1351 emacs_close (2);
1354 1352
1353 /* Redirect file descriptors and clear FD_CLOEXEC on the redirected ones. */
1355 dup2 (in, 0); 1354 dup2 (in, 0);
1356 dup2 (out, 1); 1355 dup2 (out, 1);
1357 dup2 (err, 2); 1356 dup2 (err, 2);
1357
1358 emacs_close (in); 1358 emacs_close (in);
1359 if (out != in) 1359 if (out != in)
1360 emacs_close (out); 1360 emacs_close (out);
@@ -1366,10 +1366,12 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp,
1366 1366
1367 execve (new_argv[0], new_argv, env); 1367 execve (new_argv[0], new_argv, env);
1368 1368
1369 emacs_write (1, "Can't exec program: ", 20); 1369 /* Don't output the program name here, as it can be arbitrarily long,
1370 emacs_write (1, new_argv[0], strlen (new_argv[0])); 1370 and a long write from a vforked child to its parent can cause a
1371 emacs_write (1, "\n", 1); 1371 deadlock. */
1372 _exit (1); 1372 emacs_perror ("child process");
1373
1374 _exit (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
1373 1375
1374#else /* MSDOS */ 1376#else /* MSDOS */
1375 pid = run_msdos_command (new_argv, pwd_var + 4, in, out, err, env); 1377 pid = run_msdos_command (new_argv, pwd_var + 4, in, out, err, env);
@@ -1392,16 +1394,11 @@ relocate_fd (int fd, int minfd)
1392 return fd; 1394 return fd;
1393 else 1395 else
1394 { 1396 {
1395 int new = fcntl (fd, F_DUPFD, minfd); 1397 int new = fcntl (fd, F_DUPFD_CLOEXEC, minfd);
1396 if (new == -1) 1398 if (new == -1)
1397 { 1399 {
1398 const char *message_1 = "Error while setting up child: "; 1400 emacs_perror ("while setting up child");
1399 const char *errmessage = strerror (errno); 1401 _exit (EXIT_CANCELED);
1400 const char *message_2 = "\n";
1401 emacs_write (2, message_1, strlen (message_1));
1402 emacs_write (2, errmessage, strlen (errmessage));
1403 emacs_write (2, message_2, strlen (message_2));
1404 _exit (1);
1405 } 1402 }
1406 emacs_close (fd); 1403 emacs_close (fd);
1407 return new; 1404 return new;
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 3ec3c28431b..523544d56ca 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -142,7 +142,10 @@ static bool xd_in_read_queued_messages = 0;
142 } while (0) 142 } while (0)
143 143
144#else /* !DBUS_DEBUG */ 144#else /* !DBUS_DEBUG */
145#define XD_DEBUG_MESSAGE(...) \ 145# if __STDC_VERSION__ < 199901
146# define XD_DEBUG_MESSAGE (void) /* Pre-C99 compilers cannot debug. */
147# else
148# define XD_DEBUG_MESSAGE(...) \
146 do { \ 149 do { \
147 if (!NILP (Vdbus_debug)) \ 150 if (!NILP (Vdbus_debug)) \
148 { \ 151 { \
@@ -151,7 +154,8 @@ static bool xd_in_read_queued_messages = 0;
151 message ("%s: %s", __func__, s); \ 154 message ("%s: %s", __func__, s); \
152 } \ 155 } \
153 } while (0) 156 } while (0)
154#define XD_DEBUG_VALID_LISP_OBJECT_P(object) 157# endif
158# define XD_DEBUG_VALID_LISP_OBJECT_P(object)
155#endif 159#endif
156 160
157/* Check whether TYPE is a basic DBusType. */ 161/* Check whether TYPE is a basic DBusType. */
diff --git a/src/dired.c b/src/dired.c
index 7bbfee7e5b0..b3348b0aff0 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -95,7 +95,7 @@ open_directory (char const *name, int *fdp)
95 d = fdopendir (fd); 95 d = fdopendir (fd);
96 opendir_errno = errno; 96 opendir_errno = errno;
97 if (! d) 97 if (! d)
98 close (fd); 98 emacs_close (fd);
99 } 99 }
100#endif 100#endif
101 101
diff --git a/src/dispextern.h b/src/dispextern.h
index 1dd96c6638d..e0d04231d3a 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -3298,7 +3298,7 @@ int image_ascent (struct image *, struct face *, struct glyph_slice *);
3298void get_tty_size (int, int *, int *); 3298void get_tty_size (int, int *, int *);
3299void request_sigio (void); 3299void request_sigio (void);
3300void unrequest_sigio (void); 3300void unrequest_sigio (void);
3301int tabs_safe_p (int); 3301bool tabs_safe_p (int);
3302void init_baud_rate (int); 3302void init_baud_rate (int);
3303void init_sigio (int); 3303void init_sigio (int);
3304void ignore_sigio (void); 3304void ignore_sigio (void);
@@ -3470,11 +3470,12 @@ extern int string_cost (const char *);
3470extern int per_line_cost (const char *); 3470extern int per_line_cost (const char *);
3471extern void calculate_costs (struct frame *); 3471extern void calculate_costs (struct frame *);
3472extern void produce_glyphs (struct it *); 3472extern void produce_glyphs (struct it *);
3473extern int tty_capable_p (struct tty_display_info *, unsigned, unsigned long, unsigned long); 3473extern bool tty_capable_p (struct tty_display_info *, unsigned,
3474 unsigned long, unsigned long);
3474extern void set_tty_color_mode (struct tty_display_info *, struct frame *); 3475extern void set_tty_color_mode (struct tty_display_info *, struct frame *);
3475extern struct terminal *get_named_tty (const char *); 3476extern struct terminal *get_named_tty (const char *);
3476extern void create_tty_output (struct frame *); 3477extern void create_tty_output (struct frame *);
3477extern struct terminal *init_tty (const char *, const char *, int); 3478extern struct terminal *init_tty (const char *, const char *, bool);
3478extern void tty_append_glyph (struct it *); 3479extern void tty_append_glyph (struct it *);
3479 3480
3480 3481
diff --git a/src/dispnew.c b/src/dispnew.c
index 31b8a1310ea..1eb097f05ab 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -213,6 +213,7 @@ static void
213add_window_display_history (struct window *w, const char *msg, bool paused_p) 213add_window_display_history (struct window *w, const char *msg, bool paused_p)
214{ 214{
215 char *buf; 215 char *buf;
216 void *ptr = w;
216 217
217 if (history_idx >= REDISPLAY_HISTORY_SIZE) 218 if (history_idx >= REDISPLAY_HISTORY_SIZE)
218 history_idx = 0; 219 history_idx = 0;
@@ -222,7 +223,7 @@ add_window_display_history (struct window *w, const char *msg, bool paused_p)
222 snprintf (buf, sizeof redisplay_history[0].trace, 223 snprintf (buf, sizeof redisplay_history[0].trace,
223 "%"pMu": window %p (`%s')%s\n%s", 224 "%"pMu": window %p (`%s')%s\n%s",
224 history_tick++, 225 history_tick++,
225 w, 226 ptr,
226 ((BUFFERP (w->contents) 227 ((BUFFERP (w->contents)
227 && STRINGP (BVAR (XBUFFER (w->contents), name))) 228 && STRINGP (BVAR (XBUFFER (w->contents), name)))
228 ? SSDATA (BVAR (XBUFFER (w->contents), name)) 229 ? SSDATA (BVAR (XBUFFER (w->contents), name))
@@ -240,6 +241,7 @@ static void
240add_frame_display_history (struct frame *f, bool paused_p) 241add_frame_display_history (struct frame *f, bool paused_p)
241{ 242{
242 char *buf; 243 char *buf;
244 void *ptr = f;
243 245
244 if (history_idx >= REDISPLAY_HISTORY_SIZE) 246 if (history_idx >= REDISPLAY_HISTORY_SIZE)
245 history_idx = 0; 247 history_idx = 0;
@@ -248,7 +250,7 @@ add_frame_display_history (struct frame *f, bool paused_p)
248 250
249 sprintf (buf, "%"pMu": update frame %p%s", 251 sprintf (buf, "%"pMu": update frame %p%s",
250 history_tick++, 252 history_tick++,
251 f, paused_p ? " ***paused***" : ""); 253 ptr, paused_p ? " ***paused***" : "");
252} 254}
253 255
254 256
diff --git a/src/emacs.c b/src/emacs.c
index ec17322f57a..274321482e1 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -28,12 +28,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
28#include <unistd.h> 28#include <unistd.h>
29 29
30#include <close-stream.h> 30#include <close-stream.h>
31#include <ignore-value.h>
32 31
33#include "lisp.h" 32#include "lisp.h"
34 33
35#ifdef WINDOWSNT 34#ifdef WINDOWSNT
36#include <fcntl.h> 35#include <fcntl.h>
36#include <sys/socket.h>
37#include "w32.h" 37#include "w32.h"
38#include "w32heap.h" 38#include "w32heap.h"
39#endif 39#endif
@@ -197,10 +197,10 @@ int initial_argc;
197static void sort_args (int argc, char **argv); 197static void sort_args (int argc, char **argv);
198static void syms_of_emacs (void); 198static void syms_of_emacs (void);
199 199
200/* MSVC needs each string be shorter than 2048 bytes, so the usage 200/* C89 needs each string be at most 509 characters, so the usage
201 strings below are split to not overflow this limit. */ 201 strings below are split to not overflow this limit. */
202#define USAGE1 "\ 202static char const *const usage_message[] =
203Usage: %s [OPTION-OR-FILENAME]...\n\ 203 { "\
204\n\ 204\n\
205Run Emacs, the extensible, customizable, self-documenting real-time\n\ 205Run Emacs, the extensible, customizable, self-documenting real-time\n\
206display editor. The recommended way to start Emacs for normal editing\n\ 206display editor. The recommended way to start Emacs for normal editing\n\
@@ -211,11 +211,15 @@ read the main documentation for these command-line arguments.\n\
211\n\ 211\n\
212Initialization options:\n\ 212Initialization options:\n\
213\n\ 213\n\
214",
215 "\
214--batch do not do interactive display; implies -q\n\ 216--batch do not do interactive display; implies -q\n\
215--chdir DIR change to directory DIR\n\ 217--chdir DIR change to directory DIR\n\
216--daemon start a server in the background\n\ 218--daemon start a server in the background\n\
217--debug-init enable Emacs Lisp debugger for init file\n\ 219--debug-init enable Emacs Lisp debugger for init file\n\
218--display, -d DISPLAY use X server DISPLAY\n\ 220--display, -d DISPLAY use X server DISPLAY\n\
221",
222 "\
219--no-desktop do not load a saved desktop\n\ 223--no-desktop do not load a saved desktop\n\
220--no-init-file, -q load neither ~/.emacs nor default.el\n\ 224--no-init-file, -q load neither ~/.emacs nor default.el\n\
221--no-shared-memory, -nl do not use shared memory\n\ 225--no-shared-memory, -nl do not use shared memory\n\
@@ -223,14 +227,16 @@ Initialization options:\n\
223--no-site-lisp, -nsl do not add site-lisp directories to load-path\n\ 227--no-site-lisp, -nsl do not add site-lisp directories to load-path\n\
224--no-splash do not display a splash screen on startup\n\ 228--no-splash do not display a splash screen on startup\n\
225--no-window-system, -nw do not communicate with X, ignoring $DISPLAY\n\ 229--no-window-system, -nw do not communicate with X, ignoring $DISPLAY\n\
230",
231 "\
226--quick, -Q equivalent to:\n\ 232--quick, -Q equivalent to:\n\
227 -q --no-site-file --no-site-lisp --no-splash\n\ 233 -q --no-site-file --no-site-lisp --no-splash\n\
228--script FILE run FILE as an Emacs Lisp script\n\ 234--script FILE run FILE as an Emacs Lisp script\n\
229--terminal, -t DEVICE use DEVICE for terminal I/O\n\ 235--terminal, -t DEVICE use DEVICE for terminal I/O\n\
230--user, -u USER load ~USER/.emacs instead of your own\n\ 236--user, -u USER load ~USER/.emacs instead of your own\n\
231\n%s" 237\n\
232 238",
233#define USAGE2 "\ 239 "\
234Action options:\n\ 240Action options:\n\
235\n\ 241\n\
236FILE visit FILE using find-file\n\ 242FILE visit FILE using find-file\n\
@@ -239,6 +245,8 @@ FILE visit FILE using find-file\n\
239--directory, -L DIR add DIR to variable load-path\n\ 245--directory, -L DIR add DIR to variable load-path\n\
240--eval EXPR evaluate Emacs Lisp expression EXPR\n\ 246--eval EXPR evaluate Emacs Lisp expression EXPR\n\
241--execute EXPR evaluate Emacs Lisp expression EXPR\n\ 247--execute EXPR evaluate Emacs Lisp expression EXPR\n\
248",
249 "\
242--file FILE visit FILE using find-file\n\ 250--file FILE visit FILE using find-file\n\
243--find-file FILE visit FILE using find-file\n\ 251--find-file FILE visit FILE using find-file\n\
244--funcall, -f FUNC call Emacs Lisp function FUNC with no arguments\n\ 252--funcall, -f FUNC call Emacs Lisp function FUNC with no arguments\n\
@@ -246,9 +254,9 @@ FILE visit FILE using find-file\n\
246--kill exit without asking for confirmation\n\ 254--kill exit without asking for confirmation\n\
247--load, -l FILE load Emacs Lisp FILE using the load function\n\ 255--load, -l FILE load Emacs Lisp FILE using the load function\n\
248--visit FILE visit FILE using find-file\n\ 256--visit FILE visit FILE using find-file\n\
249\n" 257\n\
250 258",
251#define USAGE3 "\ 259 "\
252Display options:\n\ 260Display options:\n\
253\n\ 261\n\
254--background-color, -bg COLOR window background color\n\ 262--background-color, -bg COLOR window background color\n\
@@ -256,6 +264,8 @@ Display options:\n\
256 used for debugging Emacs\n\ 264 used for debugging Emacs\n\
257--border-color, -bd COLOR main border color\n\ 265--border-color, -bd COLOR main border color\n\
258--border-width, -bw WIDTH width of main border\n\ 266--border-width, -bw WIDTH width of main border\n\
267",
268 "\
259--color, --color=MODE override color mode for character terminals;\n\ 269--color, --color=MODE override color mode for character terminals;\n\
260 MODE defaults to `auto', and\n\ 270 MODE defaults to `auto', and\n\
261 can also be `never', `always',\n\ 271 can also be `never', `always',\n\
@@ -263,17 +273,23 @@ Display options:\n\
263--cursor-color, -cr COLOR color of the Emacs cursor indicating point\n\ 273--cursor-color, -cr COLOR color of the Emacs cursor indicating point\n\
264--font, -fn FONT default font; must be fixed-width\n\ 274--font, -fn FONT default font; must be fixed-width\n\
265--foreground-color, -fg COLOR window foreground color\n\ 275--foreground-color, -fg COLOR window foreground color\n\
276",
277 "\
266--fullheight, -fh make the first frame high as the screen\n\ 278--fullheight, -fh make the first frame high as the screen\n\
267--fullscreen, -fs make the first frame fullscreen\n\ 279--fullscreen, -fs make the first frame fullscreen\n\
268--fullwidth, -fw make the first frame wide as the screen\n\ 280--fullwidth, -fw make the first frame wide as the screen\n\
269--maximized, -mm make the first frame maximized\n\ 281--maximized, -mm make the first frame maximized\n\
270--geometry, -g GEOMETRY window geometry\n\ 282--geometry, -g GEOMETRY window geometry\n\
283",
284 "\
271--no-bitmap-icon, -nbi do not use picture of gnu for Emacs icon\n\ 285--no-bitmap-icon, -nbi do not use picture of gnu for Emacs icon\n\
272--iconic start Emacs in iconified state\n\ 286--iconic start Emacs in iconified state\n\
273--internal-border, -ib WIDTH width between text and main border\n\ 287--internal-border, -ib WIDTH width between text and main border\n\
274--line-spacing, -lsp PIXELS additional space to put between lines\n\ 288--line-spacing, -lsp PIXELS additional space to put between lines\n\
275--mouse-color, -ms COLOR mouse cursor color in Emacs window\n\ 289--mouse-color, -ms COLOR mouse cursor color in Emacs window\n\
276--name NAME title for initial Emacs frame\n\ 290--name NAME title for initial Emacs frame\n\
291",
292 "\
277--no-blinking-cursor, -nbc disable blinking cursor\n\ 293--no-blinking-cursor, -nbc disable blinking cursor\n\
278--reverse-video, -r, -rv switch foreground and background\n\ 294--reverse-video, -r, -rv switch foreground and background\n\
279--title, -T TITLE title for initial Emacs frame\n\ 295--title, -T TITLE title for initial Emacs frame\n\
@@ -282,9 +298,9 @@ Display options:\n\
282--parent-id XID set parent window\n\ 298--parent-id XID set parent window\n\
283--help display this help and exit\n\ 299--help display this help and exit\n\
284--version output version information and exit\n\ 300--version output version information and exit\n\
285\n" 301\n\
286 302",
287#define USAGE4 "\ 303 "\
288You can generally also specify long option names with a single -; for\n\ 304You can generally also specify long option names with a single -; for\n\
289example, -batch as well as --batch. You can use any unambiguous\n\ 305example, -batch as well as --batch. You can use any unambiguous\n\
290abbreviation for a --option.\n\ 306abbreviation for a --option.\n\
@@ -294,6 +310,7 @@ Emacs' operation. See the main documentation.\n\
294\n\ 310\n\
295Report bugs to bug-gnu-emacs@gnu.org. First, please see the Bugs\n\ 311Report bugs to bug-gnu-emacs@gnu.org. First, please see the Bugs\n\
296section of the Emacs manual or the file BUGS.\n" 312section of the Emacs manual or the file BUGS.\n"
313 };
297 314
298 315
299/* True if handling a fatal error already. */ 316/* True if handling a fatal error already. */
@@ -641,9 +658,7 @@ close_output_streams (void)
641{ 658{
642 if (close_stream (stdout) != 0) 659 if (close_stream (stdout) != 0)
643 { 660 {
644 fprintf (stderr, "Write error to standard output: %s\n", 661 emacs_perror ("Write error to standard output");
645 strerror (errno));
646 fflush (stderr);
647 _exit (EXIT_FAILURE); 662 _exit (EXIT_FAILURE);
648 } 663 }
649 664
@@ -780,7 +795,7 @@ main (int argc, char **argv)
780 execvp (argv[0], argv); 795 execvp (argv[0], argv);
781 796
782 /* If the exec fails, try to dump anyway. */ 797 /* If the exec fails, try to dump anyway. */
783 perror ("execvp"); 798 emacs_perror (argv[0]);
784 } 799 }
785#endif /* HAVE_PERSONALITY_LINUX32 */ 800#endif /* HAVE_PERSONALITY_LINUX32 */
786 801
@@ -878,7 +893,7 @@ main (int argc, char **argv)
878 emacs_close (0); 893 emacs_close (0);
879 emacs_close (1); 894 emacs_close (1);
880 result = emacs_open (term, O_RDWR, 0); 895 result = emacs_open (term, O_RDWR, 0);
881 if (result < 0 || dup (0) < 0) 896 if (result < 0 || fcntl (0, F_DUPFD_CLOEXEC, 1) < 0)
882 { 897 {
883 char *errstring = strerror (errno); 898 char *errstring = strerror (errno);
884 fprintf (stderr, "%s: %s: %s\n", argv[0], term, errstring); 899 fprintf (stderr, "%s: %s: %s\n", argv[0], term, errstring);
@@ -925,9 +940,10 @@ main (int argc, char **argv)
925 /* Handle the --help option, which gives a usage message. */ 940 /* Handle the --help option, which gives a usage message. */
926 if (argmatch (argv, argc, "-help", "--help", 3, NULL, &skip_args)) 941 if (argmatch (argv, argc, "-help", "--help", 3, NULL, &skip_args))
927 { 942 {
928 printf (USAGE1, argv[0], USAGE2); 943 int i;
929 printf (USAGE3); 944 printf ("Usage: %s [OPTION-OR-FILENAME]...\n", argv[0]);
930 printf (USAGE4); 945 for (i = 0; i < sizeof usage_message / sizeof *usage_message; i++)
946 fputs (usage_message[i], stdout);
931 exit (0); 947 exit (0);
932 } 948 }
933 949
@@ -958,7 +974,7 @@ main (int argc, char **argv)
958 use a pipe for synchronization. The parent waits for the child 974 use a pipe for synchronization. The parent waits for the child
959 to close its end of the pipe (using `daemon-initialized') 975 to close its end of the pipe (using `daemon-initialized')
960 before exiting. */ 976 before exiting. */
961 if (pipe (daemon_pipe) == -1) 977 if (pipe2 (daemon_pipe, O_CLOEXEC) != 0)
962 { 978 {
963 fprintf (stderr, "Cannot pipe!\n"); 979 fprintf (stderr, "Cannot pipe!\n");
964 exit (1); 980 exit (1);
@@ -983,7 +999,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
983 char buf[1]; 999 char buf[1];
984 1000
985 /* Close unused writing end of the pipe. */ 1001 /* Close unused writing end of the pipe. */
986 close (daemon_pipe[1]); 1002 emacs_close (daemon_pipe[1]);
987 1003
988 /* Just wait for the child to close its end of the pipe. */ 1004 /* Just wait for the child to close its end of the pipe. */
989 do 1005 do
@@ -1003,13 +1019,13 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1003 exit (1); 1019 exit (1);
1004 } 1020 }
1005 1021
1006 close (daemon_pipe[0]); 1022 emacs_close (daemon_pipe[0]);
1007 exit (0); 1023 exit (0);
1008 } 1024 }
1009 if (f < 0) 1025 if (f < 0)
1010 { 1026 {
1011 fprintf (stderr, "Cannot fork!\n"); 1027 emacs_perror ("fork");
1012 exit (1); 1028 exit (EXIT_CANCELED);
1013 } 1029 }
1014 1030
1015#ifdef DAEMON_MUST_EXEC 1031#ifdef DAEMON_MUST_EXEC
@@ -1026,14 +1042,14 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1026 if (! (0 <= fdStrlen && fdStrlen < sizeof fdStr)) 1042 if (! (0 <= fdStrlen && fdStrlen < sizeof fdStr))
1027 { 1043 {
1028 fprintf (stderr, "daemon: child name too long\n"); 1044 fprintf (stderr, "daemon: child name too long\n");
1029 exit (1); 1045 exit (EXIT_CANNOT_INVOKE);
1030 } 1046 }
1031 1047
1032 argv[skip_args] = fdStr; 1048 argv[skip_args] = fdStr;
1033 1049
1034 execvp (argv[0], argv); 1050 execvp (argv[0], argv);
1035 fprintf (stderr, "emacs daemon: exec failed: %d\n", errno); 1051 emacs_perror (argv[0]);
1036 exit (1); 1052 exit (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
1037 } 1053 }
1038 1054
1039 /* In exec'd: parse special dname into pipe and name info. */ 1055 /* In exec'd: parse special dname into pipe and name info. */
@@ -1041,7 +1057,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1041 || strlen (dname_arg) < 1 || strlen (dname_arg) > 70) 1057 || strlen (dname_arg) < 1 || strlen (dname_arg) > 70)
1042 { 1058 {
1043 fprintf (stderr, "emacs daemon: daemon name absent or too long\n"); 1059 fprintf (stderr, "emacs daemon: daemon name absent or too long\n");
1044 exit (1); 1060 exit (EXIT_CANNOT_INVOKE);
1045 } 1061 }
1046 dname_arg2[0] = '\0'; 1062 dname_arg2[0] = '\0';
1047 sscanf (dname_arg, "\n%d,%d\n%s", &(daemon_pipe[0]), &(daemon_pipe[1]), 1063 sscanf (dname_arg, "\n%d,%d\n%s", &(daemon_pipe[0]), &(daemon_pipe[1]),
@@ -1053,10 +1069,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1053 if (dname_arg) 1069 if (dname_arg)
1054 daemon_name = xstrdup (dname_arg); 1070 daemon_name = xstrdup (dname_arg);
1055 /* Close unused reading end of the pipe. */ 1071 /* Close unused reading end of the pipe. */
1056 close (daemon_pipe[0]); 1072 emacs_close (daemon_pipe[0]);
1057 /* Make sure that the used end of the pipe is closed on exec, so
1058 that it is not accessible to programs started from .emacs. */
1059 fcntl (daemon_pipe[1], F_SETFD, FD_CLOEXEC);
1060 1073
1061 setsid (); 1074 setsid ();
1062#else /* DOS_NT */ 1075#else /* DOS_NT */
@@ -1910,8 +1923,8 @@ shut_down_emacs (int sig, Lisp_Object stuff)
1910 char buf[sizeof format - 2 + INT_STRLEN_BOUND (int)]; 1923 char buf[sizeof format - 2 + INT_STRLEN_BOUND (int)];
1911 int buflen = sprintf (buf, format, sig); 1924 int buflen = sprintf (buf, format, sig);
1912 char const *sig_desc = safe_strsignal (sig); 1925 char const *sig_desc = safe_strsignal (sig);
1913 ignore_value (write (STDERR_FILENO, buf, buflen)); 1926 emacs_write (STDERR_FILENO, buf, buflen);
1914 ignore_value (write (STDERR_FILENO, sig_desc, strlen (sig_desc))); 1927 emacs_write (STDERR_FILENO, sig_desc, strlen (sig_desc));
1915 } 1928 }
1916 } 1929 }
1917 } 1930 }
@@ -2233,7 +2246,7 @@ from the parent process and its tty file descriptors. */)
2233 err |= dup2 (nfd, 0) < 0; 2246 err |= dup2 (nfd, 0) < 0;
2234 err |= dup2 (nfd, 1) < 0; 2247 err |= dup2 (nfd, 1) < 0;
2235 err |= dup2 (nfd, 2) < 0; 2248 err |= dup2 (nfd, 2) < 0;
2236 err |= close (nfd) != 0; 2249 err |= emacs_close (nfd) != 0;
2237 2250
2238 /* Closing the pipe will notify the parent that it can exit. 2251 /* Closing the pipe will notify the parent that it can exit.
2239 FIXME: In case some other process inherited the pipe, closing it here 2252 FIXME: In case some other process inherited the pipe, closing it here
@@ -2243,7 +2256,7 @@ from the parent process and its tty file descriptors. */)
2243 call-process to make sure the pipe is never inherited by 2256 call-process to make sure the pipe is never inherited by
2244 subprocesses. */ 2257 subprocesses. */
2245 err |= write (daemon_pipe[1], "\n", 1) < 0; 2258 err |= write (daemon_pipe[1], "\n", 1) < 0;
2246 err |= close (daemon_pipe[1]) != 0; 2259 err |= emacs_close (daemon_pipe[1]) != 0;
2247 /* Set it to an invalid value so we know we've already run this function. */ 2260 /* Set it to an invalid value so we know we've already run this function. */
2248 daemon_pipe[1] = -1; 2261 daemon_pipe[1] = -1;
2249 2262
diff --git a/src/eval.c b/src/eval.c
index 451a7b0cc28..97e812dd890 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -114,6 +114,13 @@ Lisp_Object Vsignaling_function;
114 frame is half-initialized. */ 114 frame is half-initialized. */
115Lisp_Object inhibit_lisp_code; 115Lisp_Object inhibit_lisp_code;
116 116
117/* These would ordinarily be static, but they need to be visible to GDB. */
118bool backtrace_p (union specbinding *) EXTERNALLY_VISIBLE;
119Lisp_Object *backtrace_args (union specbinding *) EXTERNALLY_VISIBLE;
120Lisp_Object backtrace_function (union specbinding *) EXTERNALLY_VISIBLE;
121union specbinding *backtrace_next (union specbinding *) EXTERNALLY_VISIBLE;
122union specbinding *backtrace_top (void) EXTERNALLY_VISIBLE;
123
117static Lisp_Object funcall_lambda (Lisp_Object, ptrdiff_t, Lisp_Object *); 124static Lisp_Object funcall_lambda (Lisp_Object, ptrdiff_t, Lisp_Object *);
118static Lisp_Object apply_lambda (Lisp_Object fun, Lisp_Object args); 125static Lisp_Object apply_lambda (Lisp_Object fun, Lisp_Object args);
119 126
@@ -159,7 +166,7 @@ specpdl_func (union specbinding *pdl)
159 return pdl->unwind.func; 166 return pdl->unwind.func;
160} 167}
161 168
162static Lisp_Object 169Lisp_Object
163backtrace_function (union specbinding *pdl) 170backtrace_function (union specbinding *pdl)
164{ 171{
165 eassert (pdl->kind == SPECPDL_BACKTRACE); 172 eassert (pdl->kind == SPECPDL_BACKTRACE);
@@ -173,7 +180,7 @@ backtrace_nargs (union specbinding *pdl)
173 return pdl->bt.nargs; 180 return pdl->bt.nargs;
174} 181}
175 182
176static Lisp_Object * 183Lisp_Object *
177backtrace_args (union specbinding *pdl) 184backtrace_args (union specbinding *pdl)
178{ 185{
179 eassert (pdl->kind == SPECPDL_BACKTRACE); 186 eassert (pdl->kind == SPECPDL_BACKTRACE);
@@ -212,10 +219,6 @@ set_backtrace_debug_on_exit (union specbinding *pdl, bool doe)
212 219
213/* Helper functions to scan the backtrace. */ 220/* Helper functions to scan the backtrace. */
214 221
215bool backtrace_p (union specbinding *) EXTERNALLY_VISIBLE;
216union specbinding *backtrace_top (void) EXTERNALLY_VISIBLE;
217union specbinding *backtrace_next (union specbinding *pdl) EXTERNALLY_VISIBLE;
218
219bool 222bool
220backtrace_p (union specbinding *pdl) 223backtrace_p (union specbinding *pdl)
221{ return pdl >= specpdl; } 224{ return pdl >= specpdl; }
@@ -2013,38 +2016,52 @@ If LEXICAL is t, evaluate using lexical scoping. */)
2013 return unbind_to (count, eval_sub (form)); 2016 return unbind_to (count, eval_sub (form));
2014} 2017}
2015 2018
2019/* Grow the specpdl stack by one entry.
2020 The caller should have already initialized the entry.
2021 Signal an error on stack overflow.
2022
2023 Make sure that there is always one unused entry past the top of the
2024 stack, so that the just-initialized entry is safely unwound if
2025 memory exhausted and an error is signaled here. Also, allocate a
2026 never-used entry just before the bottom of the stack; sometimes its
2027 address is taken. */
2028
2016static void 2029static void
2017grow_specpdl (void) 2030grow_specpdl (void)
2018{ 2031{
2019 ptrdiff_t count = SPECPDL_INDEX (); 2032 specpdl_ptr++;
2020 ptrdiff_t max_size = min (max_specpdl_size, PTRDIFF_MAX - 1000); 2033
2021 union specbinding *pdlvec = specpdl - 1; 2034 if (specpdl_ptr == specpdl + specpdl_size)
2022 ptrdiff_t pdlvecsize = specpdl_size + 1;
2023 if (max_size <= specpdl_size)
2024 { 2035 {
2025 if (max_specpdl_size < 400) 2036 ptrdiff_t count = SPECPDL_INDEX ();
2026 max_size = max_specpdl_size = 400; 2037 ptrdiff_t max_size = min (max_specpdl_size, PTRDIFF_MAX - 1000);
2038 union specbinding *pdlvec = specpdl - 1;
2039 ptrdiff_t pdlvecsize = specpdl_size + 1;
2027 if (max_size <= specpdl_size) 2040 if (max_size <= specpdl_size)
2028 signal_error ("Variable binding depth exceeds max-specpdl-size", Qnil); 2041 {
2042 if (max_specpdl_size < 400)
2043 max_size = max_specpdl_size = 400;
2044 if (max_size <= specpdl_size)
2045 signal_error ("Variable binding depth exceeds max-specpdl-size",
2046 Qnil);
2047 }
2048 pdlvec = xpalloc (pdlvec, &pdlvecsize, 1, max_size + 1, sizeof *specpdl);
2049 specpdl = pdlvec + 1;
2050 specpdl_size = pdlvecsize - 1;
2051 specpdl_ptr = specpdl + count;
2029 } 2052 }
2030 pdlvec = xpalloc (pdlvec, &pdlvecsize, 1, max_size + 1, sizeof *specpdl);
2031 specpdl = pdlvec + 1;
2032 specpdl_size = pdlvecsize - 1;
2033 specpdl_ptr = specpdl + count;
2034} 2053}
2035 2054
2036void 2055void
2037record_in_backtrace (Lisp_Object function, Lisp_Object *args, ptrdiff_t nargs) 2056record_in_backtrace (Lisp_Object function, Lisp_Object *args, ptrdiff_t nargs)
2038{ 2057{
2039 eassert (nargs >= UNEVALLED); 2058 eassert (nargs >= UNEVALLED);
2040 if (specpdl_ptr == specpdl + specpdl_size)
2041 grow_specpdl ();
2042 specpdl_ptr->bt.kind = SPECPDL_BACKTRACE; 2059 specpdl_ptr->bt.kind = SPECPDL_BACKTRACE;
2043 specpdl_ptr->bt.debug_on_exit = false; 2060 specpdl_ptr->bt.debug_on_exit = false;
2044 specpdl_ptr->bt.function = function; 2061 specpdl_ptr->bt.function = function;
2045 specpdl_ptr->bt.args = args; 2062 specpdl_ptr->bt.args = args;
2046 specpdl_ptr->bt.nargs = nargs; 2063 specpdl_ptr->bt.nargs = nargs;
2047 specpdl_ptr++; 2064 grow_specpdl ();
2048} 2065}
2049 2066
2050/* Eval a sub-expression of the current expression (i.e. in the same 2067/* Eval a sub-expression of the current expression (i.e. in the same
@@ -3176,8 +3193,6 @@ specbind (Lisp_Object symbol, Lisp_Object value)
3176 3193
3177 CHECK_SYMBOL (symbol); 3194 CHECK_SYMBOL (symbol);
3178 sym = XSYMBOL (symbol); 3195 sym = XSYMBOL (symbol);
3179 if (specpdl_ptr == specpdl + specpdl_size)
3180 grow_specpdl ();
3181 3196
3182 start: 3197 start:
3183 switch (sym->redirect) 3198 switch (sym->redirect)
@@ -3191,7 +3206,7 @@ specbind (Lisp_Object symbol, Lisp_Object value)
3191 specpdl_ptr->let.symbol = symbol; 3206 specpdl_ptr->let.symbol = symbol;
3192 specpdl_ptr->let.old_value = SYMBOL_VAL (sym); 3207 specpdl_ptr->let.old_value = SYMBOL_VAL (sym);
3193 specpdl_ptr->let.saved_value = Qnil; 3208 specpdl_ptr->let.saved_value = Qnil;
3194 ++specpdl_ptr; 3209 grow_specpdl ();
3195 do_specbind (sym, specpdl_ptr - 1, value); 3210 do_specbind (sym, specpdl_ptr - 1, value);
3196 break; 3211 break;
3197 case SYMBOL_LOCALIZED: 3212 case SYMBOL_LOCALIZED:
@@ -3224,7 +3239,7 @@ specbind (Lisp_Object symbol, Lisp_Object value)
3224 if (NILP (Flocal_variable_p (symbol, Qnil))) 3239 if (NILP (Flocal_variable_p (symbol, Qnil)))
3225 { 3240 {
3226 specpdl_ptr->let.kind = SPECPDL_LET_DEFAULT; 3241 specpdl_ptr->let.kind = SPECPDL_LET_DEFAULT;
3227 ++specpdl_ptr; 3242 grow_specpdl ();
3228 do_specbind (sym, specpdl_ptr - 1, value); 3243 do_specbind (sym, specpdl_ptr - 1, value);
3229 return; 3244 return;
3230 } 3245 }
@@ -3232,7 +3247,7 @@ specbind (Lisp_Object symbol, Lisp_Object value)
3232 else 3247 else
3233 specpdl_ptr->let.kind = SPECPDL_LET; 3248 specpdl_ptr->let.kind = SPECPDL_LET;
3234 3249
3235 specpdl_ptr++; 3250 grow_specpdl ();
3236 do_specbind (sym, specpdl_ptr - 1, value); 3251 do_specbind (sym, specpdl_ptr - 1, value);
3237 break; 3252 break;
3238 } 3253 }
@@ -3243,12 +3258,10 @@ specbind (Lisp_Object symbol, Lisp_Object value)
3243void 3258void
3244record_unwind_protect (Lisp_Object (*function) (Lisp_Object), Lisp_Object arg) 3259record_unwind_protect (Lisp_Object (*function) (Lisp_Object), Lisp_Object arg)
3245{ 3260{
3246 if (specpdl_ptr == specpdl + specpdl_size)
3247 grow_specpdl ();
3248 specpdl_ptr->unwind.kind = SPECPDL_UNWIND; 3261 specpdl_ptr->unwind.kind = SPECPDL_UNWIND;
3249 specpdl_ptr->unwind.func = function; 3262 specpdl_ptr->unwind.func = function;
3250 specpdl_ptr->unwind.arg = arg; 3263 specpdl_ptr->unwind.arg = arg;
3251 specpdl_ptr++; 3264 grow_specpdl ();
3252} 3265}
3253 3266
3254void 3267void
diff --git a/src/fileio.c b/src/fileio.c
index 89ae89e1613..c3566390130 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -159,11 +159,13 @@ static bool e_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t,
159 struct coding_system *); 159 struct coding_system *);
160 160
161 161
162/* Signal a file-access failure. STRING describes the failure,
163 DATA the file that was involved, and ERRORNO the errno value. */
164
162void 165void
163report_file_error (const char *string, Lisp_Object data) 166report_file_errno (char const *string, Lisp_Object data, int errorno)
164{ 167{
165 Lisp_Object errstring; 168 Lisp_Object errstring;
166 int errorno = errno;
167 char *str; 169 char *str;
168 170
169 synchronize_system_messages_locale (); 171 synchronize_system_messages_locale ();
@@ -196,6 +198,12 @@ report_file_error (const char *string, Lisp_Object data)
196 } 198 }
197} 199}
198 200
201void
202report_file_error (char const *string, Lisp_Object data)
203{
204 report_file_errno (string, data, errno);
205}
206
199Lisp_Object 207Lisp_Object
200close_file_unwind (Lisp_Object fd) 208close_file_unwind (Lisp_Object fd)
201{ 209{
@@ -2019,11 +2027,8 @@ entries (depending on how Emacs was built). */)
2019 { 2027 {
2020 /* CopyFile doesn't set errno when it fails. By far the most 2028 /* CopyFile doesn't set errno when it fails. By far the most
2021 "popular" reason is that the target is read-only. */ 2029 "popular" reason is that the target is read-only. */
2022 if (GetLastError () == 5) 2030 report_file_errno ("Copying file", Fcons (file, Fcons (newname, Qnil)),
2023 errno = EACCES; 2031 GetLastError () == 5 ? EACCES : EPERM);
2024 else
2025 errno = EPERM;
2026 report_file_error ("Copying file", Fcons (file, Fcons (newname, Qnil)));
2027 } 2032 }
2028 /* CopyFile retains the timestamp by default. */ 2033 /* CopyFile retains the timestamp by default. */
2029 else if (NILP (keep_time)) 2034 else if (NILP (keep_time))
@@ -2084,36 +2089,25 @@ entries (depending on how Emacs was built). */)
2084 2089
2085 if (out_st.st_mode != 0 2090 if (out_st.st_mode != 0
2086 && st.st_dev == out_st.st_dev && st.st_ino == out_st.st_ino) 2091 && st.st_dev == out_st.st_dev && st.st_ino == out_st.st_ino)
2087 { 2092 report_file_errno ("Input and output files are the same",
2088 errno = 0; 2093 Fcons (file, Fcons (newname, Qnil)), 0);
2089 report_file_error ("Input and output files are the same",
2090 Fcons (file, Fcons (newname, Qnil)));
2091 }
2092 2094
2093 /* We can copy only regular files. */ 2095 /* We can copy only regular files. */
2094 if (!S_ISREG (st.st_mode)) 2096 if (!S_ISREG (st.st_mode))
2095 { 2097 report_file_errno ("Non-regular file", Fcons (file, Qnil),
2096 /* Get a better looking error message. */ 2098 S_ISDIR (st.st_mode) ? EISDIR : EINVAL);
2097 errno = S_ISDIR (st.st_mode) ? EISDIR : EINVAL;
2098 report_file_error ("Non-regular file", Fcons (file, Qnil));
2099 }
2100 2099
2101#ifdef MSDOS
2102 /* System's default file type was set to binary by _fmode in emacs.c. */
2103 ofd = emacs_open (SDATA (encoded_newname),
2104 O_WRONLY | O_TRUNC | O_CREAT
2105 | (NILP (ok_if_already_exists) ? O_EXCL : 0),
2106 S_IREAD | S_IWRITE);
2107#else /* not MSDOS */
2108 { 2100 {
2109 mode_t new_mask = !NILP (preserve_uid_gid) ? 0600 : 0666; 2101#ifndef MSDOS
2110 new_mask &= st.st_mode; 2102 int new_mask = st.st_mode & (!NILP (preserve_uid_gid) ? 0600 : 0666);
2103#else
2104 int new_mask = S_IREAD | S_IWRITE;
2105#endif
2111 ofd = emacs_open (SSDATA (encoded_newname), 2106 ofd = emacs_open (SSDATA (encoded_newname),
2112 (O_WRONLY | O_TRUNC | O_CREAT 2107 (O_WRONLY | O_TRUNC | O_CREAT
2113 | (NILP (ok_if_already_exists) ? O_EXCL : 0)), 2108 | (NILP (ok_if_already_exists) ? O_EXCL : 0)),
2114 new_mask); 2109 new_mask);
2115 } 2110 }
2116#endif /* not MSDOS */
2117 if (ofd < 0) 2111 if (ofd < 0)
2118 report_file_error ("Opening output file", Fcons (newname, Qnil)); 2112 report_file_error ("Opening output file", Fcons (newname, Qnil));
2119 2113
@@ -2122,7 +2116,7 @@ entries (depending on how Emacs was built). */)
2122 immediate_quit = 1; 2116 immediate_quit = 1;
2123 QUIT; 2117 QUIT;
2124 while ((n = emacs_read (ifd, buf, sizeof buf)) > 0) 2118 while ((n = emacs_read (ifd, buf, sizeof buf)) > 0)
2125 if (emacs_write (ofd, buf, n) != n) 2119 if (emacs_write_sig (ofd, buf, n) != n)
2126 report_file_error ("I/O error", Fcons (newname, Qnil)); 2120 report_file_error ("I/O error", Fcons (newname, Qnil));
2127 immediate_quit = 0; 2121 immediate_quit = 0;
2128 2122
@@ -2609,7 +2603,11 @@ Use `file-symlink-p' to test for such links. */)
2609 call the corresponding file handler. */ 2603 call the corresponding file handler. */
2610 handler = Ffind_file_name_handler (absname, Qfile_exists_p); 2604 handler = Ffind_file_name_handler (absname, Qfile_exists_p);
2611 if (!NILP (handler)) 2605 if (!NILP (handler))
2612 return call2 (handler, Qfile_exists_p, absname); 2606 {
2607 Lisp_Object result = call2 (handler, Qfile_exists_p, absname);
2608 errno = 0;
2609 return result;
2610 }
2613 2611
2614 absname = ENCODE_FILE (absname); 2612 absname = ENCODE_FILE (absname);
2615 2613
@@ -2706,7 +2704,6 @@ If there is no error, returns nil. */)
2706 (Lisp_Object filename, Lisp_Object string) 2704 (Lisp_Object filename, Lisp_Object string)
2707{ 2705{
2708 Lisp_Object handler, encoded_filename, absname; 2706 Lisp_Object handler, encoded_filename, absname;
2709 int fd;
2710 2707
2711 CHECK_STRING (filename); 2708 CHECK_STRING (filename);
2712 absname = Fexpand_file_name (filename, Qnil); 2709 absname = Fexpand_file_name (filename, Qnil);
@@ -2721,10 +2718,8 @@ If there is no error, returns nil. */)
2721 2718
2722 encoded_filename = ENCODE_FILE (absname); 2719 encoded_filename = ENCODE_FILE (absname);
2723 2720
2724 fd = emacs_open (SSDATA (encoded_filename), O_RDONLY, 0); 2721 if (faccessat (AT_FDCWD, SSDATA (encoded_filename), R_OK, AT_EACCESS) != 0)
2725 if (fd < 0)
2726 report_file_error (SSDATA (string), Fcons (filename, Qnil)); 2722 report_file_error (SSDATA (string), Fcons (filename, Qnil));
2727 emacs_close (fd);
2728 2723
2729 return Qnil; 2724 return Qnil;
2730} 2725}
@@ -2833,7 +2828,11 @@ searchable directory. */)
2833 call the corresponding file handler. */ 2828 call the corresponding file handler. */
2834 handler = Ffind_file_name_handler (absname, Qfile_accessible_directory_p); 2829 handler = Ffind_file_name_handler (absname, Qfile_accessible_directory_p);
2835 if (!NILP (handler)) 2830 if (!NILP (handler))
2836 return call2 (handler, Qfile_accessible_directory_p, absname); 2831 {
2832 Lisp_Object r = call2 (handler, Qfile_accessible_directory_p, absname);
2833 errno = 0;
2834 return r;
2835 }
2837 2836
2838 absname = ENCODE_FILE (absname); 2837 absname = ENCODE_FILE (absname);
2839 return file_accessible_directory_p (SSDATA (absname)) ? Qt : Qnil; 2838 return file_accessible_directory_p (SSDATA (absname)) ? Qt : Qnil;
@@ -3345,7 +3344,7 @@ otherwise, if FILE2 does not exist, the answer is t. */)
3345 if (stat (SSDATA (absname2), &st2) < 0) 3344 if (stat (SSDATA (absname2), &st2) < 0)
3346 return Qt; 3345 return Qt;
3347 3346
3348 return (EMACS_TIME_GT (get_stat_mtime (&st1), get_stat_mtime (&st2)) 3347 return (EMACS_TIME_LT (get_stat_mtime (&st2), get_stat_mtime (&st1))
3349 ? Qt : Qnil); 3348 ? Qt : Qnil);
3350} 3349}
3351 3350
@@ -4575,8 +4574,8 @@ by calling `format-decode', which see. */)
4575 && EMACS_NSECS (current_buffer->modtime) == NONEXISTENT_MODTIME_NSECS) 4574 && EMACS_NSECS (current_buffer->modtime) == NONEXISTENT_MODTIME_NSECS)
4576 { 4575 {
4577 /* If visiting nonexistent file, return nil. */ 4576 /* If visiting nonexistent file, return nil. */
4578 errno = save_errno; 4577 report_file_errno ("Opening input file", Fcons (orig_filename, Qnil),
4579 report_file_error ("Opening input file", Fcons (orig_filename, Qnil)); 4578 save_errno);
4580 } 4579 }
4581 4580
4582 if (read_quit) 4581 if (read_quit)
@@ -4897,13 +4896,13 @@ This calls `write-region-annotate-functions' at the start, and
4897 4896
4898 if (desc < 0) 4897 if (desc < 0)
4899 { 4898 {
4899 int open_errno = errno;
4900#ifdef CLASH_DETECTION 4900#ifdef CLASH_DETECTION
4901 save_errno = errno;
4902 if (!auto_saving) unlock_file (lockname); 4901 if (!auto_saving) unlock_file (lockname);
4903 errno = save_errno;
4904#endif /* CLASH_DETECTION */ 4902#endif /* CLASH_DETECTION */
4905 UNGCPRO; 4903 UNGCPRO;
4906 report_file_error ("Opening output file", Fcons (filename, Qnil)); 4904 report_file_errno ("Opening output file", Fcons (filename, Qnil),
4905 open_errno);
4907 } 4906 }
4908 4907
4909 record_unwind_protect (close_file_unwind, make_number (desc)); 4908 record_unwind_protect (close_file_unwind, make_number (desc));
@@ -4913,13 +4912,13 @@ This calls `write-region-annotate-functions' at the start, and
4913 off_t ret = lseek (desc, offset, SEEK_SET); 4912 off_t ret = lseek (desc, offset, SEEK_SET);
4914 if (ret < 0) 4913 if (ret < 0)
4915 { 4914 {
4915 int lseek_errno = errno;
4916#ifdef CLASH_DETECTION 4916#ifdef CLASH_DETECTION
4917 save_errno = errno;
4918 if (!auto_saving) unlock_file (lockname); 4917 if (!auto_saving) unlock_file (lockname);
4919 errno = save_errno;
4920#endif /* CLASH_DETECTION */ 4918#endif /* CLASH_DETECTION */
4921 UNGCPRO; 4919 UNGCPRO;
4922 report_file_error ("Lseek error", Fcons (filename, Qnil)); 4920 report_file_errno ("Lseek error", Fcons (filename, Qnil),
4921 lseek_errno);
4923 } 4922 }
4924 } 4923 }
4925 4924
@@ -5317,12 +5316,10 @@ e_write (int desc, Lisp_Object string, ptrdiff_t start, ptrdiff_t end,
5317 5316
5318 if (coding->produced > 0) 5317 if (coding->produced > 0)
5319 { 5318 {
5320 coding->produced 5319 char *buf = (STRINGP (coding->dst_object)
5321 -= emacs_write (desc, 5320 ? SSDATA (coding->dst_object)
5322 STRINGP (coding->dst_object) 5321 : (char *) BYTE_POS_ADDR (coding->dst_pos_byte));
5323 ? SSDATA (coding->dst_object) 5322 coding->produced -= emacs_write_sig (desc, buf, coding->produced);
5324 : (char *) BYTE_POS_ADDR (coding->dst_pos_byte),
5325 coding->produced);
5326 5323
5327 if (coding->produced) 5324 if (coding->produced)
5328 return 0; 5325 return 0;
@@ -5377,36 +5374,19 @@ See Info node `(elisp)Modification Time' for more details. */)
5377 return Qnil; 5374 return Qnil;
5378} 5375}
5379 5376
5380DEFUN ("clear-visited-file-modtime", Fclear_visited_file_modtime,
5381 Sclear_visited_file_modtime, 0, 0, 0,
5382 doc: /* Clear out records of last mod time of visited file.
5383Next attempt to save will certainly not complain of a discrepancy. */)
5384 (void)
5385{
5386 current_buffer->modtime = make_emacs_time (0, UNKNOWN_MODTIME_NSECS);
5387 current_buffer->modtime_size = -1;
5388 return Qnil;
5389}
5390
5391DEFUN ("visited-file-modtime", Fvisited_file_modtime, 5377DEFUN ("visited-file-modtime", Fvisited_file_modtime,
5392 Svisited_file_modtime, 0, 0, 0, 5378 Svisited_file_modtime, 0, 0, 0,
5393 doc: /* Return the current buffer's recorded visited file modification time. 5379 doc: /* Return the current buffer's recorded visited file modification time.
5394The value is a list of the form (HIGH LOW USEC PSEC), like the time values that 5380The value is a list of the form (HIGH LOW USEC PSEC), like the time values that
5395`file-attributes' returns. If the current buffer has no recorded file 5381`file-attributes' returns. If the current buffer has no recorded file
5396modification time, this function returns 0. If the visited file 5382modification time, this function returns 0. If the visited file
5397doesn't exist, HIGH will be -1. 5383doesn't exist, return -1.
5398See Info node `(elisp)Modification Time' for more details. */) 5384See Info node `(elisp)Modification Time' for more details. */)
5399 (void) 5385 (void)
5400{ 5386{
5401 if (EMACS_NSECS (current_buffer->modtime) < 0) 5387 int ns = EMACS_NSECS (current_buffer->modtime);
5402 { 5388 if (ns < 0)
5403 if (EMACS_NSECS (current_buffer->modtime) == NONEXISTENT_MODTIME_NSECS) 5389 return make_number (UNKNOWN_MODTIME_NSECS - ns);
5404 {
5405 /* make_lisp_time won't work here if time_t is unsigned. */
5406 return list4i (-1, 65535, 0, 0);
5407 }
5408 return make_number (0);
5409 }
5410 return make_lisp_time (current_buffer->modtime); 5390 return make_lisp_time (current_buffer->modtime);
5411} 5391}
5412 5392
@@ -5417,12 +5397,22 @@ Useful if the buffer was not read from the file normally
5417or if the file itself has been changed for some known benign reason. 5397or if the file itself has been changed for some known benign reason.
5418An argument specifies the modification time value to use 5398An argument specifies the modification time value to use
5419\(instead of that of the visited file), in the form of a list 5399\(instead of that of the visited file), in the form of a list
5420\(HIGH LOW USEC PSEC) as returned by `current-time'. */) 5400\(HIGH LOW USEC PSEC) or an integer flag as returned by
5421 (Lisp_Object time_list) 5401`visited-file-modtime'. */)
5402 (Lisp_Object time_flag)
5422{ 5403{
5423 if (!NILP (time_list)) 5404 if (!NILP (time_flag))
5424 { 5405 {
5425 current_buffer->modtime = lisp_time_argument (time_list); 5406 EMACS_TIME mtime;
5407 if (INTEGERP (time_flag))
5408 {
5409 CHECK_RANGED_INTEGER (time_flag, -1, 0);
5410 mtime = make_emacs_time (0, UNKNOWN_MODTIME_NSECS - XINT (time_flag));
5411 }
5412 else
5413 mtime = lisp_time_argument (time_flag);
5414
5415 current_buffer->modtime = mtime;
5426 current_buffer->modtime_size = -1; 5416 current_buffer->modtime_size = -1;
5427 } 5417 }
5428 else 5418 else
@@ -6123,7 +6113,6 @@ This includes interactive calls to `delete-file' and
6123 defsubr (&Swrite_region); 6113 defsubr (&Swrite_region);
6124 defsubr (&Scar_less_than_car); 6114 defsubr (&Scar_less_than_car);
6125 defsubr (&Sverify_visited_file_modtime); 6115 defsubr (&Sverify_visited_file_modtime);
6126 defsubr (&Sclear_visited_file_modtime);
6127 defsubr (&Svisited_file_modtime); 6116 defsubr (&Svisited_file_modtime);
6128 defsubr (&Sset_visited_file_modtime); 6117 defsubr (&Sset_visited_file_modtime);
6129 defsubr (&Sdo_auto_save); 6118 defsubr (&Sdo_auto_save);
diff --git a/src/filelock.c b/src/filelock.c
index de6aba8385c..244663ad20a 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -47,6 +47,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
47#include "systime.h" 47#include "systime.h"
48#ifdef WINDOWSNT 48#ifdef WINDOWSNT
49#include <share.h> 49#include <share.h>
50#include <sys/socket.h> /* for fcntl */
50#include "w32.h" /* for dostounix_filename */ 51#include "w32.h" /* for dostounix_filename */
51#endif 52#endif
52 53
@@ -380,9 +381,9 @@ rename_lock_file (char const *old, char const *new, bool force)
380#endif 381#endif
381} 382}
382 383
383/* Create the lock file FILE with contents CONTENTS. Return 0 if 384/* Create the lock file LFNAME with contents LOCK_INFO_STR. Return 0 if
384 successful, an errno value on failure. If FORCE, remove any 385 successful, an errno value on failure. If FORCE, remove any
385 existing FILE if necessary. */ 386 existing LFNAME if necessary. */
386 387
387static int 388static int
388create_lock_file (char *lfname, char *lock_info_str, bool force) 389create_lock_file (char *lfname, char *lock_info_str, bool force)
@@ -416,8 +417,13 @@ create_lock_file (char *lfname, char *lock_info_str, bool force)
416 memcpy (nonce, lfname, lfdirlen); 417 memcpy (nonce, lfname, lfdirlen);
417 strcpy (nonce + lfdirlen, nonce_base); 418 strcpy (nonce + lfdirlen, nonce_base);
418 419
419#if HAVE_MKSTEMP 420#if HAVE_MKOSTEMP
420 /* Prefer mkstemp if available, as it avoids a race between 421 /* Prefer mkostemp to mkstemp, as it avoids a window where FD is
422 temporarily open without close-on-exec. */
423 fd = mkostemp (nonce, O_BINARY | O_CLOEXEC);
424 need_fchmod = 1;
425#elif HAVE_MKSTEMP
426 /* Prefer mkstemp to mktemp, as it avoids a race between
421 mktemp and emacs_open. */ 427 mktemp and emacs_open. */
422 fd = mkstemp (nonce); 428 fd = mkstemp (nonce);
423 need_fchmod = 1; 429 need_fchmod = 1;
@@ -432,7 +438,11 @@ create_lock_file (char *lfname, char *lock_info_str, bool force)
432 err = errno; 438 err = errno;
433 else 439 else
434 { 440 {
435 ptrdiff_t lock_info_len = strlen (lock_info_str); 441 ptrdiff_t lock_info_len;
442#if ! HAVE_MKOSTEMP
443 fcntl (fd, F_SETFD, FD_CLOEXEC);
444#endif
445 lock_info_len = strlen (lock_info_str);
436 err = 0; 446 err = 0;
437 if (emacs_write (fd, lock_info_str, lock_info_len) != lock_info_len 447 if (emacs_write (fd, lock_info_str, lock_info_len) != lock_info_len
438 || (need_fchmod && fchmod (fd, world_readable) != 0)) 448 || (need_fchmod && fchmod (fd, world_readable) != 0))
diff --git a/src/fns.c b/src/fns.c
index 7a8ddc04540..49bd8470f7f 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -5011,13 +5011,21 @@ this variable. */);
5011 defsubr (&Ssecure_hash); 5011 defsubr (&Ssecure_hash);
5012 defsubr (&Slocale_info); 5012 defsubr (&Slocale_info);
5013 5013
5014 { 5014 hashtest_eq.name = Qeq;
5015 struct hash_table_test 5015 hashtest_eq.user_hash_function = Qnil;
5016 eq = { Qeq, Qnil, Qnil, NULL, hashfn_eq }, 5016 hashtest_eq.user_cmp_function = Qnil;
5017 eql = { Qeql, Qnil, Qnil, cmpfn_eql, hashfn_eql }, 5017 hashtest_eq.cmpfn = 0;
5018 equal = { Qequal, Qnil, Qnil, cmpfn_equal, hashfn_equal }; 5018 hashtest_eq.hashfn = hashfn_eq;
5019 hashtest_eq = eq; 5019
5020 hashtest_eql = eql; 5020 hashtest_eql.name = Qeql;
5021 hashtest_equal = equal; 5021 hashtest_eql.user_hash_function = Qnil;
5022 } 5022 hashtest_eql.user_cmp_function = Qnil;
5023 hashtest_eql.cmpfn = cmpfn_eql;
5024 hashtest_eql.hashfn = hashfn_eql;
5025
5026 hashtest_equal.name = Qequal;
5027 hashtest_equal.user_hash_function = Qnil;
5028 hashtest_equal.user_cmp_function = Qnil;
5029 hashtest_equal.cmpfn = cmpfn_equal;
5030 hashtest_equal.hashfn = hashfn_equal;
5023} 5031}
diff --git a/src/frame.c b/src/frame.c
index 6ecc7147c18..648687a7cb4 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -1855,7 +1855,7 @@ See `redirect-frame-focus'. */)
1855/* Return the value of frame parameter PROP in frame FRAME. */ 1855/* Return the value of frame parameter PROP in frame FRAME. */
1856 1856
1857#ifdef HAVE_WINDOW_SYSTEM 1857#ifdef HAVE_WINDOW_SYSTEM
1858#if !HAVE_NS && !defined(WINDOWSNT) 1858#if !HAVE_NS && !defined (WINDOWSNT)
1859static 1859static
1860#endif 1860#endif
1861Lisp_Object 1861Lisp_Object
diff --git a/src/gnutls.h b/src/gnutls.h
index f1a337e7b3e..86dcab77b62 100644
--- a/src/gnutls.h
+++ b/src/gnutls.h
@@ -42,7 +42,7 @@ typedef enum
42 GNUTLS_STAGE_TRANSPORT_POINTERS_SET, 42 GNUTLS_STAGE_TRANSPORT_POINTERS_SET,
43 GNUTLS_STAGE_HANDSHAKE_TRIED, 43 GNUTLS_STAGE_HANDSHAKE_TRIED,
44 44
45 GNUTLS_STAGE_READY, 45 GNUTLS_STAGE_READY
46} gnutls_initstage_t; 46} gnutls_initstage_t;
47 47
48#define GNUTLS_EMACS_ERROR_NOT_LOADED GNUTLS_E_APPLICATION_ERROR_MIN + 1 48#define GNUTLS_EMACS_ERROR_NOT_LOADED GNUTLS_E_APPLICATION_ERROR_MIN + 1
diff --git a/src/image.c b/src/image.c
index 7ecd59d27b4..c085e6e63eb 100644
--- a/src/image.c
+++ b/src/image.c
@@ -316,7 +316,6 @@ x_create_bitmap_from_file (struct frame *f, Lisp_Object file)
316 int xhot, yhot, result; 316 int xhot, yhot, result;
317 ptrdiff_t id; 317 ptrdiff_t id;
318 Lisp_Object found; 318 Lisp_Object found;
319 int fd;
320 char *filename; 319 char *filename;
321 320
322 /* Look for an existing bitmap with the same name. */ 321 /* Look for an existing bitmap with the same name. */
@@ -332,10 +331,8 @@ x_create_bitmap_from_file (struct frame *f, Lisp_Object file)
332 } 331 }
333 332
334 /* Search bitmap-file-path for the file, if appropriate. */ 333 /* Search bitmap-file-path for the file, if appropriate. */
335 fd = openp (Vx_bitmap_file_path, file, Qnil, &found, Qnil); 334 if (openp (Vx_bitmap_file_path, file, Qnil, &found, make_number (R_OK)) < 0)
336 if (fd < 0)
337 return -1; 335 return -1;
338 emacs_close (fd);
339 336
340 filename = SSDATA (found); 337 filename = SSDATA (found);
341 338
@@ -2260,7 +2257,8 @@ x_find_image_file (Lisp_Object file)
2260 else 2257 else
2261 { 2258 {
2262 file_found = ENCODE_FILE (file_found); 2259 file_found = ENCODE_FILE (file_found);
2263 close (fd); 2260 if (fd != -2)
2261 emacs_close (fd);
2264 } 2262 }
2265 2263
2266 return file_found; 2264 return file_found;
@@ -8054,7 +8052,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
8054 8052
8055 init_color_table (); 8053 init_color_table ();
8056 8054
8057#ifdef HAVE_MAGICKEXPORTIMAGEPIXELS 8055#if defined (HAVE_MAGICKEXPORTIMAGEPIXELS) && ! defined (HAVE_NS)
8058 if (imagemagick_render_type != 0) 8056 if (imagemagick_render_type != 0)
8059 { 8057 {
8060 /* Magicexportimage is normally faster than pixelpushing. This 8058 /* Magicexportimage is normally faster than pixelpushing. This
diff --git a/src/inotify.c b/src/inotify.c
index 01fb34a5c4a..f4f850bf180 100644
--- a/src/inotify.c
+++ b/src/inotify.c
@@ -71,9 +71,8 @@ static Lisp_Object Qunmount; /* IN_UNMOUNT */
71# define IN_ONLYDIR 0 71# define IN_ONLYDIR 0
72#endif 72#endif
73 73
74enum { uninitialized = -100 };
75/* File handle for inotify. */ 74/* File handle for inotify. */
76static int inotifyfd = uninitialized; 75static int inotifyfd = -1;
77 76
78/* Assoc list of files being watched. 77/* Assoc list of files being watched.
79 Format: 78 Format:
@@ -268,8 +267,10 @@ aspect_to_inotifymask (Lisp_Object aspect)
268DEFUN ("inotify-add-watch", Finotify_add_watch, Sinotify_add_watch, 3, 3, 0, 267DEFUN ("inotify-add-watch", Finotify_add_watch, Sinotify_add_watch, 3, 3, 0,
269 doc: /* Add a watch for FILE-NAME to inotify. 268 doc: /* Add a watch for FILE-NAME to inotify.
270 269
271A WATCH-DESCRIPTOR is returned on success. ASPECT might be one of the following 270Return a watch descriptor. The watch will look for ASPECT events and
272symbols or a list of those symbols: 271invoke CALLBACK when an event occurs.
272
273ASPECT might be one of the following symbols or a list of those symbols:
273 274
274access 275access
275attrib 276attrib
@@ -288,7 +289,7 @@ all-events or t
288move 289move
289close 290close
290 291
291The following symbols can also be added to a list of aspects 292The following symbols can also be added to a list of aspects:
292 293
293dont-follow 294dont-follow
294excl-unlink 295excl-unlink
@@ -296,9 +297,8 @@ mask-add
296oneshot 297oneshot
297onlydir 298onlydir
298 299
299Watching a directory is not recursive. CALLBACK gets called in case of an 300Watching a directory is not recursive. CALLBACK is passed a single argument
300event. It gets passed a single argument EVENT which contains an event structure 301EVENT which contains an event structure of the format
301of the format
302 302
303(WATCH-DESCRIPTOR ASPECTS NAME COOKIE) 303(WATCH-DESCRIPTOR ASPECTS NAME COOKIE)
304 304
@@ -331,16 +331,13 @@ is managed internally and there is no corresponding inotify_init. Use
331 331
332 CHECK_STRING (file_name); 332 CHECK_STRING (file_name);
333 333
334 if (inotifyfd == uninitialized) 334 if (inotifyfd < 0)
335 { 335 {
336 inotifyfd = inotify_init1 (IN_NONBLOCK|IN_CLOEXEC); 336 inotifyfd = inotify_init1 (IN_NONBLOCK|IN_CLOEXEC);
337 if (inotifyfd == -1) 337 if (inotifyfd < 0)
338 { 338 xsignal1
339 inotifyfd = uninitialized; 339 (Qfile_notify_error,
340 xsignal1 340 build_string ("File watching feature (inotify) is not available"));
341 (Qfile_notify_error,
342 build_string ("File watching feature (inotify) is not available"));
343 }
344 watch_list = Qnil; 341 watch_list = Qnil;
345 add_read_fd (inotifyfd, &inotify_callback, NULL); 342 add_read_fd (inotifyfd, &inotify_callback, NULL);
346 } 343 }
@@ -390,9 +387,9 @@ See inotify_rm_watch(2) for more information.
390 /* Cleanup if no more files are watched. */ 387 /* Cleanup if no more files are watched. */
391 if (NILP (watch_list)) 388 if (NILP (watch_list))
392 { 389 {
393 close (inotifyfd); 390 emacs_close (inotifyfd);
394 delete_read_fd (inotifyfd); 391 delete_read_fd (inotifyfd);
395 inotifyfd = uninitialized; 392 inotifyfd = -1;
396 } 393 }
397 394
398 return Qt; 395 return Qt;
diff --git a/src/keyboard.c b/src/keyboard.c
index 39535f5cd71..b6eb9e6ad15 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -7008,7 +7008,7 @@ tty_read_avail_input (struct terminal *terminal,
7008 { 7008 {
7009 nread = emacs_read (fileno (tty->input), (char *) cbuf, n_to_read); 7009 nread = emacs_read (fileno (tty->input), (char *) cbuf, n_to_read);
7010 /* POSIX infers that processes which are not in the session leader's 7010 /* POSIX infers that processes which are not in the session leader's
7011 process group won't get SIGHUP's at logout time. BSDI adheres to 7011 process group won't get SIGHUPs at logout time. BSDI adheres to
7012 this part standard and returns -1 from read (0) with errno==EIO 7012 this part standard and returns -1 from read (0) with errno==EIO
7013 when the control tty is taken away. 7013 when the control tty is taken away.
7014 Jeffrey Honig <jch@bsdi.com> says this is generally safe. */ 7014 Jeffrey Honig <jch@bsdi.com> says this is generally safe. */
diff --git a/src/lisp.h b/src/lisp.h
index 9af69c61da8..acd21089655 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -365,9 +365,9 @@ enum enum_USE_LSB_TAG { USE_LSB_TAG = 0 };
365#define INTMASK (EMACS_INT_MAX >> (INTTYPEBITS - 1)) 365#define INTMASK (EMACS_INT_MAX >> (INTTYPEBITS - 1))
366#define case_Lisp_Int case Lisp_Int0: case Lisp_Int1 366#define case_Lisp_Int case Lisp_Int0: case Lisp_Int1
367 367
368/* Idea stolen from GDB. MSVC doesn't support enums in bitfields, 368/* Idea stolen from GDB. Pedantic GCC complains about enum bitfields,
369 and xlc complains vociferously about them. */ 369 MSVC doesn't support them, and xlc complains vociferously about them. */
370#if defined _MSC_VER || defined __IBMC__ 370#if defined __STRICT_ANSI__ || defined _MSC_VER || defined __IBMC__
371#define ENUM_BF(TYPE) unsigned int 371#define ENUM_BF(TYPE) unsigned int
372#else 372#else
373#define ENUM_BF(TYPE) enum TYPE 373#define ENUM_BF(TYPE) enum TYPE
@@ -400,7 +400,7 @@ enum Lisp_Type
400 /* Cons. XCONS (object) points to a struct Lisp_Cons. */ 400 /* Cons. XCONS (object) points to a struct Lisp_Cons. */
401 Lisp_Cons = 6, 401 Lisp_Cons = 6,
402 402
403 Lisp_Float = 7, 403 Lisp_Float = 7
404 }; 404 };
405 405
406/* This is the set of data types that share a common structure. 406/* This is the set of data types that share a common structure.
@@ -430,7 +430,7 @@ enum Lisp_Fwd_Type
430 Lisp_Fwd_Bool, /* Fwd to a C boolean var. */ 430 Lisp_Fwd_Bool, /* Fwd to a C boolean var. */
431 Lisp_Fwd_Obj, /* Fwd to a C Lisp_Object variable. */ 431 Lisp_Fwd_Obj, /* Fwd to a C Lisp_Object variable. */
432 Lisp_Fwd_Buffer_Obj, /* Fwd to a Lisp_Object field of buffers. */ 432 Lisp_Fwd_Buffer_Obj, /* Fwd to a Lisp_Object field of buffers. */
433 Lisp_Fwd_Kboard_Obj, /* Fwd to a Lisp_Object field of kboards. */ 433 Lisp_Fwd_Kboard_Obj /* Fwd to a Lisp_Object field of kboards. */
434 }; 434 };
435 435
436/* If you want to define a new Lisp data type, here are some 436/* If you want to define a new Lisp data type, here are some
@@ -2614,11 +2614,16 @@ CHECK_NUMBER_CDR (Lisp_Object x)
2614 minargs, maxargs, lname, intspec, 0}; \ 2614 minargs, maxargs, lname, intspec, 0}; \
2615 Lisp_Object fnname 2615 Lisp_Object fnname
2616#else /* not _MSC_VER */ 2616#else /* not _MSC_VER */
2617# if __STDC_VERSION__ < 199901
2618# define DEFUN_FUNCTION_INIT(fnname, maxargs) (Lisp_Object (*) (void)) fnname
2619# else
2620# define DEFUN_FUNCTION_INIT(fnname, maxargs) .a ## maxargs = fnname
2621# endif
2617#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \ 2622#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
2618 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \ 2623 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \
2619 static struct Lisp_Subr alignas (GCALIGNMENT) sname = \ 2624 static struct Lisp_Subr alignas (GCALIGNMENT) sname = \
2620 { { PVEC_SUBR << PSEUDOVECTOR_AREA_BITS }, \ 2625 { { PVEC_SUBR << PSEUDOVECTOR_AREA_BITS }, \
2621 { .a ## maxargs = fnname }, \ 2626 { DEFUN_FUNCTION_INIT (fnname, maxargs) }, \
2622 minargs, maxargs, lname, intspec, 0}; \ 2627 minargs, maxargs, lname, intspec, 0}; \
2623 Lisp_Object fnname 2628 Lisp_Object fnname
2624#endif 2629#endif
@@ -3740,7 +3745,6 @@ extern Lisp_Object string_to_number (char const *, int, bool);
3740extern void map_obarray (Lisp_Object, void (*) (Lisp_Object, Lisp_Object), 3745extern void map_obarray (Lisp_Object, void (*) (Lisp_Object, Lisp_Object),
3741 Lisp_Object); 3746 Lisp_Object);
3742extern void dir_warning (const char *, Lisp_Object); 3747extern void dir_warning (const char *, Lisp_Object);
3743extern void close_load_descs (void);
3744extern void init_obarray (void); 3748extern void init_obarray (void);
3745extern void init_lread (void); 3749extern void init_lread (void);
3746extern void syms_of_lread (void); 3750extern void syms_of_lread (void);
@@ -3896,6 +3900,7 @@ extern Lisp_Object expand_and_dir_to_file (Lisp_Object, Lisp_Object);
3896EXFUN (Fread_file_name, 6); /* Not a normal DEFUN. */ 3900EXFUN (Fread_file_name, 6); /* Not a normal DEFUN. */
3897extern Lisp_Object close_file_unwind (Lisp_Object); 3901extern Lisp_Object close_file_unwind (Lisp_Object);
3898extern Lisp_Object restore_point_unwind (Lisp_Object); 3902extern Lisp_Object restore_point_unwind (Lisp_Object);
3903extern _Noreturn void report_file_errno (const char *, Lisp_Object, int);
3899extern _Noreturn void report_file_error (const char *, Lisp_Object); 3904extern _Noreturn void report_file_error (const char *, Lisp_Object);
3900extern bool internal_delete_file (Lisp_Object); 3905extern bool internal_delete_file (Lisp_Object);
3901extern Lisp_Object emacs_readlinkat (int, const char *); 3906extern Lisp_Object emacs_readlinkat (int, const char *);
@@ -4001,7 +4006,7 @@ extern Lisp_Object Qvisible;
4001extern void store_frame_param (struct frame *, Lisp_Object, Lisp_Object); 4006extern void store_frame_param (struct frame *, Lisp_Object, Lisp_Object);
4002extern void store_in_alist (Lisp_Object *, Lisp_Object, Lisp_Object); 4007extern void store_in_alist (Lisp_Object *, Lisp_Object, Lisp_Object);
4003extern Lisp_Object do_switch_frame (Lisp_Object, int, int, Lisp_Object); 4008extern Lisp_Object do_switch_frame (Lisp_Object, int, int, Lisp_Object);
4004#if HAVE_NS || defined(WINDOWSNT) 4009#if HAVE_NS || defined WINDOWSNT
4005extern Lisp_Object get_frame_param (struct frame *, Lisp_Object); 4010extern Lisp_Object get_frame_param (struct frame *, Lisp_Object);
4006#endif 4011#endif
4007extern void frames_discard_buffer (Lisp_Object); 4012extern void frames_discard_buffer (Lisp_Object);
@@ -4073,11 +4078,11 @@ extern void delete_keyboard_wait_descriptor (int);
4073extern void add_gpm_wait_descriptor (int); 4078extern void add_gpm_wait_descriptor (int);
4074extern void delete_gpm_wait_descriptor (int); 4079extern void delete_gpm_wait_descriptor (int);
4075#endif 4080#endif
4076extern void close_process_descs (void);
4077extern void init_process_emacs (void); 4081extern void init_process_emacs (void);
4078extern void syms_of_process (void); 4082extern void syms_of_process (void);
4079extern void setup_process_coding_systems (Lisp_Object); 4083extern void setup_process_coding_systems (Lisp_Object);
4080 4084
4085/* Defined in callproc.c. */
4081#ifndef DOS_NT 4086#ifndef DOS_NT
4082 _Noreturn 4087 _Noreturn
4083#endif 4088#endif
@@ -4169,6 +4174,8 @@ extern int emacs_open (const char *, int, int);
4169extern int emacs_close (int); 4174extern int emacs_close (int);
4170extern ptrdiff_t emacs_read (int, char *, ptrdiff_t); 4175extern ptrdiff_t emacs_read (int, char *, ptrdiff_t);
4171extern ptrdiff_t emacs_write (int, const char *, ptrdiff_t); 4176extern ptrdiff_t emacs_write (int, const char *, ptrdiff_t);
4177extern ptrdiff_t emacs_write_sig (int, char const *, ptrdiff_t);
4178extern void emacs_perror (char const *);
4172 4179
4173extern void unlock_all_files (void); 4180extern void unlock_all_files (void);
4174extern void lock_file (Lisp_Object); 4181extern void lock_file (Lisp_Object);
diff --git a/src/lread.c b/src/lread.c
index 06badce12be..f0423f166dd 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -95,9 +95,6 @@ static Lisp_Object Qload_in_progress;
95 It must be set to nil before all top-level calls to read0. */ 95 It must be set to nil before all top-level calls to read0. */
96static Lisp_Object read_objects; 96static Lisp_Object read_objects;
97 97
98/* List of descriptors now open for Fload. */
99static Lisp_Object load_descriptor_list;
100
101/* File for get_file_char to read from. Use by load. */ 98/* File for get_file_char to read from. Use by load. */
102static FILE *instream; 99static FILE *instream;
103 100
@@ -149,7 +146,6 @@ static void readevalloop (Lisp_Object, FILE *, Lisp_Object, bool,
149 Lisp_Object, Lisp_Object, 146 Lisp_Object, Lisp_Object,
150 Lisp_Object, Lisp_Object); 147 Lisp_Object, Lisp_Object);
151static Lisp_Object load_unwind (Lisp_Object); 148static Lisp_Object load_unwind (Lisp_Object);
152static Lisp_Object load_descriptor_unwind (Lisp_Object);
153 149
154/* Functions that read one byte from the current source READCHARFUN 150/* Functions that read one byte from the current source READCHARFUN
155 or unreads one byte. If the integer argument C is -1, it returns 151 or unreads one byte. If the integer argument C is -1, it returns
@@ -827,7 +823,7 @@ lisp_file_lexically_bound_p (Lisp_Object readcharfun)
827 { 823 {
828 bool rv = 0; 824 bool rv = 0;
829 enum { 825 enum {
830 NOMINAL, AFTER_FIRST_DASH, AFTER_ASTERIX, 826 NOMINAL, AFTER_FIRST_DASH, AFTER_ASTERIX
831 } beg_end_state = NOMINAL; 827 } beg_end_state = NOMINAL;
832 bool in_file_vars = 0; 828 bool in_file_vars = 0;
833 829
@@ -1328,11 +1324,8 @@ Return t if the file exists and loads successfully. */)
1328 } 1324 }
1329 1325
1330 record_unwind_protect (load_unwind, make_save_pointer (stream)); 1326 record_unwind_protect (load_unwind, make_save_pointer (stream));
1331 record_unwind_protect (load_descriptor_unwind, load_descriptor_list);
1332 specbind (Qload_file_name, found); 1327 specbind (Qload_file_name, found);
1333 specbind (Qinhibit_file_name_operation, Qnil); 1328 specbind (Qinhibit_file_name_operation, Qnil);
1334 load_descriptor_list
1335 = Fcons (make_number (fileno (stream)), load_descriptor_list);
1336 specbind (Qload_in_progress, Qt); 1329 specbind (Qload_in_progress, Qt);
1337 1330
1338 instream = stream; 1331 instream = stream;
@@ -1395,26 +1388,6 @@ load_unwind (Lisp_Object arg) /* Used as unwind-protect function in load. */
1395 } 1388 }
1396 return Qnil; 1389 return Qnil;
1397} 1390}
1398
1399static Lisp_Object
1400load_descriptor_unwind (Lisp_Object oldlist)
1401{
1402 load_descriptor_list = oldlist;
1403 return Qnil;
1404}
1405
1406/* Close all descriptors in use for Floads.
1407 This is used when starting a subprocess. */
1408
1409void
1410close_load_descs (void)
1411{
1412#ifndef WINDOWSNT
1413 Lisp_Object tail;
1414 for (tail = load_descriptor_list; CONSP (tail); tail = XCDR (tail))
1415 emacs_close (XFASTINT (XCAR (tail)));
1416#endif
1417}
1418 1391
1419static bool 1392static bool
1420complete_filename_p (Lisp_Object pathname) 1393complete_filename_p (Lisp_Object pathname)
@@ -1439,8 +1412,8 @@ directories, make sure the PREDICATE function returns `dir-ok' for them. */)
1439{ 1412{
1440 Lisp_Object file; 1413 Lisp_Object file;
1441 int fd = openp (path, filename, suffixes, &file, predicate); 1414 int fd = openp (path, filename, suffixes, &file, predicate);
1442 if (NILP (predicate) && fd > 0) 1415 if (NILP (predicate) && fd >= 0)
1443 close (fd); 1416 emacs_close (fd);
1444 return file; 1417 return file;
1445} 1418}
1446 1419
@@ -1448,14 +1421,15 @@ static Lisp_Object Qdir_ok;
1448 1421
1449/* Search for a file whose name is STR, looking in directories 1422/* Search for a file whose name is STR, looking in directories
1450 in the Lisp list PATH, and trying suffixes from SUFFIX. 1423 in the Lisp list PATH, and trying suffixes from SUFFIX.
1451 On success, returns a file descriptor. On failure, returns -1. 1424 On success, return a file descriptor (or 1 or -2 as described below).
1425 On failure, return -1 and set errno.
1452 1426
1453 SUFFIXES is a list of strings containing possible suffixes. 1427 SUFFIXES is a list of strings containing possible suffixes.
1454 The empty suffix is automatically added if the list is empty. 1428 The empty suffix is automatically added if the list is empty.
1455 1429
1456 PREDICATE non-nil means don't open the files, 1430 PREDICATE non-nil means don't open the files,
1457 just look for one that satisfies the predicate. In this case, 1431 just look for one that satisfies the predicate. In this case,
1458 returns 1 on success. The predicate can be a lisp function or 1432 return 1 on success. The predicate can be a lisp function or
1459 an integer to pass to `access' (in which case file-name-handlers 1433 an integer to pass to `access' (in which case file-name-handlers
1460 are ignored). 1434 are ignored).
1461 1435
@@ -1467,7 +1441,8 @@ static Lisp_Object Qdir_ok;
1467 but store the found remote file name in *STOREPTR. */ 1441 but store the found remote file name in *STOREPTR. */
1468 1442
1469int 1443int
1470openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *storeptr, Lisp_Object predicate) 1444openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes,
1445 Lisp_Object *storeptr, Lisp_Object predicate)
1471{ 1446{
1472 ptrdiff_t fn_size = 100; 1447 ptrdiff_t fn_size = 100;
1473 char buf[100]; 1448 char buf[100];
@@ -1478,6 +1453,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto
1478 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; 1453 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
1479 Lisp_Object string, tail, encoded_fn; 1454 Lisp_Object string, tail, encoded_fn;
1480 ptrdiff_t max_suffix_len = 0; 1455 ptrdiff_t max_suffix_len = 0;
1456 int last_errno = ENOENT;
1481 1457
1482 CHECK_STRING (str); 1458 CHECK_STRING (str);
1483 1459
@@ -1547,14 +1523,22 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto
1547 if ((!NILP (handler) || !NILP (predicate)) && !NATNUMP (predicate)) 1523 if ((!NILP (handler) || !NILP (predicate)) && !NATNUMP (predicate))
1548 { 1524 {
1549 bool exists; 1525 bool exists;
1526 last_errno = ENOENT;
1550 if (NILP (predicate)) 1527 if (NILP (predicate))
1551 exists = !NILP (Ffile_readable_p (string)); 1528 exists = !NILP (Ffile_readable_p (string));
1552 else 1529 else
1553 { 1530 {
1554 Lisp_Object tmp = call1 (predicate, string); 1531 Lisp_Object tmp = call1 (predicate, string);
1555 exists = !NILP (tmp) 1532 if (NILP (tmp))
1556 && (EQ (tmp, Qdir_ok) 1533 exists = 0;
1557 || NILP (Ffile_directory_p (string))); 1534 else if (EQ (tmp, Qdir_ok)
1535 || NILP (Ffile_directory_p (string)))
1536 exists = 1;
1537 else
1538 {
1539 exists = 0;
1540 last_errno = EISDIR;
1541 }
1558 } 1542 }
1559 1543
1560 if (exists) 1544 if (exists)
@@ -1576,21 +1560,36 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto
1576 1560
1577 /* Check that we can access or open it. */ 1561 /* Check that we can access or open it. */
1578 if (NATNUMP (predicate)) 1562 if (NATNUMP (predicate))
1579 fd = (((XFASTINT (predicate) & ~INT_MAX) == 0 1563 {
1580 && (faccessat (AT_FDCWD, pfn, XFASTINT (predicate), 1564 fd = -1;
1565 if (INT_MAX < XFASTINT (predicate))
1566 last_errno = EINVAL;
1567 else if (faccessat (AT_FDCWD, pfn, XFASTINT (predicate),
1581 AT_EACCESS) 1568 AT_EACCESS)
1582 == 0) 1569 == 0)
1583 && ! file_directory_p (pfn)) 1570 {
1584 ? 1 : -1); 1571 if (file_directory_p (pfn))
1572 last_errno = EISDIR;
1573 else
1574 fd = 1;
1575 }
1576 }
1585 else 1577 else
1586 { 1578 {
1587 struct stat st;
1588 fd = emacs_open (pfn, O_RDONLY, 0); 1579 fd = emacs_open (pfn, O_RDONLY, 0);
1589 if (fd >= 0 1580 if (fd < 0)
1590 && (fstat (fd, &st) != 0 || S_ISDIR (st.st_mode))) 1581 last_errno = errno;
1582 else
1591 { 1583 {
1592 emacs_close (fd); 1584 struct stat st;
1593 fd = -1; 1585 int err = (fstat (fd, &st) != 0 ? errno
1586 : S_ISDIR (st.st_mode) ? EISDIR : 0);
1587 if (err)
1588 {
1589 last_errno = err;
1590 emacs_close (fd);
1591 fd = -1;
1592 }
1594 } 1593 }
1595 } 1594 }
1596 1595
@@ -1609,6 +1608,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto
1609 } 1608 }
1610 1609
1611 UNGCPRO; 1610 UNGCPRO;
1611 errno = last_errno;
1612 return -1; 1612 return -1;
1613} 1613}
1614 1614
@@ -4349,9 +4349,6 @@ init_lread (void)
4349 4349
4350 load_in_progress = 0; 4350 load_in_progress = 0;
4351 Vload_file_name = Qnil; 4351 Vload_file_name = Qnil;
4352
4353 load_descriptor_list = Qnil;
4354
4355 Vstandard_input = Qt; 4352 Vstandard_input = Qt;
4356 Vloads_in_progress = Qnil; 4353 Vloads_in_progress = Qnil;
4357} 4354}
@@ -4624,9 +4621,6 @@ variables, this must be set in the first line of a file. */);
4624 4621
4625 /* Vsource_directory was initialized in init_lread. */ 4622 /* Vsource_directory was initialized in init_lread. */
4626 4623
4627 load_descriptor_list = Qnil;
4628 staticpro (&load_descriptor_list);
4629
4630 DEFSYM (Qcurrent_load_list, "current-load-list"); 4624 DEFSYM (Qcurrent_load_list, "current-load-list");
4631 DEFSYM (Qstandard_input, "standard-input"); 4625 DEFSYM (Qstandard_input, "standard-input");
4632 DEFSYM (Qread_char, "read-char"); 4626 DEFSYM (Qread_char, "read-char");
diff --git a/src/makefile.w32-in b/src/makefile.w32-in
index 272b053ed12..f4885580e1c 100644
--- a/src/makefile.w32-in
+++ b/src/makefile.w32-in
@@ -813,7 +813,6 @@ $(BLD)/emacs.$(O) : \
813 $(NT_INC)/sys/file.h \ 813 $(NT_INC)/sys/file.h \
814 $(NT_INC)/unistd.h \ 814 $(NT_INC)/unistd.h \
815 $(GNU_LIB)/close-stream.h \ 815 $(GNU_LIB)/close-stream.h \
816 $(GNU_LIB)/ignore-value.h \
817 $(ATIMER_H) \ 816 $(ATIMER_H) \
818 $(BUFFER_H) \ 817 $(BUFFER_H) \
819 $(CHARACTER_H) \ 818 $(CHARACTER_H) \
@@ -1407,7 +1406,6 @@ $(BLD)/sysdep.$(O) : \
1407 $(NT_INC)/sys/stat.h \ 1406 $(NT_INC)/sys/stat.h \
1408 $(NT_INC)/unistd.h \ 1407 $(NT_INC)/unistd.h \
1409 $(GNU_LIB)/execinfo.h \ 1408 $(GNU_LIB)/execinfo.h \
1410 $(GNU_LIB)/ignore-value.h \
1411 $(GNU_LIB)/utimens.h \ 1409 $(GNU_LIB)/utimens.h \
1412 $(CONFIG_H) \ 1410 $(CONFIG_H) \
1413 $(C_CTYPE_H) \ 1411 $(C_CTYPE_H) \
diff --git a/src/nsfns.m b/src/nsfns.m
index b8f46e461fa..6eebb4d2567 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -885,7 +885,7 @@ ns_appkit_version_str (void)
885 885
886#ifdef NS_IMPL_GNUSTEP 886#ifdef NS_IMPL_GNUSTEP
887 sprintf(tmp, "gnustep-gui-%s", Xstr(GNUSTEP_GUI_VERSION)); 887 sprintf(tmp, "gnustep-gui-%s", Xstr(GNUSTEP_GUI_VERSION));
888#elif defined(NS_IMPL_COCOA) 888#elif defined (NS_IMPL_COCOA)
889 sprintf(tmp, "apple-appkit-%.2f", NSAppKitVersionNumber); 889 sprintf(tmp, "apple-appkit-%.2f", NSAppKitVersionNumber);
890#else 890#else
891 tmp = "ns-unknown"; 891 tmp = "ns-unknown";
@@ -902,7 +902,7 @@ ns_appkit_version_int (void)
902{ 902{
903#ifdef NS_IMPL_GNUSTEP 903#ifdef NS_IMPL_GNUSTEP
904 return GNUSTEP_GUI_MAJOR_VERSION * 100 + GNUSTEP_GUI_MINOR_VERSION; 904 return GNUSTEP_GUI_MAJOR_VERSION * 100 + GNUSTEP_GUI_MINOR_VERSION;
905#elif defined(NS_IMPL_COCOA) 905#elif defined (NS_IMPL_COCOA)
906 return (int)NSAppKitVersionNumber; 906 return (int)NSAppKitVersionNumber;
907#endif 907#endif
908 return 0; 908 return 0;
@@ -2493,7 +2493,7 @@ Internal use only, use `display-monitor-attributes-list' instead. */)
2493 vy = (short) (primary_display_height - 2493 vy = (short) (primary_display_height -
2494 vfr.size.height - vfr.origin.y); 2494 vfr.size.height - vfr.origin.y);
2495 } 2495 }
2496 2496
2497 m->geom.x = (short) fr.origin.x; 2497 m->geom.x = (short) fr.origin.x;
2498 m->geom.y = y; 2498 m->geom.y = y;
2499 m->geom.width = (unsigned short) fr.size.width; 2499 m->geom.width = (unsigned short) fr.size.width;
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 1d3d111e9a1..22635dca0a2 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -612,8 +612,8 @@ extern NSString *NSMenuDidBeginTrackingNotification;
612 if (trackingMenu == 0) 612 if (trackingMenu == 0)
613 return; 613 return;
614/*fprintf (stderr, "Updating menu '%s'\n", [[self title] UTF8String]); NSLog (@"%@\n", event); */ 614/*fprintf (stderr, "Updating menu '%s'\n", [[self title] UTF8String]); NSLog (@"%@\n", event); */
615#if ! defined(NS_IMPL_COCOA) || \ 615#if (! defined (NS_IMPL_COCOA) \
616 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 616 || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5)
617 /* Don't know how to do this for anything other than OSX >= 10.5 617 /* Don't know how to do this for anything other than OSX >= 10.5
618 This is wrong, as it might run Lisp code in the event loop. */ 618 This is wrong, as it might run Lisp code in the event loop. */
619 ns_update_menubar (frame, true, self); 619 ns_update_menubar (frame, true, self);
@@ -1240,7 +1240,7 @@ update_frame_tool_bar (FRAME_PTR f)
1240#ifdef NS_IMPL_GNUSTEP 1240#ifdef NS_IMPL_GNUSTEP
1241 [self insertItemWithItemIdentifier: identifier atIndex: idx]; 1241 [self insertItemWithItemIdentifier: identifier atIndex: idx];
1242#endif 1242#endif
1243 1243
1244 [item setTag: tag]; 1244 [item setTag: tag];
1245 [item setEnabled: enabled]; 1245 [item setEnabled: enabled];
1246 1246
diff --git a/src/nsterm.m b/src/nsterm.m
index 97a6313489d..d7cea5c189a 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -3603,7 +3603,7 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds,
3603 3603
3604 /* Inform fd_handler that select should be called */ 3604 /* Inform fd_handler that select should be called */
3605 c = 'g'; 3605 c = 'g';
3606 emacs_write (selfds[1], &c, 1); 3606 emacs_write_sig (selfds[1], &c, 1);
3607 } 3607 }
3608 else if (nr == 0 && timeout) 3608 else if (nr == 0 && timeout)
3609 { 3609 {
@@ -3636,7 +3636,7 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds,
3636 if (nr > 0 && readfds) 3636 if (nr > 0 && readfds)
3637 { 3637 {
3638 c = 's'; 3638 c = 's';
3639 emacs_write (selfds[1], &c, 1); 3639 emacs_write_sig (selfds[1], &c, 1);
3640 } 3640 }
3641 unblock_input (); 3641 unblock_input ();
3642 3642
@@ -4142,7 +4142,7 @@ ns_term_init (Lisp_Object display_name)
4142 4142
4143 if (selfds[0] == -1) 4143 if (selfds[0] == -1)
4144 { 4144 {
4145 if (pipe (selfds) == -1) 4145 if (pipe2 (selfds, O_CLOEXEC) != 0)
4146 { 4146 {
4147 fprintf (stderr, "Failed to create pipe: %s\n", 4147 fprintf (stderr, "Failed to create pipe: %s\n",
4148 emacs_strerror (errno)); 4148 emacs_strerror (errno));
@@ -4419,6 +4419,16 @@ ns_term_shutdown (int sig)
4419/* NSTRACE (sendEvent); */ 4419/* NSTRACE (sendEvent); */
4420/*fprintf (stderr, "received event of type %d\t%d\n", type);*/ 4420/*fprintf (stderr, "received event of type %d\t%d\n", type);*/
4421 4421
4422#ifdef NS_IMPL_GNUSTEP
4423 // Keyboard events aren't propagated to file dialogs for some reason.
4424 if ([NSApp modalWindow] != nil &&
4425 (type == NSKeyDown || type == NSKeyUp || type == NSFlagsChanged))
4426 {
4427 [[NSApp modalWindow] sendEvent: theEvent];
4428 return;
4429 }
4430#endif
4431
4422 if (type == NSApplicationDefined) 4432 if (type == NSApplicationDefined)
4423 { 4433 {
4424 switch ([theEvent data2]) 4434 switch ([theEvent data2])
diff --git a/src/print.c b/src/print.c
index 09519d93cfe..01e490dcbad 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1765,9 +1765,8 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1765 } 1765 }
1766 else if (WINDOWP (obj)) 1766 else if (WINDOWP (obj))
1767 { 1767 {
1768 int len; 1768 void *ptr = XWINDOW (obj);
1769 strout ("#<window ", -1, -1, printcharfun); 1769 int len = sprintf (buf, "#<window %p", ptr);
1770 len = sprintf (buf, "%p", XWINDOW (obj));
1771 strout (buf, len, len, printcharfun); 1770 strout (buf, len, len, printcharfun);
1772 if (BUFFERP (XWINDOW (obj)->contents)) 1771 if (BUFFERP (XWINDOW (obj)->contents))
1773 { 1772 {
@@ -1798,6 +1797,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1798 ptrdiff_t real_size, size; 1797 ptrdiff_t real_size, size;
1799 int len; 1798 int len;
1800#if 0 1799#if 0
1800 void *ptr = h;
1801 strout ("#<hash-table", -1, -1, printcharfun); 1801 strout ("#<hash-table", -1, -1, printcharfun);
1802 if (SYMBOLP (h->test)) 1802 if (SYMBOLP (h->test))
1803 { 1803 {
@@ -1810,9 +1810,8 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1810 len = sprintf (buf, "%"pD"d/%"pD"d", h->count, ASIZE (h->next)); 1810 len = sprintf (buf, "%"pD"d/%"pD"d", h->count, ASIZE (h->next));
1811 strout (buf, len, len, printcharfun); 1811 strout (buf, len, len, printcharfun);
1812 } 1812 }
1813 len = sprintf (buf, " %p", h); 1813 len = sprintf (buf, " %p>", ptr);
1814 strout (buf, len, len, printcharfun); 1814 strout (buf, len, len, printcharfun);
1815 PRINTCHAR ('>');
1816#endif 1815#endif
1817 /* Implement a readable output, e.g.: 1816 /* Implement a readable output, e.g.:
1818 #s(hash-table size 2 test equal data (k1 v1 k2 v2)) */ 1817 #s(hash-table size 2 test equal data (k1 v1 k2 v2)) */
@@ -1892,6 +1891,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1892 else if (FRAMEP (obj)) 1891 else if (FRAMEP (obj))
1893 { 1892 {
1894 int len; 1893 int len;
1894 void *ptr = XFRAME (obj);
1895 Lisp_Object frame_name = XFRAME (obj)->name; 1895 Lisp_Object frame_name = XFRAME (obj)->name;
1896 1896
1897 strout ((FRAME_LIVE_P (XFRAME (obj)) 1897 strout ((FRAME_LIVE_P (XFRAME (obj))
@@ -1907,9 +1907,8 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1907 frame_name = build_string ("*INVALID*FRAME*NAME*"); 1907 frame_name = build_string ("*INVALID*FRAME*NAME*");
1908 } 1908 }
1909 print_string (frame_name, printcharfun); 1909 print_string (frame_name, printcharfun);
1910 len = sprintf (buf, " %p", XFRAME (obj)); 1910 len = sprintf (buf, " %p>", ptr);
1911 strout (buf, len, len, printcharfun); 1911 strout (buf, len, len, printcharfun);
1912 PRINTCHAR ('>');
1913 } 1912 }
1914 else if (FONTP (obj)) 1913 else if (FONTP (obj))
1915 { 1914 {
diff --git a/src/process.c b/src/process.c
index 2e2610ffde4..dc37bfe7067 100644
--- a/src/process.c
+++ b/src/process.c
@@ -135,6 +135,37 @@ extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *,
135 EMACS_TIME *, void *); 135 EMACS_TIME *, void *);
136#endif 136#endif
137 137
138#ifndef SOCK_CLOEXEC
139# define SOCK_CLOEXEC 0
140#endif
141
142#ifndef HAVE_ACCEPT4
143
144/* Emulate GNU/Linux accept4 and socket well enough for this module. */
145
146static int
147close_on_exec (int fd)
148{
149 if (0 <= fd)
150 fcntl (fd, F_SETFD, FD_CLOEXEC);
151 return fd;
152}
153
154static int
155accept4 (int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags)
156{
157 return close_on_exec (accept (sockfd, addr, addrlen));
158}
159
160static int
161process_socket (int domain, int type, int protocol)
162{
163 return close_on_exec (socket (domain, type, protocol));
164}
165# undef socket
166# define socket(domain, type, protocol) process_socket (domain, type, protocol)
167#endif
168
138/* Work around GCC 4.7.0 bug with strict overflow checking; see 169/* Work around GCC 4.7.0 bug with strict overflow checking; see
139 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>. 170 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>.
140 These lines can be removed once the GCC bug is fixed. */ 171 These lines can be removed once the GCC bug is fixed. */
@@ -1782,6 +1813,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1782{ 1813{
1783 int inchannel, outchannel; 1814 int inchannel, outchannel;
1784 pid_t pid; 1815 pid_t pid;
1816 int vfork_errno;
1785 int sv[2]; 1817 int sv[2];
1786#ifndef WINDOWSNT 1818#ifndef WINDOWSNT
1787 int wait_child_setup[2]; 1819 int wait_child_setup[2];
@@ -1816,47 +1848,30 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1816 else 1848 else
1817#endif /* HAVE_PTYS */ 1849#endif /* HAVE_PTYS */
1818 { 1850 {
1819 int tem; 1851 if (pipe2 (sv, O_CLOEXEC) != 0)
1820 tem = pipe (sv);
1821 if (tem < 0)
1822 report_file_error ("Creating pipe", Qnil); 1852 report_file_error ("Creating pipe", Qnil);
1823 inchannel = sv[0]; 1853 inchannel = sv[0];
1824 forkout = sv[1]; 1854 forkout = sv[1];
1825 tem = pipe (sv); 1855 if (pipe2 (sv, O_CLOEXEC) != 0)
1826 if (tem < 0)
1827 { 1856 {
1857 int pipe_errno = errno;
1828 emacs_close (inchannel); 1858 emacs_close (inchannel);
1829 emacs_close (forkout); 1859 emacs_close (forkout);
1830 report_file_error ("Creating pipe", Qnil); 1860 report_file_errno ("Creating pipe", Qnil, pipe_errno);
1831 } 1861 }
1832 outchannel = sv[1]; 1862 outchannel = sv[1];
1833 forkin = sv[0]; 1863 forkin = sv[0];
1834 } 1864 }
1835 1865
1836#ifndef WINDOWSNT 1866#ifndef WINDOWSNT
1837 { 1867 if (pipe2 (wait_child_setup, O_CLOEXEC) != 0)
1838 int tem; 1868 report_file_error ("Creating pipe", Qnil);
1839
1840 tem = pipe (wait_child_setup);
1841 if (tem < 0)
1842 report_file_error ("Creating pipe", Qnil);
1843 tem = fcntl (wait_child_setup[1], F_GETFD, 0);
1844 if (tem >= 0)
1845 tem = fcntl (wait_child_setup[1], F_SETFD, tem | FD_CLOEXEC);
1846 if (tem < 0)
1847 {
1848 emacs_close (wait_child_setup[0]);
1849 emacs_close (wait_child_setup[1]);
1850 report_file_error ("Setting file descriptor flags", Qnil);
1851 }
1852 }
1853#endif 1869#endif
1854 1870
1855 fcntl (inchannel, F_SETFL, O_NONBLOCK); 1871 fcntl (inchannel, F_SETFL, O_NONBLOCK);
1856 fcntl (outchannel, F_SETFL, O_NONBLOCK); 1872 fcntl (outchannel, F_SETFL, O_NONBLOCK);
1857 1873
1858 /* Record this as an active process, with its channels. 1874 /* Record this as an active process, with its channels. */
1859 As a result, child_setup will close Emacs's side of the pipes. */
1860 chan_process[inchannel] = process; 1875 chan_process[inchannel] = process;
1861 XPROCESS (process)->infd = inchannel; 1876 XPROCESS (process)->infd = inchannel;
1862 XPROCESS (process)->outfd = outchannel; 1877 XPROCESS (process)->outfd = outchannel;
@@ -1933,7 +1948,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1933 tcgetattr (xforkin, &t); 1948 tcgetattr (xforkin, &t);
1934 t.c_lflag = LDISC1; 1949 t.c_lflag = LDISC1;
1935 if (tcsetattr (xforkin, TCSANOW, &t) < 0) 1950 if (tcsetattr (xforkin, TCSANOW, &t) < 0)
1936 emacs_write (1, "create_process/tcsetattr LDISC1 failed\n", 39); 1951 emacs_perror ("create_process/tcsetattr LDISC1");
1937 } 1952 }
1938#else 1953#else
1939#if defined (NTTYDISC) && defined (TIOCSETD) 1954#if defined (NTTYDISC) && defined (TIOCSETD)
@@ -1980,10 +1995,8 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1980 1995
1981 if (xforkin < 0) 1996 if (xforkin < 0)
1982 { 1997 {
1983 emacs_write (1, "Couldn't open the pty terminal ", 31); 1998 emacs_perror (pty_name);
1984 emacs_write (1, pty_name, strlen (pty_name)); 1999 _exit (EXIT_CANCELED);
1985 emacs_write (1, "\n", 1);
1986 _exit (1);
1987 } 2000 }
1988 2001
1989 } 2002 }
@@ -1995,12 +2008,6 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1995 SETUP_SLAVE_PTY; 2008 SETUP_SLAVE_PTY;
1996 } 2009 }
1997#endif /* SETUP_SLAVE_PTY */ 2010#endif /* SETUP_SLAVE_PTY */
1998#ifdef AIX
1999 /* On AIX, we've disabled SIGHUP above once we start a child on a pty.
2000 Now reenable it in the child, so it will die when we want it to. */
2001 if (pty_flag)
2002 signal (SIGHUP, SIG_DFL);
2003#endif
2004#endif /* HAVE_PTYS */ 2011#endif /* HAVE_PTYS */
2005 2012
2006 signal (SIGINT, SIG_DFL); 2013 signal (SIGINT, SIG_DFL);
@@ -2026,6 +2033,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
2026 2033
2027 /* Back in the parent process. */ 2034 /* Back in the parent process. */
2028 2035
2036 vfork_errno = errno;
2029 XPROCESS (process)->pid = pid; 2037 XPROCESS (process)->pid = pid;
2030 if (pid >= 0) 2038 if (pid >= 0)
2031 XPROCESS (process)->alive = 1; 2039 XPROCESS (process)->alive = 1;
@@ -2040,6 +2048,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
2040 emacs_close (forkin); 2048 emacs_close (forkin);
2041 if (forkin != forkout && forkout >= 0) 2049 if (forkin != forkout && forkout >= 0)
2042 emacs_close (forkout); 2050 emacs_close (forkout);
2051 report_file_errno ("Doing vfork", Qnil, vfork_errno);
2043 } 2052 }
2044 else 2053 else
2045 { 2054 {
@@ -2085,10 +2094,6 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
2085 } 2094 }
2086#endif 2095#endif
2087 } 2096 }
2088
2089 /* Now generate the error if vfork failed. */
2090 if (pid < 0)
2091 report_file_error ("Doing vfork", Qnil);
2092} 2097}
2093 2098
2094void 2099void
@@ -3323,7 +3328,8 @@ usage: (make-network-process &rest ARGS) */)
3323 retry_connect: 3328 retry_connect:
3324#endif 3329#endif
3325 3330
3326 s = socket (lres->ai_family, lres->ai_socktype, lres->ai_protocol); 3331 s = socket (lres->ai_family, lres->ai_socktype | SOCK_CLOEXEC,
3332 lres->ai_protocol);
3327 if (s < 0) 3333 if (s < 0)
3328 { 3334 {
3329 xerrno = errno; 3335 xerrno = errno;
@@ -3447,12 +3453,11 @@ usage: (make-network-process &rest ARGS) */)
3447 3453
3448 len = sizeof xerrno; 3454 len = sizeof xerrno;
3449 eassert (FD_ISSET (s, &fdset)); 3455 eassert (FD_ISSET (s, &fdset));
3450 if (getsockopt (s, SOL_SOCKET, SO_ERROR, &xerrno, &len) == -1) 3456 if (getsockopt (s, SOL_SOCKET, SO_ERROR, &xerrno, &len) < 0)
3451 report_file_error ("getsockopt failed", Qnil); 3457 report_file_error ("getsockopt failed", Qnil);
3452 if (xerrno) 3458 if (xerrno)
3453 errno = xerrno, report_file_error ("error during connect", Qnil); 3459 report_file_errno ("error during connect", Qnil, xerrno);
3454 else 3460 break;
3455 break;
3456 } 3461 }
3457#endif /* !WINDOWSNT */ 3462#endif /* !WINDOWSNT */
3458 3463
@@ -3536,11 +3541,10 @@ usage: (make-network-process &rest ARGS) */)
3536 if (is_non_blocking_client) 3541 if (is_non_blocking_client)
3537 return Qnil; 3542 return Qnil;
3538 3543
3539 errno = xerrno; 3544 report_file_errno ((is_server
3540 if (is_server) 3545 ? "make server process failed"
3541 report_file_error ("make server process failed", contact); 3546 : "make client process failed"),
3542 else 3547 contact, xerrno);
3543 report_file_error ("make client process failed", contact);
3544 } 3548 }
3545 3549
3546 inch = s; 3550 inch = s;
@@ -3713,7 +3717,7 @@ format; see the description of ADDRESS in `make-network-process'. */)
3713 int s; 3717 int s;
3714 Lisp_Object res; 3718 Lisp_Object res;
3715 3719
3716 s = socket (AF_INET, SOCK_STREAM, 0); 3720 s = socket (AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
3717 if (s < 0) 3721 if (s < 0)
3718 return Qnil; 3722 return Qnil;
3719 3723
@@ -3724,14 +3728,14 @@ format; see the description of ADDRESS in `make-network-process'. */)
3724 ifconf.ifc_len = buf_size; 3728 ifconf.ifc_len = buf_size;
3725 if (ioctl (s, SIOCGIFCONF, &ifconf)) 3729 if (ioctl (s, SIOCGIFCONF, &ifconf))
3726 { 3730 {
3727 close (s); 3731 emacs_close (s);
3728 xfree (buf); 3732 xfree (buf);
3729 return Qnil; 3733 return Qnil;
3730 } 3734 }
3731 } 3735 }
3732 while (ifconf.ifc_len == buf_size); 3736 while (ifconf.ifc_len == buf_size);
3733 3737
3734 close (s); 3738 emacs_close (s);
3735 3739
3736 res = Qnil; 3740 res = Qnil;
3737 ifreq = ifconf.ifc_req; 3741 ifreq = ifconf.ifc_req;
@@ -3869,7 +3873,7 @@ FLAGS is the current flags of the interface. */)
3869 error ("interface name too long"); 3873 error ("interface name too long");
3870 strcpy (rq.ifr_name, SSDATA (ifname)); 3874 strcpy (rq.ifr_name, SSDATA (ifname));
3871 3875
3872 s = socket (AF_INET, SOCK_STREAM, 0); 3876 s = socket (AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
3873 if (s < 0) 3877 if (s < 0)
3874 return Qnil; 3878 return Qnil;
3875 3879
@@ -3988,7 +3992,7 @@ FLAGS is the current flags of the interface. */)
3988#endif 3992#endif
3989 res = Fcons (elt, res); 3993 res = Fcons (elt, res);
3990 3994
3991 close (s); 3995 emacs_close (s);
3992 3996
3993 return any ? res : Qnil; 3997 return any ? res : Qnil;
3994} 3998}
@@ -4161,7 +4165,7 @@ server_accept_connection (Lisp_Object server, int channel)
4161 } saddr; 4165 } saddr;
4162 socklen_t len = sizeof saddr; 4166 socklen_t len = sizeof saddr;
4163 4167
4164 s = accept (channel, &saddr.sa, &len); 4168 s = accept4 (channel, &saddr.sa, &len, SOCK_CLOEXEC);
4165 4169
4166 if (s < 0) 4170 if (s < 0)
4167 { 4171 {
@@ -4785,20 +4789,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4785 if (xerrno == EINTR) 4789 if (xerrno == EINTR)
4786 no_avail = 1; 4790 no_avail = 1;
4787 else if (xerrno == EBADF) 4791 else if (xerrno == EBADF)
4788 { 4792 emacs_abort ();
4789#ifdef AIX
4790 /* AIX doesn't handle PTY closure the same way BSD does. On AIX,
4791 the child's closure of the pts gives the parent a SIGHUP, and
4792 the ptc file descriptor is automatically closed,
4793 yielding EBADF here or at select() call above.
4794 So, SIGHUP is ignored (see def of PTY_TTY_NAME_SPRINTF
4795 in m/ibmrt-aix.h), and here we just ignore the select error.
4796 Cleanup occurs c/o status_notify after SIGCHLD. */
4797 no_avail = 1; /* Cannot depend on values returned */
4798#else
4799 emacs_abort ();
4800#endif
4801 }
4802 else 4793 else
4803 error ("select error: %s", emacs_strerror (xerrno)); 4794 error ("select error: %s", emacs_strerror (xerrno));
4804 } 4795 }
@@ -5648,7 +5639,7 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len,
5648 written = emacs_gnutls_write (p, cur_buf, cur_len); 5639 written = emacs_gnutls_write (p, cur_buf, cur_len);
5649 else 5640 else
5650#endif 5641#endif
5651 written = emacs_write (outfd, cur_buf, cur_len); 5642 written = emacs_write_sig (outfd, cur_buf, cur_len);
5652 rv = (written ? 0 : -1); 5643 rv = (written ? 0 : -1);
5653#ifdef ADAPTIVE_READ_BUFFERING 5644#ifdef ADAPTIVE_READ_BUFFERING
5654 if (p->read_output_delay > 0 5645 if (p->read_output_delay > 0
@@ -7010,32 +7001,6 @@ setup_process_coding_systems (Lisp_Object process)
7010#endif 7001#endif
7011} 7002}
7012 7003
7013/* Close all descriptors currently in use for communication
7014 with subprocess. This is used in a newly-forked subprocess
7015 to get rid of irrelevant descriptors. */
7016
7017void
7018close_process_descs (void)
7019{
7020#ifndef DOS_NT
7021 int i;
7022 for (i = 0; i < MAXDESC; i++)
7023 {
7024 Lisp_Object process;
7025 process = chan_process[i];
7026 if (!NILP (process))
7027 {
7028 int in = XPROCESS (process)->infd;
7029 int out = XPROCESS (process)->outfd;
7030 if (in >= 0)
7031 emacs_close (in);
7032 if (out >= 0 && in != out)
7033 emacs_close (out);
7034 }
7035 }
7036#endif
7037}
7038
7039DEFUN ("get-buffer-process", Fget_buffer_process, Sget_buffer_process, 1, 1, 0, 7004DEFUN ("get-buffer-process", Fget_buffer_process, Sget_buffer_process, 1, 1, 0,
7040 doc: /* Return the (or a) process associated with BUFFER. 7005 doc: /* Return the (or a) process associated with BUFFER.
7041BUFFER may be a buffer or the name of one. */) 7006BUFFER may be a buffer or the name of one. */)
diff --git a/src/process.h b/src/process.h
index 52142e55e94..89c7e8b1259 100644
--- a/src/process.h
+++ b/src/process.h
@@ -201,6 +201,14 @@ extern Lisp_Object QCspeed;
201extern Lisp_Object QCbytesize, QCstopbits, QCparity, Qodd, Qeven; 201extern Lisp_Object QCbytesize, QCstopbits, QCparity, Qodd, Qeven;
202extern Lisp_Object QCflowcontrol, Qhw, Qsw, QCsummary; 202extern Lisp_Object QCflowcontrol, Qhw, Qsw, QCsummary;
203 203
204/* Exit statuses for GNU programs that exec other programs. */
205enum
206{
207 EXIT_CANCELED = 125, /* Internal error prior to exec attempt. */
208 EXIT_CANNOT_INVOKE = 126, /* Program located, but not usable. */
209 EXIT_ENOENT = 127 /* Could not find program to exec. */
210};
211
204/* Defined in callproc.c. */ 212/* Defined in callproc.c. */
205 213
206extern void block_child_signal (void); 214extern void block_child_signal (void);
diff --git a/src/profiler.c b/src/profiler.c
index aba81344c68..c86fb47d21d 100644
--- a/src/profiler.c
+++ b/src/profiler.c
@@ -568,12 +568,12 @@ to make room for new entries. */);
568 profiler_log_size = 10000; 568 profiler_log_size = 10000;
569 569
570 DEFSYM (Qprofiler_backtrace_equal, "profiler-backtrace-equal"); 570 DEFSYM (Qprofiler_backtrace_equal, "profiler-backtrace-equal");
571 { 571
572 struct hash_table_test test 572 hashtest_profiler.name = Qprofiler_backtrace_equal;
573 = { Qprofiler_backtrace_equal, Qnil, Qnil, 573 hashtest_profiler.user_hash_function = Qnil;
574 cmpfn_profiler, hashfn_profiler }; 574 hashtest_profiler.user_cmp_function = Qnil;
575 hashtest_profiler = test; 575 hashtest_profiler.cmpfn = cmpfn_profiler;
576 } 576 hashtest_profiler.hashfn = hashfn_profiler;
577 577
578 defsubr (&Sfunction_equal); 578 defsubr (&Sfunction_equal);
579 579
diff --git a/src/regex.c b/src/regex.c
index 73a735cea65..5024f748884 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -531,8 +531,10 @@ init_syntax_once (void)
531/* Type of source-pattern and string chars. */ 531/* Type of source-pattern and string chars. */
532#ifdef _MSC_VER 532#ifdef _MSC_VER
533typedef unsigned char re_char; 533typedef unsigned char re_char;
534typedef const re_char const_re_char;
534#else 535#else
535typedef const unsigned char re_char; 536typedef const unsigned char re_char;
537typedef re_char const_re_char;
536#endif 538#endif
537 539
538typedef char boolean; 540typedef char boolean;
@@ -2019,7 +2021,7 @@ struct range_table_work_area
2019 2021
2020/* Map a string to the char class it names (if any). */ 2022/* Map a string to the char class it names (if any). */
2021re_wctype_t 2023re_wctype_t
2022re_wctype (const re_char *str) 2024re_wctype (const_re_char *str)
2023{ 2025{
2024 const char *string = (const char *) str; 2026 const char *string = (const char *) str;
2025 if (STREQ (string, "alnum")) return RECC_ALNUM; 2027 if (STREQ (string, "alnum")) return RECC_ALNUM;
@@ -2413,7 +2415,8 @@ do { \
2413 } while (0) 2415 } while (0)
2414 2416
2415static reg_errcode_t 2417static reg_errcode_t
2416regex_compile (const re_char *pattern, size_t size, reg_syntax_t syntax, struct re_pattern_buffer *bufp) 2418regex_compile (const_re_char *pattern, size_t size, reg_syntax_t syntax,
2419 struct re_pattern_buffer *bufp)
2417{ 2420{
2418 /* We fetch characters from PATTERN here. */ 2421 /* We fetch characters from PATTERN here. */
2419 register re_wchar_t c, c1; 2422 register re_wchar_t c, c1;
@@ -3769,7 +3772,7 @@ insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, unsigned cha
3769 least one character before the ^. */ 3772 least one character before the ^. */
3770 3773
3771static boolean 3774static boolean
3772at_begline_loc_p (const re_char *pattern, const re_char *p, reg_syntax_t syntax) 3775at_begline_loc_p (const_re_char *pattern, const_re_char *p, reg_syntax_t syntax)
3773{ 3776{
3774 re_char *prev = p - 2; 3777 re_char *prev = p - 2;
3775 boolean odd_backslashes; 3778 boolean odd_backslashes;
@@ -3810,7 +3813,7 @@ at_begline_loc_p (const re_char *pattern, const re_char *p, reg_syntax_t syntax)
3810 at least one character after the $, i.e., `P < PEND'. */ 3813 at least one character after the $, i.e., `P < PEND'. */
3811 3814
3812static boolean 3815static boolean
3813at_endline_loc_p (const re_char *p, const re_char *pend, reg_syntax_t syntax) 3816at_endline_loc_p (const_re_char *p, const_re_char *pend, reg_syntax_t syntax)
3814{ 3817{
3815 re_char *next = p; 3818 re_char *next = p;
3816 boolean next_backslash = *next == '\\'; 3819 boolean next_backslash = *next == '\\';
@@ -3854,7 +3857,8 @@ group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum)
3854 Return -1 if fastmap was not updated accurately. */ 3857 Return -1 if fastmap was not updated accurately. */
3855 3858
3856static int 3859static int
3857analyse_first (const re_char *p, const re_char *pend, char *fastmap, const int multibyte) 3860analyse_first (const_re_char *p, const_re_char *pend, char *fastmap,
3861 const int multibyte)
3858{ 3862{
3859 int j, k; 3863 int j, k;
3860 boolean not; 3864 boolean not;
@@ -4598,7 +4602,7 @@ static int bcmp_translate (re_char *s1, re_char *s2,
4598/* If the operation is a match against one or more chars, 4602/* If the operation is a match against one or more chars,
4599 return a pointer to the next operation, else return NULL. */ 4603 return a pointer to the next operation, else return NULL. */
4600static re_char * 4604static re_char *
4601skip_one_char (const re_char *p) 4605skip_one_char (const_re_char *p)
4602{ 4606{
4603 switch (*p++) 4607 switch (*p++)
4604 { 4608 {
@@ -4640,7 +4644,7 @@ skip_one_char (const re_char *p)
4640 4644
4641/* Jump over non-matching operations. */ 4645/* Jump over non-matching operations. */
4642static re_char * 4646static re_char *
4643skip_noops (const re_char *p, const re_char *pend) 4647skip_noops (const_re_char *p, const_re_char *pend)
4644{ 4648{
4645 int mcnt; 4649 int mcnt;
4646 while (p < pend) 4650 while (p < pend)
@@ -4667,7 +4671,8 @@ skip_noops (const re_char *p, const re_char *pend)
4667 4671
4668/* Non-zero if "p1 matches something" implies "p2 fails". */ 4672/* Non-zero if "p1 matches something" implies "p2 fails". */
4669static int 4673static int
4670mutually_exclusive_p (struct re_pattern_buffer *bufp, const re_char *p1, const re_char *p2) 4674mutually_exclusive_p (struct re_pattern_buffer *bufp, const_re_char *p1,
4675 const_re_char *p2)
4671{ 4676{
4672 re_opcode_t op2; 4677 re_opcode_t op2;
4673 const boolean multibyte = RE_MULTIBYTE_P (bufp); 4678 const boolean multibyte = RE_MULTIBYTE_P (bufp);
@@ -4920,8 +4925,8 @@ WEAK_ALIAS (__re_match_2, re_match_2)
4920/* This is a separate function so that we can force an alloca cleanup 4925/* This is a separate function so that we can force an alloca cleanup
4921 afterwards. */ 4926 afterwards. */
4922static regoff_t 4927static regoff_t
4923re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1, 4928re_match_2_internal (struct re_pattern_buffer *bufp, const_re_char *string1,
4924 size_t size1, const re_char *string2, size_t size2, 4929 size_t size1, const_re_char *string2, size_t size2,
4925 ssize_t pos, struct re_registers *regs, ssize_t stop) 4930 ssize_t pos, struct re_registers *regs, ssize_t stop)
4926{ 4931{
4927 /* General temporaries. */ 4932 /* General temporaries. */
@@ -6263,7 +6268,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1,
6263 bytes; nonzero otherwise. */ 6268 bytes; nonzero otherwise. */
6264 6269
6265static int 6270static int
6266bcmp_translate (const re_char *s1, const re_char *s2, register ssize_t len, 6271bcmp_translate (const_re_char *s1, const_re_char *s2, register ssize_t len,
6267 RE_TRANSLATE_TYPE translate, const int target_multibyte) 6272 RE_TRANSLATE_TYPE translate, const int target_multibyte)
6268{ 6273{
6269 register re_char *p1 = s1, *p2 = s2; 6274 register re_char *p1 = s1, *p2 = s2;
@@ -6432,7 +6437,7 @@ re_exec (const char *s)
6432 the return codes and their meanings.) */ 6437 the return codes and their meanings.) */
6433 6438
6434reg_errcode_t 6439reg_errcode_t
6435regcomp (regex_t *__restrict preg, const char *__restrict pattern, 6440regcomp (regex_t *_Restrict_ preg, const char *_Restrict_ pattern,
6436 int cflags) 6441 int cflags)
6437{ 6442{
6438 reg_errcode_t ret; 6443 reg_errcode_t ret;
@@ -6513,8 +6518,8 @@ WEAK_ALIAS (__regcomp, regcomp)
6513 We return 0 if we find a match and REG_NOMATCH if not. */ 6518 We return 0 if we find a match and REG_NOMATCH if not. */
6514 6519
6515reg_errcode_t 6520reg_errcode_t
6516regexec (const regex_t *__restrict preg, const char *__restrict string, 6521regexec (const regex_t *_Restrict_ preg, const char *_Restrict_ string,
6517 size_t nmatch, regmatch_t pmatch[__restrict_arr], int eflags) 6522 size_t nmatch, regmatch_t pmatch[_Restrict_arr_], int eflags)
6518{ 6523{
6519 regoff_t ret; 6524 regoff_t ret;
6520 struct re_registers regs; 6525 struct re_registers regs;
diff --git a/src/regex.h b/src/regex.h
index 175eed10177..31be0504c9e 100644
--- a/src/regex.h
+++ b/src/regex.h
@@ -528,31 +528,41 @@ extern int re_exec (const char *);
528#endif 528#endif
529 529
530/* GCC 2.95 and later have "__restrict"; C99 compilers have 530/* GCC 2.95 and later have "__restrict"; C99 compilers have
531 "restrict", and "configure" may have defined "restrict". */ 531 "restrict", and "configure" may have defined "restrict".
532#ifndef __restrict 532 Other compilers use __restrict, __restrict__, and _Restrict, and
533# if ! (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)) 533 'configure' might #define 'restrict' to those words, so pick a
534# if defined restrict || 199901L <= __STDC_VERSION__ 534 different name. */
535# define __restrict restrict 535#ifndef _Restrict_
536# else 536# if 199901L <= __STDC_VERSION__
537# define __restrict 537# define _Restrict_ restrict
538# endif 538# elif 2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__)
539# define _Restrict_ __restrict
540# else
541# define _Restrict_
539# endif 542# endif
540#endif 543#endif
541/* For now conditionally define __restrict_arr to expand to nothing. 544/* gcc 3.1 and up support the [restrict] syntax. Don't trust
542 Ideally we would have a test for the compiler which allows defining 545 sys/cdefs.h's definition of __restrict_arr, though, as it
543 it to restrict. */ 546 mishandles gcc -ansi -pedantic. */
544#ifndef __restrict_arr 547#ifndef _Restrict_arr_
545# define __restrict_arr 548# if ((199901L <= __STDC_VERSION__ \
549 || ((3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__)) \
550 && !defined __STRICT_ANSI__)) \
551 && !defined __GNUG__)
552# define _Restrict_arr_ _Restrict_
553# else
554# define _Restrict_arr_
555# endif
546#endif 556#endif
547 557
548/* POSIX compatibility. */ 558/* POSIX compatibility. */
549extern reg_errcode_t regcomp (regex_t *__restrict __preg, 559extern reg_errcode_t regcomp (regex_t *_Restrict_ __preg,
550 const char *__restrict __pattern, 560 const char *_Restrict_ __pattern,
551 int __cflags); 561 int __cflags);
552 562
553extern reg_errcode_t regexec (const regex_t *__restrict __preg, 563extern reg_errcode_t regexec (const regex_t *_Restrict_ __preg,
554 const char *__restrict __string, size_t __nmatch, 564 const char *_Restrict_ __string, size_t __nmatch,
555 regmatch_t __pmatch[__restrict_arr], 565 regmatch_t __pmatch[_Restrict_arr_],
556 int __eflags); 566 int __eflags);
557 567
558extern size_t regerror (int __errcode, const regex_t * __preg, 568extern size_t regerror (int __errcode, const regex_t * __preg,
diff --git a/src/search.c b/src/search.c
index b4e3cca8269..ff47bb2fecf 100644
--- a/src/search.c
+++ b/src/search.c
@@ -22,10 +22,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
22#include <config.h> 22#include <config.h>
23 23
24#include "lisp.h" 24#include "lisp.h"
25#include "syntax.h"
26#include "category.h" 25#include "category.h"
27#include "character.h" 26#include "character.h"
28#include "buffer.h" 27#include "buffer.h"
28#include "syntax.h"
29#include "charset.h" 29#include "charset.h"
30#include "region-cache.h" 30#include "region-cache.h"
31#include "commands.h" 31#include "commands.h"
diff --git a/src/sheap.c b/src/sheap.c
index f8eec753268..54eef60c27d 100644
--- a/src/sheap.c
+++ b/src/sheap.c
@@ -25,7 +25,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
25 25
26#include <unistd.h> 26#include <unistd.h>
27 27
28#ifdef __x86_64__
29#define STATIC_HEAP_SIZE (18 * 1024 * 1024)
30#else
28#define STATIC_HEAP_SIZE (13 * 1024 * 1024) 31#define STATIC_HEAP_SIZE (13 * 1024 * 1024)
32#endif
29 33
30int debug_sheap = 0; 34int debug_sheap = 0;
31 35
diff --git a/src/sound.c b/src/sound.c
index 7f0ede5b398..5ce185ea60e 100644
--- a/src/sound.c
+++ b/src/sound.c
@@ -879,7 +879,7 @@ vox_init (struct sound_device *sd)
879static void 879static void
880vox_write (struct sound_device *sd, const char *buffer, ptrdiff_t nbytes) 880vox_write (struct sound_device *sd, const char *buffer, ptrdiff_t nbytes)
881{ 881{
882 if (emacs_write (sd->fd, buffer, nbytes) != nbytes) 882 if (emacs_write_sig (sd->fd, buffer, nbytes) != nbytes)
883 sound_perror ("Error writing to sound device"); 883 sound_perror ("Error writing to sound device");
884} 884}
885 885
diff --git a/src/syntax.c b/src/syntax.c
index ea15cf68c43..6d52d115889 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -20,6 +20,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21#include <config.h> 21#include <config.h>
22 22
23#define SYNTAX_INLINE EXTERN_INLINE
24
23#include <sys/types.h> 25#include <sys/types.h>
24 26
25#include "lisp.h" 27#include "lisp.h"
@@ -58,54 +60,86 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
58 For style c (like the nested flag), the flag can be placed on any of 60 For style c (like the nested flag), the flag can be placed on any of
59 the chars. */ 61 the chars. */
60 62
61/* These macros extract specific flags from an integer 63/* These functions extract specific flags from an integer
62 that holds the syntax code and the flags. */ 64 that holds the syntax code and the flags. */
63 65
64#define SYNTAX_FLAGS_COMSTART_FIRST(flags) (((flags) >> 16) & 1) 66static bool
65 67SYNTAX_FLAGS_COMSTART_FIRST (int flags)
66#define SYNTAX_FLAGS_COMSTART_SECOND(flags) (((flags) >> 17) & 1) 68{
67 69 return (flags >> 16) & 1;
68#define SYNTAX_FLAGS_COMEND_FIRST(flags) (((flags) >> 18) & 1) 70}
69 71static bool
70#define SYNTAX_FLAGS_COMEND_SECOND(flags) (((flags) >> 19) & 1) 72SYNTAX_FLAGS_COMSTART_SECOND (int flags)
71 73{
72#define SYNTAX_FLAGS_PREFIX(flags) (((flags) >> 20) & 1) 74 return (flags >> 17) & 1;
75}
76static bool
77SYNTAX_FLAGS_COMEND_FIRST (int flags)
78{
79 return (flags >> 18) & 1;
80}
81static bool
82SYNTAX_FLAGS_COMEND_SECOND (int flags)
83{
84 return (flags >> 19) & 1;
85}
86static bool
87SYNTAX_FLAGS_PREFIX (int flags)
88{
89 return (flags >> 20) & 1;
90}
91static bool
92SYNTAX_FLAGS_COMMENT_STYLEB (int flags)
93{
94 return (flags >> 21) & 1;
95}
96static bool
97SYNTAX_FLAGS_COMMENT_STYLEC (int flags)
98{
99 return (flags >> 23) & 1;
100}
101static int
102SYNTAX_FLAGS_COMMENT_STYLEC2 (int flags)
103{
104 return (flags >> 22) & 2; /* SYNTAX_FLAGS_COMMENT_STYLEC (flags) * 2 */
105}
106static bool
107SYNTAX_FLAGS_COMMENT_NESTED (int flags)
108{
109 return (flags >> 22) & 1;
110}
73 111
74#define SYNTAX_FLAGS_COMMENT_STYLEB(flags) (((flags) >> 21) & 1)
75#define SYNTAX_FLAGS_COMMENT_STYLEC(flags) (((flags) >> 23) & 1)
76#define SYNTAX_FLAGS_COMMENT_STYLEC2(flags) (((flags) >> 22) & 2) /* C * 2 */
77/* FLAGS should be the flags of the main char of the comment marker, e.g. 112/* FLAGS should be the flags of the main char of the comment marker, e.g.
78 the second for comstart and the first for comend. */ 113 the second for comstart and the first for comend. */
79#define SYNTAX_FLAGS_COMMENT_STYLE(flags, other_flags) \ 114static int
80 (SYNTAX_FLAGS_COMMENT_STYLEB (flags) \ 115SYNTAX_FLAGS_COMMENT_STYLE (int flags, int other_flags)
81 | SYNTAX_FLAGS_COMMENT_STYLEC2 (flags) \ 116{
82 | SYNTAX_FLAGS_COMMENT_STYLEC2 (other_flags)) 117 return (SYNTAX_FLAGS_COMMENT_STYLEB (flags)
83 118 | SYNTAX_FLAGS_COMMENT_STYLEC2 (flags)
84#define SYNTAX_FLAGS_COMMENT_NESTED(flags) (((flags) >> 22) & 1) 119 | SYNTAX_FLAGS_COMMENT_STYLEC2 (other_flags));
120}
85 121
86/* These macros extract a particular flag for a given character. */ 122/* Extract a particular flag for a given character. */
87 123
88#define SYNTAX_COMEND_FIRST(c) \ 124static bool
89 (SYNTAX_FLAGS_COMEND_FIRST (SYNTAX_WITH_FLAGS (c))) 125SYNTAX_COMEND_FIRST (int c)
90#define SYNTAX_PREFIX(c) (SYNTAX_FLAGS_PREFIX (SYNTAX_WITH_FLAGS (c))) 126{
127 return SYNTAX_FLAGS_COMEND_FIRST (SYNTAX_WITH_FLAGS (c));
128}
91 129
92/* We use these constants in place for comment-style and 130/* We use these constants in place for comment-style and
93 string-ender-char to distinguish comments/strings started by 131 string-ender-char to distinguish comments/strings started by
94 comment_fence and string_fence codes. */ 132 comment_fence and string_fence codes. */
95 133
96#define ST_COMMENT_STYLE (256 + 1) 134enum
97#define ST_STRING_STYLE (256 + 2) 135 {
136 ST_COMMENT_STYLE = 256 + 1,
137 ST_STRING_STYLE = 256 + 2
138 };
98 139
99static Lisp_Object Qsyntax_table_p; 140static Lisp_Object Qsyntax_table_p;
100static Lisp_Object Qsyntax_table, Qscan_error; 141static Lisp_Object Qsyntax_table, Qscan_error;
101 142
102#ifndef __GNUC__
103/* Used as a temporary in SYNTAX_ENTRY and other macros in syntax.h,
104 if not compiled with GCC. No need to mark it, since it is used
105 only very temporarily. */
106Lisp_Object syntax_temp;
107#endif
108
109/* This is the internal form of the parse state used in parse-partial-sexp. */ 143/* This is the internal form of the parse state used in parse-partial-sexp. */
110 144
111struct lisp_parse_state 145struct lisp_parse_state
@@ -162,14 +196,107 @@ bset_syntax_table (struct buffer *b, Lisp_Object val)
162bool 196bool
163syntax_prefix_flag_p (int c) 197syntax_prefix_flag_p (int c)
164{ 198{
165 return SYNTAX_PREFIX (c); 199 return SYNTAX_FLAGS_PREFIX (SYNTAX_WITH_FLAGS (c));
166} 200}
167 201
168struct gl_state_s gl_state; /* Global state of syntax parser. */ 202struct gl_state_s gl_state; /* Global state of syntax parser. */
169 203
170#define INTERVALS_AT_ONCE 10 /* 1 + max-number of intervals 204enum { INTERVALS_AT_ONCE = 10 }; /* 1 + max-number of intervals
171 to scan to property-change. */ 205 to scan to property-change. */
172 206
207/* Set the syntax entry VAL for char C in table TABLE. */
208
209static void
210SET_RAW_SYNTAX_ENTRY (Lisp_Object table, int c, Lisp_Object val)
211{
212 CHAR_TABLE_SET (table, c, val);
213}
214
215/* Set the syntax entry VAL for char-range RANGE in table TABLE.
216 RANGE is a cons (FROM . TO) specifying the range of characters. */
217
218static void
219SET_RAW_SYNTAX_ENTRY_RANGE (Lisp_Object table, Lisp_Object range,
220 Lisp_Object val)
221{
222 Fset_char_table_range (table, range, val);
223}
224
225/* Extract the information from the entry for character C
226 in the current syntax table. */
227
228static Lisp_Object
229SYNTAX_MATCH (int c)
230{
231 Lisp_Object ent = SYNTAX_ENTRY (c);
232 return CONSP (ent) ? XCDR (ent) : Qnil;
233}
234
235/* This should be called with FROM at the start of forward
236 search, or after the last position of the backward search. It
237 makes sure that the first char is picked up with correct table, so
238 one does not need to call UPDATE_SYNTAX_TABLE immediately after the
239 call.
240 Sign of COUNT gives the direction of the search.
241 */
242
243static void
244SETUP_SYNTAX_TABLE (ptrdiff_t from, ptrdiff_t count)
245{
246 SETUP_BUFFER_SYNTAX_TABLE ();
247 gl_state.b_property = BEGV;
248 gl_state.e_property = ZV + 1;
249 gl_state.object = Qnil;
250 gl_state.offset = 0;
251 if (parse_sexp_lookup_properties)
252 if (count > 0 || from > BEGV)
253 update_syntax_table (count > 0 ? from : from - 1, count, 1, Qnil);
254}
255
256/* Same as above, but in OBJECT. If OBJECT is nil, use current buffer.
257 If it is t (which is only used in fast_c_string_match_ignore_case),
258 ignore properties altogether.
259
260 This is meant for regex.c to use. For buffers, regex.c passes arguments
261 to the UPDATE_SYNTAX_TABLE functions which are relative to BEGV.
262 So if it is a buffer, we set the offset field to BEGV. */
263
264void
265SETUP_SYNTAX_TABLE_FOR_OBJECT (Lisp_Object object,
266 ptrdiff_t from, ptrdiff_t count)
267{
268 SETUP_BUFFER_SYNTAX_TABLE ();
269 gl_state.object = object;
270 if (BUFFERP (gl_state.object))
271 {
272 struct buffer *buf = XBUFFER (gl_state.object);
273 gl_state.b_property = 1;
274 gl_state.e_property = BUF_ZV (buf) - BUF_BEGV (buf) + 1;
275 gl_state.offset = BUF_BEGV (buf) - 1;
276 }
277 else if (NILP (gl_state.object))
278 {
279 gl_state.b_property = 1;
280 gl_state.e_property = ZV - BEGV + 1;
281 gl_state.offset = BEGV - 1;
282 }
283 else if (EQ (gl_state.object, Qt))
284 {
285 gl_state.b_property = 0;
286 gl_state.e_property = PTRDIFF_MAX;
287 gl_state.offset = 0;
288 }
289 else
290 {
291 gl_state.b_property = 0;
292 gl_state.e_property = 1 + SCHARS (gl_state.object);
293 gl_state.offset = 0;
294 }
295 if (parse_sexp_lookup_properties)
296 update_syntax_table (from + gl_state.offset - (count <= 0),
297 count, 1, gl_state.object);
298}
299
173/* Update gl_state to an appropriate interval which contains CHARPOS. The 300/* Update gl_state to an appropriate interval which contains CHARPOS. The
174 sign of COUNT give the relative position of CHARPOS wrt the previously 301 sign of COUNT give the relative position of CHARPOS wrt the previously
175 valid interval. If INIT, only [be]_property fields of gl_state are 302 valid interval. If INIT, only [be]_property fields of gl_state are
@@ -1751,7 +1878,7 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim,
1751 } 1878 }
1752 1879
1753 immediate_quit = 1; 1880 immediate_quit = 1;
1754 /* This code may look up syntax tables using macros that rely on the 1881 /* This code may look up syntax tables using functions that rely on the
1755 gl_state object. To make sure this object is not out of date, 1882 gl_state object. To make sure this object is not out of date,
1756 let's initialize it manually. 1883 let's initialize it manually.
1757 We ignore syntax-table text-properties for now, since that's 1884 We ignore syntax-table text-properties for now, since that's
@@ -2426,11 +2553,13 @@ between them, return t; otherwise return nil. */)
2426} 2553}
2427 2554
2428/* Return syntax code of character C if C is an ASCII character 2555/* Return syntax code of character C if C is an ASCII character
2429 or `multibyte_symbol_p' is zero. Otherwise, return Ssymbol. */ 2556 or if MULTIBYTE_SYMBOL_P is false. Otherwise, return Ssymbol. */
2430 2557
2431#define SYNTAX_WITH_MULTIBYTE_CHECK(c) \ 2558static enum syntaxcode
2432 ((ASCII_CHAR_P (c) || !multibyte_symbol_p) \ 2559syntax_multibyte (int c, bool multibyte_symbol_p)
2433 ? SYNTAX (c) : Ssymbol) 2560{
2561 return ASCII_CHAR_P (c) || !multibyte_symbol_p ? SYNTAX (c) : Ssymbol;
2562}
2434 2563
2435static Lisp_Object 2564static Lisp_Object
2436scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) 2565scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
@@ -2441,7 +2570,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2441 int stringterm; 2570 int stringterm;
2442 bool quoted; 2571 bool quoted;
2443 bool mathexit = 0; 2572 bool mathexit = 0;
2444 enum syntaxcode code, temp_code, c_code; 2573 enum syntaxcode code;
2445 EMACS_INT min_depth = depth; /* Err out if depth gets less than this. */ 2574 EMACS_INT min_depth = depth; /* Err out if depth gets less than this. */
2446 int comstyle = 0; /* style of comment encountered */ 2575 int comstyle = 0; /* style of comment encountered */
2447 bool comnested = 0; /* whether the comment is nestable or not */ 2576 bool comnested = 0; /* whether the comment is nestable or not */
@@ -2473,7 +2602,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2473 UPDATE_SYNTAX_TABLE_FORWARD (from); 2602 UPDATE_SYNTAX_TABLE_FORWARD (from);
2474 c = FETCH_CHAR_AS_MULTIBYTE (from_byte); 2603 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
2475 syntax = SYNTAX_WITH_FLAGS (c); 2604 syntax = SYNTAX_WITH_FLAGS (c);
2476 code = SYNTAX_WITH_MULTIBYTE_CHECK (c); 2605 code = syntax_multibyte (c, multibyte_symbol_p);
2477 comstart_first = SYNTAX_FLAGS_COMSTART_FIRST (syntax); 2606 comstart_first = SYNTAX_FLAGS_COMSTART_FIRST (syntax);
2478 comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax); 2607 comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax);
2479 comstyle = SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0); 2608 comstyle = SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0);
@@ -2519,10 +2648,8 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2519 { 2648 {
2520 UPDATE_SYNTAX_TABLE_FORWARD (from); 2649 UPDATE_SYNTAX_TABLE_FORWARD (from);
2521 2650
2522 /* Some compilers can't handle this inside the switch. */
2523 c = FETCH_CHAR_AS_MULTIBYTE (from_byte); 2651 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
2524 c_code = SYNTAX_WITH_MULTIBYTE_CHECK (c); 2652 switch (syntax_multibyte (c, multibyte_symbol_p))
2525 switch (c_code)
2526 { 2653 {
2527 case Scharquote: 2654 case Scharquote:
2528 case Sescape: 2655 case Sescape:
@@ -2594,18 +2721,17 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2594 stringterm = FETCH_CHAR_AS_MULTIBYTE (temp_pos); 2721 stringterm = FETCH_CHAR_AS_MULTIBYTE (temp_pos);
2595 while (1) 2722 while (1)
2596 { 2723 {
2724 enum syntaxcode c_code;
2597 if (from >= stop) 2725 if (from >= stop)
2598 goto lose; 2726 goto lose;
2599 UPDATE_SYNTAX_TABLE_FORWARD (from); 2727 UPDATE_SYNTAX_TABLE_FORWARD (from);
2600 c = FETCH_CHAR_AS_MULTIBYTE (from_byte); 2728 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
2729 c_code = syntax_multibyte (c, multibyte_symbol_p);
2601 if (code == Sstring 2730 if (code == Sstring
2602 ? (c == stringterm 2731 ? c == stringterm && c_code == Sstring
2603 && SYNTAX_WITH_MULTIBYTE_CHECK (c) == Sstring) 2732 : c_code == Sstring_fence)
2604 : SYNTAX_WITH_MULTIBYTE_CHECK (c) == Sstring_fence)
2605 break; 2733 break;
2606 2734
2607 /* Some compilers can't handle this inside the switch. */
2608 c_code = SYNTAX_WITH_MULTIBYTE_CHECK (c);
2609 switch (c_code) 2735 switch (c_code)
2610 { 2736 {
2611 case Scharquote: 2737 case Scharquote:
@@ -2644,7 +2770,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2644 UPDATE_SYNTAX_TABLE_BACKWARD (from); 2770 UPDATE_SYNTAX_TABLE_BACKWARD (from);
2645 c = FETCH_CHAR_AS_MULTIBYTE (from_byte); 2771 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
2646 syntax= SYNTAX_WITH_FLAGS (c); 2772 syntax= SYNTAX_WITH_FLAGS (c);
2647 code = SYNTAX_WITH_MULTIBYTE_CHECK (c); 2773 code = syntax_multibyte (c, multibyte_symbol_p);
2648 if (depth == min_depth) 2774 if (depth == min_depth)
2649 last_good = from; 2775 last_good = from;
2650 comstyle = 0; 2776 comstyle = 0;
@@ -2697,9 +2823,8 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2697 temp_pos--; 2823 temp_pos--;
2698 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); 2824 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1);
2699 c1 = FETCH_CHAR_AS_MULTIBYTE (temp_pos); 2825 c1 = FETCH_CHAR_AS_MULTIBYTE (temp_pos);
2700 temp_code = SYNTAX_WITH_MULTIBYTE_CHECK (c1);
2701 /* Don't allow comment-end to be quoted. */ 2826 /* Don't allow comment-end to be quoted. */
2702 if (temp_code == Sendcomment) 2827 if (syntax_multibyte (c1, multibyte_symbol_p) == Sendcomment)
2703 goto done2; 2828 goto done2;
2704 quoted = char_quoted (from - 1, temp_pos); 2829 quoted = char_quoted (from - 1, temp_pos);
2705 if (quoted) 2830 if (quoted)
@@ -2709,11 +2834,12 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2709 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); 2834 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1);
2710 } 2835 }
2711 c1 = FETCH_CHAR_AS_MULTIBYTE (temp_pos); 2836 c1 = FETCH_CHAR_AS_MULTIBYTE (temp_pos);
2712 temp_code = SYNTAX_WITH_MULTIBYTE_CHECK (c1); 2837 if (! quoted)
2713 if (! (quoted || temp_code == Sword 2838 switch (syntax_multibyte (c1, multibyte_symbol_p))
2714 || temp_code == Ssymbol 2839 {
2715 || temp_code == Squote)) 2840 case Sword: case Ssymbol: case Squote: break;
2716 goto done2; 2841 default: goto done2;
2842 }
2717 DEC_BOTH (from, from_byte); 2843 DEC_BOTH (from, from_byte);
2718 } 2844 }
2719 goto done2; 2845 goto done2;
@@ -2768,10 +2894,12 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2768 goto lose; 2894 goto lose;
2769 DEC_BOTH (from, from_byte); 2895 DEC_BOTH (from, from_byte);
2770 UPDATE_SYNTAX_TABLE_BACKWARD (from); 2896 UPDATE_SYNTAX_TABLE_BACKWARD (from);
2771 if (!char_quoted (from, from_byte) 2897 if (!char_quoted (from, from_byte))
2772 && (c = FETCH_CHAR_AS_MULTIBYTE (from_byte), 2898 {
2773 SYNTAX_WITH_MULTIBYTE_CHECK (c) == code)) 2899 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
2774 break; 2900 if (syntax_multibyte (c, multibyte_symbol_p) == code)
2901 break;
2902 }
2775 } 2903 }
2776 if (code == Sstring_fence && !depth && sexpflag) goto done2; 2904 if (code == Sstring_fence && !depth && sexpflag) goto done2;
2777 break; 2905 break;
@@ -2784,11 +2912,14 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2784 goto lose; 2912 goto lose;
2785 DEC_BOTH (from, from_byte); 2913 DEC_BOTH (from, from_byte);
2786 UPDATE_SYNTAX_TABLE_BACKWARD (from); 2914 UPDATE_SYNTAX_TABLE_BACKWARD (from);
2787 if (!char_quoted (from, from_byte) 2915 if (!char_quoted (from, from_byte))
2788 && (stringterm 2916 {
2789 == (c = FETCH_CHAR_AS_MULTIBYTE (from_byte))) 2917 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
2790 && SYNTAX_WITH_MULTIBYTE_CHECK (c) == Sstring) 2918 if (c == stringterm
2791 break; 2919 && (syntax_multibyte (c, multibyte_symbol_p)
2920 == Sstring))
2921 break;
2922 }
2792 } 2923 }
2793 if (!depth && sexpflag) goto done2; 2924 if (!depth && sexpflag) goto done2;
2794 break; 2925 break;
@@ -2894,7 +3025,7 @@ This includes chars with "quote" or "prefix" syntax (' or p). */)
2894 while (!char_quoted (pos, pos_byte) 3025 while (!char_quoted (pos, pos_byte)
2895 /* Previous statement updates syntax table. */ 3026 /* Previous statement updates syntax table. */
2896 && ((c = FETCH_CHAR_AS_MULTIBYTE (pos_byte), SYNTAX (c) == Squote) 3027 && ((c = FETCH_CHAR_AS_MULTIBYTE (pos_byte), SYNTAX (c) == Squote)
2897 || SYNTAX_PREFIX (c))) 3028 || syntax_prefix_flag_p (c)))
2898 { 3029 {
2899 opoint = pos; 3030 opoint = pos;
2900 opoint_byte = pos_byte; 3031 opoint_byte = pos_byte;
@@ -3117,10 +3248,8 @@ do { prev_from = from; \
3117 symstarted: 3248 symstarted:
3118 while (from < end) 3249 while (from < end)
3119 { 3250 {
3120 /* Some compilers can't handle this inside the switch. */
3121 int symchar = FETCH_CHAR_AS_MULTIBYTE (from_byte); 3251 int symchar = FETCH_CHAR_AS_MULTIBYTE (from_byte);
3122 enum syntaxcode symcharcode = SYNTAX (symchar); 3252 switch (SYNTAX (symchar))
3123 switch (symcharcode)
3124 { 3253 {
3125 case Scharquote: 3254 case Scharquote:
3126 case Sescape: 3255 case Sescape:
@@ -3206,7 +3335,6 @@ do { prev_from = from; \
3206 3335
3207 if (from >= end) goto done; 3336 if (from >= end) goto done;
3208 c = FETCH_CHAR_AS_MULTIBYTE (from_byte); 3337 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
3209 /* Some compilers can't handle this inside the switch. */
3210 c_code = SYNTAX (c); 3338 c_code = SYNTAX (c);
3211 3339
3212 /* Check C_CODE here so that if the char has 3340 /* Check C_CODE here so that if the char has
diff --git a/src/syntax.h b/src/syntax.h
index 58d39b9059c..1b96284af42 100644
--- a/src/syntax.h
+++ b/src/syntax.h
@@ -18,6 +18,10 @@ GNU General Public License for more details.
18You should have received a copy of the GNU General Public License 18You should have received a copy of the GNU General Public License
19along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 19along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21INLINE_HEADER_BEGIN
22#ifndef SYNTAX_INLINE
23# define SYNTAX_INLINE INLINE
24#endif
21 25
22extern void update_syntax_table (ptrdiff_t, EMACS_INT, bool, Lisp_Object); 26extern void update_syntax_table (ptrdiff_t, EMACS_INT, bool, Lisp_Object);
23 27
@@ -54,79 +58,64 @@ enum syntaxcode
54 Smax /* Upper bound on codes that are meaningful */ 58 Smax /* Upper bound on codes that are meaningful */
55 }; 59 };
56 60
57/* Set the syntax entry VAL for char C in table TABLE. */
58
59#define SET_RAW_SYNTAX_ENTRY(table, c, val) \
60 CHAR_TABLE_SET ((table), c, (val))
61 61
62/* Set the syntax entry VAL for char-range RANGE in table TABLE. 62struct gl_state_s
63 RANGE is a cons (FROM . TO) specifying the range of characters. */ 63{
64 Lisp_Object object; /* The object we are scanning. */
65 ptrdiff_t start; /* Where to stop. */
66 ptrdiff_t stop; /* Where to stop. */
67 bool use_global; /* Whether to use global_code
68 or c_s_t. */
69 Lisp_Object global_code; /* Syntax code of current char. */
70 Lisp_Object current_syntax_table; /* Syntax table for current pos. */
71 Lisp_Object old_prop; /* Syntax-table prop at prev pos. */
72 ptrdiff_t b_property; /* First index where c_s_t is valid. */
73 ptrdiff_t e_property; /* First index where c_s_t is
74 not valid. */
75 INTERVAL forward_i; /* Where to start lookup on forward */
76 INTERVAL backward_i; /* or backward movement. The
77 data in c_s_t is valid
78 between these intervals,
79 and possibly at the
80 intervals too, depending
81 on: */
82 /* Offset for positions specified to UPDATE_SYNTAX_TABLE. */
83 ptrdiff_t offset;
84};
64 85
65#define SET_RAW_SYNTAX_ENTRY_RANGE(table, range, val) \ 86extern struct gl_state_s gl_state;
66 Fset_char_table_range ((table), (range), (val))
67 87
68/* SYNTAX_ENTRY fetches the information from the entry for character C 88/* Fetch the information from the entry for character C
69 in syntax table TABLE, or from globally kept data (gl_state). 89 in syntax table TABLE, or from globally kept data (gl_state).
70 Does inheritance. */ 90 Does inheritance. */
71/* CURRENT_SYNTAX_TABLE gives the syntax table valid for current
72 position, it is either the buffer's syntax table, or syntax table
73 found in text properties. */
74 91
92SYNTAX_INLINE Lisp_Object
93SYNTAX_ENTRY (int c)
94{
75#ifdef SYNTAX_ENTRY_VIA_PROPERTY 95#ifdef SYNTAX_ENTRY_VIA_PROPERTY
76# define SYNTAX_ENTRY(c) \ 96 return (gl_state.use_global
77 (gl_state.use_global ? gl_state.global_code : SYNTAX_ENTRY_INT (c)) 97 ? gl_state.global_code
78# define CURRENT_SYNTAX_TABLE gl_state.current_syntax_table 98 : CHAR_TABLE_REF (gl_state.current_syntax_table, c));
79#else 99#else
80# define SYNTAX_ENTRY SYNTAX_ENTRY_INT 100 return CHAR_TABLE_REF (BVAR (current_buffer, syntax_table), c);
81# define CURRENT_SYNTAX_TABLE BVAR (current_buffer, syntax_table)
82#endif 101#endif
83 102}
84#define SYNTAX_ENTRY_INT(c) CHAR_TABLE_REF (CURRENT_SYNTAX_TABLE, (c))
85 103
86/* Extract the information from the entry for character C 104/* Extract the information from the entry for character C
87 in the current syntax table. */ 105 in the current syntax table. */
88 106
89#ifdef __GNUC__ 107SYNTAX_INLINE int
90#define SYNTAX(c) \ 108SYNTAX_WITH_FLAGS (int c)
91 ({ Lisp_Object _syntax_temp; \ 109{
92 _syntax_temp = SYNTAX_ENTRY (c); \ 110 Lisp_Object ent = SYNTAX_ENTRY (c);
93 (CONSP (_syntax_temp) \ 111 return CONSP (ent) ? XINT (XCAR (ent)) : Swhitespace;
94 ? (enum syntaxcode) (XINT (XCAR (_syntax_temp)) & 0xff) \ 112}
95 : Swhitespace); }) 113
96 114SYNTAX_INLINE enum syntaxcode
97#define SYNTAX_WITH_FLAGS(c) \ 115SYNTAX (int c)
98 ({ Lisp_Object _syntax_temp; \ 116{
99 _syntax_temp = SYNTAX_ENTRY (c); \ 117 return SYNTAX_WITH_FLAGS (c) & 0xff;
100 (CONSP (_syntax_temp) \ 118}
101 ? XINT (XCAR (_syntax_temp)) \
102 : Swhitespace); })
103
104#define SYNTAX_MATCH(c) \
105 ({ Lisp_Object _syntax_temp; \
106 _syntax_temp = SYNTAX_ENTRY (c); \
107 (CONSP (_syntax_temp) \
108 ? XCDR (_syntax_temp) \
109 : Qnil); })
110#else
111extern Lisp_Object syntax_temp;
112#define SYNTAX(c) \
113 (syntax_temp = SYNTAX_ENTRY ((c)), \
114 (CONSP (syntax_temp) \
115 ? (enum syntaxcode) (XINT (XCAR (syntax_temp)) & 0xff) \
116 : Swhitespace))
117
118#define SYNTAX_WITH_FLAGS(c) \
119 (syntax_temp = SYNTAX_ENTRY ((c)), \
120 (CONSP (syntax_temp) \
121 ? XINT (XCAR (syntax_temp)) \
122 : Swhitespace))
123
124#define SYNTAX_MATCH(c) \
125 (syntax_temp = SYNTAX_ENTRY ((c)), \
126 (CONSP (syntax_temp) \
127 ? XCDR (syntax_temp) \
128 : Qnil))
129#endif
130 119
131 120
132/* Whether the syntax of the character C has the prefix flag set. */ 121/* Whether the syntax of the character C has the prefix flag set. */
@@ -145,158 +134,65 @@ extern char const syntax_code_spec[16];
145/* Convert the byte offset BYTEPOS into a character position, 134/* Convert the byte offset BYTEPOS into a character position,
146 for the object recorded in gl_state with SETUP_SYNTAX_TABLE_FOR_OBJECT. 135 for the object recorded in gl_state with SETUP_SYNTAX_TABLE_FOR_OBJECT.
147 136
148 The value is meant for use in the UPDATE_SYNTAX_TABLE... macros. 137 The value is meant for use in code that does nothing when
149 These macros do nothing when parse_sexp_lookup_properties is 0, 138 parse_sexp_lookup_properties is 0, so return 0 in that case, for speed. */
150 so we return 0 in that case, for speed. */ 139
151 140SYNTAX_INLINE ptrdiff_t
152#define SYNTAX_TABLE_BYTE_TO_CHAR(bytepos) \ 141SYNTAX_TABLE_BYTE_TO_CHAR (ptrdiff_t bytepos)
153 (! parse_sexp_lookup_properties \ 142{
154 ? 0 \ 143 return (! parse_sexp_lookup_properties
155 : STRINGP (gl_state.object) \ 144 ? 0
156 ? string_byte_to_char (gl_state.object, (bytepos)) \ 145 : STRINGP (gl_state.object)
157 : BUFFERP (gl_state.object) \ 146 ? string_byte_to_char (gl_state.object, bytepos)
158 ? buf_bytepos_to_charpos (XBUFFER (gl_state.object), \ 147 : BUFFERP (gl_state.object)
159 (bytepos) + BUF_BEGV_BYTE (XBUFFER (gl_state.object)) - 1) - BUF_BEGV (XBUFFER (gl_state.object)) + 1 \ 148 ? ((buf_bytepos_to_charpos
160 : NILP (gl_state.object) \ 149 (XBUFFER (gl_state.object),
161 ? BYTE_TO_CHAR ((bytepos) + BEGV_BYTE - 1) - BEGV + 1 \ 150 (bytepos + BUF_BEGV_BYTE (XBUFFER (gl_state.object)) - 1)))
162 : (bytepos)) 151 - BUF_BEGV (XBUFFER (gl_state.object)) + 1)
152 : NILP (gl_state.object)
153 ? BYTE_TO_CHAR (bytepos + BEGV_BYTE - 1) - BEGV + 1
154 : bytepos);
155}
163 156
164/* Make syntax table state (gl_state) good for CHARPOS, assuming it is 157/* Make syntax table state (gl_state) good for CHARPOS, assuming it is
165 currently good for a position before CHARPOS. */ 158 currently good for a position before CHARPOS. */
166 159
167#define UPDATE_SYNTAX_TABLE_FORWARD(charpos) \ 160SYNTAX_INLINE void
168 (parse_sexp_lookup_properties \ 161UPDATE_SYNTAX_TABLE_FORWARD (ptrdiff_t charpos)
169 && (charpos) >= gl_state.e_property \ 162{
170 ? (update_syntax_table ((charpos) + gl_state.offset, 1, 0, \ 163 if (parse_sexp_lookup_properties && charpos >= gl_state.e_property)
171 gl_state.object), \ 164 update_syntax_table (charpos + gl_state.offset, 1, 0, gl_state.object);
172 1) \ 165}
173 : 0)
174 166
175/* Make syntax table state (gl_state) good for CHARPOS, assuming it is 167/* Make syntax table state (gl_state) good for CHARPOS, assuming it is
176 currently good for a position after CHARPOS. */ 168 currently good for a position after CHARPOS. */
177 169
178#define UPDATE_SYNTAX_TABLE_BACKWARD(charpos) \ 170SYNTAX_INLINE void
179 (parse_sexp_lookup_properties \ 171UPDATE_SYNTAX_TABLE_BACKWARD (ptrdiff_t charpos)
180 && (charpos) < gl_state.b_property \ 172{
181 ? (update_syntax_table ((charpos) + gl_state.offset, -1, 0, \ 173 if (parse_sexp_lookup_properties && charpos < gl_state.b_property)
182 gl_state.object), \ 174 update_syntax_table (charpos + gl_state.offset, -1, 0, gl_state.object);
183 1) \ 175}
184 : 0)
185 176
186/* Make syntax table good for CHARPOS. */ 177/* Make syntax table good for CHARPOS. */
187 178
188#define UPDATE_SYNTAX_TABLE(charpos) \ 179SYNTAX_INLINE void
189 (parse_sexp_lookup_properties \ 180UPDATE_SYNTAX_TABLE (ptrdiff_t charpos)
190 && (charpos) < gl_state.b_property \ 181{
191 ? (update_syntax_table ((charpos) + gl_state.offset, -1, 0, \ 182 UPDATE_SYNTAX_TABLE_BACKWARD (charpos);
192 gl_state.object), \ 183 UPDATE_SYNTAX_TABLE_FORWARD (charpos);
193 1) \ 184}
194 : (parse_sexp_lookup_properties \ 185
195 && (charpos) >= gl_state.e_property \ 186/* Set up the buffer-global syntax table. */
196 ? (update_syntax_table ((charpos) + gl_state.offset, 1, 0,\
197 gl_state.object), \
198 1) \
199 : 0))
200
201/* This macro sets up the buffer-global syntax table. */
202#define SETUP_BUFFER_SYNTAX_TABLE() \
203do \
204 { \
205 gl_state.use_global = 0; \
206 gl_state.current_syntax_table = BVAR (current_buffer, syntax_table);\
207 } while (0)
208
209/* This macro should be called with FROM at the start of forward
210 search, or after the last position of the backward search. It
211 makes sure that the first char is picked up with correct table, so
212 one does not need to call UPDATE_SYNTAX_TABLE immediately after the
213 call.
214 Sign of COUNT gives the direction of the search.
215 */
216
217#define SETUP_SYNTAX_TABLE(FROM, COUNT) \
218do \
219 { \
220 SETUP_BUFFER_SYNTAX_TABLE (); \
221 gl_state.b_property = BEGV; \
222 gl_state.e_property = ZV + 1; \
223 gl_state.object = Qnil; \
224 gl_state.offset = 0; \
225 if (parse_sexp_lookup_properties) \
226 if ((COUNT) > 0 || (FROM) > BEGV) \
227 update_syntax_table ((COUNT) > 0 ? (FROM) : (FROM) - 1, (COUNT),\
228 1, Qnil); \
229 } \
230while (0)
231
232/* Same as above, but in OBJECT. If OBJECT is nil, use current buffer.
233 If it is t (which is only used in fast_c_string_match_ignore_case),
234 ignore properties altogether.
235
236 This is meant for regex.c to use. For buffers, regex.c passes arguments
237 to the UPDATE_SYNTAX_TABLE macros which are relative to BEGV.
238 So if it is a buffer, we set the offset field to BEGV. */
239
240#define SETUP_SYNTAX_TABLE_FOR_OBJECT(OBJECT, FROM, COUNT) \
241do \
242 { \
243 SETUP_BUFFER_SYNTAX_TABLE (); \
244 gl_state.object = (OBJECT); \
245 if (BUFFERP (gl_state.object)) \
246 { \
247 struct buffer *buf = XBUFFER (gl_state.object); \
248 gl_state.b_property = 1; \
249 gl_state.e_property = BUF_ZV (buf) - BUF_BEGV (buf) + 1; \
250 gl_state.offset = BUF_BEGV (buf) - 1; \
251 } \
252 else if (NILP (gl_state.object)) \
253 { \
254 gl_state.b_property = 1; \
255 gl_state.e_property = ZV - BEGV + 1; \
256 gl_state.offset = BEGV - 1; \
257 } \
258 else if (EQ (gl_state.object, Qt)) \
259 { \
260 gl_state.b_property = 0; \
261 gl_state.e_property = PTRDIFF_MAX; \
262 gl_state.offset = 0; \
263 } \
264 else \
265 { \
266 gl_state.b_property = 0; \
267 gl_state.e_property = 1 + SCHARS (gl_state.object); \
268 gl_state.offset = 0; \
269 } \
270 if (parse_sexp_lookup_properties) \
271 update_syntax_table (((FROM) + gl_state.offset \
272 + (COUNT > 0 ? 0 : -1)), \
273 COUNT, 1, gl_state.object); \
274 } \
275while (0)
276 187
277struct gl_state_s 188SYNTAX_INLINE void
189SETUP_BUFFER_SYNTAX_TABLE (void)
278{ 190{
279 Lisp_Object object; /* The object we are scanning. */ 191 gl_state.use_global = 0;
280 ptrdiff_t start; /* Where to stop. */ 192 gl_state.current_syntax_table = BVAR (current_buffer, syntax_table);
281 ptrdiff_t stop; /* Where to stop. */ 193}
282 int use_global; /* Whether to use global_code
283 or c_s_t. */
284 Lisp_Object global_code; /* Syntax code of current char. */
285 Lisp_Object current_syntax_table; /* Syntax table for current pos. */
286 Lisp_Object old_prop; /* Syntax-table prop at prev pos. */
287 ptrdiff_t b_property; /* First index where c_s_t is valid. */
288 ptrdiff_t e_property; /* First index where c_s_t is
289 not valid. */
290 INTERVAL forward_i; /* Where to start lookup on forward */
291 INTERVAL backward_i; /* or backward movement. The
292 data in c_s_t is valid
293 between these intervals,
294 and possibly at the
295 intervals too, depending
296 on: */
297 /* Offset for positions specified to UPDATE_SYNTAX_TABLE. */
298 ptrdiff_t offset;
299};
300 194
301extern struct gl_state_s gl_state;
302extern ptrdiff_t scan_words (ptrdiff_t, EMACS_INT); 195extern ptrdiff_t scan_words (ptrdiff_t, EMACS_INT);
196extern void SETUP_SYNTAX_TABLE_FOR_OBJECT (Lisp_Object, ptrdiff_t, ptrdiff_t);
197
198INLINE_HEADER_END
diff --git a/src/sysdep.c b/src/sysdep.c
index 91e941a2050..f614d8bc557 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -31,7 +31,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
31#include <unistd.h> 31#include <unistd.h>
32 32
33#include <c-ctype.h> 33#include <c-ctype.h>
34#include <ignore-value.h>
35#include <utimens.h> 34#include <utimens.h>
36 35
37#include "lisp.h" 36#include "lisp.h"
@@ -103,8 +102,8 @@ int _cdecl _getpid (void);
103#include "syssignal.h" 102#include "syssignal.h"
104#include "systime.h" 103#include "systime.h"
105 104
106static int emacs_get_tty (int, struct emacs_tty *); 105static void emacs_get_tty (int, struct emacs_tty *);
107static int emacs_set_tty (int, struct emacs_tty *, int); 106static int emacs_set_tty (int, struct emacs_tty *, bool);
108 107
109/* ULLONG_MAX is missing on Red Hat Linux 7.3; see Bug#11781. */ 108/* ULLONG_MAX is missing on Red Hat Linux 7.3; see Bug#11781. */
110#ifndef ULLONG_MAX 109#ifndef ULLONG_MAX
@@ -538,13 +537,11 @@ sys_subshell (void)
538 if (str && chdir ((char *) str) != 0) 537 if (str && chdir ((char *) str) != 0)
539 { 538 {
540#ifndef DOS_NT 539#ifndef DOS_NT
541 ignore_value (write (1, "Can't chdir\n", 12)); 540 emacs_perror ((char *) str);
542 _exit (1); 541 _exit (EXIT_CANCELED);
543#endif 542#endif
544 } 543 }
545 544
546 close_process_descs (); /* Close Emacs's pipes/ptys */
547
548#ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida */ 545#ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida */
549 { 546 {
550 char *epwd = getenv ("PWD"); 547 char *epwd = getenv ("PWD");
@@ -572,8 +569,8 @@ sys_subshell (void)
572 write (1, "Can't execute subshell", 22); 569 write (1, "Can't execute subshell", 22);
573#else /* not WINDOWSNT */ 570#else /* not WINDOWSNT */
574 execlp (sh, sh, (char *) 0); 571 execlp (sh, sh, (char *) 0);
575 ignore_value (write (1, "Can't execute subshell", 22)); 572 emacs_perror (sh);
576 _exit (1); 573 _exit (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
577#endif /* not WINDOWSNT */ 574#endif /* not WINDOWSNT */
578#endif /* not MSDOS */ 575#endif /* not MSDOS */
579 } 576 }
@@ -772,31 +769,26 @@ widen_foreground_group (int fd)
772 769
773/* Getting and setting emacs_tty structures. */ 770/* Getting and setting emacs_tty structures. */
774 771
775/* Set *TC to the parameters associated with the terminal FD. 772/* Set *TC to the parameters associated with the terminal FD,
776 Return zero if all's well, or -1 if we ran into an error we 773 or clear it if the parameters are not available. */
777 couldn't deal with. */ 774static void
778int
779emacs_get_tty (int fd, struct emacs_tty *settings) 775emacs_get_tty (int fd, struct emacs_tty *settings)
780{ 776{
781 /* Retrieve the primary parameters - baud rate, character size, etcetera. */ 777 /* Retrieve the primary parameters - baud rate, character size, etcetera. */
782#ifndef DOS_NT 778#ifndef DOS_NT
783 /* We have those nifty POSIX tcmumbleattr functions. */ 779 /* We have those nifty POSIX tcmumbleattr functions. */
784 memset (&settings->main, 0, sizeof (settings->main)); 780 memset (&settings->main, 0, sizeof (settings->main));
785 if (tcgetattr (fd, &settings->main) < 0) 781 tcgetattr (fd, &settings->main);
786 return -1;
787#endif 782#endif
788
789 /* We have survived the tempest. */
790 return 0;
791} 783}
792 784
793 785
794/* Set the parameters of the tty on FD according to the contents of 786/* Set the parameters of the tty on FD according to the contents of
795 *SETTINGS. If FLUSHP is non-zero, we discard input. 787 *SETTINGS. If FLUSHP, discard input.
796 Return 0 if all went well, and -1 if anything failed. */ 788 Return 0 if all went well, and -1 (setting errno) if anything failed. */
797 789
798int 790static int
799emacs_set_tty (int fd, struct emacs_tty *settings, int flushp) 791emacs_set_tty (int fd, struct emacs_tty *settings, bool flushp)
800{ 792{
801 /* Set the primary parameters - baud rate, character size, etcetera. */ 793 /* Set the primary parameters - baud rate, character size, etcetera. */
802#ifndef DOS_NT 794#ifndef DOS_NT
@@ -1121,10 +1113,10 @@ init_sys_modes (struct tty_display_info *tty_out)
1121 tty_out->term_initted = 1; 1113 tty_out->term_initted = 1;
1122} 1114}
1123 1115
1124/* Return nonzero if safe to use tabs in output. 1116/* Return true if safe to use tabs in output.
1125 At the time this is called, init_sys_modes has not been done yet. */ 1117 At the time this is called, init_sys_modes has not been done yet. */
1126 1118
1127int 1119bool
1128tabs_safe_p (int fd) 1120tabs_safe_p (int fd)
1129{ 1121{
1130 struct emacs_tty etty; 1122 struct emacs_tty etty;
@@ -1378,8 +1370,10 @@ init_system_name (void)
1378 uname (&uts); 1370 uname (&uts);
1379 Vsystem_name = build_string (uts.nodename); 1371 Vsystem_name = build_string (uts.nodename);
1380#else /* HAVE_GETHOSTNAME */ 1372#else /* HAVE_GETHOSTNAME */
1381 unsigned int hostname_size = 256; 1373 char *hostname_alloc = NULL;
1382 char *hostname = alloca (hostname_size); 1374 char hostname_buf[256];
1375 ptrdiff_t hostname_size = sizeof hostname_buf;
1376 char *hostname = hostname_buf;
1383 1377
1384 /* Try to get the host name; if the buffer is too short, try 1378 /* Try to get the host name; if the buffer is too short, try
1385 again. Apparently, the only indication gethostname gives of 1379 again. Apparently, the only indication gethostname gives of
@@ -1394,8 +1388,8 @@ init_system_name (void)
1394 if (strlen (hostname) < hostname_size - 1) 1388 if (strlen (hostname) < hostname_size - 1)
1395 break; 1389 break;
1396 1390
1397 hostname_size <<= 1; 1391 hostname = hostname_alloc = xpalloc (hostname_alloc, &hostname_size, 1,
1398 hostname = alloca (hostname_size); 1392 min (PTRDIFF_MAX, SIZE_MAX), 1);
1399 } 1393 }
1400#ifdef HAVE_SOCKETS 1394#ifdef HAVE_SOCKETS
1401 /* Turn the hostname into the official, fully-qualified hostname. 1395 /* Turn the hostname into the official, fully-qualified hostname.
@@ -1440,7 +1434,13 @@ init_system_name (void)
1440 } 1434 }
1441 if (it) 1435 if (it)
1442 { 1436 {
1443 hostname = alloca (strlen (it->ai_canonname) + 1); 1437 ptrdiff_t len = strlen (it->ai_canonname);
1438 if (hostname_size <= len)
1439 {
1440 hostname_size = len + 1;
1441 hostname = hostname_alloc = xrealloc (hostname_alloc,
1442 hostname_size);
1443 }
1444 strcpy (hostname, it->ai_canonname); 1444 strcpy (hostname, it->ai_canonname);
1445 } 1445 }
1446 freeaddrinfo (res); 1446 freeaddrinfo (res);
@@ -1487,10 +1487,11 @@ init_system_name (void)
1487 } 1487 }
1488#endif /* HAVE_SOCKETS */ 1488#endif /* HAVE_SOCKETS */
1489 Vsystem_name = build_string (hostname); 1489 Vsystem_name = build_string (hostname);
1490 xfree (hostname_alloc);
1490#endif /* HAVE_GETHOSTNAME */ 1491#endif /* HAVE_GETHOSTNAME */
1491 { 1492 {
1492 unsigned char *p; 1493 char *p;
1493 for (p = SDATA (Vsystem_name); *p; p++) 1494 for (p = SSDATA (Vsystem_name); *p; p++)
1494 if (*p == ' ' || *p == '\t') 1495 if (*p == ' ' || *p == '\t')
1495 *p = '-'; 1496 *p = '-';
1496 } 1497 }
@@ -2136,10 +2137,10 @@ emacs_backtrace (int backtrace_limit)
2136 2137
2137 if (npointers) 2138 if (npointers)
2138 { 2139 {
2139 ignore_value (write (STDERR_FILENO, "\nBacktrace:\n", 12)); 2140 emacs_write (STDERR_FILENO, "\nBacktrace:\n", 12);
2140 backtrace_symbols_fd (buffer, npointers, STDERR_FILENO); 2141 backtrace_symbols_fd (buffer, npointers, STDERR_FILENO);
2141 if (bounded_limit < npointers) 2142 if (bounded_limit < npointers)
2142 ignore_value (write (STDERR_FILENO, "...\n", 4)); 2143 emacs_write (STDERR_FILENO, "...\n", 4);
2143 } 2144 }
2144} 2145}
2145 2146
@@ -2152,6 +2153,8 @@ emacs_abort (void)
2152#endif 2153#endif
2153 2154
2154/* Open FILE for Emacs use, using open flags OFLAG and mode MODE. 2155/* Open FILE for Emacs use, using open flags OFLAG and mode MODE.
2156 Arrange for subprograms to not inherit the file descriptor.
2157 Prefer a method that is multithread-safe, if available.
2155 Do not fail merely because the open was interrupted by a signal. 2158 Do not fail merely because the open was interrupted by a signal.
2156 Allow the user to quit. */ 2159 Allow the user to quit. */
2157 2160
@@ -2159,8 +2162,11 @@ int
2159emacs_open (const char *file, int oflags, int mode) 2162emacs_open (const char *file, int oflags, int mode)
2160{ 2163{
2161 int fd; 2164 int fd;
2165 oflags |= O_CLOEXEC;
2162 while ((fd = open (file, oflags, mode)) < 0 && errno == EINTR) 2166 while ((fd = open (file, oflags, mode)) < 0 && errno == EINTR)
2163 QUIT; 2167 QUIT;
2168 if (! O_CLOEXEC && 0 <= fd)
2169 fcntl (fd, F_SETFD, FD_CLOEXEC);
2164 return fd; 2170 return fd;
2165} 2171}
2166 2172
@@ -2170,29 +2176,84 @@ emacs_open (const char *file, int oflags, int mode)
2170FILE * 2176FILE *
2171emacs_fopen (char const *file, char const *mode) 2177emacs_fopen (char const *file, char const *mode)
2172{ 2178{
2173 FILE *fp; 2179 int fd, omode, oflags;
2174 while (! (fp = fopen (file, mode)) && errno == EINTR) 2180 int bflag = 0;
2175 QUIT; 2181 char const *m = mode;
2176 return fp; 2182
2183 switch (*m++)
2184 {
2185 case 'r': omode = O_RDONLY; oflags = 0; break;
2186 case 'w': omode = O_WRONLY; oflags = O_CREAT | O_TRUNC; break;
2187 case 'a': omode = O_WRONLY; oflags = O_CREAT | O_APPEND; break;
2188 default: emacs_abort ();
2189 }
2190
2191 while (*m)
2192 switch (*m++)
2193 {
2194 case '+': omode = O_RDWR; break;
2195 case 'b': bflag = O_BINARY; break;
2196 case 't': bflag = O_TEXT; break;
2197 default: /* Ignore. */ break;
2198 }
2199
2200 fd = emacs_open (file, omode | oflags | bflag, 0666);
2201 return fd < 0 ? 0 : fdopen (fd, mode);
2177} 2202}
2178 2203
2179int 2204/* Approximate posix_close and POSIX_CLOSE_RESTART well enough for Emacs.
2180emacs_close (int fd) 2205 For the background behind this mess, please see Austin Group defect 529
2206 <http://austingroupbugs.net/view.php?id=529>. */
2207
2208#ifndef POSIX_CLOSE_RESTART
2209# define POSIX_CLOSE_RESTART 1
2210static int
2211posix_close (int fd, int flag)
2181{ 2212{
2182 int did_retry = 0; 2213 /* Only the POSIX_CLOSE_RESTART case is emulated. */
2183 register int rtnval; 2214 eassert (flag == POSIX_CLOSE_RESTART);
2184 2215
2185 while ((rtnval = close (fd)) == -1 2216 /* Things are tricky if close (fd) returns -1 with errno == EINTR
2186 && (errno == EINTR)) 2217 on a system that does not define POSIX_CLOSE_RESTART.
2187 did_retry = 1;
2188 2218
2189 /* If close is interrupted SunOS 4.1 may or may not have closed the 2219 In this case, in some systems (e.g., GNU/Linux, AIX) FD is
2190 file descriptor. If it did the second close will fail with 2220 closed, and retrying the close could inadvertently close a file
2191 errno = EBADF. That means we have succeeded. */ 2221 descriptor allocated by some other thread. In other systems
2192 if (rtnval == -1 && did_retry && errno == EBADF) 2222 (e.g., HP/UX) FD is not closed. And in still other systems
2193 return 0; 2223 (e.g., OS X, Solaris), maybe FD is closed, maybe not, and in a
2224 multithreaded program there can be no way to tell.
2194 2225
2195 return rtnval; 2226 So, in this case, pretend that the close succeeded. This works
2227 well on systems like GNU/Linux that close FD. Although it may
2228 leak a file descriptor on other systems, the leak is unlikely and
2229 it's better to leak than to close a random victim. */
2230 return close (fd) == 0 || errno == EINTR ? 0 : -1;
2231}
2232#endif
2233
2234/* Close FD, retrying if interrupted. If successful, return 0;
2235 otherwise, return -1 and set errno to a non-EINTR value. Consider
2236 an EINPROGRESS error to be successful, as that's merely a signal
2237 arriving. FD is always closed when this function returns, even
2238 when it returns -1.
2239
2240 Do not call this function if FD is nonnegative and might already be closed,
2241 as that might close an innocent victim opened by some other thread. */
2242
2243int
2244emacs_close (int fd)
2245{
2246 while (1)
2247 {
2248 int r = posix_close (fd, POSIX_CLOSE_RESTART);
2249 if (r == 0)
2250 return r;
2251 if (!POSIX_CLOSE_RESTART || errno != EINTR)
2252 {
2253 eassert (errno != EBADF || fd < 0);
2254 return errno == EINPROGRESS ? 0 : r;
2255 }
2256 }
2196} 2257}
2197 2258
2198/* Maximum number of bytes to read or write in a single system call. 2259/* Maximum number of bytes to read or write in a single system call.
@@ -2224,27 +2285,26 @@ emacs_read (int fildes, char *buf, ptrdiff_t nbyte)
2224} 2285}
2225 2286
2226/* Write to FILEDES from a buffer BUF with size NBYTE, retrying if interrupted 2287/* Write to FILEDES from a buffer BUF with size NBYTE, retrying if interrupted
2227 or if a partial write occurs. Return the number of bytes written, setting 2288 or if a partial write occurs. If interrupted, process pending
2289 signals if PROCESS SIGNALS. Return the number of bytes written, setting
2228 errno if this is less than NBYTE. */ 2290 errno if this is less than NBYTE. */
2229ptrdiff_t 2291static ptrdiff_t
2230emacs_write (int fildes, const char *buf, ptrdiff_t nbyte) 2292emacs_full_write (int fildes, char const *buf, ptrdiff_t nbyte,
2293 bool process_signals)
2231{ 2294{
2232 ssize_t rtnval; 2295 ptrdiff_t bytes_written = 0;
2233 ptrdiff_t bytes_written;
2234
2235 bytes_written = 0;
2236 2296
2237 while (nbyte > 0) 2297 while (nbyte > 0)
2238 { 2298 {
2239 rtnval = write (fildes, buf, min (nbyte, MAX_RW_COUNT)); 2299 ssize_t n = write (fildes, buf, min (nbyte, MAX_RW_COUNT));
2240 2300
2241 if (rtnval < 0) 2301 if (n < 0)
2242 { 2302 {
2243 if (errno == EINTR) 2303 if (errno == EINTR)
2244 { 2304 {
2245 /* I originally used `QUIT' but that might causes files to 2305 /* I originally used `QUIT' but that might causes files to
2246 be truncated if you hit C-g in the middle of it. --Stef */ 2306 be truncated if you hit C-g in the middle of it. --Stef */
2247 if (pending_signals) 2307 if (process_signals && pending_signals)
2248 process_pending_signals (); 2308 process_pending_signals ();
2249 continue; 2309 continue;
2250 } 2310 }
@@ -2252,12 +2312,57 @@ emacs_write (int fildes, const char *buf, ptrdiff_t nbyte)
2252 break; 2312 break;
2253 } 2313 }
2254 2314
2255 buf += rtnval; 2315 buf += n;
2256 nbyte -= rtnval; 2316 nbyte -= n;
2257 bytes_written += rtnval; 2317 bytes_written += n;
2258 } 2318 }
2259 2319
2260 return (bytes_written); 2320 return bytes_written;
2321}
2322
2323/* Write to FILEDES from a buffer BUF with size NBYTE, retrying if
2324 interrupted or if a partial write occurs. Return the number of
2325 bytes written, setting errno if this is less than NBYTE. */
2326ptrdiff_t
2327emacs_write (int fildes, char const *buf, ptrdiff_t nbyte)
2328{
2329 return emacs_full_write (fildes, buf, nbyte, 0);
2330}
2331
2332/* Like emacs_write, but also process pending signals if interrupted. */
2333ptrdiff_t
2334emacs_write_sig (int fildes, char const *buf, ptrdiff_t nbyte)
2335{
2336 return emacs_full_write (fildes, buf, nbyte, 1);
2337}
2338
2339/* Write a diagnostic to standard error that contains MESSAGE and a
2340 string derived from errno. Preserve errno. Do not buffer stderr.
2341 Do not process pending signals if interrupted. */
2342void
2343emacs_perror (char const *message)
2344{
2345 int err = errno;
2346 char const *error_string = strerror (err);
2347 char const *command = (initial_argv && initial_argv[0]
2348 ? initial_argv[0] : "emacs");
2349 /* Write it out all at once, if it's short; this is less likely to
2350 be interleaved with other output. */
2351 char buf[BUFSIZ];
2352 int nbytes = snprintf (buf, sizeof buf, "%s: %s: %s\n",
2353 command, message, error_string);
2354 if (0 <= nbytes && nbytes < BUFSIZ)
2355 emacs_write (STDERR_FILENO, buf, nbytes);
2356 else
2357 {
2358 emacs_write (STDERR_FILENO, command, strlen (command));
2359 emacs_write (STDERR_FILENO, ": ", 2);
2360 emacs_write (STDERR_FILENO, message, strlen (message));
2361 emacs_write (STDERR_FILENO, ": ", 2);
2362 emacs_write (STDERR_FILENO, error_string, strlen (error_string));
2363 emacs_write (STDERR_FILENO, "\n", 1);
2364 }
2365 errno = err;
2261} 2366}
2262 2367
2263/* Return a struct timeval that is roughly equivalent to T. 2368/* Return a struct timeval that is roughly equivalent to T.
@@ -2611,7 +2716,7 @@ list_system_processes (void)
2611 2716
2612#endif /* !defined (WINDOWSNT) */ 2717#endif /* !defined (WINDOWSNT) */
2613 2718
2614#ifdef GNU_LINUX 2719#if defined GNU_LINUX && defined HAVE_LONG_LONG_INT
2615static EMACS_TIME 2720static EMACS_TIME
2616time_from_jiffies (unsigned long long tval, long hz) 2721time_from_jiffies (unsigned long long tval, long hz)
2617{ 2722{
diff --git a/src/systime.h b/src/systime.h
index 0e611a3f5e3..657f2cca11f 100644
--- a/src/systime.h
+++ b/src/systime.h
@@ -67,7 +67,9 @@ SYSTIME_INLINE time_t *emacs_secs_addr (EMACS_TIME *t) { return &t->tv_sec; }
67SYSTIME_INLINE EMACS_TIME 67SYSTIME_INLINE EMACS_TIME
68make_emacs_time (time_t s, int ns) 68make_emacs_time (time_t s, int ns)
69{ 69{
70 EMACS_TIME r = { s, ns }; 70 EMACS_TIME r;
71 r.tv_sec = s;
72 r.tv_nsec = ns;
71 return r; 73 return r;
72} 74}
73 75
@@ -75,7 +77,9 @@ make_emacs_time (time_t s, int ns)
75SYSTIME_INLINE EMACS_TIME 77SYSTIME_INLINE EMACS_TIME
76invalid_emacs_time (void) 78invalid_emacs_time (void)
77{ 79{
78 EMACS_TIME r = { 0, -1 }; 80 EMACS_TIME r;
81 r.tv_sec = 0;
82 r.tv_nsec = -1;
79 return r; 83 return r;
80} 84}
81 85
@@ -166,21 +170,6 @@ EMACS_TIME_EQ (EMACS_TIME t1, EMACS_TIME t2)
166 return timespec_cmp (t1, t2) == 0; 170 return timespec_cmp (t1, t2) == 0;
167} 171}
168SYSTIME_INLINE int 172SYSTIME_INLINE int
169EMACS_TIME_NE (EMACS_TIME t1, EMACS_TIME t2)
170{
171 return timespec_cmp (t1, t2) != 0;
172}
173SYSTIME_INLINE int
174EMACS_TIME_GT (EMACS_TIME t1, EMACS_TIME t2)
175{
176 return timespec_cmp (t1, t2) > 0;
177}
178SYSTIME_INLINE int
179EMACS_TIME_GE (EMACS_TIME t1, EMACS_TIME t2)
180{
181 return timespec_cmp (t1, t2) >= 0;
182}
183SYSTIME_INLINE int
184EMACS_TIME_LT (EMACS_TIME t1, EMACS_TIME t2) 173EMACS_TIME_LT (EMACS_TIME t1, EMACS_TIME t2)
185{ 174{
186 return timespec_cmp (t1, t2) < 0; 175 return timespec_cmp (t1, t2) < 0;
diff --git a/src/term.c b/src/term.c
index 39d143564c6..b6878a0abd1 100644
--- a/src/term.c
+++ b/src/term.c
@@ -71,13 +71,13 @@ static void tty_turn_off_highlight (struct tty_display_info *);
71static void tty_show_cursor (struct tty_display_info *); 71static void tty_show_cursor (struct tty_display_info *);
72static void tty_hide_cursor (struct tty_display_info *); 72static void tty_hide_cursor (struct tty_display_info *);
73static void tty_background_highlight (struct tty_display_info *tty); 73static void tty_background_highlight (struct tty_display_info *tty);
74static struct terminal *get_tty_terminal (Lisp_Object, int); 74static struct terminal *get_tty_terminal (Lisp_Object, bool);
75static void clear_tty_hooks (struct terminal *terminal); 75static void clear_tty_hooks (struct terminal *terminal);
76static void set_tty_hooks (struct terminal *terminal); 76static void set_tty_hooks (struct terminal *terminal);
77static void dissociate_if_controlling_tty (int fd); 77static void dissociate_if_controlling_tty (int fd);
78static void delete_tty (struct terminal *); 78static void delete_tty (struct terminal *);
79static _Noreturn void maybe_fatal (int must_succeed, struct terminal *terminal, 79static _Noreturn void maybe_fatal (bool, struct terminal *,
80 const char *str1, const char *str2, ...) 80 const char *, const char *, ...)
81 ATTRIBUTE_FORMAT_PRINTF (3, 5) ATTRIBUTE_FORMAT_PRINTF (4, 5); 81 ATTRIBUTE_FORMAT_PRINTF (3, 5) ATTRIBUTE_FORMAT_PRINTF (4, 5);
82static _Noreturn void vfatal (const char *str, va_list ap) 82static _Noreturn void vfatal (const char *str, va_list ap)
83 ATTRIBUTE_FORMAT_PRINTF (1, 0); 83 ATTRIBUTE_FORMAT_PRINTF (1, 0);
@@ -85,8 +85,7 @@ static _Noreturn void vfatal (const char *str, va_list ap)
85 85
86#define OUTPUT(tty, a) \ 86#define OUTPUT(tty, a) \
87 emacs_tputs ((tty), a, \ 87 emacs_tputs ((tty), a, \
88 (int) (FRAME_LINES (XFRAME (selected_frame)) \ 88 FRAME_LINES (XFRAME (selected_frame)) - curY (tty), \
89 - curY (tty)), \
90 cmputc) 89 cmputc)
91 90
92#define OUTPUT1(tty, a) emacs_tputs ((tty), a, 1, cmputc) 91#define OUTPUT1(tty, a) emacs_tputs ((tty), a, 1, cmputc)
@@ -695,7 +694,7 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len)
695{ 694{
696 unsigned char *conversion_buffer; 695 unsigned char *conversion_buffer;
697 struct coding_system *coding; 696 struct coding_system *coding;
698 size_t n, stringlen; 697 int n, stringlen;
699 698
700 struct tty_display_info *tty = FRAME_TTY (f); 699 struct tty_display_info *tty = FRAME_TTY (f);
701 700
@@ -1431,7 +1430,7 @@ static void append_glyph (struct it *);
1431static void append_composite_glyph (struct it *); 1430static void append_composite_glyph (struct it *);
1432static void produce_composite_glyph (struct it *); 1431static void produce_composite_glyph (struct it *);
1433static void append_glyphless_glyph (struct it *, int, const char *); 1432static void append_glyphless_glyph (struct it *, int, const char *);
1434static void produce_glyphless_glyph (struct it *, int, Lisp_Object); 1433static void produce_glyphless_glyph (struct it *, Lisp_Object);
1435 1434
1436/* Append glyphs to IT's glyph_row. Called from produce_glyphs for 1435/* Append glyphs to IT's glyph_row. Called from produce_glyphs for
1437 terminal frames if IT->glyph_row != NULL. IT->char_to_display is 1436 terminal frames if IT->glyph_row != NULL. IT->char_to_display is
@@ -1551,7 +1550,7 @@ produce_glyphs (struct it *it)
1551 1550
1552 if (it->what == IT_GLYPHLESS) 1551 if (it->what == IT_GLYPHLESS)
1553 { 1552 {
1554 produce_glyphless_glyph (it, 0, Qnil); 1553 produce_glyphless_glyph (it, Qnil);
1555 goto done; 1554 goto done;
1556 } 1555 }
1557 1556
@@ -1620,7 +1619,7 @@ produce_glyphs (struct it *it)
1620 Lisp_Object acronym = lookup_glyphless_char_display (-1, it); 1619 Lisp_Object acronym = lookup_glyphless_char_display (-1, it);
1621 1620
1622 eassert (it->what == IT_GLYPHLESS); 1621 eassert (it->what == IT_GLYPHLESS);
1623 produce_glyphless_glyph (it, 1, acronym); 1622 produce_glyphless_glyph (it, acronym);
1624 } 1623 }
1625 } 1624 }
1626 1625
@@ -1794,14 +1793,12 @@ append_glyphless_glyph (struct it *it, int face_id, const char *str)
1794 the character. See the description of enum 1793 the character. See the description of enum
1795 glyphless_display_method in dispextern.h for the details. 1794 glyphless_display_method in dispextern.h for the details.
1796 1795
1797 FOR_NO_FONT is nonzero if and only if this is for a character that 1796 ACRONYM, if non-nil, is an acronym string for the character.
1798 is not supported by the coding system of the terminal. ACRONYM, if
1799 non-nil, is an acronym string for the character.
1800 1797
1801 The glyphs actually produced are of type CHAR_GLYPH. */ 1798 The glyphs actually produced are of type CHAR_GLYPH. */
1802 1799
1803static void 1800static void
1804produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym) 1801produce_glyphless_glyph (struct it *it, Lisp_Object acronym)
1805{ 1802{
1806 int face_id; 1803 int face_id;
1807 int len; 1804 int len;
@@ -1968,7 +1965,7 @@ turn_on_face (struct frame *f, int face_id)
1968 ts = tty->standout_mode ? tty->TS_set_background : tty->TS_set_foreground; 1965 ts = tty->standout_mode ? tty->TS_set_background : tty->TS_set_foreground;
1969 if (fg >= 0 && ts) 1966 if (fg >= 0 && ts)
1970 { 1967 {
1971 p = tparam (ts, NULL, 0, (int) fg, 0, 0, 0); 1968 p = tparam (ts, NULL, 0, fg, 0, 0, 0);
1972 OUTPUT (tty, p); 1969 OUTPUT (tty, p);
1973 xfree (p); 1970 xfree (p);
1974 } 1971 }
@@ -1976,7 +1973,7 @@ turn_on_face (struct frame *f, int face_id)
1976 ts = tty->standout_mode ? tty->TS_set_foreground : tty->TS_set_background; 1973 ts = tty->standout_mode ? tty->TS_set_foreground : tty->TS_set_background;
1977 if (bg >= 0 && ts) 1974 if (bg >= 0 && ts)
1978 { 1975 {
1979 p = tparam (ts, NULL, 0, (int) bg, 0, 0, 0); 1976 p = tparam (ts, NULL, 0, bg, 0, 0, 0);
1980 OUTPUT (tty, p); 1977 OUTPUT (tty, p);
1981 xfree (p); 1978 xfree (p);
1982 } 1979 }
@@ -2027,11 +2024,11 @@ turn_off_face (struct frame *f, int face_id)
2027} 2024}
2028 2025
2029 2026
2030/* Return non-zero if the terminal on frame F supports all of the 2027/* Return true if the terminal on frame F supports all of the
2031 capabilities in CAPS simultaneously, with foreground and background 2028 capabilities in CAPS simultaneously, with foreground and background
2032 colors FG and BG. */ 2029 colors FG and BG. */
2033 2030
2034int 2031bool
2035tty_capable_p (struct tty_display_info *tty, unsigned int caps, 2032tty_capable_p (struct tty_display_info *tty, unsigned int caps,
2036 unsigned long fg, unsigned long bg) 2033 unsigned long fg, unsigned long bg)
2037{ 2034{
@@ -2099,7 +2096,7 @@ static char *default_set_background;
2099/* Save or restore the default color-related capabilities of this 2096/* Save or restore the default color-related capabilities of this
2100 terminal. */ 2097 terminal. */
2101static void 2098static void
2102tty_default_color_capabilities (struct tty_display_info *tty, int save) 2099tty_default_color_capabilities (struct tty_display_info *tty, bool save)
2103{ 2100{
2104 2101
2105 if (save) 2102 if (save)
@@ -2209,7 +2206,7 @@ set_tty_color_mode (struct tty_display_info *tty, struct frame *f)
2209/* Return the tty display object specified by TERMINAL. */ 2206/* Return the tty display object specified by TERMINAL. */
2210 2207
2211static struct terminal * 2208static struct terminal *
2212get_tty_terminal (Lisp_Object terminal, int throw) 2209get_tty_terminal (Lisp_Object terminal, bool throw)
2213{ 2210{
2214 struct terminal *t = get_terminal (terminal, throw); 2211 struct terminal *t = get_terminal (terminal, throw);
2215 2212
@@ -2481,7 +2478,7 @@ term_mouse_moveto (int x, int y)
2481 name = (const char *) ttyname (0); 2478 name = (const char *) ttyname (0);
2482 fd = emacs_open (name, O_WRONLY, 0); 2479 fd = emacs_open (name, O_WRONLY, 0);
2483 SOME_FUNCTION (x, y, fd); 2480 SOME_FUNCTION (x, y, fd);
2484 close (fd); 2481 emacs_close (fd);
2485 last_mouse_x = x; 2482 last_mouse_x = x;
2486 last_mouse_y = y; */ 2483 last_mouse_y = y; */
2487} 2484}
@@ -2519,7 +2516,7 @@ tty_draw_row_with_mouse_face (struct window *w, struct glyph_row *row,
2519 cursor_to (f, save_y, save_x); 2516 cursor_to (f, save_y, save_x);
2520} 2517}
2521 2518
2522static int 2519static bool
2523term_mouse_movement (FRAME_PTR frame, Gpm_Event *event) 2520term_mouse_movement (FRAME_PTR frame, Gpm_Event *event)
2524{ 2521{
2525 /* Has the mouse moved off the glyph it was on at the last sighting? */ 2522 /* Has the mouse moved off the glyph it was on at the last sighting? */
@@ -2649,7 +2646,7 @@ handle_one_term_event (struct tty_display_info *tty, Gpm_Event *event, struct in
2649{ 2646{
2650 struct frame *f = XFRAME (tty->top_frame); 2647 struct frame *f = XFRAME (tty->top_frame);
2651 struct input_event ie; 2648 struct input_event ie;
2652 int do_help = 0; 2649 bool do_help = 0;
2653 int count = 0; 2650 int count = 0;
2654 2651
2655 EVENT_INIT (ie); 2652 EVENT_INIT (ie);
@@ -2934,7 +2931,7 @@ dissociate_if_controlling_tty (int fd)
2934 If MUST_SUCCEED is true, then all errors are fatal. */ 2931 If MUST_SUCCEED is true, then all errors are fatal. */
2935 2932
2936struct terminal * 2933struct terminal *
2937init_tty (const char *name, const char *terminal_type, int must_succeed) 2934init_tty (const char *name, const char *terminal_type, bool must_succeed)
2938{ 2935{
2939 char *area = NULL; 2936 char *area = NULL;
2940 char **address = &area; 2937 char **address = &area;
@@ -2942,7 +2939,7 @@ init_tty (const char *name, const char *terminal_type, int must_succeed)
2942 int status; 2939 int status;
2943 struct tty_display_info *tty = NULL; 2940 struct tty_display_info *tty = NULL;
2944 struct terminal *terminal = NULL; 2941 struct terminal *terminal = NULL;
2945 int ctty = 0; /* 1 if asked to open controlling tty. */ 2942 bool ctty = 0; /* True if asked to open controlling tty. */
2946 2943
2947 if (!terminal_type) 2944 if (!terminal_type)
2948 maybe_fatal (must_succeed, 0, 2945 maybe_fatal (must_succeed, 0,
@@ -3015,7 +3012,7 @@ init_tty (const char *name, const char *terminal_type, int must_succeed)
3015 name); 3012 name);
3016 if (!isatty (fd)) 3013 if (!isatty (fd))
3017 { 3014 {
3018 close (fd); 3015 emacs_close (fd);
3019 maybe_fatal (must_succeed, terminal, 3016 maybe_fatal (must_succeed, terminal,
3020 "Not a tty device: %s", 3017 "Not a tty device: %s",
3021 "Not a tty device: %s", 3018 "Not a tty device: %s",
@@ -3412,10 +3409,10 @@ vfatal (const char *str, va_list ap)
3412 3409
3413/* Auxiliary error-handling function for init_tty. 3410/* Auxiliary error-handling function for init_tty.
3414 Delete TERMINAL, then call error or fatal with str1 or str2, 3411 Delete TERMINAL, then call error or fatal with str1 or str2,
3415 respectively, according to whether MUST_SUCCEED is zero or not. */ 3412 respectively, according to whether MUST_SUCCEED is true. */
3416 3413
3417static void 3414static void
3418maybe_fatal (int must_succeed, struct terminal *terminal, 3415maybe_fatal (bool must_succeed, struct terminal *terminal,
3419 const char *str1, const char *str2, ...) 3416 const char *str1, const char *str2, ...)
3420{ 3417{
3421 va_list ap; 3418 va_list ap;
diff --git a/src/termcap.c b/src/termcap.c
index 7256eef9e81..be05828eea6 100644
--- a/src/termcap.c
+++ b/src/termcap.c
@@ -213,8 +213,8 @@ tgetst1 (char *ptr, char **area)
213 abbreviation expansion makes that effort a little more hairy than 213 abbreviation expansion makes that effort a little more hairy than
214 its worth; this is cleaner. */ 214 its worth; this is cleaner. */
215 { 215 {
216 register int last_p_param = 0; 216 int last_p_param = 0;
217 int remove_p_params = 1; 217 bool remove_p_params = 1;
218 struct { char *beg; int len; } cut[11]; 218 struct { char *beg; int len; } cut[11];
219 219
220 for (cut[0].beg = p = ret; p < r - 3; p++) 220 for (cut[0].beg = p = ret; p < r - 3; p++)
@@ -318,26 +318,26 @@ struct termcap_buffer
318 char *beg; 318 char *beg;
319 ptrdiff_t size; 319 ptrdiff_t size;
320 char *ptr; 320 char *ptr;
321 int ateof; 321 bool ateof;
322 ptrdiff_t full; 322 ptrdiff_t full;
323 }; 323 };
324 324
325/* Forward declarations of static functions. */ 325/* Forward declarations of static functions. */
326 326
327static int scan_file (char *str, int fd, register struct termcap_buffer *bufp); 327static bool scan_file (char *, int, struct termcap_buffer *);
328static char *gobble_line (int fd, register struct termcap_buffer *bufp, char *append_end); 328static char *gobble_line (int, struct termcap_buffer *, char *);
329static int compare_contin (register char *str1, register char *str2); 329static bool compare_contin (char *, char *);
330static int name_match (char *line, char *name); 330static bool name_match (char *, char *);
331 331
332#ifdef MSDOS /* MW, May 1993 */ 332static bool
333static int
334valid_filename_p (char *fn) 333valid_filename_p (char *fn)
335{ 334{
335#ifdef MSDOS
336 return *fn == '/' || fn[1] == ':'; 336 return *fn == '/' || fn[1] == ':';
337}
338#else 337#else
339#define valid_filename_p(fn) (*(fn) == '/') 338 return *fn == '/';
340#endif 339#endif
340}
341 341
342/* Find the termcap entry data for terminal type NAME 342/* Find the termcap entry data for terminal type NAME
343 and store it in the block that BP points to. 343 and store it in the block that BP points to.
@@ -360,10 +360,10 @@ tgetent (char *bp, const char *name)
360 char *tc_search_point; 360 char *tc_search_point;
361 char *term; 361 char *term;
362 ptrdiff_t malloc_size = 0; 362 ptrdiff_t malloc_size = 0;
363 register int c; 363 int c;
364 char *tcenv = NULL; /* TERMCAP value, if it contains :tc=. */ 364 char *tcenv = NULL; /* TERMCAP value, if it contains :tc=. */
365 char *indirect = NULL; /* Terminal type in :tc= in TERMCAP value. */ 365 char *indirect = NULL; /* Terminal type in :tc= in TERMCAP value. */
366 int filep; 366 bool filep;
367 367
368#ifdef INTERNAL_TERMINAL 368#ifdef INTERNAL_TERMINAL
369 /* For the internal terminal we don't want to read any termcap file, 369 /* For the internal terminal we don't want to read any termcap file,
@@ -455,7 +455,7 @@ tgetent (char *bp, const char *name)
455 /* Scan the file, reading it via buf, till find start of main entry. */ 455 /* Scan the file, reading it via buf, till find start of main entry. */
456 if (scan_file (term, fd, &buf) == 0) 456 if (scan_file (term, fd, &buf) == 0)
457 { 457 {
458 close (fd); 458 emacs_close (fd);
459 xfree (buf.beg); 459 xfree (buf.beg);
460 if (malloc_size) 460 if (malloc_size)
461 xfree (bp); 461 xfree (bp);
@@ -493,7 +493,7 @@ tgetent (char *bp, const char *name)
493 term = tgetst1 (tc_search_point, (char **) 0); 493 term = tgetst1 (tc_search_point, (char **) 0);
494 } 494 }
495 495
496 close (fd); 496 emacs_close (fd);
497 xfree (buf.beg); 497 xfree (buf.beg);
498 498
499 if (malloc_size) 499 if (malloc_size)
@@ -510,10 +510,10 @@ tgetent (char *bp, const char *name)
510 Return 1 if successful, with that line in BUFP, 510 Return 1 if successful, with that line in BUFP,
511 or 0 if no entry is found in the file. */ 511 or 0 if no entry is found in the file. */
512 512
513static int 513static bool
514scan_file (char *str, int fd, register struct termcap_buffer *bufp) 514scan_file (char *str, int fd, struct termcap_buffer *bufp)
515{ 515{
516 register char *end; 516 char *end;
517 517
518 bufp->ptr = bufp->beg; 518 bufp->ptr = bufp->beg;
519 bufp->full = 0; 519 bufp->full = 0;
@@ -544,13 +544,13 @@ scan_file (char *str, int fd, register struct termcap_buffer *bufp)
544 return 0; 544 return 0;
545} 545}
546 546
547/* Return nonzero if NAME is one of the names specified 547/* Return true if NAME is one of the names specified
548 by termcap entry LINE. */ 548 by termcap entry LINE. */
549 549
550static int 550static bool
551name_match (char *line, char *name) 551name_match (char *line, char *name)
552{ 552{
553 register char *tem; 553 char *tem;
554 554
555 if (!compare_contin (line, name)) 555 if (!compare_contin (line, name))
556 return 1; 556 return 1;
@@ -562,18 +562,18 @@ name_match (char *line, char *name)
562 return 0; 562 return 0;
563} 563}
564 564
565static int 565static bool
566compare_contin (register char *str1, register char *str2) 566compare_contin (char *str1, char *str2)
567{ 567{
568 register int c1, c2;
569 while (1) 568 while (1)
570 { 569 {
571 c1 = *str1++; 570 int c1 = *str1++;
572 c2 = *str2++; 571 int c2 = *str2++;
573 while (c1 == '\\' && *str1 == '\n') 572 while (c1 == '\\' && *str1 == '\n')
574 { 573 {
575 str1++; 574 str1++;
576 while ((c1 = *str1++) == ' ' || c1 == '\t'); 575 while ((c1 = *str1++) == ' ' || c1 == '\t')
576 continue;
577 } 577 }
578 if (c2 == '\0') 578 if (c2 == '\0')
579 { 579 {
@@ -647,57 +647,3 @@ gobble_line (int fd, register struct termcap_buffer *bufp, char *append_end)
647 } 647 }
648 return end + 1; 648 return end + 1;
649} 649}
650
651#ifdef TEST
652
653#include <stdio.h>
654
655static void
656tprint (char *cap)
657{
658 char *x = tgetstr (cap, 0);
659 register char *y;
660
661 printf ("%s: ", cap);
662 if (x)
663 {
664 for (y = x; *y; y++)
665 if (*y <= ' ' || *y == 0177)
666 printf ("\\%0o", *y);
667 else
668 putchar (*y);
669 free (x);
670 }
671 else
672 printf ("none");
673 putchar ('\n');
674}
675
676int
677main (int argc, char **argv)
678{
679 char *term;
680 char *buf;
681
682 term = argv[1];
683 printf ("TERM: %s\n", term);
684
685 buf = (char *) tgetent (0, term);
686 if ((int) buf <= 0)
687 {
688 printf ("No entry.\n");
689 return 0;
690 }
691
692 printf ("Entry: %s\n", buf);
693
694 tprint ("cm");
695 tprint ("AL");
696
697 printf ("co: %d\n", tgetnum ("co"));
698 printf ("am: %d\n", tgetflag ("am"));
699
700 return 0;
701}
702
703#endif /* TEST */
diff --git a/src/termhooks.h b/src/termhooks.h
index 4f3fa9cb47f..0190478c254 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -643,7 +643,7 @@ extern struct terminal *terminal_list;
643 (((d)->type != output_termcap && (d)->type != output_msdos_raw) \ 643 (((d)->type != output_termcap && (d)->type != output_msdos_raw) \
644 || (d)->display_info.tty->input) 644 || (d)->display_info.tty->input)
645 645
646extern struct terminal *get_terminal (Lisp_Object terminal, int); 646extern struct terminal *get_terminal (Lisp_Object terminal, bool);
647extern struct terminal *create_terminal (void); 647extern struct terminal *create_terminal (void);
648extern void delete_terminal (struct terminal *); 648extern void delete_terminal (struct terminal *);
649 649
diff --git a/src/terminal.c b/src/terminal.c
index c99c39c64ae..c55fd4eb077 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -199,11 +199,11 @@ ins_del_lines (struct frame *f, int vpos, int n)
199 199
200/* Return the terminal object specified by TERMINAL. TERMINAL may be 200/* Return the terminal object specified by TERMINAL. TERMINAL may be
201 a terminal object, a frame, or nil for the terminal device of the 201 a terminal object, a frame, or nil for the terminal device of the
202 current frame. If THROW is zero, return NULL for failure, 202 current frame. If THROW is false, return NULL for failure,
203 otherwise throw an error. */ 203 otherwise throw an error. */
204 204
205struct terminal * 205struct terminal *
206get_terminal (Lisp_Object terminal, int throw) 206get_terminal (Lisp_Object terminal, bool throw)
207{ 207{
208 struct terminal *result = NULL; 208 struct terminal *result = NULL;
209 209
diff --git a/src/undo.c b/src/undo.c
index d8711882fbf..234b8510f0a 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -229,10 +229,9 @@ record_first_change (void)
229 if (base_buffer->base_buffer) 229 if (base_buffer->base_buffer)
230 base_buffer = base_buffer->base_buffer; 230 base_buffer = base_buffer->base_buffer;
231 231
232 bset_undo_list 232 bset_undo_list (current_buffer,
233 (current_buffer, 233 Fcons (Fcons (Qt, Fvisited_file_modtime ()),
234 Fcons (Fcons (Qt, make_lisp_time (base_buffer->modtime)), 234 BVAR (current_buffer, undo_list)));
235 BVAR (current_buffer, undo_list)));
236} 235}
237 236
238/* Record a change in property PROP (whose old value was VAL) 237/* Record a change in property PROP (whose old value was VAL)
diff --git a/src/unexaix.c b/src/unexaix.c
index 204f6cf4ad3..757ba6f51b3 100644
--- a/src/unexaix.c
+++ b/src/unexaix.c
@@ -94,13 +94,10 @@ static int pagemask;
94static _Noreturn void 94static _Noreturn void
95report_error (const char *file, int fd) 95report_error (const char *file, int fd)
96{ 96{
97 int err = errno;
97 if (fd) 98 if (fd)
98 { 99 emacs_close (fd);
99 int failed_errno = errno; 100 report_file_errno ("Cannot unexec", Fcons (build_string (file), Qnil), err);
100 close (fd);
101 errno = failed_errno;
102 }
103 report_file_error ("Cannot unexec", Fcons (build_string (file), Qnil));
104} 101}
105 102
106#define ERROR0(msg) report_error_1 (new, msg) 103#define ERROR0(msg) report_error_1 (new, msg)
@@ -111,7 +108,7 @@ static _Noreturn void ATTRIBUTE_FORMAT_PRINTF (2, 3)
111report_error_1 (int fd, const char *msg, ...) 108report_error_1 (int fd, const char *msg, ...)
112{ 109{
113 va_list ap; 110 va_list ap;
114 close (fd); 111 emacs_close (fd);
115 va_start (ap, msg); 112 va_start (ap, msg);
116 verror (msg, ap); 113 verror (msg, ap);
117 va_end (ap); 114 va_end (ap);
@@ -148,13 +145,13 @@ unexec (const char *new_name, const char *a_name)
148 || adjust_lnnoptrs (new, a_out, new_name) < 0 145 || adjust_lnnoptrs (new, a_out, new_name) < 0
149 || unrelocate_symbols (new, a_out, a_name, new_name) < 0) 146 || unrelocate_symbols (new, a_out, a_name, new_name) < 0)
150 { 147 {
151 close (new); 148 emacs_close (new);
152 return; 149 return;
153 } 150 }
154 151
155 close (new); 152 emacs_close (new);
156 if (a_out >= 0) 153 if (a_out >= 0)
157 close (a_out); 154 emacs_close (a_out);
158 mark_x (new_name); 155 mark_x (new_name);
159} 156}
160 157
@@ -534,7 +531,7 @@ adjust_lnnoptrs (int writedesc, int readdesc, const char *new_name)
534 } 531 }
535 } 532 }
536 } 533 }
537 close (new); 534 emacs_close (new);
538 535
539 return 0; 536 return 0;
540} 537}
diff --git a/src/unexcoff.c b/src/unexcoff.c
index e79821251ba..c467e59a665 100644
--- a/src/unexcoff.c
+++ b/src/unexcoff.c
@@ -127,9 +127,10 @@ static int pagemask;
127static void 127static void
128report_error (const char *file, int fd) 128report_error (const char *file, int fd)
129{ 129{
130 int err = errno;
130 if (fd) 131 if (fd)
131 close (fd); 132 emacs_close (fd);
132 report_file_error ("Cannot unexec", Fcons (build_string (file), Qnil)); 133 report_file_errno ("Cannot unexec", Fcons (build_string (file), Qnil), err);
133} 134}
134 135
135#define ERROR0(msg) report_error_1 (new, msg, 0, 0); return -1 136#define ERROR0(msg) report_error_1 (new, msg, 0, 0); return -1
@@ -139,7 +140,7 @@ report_error (const char *file, int fd)
139static void 140static void
140report_error_1 (int fd, const char *msg, int a1, int a2) 141report_error_1 (int fd, const char *msg, int a1, int a2)
141{ 142{
142 close (fd); 143 emacs_close (fd);
143 error (msg, a1, a2); 144 error (msg, a1, a2);
144} 145}
145 146
@@ -511,7 +512,7 @@ adjust_lnnoptrs (int writedesc, int readdesc, const char *new_name)
511 } 512 }
512 } 513 }
513#ifndef MSDOS 514#ifndef MSDOS
514 close (new); 515 emacs_close (new);
515#endif 516#endif
516 return 0; 517 return 0;
517} 518}
@@ -541,13 +542,13 @@ unexec (const char *new_name, const char *a_name)
541 || adjust_lnnoptrs (new, a_out, new_name) < 0 542 || adjust_lnnoptrs (new, a_out, new_name) < 0
542 ) 543 )
543 { 544 {
544 close (new); 545 emacs_close (new);
545 return; 546 return;
546 } 547 }
547 548
548 close (new); 549 emacs_close (new);
549 if (a_out >= 0) 550 if (a_out >= 0)
550 close (a_out); 551 emacs_close (a_out);
551 mark_x (new_name); 552 mark_x (new_name);
552} 553}
553 554
diff --git a/src/unexcw.c b/src/unexcw.c
index 0312a7328fb..12435a85051 100644
--- a/src/unexcw.c
+++ b/src/unexcw.c
@@ -316,13 +316,13 @@ unexec (const char *outfile, const char *infile)
316 ret2 = write (fd_out, buffer, ret); 316 ret2 = write (fd_out, buffer, ret);
317 assert (ret2 == ret); 317 assert (ret2 == ret);
318 } 318 }
319 ret = close (fd_in); 319 ret = emacs_close (fd_in);
320 assert (ret == 0); 320 assert (ret == 0);
321 321
322 bss_sbrk_did_unexec = 1; 322 bss_sbrk_did_unexec = 1;
323 fixup_executable (fd_out); 323 fixup_executable (fd_out);
324 bss_sbrk_did_unexec = 0; 324 bss_sbrk_did_unexec = 0;
325 325
326 ret = close (fd_out); 326 ret = emacs_close (fd_out);
327 assert (ret == 0); 327 assert (ret == 0);
328} 328}
diff --git a/src/unexelf.c b/src/unexelf.c
index 28847157e40..e2412393286 100644
--- a/src/unexelf.c
+++ b/src/unexelf.c
@@ -1312,13 +1312,13 @@ temacs:
1312 /* Close the files and make the new file executable. */ 1312 /* Close the files and make the new file executable. */
1313 1313
1314#if MAP_ANON == 0 1314#if MAP_ANON == 0
1315 close (mmap_fd); 1315 emacs_close (mmap_fd);
1316#endif 1316#endif
1317 1317
1318 if (close (old_file) != 0) 1318 if (emacs_close (old_file) != 0)
1319 fatal ("Can't close (%s): %s", old_name, strerror (errno)); 1319 fatal ("Can't close (%s): %s", old_name, strerror (errno));
1320 1320
1321 if (close (new_file) != 0) 1321 if (emacs_close (new_file) != 0)
1322 fatal ("Can't close (%s): %s", new_name, strerror (errno)); 1322 fatal ("Can't close (%s): %s", new_name, strerror (errno));
1323 1323
1324 if (stat (new_name, &stat_buf) != 0) 1324 if (stat (new_name, &stat_buf) != 0)
diff --git a/src/unexhp9k800.c b/src/unexhp9k800.c
index 0f6eb87ee01..bee2517307a 100644
--- a/src/unexhp9k800.c
+++ b/src/unexhp9k800.c
@@ -306,6 +306,6 @@ unexec (const char *new_name, /* name of the new a.out file to be created *
306 write_header (new, &hdr, &auxhdr); 306 write_header (new, &hdr, &auxhdr);
307 307
308 /* Close the binary file */ 308 /* Close the binary file */
309 close (old); 309 emacs_close (old);
310 close (new); 310 emacs_close (new);
311} 311}
diff --git a/src/unexmacosx.c b/src/unexmacosx.c
index 2bc6de177eb..87848b012ba 100644
--- a/src/unexmacosx.c
+++ b/src/unexmacosx.c
@@ -1332,7 +1332,7 @@ unexec (const char *outfile, const char *infile)
1332 outfd = emacs_open (outfile, O_WRONLY | O_TRUNC | O_CREAT, 0755); 1332 outfd = emacs_open (outfile, O_WRONLY | O_TRUNC | O_CREAT, 0755);
1333 if (outfd < 0) 1333 if (outfd < 0)
1334 { 1334 {
1335 close (infd); 1335 emacs_close (infd);
1336 unexec_error ("cannot open output file `%s'", outfile); 1336 unexec_error ("cannot open output file `%s'", outfile);
1337 } 1337 }
1338 1338
@@ -1346,7 +1346,7 @@ unexec (const char *outfile, const char *infile)
1346 1346
1347 dump_it (); 1347 dump_it ();
1348 1348
1349 close (outfd); 1349 emacs_close (outfd);
1350} 1350}
1351 1351
1352 1352
diff --git a/src/w32.c b/src/w32.c
index 230479cd61a..1a3d81bbffc 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -234,6 +234,8 @@ extern int sys_access (const char *, int);
234extern void *e_malloc (size_t); 234extern void *e_malloc (size_t);
235extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *, 235extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *,
236 EMACS_TIME *, void *); 236 EMACS_TIME *, void *);
237extern int sys_dup (int);
238
237 239
238 240
239 241
@@ -6719,10 +6721,16 @@ sys_sendto (int s, const char * buf, int len, int flags,
6719} 6721}
6720 6722
6721/* Windows does not have an fcntl function. Provide an implementation 6723/* Windows does not have an fcntl function. Provide an implementation
6722 solely for making sockets non-blocking. */ 6724 good enough for Emacs. */
6723int 6725int
6724fcntl (int s, int cmd, int options) 6726fcntl (int s, int cmd, int options)
6725{ 6727{
6728 /* In the w32 Emacs port, fcntl (fd, F_DUPFD_CLOEXEC, fd1) is always
6729 invoked in a context where fd1 is closed and all descriptors less
6730 than fd1 are open, so sys_dup is an adequate implementation. */
6731 if (cmd == F_DUPFD_CLOEXEC)
6732 return sys_dup (s);
6733
6726 if (winsock_lib == NULL) 6734 if (winsock_lib == NULL)
6727 { 6735 {
6728 errno = ENETDOWN; 6736 errno = ENETDOWN;
@@ -6864,13 +6872,14 @@ sys_dup2 (int src, int dst)
6864 return rc; 6872 return rc;
6865} 6873}
6866 6874
6867/* Unix pipe() has only one arg */
6868int 6875int
6869sys_pipe (int * phandles) 6876pipe2 (int * phandles, int pipe2_flags)
6870{ 6877{
6871 int rc; 6878 int rc;
6872 unsigned flags; 6879 unsigned flags;
6873 6880
6881 eassert (pipe2_flags == O_CLOEXEC);
6882
6874 /* make pipe handles non-inheritable; when we spawn a child, we 6883 /* make pipe handles non-inheritable; when we spawn a child, we
6875 replace the relevant handle with an inheritable one. Also put 6884 replace the relevant handle with an inheritable one. Also put
6876 pipes into binary mode; we will do text mode translation ourselves 6885 pipes into binary mode; we will do text mode translation ourselves
diff --git a/src/w32.h b/src/w32.h
index 17da0778db1..9c1f1efa699 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -188,7 +188,7 @@ extern int random (void);
188 188
189extern int fchmod (int, mode_t); 189extern int fchmod (int, mode_t);
190extern int sys_rename_replace (char const *, char const *, BOOL); 190extern int sys_rename_replace (char const *, char const *, BOOL);
191extern int sys_pipe (int *); 191extern int pipe2 (int *, int);
192 192
193extern void set_process_dir (char *); 193extern void set_process_dir (char *);
194extern int sys_spawnve (int, char *, char **, char **); 194extern int sys_spawnve (int, char *, char **, char **);
diff --git a/src/xdisp.c b/src/xdisp.c
index 5869ce5fdfa..12b294e6800 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -12589,6 +12589,7 @@ static void debug_method_add (struct window *, char const *, ...)
12589static void 12589static void
12590debug_method_add (struct window *w, char const *fmt, ...) 12590debug_method_add (struct window *w, char const *fmt, ...)
12591{ 12591{
12592 void *ptr = w;
12592 char *method = w->desired_matrix->method; 12593 char *method = w->desired_matrix->method;
12593 int len = strlen (method); 12594 int len = strlen (method);
12594 int size = sizeof w->desired_matrix->method; 12595 int size = sizeof w->desired_matrix->method;
@@ -12607,7 +12608,7 @@ debug_method_add (struct window *w, char const *fmt, ...)
12607 12608
12608 if (trace_redisplay_p) 12609 if (trace_redisplay_p)
12609 fprintf (stderr, "%p (%s): %s\n", 12610 fprintf (stderr, "%p (%s): %s\n",
12610 w, 12611 ptr,
12611 ((BUFFERP (w->contents) 12612 ((BUFFERP (w->contents)
12612 && STRINGP (BVAR (XBUFFER (w->contents), name))) 12613 && STRINGP (BVAR (XBUFFER (w->contents), name)))
12613 ? SSDATA (BVAR (XBUFFER (w->contents), name)) 12614 ? SSDATA (BVAR (XBUFFER (w->contents), name))
diff --git a/src/xrdb.c b/src/xrdb.c
index c25c25d6f33..7c9cd53fa8c 100644
--- a/src/xrdb.c
+++ b/src/xrdb.c
@@ -634,10 +634,7 @@ member (char *elt, List list)
634static void 634static void
635fatal (char *msg, char *prog) 635fatal (char *msg, char *prog)
636{ 636{
637 if (errno) 637 fprintf (stderr, msg, prog);
638 perror (prog);
639
640 (void) fprintf (stderr, msg, prog);
641 exit (1); 638 exit (1);
642} 639}
643 640
diff --git a/src/xsettings.c b/src/xsettings.c
index f48c49dbafe..45f8435d9f4 100644
--- a/src/xsettings.c
+++ b/src/xsettings.c
@@ -170,7 +170,7 @@ enum {
170 SEEN_HINTSTYLE = 0x10, 170 SEEN_HINTSTYLE = 0x10,
171 SEEN_DPI = 0x20, 171 SEEN_DPI = 0x20,
172 SEEN_FONT = 0x40, 172 SEEN_FONT = 0x40,
173 SEEN_TB_STYLE = 0x80, 173 SEEN_TB_STYLE = 0x80
174}; 174};
175struct xsettings 175struct xsettings
176{ 176{
@@ -687,7 +687,7 @@ apply_xft_settings (struct x_display_info *dpyinfo,
687 { 687 {
688 static char const format[] = 688 static char const format[] =
689 "Antialias: %d, Hinting: %d, RGBA: %d, LCDFilter: %d, " 689 "Antialias: %d, Hinting: %d, RGBA: %d, LCDFilter: %d, "
690 "Hintstyle: %d, DPI: %lf"; 690 "Hintstyle: %d, DPI: %f";
691 enum 691 enum
692 { 692 {
693 d_formats = 5, 693 d_formats = 5,
@@ -696,7 +696,7 @@ apply_xft_settings (struct x_display_info *dpyinfo,
696 max_f_integer_digits = DBL_MAX_10_EXP + 1, 696 max_f_integer_digits = DBL_MAX_10_EXP + 1,
697 f_precision = 6, 697 f_precision = 6,
698 lf_growth = (sizeof "-." + max_f_integer_digits + f_precision 698 lf_growth = (sizeof "-." + max_f_integer_digits + f_precision
699 - sizeof "%lf") 699 - sizeof "%f")
700 }; 700 };
701 char buf[sizeof format + d_formats * d_growth + lf_formats * lf_growth]; 701 char buf[sizeof format + d_formats * d_growth + lf_formats * lf_growth];
702 702
diff --git a/src/xterm.c b/src/xterm.c
index f0b95d585e3..818b69cc41d 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -2647,7 +2647,10 @@ x_draw_underwave (struct glyph_string *s)
2647 2647
2648 /* Find and set clipping rectangle */ 2648 /* Find and set clipping rectangle */
2649 2649
2650 wave_clip = (XRectangle){ x0, y0, width, wave_height }; 2650 wave_clip.x = x0;
2651 wave_clip.y = y0;
2652 wave_clip.width = width;
2653 wave_clip.height = wave_height;
2651 get_glyph_string_clip_rect (s, &string_clip); 2654 get_glyph_string_clip_rect (s, &string_clip);
2652 2655
2653 if (!x_intersect_rectangles (&wave_clip, &string_clip, &final_clip)) 2656 if (!x_intersect_rectangles (&wave_clip, &string_clip, &final_clip))
@@ -10191,71 +10194,73 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
10191 } 10194 }
10192 10195
10193 { 10196 {
10194 const struct 10197 static const struct
10195 { 10198 {
10196 const char *name; 10199 const char *name;
10197 Atom *atom; 10200 int offset;
10198 } atom_refs[] = { 10201 } atom_refs[] = {
10199 { "WM_PROTOCOLS", &dpyinfo->Xatom_wm_protocols }, 10202#define ATOM_REFS_INIT(string, member) \
10200 { "WM_TAKE_FOCUS", &dpyinfo->Xatom_wm_take_focus }, 10203 { string, offsetof (struct x_display_info, member) },
10201 { "WM_SAVE_YOURSELF", &dpyinfo->Xatom_wm_save_yourself }, 10204 ATOM_REFS_INIT ("WM_PROTOCOLS", Xatom_wm_protocols)
10202 { "WM_DELETE_WINDOW", &dpyinfo->Xatom_wm_delete_window }, 10205 ATOM_REFS_INIT ("WM_TAKE_FOCUS", Xatom_wm_take_focus)
10203 { "WM_CHANGE_STATE", &dpyinfo->Xatom_wm_change_state }, 10206 ATOM_REFS_INIT ("WM_SAVE_YOURSELF", Xatom_wm_save_yourself)
10204 { "WM_CONFIGURE_DENIED", &dpyinfo->Xatom_wm_configure_denied }, 10207 ATOM_REFS_INIT ("WM_DELETE_WINDOW", Xatom_wm_delete_window)
10205 { "WM_MOVED", &dpyinfo->Xatom_wm_window_moved }, 10208 ATOM_REFS_INIT ("WM_CHANGE_STATE", Xatom_wm_change_state)
10206 { "WM_CLIENT_LEADER", &dpyinfo->Xatom_wm_client_leader }, 10209 ATOM_REFS_INIT ("WM_CONFIGURE_DENIED", Xatom_wm_configure_denied)
10207 { "Editres", &dpyinfo->Xatom_editres }, 10210 ATOM_REFS_INIT ("WM_MOVED", Xatom_wm_window_moved)
10208 { "CLIPBOARD", &dpyinfo->Xatom_CLIPBOARD }, 10211 ATOM_REFS_INIT ("WM_CLIENT_LEADER", Xatom_wm_client_leader)
10209 { "TIMESTAMP", &dpyinfo->Xatom_TIMESTAMP }, 10212 ATOM_REFS_INIT ("Editres", Xatom_editres)
10210 { "TEXT", &dpyinfo->Xatom_TEXT }, 10213 ATOM_REFS_INIT ("CLIPBOARD", Xatom_CLIPBOARD)
10211 { "COMPOUND_TEXT", &dpyinfo->Xatom_COMPOUND_TEXT }, 10214 ATOM_REFS_INIT ("TIMESTAMP", Xatom_TIMESTAMP)
10212 { "UTF8_STRING", &dpyinfo->Xatom_UTF8_STRING }, 10215 ATOM_REFS_INIT ("TEXT", Xatom_TEXT)
10213 { "DELETE", &dpyinfo->Xatom_DELETE }, 10216 ATOM_REFS_INIT ("COMPOUND_TEXT", Xatom_COMPOUND_TEXT)
10214 { "MULTIPLE", &dpyinfo->Xatom_MULTIPLE }, 10217 ATOM_REFS_INIT ("UTF8_STRING", Xatom_UTF8_STRING)
10215 { "INCR", &dpyinfo->Xatom_INCR }, 10218 ATOM_REFS_INIT ("DELETE", Xatom_DELETE)
10216 { "_EMACS_TMP_", &dpyinfo->Xatom_EMACS_TMP }, 10219 ATOM_REFS_INIT ("MULTIPLE", Xatom_MULTIPLE)
10217 { "TARGETS", &dpyinfo->Xatom_TARGETS }, 10220 ATOM_REFS_INIT ("INCR", Xatom_INCR)
10218 { "NULL", &dpyinfo->Xatom_NULL }, 10221 ATOM_REFS_INIT ("_EMACS_TMP_", Xatom_EMACS_TMP)
10219 { "ATOM", &dpyinfo->Xatom_ATOM }, 10222 ATOM_REFS_INIT ("TARGETS", Xatom_TARGETS)
10220 { "ATOM_PAIR", &dpyinfo->Xatom_ATOM_PAIR }, 10223 ATOM_REFS_INIT ("NULL", Xatom_NULL)
10221 { "CLIPBOARD_MANAGER", &dpyinfo->Xatom_CLIPBOARD_MANAGER }, 10224 ATOM_REFS_INIT ("ATOM", Xatom_ATOM)
10222 { "_XEMBED_INFO", &dpyinfo->Xatom_XEMBED_INFO }, 10225 ATOM_REFS_INIT ("ATOM_PAIR", Xatom_ATOM_PAIR)
10226 ATOM_REFS_INIT ("CLIPBOARD_MANAGER", Xatom_CLIPBOARD_MANAGER)
10227 ATOM_REFS_INIT ("_XEMBED_INFO", Xatom_XEMBED_INFO)
10223 /* For properties of font. */ 10228 /* For properties of font. */
10224 { "PIXEL_SIZE", &dpyinfo->Xatom_PIXEL_SIZE }, 10229 ATOM_REFS_INIT ("PIXEL_SIZE", Xatom_PIXEL_SIZE)
10225 { "AVERAGE_WIDTH", &dpyinfo->Xatom_AVERAGE_WIDTH }, 10230 ATOM_REFS_INIT ("AVERAGE_WIDTH", Xatom_AVERAGE_WIDTH)
10226 { "_MULE_BASELINE_OFFSET", &dpyinfo->Xatom_MULE_BASELINE_OFFSET }, 10231 ATOM_REFS_INIT ("_MULE_BASELINE_OFFSET", Xatom_MULE_BASELINE_OFFSET)
10227 { "_MULE_RELATIVE_COMPOSE", &dpyinfo->Xatom_MULE_RELATIVE_COMPOSE }, 10232 ATOM_REFS_INIT ("_MULE_RELATIVE_COMPOSE", Xatom_MULE_RELATIVE_COMPOSE)
10228 { "_MULE_DEFAULT_ASCENT", &dpyinfo->Xatom_MULE_DEFAULT_ASCENT }, 10233 ATOM_REFS_INIT ("_MULE_DEFAULT_ASCENT", Xatom_MULE_DEFAULT_ASCENT)
10229 /* Ghostscript support. */ 10234 /* Ghostscript support. */
10230 { "DONE", &dpyinfo->Xatom_DONE }, 10235 ATOM_REFS_INIT ("DONE", Xatom_DONE)
10231 { "PAGE", &dpyinfo->Xatom_PAGE }, 10236 ATOM_REFS_INIT ("PAGE", Xatom_PAGE)
10232 { "SCROLLBAR", &dpyinfo->Xatom_Scrollbar }, 10237 ATOM_REFS_INIT ("SCROLLBAR", Xatom_Scrollbar)
10233 { "_XEMBED", &dpyinfo->Xatom_XEMBED }, 10238 ATOM_REFS_INIT ("_XEMBED", Xatom_XEMBED)
10234 /* EWMH */ 10239 /* EWMH */
10235 { "_NET_WM_STATE", &dpyinfo->Xatom_net_wm_state }, 10240 ATOM_REFS_INIT ("_NET_WM_STATE", Xatom_net_wm_state)
10236 { "_NET_WM_STATE_FULLSCREEN", &dpyinfo->Xatom_net_wm_state_fullscreen }, 10241 ATOM_REFS_INIT ("_NET_WM_STATE_FULLSCREEN", Xatom_net_wm_state_fullscreen)
10237 { "_NET_WM_STATE_MAXIMIZED_HORZ", 10242 ATOM_REFS_INIT ("_NET_WM_STATE_MAXIMIZED_HORZ",
10238 &dpyinfo->Xatom_net_wm_state_maximized_horz }, 10243 Xatom_net_wm_state_maximized_horz)
10239 { "_NET_WM_STATE_MAXIMIZED_VERT", 10244 ATOM_REFS_INIT ("_NET_WM_STATE_MAXIMIZED_VERT",
10240 &dpyinfo->Xatom_net_wm_state_maximized_vert }, 10245 Xatom_net_wm_state_maximized_vert)
10241 { "_NET_WM_STATE_STICKY", &dpyinfo->Xatom_net_wm_state_sticky }, 10246 ATOM_REFS_INIT ("_NET_WM_STATE_STICKY", Xatom_net_wm_state_sticky)
10242 { "_NET_WM_STATE_HIDDEN", &dpyinfo->Xatom_net_wm_state_hidden }, 10247 ATOM_REFS_INIT ("_NET_WM_STATE_HIDDEN", Xatom_net_wm_state_hidden)
10243 { "_NET_WM_WINDOW_TYPE", &dpyinfo->Xatom_net_window_type }, 10248 ATOM_REFS_INIT ("_NET_WM_WINDOW_TYPE", Xatom_net_window_type)
10244 { "_NET_WM_WINDOW_TYPE_TOOLTIP", 10249 ATOM_REFS_INIT ("_NET_WM_WINDOW_TYPE_TOOLTIP",
10245 &dpyinfo->Xatom_net_window_type_tooltip }, 10250 Xatom_net_window_type_tooltip)
10246 { "_NET_WM_ICON_NAME", &dpyinfo->Xatom_net_wm_icon_name }, 10251 ATOM_REFS_INIT ("_NET_WM_ICON_NAME", Xatom_net_wm_icon_name)
10247 { "_NET_WM_NAME", &dpyinfo->Xatom_net_wm_name }, 10252 ATOM_REFS_INIT ("_NET_WM_NAME", Xatom_net_wm_name)
10248 { "_NET_SUPPORTED", &dpyinfo->Xatom_net_supported }, 10253 ATOM_REFS_INIT ("_NET_SUPPORTED", Xatom_net_supported)
10249 { "_NET_SUPPORTING_WM_CHECK", &dpyinfo->Xatom_net_supporting_wm_check }, 10254 ATOM_REFS_INIT ("_NET_SUPPORTING_WM_CHECK", Xatom_net_supporting_wm_check)
10250 { "_NET_WM_WINDOW_OPACITY", &dpyinfo->Xatom_net_wm_window_opacity }, 10255 ATOM_REFS_INIT ("_NET_WM_WINDOW_OPACITY", Xatom_net_wm_window_opacity)
10251 { "_NET_ACTIVE_WINDOW", &dpyinfo->Xatom_net_active_window }, 10256 ATOM_REFS_INIT ("_NET_ACTIVE_WINDOW", Xatom_net_active_window)
10252 { "_NET_FRAME_EXTENTS", &dpyinfo->Xatom_net_frame_extents }, 10257 ATOM_REFS_INIT ("_NET_FRAME_EXTENTS", Xatom_net_frame_extents)
10253 { "_NET_CURRENT_DESKTOP", &dpyinfo->Xatom_net_current_desktop }, 10258 ATOM_REFS_INIT ("_NET_CURRENT_DESKTOP", Xatom_net_current_desktop)
10254 { "_NET_WORKAREA", &dpyinfo->Xatom_net_workarea }, 10259 ATOM_REFS_INIT ("_NET_WORKAREA", Xatom_net_workarea)
10255 /* Session management */ 10260 /* Session management */
10256 { "SM_CLIENT_ID", &dpyinfo->Xatom_SM_CLIENT_ID }, 10261 ATOM_REFS_INIT ("SM_CLIENT_ID", Xatom_SM_CLIENT_ID)
10257 { "_XSETTINGS_SETTINGS", &dpyinfo->Xatom_xsettings_prop }, 10262 ATOM_REFS_INIT ("_XSETTINGS_SETTINGS", Xatom_xsettings_prop)
10258 { "MANAGER", &dpyinfo->Xatom_xsettings_mgr }, 10263 ATOM_REFS_INIT ("MANAGER", Xatom_xsettings_mgr)
10259 }; 10264 };
10260 10265
10261 int i; 10266 int i;
@@ -10280,7 +10285,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
10280 False, atoms_return); 10285 False, atoms_return);
10281 10286
10282 for (i = 0; i < atom_count; i++) 10287 for (i = 0; i < atom_count; i++)
10283 *atom_refs[i].atom = atoms_return[i]; 10288 *(Atom *) ((char *) dpyinfo + atom_refs[i].offset) = atoms_return[i];
10284 10289
10285 /* Manual copy of last atom */ 10290 /* Manual copy of last atom */
10286 dpyinfo->Xatom_xsettings_sel = atoms_return[i]; 10291 dpyinfo->Xatom_xsettings_sel = atoms_return[i];
diff --git a/test/ChangeLog b/test/ChangeLog
index aded5473304..d3d8db6b501 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,68 @@
12013-07-11 Glenn Morris <rgm@gnu.org>
2
3 * automated/ert-tests.el: Require cl-lib at runtime too.
4 (ert-test-special-operator-p): Use cl-gensym rather than ert-- version.
5 (ert-test-remprop, ert-test-remove-if-not, ert-test-remove*)
6 (ert-test-set-functions, ert-test-gensym)
7 (ert-test-coerce-to-vector, ert-test-string-position)
8 (ert-test-mismatch): Remove tests.
9 * automated/cl-lib.el: New, split from ert-tests.el.
10
11 * automated/ruby-mode-tests.el (ruby-deftest-move-to-block):
12 Goto point-min.
13 (works-on-do, zero-is-noop, ok-with-three, ok-with-minus-two)
14 (ruby-move-to-block-skips-percent-literal)
15 (ruby-move-to-block-skips-heredoc)
16 (ruby-move-to-block-moves-from-else-to-if)
17 (ruby-beginning-of-defun-does-not-fold-case)
18 (ruby-end-of-defun-skips-to-next-line-after-the-method):
19 Replace goto-line with forward-line/goto-char.
20 (ruby-move-to-block-does-not-fold-case): Remove unneeded end-of-buffer.
21
22 * automated/package-test.el (makeinfo-buffer): Autoload.
23 (compilation-in-progress, tar-parse-info, tar-header-name): Declare.
24 (package-test-install-texinfo): Don't require makeinfo.
25
26 * automated/files.el: Stop "local variables" confusion.
27
28 * automated/flymake-tests.el (flymake-tests): Remove unused group.
29
30 * automated/icalendar-tests.el (icalendar-tests--do-test-cycle):
31 Use with-current-buffer.
32
33 * automated/undo-tests.el (undo-test-buffer-modified)
34 (undo-test-file-modified): New tests.
35
362013-07-09 Michael Albinus <michael.albinus@gmx.de>
37
38 * automated/file-notify-tests.el (file-notify-test00-availability):
39 Set :expected-result.
40 (file-notify-test01-add-watch, file-notify-test01-add-watch-remote)
41 (file-notify-test02-events, file-notify-test02-events-remote)
42 (file-notify-test03-autorevert, file-notify-test03-autorevert-remote):
43 Skip when `file-notify-support' is nil. (Bug#14823)
44
452013-07-09 Glenn Morris <rgm@gnu.org>
46
47 * automated/inotify-test.el (inotify-add-watch, inotify-rm-watch):
48 Declare.
49 (inotify-file-watch-simple): Silence compiler.
50
51 * automated/python-tests.el (python-indent-block-enders):
52 Make it actually test something.
53
54 * automated/package-x-test.el: Require package-test when compiling.
55
56 * automated/add-log-tests.el, automated/advice-tests.el:
57 * automated/imenu-test.el, automated/package-x-test.el:
58 * automated/python-tests.el, automated/ruby-mode-tests.el:
59 * automated/xml-parse-tests.el: Explictly require ert.
60
612013-07-08 Kenichi Handa <handa@gnu.org>
62
63 * automated/decoder-tests.el (decoder-tests-prefer-utf-8-read):
64 Use with-ccoding-priority to avoid side-effect (Bug#14781).
65
12013-07-05 Michael Albinus <michael.albinus@gmx.de> 662013-07-05 Michael Albinus <michael.albinus@gmx.de>
2 67
3 * automated/file-notify-tests.el 68 * automated/file-notify-tests.el
@@ -71,7 +136,7 @@
71 Use it to create separate tests for each element, so we run them 136 Use it to create separate tests for each element, so we run them
72 all rather than stopping at the first error. 137 all rather than stopping at the first error.
73 138
742013-06-24 Glenn Morris <rgm@fencepost.gnu.org> 1392013-06-24 Glenn Morris <rgm@gnu.org>
75 140
76 * automated/occur-tests.el (occur-tests): 141 * automated/occur-tests.el (occur-tests):
77 Update for 2013-05-29 change to occur header line. 142 Update for 2013-05-29 change to occur header line.
diff --git a/test/automated/add-log-tests.el b/test/automated/add-log-tests.el
index f6e803cd317..bd073016505 100644
--- a/test/automated/add-log-tests.el
+++ b/test/automated/add-log-tests.el
@@ -22,6 +22,7 @@
22 22
23;;; Code: 23;;; Code:
24 24
25(require 'ert)
25(require 'add-log) 26(require 'add-log)
26 27
27(defmacro add-log-current-defun-deftest (name doc major-mode 28(defmacro add-log-current-defun-deftest (name doc major-mode
diff --git a/test/automated/advice-tests.el b/test/automated/advice-tests.el
index 8beaea64cd9..69c15e34ed0 100644
--- a/test/automated/advice-tests.el
+++ b/test/automated/advice-tests.el
@@ -21,6 +21,8 @@
21 21
22;;; Code: 22;;; Code:
23 23
24(require 'ert)
25
24(ert-deftest advice-tests-nadvice () 26(ert-deftest advice-tests-nadvice ()
25 "Test nadvice code." 27 "Test nadvice code."
26 (defun sm-test1 (x) (+ x 4)) 28 (defun sm-test1 (x) (+ x 4))
diff --git a/test/automated/cl-lib.el b/test/automated/cl-lib.el
new file mode 100644
index 00000000000..3a339e01734
--- /dev/null
+++ b/test/automated/cl-lib.el
@@ -0,0 +1,198 @@
1;;; cl-lib.el --- tests for emacs-lisp/cl-lib.el
2
3;; Copyright (C) 2013 Free Software Foundation, Inc.
4
5;; This file is part of GNU Emacs.
6
7;; This program is free software: you can redistribute it and/or
8;; modify it under the terms of the GNU General Public License as
9;; published by the Free Software Foundation, either version 3 of the
10;; License, or (at your option) any later version.
11;;
12;; This program is distributed in the hope that it will be useful, but
13;; WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15;; General Public License for more details.
16;;
17;; You should have received a copy of the GNU General Public License
18;; along with this program. If not, see `http://www.gnu.org/licenses/'.
19
20;;; Commentary:
21
22;; Extracted from ert-tests.el, back when ert used to reimplement some
23;; cl functions.
24
25;;; Code:
26
27(require 'cl-lib)
28(require 'ert)
29
30(ert-deftest cl-lib-test-remprop ()
31 (let ((x (cl-gensym)))
32 (should (equal (symbol-plist x) '()))
33 ;; Remove nonexistent property on empty plist.
34 (cl-remprop x 'b)
35 (should (equal (symbol-plist x) '()))
36 (put x 'a 1)
37 (should (equal (symbol-plist x) '(a 1)))
38 ;; Remove nonexistent property on nonempty plist.
39 (cl-remprop x 'b)
40 (should (equal (symbol-plist x) '(a 1)))
41 (put x 'b 2)
42 (put x 'c 3)
43 (put x 'd 4)
44 (should (equal (symbol-plist x) '(a 1 b 2 c 3 d 4)))
45 ;; Remove property that is neither first nor last.
46 (cl-remprop x 'c)
47 (should (equal (symbol-plist x) '(a 1 b 2 d 4)))
48 ;; Remove last property from a plist of length >1.
49 (cl-remprop x 'd)
50 (should (equal (symbol-plist x) '(a 1 b 2)))
51 ;; Remove first property from a plist of length >1.
52 (cl-remprop x 'a)
53 (should (equal (symbol-plist x) '(b 2)))
54 ;; Remove property when there is only one.
55 (cl-remprop x 'b)
56 (should (equal (symbol-plist x) '()))))
57
58(ert-deftest cl-lib-test-remove-if-not ()
59 (let ((list (list 'a 'b 'c 'd))
60 (i 0))
61 (let ((result (cl-remove-if-not (lambda (x)
62 (should (eql x (nth i list)))
63 (cl-incf i)
64 (member i '(2 3)))
65 list)))
66 (should (equal i 4))
67 (should (equal result '(b c)))
68 (should (equal list '(a b c d)))))
69 (should (equal '()
70 (cl-remove-if-not (lambda (_x) (should nil)) '()))))
71
72(ert-deftest cl-lib-test-remove ()
73 (let ((list (list 'a 'b 'c 'd))
74 (key-index 0)
75 (test-index 0))
76 (let ((result
77 (cl-remove 'foo list
78 :key (lambda (x)
79 (should (eql x (nth key-index list)))
80 (prog1
81 (list key-index x)
82 (cl-incf key-index)))
83 :test
84 (lambda (a b)
85 (should (eql a 'foo))
86 (should (equal b (list test-index
87 (nth test-index list))))
88 (cl-incf test-index)
89 (member test-index '(2 3))))))
90 (should (equal key-index 4))
91 (should (equal test-index 4))
92 (should (equal result '(a d)))
93 (should (equal list '(a b c d)))))
94 (let ((x (cons nil nil))
95 (y (cons nil nil)))
96 (should (equal (cl-remove x (list x y))
97 ;; or (list x), since we use `equal' -- the
98 ;; important thing is that only one element got
99 ;; removed, this proves that the default test is
100 ;; `eql', not `equal'
101 (list y)))))
102
103
104(ert-deftest cl-lib-test-set-functions ()
105 (let ((c1 (cons nil nil))
106 (c2 (cons nil nil))
107 (sym (make-symbol "a")))
108 (let ((e '())
109 (a (list 'a 'b sym nil "" "x" c1 c2))
110 (b (list c1 'y 'b sym 'x)))
111 (should (equal (cl-set-difference e e) e))
112 (should (equal (cl-set-difference a e) a))
113 (should (equal (cl-set-difference e a) e))
114 (should (equal (cl-set-difference a a) e))
115 (should (equal (cl-set-difference b e) b))
116 (should (equal (cl-set-difference e b) e))
117 (should (equal (cl-set-difference b b) e))
118 ;; Note: this test (and others) is sensitive to the order of the
119 ;; result, which is not documented.
120 (should (equal (cl-set-difference a b) (list c2 "x" "" nil 'a)))
121 (should (equal (cl-set-difference b a) (list 'x 'y)))
122
123 ;; We aren't testing whether this is really using `eq' rather than `eql'.
124 (should (equal (cl-set-difference e e :test 'eq) e))
125 (should (equal (cl-set-difference a e :test 'eq) a))
126 (should (equal (cl-set-difference e a :test 'eq) e))
127 (should (equal (cl-set-difference a a :test 'eq) e))
128 (should (equal (cl-set-difference b e :test 'eq) b))
129 (should (equal (cl-set-difference e b :test 'eq) e))
130 (should (equal (cl-set-difference b b :test 'eq) e))
131 (should (equal (cl-set-difference a b :test 'eq) (list c2 "x" "" nil 'a)))
132 (should (equal (cl-set-difference b a :test 'eq) (list 'x 'y)))
133
134 (should (equal (cl-union e e) e))
135 (should (equal (cl-union a e) a))
136 (should (equal (cl-union e a) a))
137 (should (equal (cl-union a a) a))
138 (should (equal (cl-union b e) b))
139 (should (equal (cl-union e b) b))
140 (should (equal (cl-union b b) b))
141 (should (equal (cl-union a b) (list 'x 'y 'a 'b sym nil "" "x" c1 c2)))
142
143 (should (equal (cl-union b a) (list 'x 'y 'a 'b sym nil "" "x" c1 c2)))
144
145 (should (equal (cl-intersection e e) e))
146 (should (equal (cl-intersection a e) e))
147 (should (equal (cl-intersection e a) e))
148 (should (equal (cl-intersection a a) a))
149 (should (equal (cl-intersection b e) e))
150 (should (equal (cl-intersection e b) e))
151 (should (equal (cl-intersection b b) b))
152 (should (equal (cl-intersection a b) (list sym 'b c1)))
153 (should (equal (cl-intersection b a) (list sym 'b c1))))))
154
155(ert-deftest cl-lib-test-gensym ()
156 ;; Since the expansion of `should' calls `cl-gensym' and thus has a
157 ;; side-effect on `cl--gensym-counter', we have to make sure all
158 ;; macros in our test body are expanded before we rebind
159 ;; `cl--gensym-counter' and run the body. Otherwise, the test would
160 ;; fail if run interpreted.
161 (let ((body (byte-compile
162 '(lambda ()
163 (should (equal (symbol-name (cl-gensym)) "G0"))
164 (should (equal (symbol-name (cl-gensym)) "G1"))
165 (should (equal (symbol-name (cl-gensym)) "G2"))
166 (should (equal (symbol-name (cl-gensym "foo")) "foo3"))
167 (should (equal (symbol-name (cl-gensym "bar")) "bar4"))
168 (should (equal cl--gensym-counter 5))))))
169 (let ((cl--gensym-counter 0))
170 (funcall body))))
171
172(ert-deftest cl-lib-test-coerce-to-vector ()
173 (let* ((a (vector))
174 (b (vector 1 a 3))
175 (c (list))
176 (d (list b a)))
177 (should (eql (cl-coerce a 'vector) a))
178 (should (eql (cl-coerce b 'vector) b))
179 (should (equal (cl-coerce c 'vector) (vector)))
180 (should (equal (cl-coerce d 'vector) (vector b a)))))
181
182(ert-deftest cl-lib-test-string-position ()
183 (should (eql (cl-position ?x "") nil))
184 (should (eql (cl-position ?a "abc") 0))
185 (should (eql (cl-position ?b "abc") 1))
186 (should (eql (cl-position ?c "abc") 2))
187 (should (eql (cl-position ?d "abc") nil))
188 (should (eql (cl-position ?A "abc") nil)))
189
190(ert-deftest cl-lib-test-mismatch ()
191 (should (eql (cl-mismatch "" "") nil))
192 (should (eql (cl-mismatch "" "a") 0))
193 (should (eql (cl-mismatch "a" "a") nil))
194 (should (eql (cl-mismatch "ab" "a") 1))
195 (should (eql (cl-mismatch "Aa" "aA") 0))
196 (should (eql (cl-mismatch '(a b c) '(a b d)) 2)))
197
198;;; cl-lib.el ends here
diff --git a/test/automated/decoder-tests.el b/test/automated/decoder-tests.el
index e1b05faf3c0..2e99fd7f115 100644
--- a/test/automated/decoder-tests.el
+++ b/test/automated/decoder-tests.el
@@ -213,10 +213,9 @@
213;; PREFER is non-nil, prefer that coding system before reading. 213;; PREFER is non-nil, prefer that coding system before reading.
214 214
215(defun decoder-tests-prefer-utf-8-read (file detect prefer) 215(defun decoder-tests-prefer-utf-8-read (file detect prefer)
216 (if prefer
217 (prefer-coding-system prefer))
218 (with-temp-buffer 216 (with-temp-buffer
219 (insert-file-contents file) 217 (with-coding-priority (if prefer (list prefer))
218 (insert-file-contents file))
220 (if (eq buffer-file-coding-system detect) 219 (if (eq buffer-file-coding-system detect)
221 nil 220 nil
222 (format "Invalid detection: %s" buffer-file-coding-system)))) 221 (format "Invalid detection: %s" buffer-file-coding-system))))
diff --git a/test/automated/ert-tests.el b/test/automated/ert-tests.el
index 0c3c3692c1d..36864377ec9 100644
--- a/test/automated/ert-tests.el
+++ b/test/automated/ert-tests.el
@@ -26,11 +26,9 @@
26 26
27;;; Code: 27;;; Code:
28 28
29(eval-when-compile 29(require 'cl-lib)
30 (require 'cl-lib))
31(require 'ert) 30(require 'ert)
32 31
33
34;;; Self-test that doesn't rely on ERT, for bootstrapping. 32;;; Self-test that doesn't rely on ERT, for bootstrapping.
35 33
36;; This is used to test that bodies actually run. 34;; This is used to test that bodies actually run.
@@ -578,7 +576,7 @@ This macro is used to test if macroexpansion in `should' works."
578 (should (ert--special-operator-p 'if)) 576 (should (ert--special-operator-p 'if))
579 (should-not (ert--special-operator-p 'car)) 577 (should-not (ert--special-operator-p 'car))
580 (should-not (ert--special-operator-p 'ert--special-operator-p)) 578 (should-not (ert--special-operator-p 'ert--special-operator-p))
581 (let ((b (ert--gensym))) 579 (let ((b (cl-gensym)))
582 (should-not (ert--special-operator-p b)) 580 (should-not (ert--special-operator-p b))
583 (fset b 'if) 581 (fset b 'if)
584 (should (ert--special-operator-p b)))) 582 (should (ert--special-operator-p b))))
@@ -626,171 +624,6 @@ This macro is used to test if macroexpansion in `should' works."
626 :explanation nil) 624 :explanation nil)
627 )))))) 625 ))))))
628 626
629(ert-deftest ert-test-remprop ()
630 (let ((x (ert--gensym)))
631 (should (equal (symbol-plist x) '()))
632 ;; Remove nonexistent property on empty plist.
633 (ert--remprop x 'b)
634 (should (equal (symbol-plist x) '()))
635 (put x 'a 1)
636 (should (equal (symbol-plist x) '(a 1)))
637 ;; Remove nonexistent property on nonempty plist.
638 (ert--remprop x 'b)
639 (should (equal (symbol-plist x) '(a 1)))
640 (put x 'b 2)
641 (put x 'c 3)
642 (put x 'd 4)
643 (should (equal (symbol-plist x) '(a 1 b 2 c 3 d 4)))
644 ;; Remove property that is neither first nor last.
645 (ert--remprop x 'c)
646 (should (equal (symbol-plist x) '(a 1 b 2 d 4)))
647 ;; Remove last property from a plist of length >1.
648 (ert--remprop x 'd)
649 (should (equal (symbol-plist x) '(a 1 b 2)))
650 ;; Remove first property from a plist of length >1.
651 (ert--remprop x 'a)
652 (should (equal (symbol-plist x) '(b 2)))
653 ;; Remove property when there is only one.
654 (ert--remprop x 'b)
655 (should (equal (symbol-plist x) '()))))
656
657(ert-deftest ert-test-remove-if-not ()
658 (let ((list (list 'a 'b 'c 'd))
659 (i 0))
660 (let ((result (ert--remove-if-not (lambda (x)
661 (should (eql x (nth i list)))
662 (cl-incf i)
663 (member i '(2 3)))
664 list)))
665 (should (equal i 4))
666 (should (equal result '(b c)))
667 (should (equal list '(a b c d)))))
668 (should (equal '()
669 (ert--remove-if-not (lambda (_x) (should nil)) '()))))
670
671(ert-deftest ert-test-remove* ()
672 (let ((list (list 'a 'b 'c 'd))
673 (key-index 0)
674 (test-index 0))
675 (let ((result
676 (ert--remove* 'foo list
677 :key (lambda (x)
678 (should (eql x (nth key-index list)))
679 (prog1
680 (list key-index x)
681 (cl-incf key-index)))
682 :test
683 (lambda (a b)
684 (should (eql a 'foo))
685 (should (equal b (list test-index
686 (nth test-index list))))
687 (cl-incf test-index)
688 (member test-index '(2 3))))))
689 (should (equal key-index 4))
690 (should (equal test-index 4))
691 (should (equal result '(a d)))
692 (should (equal list '(a b c d)))))
693 (let ((x (cons nil nil))
694 (y (cons nil nil)))
695 (should (equal (ert--remove* x (list x y))
696 ;; or (list x), since we use `equal' -- the
697 ;; important thing is that only one element got
698 ;; removed, this proves that the default test is
699 ;; `eql', not `equal'
700 (list y)))))
701
702
703(ert-deftest ert-test-set-functions ()
704 (let ((c1 (cons nil nil))
705 (c2 (cons nil nil))
706 (sym (make-symbol "a")))
707 (let ((e '())
708 (a (list 'a 'b sym nil "" "x" c1 c2))
709 (b (list c1 'y 'b sym 'x)))
710 (should (equal (ert--set-difference e e) e))
711 (should (equal (ert--set-difference a e) a))
712 (should (equal (ert--set-difference e a) e))
713 (should (equal (ert--set-difference a a) e))
714 (should (equal (ert--set-difference b e) b))
715 (should (equal (ert--set-difference e b) e))
716 (should (equal (ert--set-difference b b) e))
717 (should (equal (ert--set-difference a b) (list 'a nil "" "x" c2)))
718 (should (equal (ert--set-difference b a) (list 'y 'x)))
719
720 ;; We aren't testing whether this is really using `eq' rather than `eql'.
721 (should (equal (ert--set-difference-eq e e) e))
722 (should (equal (ert--set-difference-eq a e) a))
723 (should (equal (ert--set-difference-eq e a) e))
724 (should (equal (ert--set-difference-eq a a) e))
725 (should (equal (ert--set-difference-eq b e) b))
726 (should (equal (ert--set-difference-eq e b) e))
727 (should (equal (ert--set-difference-eq b b) e))
728 (should (equal (ert--set-difference-eq a b) (list 'a nil "" "x" c2)))
729 (should (equal (ert--set-difference-eq b a) (list 'y 'x)))
730
731 (should (equal (ert--union e e) e))
732 (should (equal (ert--union a e) a))
733 (should (equal (ert--union e a) a))
734 (should (equal (ert--union a a) a))
735 (should (equal (ert--union b e) b))
736 (should (equal (ert--union e b) b))
737 (should (equal (ert--union b b) b))
738 (should (equal (ert--union a b) (list 'a 'b sym nil "" "x" c1 c2 'y 'x)))
739 (should (equal (ert--union b a) (list c1 'y 'b sym 'x 'a nil "" "x" c2)))
740
741 (should (equal (ert--intersection e e) e))
742 (should (equal (ert--intersection a e) e))
743 (should (equal (ert--intersection e a) e))
744 (should (equal (ert--intersection a a) a))
745 (should (equal (ert--intersection b e) e))
746 (should (equal (ert--intersection e b) e))
747 (should (equal (ert--intersection b b) b))
748 (should (equal (ert--intersection a b) (list 'b sym c1)))
749 (should (equal (ert--intersection b a) (list c1 'b sym))))))
750
751(ert-deftest ert-test-gensym ()
752 ;; Since the expansion of `should' calls `ert--gensym' and thus has a
753 ;; side-effect on `ert--gensym-counter', we have to make sure all
754 ;; macros in our test body are expanded before we rebind
755 ;; `ert--gensym-counter' and run the body. Otherwise, the test would
756 ;; fail if run interpreted.
757 (let ((body (byte-compile
758 '(lambda ()
759 (should (equal (symbol-name (ert--gensym)) "G0"))
760 (should (equal (symbol-name (ert--gensym)) "G1"))
761 (should (equal (symbol-name (ert--gensym)) "G2"))
762 (should (equal (symbol-name (ert--gensym "foo")) "foo3"))
763 (should (equal (symbol-name (ert--gensym "bar")) "bar4"))
764 (should (equal ert--gensym-counter 5))))))
765 (let ((ert--gensym-counter 0))
766 (funcall body))))
767
768(ert-deftest ert-test-coerce-to-vector ()
769 (let* ((a (vector))
770 (b (vector 1 a 3))
771 (c (list))
772 (d (list b a)))
773 (should (eql (ert--coerce-to-vector a) a))
774 (should (eql (ert--coerce-to-vector b) b))
775 (should (equal (ert--coerce-to-vector c) (vector)))
776 (should (equal (ert--coerce-to-vector d) (vector b a)))))
777
778(ert-deftest ert-test-string-position ()
779 (should (eql (ert--string-position ?x "") nil))
780 (should (eql (ert--string-position ?a "abc") 0))
781 (should (eql (ert--string-position ?b "abc") 1))
782 (should (eql (ert--string-position ?c "abc") 2))
783 (should (eql (ert--string-position ?d "abc") nil))
784 (should (eql (ert--string-position ?A "abc") nil)))
785
786(ert-deftest ert-test-mismatch ()
787 (should (eql (ert--mismatch "" "") nil))
788 (should (eql (ert--mismatch "" "a") 0))
789 (should (eql (ert--mismatch "a" "a") nil))
790 (should (eql (ert--mismatch "ab" "a") 1))
791 (should (eql (ert--mismatch "Aa" "aA") 0))
792 (should (eql (ert--mismatch '(a b c) '(a b d)) 2)))
793
794(ert-deftest ert-test-string-first-line () 627(ert-deftest ert-test-string-first-line ()
795 (should (equal (ert--string-first-line "") "")) 628 (should (equal (ert--string-first-line "") ""))
796 (should (equal (ert--string-first-line "abc") "abc")) 629 (should (equal (ert--string-first-line "abc") "abc"))
diff --git a/test/automated/file-notify-tests.el b/test/automated/file-notify-tests.el
index 8fcfbe548fc..0e9be33f157 100644
--- a/test/automated/file-notify-tests.el
+++ b/test/automated/file-notify-tests.el
@@ -77,40 +77,46 @@
77 77
78(ert-deftest file-notify-test00-availability () 78(ert-deftest file-notify-test00-availability ()
79 "Test availability of `file-notify'." 79 "Test availability of `file-notify'."
80 :expected-result (if file-notify-support :passed :failed)
80 (should (memq file-notify-support '(gfilenotify inotify w32notify)))) 81 (should (memq file-notify-support '(gfilenotify inotify w32notify))))
81 82
82(ert-deftest file-notify-test01-add-watch () 83(when file-notify-support
83 "Check `file-notify-add-watch'."
84 (let (desc)
85 ;; Check, that different valid parameters are accepted.
86 (should (setq desc (file-notify-add-watch
87 temporary-file-directory '(change) 'ignore)))
88 (file-notify-rm-watch desc)
89 (should (setq desc (file-notify-add-watch
90 temporary-file-directory '(attribute-change) 'ignore)))
91 (file-notify-rm-watch desc)
92 (should (setq desc (file-notify-add-watch
93 temporary-file-directory
94 '(change attribute-change) 'ignore)))
95 (file-notify-rm-watch desc)
96
97 ;; Check error handling.
98 (should
99 (equal (car (should-error (file-notify-add-watch 1 2 3 4)))
100 'wrong-number-of-arguments))
101 (should
102 (equal (should-error (file-notify-add-watch 1 2 3))
103 '(wrong-type-argument 1)))
104 (should
105 (equal (should-error (file-notify-add-watch temporary-file-directory 2 3))
106 '(wrong-type-argument 2)))
107 (should
108 (equal (should-error (file-notify-add-watch
109 temporary-file-directory '(change) 3))
110 '(wrong-type-argument 3)))))
111 84
112(file-notify--deftest-remote file-notify-test01-add-watch 85 (ert-deftest file-notify-test01-add-watch ()
113 "Check `file-notify-add-watch' for remote files.") 86 "Check `file-notify-add-watch'."
87 (let (desc)
88 ;; Check, that different valid parameters are accepted.
89 (should (setq desc (file-notify-add-watch
90 temporary-file-directory '(change) 'ignore)))
91 (file-notify-rm-watch desc)
92 (should (setq desc (file-notify-add-watch
93 temporary-file-directory
94 '(attribute-change) 'ignore)))
95 (file-notify-rm-watch desc)
96 (should (setq desc (file-notify-add-watch
97 temporary-file-directory
98 '(change attribute-change) 'ignore)))
99 (file-notify-rm-watch desc)
100
101 ;; Check error handling.
102 (should
103 (equal (car (should-error (file-notify-add-watch 1 2 3 4)))
104 'wrong-number-of-arguments))
105 (should
106 (equal (should-error (file-notify-add-watch 1 2 3))
107 '(wrong-type-argument 1)))
108 (should
109 (equal (should-error (file-notify-add-watch
110 temporary-file-directory 2 3))
111 '(wrong-type-argument 2)))
112 (should
113 (equal (should-error (file-notify-add-watch
114 temporary-file-directory '(change) 3))
115 '(wrong-type-argument 3)))))
116
117 (file-notify--deftest-remote file-notify-test01-add-watch
118 "Check `file-notify-add-watch' for remote files.")
119 ) ;; file-notify-support
114 120
115(defun file-notify--test-event-test () 121(defun file-notify--test-event-test ()
116 "Ert test function to be called by `file-notify--test-event-handler'. 122 "Ert test function to be called by `file-notify--test-event-handler'.
@@ -141,52 +147,55 @@ Save the result in `file-notify--test-results', for later analysis."
141 (expand-file-name 147 (expand-file-name
142 (make-temp-name "file-notify-test") temporary-file-directory)) 148 (make-temp-name "file-notify-test") temporary-file-directory))
143 149
144(ert-deftest file-notify-test02-events () 150(when file-notify-support
145 "Check file creation/removal notifications." 151
146 (let (desc) 152 (ert-deftest file-notify-test02-events ()
147 (unwind-protect 153 "Check file creation/removal notifications."
148 (progn 154 (let (desc)
149 (setq file-notify--test-results nil 155 (unwind-protect
150 file-notify--test-tmpfile (file-notify--test-make-temp-name) 156 (progn
151 file-notify--test-tmpfile1 (file-notify--test-make-temp-name) 157 (setq file-notify--test-results nil
152 desc 158 file-notify--test-tmpfile (file-notify--test-make-temp-name)
153 (file-notify-add-watch 159 file-notify--test-tmpfile1 (file-notify--test-make-temp-name)
154 file-notify--test-tmpfile 160 desc
155 '(change) 'file-notify--test-event-handler)) 161 (file-notify-add-watch
156 162 file-notify--test-tmpfile
157 ;; Check creation and removal. 163 '(change) 'file-notify--test-event-handler))
158 (write-region "any text" nil file-notify--test-tmpfile) 164
159 (delete-file file-notify--test-tmpfile) 165 ;; Check creation and removal.
160 166 (write-region "any text" nil file-notify--test-tmpfile)
161 ;; Check copy and rename. 167 (delete-file file-notify--test-tmpfile)
162 (write-region "any text" nil file-notify--test-tmpfile) 168
163 (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1) 169 ;; Check copy and rename.
164 (delete-file file-notify--test-tmpfile) 170 (write-region "any text" nil file-notify--test-tmpfile)
165 (delete-file file-notify--test-tmpfile1) 171 (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1)
166 172 (delete-file file-notify--test-tmpfile)
167 (write-region "any text" nil file-notify--test-tmpfile) 173 (delete-file file-notify--test-tmpfile1)
168 (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1) 174
169 (delete-file file-notify--test-tmpfile1)) 175 (write-region "any text" nil file-notify--test-tmpfile)
170 176 (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1)
171 ;; Wait for events, and exit. 177 (delete-file file-notify--test-tmpfile1))
172 (sit-for 5 'nodisplay) 178
173 (file-notify-rm-watch desc) 179 ;; Wait for events, and exit.
174 (ignore-errors (delete-file file-notify--test-tmpfile)) 180 (sit-for 5 'nodisplay)
175 (ignore-errors (delete-file file-notify--test-tmpfile1)))) 181 (file-notify-rm-watch desc)
182 (ignore-errors (delete-file file-notify--test-tmpfile))
183 (ignore-errors (delete-file file-notify--test-tmpfile1))))
176 184
177 (dolist (result file-notify--test-results) 185 (dolist (result file-notify--test-results)
178 ;(message "%s" (ert-test-result-messages result)) 186 ;(message "%s" (ert-test-result-messages result))
179 (when (ert-test-failed-p result) 187 (when (ert-test-failed-p result)
180 (ert-fail (cadr (ert-test-result-with-condition-condition result)))))) 188 (ert-fail (cadr (ert-test-result-with-condition-condition result))))))
181 189
182(file-notify--deftest-remote file-notify-test02-events 190 (file-notify--deftest-remote file-notify-test02-events
183 "Check file creation/removal notifications for remote files.") 191 "Check file creation/removal notifications for remote files.")
192 ) ;; file-notify-support
184 193
185;; autorevert runs only in interactive mode. 194;; autorevert runs only in interactive mode.
186(defvar auto-revert-remote-files) 195(defvar auto-revert-remote-files)
187(setq auto-revert-remote-files t) 196(setq auto-revert-remote-files t)
188(require 'autorevert) 197(require 'autorevert)
189(when (null noninteractive) 198(when (and file-notify-support (null noninteractive))
190 199
191 (ert-deftest file-notify-test03-autorevert () 200 (ert-deftest file-notify-test03-autorevert ()
192 "Check autorevert via file notification. 201 "Check autorevert via file notification.
@@ -240,7 +249,7 @@ This test is skipped in batch mode."
240 (file-notify--deftest-remote file-notify-test03-autorevert 249 (file-notify--deftest-remote file-notify-test03-autorevert
241 "Check autorevert via file notification for remote files. 250 "Check autorevert via file notification for remote files.
242This test is skipped in batch mode.") 251This test is skipped in batch mode.")
243 ) ;; (null noninteractive) 252 ) ;; (and file-notify-support (null noninteractive))
244 253
245(defun file-notify-test-all (&optional interactive) 254(defun file-notify-test-all (&optional interactive)
246 "Run all tests for \\[file-notify]." 255 "Run all tests for \\[file-notify]."
diff --git a/test/automated/files.el b/test/automated/files.el
index f2d2192a420..8ce2ed7230c 100644
--- a/test/automated/files.el
+++ b/test/automated/files.el
@@ -146,4 +146,7 @@ form.")
146 (should (file-test--do-local-variables-test str subtest)))))) 146 (should (file-test--do-local-variables-test str subtest))))))
147 (ad-disable-advice 'hack-local-variables-confirm 'around 'files-test))) 147 (ad-disable-advice 'hack-local-variables-confirm 'around 'files-test)))
148 148
149;; Stop the above "Local Var..." confusing Emacs.
150
151
149;;; files.el ends here 152;;; files.el ends here
diff --git a/test/automated/flymake-tests.el b/test/automated/flymake-tests.el
index 9cc87b608ad..03a8fb08bc5 100644
--- a/test/automated/flymake-tests.el
+++ b/test/automated/flymake-tests.el
@@ -25,9 +25,6 @@
25(require 'ert) 25(require 'ert)
26(require 'flymake) 26(require 'flymake)
27 27
28(defgroup flymake-tests nil
29 "Test suite for flymake.")
30
31 28
32;; Warning predicate 29;; Warning predicate
33(defun flymake-tests--current-face (file predicate) 30(defun flymake-tests--current-face (file predicate)
diff --git a/test/automated/icalendar-tests.el b/test/automated/icalendar-tests.el
index bca462da4d9..28fa47630a8 100644
--- a/test/automated/icalendar-tests.el
+++ b/test/automated/icalendar-tests.el
@@ -1194,8 +1194,7 @@ Argument INPUT icalendar event string."
1194 (should (string= org-input cycled))))) 1194 (should (string= org-input cycled)))))
1195 ;; clean up 1195 ;; clean up
1196 (kill-buffer (find-buffer-visiting temp-diary)) 1196 (kill-buffer (find-buffer-visiting temp-diary))
1197 (save-excursion 1197 (with-current-buffer (find-buffer-visiting temp-ics)
1198 (set-buffer (find-buffer-visiting temp-ics))
1199 (set-buffer-modified-p nil) 1198 (set-buffer-modified-p nil)
1200 (kill-buffer (current-buffer))) 1199 (kill-buffer (current-buffer)))
1201 (delete-file temp-diary) 1200 (delete-file temp-diary)
diff --git a/test/automated/imenu-test.el b/test/automated/imenu-test.el
index 83e19ebd914..b2b0c6b5c31 100644
--- a/test/automated/imenu-test.el
+++ b/test/automated/imenu-test.el
@@ -22,6 +22,7 @@
22 22
23;;; Code: 23;;; Code:
24 24
25(require 'ert)
25(require 'imenu) 26(require 'imenu)
26 27
27;; (imenu-simple-scan-deftest-gather-strings-from-list 28;; (imenu-simple-scan-deftest-gather-strings-from-list
diff --git a/test/automated/inotify-test.el b/test/automated/inotify-test.el
index 175f262b282..b4d20cf4fb1 100644
--- a/test/automated/inotify-test.el
+++ b/test/automated/inotify-test.el
@@ -25,6 +25,9 @@
25 25
26(require 'ert) 26(require 'ert)
27 27
28(declare-function inotify-add-watch "inotify.c" (file-name aspect callback))
29(declare-function inotify-rm-watch "inotify.c" (watch-descriptor))
30
28(when (featurep 'inotify) 31(when (featurep 'inotify)
29 32
30 ;; (ert-deftest filewatch-file-watch-aspects-check () 33 ;; (ert-deftest filewatch-file-watch-aspects-check ()
@@ -45,7 +48,7 @@
45 (let ((temp-file (make-temp-file "inotify-simple")) 48 (let ((temp-file (make-temp-file "inotify-simple"))
46 (events 0)) 49 (events 0))
47 (let ((wd 50 (let ((wd
48 (inotify-add-watch temp-file t (lambda (ev) 51 (inotify-add-watch temp-file t (lambda (_ev)
49 (setq events (1+ events)))))) 52 (setq events (1+ events))))))
50 (unwind-protect 53 (unwind-protect
51 (progn 54 (progn
diff --git a/test/automated/package-test.el b/test/automated/package-test.el
index 706ba953d98..a5f0ebb1f94 100755
--- a/test/automated/package-test.el
+++ b/test/automated/package-test.el
@@ -142,6 +142,9 @@
142 (let ((help-xref-following t)) 142 (let ((help-xref-following t))
143 ,@body))) 143 ,@body)))
144 144
145(autoload 'makeinfo-buffer "makeinfo")
146(defvar compilation-in-progress)
147
145(defun package-test-install-texinfo (file) 148(defun package-test-install-texinfo (file)
146 "Install from texinfo FILE. 149 "Install from texinfo FILE.
147 150
@@ -156,7 +159,6 @@ FILE should be a .texinfo file relative to the current
156 (with-current-buffer (find-file-literally full-file) 159 (with-current-buffer (find-file-literally full-file)
157 (unwind-protect 160 (unwind-protect
158 (progn 161 (progn
159 (require 'makeinfo)
160 (makeinfo-buffer) 162 (makeinfo-buffer)
161 ;; Give `makeinfo-buffer' a chance to finish 163 ;; Give `makeinfo-buffer' a chance to finish
162 (while compilation-in-progress 164 (while compilation-in-progress
@@ -184,6 +186,9 @@ DIR is the base name of the package directory, without the trailing slash"
184 (dolist (file (package-test-suffix-matches dir package-test-built-file-suffixes)) 186 (dolist (file (package-test-suffix-matches dir package-test-built-file-suffixes))
185 (delete-file file)))) 187 (delete-file file))))
186 188
189(defvar tar-parse-info)
190(declare-function tar-header-name "tar-mode" (cl-x) t) ; defstruct
191
187(defun package-test-search-tar-file (filename) 192(defun package-test-search-tar-file (filename)
188 "Search the current buffer's `tar-parse-info' variable for FILENAME. 193 "Search the current buffer's `tar-parse-info' variable for FILENAME.
189 194
diff --git a/test/automated/package-x-test.el b/test/automated/package-x-test.el
index b8f2a23f6d5..beb18358085 100755
--- a/test/automated/package-x-test.el
+++ b/test/automated/package-x-test.el
@@ -35,6 +35,7 @@
35(require 'package-x) 35(require 'package-x)
36(require 'ert) 36(require 'ert)
37(require 'cl-lib) 37(require 'cl-lib)
38(eval-when-compile (require 'package-test))
38 39
39;; package-test is not normally in `load-path', so temporarily set 40;; package-test is not normally in `load-path', so temporarily set
40;; `load-path' to contain the current directory. 41;; `load-path' to contain the current directory.
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el
index 40505cc7953..1dffe9544fe 100644
--- a/test/automated/python-tests.el
+++ b/test/automated/python-tests.el
@@ -21,6 +21,7 @@
21 21
22;;; Code: 22;;; Code:
23 23
24(require 'ert)
24(require 'python) 25(require 'python)
25 26
26(defmacro python-tests-with-temp-buffer (contents &rest body) 27(defmacro python-tests-with-temp-buffer (contents &rest body)
@@ -463,10 +464,10 @@ Class foo(object):
463" 464"
464 (python-tests-look-at "3)") 465 (python-tests-look-at "3)")
465 (forward-line 1) 466 (forward-line 1)
466 (= (python-indent-calculate-indentation) 12) 467 (should (= (python-indent-calculate-indentation) 8))
467 (python-tests-look-at "pass") 468 (python-tests-look-at "pass")
468 (forward-line 1) 469 (forward-line 1)
469 (= (python-indent-calculate-indentation) 8))) 470 (should (= (python-indent-calculate-indentation) 8))))
470 471
471 472
472;;; Navigation 473;;; Navigation
diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el
index 02582e8ad2d..ad805f16777 100644
--- a/test/automated/ruby-mode-tests.el
+++ b/test/automated/ruby-mode-tests.el
@@ -21,6 +21,7 @@
21 21
22;;; Code: 22;;; Code:
23 23
24(require 'ert)
24(require 'ruby-mode) 25(require 'ruby-mode)
25 26
26(defun ruby-should-indent (content column) 27(defun ruby-should-indent (content column)
@@ -474,29 +475,30 @@ VALUES-PLIST is a list with alternating index and value elements."
474 (with-temp-buffer 475 (with-temp-buffer
475 (insert ruby-block-test-example) 476 (insert ruby-block-test-example)
476 (ruby-mode) 477 (ruby-mode)
478 (goto-char (point-min))
477 ,@body))) 479 ,@body)))
478 480
479(put 'ruby-deftest-move-to-block 'lisp-indent-function 'defun) 481(put 'ruby-deftest-move-to-block 'lisp-indent-function 'defun)
480 482
481(ruby-deftest-move-to-block works-on-do 483(ruby-deftest-move-to-block works-on-do
482 (goto-line 11) 484 (forward-line 10)
483 (ruby-end-of-block) 485 (ruby-end-of-block)
484 (should (= 13 (line-number-at-pos))) 486 (should (= 13 (line-number-at-pos)))
485 (ruby-beginning-of-block) 487 (ruby-beginning-of-block)
486 (should (= 11 (line-number-at-pos)))) 488 (should (= 11 (line-number-at-pos))))
487 489
488(ruby-deftest-move-to-block zero-is-noop 490(ruby-deftest-move-to-block zero-is-noop
489 (goto-line 5) 491 (forward-line 4)
490 (ruby-move-to-block 0) 492 (ruby-move-to-block 0)
491 (should (= 5 (line-number-at-pos)))) 493 (should (= 5 (line-number-at-pos))))
492 494
493(ruby-deftest-move-to-block ok-with-three 495(ruby-deftest-move-to-block ok-with-three
494 (goto-line 2) 496 (forward-line 1)
495 (ruby-move-to-block 3) 497 (ruby-move-to-block 3)
496 (should (= 14 (line-number-at-pos)))) 498 (should (= 14 (line-number-at-pos))))
497 499
498(ruby-deftest-move-to-block ok-with-minus-two 500(ruby-deftest-move-to-block ok-with-minus-two
499 (goto-line 10) 501 (forward-line 9)
500 (ruby-move-to-block -2) 502 (ruby-move-to-block -2)
501 (should (= 2 (line-number-at-pos)))) 503 (should (= 2 (line-number-at-pos))))
502 504
@@ -514,7 +516,7 @@ VALUES-PLIST is a list with alternating index and value elements."
514 | | 516 | |
515 |end"))) 517 |end")))
516 (ruby-with-temp-buffer s 518 (ruby-with-temp-buffer s
517 (goto-line 1) 519 (goto-char (point-min))
518 (ruby-end-of-block) 520 (ruby-end-of-block)
519 (should (= 5 (line-number-at-pos))) 521 (should (= 5 (line-number-at-pos)))
520 (ruby-beginning-of-block) 522 (ruby-beginning-of-block)
@@ -529,7 +531,7 @@ VALUES-PLIST is a list with alternating index and value elements."
529 | end 531 | end
530 | eowarn 532 | eowarn
531 |end") 533 |end")
532 (goto-line 1) 534 (goto-char (point-min))
533 (ruby-end-of-block) 535 (ruby-end-of-block)
534 (should (= 6 (line-number-at-pos))) 536 (should (= 6 (line-number-at-pos)))
535 (ruby-beginning-of-block) 537 (ruby-beginning-of-block)
@@ -541,7 +543,6 @@ VALUES-PLIST is a list with alternating index and value elements."
541 "foo do 543 "foo do
542 | Module.to_s 544 | Module.to_s
543 |end") 545 |end")
544 (end-of-buffer)
545 (let ((case-fold-search t)) 546 (let ((case-fold-search t))
546 (ruby-beginning-of-block)) 547 (ruby-beginning-of-block))
547 (should (= 1 (line-number-at-pos))))) 548 (should (= 1 (line-number-at-pos)))))
@@ -553,7 +554,8 @@ VALUES-PLIST is a list with alternating index and value elements."
553 | end 554 | end
554 |else 555 |else
555 |end") 556 |end")
556 (goto-line 4) 557 (goto-char (point-min))
558 (forward-line 3)
557 (ruby-beginning-of-block) 559 (ruby-beginning-of-block)
558 (should (= 1 (line-number-at-pos))))) 560 (should (= 1 (line-number-at-pos)))))
559 561
@@ -565,7 +567,8 @@ VALUES-PLIST is a list with alternating index and value elements."
565 | Class.to_s 567 | Class.to_s
566 | end 568 | end
567 |end") 569 |end")
568 (goto-line 4) 570 (goto-char (point-min))
571 (forward-line 3)
569 (let ((case-fold-search t)) 572 (let ((case-fold-search t))
570 (beginning-of-defun)) 573 (beginning-of-defun))
571 (should (= 2 (line-number-at-pos))))) 574 (should (= 2 (line-number-at-pos)))))
@@ -578,7 +581,8 @@ VALUES-PLIST is a list with alternating index and value elements."
578 | 'ho hum' 581 | 'ho hum'
579 | end 582 | end
580 |end") 583 |end")
581 (goto-line 2) 584 (goto-char (point-min))
585 (forward-line 1)
582 (end-of-defun) 586 (end-of-defun)
583 (should (= 5 (line-number-at-pos))))) 587 (should (= 5 (line-number-at-pos)))))
584 588
diff --git a/test/automated/undo-tests.el b/test/automated/undo-tests.el
index 98b0c52728b..87c55c5d374 100644
--- a/test/automated/undo-tests.el
+++ b/test/automated/undo-tests.el
@@ -200,6 +200,32 @@
200 '(error "Unrecognized entry in undo list \"bogus\"")))) 200 '(error "Unrecognized entry in undo list \"bogus\""))))
201 (buffer-string)))))) 201 (buffer-string))))))
202 202
203;; http://debbugs.gnu.org/14824
204(ert-deftest undo-test-buffer-modified ()
205 "Test undoing marks buffer unmodified."
206 (with-temp-buffer
207 (buffer-enable-undo)
208 (insert "1")
209 (undo-boundary)
210 (set-buffer-modified-p nil)
211 (insert "2")
212 (undo)
213 (should-not (buffer-modified-p))))
214
215(ert-deftest undo-test-file-modified ()
216 "Test undoing marks buffer visiting file unmodified."
217 (let ((tempfile (make-temp-file "undo-test")))
218 (unwind-protect
219 (progn
220 (with-current-buffer (find-file-noselect tempfile)
221 (insert "1")
222 (undo-boundary)
223 (set-buffer-modified-p nil)
224 (insert "2")
225 (undo)
226 (should-not (buffer-modified-p))))
227 (delete-file tempfile))))
228
203(defun undo-test-all (&optional interactive) 229(defun undo-test-all (&optional interactive)
204 "Run all tests for \\[undo]." 230 "Run all tests for \\[undo]."
205 (interactive "p") 231 (interactive "p")
diff --git a/test/automated/xml-parse-tests.el b/test/automated/xml-parse-tests.el
index 874ae01affb..9157a0d3002 100644
--- a/test/automated/xml-parse-tests.el
+++ b/test/automated/xml-parse-tests.el
@@ -27,6 +27,7 @@
27 27
28;;; Code: 28;;; Code:
29 29
30(require 'ert)
30(require 'xml) 31(require 'xml)
31 32
32(defvar xml-parse-tests--data 33(defvar xml-parse-tests--data