aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTom Tromey2013-01-05 19:36:45 -0700
committerTom Tromey2013-01-05 19:36:45 -0700
commite078a23febca14bc919c5806670479c395e3253e (patch)
treee9e4ed91feef744d525264c31974c3ed00146bcd /src
parent63d535c829a930207b64fe733228f15a554644b1 (diff)
parent7a2657fa3bedbd977f4e11fe030cb4a210c04ab4 (diff)
downloademacs-e078a23febca14bc919c5806670479c395e3253e.tar.gz
emacs-e078a23febca14bc919c5806670479c395e3253e.zip
merge from trunk
Diffstat (limited to 'src')
-rw-r--r--src/.gdbinit6
-rw-r--r--src/ChangeLog385
-rw-r--r--src/ChangeLog.12
-rw-r--r--src/ChangeLog.102
-rw-r--r--src/ChangeLog.112
-rw-r--r--src/ChangeLog.22
-rw-r--r--src/ChangeLog.32
-rw-r--r--src/ChangeLog.42
-rw-r--r--src/ChangeLog.52
-rw-r--r--src/ChangeLog.62
-rw-r--r--src/ChangeLog.72
-rw-r--r--src/ChangeLog.82
-rw-r--r--src/ChangeLog.92
-rw-r--r--src/Makefile.in14
-rw-r--r--src/README2
-rw-r--r--src/alloc.c16
-rw-r--r--src/atimer.c2
-rw-r--r--src/atimer.h2
-rw-r--r--src/bidi.c4
-rw-r--r--src/blockinput.h2
-rw-r--r--src/buffer.c16
-rw-r--r--src/buffer.h7
-rw-r--r--src/bytecode.c3
-rw-r--r--src/callint.c4
-rw-r--r--src/casefiddle.c3
-rw-r--r--src/casetab.c2
-rw-r--r--src/category.c2
-rw-r--r--src/ccl.c2
-rw-r--r--src/character.c2
-rw-r--r--src/charset.c2
-rw-r--r--src/charset.h2
-rw-r--r--src/cm.c2
-rw-r--r--src/cm.h2
-rw-r--r--src/cmds.c2
-rw-r--r--src/coding.c9
-rw-r--r--src/coding.h4
-rw-r--r--src/commands.h2
-rw-r--r--src/composite.c2
-rw-r--r--src/composite.h2
-rw-r--r--src/conf_post.h12
-rw-r--r--src/cygw32.c20
-rw-r--r--src/cygw32.h2
-rw-r--r--src/data.c6
-rw-r--r--src/dbusbind.c2
-rw-r--r--src/deps.mk4
-rw-r--r--src/dired.c8
-rw-r--r--src/dispextern.h15
-rw-r--r--src/dispnew.c3
-rw-r--r--src/disptab.h2
-rw-r--r--src/doc.c12
-rw-r--r--src/doprnt.c2
-rw-r--r--src/dosfns.c3
-rw-r--r--src/dosfns.h4
-rw-r--r--src/editfns.c13
-rw-r--r--src/emacs-icon.h2
-rw-r--r--src/emacs.c4
-rw-r--r--src/emacsgtkfixed.c2
-rw-r--r--src/emacsgtkfixed.h2
-rw-r--r--src/epaths.in4
-rw-r--r--src/eval.c3
-rw-r--r--src/fileio.c212
-rw-r--r--src/filelock.c4
-rw-r--r--src/firstfile.c2
-rw-r--r--src/floatfns.c8
-rw-r--r--src/fns.c24
-rw-r--r--src/font.c15
-rw-r--r--src/font.h2
-rw-r--r--src/fontset.c2
-rw-r--r--src/fontset.h2
-rw-r--r--src/frame.c6
-rw-r--r--src/frame.h5
-rw-r--r--src/fringe.c7
-rw-r--r--src/ftfont.c2
-rw-r--r--src/ftxfont.c2
-rw-r--r--src/getpagesize.h3
-rw-r--r--src/gmalloc.c40
-rw-r--r--src/gnutls.c2
-rw-r--r--src/gnutls.h2
-rw-r--r--src/gtkutil.c105
-rw-r--r--src/gtkutil.h2
-rw-r--r--src/image.c2
-rw-r--r--src/indent.c7
-rw-r--r--src/indent.h2
-rw-r--r--src/inotify.c3
-rw-r--r--src/insdel.c6
-rw-r--r--src/intervals.c6
-rw-r--r--src/intervals.h2
-rw-r--r--src/keyboard.c41
-rw-r--r--src/keyboard.h3
-rw-r--r--src/keymap.c5
-rw-r--r--src/keymap.h2
-rw-r--r--src/lastfile.c2
-rw-r--r--src/lisp.h12
-rw-r--r--src/lisp.mk4
-rw-r--r--src/lread.c6
-rw-r--r--src/macros.c2
-rw-r--r--src/macros.h2
-rw-r--r--src/makefile.w32-in6
-rw-r--r--src/marker.c24
-rw-r--r--src/mem-limits.h3
-rw-r--r--src/menu.c4
-rw-r--r--src/menu.h2
-rw-r--r--src/minibuf.c9
-rw-r--r--src/msdos.c2
-rw-r--r--src/msdos.h2
-rw-r--r--src/nsfns.m15
-rw-r--r--src/nsfont.m2
-rw-r--r--src/nsgui.h2
-rw-r--r--src/nsimage.m4
-rw-r--r--src/nsmenu.m2
-rw-r--r--src/nsselect.m4
-rw-r--r--src/nsterm.h3
-rw-r--r--src/nsterm.m17
-rw-r--r--src/print.c46
-rw-r--r--src/process.c28
-rw-r--r--src/process.h2
-rw-r--r--src/profiler.c2
-rw-r--r--src/puresize.h2
-rw-r--r--src/ralloc.c2
-rw-r--r--src/regex.c6
-rw-r--r--src/regex.h8
-rw-r--r--src/region-cache.c4
-rw-r--r--src/region-cache.h4
-rw-r--r--src/scroll.c4
-rw-r--r--src/search.c13
-rw-r--r--src/sheap.c2
-rw-r--r--src/sound.c2
-rw-r--r--src/syntax.c4
-rw-r--r--src/syntax.h4
-rw-r--r--src/sysdep.c6
-rw-r--r--src/sysselect.h2
-rw-r--r--src/syssignal.h2
-rw-r--r--src/systime.h2
-rw-r--r--src/systty.h2
-rw-r--r--src/syswait.h2
-rw-r--r--src/term.c8
-rw-r--r--src/termcap.c8
-rw-r--r--src/termchar.h2
-rw-r--r--src/termhooks.h3
-rw-r--r--src/terminal.c4
-rw-r--r--src/terminfo.c2
-rw-r--r--src/termopts.h3
-rw-r--r--src/textprop.c21
-rw-r--r--src/tparam.c8
-rw-r--r--src/tparam.h2
-rw-r--r--src/undo.c3
-rw-r--r--src/unexaix.c3
-rw-r--r--src/unexcoff.c3
-rw-r--r--src/unexcw.c2
-rw-r--r--src/unexelf.c4
-rw-r--r--src/unexmacosx.c2
-rw-r--r--src/unexw32.c2
-rw-r--r--src/vm-limit.c2
-rw-r--r--src/w16select.c2
-rw-r--r--src/w32.c515
-rw-r--r--src/w32.h2
-rw-r--r--src/w32common.h2
-rw-r--r--src/w32console.c2
-rw-r--r--src/w32fns.c2
-rw-r--r--src/w32font.c2
-rw-r--r--src/w32font.h2
-rw-r--r--src/w32gui.h2
-rw-r--r--src/w32heap.c2
-rw-r--r--src/w32heap.h2
-rw-r--r--src/w32inevt.c3
-rw-r--r--src/w32inevt.h2
-rw-r--r--src/w32menu.c4
-rw-r--r--src/w32notify.c2
-rw-r--r--src/w32proc.c38
-rw-r--r--src/w32reg.c3
-rw-r--r--src/w32select.c2
-rw-r--r--src/w32select.h2
-rw-r--r--src/w32term.c82
-rw-r--r--src/w32term.h2
-rw-r--r--src/w32uniscribe.c2
-rw-r--r--src/w32xfns.c3
-rw-r--r--src/widget.c2
-rw-r--r--src/widget.h2
-rw-r--r--src/widgetprv.h2
-rw-r--r--src/window.c47
-rw-r--r--src/window.h12
-rw-r--r--src/xdisp.c156
-rw-r--r--src/xfaces.c2
-rw-r--r--src/xfns.c2
-rw-r--r--src/xfont.c2
-rw-r--r--src/xftfont.c2
-rw-r--r--src/xgselect.c2
-rw-r--r--src/xgselect.h2
-rw-r--r--src/xmenu.c4
-rw-r--r--src/xml.c2
-rw-r--r--src/xrdb.c3
-rw-r--r--src/xselect.c2
-rw-r--r--src/xsettings.c2
-rw-r--r--src/xsettings.h2
-rw-r--r--src/xsmfns.c2
-rw-r--r--src/xterm.c15
-rw-r--r--src/xterm.h12
197 files changed, 1767 insertions, 726 deletions
diff --git a/src/.gdbinit b/src/.gdbinit
index e1ee81e66b5..4688b0a4421 100644
--- a/src/.gdbinit
+++ b/src/.gdbinit
@@ -1,4 +1,4 @@
1# Copyright (C) 1992-1998, 2000-2012 Free Software Foundation, Inc. 1# Copyright (C) 1992-1998, 2000-2013 Free Software Foundation, Inc.
2# 2#
3# This file is part of GNU Emacs. 3# This file is part of GNU Emacs.
4# 4#
@@ -13,9 +13,7 @@
13# GNU General Public License for more details. 13# GNU General Public License for more details.
14# 14#
15# You should have received a copy of the GNU General Public License 15# You should have received a copy of the GNU General Public License
16# along with GNU Emacs; see the file COPYING. If not, write to the 16# along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
17# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18# Boston, MA 02110-1301, USA.
19 17
20# Force loading of symbols, enough to give us VALBITS etc. 18# Force loading of symbols, enough to give us VALBITS etc.
21set $dummy = main + 8 19set $dummy = main + 8
diff --git a/src/ChangeLog b/src/ChangeLog
index 3cf105c8003..c0c85c15ee9 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,9 +1,369 @@
12013-01-05 Eli Zaretskii <eliz@gnu.org>
2
3 * xdisp.c (dump_glyph): Align glyph data better. Use "pD" instead
4 of a non-portable "t" to print ptrdiff_t values. Allow up to 9
5 digits for buffer positions, before misalignment starts. Display
6 "0" for integer "object" field.
7 (dump_glyph_row): Adapt the header line to changes in dump_glyph.
8 Display the newline glyph more unambiguously.
9
102013-01-04 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
11
12 * nsterm.m (ns_draw_underwave):
13 * w32term.c (w32_draw_underwave):
14 * xterm.c (x_draw_underwave): Make underwave look more triangular
15 and also degrade gracefully for small fonts. (Bug#13000)
16
17 * nsterm.m (ns_draw_text_decoration):
18 * w32term.c (x_draw_glyph_string):
19 * xterm.c (x_draw_glyph_string): Don't use previous underline
20 thickness and position if previous underline type is underwave.
21
222013-01-04 Stefan Monnier <monnier@iro.umontreal.ca>
23
24 * fileio.c (Ffile_acl): Undocument return format.
25
262013-01-02 Glenn Morris <rgm@gnu.org>
27
28 * keymap.c (Fkey_description): Doc fix. (Bug#13323)
29
302013-01-02 Paul Eggert <eggert@cs.ucla.edu>
31
32 Simplify via eabs.
33 * dired.c (file_name_completion):
34 * doc.c (get_doc_string):
35 * floatfns.c (round2):
36 * font.c (font_score, font_delete_unmatched):
37 * fringe.c (compute_fringe_widths):
38 * lread.c (read_list):
39 * minibuf.c (Ftry_completion):
40 * term.c (tty_ins_del_lines):
41 * xterm.c (x_draw_image_foreground, x_draw_image_foreground_1):
42 Use eabs (x) rather than open-coding it as (x < 0 ? -x : x).
43
442012-12-31 Eli Zaretskii <eliz@gnu.org>
45
46 * w32.c (unsetenv): Set up the string passed to _putenv
47 correctly. See
48 http://lists.gnu.org/archive/html/emacs-devel/2012-12/msg00863.html
49 for the bug this caused.
50
512012-12-30 Paul Eggert <eggert@cs.ucla.edu>
52
53 * coding.c (Qmac): Now static.
54
552012-12-30 Jan Djärv <jan.h.d@swipnet.se>
56
57 * gtkutil.c (TOOLBAR_TOP_WIDGET): New macro.
58 (xg_pack_tool_bar): Use TOOLBAR_TOP_WIDGET, condition out use of
59 handlebox_widget. Set toolbar_in_hbox to false/true, set
60 toolbar_is_packed to true.
61 (xg_update_tool_bar_sizes): Use widget returned by TOOLBAR_TOP_WIDGET.
62 (update_frame_tool_bar): Check toolbar_is_packed for packing.
63 Show all on TOOLBAR_TOP_WIDGET.
64 (free_frame_tool_bar): Check toolbar_is_packed. Use widget returned
65 by TOOLBAR_TOP_WIDGET.
66 (xg_change_toolbar_position): Use widget returned by TOOLBAR_TOP_WIDGET.
67 Check toolbar_is_packed.
68 (xg_have_tear_offs, tearoff_remove, tearoff_activate): Condition on
69 HAVE_GTK_TEAROFF_MENU_ITEM_NEW.
70 (xg_have_tear_offs): When ! HAVE_GTK_TEAROFF_MENU_ITEM_NEW, return
71 false.
72 (create_menus): Create tearoff only if HAVE_GTK_TEAROFF_MENU_ITEM_NEW.
73 (xg_update_menubar): Update title only if
74 HAVE_GTK_TEAROFF_MENU_ITEM_NEW.
75 (xg_update_submenu): Skip tearoff only if
76 HAVE_GTK_TEAROFF_MENU_ITEM_NEW.
77 (xg_initialize): Initialize xg_detached_menus only if
78 HAVE_GTK_TEAROFF_MENU_ITEM_NEW.
79
80 * xterm.h (struct x_output): Surround handlebox_widget with
81 #ifdef HAVE_GTK_HANDLE_BOX_NEW. toolbar_is_packed is new,
82 toolbar_in_hbox is bool.
83
842012-12-30 Andreas Schwab <schwab@linux-m68k.org>
85
86 * src/Makefile.in (TEMACS_LDFLAGS2): Remove.
87 (LIBS_GNUSTEP): Define.
88 (LIBES): Add $(LIBS_GNUSTEP).
89 (temacs$(EXEEXT)): Use $(LDFLAGS) instead of $(TEMACS_LDFLAGS2).
90
912012-12-30 Eli Zaretskii <eliz@gnu.org>
92
93 * xdisp.c (set_cursor_from_row): Don't confuse a truncation or
94 continuation glyph on a TTY with an indication of an empty line.
95 (Bug#13277)
96
972012-12-29 Eli Zaretskii <eliz@gnu.org>
98
99 * fileio.c (Fset_file_selinux_context, Fset_file_acl): Return t if
100 file's SELinux context or ACLs successfully set, nil otherwise.
101 (Bug#13298)
102 (Fcopy_file) [WINDOWSNT]: Improve diagnostics when CopyFile fails.
103
104 * w32proc.c (reader_thread): Avoid passing NULL handles to
105 SetEvent and WaitForSingleObject.
106
1072012-12-28 Paul Eggert <eggert@cs.ucla.edu>
108
109 Port EXTERNALLY_VISIBLE to Clang 3.2.
110 * conf_post.h (__has_attribute): New macro.
111 (EXTERNALLY_VISIBLE): Use it. This ports to Clang 3.2.
112
1132012-12-27 Glenn Morris <rgm@gnu.org>
114
115 * cygw32.c (Fcygwin_convert_file_name_to_windows)
116 (Fcygwin_convert_file_name_from_windows): Doc fixes.
117
1182012-12-27 Eli Zaretskii <eliz@gnu.org>
119
120 * fileio.c (file_name_as_directory, directory_file_name): Accept
121 an additional argument MULTIBYTE to indicate whether the input C
122 came from a multibyte or a unibyte Lisp string; all callers
123 adjusted. Don't assume the input string is always multibyte.
124 (Bug#13262)
125 (Ffile_name_directory) [DOS_NT]: Handle unibyte strings correctly:
126 don't ENCODE_FILE them, and return a unibyte string if the input
127 was unibyte.
128 (Fexpand_file_name): Don't mix unibyte with multibyte strings, and
129 don't assume the input strings will always be multibyte. If the
130 input strings are multibyte, decode strings obtained from C
131 library functions.
132
1332012-12-26 Dmitry Antipov <dmantipov@yandex.ru>
134
135 * lisp.h (toplevel): Add two notices to the comment about
136 defining a new Lisp data type.
137 * print.c (print_object): If Lisp_Save_Value object's pointer
138 is the address of a memory area containing Lisp_Objects, try
139 to print them.
140 * alloc.c (valid_lisp_object_p): Adjust comment.
141
1422012-12-26 Dmitry Antipov <dmantipov@yandex.ru>
143
144 * keyboard.c (record_asynch_buffer_change): Initialize an event
145 only if it's really needed.
146 * frame.h (enum output_method): Remove output_mac member since
147 it's a leftover from the deleted code.
148 * frame.c (Fframep): Adjust user here ...
149 * terminal.c (Fterminal_live_p): ... and here.
150 * coding.c (Qmac): Now here because it's only used to denote
151 end-of-line encoding type.
152 (syms_of_coding): DEFSYM it.
153 * frame.h (Qmac): Remove duplicated declaration.
154
1552012-12-26 Paul Eggert <eggert@cs.ucla.edu>
156
157 * window.c (select_window_1): Now static, since it's used only here.
158
1592012-12-25 Eli Zaretskii <eliz@gnu.org>
160
161 * window.c (window_body_cols): Subtract display margins from the
162 window body width on TTYs as well. See
163 http://lists.gnu.org/archive/html/help-gnu-emacs/2012-12/msg00317.html
164 for the original report.
165
1662012-12-25 Dmitry Antipov <dmantipov@yandex.ru>
167
168 * xdisp.c (redisplay_window): Remove inner local variable
169 because the outer shadowed one has the same meaning.
170 * xterm.h (struct x_output): Remove toolbar_detached member since it's
171 set but never used.
172 * gtkutil.c (xg_tool_bar_detach_callback, xg_tool_bar_attach_callback)
173 (xg_create_tool_bar): Adjust users.
174
1752012-12-24 Dmitry Antipov <dmantipov@yandex.ru>
176
177 * buffer.h (BUF_COMPACT): New macro to follow the common style.
178 * buffer.c (Fget_buffer_create): Use it to set compact field of
179 struct buffer_text to avoid accessing an uninitialized value
180 when compact_buffer is called for the first time.
181 (compact_buffer): Use convenient BUF_COMPACT and BUF_MODIFF.
182 (Fset_buffer_modified_p): Use buffer_window_count to check
183 whether the buffer is displayed in some window.
184 * xdisp.c (message_dolog): Likewise.
185
1862012-12-23 Eli Zaretskii <eliz@gnu.org>
187
188 * w32.c (acl_set_file): If setting the file security descriptor
189 fails, and the new DACL is identical to the existing one, silently
190 return success. This fixes problems for users backing up their
191 own files without having the necessary privileges for setting
192 security descriptors.
193
194 * w32proc.c (reader_thread): Do not index fd_info[] with negative
195 values.
196 (reader_thread): Exit when cp->status becomes STATUS_READ_ERROR
197 after WaitForSingleObject returns normally. This expedites reader
198 thread shutdown when delete_child triggers it.
199 (reap_subprocess): More accurate commentary for why we call
200 delete_child only when cp->fd is negative.
201
202 * w32.c (sys_close): Do not call delete_child on a subprocess
203 whose handle is not yet closed. Instead, set its file descriptor
204 to a negative value, so that reap_subprocess will call
205 delete_child on that subprocess when its SIGCHLD arrives. This
206 avoids closing handles used for communications between sys_select
207 and reader_thread, which doesn't give sys_select a chance to
208 notice that the process exited and invoke the SIGCHLD handler for
209 it.
210
2112012-12-23 Jan Djärv <jan.h.d@swipnet.se>
212
213 * nsfns.m (Fns_do_applescript): Run event loop until script has
214 been executed (Bug#12969).
215 (ns_run_ascript): Chech as_script for nil, set to nil after
216 executing script.
217
2182012-12-22 Martin Rudalics <rudalics@gmx.at>
219
220 * window.c (Fselect_window): Reword doc-string (Bug#13248).
221
2222012-12-22 Eli Zaretskii <eliz@gnu.org>
223
224 * w32term.c (w32fullscreen_hook): New function.
225 (w32_create_terminal): Plug it into the terminal's fullscreen_hook.
226
2272012-12-21 Eli Zaretskii <eliz@gnu.org>
228
229 * fileio.c (Finsert_file_contents): Doc fix.
230
231 * w32proc.c (new_child, delete_child, find_child_pid): For a
232 subprocess, consider its slot being in use as long as its process
233 handle (procinfo.hProcess) is not NULL. This avoids reusing the
234 slot when a new process is started immediately after killing
235 another one, without waiting enough time for the first process to
236 be reaped and resources allocated for it be orderly freed.
237 (Bug#13086)
238 Suggested by Fabrice Popineau <fabrice.popineau@supelec.fr>.
239
2402012-12-21 Chong Yidong <cyd@gnu.org>
241
242 * buffer.c (Fset_buffer_major_mode): Doc fix (Bug#13231).
243
244 * fns.c (Fcompare_strings): Doc fix (Bug#13081).
245
2462012-12-21 Eli Zaretskii <eliz@gnu.org>
247
248 * w32.c (get_name_and_id): Always pass NULL as the first argument
249 of lookup_account_sid. Avoids crashes with UNC file names that
250 refer to DFS domains, not to specific machine names. (Bug#12621)
251 Remove now unused argument FNAME; all callers changed.
252 (get_file_owner_and_group): Remove now unused argument FNAME; all
253 callers changed.
254
2552012-12-21 Chong Yidong <cyd@gnu.org>
256
257 * editfns.c (Finsert_char): Since read-char-by-name now signals an
258 error for invalid chars, don't check for a nil return value.
259
2602012-12-20 Dmitry Antipov <dmantipov@yandex.ru>
261
262 Avoid calls to CHAR_TO_BYTE if byte position is known.
263 * editfns.c (make_buffer_string_both): Use move_gap_both.
264 (Fbuffer_string): Use make_buffer_string_both.
265 * marker.c (buf_charpos_to_bytepos): Convert to eassert.
266 Adjust comment.
267 (buf_bytepos_to_charpos): Likewise.
268 (charpos_to_bytepos): Remove.
269 * fileio.c (Finsert_file_contents): Use move_gap_both.
270 * search.c (Freplace_match): Likewise.
271 * process.c (process_send_region): Likewise. Use convenient
272 names for byte positions.
273 * lisp.h (charpos_to_bytepos): Remove prototype.
274 * indent.c (scan_for_column): Use CHAR_TO_BYTE.
275 * insdel.c (move_gap): Likewise.
276
2772012-12-20 Paul Eggert <eggert@cs.ucla.edu>
278
279 * xdisp.c (redisplay_internal): Remove now-unused local.
280
2812012-12-20 Stefan Monnier <monnier@iro.umontreal.ca>
282
283 * xdisp.c (select_frame_for_redisplay, ensure_selected_frame): Remove.
284 (redisplay_internal): Don't bother selecting the frame to get the
285 proper value of frame-local variables (bug#13225).
286
2872012-12-20 Dmitry Antipov <dmantipov@yandex.ru>
288
289 * textprop.c (set_text_properties_1): Do not allow NULL interval.
290 Rename 4th argument since it may be buffer or string. Adjust comment.
291 * intervals.c (graft_intervals_info_buffer): Find an interval here.
292
2932012-12-19 Dmitry Antipov <dmantipov@yandex.ru>
294
295 * coding.c (Fdetect_coding_region): Do not check start and end with
296 CHECK_NUMBER_COERCE_MARKER since validate_region does that itself.
297 (code_convert_region): Likewise.
298
2992012-12-18 Eli Zaretskii <eliz@gnu.org>
300
301 * w32.c (acl_get_file, acl_set_file): Run the file name through
302 map_w32_filename, and resolve any symlinks in the file name, like
303 Posix platforms do.
304 (acl_set_file): Call revert_to_self, if any privileges were
305 enabled.
306
3072012-12-17 Juanma Barranquero <lekktu@gmail.com>
308
309 * makefile.w32-in ($(BLD)/editfns.$(O), $(BLD)/fileio.$(O))
310 ($(BLD)/w32.$(O)): Update dependencies.
311
3122012-12-17 Stefan Monnier <monnier@iro.umontreal.ca>
313
314 * xdisp.c (select_frame_for_redisplay): Use select_window_1 to
315 propagate redisplay's scrolling (if any) to the right window.
316 (redisplay_internal): Use ensure_selected_frame.
317 (display_mode_lines): Complete last fix.
318 * window.c (select_window_1): New func, extracted from select_window.
319 (select_window): Use it.
320 * window.h (select_window_1): Declare.
321
3222012-12-17 Eli Zaretskii <eliz@gnu.org>
323
324 Emulate Posix ACL APIs on MS-Windows.
325 * w32.c: Include sddl.h and sys/acl.h.
326 (SDDL_REVISION_1): Define if not already defined.
327 (g_b_init_get_security_descriptor_dacl)
328 (g_b_init_convert_sd_to_sddl, g_b_init_convert_sddl_to_sd)
329 (g_b_init_is_valid_security_descriptor)
330 (g_b_init_set_file_security): New static flags.
331 (globals_of_w32): Initialize them to zero.
332 (SetFileSecurity_Name): New string constant.
333 (SetFileSecurity_Proc, GetSecurityDescriptorDacl_Proc)
334 (ConvertStringSecurityDescriptorToSecurityDescriptor_Proc)
335 (ConvertSecurityDescriptorToStringSecurityDescriptor_Proc)
336 (IsValidSecurityDescriptor_Proc): New typedefs.
337 (get_file_security, get_security_descriptor_owner)
338 (get_security_descriptor_group): Set errno to ENOTSUP.
339 (set_file_security, get_security_descriptor_dacl)
340 (is_valid_security_descriptor, convert_sd_to_sddl)
341 (convert_sddl_to_sd, acl_valid, acl_to_text, acl_from_text)
342 (acl_free, acl_get_file, acl_set_file): New functions.
343
344 * fileio.c (Fcopy_file) [WINDOWSNT]: Support copying ACLs.
345
3462012-12-17 Paul Eggert <eggert@cs.ucla.edu>
347
348 Don't reraise SIGCHLD, as that can now lose (Bug#13192).
349 With the 2012-12-03 fix for Bug#12980 in place, an old workaround
350 for some of that bug's symptoms can now cause Emacs to abort.
351 Remove the workaround.
352 * process.c (wait_reading_process_output): Don't reraise SIGCHLD.
353 The bug that caused SIGCHLD to get lost has been fixed, and the
354 workaround for it can now cause Emacs to abort.
355
3562012-12-16 Paul Eggert <eggert@cs.ucla.edu>
357
358 * sysdep.c (emacs_abort): Bump backtrace size to 40.
359 Companion to the 2012-09-30 patch. Suggested by Eli Zaretskii in
360 <http://lists.gnu.org/archive/html/emacs-devel/2012-09/msg00796.html>.
361
12012-12-16 Romain Francoise <romain@orebokech.com> 3622012-12-16 Romain Francoise <romain@orebokech.com>
2 363
3 * fileio.c (Ffile_acl, Fset_file_acl): New functions. 364 * fileio.c (Ffile_acl, Fset_file_acl): New functions.
4 (Fcopy_file): Change last arg to `preserve_extended_attributes' 365 (Fcopy_file): Change last arg to `preserve_extended_attributes'
5 and copy ACL entries of file in addition to SELinux context if 366 and copy ACL entries of file in addition to SELinux context if set.
6 set.
7 (syms_of_fileio): Add `file-acl' and `set-file-acl'. 367 (syms_of_fileio): Add `file-acl' and `set-file-acl'.
8 368
9 * Makefile.in (LIBACL_LIBS): New macro. 369 * Makefile.in (LIBACL_LIBS): New macro.
@@ -126,7 +486,7 @@
126 486
1272012-12-12 Daniel Colascione <dancol@dancol.org> 4872012-12-12 Daniel Colascione <dancol@dancol.org>
128 488
129 * unexcw.c (fixup_executable): use posix_fallocate to ensure that 489 * unexcw.c (fixup_executable): Use posix_fallocate to ensure that
130 the dumped Emacs is not a sparse file, greatly improving Cygwin 490 the dumped Emacs is not a sparse file, greatly improving Cygwin
131 "make bootstrap" performance. 491 "make bootstrap" performance.
132 492
@@ -195,8 +555,7 @@
195 * w32fns.c (cache_system_info): Initialize the global hinst 555 * w32fns.c (cache_system_info): Initialize the global hinst
196 variable here so various initialization calls DTRT. 556 variable here so various initialization calls DTRT.
197 557
198 * unexw32.c (hprevinst, lpCmdLine, nCmdShow): Remove unused 558 * unexw32.c (hprevinst, lpCmdLine, nCmdShow): Remove unused variables.
199 variables.
200 (hinst): Remove unneeded extern declaration. 559 (hinst): Remove unneeded extern declaration.
201 (_start): Remove initialization of above variables; remove 560 (_start): Remove initialization of above variables; remove
202 initialization of hinst, as cache_system_info now does that. 561 initialization of hinst, as cache_system_info now does that.
@@ -268,8 +627,7 @@
268 * w32fns.c (w32_wnd_proc): Handle the WM_EMACS_FILENOTIFY message 627 * w32fns.c (w32_wnd_proc): Handle the WM_EMACS_FILENOTIFY message
269 by posting it to the w32_read_socket queue. 628 by posting it to the w32_read_socket queue.
270 629
271 * termhooks.h (enum event_kind) [HAVE_NTGUI]: Support 630 * termhooks.h (enum event_kind) [HAVE_NTGUI]: Support FILE_NOTIFY_EVENT.
272 FILE_NOTIFY_EVENT.
273 631
274 * makefile.w32-in (OBJ2): Add $(BLD)/w32notify.$(O). 632 * makefile.w32-in (OBJ2): Add $(BLD)/w32notify.$(O).
275 (GLOBAL_SOURCES): Add w32notify.c 633 (GLOBAL_SOURCES): Add w32notify.c
@@ -277,8 +635,8 @@
277 635
278 * lisp.h (syms_of_w32notify) [WINDOWSNT]: Add prototype. 636 * lisp.h (syms_of_w32notify) [WINDOWSNT]: Add prototype.
279 637
280 * keyboard.c (kbd_buffer_get_event) [WINDOWSNT]: Handle 638 * keyboard.c (kbd_buffer_get_event) [WINDOWSNT]:
281 FILE_NOTIFY_EVENT. 639 Handle FILE_NOTIFY_EVENT.
282 (syms_of_keyboard) [HAVE_NTGUI] <Qfile_notify>: New symbol. 640 (syms_of_keyboard) [HAVE_NTGUI] <Qfile_notify>: New symbol.
283 (keys_of_keyboard) [WINDOWSNT]: Bind file-notify to 641 (keys_of_keyboard) [WINDOWSNT]: Bind file-notify to
284 w32notify-handle-event by default. 642 w32notify-handle-event by default.
@@ -289,8 +647,7 @@
2892012-12-10 Rüdiger Sonderfeld <ruediger@c-plusplus.de> 6472012-12-10 Rüdiger Sonderfeld <ruediger@c-plusplus.de>
290 648
291 Support for filesystem notifications on GNU/Linux via inotify. 649 Support for filesystem notifications on GNU/Linux via inotify.
292 * termhooks.h (enum event_kind) [HAVE_INOTIFY]: Add 650 * termhooks.h (enum event_kind) [HAVE_INOTIFY]: Add FILE_NOTIFY_EVENT.
293 FILE_NOTIFY_EVENT.
294 651
295 * lisp.h (syms_of_inotify) [HAVE_INOTIFY]: Add prototype. 652 * lisp.h (syms_of_inotify) [HAVE_INOTIFY]: Add prototype.
296 653
@@ -607,9 +964,9 @@
6072012-12-03 Fabrice Popineau <fabrice.popineau@gmail.com> 9642012-12-03 Fabrice Popineau <fabrice.popineau@gmail.com>
608 965
609 * w32fns.c: Remove prototype of atof. 966 * w32fns.c: Remove prototype of atof.
610 (syspage_mask): Declared DWORD_PTR, for compatibility with 64-bit 967 (syspage_mask): Make it DWORD_PTR, for compatibility with 64-bit
611 builds. 968 builds.
612 (file_dialog_callback): Declared UINT_PTR. 969 (file_dialog_callback): Make it UINT_PTR.
613 970
614 * w32common.h (syspage_mask): Declare DWORD_PTR, for compatibility 971 * w32common.h (syspage_mask): Declare DWORD_PTR, for compatibility
615 with 64-bit builds. 972 with 64-bit builds.
@@ -20977,7 +21334,7 @@ See ChangeLog.11 for earlier changes.
20977;; coding: utf-8 21334;; coding: utf-8
20978;; End: 21335;; End:
20979 21336
20980 Copyright (C) 2011-2012 Free Software Foundation, Inc. 21337 Copyright (C) 2011-2013 Free Software Foundation, Inc.
20981 21338
20982 This file is part of GNU Emacs. 21339 This file is part of GNU Emacs.
20983 21340
diff --git a/src/ChangeLog.1 b/src/ChangeLog.1
index 5265d6fdf59..0d926760017 100644
--- a/src/ChangeLog.1
+++ b/src/ChangeLog.1
@@ -3521,7 +3521,7 @@
3521 * minibuf.c: Don't allow entry to minibuffer 3521 * minibuf.c: Don't allow entry to minibuffer
3522 while minibuffer is selected. 3522 while minibuffer is selected.
3523 3523
3524 Copyright (C) 1985-1986, 2001-2012 Free Software Foundation, Inc. 3524 Copyright (C) 1985-1986, 2001-2013 Free Software Foundation, Inc.
3525 3525
3526 This file is part of GNU Emacs. 3526 This file is part of GNU Emacs.
3527 3527
diff --git a/src/ChangeLog.10 b/src/ChangeLog.10
index 6eda101c815..c878c48a4f4 100644
--- a/src/ChangeLog.10
+++ b/src/ChangeLog.10
@@ -27912,7 +27912,7 @@ See ChangeLog.9 for earlier changes.
27912;; add-log-time-zone-rule: t 27912;; add-log-time-zone-rule: t
27913;; End: 27913;; End:
27914 27914
27915 Copyright (C) 2001-2012 Free Software Foundation, Inc. 27915 Copyright (C) 2001-2013 Free Software Foundation, Inc.
27916 27916
27917 This file is part of GNU Emacs. 27917 This file is part of GNU Emacs.
27918 27918
diff --git a/src/ChangeLog.11 b/src/ChangeLog.11
index 1f444b9292c..1195a8f9592 100644
--- a/src/ChangeLog.11
+++ b/src/ChangeLog.11
@@ -31383,7 +31383,7 @@ See ChangeLog.10 for earlier changes.
31383;; coding: utf-8 31383;; coding: utf-8
31384;; End: 31384;; End:
31385 31385
31386 Copyright (C) 2007-2012 Free Software Foundation, Inc. 31386 Copyright (C) 2007-2013 Free Software Foundation, Inc.
31387 31387
31388 This file is part of GNU Emacs. 31388 This file is part of GNU Emacs.
31389 31389
diff --git a/src/ChangeLog.2 b/src/ChangeLog.2
index 0806106836e..64e793c763c 100644
--- a/src/ChangeLog.2
+++ b/src/ChangeLog.2
@@ -4771,7 +4771,7 @@
4771 4771
4772See ChangeLog.1 for earlier changes. 4772See ChangeLog.1 for earlier changes.
4773 4773
4774 Copyright (C) 1986-1988, 2001-2012 Free Software Foundation, Inc. 4774 Copyright (C) 1986-1988, 2001-2013 Free Software Foundation, Inc.
4775 4775
4776 This file is part of GNU Emacs. 4776 This file is part of GNU Emacs.
4777 4777
diff --git a/src/ChangeLog.3 b/src/ChangeLog.3
index 4f6e02ff8d3..2f798e1f0bc 100644
--- a/src/ChangeLog.3
+++ b/src/ChangeLog.3
@@ -16507,7 +16507,7 @@ See ChangeLog.2 for earlier changes.
16507;; coding: utf-8 16507;; coding: utf-8
16508;; End: 16508;; End:
16509 16509
16510 Copyright (C) 1993, 2001-2012 Free Software Foundation, Inc. 16510 Copyright (C) 1993, 2001-2013 Free Software Foundation, Inc.
16511 16511
16512 This file is part of GNU Emacs. 16512 This file is part of GNU Emacs.
16513 16513
diff --git a/src/ChangeLog.4 b/src/ChangeLog.4
index d7ef7d8779a..54ce63556ea 100644
--- a/src/ChangeLog.4
+++ b/src/ChangeLog.4
@@ -6906,7 +6906,7 @@ See ChangeLog.3 for earlier changes.
6906;; coding: utf-8 6906;; coding: utf-8
6907;; End: 6907;; End:
6908 6908
6909 Copyright (C) 1993-1994, 2001-2012 Free Software Foundation, Inc. 6909 Copyright (C) 1993-1994, 2001-2013 Free Software Foundation, Inc.
6910 6910
6911 This file is part of GNU Emacs. 6911 This file is part of GNU Emacs.
6912 6912
diff --git a/src/ChangeLog.5 b/src/ChangeLog.5
index c6dfde7496b..6fefabc5cd0 100644
--- a/src/ChangeLog.5
+++ b/src/ChangeLog.5
@@ -7148,7 +7148,7 @@ See ChangeLog.4 for earlier changes.
7148;; coding: utf-8 7148;; coding: utf-8
7149;; End: 7149;; End:
7150 7150
7151 Copyright (C) 1994-1995, 2001-2012 Free Software Foundation, Inc. 7151 Copyright (C) 1994-1995, 2001-2013 Free Software Foundation, Inc.
7152 7152
7153 This file is part of GNU Emacs. 7153 This file is part of GNU Emacs.
7154 7154
diff --git a/src/ChangeLog.6 b/src/ChangeLog.6
index 64f8b3a8314..77aadf4cf10 100644
--- a/src/ChangeLog.6
+++ b/src/ChangeLog.6
@@ -5354,7 +5354,7 @@
5354 5354
5355See ChangeLog.5 for earlier changes. 5355See ChangeLog.5 for earlier changes.
5356 5356
5357 Copyright (C) 1995-1996, 2001-2012 Free Software Foundation, Inc. 5357 Copyright (C) 1995-1996, 2001-2013 Free Software Foundation, Inc.
5358 5358
5359 This file is part of GNU Emacs. 5359 This file is part of GNU Emacs.
5360 5360
diff --git a/src/ChangeLog.7 b/src/ChangeLog.7
index ce240ab2928..bb12627b698 100644
--- a/src/ChangeLog.7
+++ b/src/ChangeLog.7
@@ -11091,7 +11091,7 @@ See ChangeLog.6 for earlier changes.
11091;; coding: utf-8 11091;; coding: utf-8
11092;; End: 11092;; End:
11093 11093
11094 Copyright (C) 1997-1998, 2001-2012 Free Software Foundation, Inc. 11094 Copyright (C) 1997-1998, 2001-2013 Free Software Foundation, Inc.
11095 11095
11096 This file is part of GNU Emacs. 11096 This file is part of GNU Emacs.
11097 11097
diff --git a/src/ChangeLog.8 b/src/ChangeLog.8
index e68966b16a2..e89e6b006b7 100644
--- a/src/ChangeLog.8
+++ b/src/ChangeLog.8
@@ -13979,7 +13979,7 @@
13979 13979
13980See ChangeLog.7 for earlier changes. 13980See ChangeLog.7 for earlier changes.
13981 13981
13982 Copyright (C) 1999, 2001-2012 Free Software Foundation, Inc. 13982 Copyright (C) 1999, 2001-2013 Free Software Foundation, Inc.
13983 13983
13984 This file is part of GNU Emacs. 13984 This file is part of GNU Emacs.
13985 13985
diff --git a/src/ChangeLog.9 b/src/ChangeLog.9
index d6d772c5f95..b451b78944f 100644
--- a/src/ChangeLog.9
+++ b/src/ChangeLog.9
@@ -13294,7 +13294,7 @@ See ChangeLog.8 for earlier changes.
13294;; coding: utf-8 13294;; coding: utf-8
13295;; End: 13295;; End:
13296 13296
13297 Copyright (C) 2001-2012 Free Software Foundation, Inc. 13297 Copyright (C) 2001-2013 Free Software Foundation, Inc.
13298 13298
13299 This file is part of GNU Emacs. 13299 This file is part of GNU Emacs.
13300 13300
diff --git a/src/Makefile.in b/src/Makefile.in
index b920600c4c0..7a17f823df5 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -1,7 +1,7 @@
1# src/Makefile for GNU Emacs. 1# src/Makefile for GNU Emacs.
2 2
3# Copyright (C) 1985, 1987-1988, 1993-1995, 1999-2012 3# Copyright (C) 1985, 1987-1988, 1993-1995, 1999-2013 Free Software
4# Free Software Foundation, Inc. 4# Foundation, Inc.
5 5
6# This file is part of GNU Emacs. 6# This file is part of GNU Emacs.
7 7
@@ -111,9 +111,6 @@ LD_SWITCH_SYSTEM_TEMACS=@LD_SWITCH_SYSTEM_TEMACS@
111## Flags to pass to ld only for temacs. 111## Flags to pass to ld only for temacs.
112TEMACS_LDFLAGS = $(LD_SWITCH_SYSTEM) $(LD_SWITCH_SYSTEM_TEMACS) 112TEMACS_LDFLAGS = $(LD_SWITCH_SYSTEM) $(LD_SWITCH_SYSTEM_TEMACS)
113 113
114## $LDFLAGS or empty if NS_IMPL_GNUSTEP (for some reason).
115TEMACS_LDFLAGS2 = @TEMACS_LDFLAGS2@
116
117## If available, the full path to the paxctl program. 114## If available, the full path to the paxctl program.
118## On grsecurity/PaX systems, unexec will fail due to a gap between 115## On grsecurity/PaX systems, unexec will fail due to a gap between
119## the bss section and the heap. This can be prevented by disabling 116## the bss section and the heap. This can be prevented by disabling
@@ -230,6 +227,9 @@ LIBX_OTHER=@LIBX_OTHER@
230## configure, which should set it to nil in non-X builds. 227## configure, which should set it to nil in non-X builds.
231LIBX_BASE=$(LIBXMENU) $(LD_SWITCH_X_SITE) 228LIBX_BASE=$(LIBXMENU) $(LD_SWITCH_X_SITE)
232 229
230## Only used for GNUstep
231LIBS_GNUSTEP=@LIBS_GNUSTEP@
232
233LIBSOUND= @LIBSOUND@ 233LIBSOUND= @LIBSOUND@
234CFLAGS_SOUND= @CFLAGS_SOUND@ 234CFLAGS_SOUND= @CFLAGS_SOUND@
235 235
@@ -401,7 +401,7 @@ otherobj= $(TERMCAP_OBJ) $(PRE_ALLOC_OBJ) $(GMALLOC_OBJ) $(RALLOC_OBJ) \
401## Note that SunOS needs -lm to come before -lc; otherwise, you get 401## Note that SunOS needs -lm to come before -lc; otherwise, you get
402## duplicated symbols. If the standard libraries were compiled 402## duplicated symbols. If the standard libraries were compiled
403## with GCC, we might need LIB_GCC again after them. 403## with GCC, we might need LIB_GCC again after them.
404LIBES = $(LIBS) $(W32_LIBS) $(LIBX_BASE) $(LIBIMAGE) \ 404LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \
405 $(LIBX_OTHER) $(LIBSOUND) \ 405 $(LIBX_OTHER) $(LIBSOUND) \
406 $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) \ 406 $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) \
407 $(LIB_EACCESS) $(LIB_TIMER_TIME) $(DBUS_LIBS) \ 407 $(LIB_EACCESS) $(LIB_TIMER_TIME) $(DBUS_LIBS) \
@@ -476,7 +476,7 @@ $(lib)/libgnu.a: $(config_h)
476 476
477temacs$(EXEEXT): $(START_FILES) stamp-oldxmenu $(obj) $(otherobj) \ 477temacs$(EXEEXT): $(START_FILES) stamp-oldxmenu $(obj) $(otherobj) \
478 $(lib)/libgnu.a $(W32_RES) 478 $(lib)/libgnu.a $(W32_RES)
479 $(CC) $(LD_FIRSTFLAG) $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(TEMACS_LDFLAGS2) \ 479 $(CC) $(LD_FIRSTFLAG) $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(LDFLAGS) \
480 -o temacs $(START_FILES) $(obj) $(otherobj) $(lib)/libgnu.a $(LIBES) \ 480 -o temacs $(START_FILES) $(obj) $(otherobj) $(lib)/libgnu.a $(LIBES) \
481 $(W32_RES_LINK) 481 $(W32_RES_LINK)
482 test "$(CANNOT_DUMP)" = "yes" || \ 482 test "$(CANNOT_DUMP)" = "yes" || \
diff --git a/src/README b/src/README
index 558710627a7..0508137cbea 100644
--- a/src/README
+++ b/src/README
@@ -1,4 +1,4 @@
1Copyright (C) 2001-2012 Free Software Foundation, Inc. 1Copyright (C) 2001-2013 Free Software Foundation, Inc.
2See the end of the file for license conditions. 2See the end of the file for license conditions.
3 3
4 4
diff --git a/src/alloc.c b/src/alloc.c
index d091a9cdf55..c2b2a4c1ed7 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -1,7 +1,7 @@
1/* Storage allocation and gc for GNU Emacs Lisp interpreter. 1/* Storage allocation and gc for GNU Emacs Lisp interpreter.
2 2
3Copyright (C) 1985-1986, 1988, 1993-1995, 1997-2012 3Copyright (C) 1985-1986, 1988, 1993-1995, 1997-2013 Free Software
4 Free Software Foundation, Inc. 4Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
@@ -4726,12 +4726,12 @@ valid_pointer_p (void *p)
4726#endif 4726#endif
4727} 4727}
4728 4728
4729/* Return 2 if OBJ is a killed or special buffer object. 4729/* Return 2 if OBJ is a killed or special buffer object, 1 if OBJ is a
4730 Return 1 if OBJ is a valid lisp object. 4730 valid lisp object, 0 if OBJ is NOT a valid lisp object, or -1 if we
4731 Return 0 if OBJ is NOT a valid lisp object. 4731 cannot validate OBJ. This function can be quite slow, so its primary
4732 Return -1 if we cannot validate OBJ. 4732 use is the manual debugging. The only exception is print_object, where
4733 This function can be quite slow, 4733 we use it to check whether the memory referenced by the pointer of
4734 so it should only be used in code for manual debugging. */ 4734 Lisp_Save_Value object contains valid objects. */
4735 4735
4736int 4736int
4737valid_lisp_object_p (Lisp_Object obj) 4737valid_lisp_object_p (Lisp_Object obj)
diff --git a/src/atimer.c b/src/atimer.c
index 5752192be76..73c7aa5686b 100644
--- a/src/atimer.c
+++ b/src/atimer.c
@@ -1,5 +1,5 @@
1/* Asynchronous timers. 1/* Asynchronous timers.
2 Copyright (C) 2000-2012 Free Software Foundation, Inc. 2 Copyright (C) 2000-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/atimer.h b/src/atimer.h
index 6d441d71641..2a92f1bebea 100644
--- a/src/atimer.h
+++ b/src/atimer.h
@@ -1,5 +1,5 @@
1/* Asynchronous timers. 1/* Asynchronous timers.
2 Copyright (C) 2000-2012 Free Software Foundation, Inc. 2 Copyright (C) 2000-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/bidi.c b/src/bidi.c
index 6f3d749ef22..b067c8134e3 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -1,6 +1,6 @@
1/* Low-level bidirectional buffer/string-scanning functions for GNU Emacs. 1/* Low-level bidirectional buffer/string-scanning functions for GNU Emacs.
2 Copyright (C) 2000-2001, 2004-2005, 2009-2012 2 Copyright (C) 2000-2001, 2004-2005, 2009-2013 Free Software
3 Free Software Foundation, Inc. 3 Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/blockinput.h b/src/blockinput.h
index 70822e29be7..192c813073d 100644
--- a/src/blockinput.h
+++ b/src/blockinput.h
@@ -1,5 +1,5 @@
1/* blockinput.h - interface to blocking complicated interrupt-driven input. 1/* blockinput.h - interface to blocking complicated interrupt-driven input.
2 Copyright (C) 1989, 1993, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1989, 1993, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/buffer.c b/src/buffer.c
index c8864419076..61b457e4558 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1,6 +1,7 @@
1/* Buffer manipulation primitives for GNU Emacs. 1/* Buffer manipulation primitives for GNU Emacs.
2 2
3Copyright (C) 1985-1989, 1993-1995, 1997-2012 Free Software Foundation, Inc. 3Copyright (C) 1985-1989, 1993-1995, 1997-2013 Free Software Foundation,
4Inc.
4 5
5This file is part of GNU Emacs. 6This file is part of GNU Emacs.
6 7
@@ -573,6 +574,7 @@ even if it is dead. The return value is never nil. */)
573 BUF_CHARS_MODIFF (b) = 1; 574 BUF_CHARS_MODIFF (b) = 1;
574 BUF_OVERLAY_MODIFF (b) = 1; 575 BUF_OVERLAY_MODIFF (b) = 1;
575 BUF_SAVE_MODIFF (b) = 1; 576 BUF_SAVE_MODIFF (b) = 1;
577 BUF_COMPACT (b) = 1;
576 set_buffer_intervals (b, NULL); 578 set_buffer_intervals (b, NULL);
577 BUF_UNCHANGED_MODIFIED (b) = 1; 579 BUF_UNCHANGED_MODIFIED (b) = 1;
578 BUF_OVERLAY_UNCHANGED_MODIFIED (b) = 1; 580 BUF_OVERLAY_UNCHANGED_MODIFIED (b) = 1;
@@ -1338,7 +1340,7 @@ DEFUN ("set-buffer-modified-p", Fset_buffer_modified_p, Sset_buffer_modified_p,
1338A non-nil FLAG means mark the buffer modified. */) 1340A non-nil FLAG means mark the buffer modified. */)
1339 (Lisp_Object flag) 1341 (Lisp_Object flag)
1340{ 1342{
1341 Lisp_Object fn, buffer, window; 1343 Lisp_Object fn;
1342 1344
1343#ifdef CLASH_DETECTION 1345#ifdef CLASH_DETECTION
1344 /* If buffer becoming modified, lock the file. 1346 /* If buffer becoming modified, lock the file.
@@ -1391,9 +1393,7 @@ A non-nil FLAG means mark the buffer modified. */)
1391 Ideally, I think there should be another mechanism for fontifying 1393 Ideally, I think there should be another mechanism for fontifying
1392 buffers without "modifying" buffers, or redisplay should be 1394 buffers without "modifying" buffers, or redisplay should be
1393 smarter about updating the `*' in mode lines. --gerd */ 1395 smarter about updating the `*' in mode lines. --gerd */
1394 XSETBUFFER (buffer, current_buffer); 1396 if (buffer_window_count (current_buffer))
1395 window = Fget_buffer_window (buffer, Qt);
1396 if (WINDOWP (window))
1397 { 1397 {
1398 ++update_mode_lines; 1398 ++update_mode_lines;
1399 current_buffer->prevent_redisplay_optimizations_p = 1; 1399 current_buffer->prevent_redisplay_optimizations_p = 1;
@@ -1667,7 +1667,7 @@ compact_buffer (struct buffer *buffer)
1667 which aren't changed since last compaction. */ 1667 which aren't changed since last compaction. */
1668 if (BUFFER_LIVE_P (buffer) 1668 if (BUFFER_LIVE_P (buffer)
1669 && (buffer->base_buffer == NULL) 1669 && (buffer->base_buffer == NULL)
1670 && (buffer->text->compact != buffer->text->modiff)) 1670 && (BUF_COMPACT (buffer) != BUF_MODIFF (buffer)))
1671 { 1671 {
1672 /* If a buffer's undo list is Qt, that means that undo is 1672 /* If a buffer's undo list is Qt, that means that undo is
1673 turned off in that buffer. Calling truncate_undo_list on 1673 turned off in that buffer. Calling truncate_undo_list on
@@ -1692,7 +1692,7 @@ compact_buffer (struct buffer *buffer)
1692 current_buffer = save_current; 1692 current_buffer = save_current;
1693 } 1693 }
1694 } 1694 }
1695 buffer->text->compact = buffer->text->modiff; 1695 BUF_COMPACT (buffer) = BUF_MODIFF (buffer);
1696 } 1696 }
1697} 1697}
1698 1698
@@ -2047,7 +2047,7 @@ DEFUN ("bury-buffer-internal", Fbury_buffer_internal, Sbury_buffer_internal,
2047DEFUN ("set-buffer-major-mode", Fset_buffer_major_mode, Sset_buffer_major_mode, 1, 1, 0, 2047DEFUN ("set-buffer-major-mode", Fset_buffer_major_mode, Sset_buffer_major_mode, 1, 1, 0,
2048 doc: /* Set an appropriate major mode for BUFFER. 2048 doc: /* Set an appropriate major mode for BUFFER.
2049For the *scratch* buffer, use `initial-major-mode', otherwise choose a mode 2049For the *scratch* buffer, use `initial-major-mode', otherwise choose a mode
2050according to `default-major-mode'. 2050according to the default value of `major-mode'.
2051Use this function before selecting the buffer, since it may need to inspect 2051Use this function before selecting the buffer, since it may need to inspect
2052the current buffer's major mode. */) 2052the current buffer's major mode. */)
2053 (Lisp_Object buffer) 2053 (Lisp_Object buffer)
diff --git a/src/buffer.h b/src/buffer.h
index a65b769469f..4bf2b4c2a0b 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1,7 +1,7 @@
1/* Header file for the buffer manipulation primitives. 1/* Header file for the buffer manipulation primitives.
2 2
3Copyright (C) 1985-1986, 1993-1995, 1997-2012 3Copyright (C) 1985-1986, 1993-1995, 1997-2013 Free Software Foundation,
4 Free Software Foundation, Inc. 4Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
@@ -193,6 +193,9 @@ INLINE_HEADER_BEGIN
193/* FIXME: should we move this into ->text->auto_save_modiff? */ 193/* FIXME: should we move this into ->text->auto_save_modiff? */
194#define BUF_AUTOSAVE_MODIFF(buf) ((buf)->auto_save_modified) 194#define BUF_AUTOSAVE_MODIFF(buf) ((buf)->auto_save_modified)
195 195
196/* Compaction count. */
197#define BUF_COMPACT(buf) ((buf)->text->compact)
198
196/* Marker chain of buffer. */ 199/* Marker chain of buffer. */
197#define BUF_MARKERS(buf) ((buf)->text->markers) 200#define BUF_MARKERS(buf) ((buf)->text->markers)
198 201
diff --git a/src/bytecode.c b/src/bytecode.c
index a0b257347c2..010477904be 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -1,5 +1,6 @@
1/* Execution of byte code produced by bytecomp.el. 1/* Execution of byte code produced by bytecomp.el.
2 Copyright (C) 1985-1988, 1993, 2000-2012 Free Software Foundation, Inc. 2 Copyright (C) 1985-1988, 1993, 2000-2013 Free Software Foundation,
3 Inc.
3 4
4This file is part of GNU Emacs. 5This file is part of GNU Emacs.
5 6
diff --git a/src/callint.c b/src/callint.c
index c4c087e83d7..cd303908f69 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -1,6 +1,6 @@
1/* Call a Lisp function interactively. 1/* Call a Lisp function interactively.
2 Copyright (C) 1985-1986, 1993-1995, 1997, 2000-2012 2 Copyright (C) 1985-1986, 1993-1995, 1997, 2000-2013 Free Software
3 Free Software Foundation, Inc. 3 Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/casefiddle.c b/src/casefiddle.c
index d9c6a078973..7f5b99752fa 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -1,6 +1,7 @@
1/* GNU Emacs case conversion functions. 1/* GNU Emacs case conversion functions.
2 2
3Copyright (C) 1985, 1994, 1997-1999, 2001-2012 Free Software Foundation, Inc. 3Copyright (C) 1985, 1994, 1997-1999, 2001-2013 Free Software Foundation,
4Inc.
4 5
5This file is part of GNU Emacs. 6This file is part of GNU Emacs.
6 7
diff --git a/src/casetab.c b/src/casetab.c
index a84bc9202d0..76f72b26db3 100644
--- a/src/casetab.c
+++ b/src/casetab.c
@@ -1,5 +1,5 @@
1/* GNU Emacs routines to deal with case tables. 1/* GNU Emacs routines to deal with case tables.
2 Copyright (C) 1993-1994, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1993-1994, 2001-2013 Free Software Foundation, Inc.
3 3
4Author: Howard Gayle 4Author: Howard Gayle
5 5
diff --git a/src/category.c b/src/category.c
index 31cc90bca68..30ffbd0890f 100644
--- a/src/category.c
+++ b/src/category.c
@@ -1,6 +1,6 @@
1/* GNU Emacs routines to deal with category tables. 1/* GNU Emacs routines to deal with category tables.
2 2
3Copyright (C) 1998, 2001-2012 Free Software Foundation, Inc. 3Copyright (C) 1998, 2001-2013 Free Software Foundation, Inc.
4Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 4Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
5 2005, 2006, 2007, 2008, 2009, 2010, 2011 5 2005, 2006, 2007, 2008, 2009, 2010, 2011
6 National Institute of Advanced Industrial Science and Technology (AIST) 6 National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/src/ccl.c b/src/ccl.c
index 34cc1c98eea..9bfd437d885 100644
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -1,5 +1,5 @@
1/* CCL (Code Conversion Language) interpreter. 1/* CCL (Code Conversion Language) interpreter.
2 Copyright (C) 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 2001-2013 Free Software Foundation, Inc.
3 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 3 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 2005, 2006, 2007, 2008, 2009, 2010, 2011 4 2005, 2006, 2007, 2008, 2009, 2010, 2011
5 National Institute of Advanced Industrial Science and Technology (AIST) 5 National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/src/character.c b/src/character.c
index 5808d48a235..b2caaa290af 100644
--- a/src/character.c
+++ b/src/character.c
@@ -1,6 +1,6 @@
1/* Basic character support. 1/* Basic character support.
2 2
3Copyright (C) 2001-2012 Free Software Foundation, Inc. 3Copyright (C) 2001-2013 Free Software Foundation, Inc.
4Copyright (C) 1995, 1997, 1998, 2001 Electrotechnical Laboratory, JAPAN. 4Copyright (C) 1995, 1997, 1998, 2001 Electrotechnical Laboratory, JAPAN.
5 Licensed to the Free Software Foundation. 5 Licensed to the Free Software Foundation.
6Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 6Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
diff --git a/src/charset.c b/src/charset.c
index 43be0e9c780..c3a4538f223 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1,5 +1,5 @@
1/* Basic character set support. 1/* Basic character set support.
2 Copyright (C) 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 2001-2013 Free Software Foundation, Inc.
3 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 3 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 2005, 2006, 2007, 2008, 2009, 2010, 2011 4 2005, 2006, 2007, 2008, 2009, 2010, 2011
5 National Institute of Advanced Industrial Science and Technology (AIST) 5 National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/src/charset.h b/src/charset.h
index b5fa36290c8..d9a5662e520 100644
--- a/src/charset.h
+++ b/src/charset.h
@@ -1,5 +1,5 @@
1/* Header for charset handler. 1/* Header for charset handler.
2 Copyright (C) 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 2001-2013 Free Software Foundation, Inc.
3 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 3 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 2005, 2006, 2007, 2008, 2009, 2010, 2011 4 2005, 2006, 2007, 2008, 2009, 2010, 2011
5 National Institute of Advanced Industrial Science and Technology (AIST) 5 National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/src/cm.c b/src/cm.c
index eda6430bafa..842633aceec 100644
--- a/src/cm.c
+++ b/src/cm.c
@@ -1,5 +1,5 @@
1/* Cursor motion subroutines for GNU Emacs. 1/* Cursor motion subroutines for GNU Emacs.
2 Copyright (C) 1985, 1995, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1985, 1995, 2001-2013 Free Software Foundation, Inc.
3 based primarily on public domain code written by Chris Torek 3 based primarily on public domain code written by Chris Torek
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
diff --git a/src/cm.h b/src/cm.h
index e3e2b71dba6..6d49dda9419 100644
--- a/src/cm.h
+++ b/src/cm.h
@@ -1,5 +1,5 @@
1/* Cursor motion calculation definitions for GNU Emacs 1/* Cursor motion calculation definitions for GNU Emacs
2 Copyright (C) 1985, 1989, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1985, 1989, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/cmds.c b/src/cmds.c
index 453a4b67e57..3ebad50184a 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -1,6 +1,6 @@
1/* Simple built-in editing commands. 1/* Simple built-in editing commands.
2 2
3Copyright (C) 1985, 1993-1998, 2001-2012 Free Software Foundation, Inc. 3Copyright (C) 1985, 1993-1998, 2001-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/coding.c b/src/coding.c
index 56202e4861d..5285a906823 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -1,5 +1,5 @@
1/* Coding system handler (conversion, detection, etc). 1/* Coding system handler (conversion, detection, etc).
2 Copyright (C) 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 2001-2013 Free Software Foundation, Inc.
3 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 3 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 2005, 2006, 2007, 2008, 2009, 2010, 2011 4 2005, 2006, 2007, 2008, 2009, 2010, 2011
5 National Institute of Advanced Industrial Science and Technology (AIST) 5 National Institute of Advanced Industrial Science and Technology (AIST)
@@ -302,6 +302,7 @@ Lisp_Object Vcoding_system_hash_table;
302static Lisp_Object Qcoding_system, Qeol_type; 302static Lisp_Object Qcoding_system, Qeol_type;
303static Lisp_Object Qcoding_aliases; 303static Lisp_Object Qcoding_aliases;
304Lisp_Object Qunix, Qdos; 304Lisp_Object Qunix, Qdos;
305static Lisp_Object Qmac;
305Lisp_Object Qbuffer_file_coding_system; 306Lisp_Object Qbuffer_file_coding_system;
306static Lisp_Object Qpost_read_conversion, Qpre_write_conversion; 307static Lisp_Object Qpost_read_conversion, Qpre_write_conversion;
307static Lisp_Object Qdefault_char; 308static Lisp_Object Qdefault_char;
@@ -8426,9 +8427,6 @@ highest priority. */)
8426 ptrdiff_t from, to; 8427 ptrdiff_t from, to;
8427 ptrdiff_t from_byte, to_byte; 8428 ptrdiff_t from_byte, to_byte;
8428 8429
8429 CHECK_NUMBER_COERCE_MARKER (start);
8430 CHECK_NUMBER_COERCE_MARKER (end);
8431
8432 validate_region (&start, &end); 8430 validate_region (&start, &end);
8433 from = XINT (start), to = XINT (end); 8431 from = XINT (start), to = XINT (end);
8434 from_byte = CHAR_TO_BYTE (from); 8432 from_byte = CHAR_TO_BYTE (from);
@@ -8872,8 +8870,6 @@ code_convert_region (Lisp_Object start, Lisp_Object end,
8872 ptrdiff_t from, from_byte, to, to_byte; 8870 ptrdiff_t from, from_byte, to, to_byte;
8873 Lisp_Object src_object; 8871 Lisp_Object src_object;
8874 8872
8875 CHECK_NUMBER_COERCE_MARKER (start);
8876 CHECK_NUMBER_COERCE_MARKER (end);
8877 if (NILP (coding_system)) 8873 if (NILP (coding_system))
8878 coding_system = Qno_conversion; 8874 coding_system = Qno_conversion;
8879 else 8875 else
@@ -10308,6 +10304,7 @@ syms_of_coding (void)
10308 DEFSYM (Qeol_type, "eol-type"); 10304 DEFSYM (Qeol_type, "eol-type");
10309 DEFSYM (Qunix, "unix"); 10305 DEFSYM (Qunix, "unix");
10310 DEFSYM (Qdos, "dos"); 10306 DEFSYM (Qdos, "dos");
10307 DEFSYM (Qmac, "mac");
10311 10308
10312 DEFSYM (Qbuffer_file_coding_system, "buffer-file-coding-system"); 10309 DEFSYM (Qbuffer_file_coding_system, "buffer-file-coding-system");
10313 DEFSYM (Qpost_read_conversion, "post-read-conversion"); 10310 DEFSYM (Qpost_read_conversion, "post-read-conversion");
diff --git a/src/coding.h b/src/coding.h
index 192be58f083..eb95fa13ddb 100644
--- a/src/coding.h
+++ b/src/coding.h
@@ -1,5 +1,5 @@
1/* Header for coding system handler. 1/* Header for coding system handler.
2 Copyright (C) 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 2001-2013 Free Software Foundation, Inc.
3 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 3 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 2005, 2006, 2007, 2008, 2009, 2010, 2011 4 2005, 2006, 2007, 2008, 2009, 2010, 2011
5 National Institute of Advanced Industrial Science and Technology (AIST) 5 National Institute of Advanced Industrial Science and Technology (AIST)
@@ -767,7 +767,7 @@ extern Lisp_Object Qcoding_system_p;
767extern Lisp_Object Qraw_text, Qemacs_mule, Qno_conversion, Qundecided; 767extern Lisp_Object Qraw_text, Qemacs_mule, Qno_conversion, Qundecided;
768extern Lisp_Object Qbuffer_file_coding_system; 768extern Lisp_Object Qbuffer_file_coding_system;
769 769
770extern Lisp_Object Qunix, Qdos, Qmac; 770extern Lisp_Object Qunix, Qdos;
771 771
772extern Lisp_Object Qtranslation_table; 772extern Lisp_Object Qtranslation_table;
773extern Lisp_Object Qtranslation_table_id; 773extern Lisp_Object Qtranslation_table_id;
diff --git a/src/commands.h b/src/commands.h
index 510fce0e182..35c2c05fe72 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -1,5 +1,5 @@
1/* Definitions needed by most editing commands. 1/* Definitions needed by most editing commands.
2 Copyright (C) 1985, 1994, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1985, 1994, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/composite.c b/src/composite.c
index bcde0a4c9e6..ddd92389725 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -1,5 +1,5 @@
1/* Composite sequence support. 1/* Composite sequence support.
2 Copyright (C) 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 2001-2013 Free Software Foundation, Inc.
3 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 3 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
4 National Institute of Advanced Industrial Science and Technology (AIST) 4 National Institute of Advanced Industrial Science and Technology (AIST)
5 Registration Number H14PRO021 5 Registration Number H14PRO021
diff --git a/src/composite.h b/src/composite.h
index 9462b932c66..603291044bc 100644
--- a/src/composite.h
+++ b/src/composite.h
@@ -1,5 +1,5 @@
1/* Header for composite sequence handler. 1/* Header for composite sequence handler.
2 Copyright (C) 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 2001-2013 Free Software Foundation, Inc.
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
4 National Institute of Advanced Industrial Science and Technology (AIST) 4 National Institute of Advanced Industrial Science and Technology (AIST)
5 Registration Number H14PRO021 5 Registration Number H14PRO021
diff --git a/src/conf_post.h b/src/conf_post.h
index b1997e79081..cd1e35bea7a 100644
--- a/src/conf_post.h
+++ b/src/conf_post.h
@@ -1,7 +1,7 @@
1/* conf_post.h --- configure.ac includes this via AH_BOTTOM 1/* conf_post.h --- configure.ac includes this via AH_BOTTOM
2 2
3Copyright (C) 1988, 1993-1994, 1999-2002, 2004-2012 3Copyright (C) 1988, 1993-1994, 1999-2002, 2004-2013 Free Software
4 Free Software Foundation, Inc. 4Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
@@ -40,6 +40,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
40#endif 40#endif
41#endif 41#endif
42 42
43#ifndef __has_attribute
44# define __has_attribute(a) 0 /* non-clang */
45#endif
46
43/* This silences a few compilation warnings on FreeBSD. */ 47/* This silences a few compilation warnings on FreeBSD. */
44#ifdef BSD_SYSTEM_AHB 48#ifdef BSD_SYSTEM_AHB
45#undef BSD_SYSTEM_AHB 49#undef BSD_SYSTEM_AHB
@@ -191,7 +195,9 @@ extern void _DebPrint (const char *fmt, ...);
191#define NO_INLINE 195#define NO_INLINE
192#endif 196#endif
193 197
194#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) 198#if (__clang__ \
199 ? __has_attribute (externally_visible) \
200 : (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)))
195#define EXTERNALLY_VISIBLE __attribute__((externally_visible)) 201#define EXTERNALLY_VISIBLE __attribute__((externally_visible))
196#else 202#else
197#define EXTERNALLY_VISIBLE 203#define EXTERNALLY_VISIBLE
diff --git a/src/cygw32.c b/src/cygw32.c
index d9777d5e22e..a7dbdaed615 100644
--- a/src/cygw32.c
+++ b/src/cygw32.c
@@ -1,5 +1,5 @@
1/* Cygwin support routines. 1/* Cygwin support routines.
2 Copyright (C) 2011-2012 Free Software Foundation, Inc. 2 Copyright (C) 2011-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
@@ -110,23 +110,25 @@ DEFUN ("cygwin-convert-file-name-to-windows",
110 Fcygwin_convert_file_name_to_windows, 110 Fcygwin_convert_file_name_to_windows,
111 Scygwin_convert_file_name_to_windows, 111 Scygwin_convert_file_name_to_windows,
112 1, 2, 0, 112 1, 2, 0,
113 doc: /* Convert PATH to a Windows path. If ABSOLUTE-P is 113 doc: /* Convert a Cygwin file name FILE to a Windows-style file name.
114non-nil, return an absolute path.*/) 114If ABSOLUTE-P is non-nil, return an absolute file name.
115 (Lisp_Object path, Lisp_Object absolute_p) 115For the reverse operation, see `cygwin-convert-file-name-from-windows'. */)
116 (Lisp_Object file, Lisp_Object absolute_p)
116{ 117{
117 return from_unicode ( 118 return from_unicode (
118 conv_filename_to_w32_unicode (path, EQ (absolute_p, Qnil) ? 0 : 1)); 119 conv_filename_to_w32_unicode (file, EQ (absolute_p, Qnil) ? 0 : 1));
119} 120}
120 121
121DEFUN ("cygwin-convert-file-name-from-windows", 122DEFUN ("cygwin-convert-file-name-from-windows",
122 Fcygwin_convert_file_name_from_windows, 123 Fcygwin_convert_file_name_from_windows,
123 Scygwin_convert_file_name_from_windows, 124 Scygwin_convert_file_name_from_windows,
124 1, 2, 0, 125 1, 2, 0,
125 doc: /* Convert a Windows path to a Cygwin path. If ABSOLUTE-P 126 doc: /* Convert a Windows-style file name FILE to a Cygwin file name.
126is non-nil, return an absolute path.*/) 127If ABSOLUTE-P is non-nil, return an absolute file name.
127 (Lisp_Object path, Lisp_Object absolute_p) 128For the reverse operation, see `cygwin-convert-file-name-to-windows'. */)
129 (Lisp_Object file, Lisp_Object absolute_p)
128{ 130{
129 return conv_filename_from_w32_unicode (to_unicode (path, &path), 131 return conv_filename_from_w32_unicode (to_unicode (file, &file),
130 EQ (absolute_p, Qnil) ? 0 : 1); 132 EQ (absolute_p, Qnil) ? 0 : 1);
131} 133}
132 134
diff --git a/src/cygw32.h b/src/cygw32.h
index 51571913fd1..5c7066f26d1 100644
--- a/src/cygw32.h
+++ b/src/cygw32.h
@@ -1,5 +1,5 @@
1/* Header for Cygwin support routines. 1/* Header for Cygwin support routines.
2 Copyright (C) 2011-2012 Free Software Foundation, Inc. 2 Copyright (C) 2011-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/data.c b/src/data.c
index 540c91bd4a5..e9f3a2cff3f 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1,6 +1,6 @@
1/* Primitive operations on Lisp data types for GNU Emacs Lisp interpreter. 1/* Primitive operations on Lisp data types for GNU Emacs Lisp interpreter.
2 Copyright (C) 1985-1986, 1988, 1993-1995, 1997-2012 2 Copyright (C) 1985-1986, 1988, 1993-1995, 1997-2013 Free Software
3 Free Software Foundation, Inc. 3 Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -620,7 +620,7 @@ DEFUN ("symbol-function", Fsymbol_function, Ssymbol_function, 1, 1, 0,
620 (register Lisp_Object symbol) 620 (register Lisp_Object symbol)
621{ 621{
622 CHECK_SYMBOL (symbol); 622 CHECK_SYMBOL (symbol);
623 return XSYMBOL (symbol)->function; 623 return XSYMBOL (symbol)->function;
624} 624}
625 625
626DEFUN ("symbol-plist", Fsymbol_plist, Ssymbol_plist, 1, 1, 0, 626DEFUN ("symbol-plist", Fsymbol_plist, Ssymbol_plist, 1, 1, 0,
diff --git a/src/dbusbind.c b/src/dbusbind.c
index da8bbb1e5d7..863f7634eb5 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -1,5 +1,5 @@
1/* Elisp bindings for D-Bus. 1/* Elisp bindings for D-Bus.
2 Copyright (C) 2007-2012 Free Software Foundation, Inc. 2 Copyright (C) 2007-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/deps.mk b/src/deps.mk
index beca5f7c6bc..47185c9262c 100644
--- a/src/deps.mk
+++ b/src/deps.mk
@@ -1,7 +1,7 @@
1### deps.mk --- src/Makefile fragment for GNU Emacs 1### deps.mk --- src/Makefile fragment for GNU Emacs
2 2
3## Copyright (C) 1985, 1987-1988, 1993-1995, 1999-2012 3## Copyright (C) 1985, 1987-1988, 1993-1995, 1999-2013 Free Software
4## Free Software Foundation, Inc. 4## Foundation, Inc.
5 5
6## This file is part of GNU Emacs. 6## This file is part of GNU Emacs.
7 7
diff --git a/src/dired.c b/src/dired.c
index 1fda9e8b371..b4dc702112e 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -1,5 +1,6 @@
1/* Lisp functions for making directory listings. 1/* Lisp functions for making directory listings.
2 Copyright (C) 1985-1986, 1993-1994, 1999-2012 Free Software Foundation, Inc. 2 Copyright (C) 1985-1986, 1993-1994, 1999-2013 Free Software
3 Foundation, Inc.
3 4
4This file is part of GNU Emacs. 5This file is part of GNU Emacs.
5 6
@@ -671,10 +672,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag,
671 name, zero, 672 name, zero,
672 make_number (compare), 673 make_number (compare),
673 completion_ignore_case ? Qt : Qnil); 674 completion_ignore_case ? Qt : Qnil);
674 ptrdiff_t matchsize 675 ptrdiff_t matchsize = EQ (cmp, Qt) ? compare : eabs (XINT (cmp)) - 1;
675 = (EQ (cmp, Qt) ? compare
676 : XINT (cmp) < 0 ? - XINT (cmp) - 1
677 : XINT (cmp) - 1);
678 676
679 if (completion_ignore_case) 677 if (completion_ignore_case)
680 { 678 {
diff --git a/src/dispextern.h b/src/dispextern.h
index aa40f019fbe..46878745c07 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1,6 +1,6 @@
1/* Interface definitions for display code. 1/* Interface definitions for display code.
2 2
3Copyright (C) 1985, 1993-1994, 1997-2012 Free Software Foundation, Inc. 3Copyright (C) 1985, 1993-1994, 1997-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -317,13 +317,18 @@ struct glyph
317 Lisp string, this is a position in that string. If it is a 317 Lisp string, this is a position in that string. If it is a
318 buffer, this is a position in that buffer. A value of -1 318 buffer, this is a position in that buffer. A value of -1
319 together with a null object means glyph is a truncation glyph at 319 together with a null object means glyph is a truncation glyph at
320 the start of a row. */ 320 the start of a row. Right truncation and continuation glyphs at
321 the right edge of a row have their position set to the next
322 buffer position that is not shown on this row. Glyphs inserted
323 by redisplay, such as the empty space after the end of a line on
324 TTYs, or the overlay-arrow on a TTY, have this set to -1. */
321 ptrdiff_t charpos; 325 ptrdiff_t charpos;
322 326
323 /* Lisp object source of this glyph. Currently either a buffer or 327 /* Lisp object source of this glyph. Currently either a buffer or a
324 a string, if the glyph was produced from characters which came from 328 string, if the glyph was produced from characters which came from
325 a buffer or a string; or 0 if the glyph was inserted by redisplay 329 a buffer or a string; or 0 if the glyph was inserted by redisplay
326 for its own purposes such as padding. */ 330 for its own purposes, such as padding or truncation/continuation
331 glyphs, or the overlay-arrow glyphs on TTYs. */
327 Lisp_Object object; 332 Lisp_Object object;
328 333
329 /* Width in pixels. */ 334 /* Width in pixels. */
diff --git a/src/dispnew.c b/src/dispnew.c
index 02b2f9c84e4..1e9d94f3789 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -1,6 +1,7 @@
1/* Updating of data structures for redisplay. 1/* Updating of data structures for redisplay.
2 2
3Copyright (C) 1985-1988, 1993-1995, 1997-2012 Free Software Foundation, Inc. 3Copyright (C) 1985-1988, 1993-1995, 1997-2013 Free Software Foundation,
4Inc.
4 5
5This file is part of GNU Emacs. 6This file is part of GNU Emacs.
6 7
diff --git a/src/disptab.h b/src/disptab.h
index 2e041707eea..e02bab04bbc 100644
--- a/src/disptab.h
+++ b/src/disptab.h
@@ -1,5 +1,5 @@
1/* Things for GLYPHS and glyph tables. 1/* Things for GLYPHS and glyph tables.
2 Copyright (C) 1993, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1993, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/doc.c b/src/doc.c
index 76008295add..16c0d4090a0 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -1,6 +1,7 @@
1/* Record indices of function doc strings stored in a file. 1/* Record indices of function doc strings stored in a file.
2 2
3Copyright (C) 1985-1986, 1993-1995, 1997-2012 Free Software Foundation, Inc. 3Copyright (C) 1985-1986, 1993-1995, 1997-2013 Free Software Foundation,
4Inc.
4 5
5This file is part of GNU Emacs. 6This file is part of GNU Emacs.
6 7
@@ -83,24 +84,23 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition)
83 ptrdiff_t minsize; 84 ptrdiff_t minsize;
84 int offset; 85 int offset;
85 EMACS_INT position; 86 EMACS_INT position;
86 Lisp_Object file, tem; 87 Lisp_Object file, tem, pos;
87 USE_SAFE_ALLOCA; 88 USE_SAFE_ALLOCA;
88 89
89 if (INTEGERP (filepos)) 90 if (INTEGERP (filepos))
90 { 91 {
91 file = Vdoc_file_name; 92 file = Vdoc_file_name;
92 position = XINT (filepos); 93 pos = filepos;
93 } 94 }
94 else if (CONSP (filepos)) 95 else if (CONSP (filepos))
95 { 96 {
96 file = XCAR (filepos); 97 file = XCAR (filepos);
97 position = XINT (XCDR (filepos)); 98 pos = XCDR (filepos);
98 } 99 }
99 else 100 else
100 return Qnil; 101 return Qnil;
101 102
102 if (position < 0) 103 position = eabs (XINT (pos));
103 position = - position;
104 104
105 if (!STRINGP (Vdoc_directory)) 105 if (!STRINGP (Vdoc_directory))
106 return Qnil; 106 return Qnil;
diff --git a/src/doprnt.c b/src/doprnt.c
index 8cab219aafa..b8e1b547268 100644
--- a/src/doprnt.c
+++ b/src/doprnt.c
@@ -1,7 +1,7 @@
1/* Output like sprintf to a buffer of specified size. 1/* Output like sprintf to a buffer of specified size.
2 Also takes args differently: pass one pointer to the end 2 Also takes args differently: pass one pointer to the end
3 of the format string in addition to the format string itself. 3 of the format string in addition to the format string itself.
4 Copyright (C) 1985, 2001-2012 Free Software Foundation, Inc. 4 Copyright (C) 1985, 2001-2013 Free Software Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
diff --git a/src/dosfns.c b/src/dosfns.c
index ce1ec4a4f93..37d3998b5ee 100644
--- a/src/dosfns.c
+++ b/src/dosfns.c
@@ -1,6 +1,7 @@
1/* MS-DOS specific Lisp utilities. Coded by Manabu Higashida, 1991. 1/* MS-DOS specific Lisp utilities. Coded by Manabu Higashida, 1991.
2 Major changes May-July 1993 Morten Welinder (only 10% original code left) 2 Major changes May-July 1993 Morten Welinder (only 10% original code left)
3 Copyright (C) 1991, 1993, 1996-1998, 2001-2012 Free Software Foundation, Inc. 3 Copyright (C) 1991, 1993, 1996-1998, 2001-2013 Free Software
4 Foundation, Inc.
4 5
5This file is part of GNU Emacs. 6This file is part of GNU Emacs.
6 7
diff --git a/src/dosfns.h b/src/dosfns.h
index 9747c364d71..0bf0ae1f19b 100644
--- a/src/dosfns.h
+++ b/src/dosfns.h
@@ -2,8 +2,8 @@
2 Coded by Manabu Higashida, 1991. 2 Coded by Manabu Higashida, 1991.
3 Modified by Morten Welinder, 1993-1994. 3 Modified by Morten Welinder, 1993-1994.
4 4
5Copyright (C) 1991, 1994-1995, 1997, 1999, 2001-2012 5Copyright (C) 1991, 1994-1995, 1997, 1999, 2001-2013 Free Software
6 Free Software Foundation, Inc. 6Foundation, Inc.
7 7
8This file is part of GNU Emacs. 8This file is part of GNU Emacs.
9 9
diff --git a/src/editfns.c b/src/editfns.c
index 911cd416e80..df0dad0669d 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1,6 +1,6 @@
1/* Lisp functions pertaining to editing. 1/* Lisp functions pertaining to editing.
2 2
3Copyright (C) 1985-1987, 1989, 1993-2012 Free Software Foundation, Inc. 3Copyright (C) 1985-1987, 1989, 1993-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -2361,10 +2361,9 @@ usage: (insert-before-markers-and-inherit &rest ARGS) */)
2361} 2361}
2362 2362
2363DEFUN ("insert-char", Finsert_char, Sinsert_char, 1, 3, 2363DEFUN ("insert-char", Finsert_char, Sinsert_char, 1, 3,
2364 "(list (or (read-char-by-name \"Insert character (Unicode name or hex): \")\ 2364 "(list (read-char-by-name \"Insert character (Unicode name or hex): \")\
2365 (error \"You did not specify a valid character\"))\ 2365 (prefix-numeric-value current-prefix-arg)\
2366 (prefix-numeric-value current-prefix-arg)\ 2366 t))",
2367 t))",
2368 doc: /* Insert COUNT copies of CHARACTER. 2367 doc: /* Insert COUNT copies of CHARACTER.
2369Interactively, prompt for CHARACTER. You can specify CHARACTER in one 2368Interactively, prompt for CHARACTER. You can specify CHARACTER in one
2370of these ways: 2369of these ways:
@@ -2501,7 +2500,7 @@ make_buffer_string_both (ptrdiff_t start, ptrdiff_t start_byte,
2501 Lisp_Object result, tem, tem1; 2500 Lisp_Object result, tem, tem1;
2502 2501
2503 if (start < GPT && GPT < end) 2502 if (start < GPT && GPT < end)
2504 move_gap (start); 2503 move_gap_both (start, start_byte);
2505 2504
2506 if (! NILP (BVAR (current_buffer, enable_multibyte_characters))) 2505 if (! NILP (BVAR (current_buffer, enable_multibyte_characters)))
2507 result = make_uninit_multibyte_string (end - start, end_byte - start_byte); 2506 result = make_uninit_multibyte_string (end - start, end_byte - start_byte);
@@ -2599,7 +2598,7 @@ If narrowing is in effect, this function returns only the visible part
2599of the buffer. */) 2598of the buffer. */)
2600 (void) 2599 (void)
2601{ 2600{
2602 return make_buffer_string (BEGV, ZV, 1); 2601 return make_buffer_string_both (BEGV, BEGV_BYTE, ZV, ZV_BYTE, 1);
2603} 2602}
2604 2603
2605DEFUN ("insert-buffer-substring", Finsert_buffer_substring, Sinsert_buffer_substring, 2604DEFUN ("insert-buffer-substring", Finsert_buffer_substring, Sinsert_buffer_substring,
diff --git a/src/emacs-icon.h b/src/emacs-icon.h
index 590d874ca82..8869f6d7d76 100644
--- a/src/emacs-icon.h
+++ b/src/emacs-icon.h
@@ -1,7 +1,7 @@
1/* XPM */ 1/* XPM */
2/* Emacs icon 2/* Emacs icon
3 3
4Copyright (C) 2008-2012 Free Software Foundation, Inc. 4Copyright (C) 2008-2013 Free Software Foundation, Inc.
5 5
6Author: Kentaro Ohkouchi <nanasess@fsm.ne.jp> 6Author: Kentaro Ohkouchi <nanasess@fsm.ne.jp>
7 7
diff --git a/src/emacs.c b/src/emacs.c
index 8787e4bca9f..57de81f05b0 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1,7 +1,7 @@
1/* Fully extensible Emacs, running on Unix, intended for GNU. 1/* Fully extensible Emacs, running on Unix, intended for GNU.
2 2
3Copyright (C) 1985-1987, 1993-1995, 1997-1999, 2001-2012 3Copyright (C) 1985-1987, 1993-1995, 1997-1999, 2001-2013 Free Software
4 Free Software Foundation, Inc. 4Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
diff --git a/src/emacsgtkfixed.c b/src/emacsgtkfixed.c
index d10185072cc..6a8c751e306 100644
--- a/src/emacsgtkfixed.c
+++ b/src/emacsgtkfixed.c
@@ -1,7 +1,7 @@
1/* A Gtk Widget that inherits GtkFixed, but can be shrunk. 1/* A Gtk Widget that inherits GtkFixed, but can be shrunk.
2This file is only use when compiling with Gtk+ 3. 2This file is only use when compiling with Gtk+ 3.
3 3
4Copyright (C) 2011-2012 Free Software Foundation, Inc. 4Copyright (C) 2011-2013 Free Software Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
diff --git a/src/emacsgtkfixed.h b/src/emacsgtkfixed.h
index 3fa294aa41e..d987797a934 100644
--- a/src/emacsgtkfixed.h
+++ b/src/emacsgtkfixed.h
@@ -1,7 +1,7 @@
1/* A Gtk Widget that inherits GtkFixed, but can be shrunk. 1/* A Gtk Widget that inherits GtkFixed, but can be shrunk.
2This file is only use when compiling with Gtk+ 3. 2This file is only use when compiling with Gtk+ 3.
3 3
4Copyright (C) 2011-2012 Free Software Foundation, Inc. 4Copyright (C) 2011-2013 Free Software Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
diff --git a/src/epaths.in b/src/epaths.in
index 705fe3aab1b..0cf8cc9ce5b 100644
--- a/src/epaths.in
+++ b/src/epaths.in
@@ -1,7 +1,7 @@
1/* Hey Emacs, this is -*- C -*- code! */ 1/* Hey Emacs, this is -*- C -*- code! */
2/* 2/*
3Copyright (C) 1993, 1995, 1997, 1999, 2001-2012 3Copyright (C) 1993, 1995, 1997, 1999, 2001-2013 Free Software
4 Free Software Foundation, Inc. 4Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
diff --git a/src/eval.c b/src/eval.c
index 0932564b36f..f88567f14cb 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1,5 +1,6 @@
1/* Evaluator for GNU Emacs Lisp interpreter. 1/* Evaluator for GNU Emacs Lisp interpreter.
2 Copyright (C) 1985-1987, 1993-1995, 1999-2012 Free Software Foundation, Inc. 2 Copyright (C) 1985-1987, 1993-1995, 1999-2013 Free Software
3 Foundation, Inc.
3 4
4This file is part of GNU Emacs. 5This file is part of GNU Emacs.
5 6
diff --git a/src/fileio.c b/src/fileio.c
index f1cfe0eb625..5e9b36ee44a 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -1,6 +1,6 @@
1/* File IO for GNU Emacs. 1/* File IO for GNU Emacs.
2 2
3Copyright (C) 1985-1988, 1993-2012 Free Software Foundation, Inc. 3Copyright (C) 1985-1988, 1993-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -379,12 +379,26 @@ Given a Unix syntax file name, returns a string ending in slash. */)
379 strcat (res, "/"); 379 strcat (res, "/");
380 beg = res; 380 beg = res;
381 p = beg + strlen (beg); 381 p = beg + strlen (beg);
382 dostounix_filename (beg);
383 tem_fn = make_specified_string (beg, -1, p - beg,
384 STRING_MULTIBYTE (filename));
382 } 385 }
386 else
387 tem_fn = make_specified_string (beg - 2, -1, p - beg + 2,
388 STRING_MULTIBYTE (filename));
389 }
390 else if (STRING_MULTIBYTE (filename))
391 {
392 tem_fn = ENCODE_FILE (make_specified_string (beg, -1, p - beg, 1));
393 dostounix_filename (SSDATA (tem_fn));
394 tem_fn = DECODE_FILE (tem_fn);
395 }
396 else
397 {
398 dostounix_filename (beg);
399 tem_fn = make_specified_string (beg, -1, p - beg, 0);
383 } 400 }
384 tem_fn = ENCODE_FILE (make_specified_string (beg, -1, p - beg, 401 return tem_fn;
385 STRING_MULTIBYTE (filename)));
386 dostounix_filename (SSDATA (tem_fn));
387 return DECODE_FILE (tem_fn);
388#else /* DOS_NT */ 402#else /* DOS_NT */
389 return make_specified_string (beg, -1, p - beg, STRING_MULTIBYTE (filename)); 403 return make_specified_string (beg, -1, p - beg, STRING_MULTIBYTE (filename));
390#endif /* DOS_NT */ 404#endif /* DOS_NT */
@@ -459,12 +473,14 @@ get a current directory to run processes in. */)
459 return Ffile_name_directory (filename); 473 return Ffile_name_directory (filename);
460} 474}
461 475
462/* Convert from file name SRC of length SRCLEN to directory name 476/* Convert from file name SRC of length SRCLEN to directory name in
463 in DST. On UNIX, just make sure there is a terminating /. 477 DST. MULTIBYTE non-zero means the file name in SRC is a multibyte
464 Return the length of DST in bytes. */ 478 string. On UNIX, just make sure there is a terminating /. Return
479 the length of DST in bytes. */
465 480
466static ptrdiff_t 481static ptrdiff_t
467file_name_as_directory (char *dst, const char *src, ptrdiff_t srclen) 482file_name_as_directory (char *dst, const char *src, ptrdiff_t srclen,
483 bool multibyte)
468{ 484{
469 if (srclen == 0) 485 if (srclen == 0)
470 { 486 {
@@ -483,14 +499,17 @@ file_name_as_directory (char *dst, const char *src, ptrdiff_t srclen)
483 srclen++; 499 srclen++;
484 } 500 }
485#ifdef DOS_NT 501#ifdef DOS_NT
486 { 502 if (multibyte)
487 Lisp_Object tem_fn = make_specified_string (dst, -1, srclen, 1); 503 {
504 Lisp_Object tem_fn = make_specified_string (dst, -1, srclen, 1);
488 505
489 tem_fn = ENCODE_FILE (tem_fn); 506 tem_fn = ENCODE_FILE (tem_fn);
490 dostounix_filename (SSDATA (tem_fn)); 507 dostounix_filename (SSDATA (tem_fn));
491 tem_fn = DECODE_FILE (tem_fn); 508 tem_fn = DECODE_FILE (tem_fn);
492 memcpy (dst, SSDATA (tem_fn), (srclen = SBYTES (tem_fn)) + 1); 509 memcpy (dst, SSDATA (tem_fn), (srclen = SBYTES (tem_fn)) + 1);
493 } 510 }
511 else
512 dostounix_filename (dst);
494#endif 513#endif
495 return srclen; 514 return srclen;
496} 515}
@@ -526,16 +545,18 @@ For a Unix-syntax file name, just appends a slash. */)
526 } 545 }
527 546
528 buf = alloca (SBYTES (file) + 10); 547 buf = alloca (SBYTES (file) + 10);
529 length = file_name_as_directory (buf, SSDATA (file), SBYTES (file)); 548 length = file_name_as_directory (buf, SSDATA (file), SBYTES (file),
549 STRING_MULTIBYTE (file));
530 return make_specified_string (buf, -1, length, STRING_MULTIBYTE (file)); 550 return make_specified_string (buf, -1, length, STRING_MULTIBYTE (file));
531} 551}
532 552
533/* Convert from directory name SRC of length SRCLEN to 553/* Convert from directory name SRC of length SRCLEN to file name in
534 file name in DST. On UNIX, just make sure there isn't 554 DST. MULTIBYTE non-zero means the file name in SRC is a multibyte
535 a terminating /. Return the length of DST in bytes. */ 555 string. On UNIX, just make sure there isn't a terminating /.
556 Return the length of DST in bytes. */
536 557
537static ptrdiff_t 558static ptrdiff_t
538directory_file_name (char *dst, char *src, ptrdiff_t srclen) 559directory_file_name (char *dst, char *src, ptrdiff_t srclen, bool multibyte)
539{ 560{
540 /* Process as Unix format: just remove any final slash. 561 /* Process as Unix format: just remove any final slash.
541 But leave "/" unchanged; do not change it to "". */ 562 But leave "/" unchanged; do not change it to "". */
@@ -551,14 +572,17 @@ directory_file_name (char *dst, char *src, ptrdiff_t srclen)
551 srclen--; 572 srclen--;
552 } 573 }
553#ifdef DOS_NT 574#ifdef DOS_NT
554 { 575 if (multibyte)
555 Lisp_Object tem_fn = make_specified_string (dst, -1, srclen, 1); 576 {
577 Lisp_Object tem_fn = make_specified_string (dst, -1, srclen, 1);
556 578
557 tem_fn = ENCODE_FILE (tem_fn); 579 tem_fn = ENCODE_FILE (tem_fn);
558 dostounix_filename (SSDATA (tem_fn)); 580 dostounix_filename (SSDATA (tem_fn));
559 tem_fn = DECODE_FILE (tem_fn); 581 tem_fn = DECODE_FILE (tem_fn);
560 memcpy (dst, SSDATA (tem_fn), (srclen = SBYTES (tem_fn)) + 1); 582 memcpy (dst, SSDATA (tem_fn), (srclen = SBYTES (tem_fn)) + 1);
561 } 583 }
584 else
585 dostounix_filename (dst);
562#endif 586#endif
563 return srclen; 587 return srclen;
564} 588}
@@ -594,7 +618,8 @@ In Unix-syntax, this function just removes the final slash. */)
594 } 618 }
595 619
596 buf = alloca (SBYTES (directory) + 20); 620 buf = alloca (SBYTES (directory) + 20);
597 length = directory_file_name (buf, SSDATA (directory), SBYTES (directory)); 621 length = directory_file_name (buf, SSDATA (directory), SBYTES (directory),
622 STRING_MULTIBYTE (directory));
598 return make_specified_string (buf, -1, length, STRING_MULTIBYTE (directory)); 623 return make_specified_string (buf, -1, length, STRING_MULTIBYTE (directory));
599} 624}
600 625
@@ -1044,7 +1069,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1044 /* `egetenv' may return a unibyte string, which will bite us since 1069 /* `egetenv' may return a unibyte string, which will bite us since
1045 we expect the directory to be multibyte. */ 1070 we expect the directory to be multibyte. */
1046 tem = build_string (newdir); 1071 tem = build_string (newdir);
1047 if (!STRING_MULTIBYTE (tem)) 1072 if (multibyte && !STRING_MULTIBYTE (tem))
1048 { 1073 {
1049 hdir = DECODE_FILE (tem); 1074 hdir = DECODE_FILE (tem);
1050 newdir = SSDATA (hdir); 1075 newdir = SSDATA (hdir);
@@ -1066,7 +1091,18 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1066 unblock_input (); 1091 unblock_input ();
1067 if (pw) 1092 if (pw)
1068 { 1093 {
1094 Lisp_Object tem;
1095
1069 newdir = pw->pw_dir; 1096 newdir = pw->pw_dir;
1097 /* `getpwnam' may return a unibyte string, which will
1098 bite us since we expect the directory to be
1099 multibyte. */
1100 tem = build_string (newdir);
1101 if (multibyte && !STRING_MULTIBYTE (tem))
1102 {
1103 hdir = DECODE_FILE (tem);
1104 newdir = SSDATA (hdir);
1105 }
1070 nm = p; 1106 nm = p;
1071#ifdef DOS_NT 1107#ifdef DOS_NT
1072 collapse_newdir = 0; 1108 collapse_newdir = 0;
@@ -1090,6 +1126,13 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1090 adir = alloca (MAXPATHLEN + 1); 1126 adir = alloca (MAXPATHLEN + 1);
1091 if (!getdefdir (c_toupper (drive) - 'A' + 1, adir)) 1127 if (!getdefdir (c_toupper (drive) - 'A' + 1, adir))
1092 adir = NULL; 1128 adir = NULL;
1129 else if (multibyte)
1130 {
1131 Lisp_Object tem = build_string (adir);
1132
1133 tem = DECODE_FILE (tem);
1134 memcpy (adir, SSDATA (tem), SBYTES (tem) + 1);
1135 }
1093 } 1136 }
1094 if (!adir) 1137 if (!adir)
1095 { 1138 {
@@ -1148,6 +1191,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1148 indirectly by prepending newdir to nm if necessary, and using 1191 indirectly by prepending newdir to nm if necessary, and using
1149 cwd (or the wd of newdir's drive) as the new newdir. */ 1192 cwd (or the wd of newdir's drive) as the new newdir. */
1150 char *adir; 1193 char *adir;
1194
1151 if (IS_DRIVE (newdir[0]) && IS_DEVICE_SEP (newdir[1])) 1195 if (IS_DRIVE (newdir[0]) && IS_DEVICE_SEP (newdir[1]))
1152 { 1196 {
1153 drive = (unsigned char) newdir[0]; 1197 drive = (unsigned char) newdir[0];
@@ -1157,7 +1201,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1157 { 1201 {
1158 ptrdiff_t newlen = strlen (newdir); 1202 ptrdiff_t newlen = strlen (newdir);
1159 char *tmp = alloca (newlen + strlen (nm) + 2); 1203 char *tmp = alloca (newlen + strlen (nm) + 2);
1160 file_name_as_directory (tmp, newdir, newlen); 1204 file_name_as_directory (tmp, newdir, newlen, multibyte);
1161 strcat (tmp, nm); 1205 strcat (tmp, nm);
1162 nm = tmp; 1206 nm = tmp;
1163 } 1207 }
@@ -1165,10 +1209,17 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1165 if (drive) 1209 if (drive)
1166 { 1210 {
1167 if (!getdefdir (c_toupper (drive) - 'A' + 1, adir)) 1211 if (!getdefdir (c_toupper (drive) - 'A' + 1, adir))
1168 newdir = "/"; 1212 strcpy (adir, "/");
1169 } 1213 }
1170 else 1214 else
1171 getcwd (adir, MAXPATHLEN + 1); 1215 getcwd (adir, MAXPATHLEN + 1);
1216 if (multibyte)
1217 {
1218 Lisp_Object tem = build_string (adir);
1219
1220 tem = DECODE_FILE (tem);
1221 memcpy (adir, SSDATA (tem), SBYTES (tem) + 1);
1222 }
1172 newdir = adir; 1223 newdir = adir;
1173 } 1224 }
1174 1225
@@ -1255,7 +1306,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1255 strcpy (target, newdir); 1306 strcpy (target, newdir);
1256 } 1307 }
1257 else 1308 else
1258 file_name_as_directory (target, newdir, length); 1309 file_name_as_directory (target, newdir, length, multibyte);
1259 } 1310 }
1260 1311
1261 strcat (target, nm); 1312 strcat (target, nm);
@@ -1341,9 +1392,14 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1341 target[1] = ':'; 1392 target[1] = ':';
1342 } 1393 }
1343 result = make_specified_string (target, -1, o - target, multibyte); 1394 result = make_specified_string (target, -1, o - target, multibyte);
1344 result = ENCODE_FILE (result); 1395 if (multibyte)
1345 dostounix_filename (SSDATA (result)); 1396 {
1346 result = DECODE_FILE (result); 1397 result = ENCODE_FILE (result);
1398 dostounix_filename (SSDATA (result));
1399 result = DECODE_FILE (result);
1400 }
1401 else
1402 dostounix_filename (SSDATA (result));
1347#else /* !DOS_NT */ 1403#else /* !DOS_NT */
1348 result = make_specified_string (target, -1, o - target, multibyte); 1404 result = make_specified_string (target, -1, o - target, multibyte);
1349#endif /* !DOS_NT */ 1405#endif /* !DOS_NT */
@@ -1625,18 +1681,24 @@ those `/' is discarded. */)
1625 memcpy (nm, SDATA (filename), SBYTES (filename) + 1); 1681 memcpy (nm, SDATA (filename), SBYTES (filename) + 1);
1626 1682
1627#ifdef DOS_NT 1683#ifdef DOS_NT
1628 { 1684 if (multibyte)
1629 Lisp_Object encoded_filename = ENCODE_FILE (filename); 1685 {
1630 Lisp_Object tem_fn; 1686 Lisp_Object encoded_filename = ENCODE_FILE (filename);
1631 1687 Lisp_Object tem_fn;
1632 dostounix_filename (SDATA (encoded_filename)); 1688
1633 tem_fn = DECODE_FILE (encoded_filename); 1689 dostounix_filename (SDATA (encoded_filename));
1634 nm = alloca (SBYTES (tem_fn) + 1); 1690 tem_fn = DECODE_FILE (encoded_filename);
1635 memcpy (nm, SDATA (tem_fn), SBYTES (tem_fn) + 1); 1691 nm = alloca (SBYTES (tem_fn) + 1);
1636 substituted = (memcmp (nm, SDATA (filename), SBYTES (filename)) != 0); 1692 memcpy (nm, SDATA (tem_fn), SBYTES (tem_fn) + 1);
1637 if (substituted) 1693 substituted = (memcmp (nm, SDATA (filename), SBYTES (filename)) != 0);
1638 filename = tem_fn; 1694 if (substituted)
1639 } 1695 filename = tem_fn;
1696 }
1697 else
1698 {
1699 dostounix_filename (nm);
1700 substituted = (memcmp (nm, SDATA (filename), SBYTES (filename)) != 0);
1701 }
1640#endif 1702#endif
1641 endp = nm + SBYTES (filename); 1703 endp = nm + SBYTES (filename);
1642 1704
@@ -1956,10 +2018,26 @@ entries (depending on how Emacs was built). */)
1956 out_st.st_mode = 0; 2018 out_st.st_mode = 0;
1957 2019
1958#ifdef WINDOWSNT 2020#ifdef WINDOWSNT
2021 if (!NILP (preserve_extended_attributes))
2022 {
2023#ifdef HAVE_POSIX_ACL
2024 acl = acl_get_file (SDATA (encoded_file), ACL_TYPE_ACCESS);
2025 if (acl == NULL && errno != ENOTSUP)
2026 report_file_error ("Getting ACL", Fcons (file, Qnil));
2027#endif
2028 }
1959 if (!CopyFile (SDATA (encoded_file), 2029 if (!CopyFile (SDATA (encoded_file),
1960 SDATA (encoded_newname), 2030 SDATA (encoded_newname),
1961 FALSE)) 2031 FALSE))
1962 report_file_error ("Copying file", Fcons (file, Fcons (newname, Qnil))); 2032 {
2033 /* CopyFile doesn't set errno when it fails. By far the most
2034 "popular" reason is that the target is read-only. */
2035 if (GetLastError () == 5)
2036 errno = EACCES;
2037 else
2038 errno = EPERM;
2039 report_file_error ("Copying file", Fcons (file, Fcons (newname, Qnil)));
2040 }
1963 /* CopyFile retains the timestamp by default. */ 2041 /* CopyFile retains the timestamp by default. */
1964 else if (NILP (keep_time)) 2042 else if (NILP (keep_time))
1965 { 2043 {
@@ -1983,6 +2061,17 @@ entries (depending on how Emacs was built). */)
1983 /* Restore original attributes. */ 2061 /* Restore original attributes. */
1984 SetFileAttributes (filename, attributes); 2062 SetFileAttributes (filename, attributes);
1985 } 2063 }
2064#ifdef HAVE_POSIX_ACL
2065 if (acl != NULL)
2066 {
2067 bool fail =
2068 acl_set_file (SDATA (encoded_newname), ACL_TYPE_ACCESS, acl) != 0;
2069 if (fail && errno != ENOTSUP)
2070 report_file_error ("Setting ACL", Fcons (newname, Qnil));
2071
2072 acl_free (acl);
2073 }
2074#endif
1986#else /* not WINDOWSNT */ 2075#else /* not WINDOWSNT */
1987 immediate_quit = 1; 2076 immediate_quit = 1;
1988 ifd = emacs_open (SSDATA (encoded_file), O_RDONLY, 0); 2077 ifd = emacs_open (SSDATA (encoded_file), O_RDONLY, 0);
@@ -2915,8 +3004,10 @@ DEFUN ("set-file-selinux-context", Fset_file_selinux_context,
2915CONTEXT should be a list (USER ROLE TYPE RANGE), where the list 3004CONTEXT should be a list (USER ROLE TYPE RANGE), where the list
2916elements are strings naming the components of a SELinux context. 3005elements are strings naming the components of a SELinux context.
2917 3006
2918This function does nothing if SELinux is disabled, or if Emacs was not 3007Value is t if setting of SELinux context was successful, nil otherwise.
2919compiled with SELinux support. */) 3008
3009This function does nothing and returns nil if SELinux is disabled,
3010or if Emacs was not compiled with SELinux support. */)
2920 (Lisp_Object filename, Lisp_Object context) 3011 (Lisp_Object filename, Lisp_Object context)
2921{ 3012{
2922 Lisp_Object absname; 3013 Lisp_Object absname;
@@ -2982,6 +3073,7 @@ compiled with SELinux support. */)
2982 3073
2983 context_free (parsed_con); 3074 context_free (parsed_con);
2984 freecon (con); 3075 freecon (con);
3076 return fail ? Qnil : Qt;
2985 } 3077 }
2986 else 3078 else
2987 report_file_error ("Doing lgetfilecon", Fcons (absname, Qnil)); 3079 report_file_error ("Doing lgetfilecon", Fcons (absname, Qnil));
@@ -2992,11 +3084,11 @@ compiled with SELinux support. */)
2992} 3084}
2993 3085
2994DEFUN ("file-acl", Ffile_acl, Sfile_acl, 1, 1, 0, 3086DEFUN ("file-acl", Ffile_acl, Sfile_acl, 1, 1, 0,
2995 doc: /* Return ACL entries of file named FILENAME, as a string. 3087 doc: /* Return ACL entries of file named FILENAME.
3088The entries are returned in a format suitable for use in `set-file-acl'
3089but is otherwise undocumented and subject to change.
2996Return nil if file does not exist or is not accessible, or if Emacs 3090Return nil if file does not exist or is not accessible, or if Emacs
2997was unable to determine the ACL entries. The latter can happen for 3091was unable to determine the ACL entries. */)
2998local files if Emacs was not compiled with ACL support, or for remote
2999files if the file handler returns nil for the file's ACL entries. */)
3000 (Lisp_Object filename) 3092 (Lisp_Object filename)
3001{ 3093{
3002 Lisp_Object absname; 3094 Lisp_Object absname;
@@ -3046,6 +3138,8 @@ DEFUN ("set-file-acl", Fset_file_acl, Sset_file_acl,
3046ACL-STRING should contain the textual representation of the ACL 3138ACL-STRING should contain the textual representation of the ACL
3047entries in a format suitable for the platform. 3139entries in a format suitable for the platform.
3048 3140
3141Value is t if setting of ACL was successful, nil otherwise.
3142
3049Setting ACL for local files requires Emacs to be built with ACL 3143Setting ACL for local files requires Emacs to be built with ACL
3050support. */) 3144support. */)
3051 (Lisp_Object filename, Lisp_Object acl_string) 3145 (Lisp_Object filename, Lisp_Object acl_string)
@@ -3085,6 +3179,7 @@ support. */)
3085 report_file_error ("Setting ACL", Fcons (absname, Qnil)); 3179 report_file_error ("Setting ACL", Fcons (absname, Qnil));
3086 3180
3087 acl_free (acl); 3181 acl_free (acl);
3182 return fail ? Qnil : Qt;
3088 } 3183 }
3089#endif 3184#endif
3090 3185
@@ -3398,7 +3493,10 @@ the number of characters that replace previous buffer contents.
3398 3493
3399This function does code conversion according to the value of 3494This function does code conversion according to the value of
3400`coding-system-for-read' or `file-coding-system-alist', and sets the 3495`coding-system-for-read' or `file-coding-system-alist', and sets the
3401variable `last-coding-system-used' to the coding system actually used. */) 3496variable `last-coding-system-used' to the coding system actually used.
3497
3498In addition, this function decodes the inserted text from known formats
3499by calling `format-decode', which see. */)
3402 (Lisp_Object filename, Lisp_Object visit, Lisp_Object beg, Lisp_Object end, Lisp_Object replace) 3500 (Lisp_Object filename, Lisp_Object visit, Lisp_Object beg, Lisp_Object end, Lisp_Object replace)
3403{ 3501{
3404 struct stat st; 3502 struct stat st;
@@ -4112,7 +4210,7 @@ variable `last-coding-system-used' to the coding system actually used. */)
4112 prepare_to_modify_buffer (GPT, GPT, NULL); 4210 prepare_to_modify_buffer (GPT, GPT, NULL);
4113 } 4211 }
4114 4212
4115 move_gap (PT); 4213 move_gap_both (PT, PT_BYTE);
4116 if (GAP_SIZE < total) 4214 if (GAP_SIZE < total)
4117 make_gap (total - GAP_SIZE); 4215 make_gap (total - GAP_SIZE);
4118 4216
diff --git a/src/filelock.c b/src/filelock.c
index 17f3f253249..f21240f8340 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -1,6 +1,6 @@
1/* Lock files for editing. 1/* Lock files for editing.
2 Copyright (C) 1985-1987, 1993-1994, 1996, 1998-2012 2 Copyright (C) 1985-1987, 1993-1994, 1996, 1998-2013 Free Software
3 Free Software Foundation, Inc. 3 Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/firstfile.c b/src/firstfile.c
index 444fb71b55d..80c936719d6 100644
--- a/src/firstfile.c
+++ b/src/firstfile.c
@@ -1,5 +1,5 @@
1/* Mark beginning of data space to dump as pure, for GNU Emacs. 1/* Mark beginning of data space to dump as pure, for GNU Emacs.
2 Copyright (C) 1997, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1997, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/floatfns.c b/src/floatfns.c
index 645a5957609..43576a16248 100644
--- a/src/floatfns.c
+++ b/src/floatfns.c
@@ -1,7 +1,7 @@
1/* Primitive operations on floating point for GNU Emacs Lisp interpreter. 1/* Primitive operations on floating point for GNU Emacs Lisp interpreter.
2 2
3Copyright (C) 1988, 1993-1994, 1999, 2001-2012 3Copyright (C) 1988, 1993-1994, 1999, 2001-2013 Free Software Foundation,
4 Free Software Foundation, Inc. 4Inc.
5 5
6Author: Wolfgang Rupprecht 6Author: Wolfgang Rupprecht
7(according to ack.texi) 7(according to ack.texi)
@@ -399,8 +399,8 @@ round2 (EMACS_INT i1, EMACS_INT i2)
399 odd. */ 399 odd. */
400 EMACS_INT q = i1 / i2; 400 EMACS_INT q = i1 / i2;
401 EMACS_INT r = i1 % i2; 401 EMACS_INT r = i1 % i2;
402 EMACS_INT abs_r = r < 0 ? -r : r; 402 EMACS_INT abs_r = eabs (r);
403 EMACS_INT abs_r1 = (i2 < 0 ? -i2 : i2) - abs_r; 403 EMACS_INT abs_r1 = eabs (i2) - abs_r;
404 return q + (abs_r + (q & 1) <= abs_r1 ? 0 : (i2 ^ r) < 0 ? -1 : 1); 404 return q + (abs_r + (q & 1) <= abs_r1 ? 0 : (i2 ^ r) < 0 ? -1 : 1);
405} 405}
406 406
diff --git a/src/fns.c b/src/fns.c
index 7c2222e9805..687c3f6ff39 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -1,6 +1,6 @@
1/* Random utility Lisp functions. 1/* Random utility Lisp functions.
2 Copyright (C) 1985-1987, 1993-1995, 1997-2012 2
3 Free Software Foundation, Inc. 3Copyright (C) 1985-1987, 1993-1995, 1997-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -86,7 +86,7 @@ Other values of LIMIT are ignored. */)
86 before it's time to do a QUIT. This must be a power of 2. */ 86 before it's time to do a QUIT. This must be a power of 2. */
87enum { QUIT_COUNT_HEURISTIC = 1 << 16 }; 87enum { QUIT_COUNT_HEURISTIC = 1 << 16 };
88 88
89/* Random data-structure functions */ 89/* Random data-structure functions. */
90 90
91DEFUN ("length", Flength, Slength, 1, 1, 0, 91DEFUN ("length", Flength, Slength, 1, 1, 0,
92 doc: /* Return the length of vector, list or string SEQUENCE. 92 doc: /* Return the length of vector, list or string SEQUENCE.
@@ -211,12 +211,18 @@ Symbols are also allowed; their print names are used instead. */)
211 211
212DEFUN ("compare-strings", Fcompare_strings, Scompare_strings, 6, 7, 0, 212DEFUN ("compare-strings", Fcompare_strings, Scompare_strings, 6, 7, 0,
213 doc: /* Compare the contents of two strings, converting to multibyte if needed. 213 doc: /* Compare the contents of two strings, converting to multibyte if needed.
214In string STR1, skip the first START1 characters and stop at END1. 214The arguments START1, END1, START2, and END2, if non-nil, are
215In string STR2, skip the first START2 characters and stop at END2. 215positions specifying which parts of STR1 or STR2 to compare. In
216END1 and END2 default to the full lengths of the respective strings. 216string STR1, compare the part between START1 (inclusive) and END1
217 217\(exclusive). If START1 is nil, it defaults to 0, the beginning of
218Case is significant in this comparison if IGNORE-CASE is nil. 218the string; if END1 is nil, it defaults to the length of the string.
219Unibyte strings are converted to multibyte for comparison. 219Likewise, in string STR2, compare the part between START2 and END2.
220
221The strings are compared by the numeric values of their characters.
222For instance, STR1 is "less than" STR2 if its first differing
223character has a smaller numeric value. If IGNORE-CASE is non-nil,
224characters are converted to lower-case before comparing them. Unibyte
225strings are converted to multibyte for comparison.
220 226
221The value is t if the strings (or specified portions) match. 227The value is t if the strings (or specified portions) match.
222If string STR1 is less, the value is a negative number N; 228If string STR1 is less, the value is a negative number N;
diff --git a/src/font.c b/src/font.c
index f6b6fa026c0..a3a41006f9b 100644
--- a/src/font.c
+++ b/src/font.c
@@ -1,6 +1,6 @@
1/* font.c -- "Font" primitives. 1/* font.c -- "Font" primitives.
2 2
3Copyright (C) 2006-2012 Free Software Foundation, Inc. 3Copyright (C) 2006-2013 Free Software Foundation, Inc.
4Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 4Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
5 National Institute of Advanced Industrial Science and Technology (AIST) 5 National Institute of Advanced Industrial Science and Technology (AIST)
6 Registration Number H13PRO009 6 Registration Number H13PRO009
@@ -2101,9 +2101,7 @@ font_score (Lisp_Object entity, Lisp_Object *spec_prop)
2101 { 2101 {
2102 EMACS_INT diff = ((XINT (AREF (entity, i)) >> 8) 2102 EMACS_INT diff = ((XINT (AREF (entity, i)) >> 8)
2103 - (XINT (spec_prop[i]) >> 8)); 2103 - (XINT (spec_prop[i]) >> 8));
2104 if (diff < 0) 2104 score |= min (eabs (diff), 127) << sort_shift_bits[i];
2105 diff = - diff;
2106 score |= min (diff, 127) << sort_shift_bits[i];
2107 } 2105 }
2108 2106
2109 /* Score the size. Maximum difference is 127. */ 2107 /* Score the size. Maximum difference is 127. */
@@ -2118,10 +2116,7 @@ font_score (Lisp_Object entity, Lisp_Object *spec_prop)
2118 2116
2119 if (CONSP (Vface_font_rescale_alist)) 2117 if (CONSP (Vface_font_rescale_alist))
2120 pixel_size *= font_rescale_ratio (entity); 2118 pixel_size *= font_rescale_ratio (entity);
2121 diff = pixel_size - XINT (AREF (entity, FONT_SIZE_INDEX)); 2119 diff = eabs (pixel_size - XINT (AREF (entity, FONT_SIZE_INDEX))) << 1;
2122 if (diff < 0)
2123 diff = - diff;
2124 diff <<= 1;
2125 if (! NILP (spec_prop[FONT_DPI_INDEX]) 2120 if (! NILP (spec_prop[FONT_DPI_INDEX])
2126 && ! EQ (spec_prop[FONT_DPI_INDEX], AREF (entity, FONT_DPI_INDEX))) 2121 && ! EQ (spec_prop[FONT_DPI_INDEX], AREF (entity, FONT_DPI_INDEX)))
2127 diff |= 1; 2122 diff |= 1;
@@ -2671,9 +2666,7 @@ font_delete_unmatched (Lisp_Object vec, Lisp_Object spec, int size)
2671 { 2666 {
2672 int diff = XINT (AREF (entity, FONT_SIZE_INDEX)) - size; 2667 int diff = XINT (AREF (entity, FONT_SIZE_INDEX)) - size;
2673 2668
2674 if (diff != 0 2669 if (eabs (diff) > FONT_PIXEL_SIZE_QUANTUM)
2675 && (diff < 0 ? -diff > FONT_PIXEL_SIZE_QUANTUM
2676 : diff > FONT_PIXEL_SIZE_QUANTUM))
2677 prop = FONT_SPEC_MAX; 2670 prop = FONT_SPEC_MAX;
2678 } 2671 }
2679 if (prop < FONT_SPEC_MAX 2672 if (prop < FONT_SPEC_MAX
diff --git a/src/font.h b/src/font.h
index 3035a909efc..b565fb4b01b 100644
--- a/src/font.h
+++ b/src/font.h
@@ -1,5 +1,5 @@
1/* font.h -- Interface definition for font handling. 1/* font.h -- Interface definition for font handling.
2 Copyright (C) 2006-2012 Free Software Foundation, Inc. 2 Copyright (C) 2006-2013 Free Software Foundation, Inc.
3 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 3 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
4 National Institute of Advanced Industrial Science and Technology (AIST) 4 National Institute of Advanced Industrial Science and Technology (AIST)
5 Registration Number H13PRO009 5 Registration Number H13PRO009
diff --git a/src/fontset.c b/src/fontset.c
index 660ca432fad..b7f3e46d69c 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -1,6 +1,6 @@
1/* Fontset handler. 1/* Fontset handler.
2 2
3Copyright (C) 2001-2012 Free Software Foundation, Inc. 3Copyright (C) 2001-2013 Free Software Foundation, Inc.
4Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 4Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
5 2005, 2006, 2007, 2008, 2009, 2010, 2011 5 2005, 2006, 2007, 2008, 2009, 2010, 2011
6 National Institute of Advanced Industrial Science and Technology (AIST) 6 National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/src/fontset.h b/src/fontset.h
index 3eb8d633b6c..07ee5d65c25 100644
--- a/src/fontset.h
+++ b/src/fontset.h
@@ -1,5 +1,5 @@
1/* Header for fontset handler. 1/* Header for fontset handler.
2 Copyright (C) 1998, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1998, 2001-2013 Free Software Foundation, Inc.
3 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 3 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 2005, 2006, 2007, 2008, 2009, 2010, 2011 4 2005, 2006, 2007, 2008, 2009, 2010, 2011
5 National Institute of Advanced Industrial Science and Technology (AIST) 5 National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/src/frame.c b/src/frame.c
index 5cefad6ca46..514b338df5b 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -1,6 +1,6 @@
1/* Generic frame functions. 1/* Generic frame functions.
2 2
3Copyright (C) 1993-1995, 1997, 1999-2012 Free Software Foundation, Inc. 3Copyright (C) 1993-1995, 1997, 1999-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -60,7 +60,7 @@ Lisp_Object Qns_parse_geometry;
60Lisp_Object Qframep, Qframe_live_p; 60Lisp_Object Qframep, Qframe_live_p;
61Lisp_Object Qicon, Qmodeline; 61Lisp_Object Qicon, Qmodeline;
62Lisp_Object Qonly, Qnone; 62Lisp_Object Qonly, Qnone;
63Lisp_Object Qx, Qw32, Qmac, Qpc, Qns; 63Lisp_Object Qx, Qw32, Qpc, Qns;
64Lisp_Object Qvisible; 64Lisp_Object Qvisible;
65Lisp_Object Qdisplay_type; 65Lisp_Object Qdisplay_type;
66static Lisp_Object Qbackground_mode; 66static Lisp_Object Qbackground_mode;
@@ -225,8 +225,6 @@ See also `frame-live-p'. */)
225 return Qw32; 225 return Qw32;
226 case output_msdos_raw: 226 case output_msdos_raw:
227 return Qpc; 227 return Qpc;
228 case output_mac:
229 return Qmac;
230 case output_ns: 228 case output_ns:
231 return Qns; 229 return Qns;
232 default: 230 default:
diff --git a/src/frame.h b/src/frame.h
index 589b45fc0ff..ec535d4448f 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -1,5 +1,5 @@
1/* Define frame-object for GNU Emacs. 1/* Define frame-object for GNU Emacs.
2 Copyright (C) 1993-1994, 1999-2012 Free Software Foundation, Inc. 2 Copyright (C) 1993-1994, 1999-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
@@ -46,7 +46,6 @@ enum output_method
46 output_x_window, 46 output_x_window,
47 output_msdos_raw, 47 output_msdos_raw,
48 output_w32, 48 output_w32,
49 output_mac,
50 output_ns 49 output_ns
51}; 50};
52 51
@@ -1178,7 +1177,7 @@ extern Lisp_Object Qalpha;
1178extern Lisp_Object Qleft_fringe, Qright_fringe; 1177extern Lisp_Object Qleft_fringe, Qright_fringe;
1179extern Lisp_Object Qheight, Qwidth; 1178extern Lisp_Object Qheight, Qwidth;
1180extern Lisp_Object Qminibuffer, Qmodeline; 1179extern Lisp_Object Qminibuffer, Qmodeline;
1181extern Lisp_Object Qx, Qw32, Qmac, Qpc, Qns; 1180extern Lisp_Object Qx, Qw32, Qpc, Qns;
1182extern Lisp_Object Qvisible; 1181extern Lisp_Object Qvisible;
1183extern Lisp_Object Qdisplay_type; 1182extern Lisp_Object Qdisplay_type;
1184 1183
diff --git a/src/fringe.c b/src/fringe.c
index ce31fd01763..fa6f889ba69 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -1,5 +1,6 @@
1/* Fringe handling (split from xdisp.c). 1/* Fringe handling (split from xdisp.c).
2 Copyright (C) 1985-1988, 1993-1995, 1997-2012 Free Software Foundation, Inc. 2 Copyright (C) 1985-1988, 1993-1995, 1997-2013 Free Software
3 Foundation, Inc.
3 4
4This file is part of GNU Emacs. 5This file is part of GNU Emacs.
5 6
@@ -1360,8 +1361,8 @@ compute_fringe_widths (struct frame *f, int redraw)
1360 1361
1361 if (left_fringe_width || right_fringe_width) 1362 if (left_fringe_width || right_fringe_width)
1362 { 1363 {
1363 int left_wid = left_fringe_width >= 0 ? left_fringe_width : -left_fringe_width; 1364 int left_wid = eabs (left_fringe_width);
1364 int right_wid = right_fringe_width >= 0 ? right_fringe_width : -right_fringe_width; 1365 int right_wid = eabs (right_fringe_width);
1365 int conf_wid = left_wid + right_wid; 1366 int conf_wid = left_wid + right_wid;
1366 int font_wid = FRAME_COLUMN_WIDTH (f); 1367 int font_wid = FRAME_COLUMN_WIDTH (f);
1367 int cols = (left_wid + right_wid + font_wid-1) / font_wid; 1368 int cols = (left_wid + right_wid + font_wid-1) / font_wid;
diff --git a/src/ftfont.c b/src/ftfont.c
index f07ad6f33c7..1ada95d377c 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -1,5 +1,5 @@
1/* ftfont.c -- FreeType font driver. 1/* ftfont.c -- FreeType font driver.
2 Copyright (C) 2006-2012 Free Software Foundation, Inc. 2 Copyright (C) 2006-2013 Free Software Foundation, Inc.
3 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 3 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
4 National Institute of Advanced Industrial Science and Technology (AIST) 4 National Institute of Advanced Industrial Science and Technology (AIST)
5 Registration Number H13PRO009 5 Registration Number H13PRO009
diff --git a/src/ftxfont.c b/src/ftxfont.c
index 5effe6e9104..8c56ee05adc 100644
--- a/src/ftxfont.c
+++ b/src/ftxfont.c
@@ -1,5 +1,5 @@
1/* ftxfont.c -- FreeType font driver on X (without using XFT). 1/* ftxfont.c -- FreeType font driver on X (without using XFT).
2 Copyright (C) 2006-2012 Free Software Foundation, Inc. 2 Copyright (C) 2006-2013 Free Software Foundation, Inc.
3 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 3 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
4 National Institute of Advanced Industrial Science and Technology (AIST) 4 National Institute of Advanced Industrial Science and Technology (AIST)
5 Registration Number H13PRO009 5 Registration Number H13PRO009
diff --git a/src/getpagesize.h b/src/getpagesize.h
index 545082b2e78..6d0932abf1b 100644
--- a/src/getpagesize.h
+++ b/src/getpagesize.h
@@ -1,5 +1,6 @@
1/* Emulate getpagesize on systems that lack it. 1/* Emulate getpagesize on systems that lack it.
2 Copyright (C) 1986, 1992, 1995, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1986, 1992, 1995, 2001-2013 Free Software Foundation,
3 Inc.
3 4
4This file is part of GNU Emacs. 5This file is part of GNU Emacs.
5 6
diff --git a/src/gmalloc.c b/src/gmalloc.c
index c325ca79910..bc1d85ac5fb 100644
--- a/src/gmalloc.c
+++ b/src/gmalloc.c
@@ -1,6 +1,6 @@
1/* Declarations for `malloc' and friends. 1/* Declarations for `malloc' and friends.
2 Copyright (C) 1990, 1991, 1992, 1993, 1995, 1996, 1999, 2002, 2003, 2004, 2 Copyright (C) 1990-1993, 1995-1996, 1999, 2002-2007, 2013 Free
3 2005, 2006, 2007 Free Software Foundation, Inc. 3 Software Foundation, Inc.
4 Written May 1989 by Mike Haertel. 4 Written May 1989 by Mike Haertel.
5 5
6This library is free software; you can redistribute it and/or 6This library is free software; you can redistribute it and/or
@@ -14,9 +14,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details. 14General Public License for more details.
15 15
16You should have received a copy of the GNU General Public 16You should have received a copy of the GNU General Public
17License along with this library; see the file COPYING. If 17License along with this library. If not, see <http://www.gnu.org/licenses/>.
18not, write to the Free Software Foundation, Inc., 51 Franklin Street,
19Fifth Floor, Boston, MA 02110-1301, USA.
20 18
21 The author may be reached (Email) at the address mike@ai.mit.edu, 19 The author may be reached (Email) at the address mike@ai.mit.edu,
22 or (US mail) as Mike Haertel c/o Free Software Foundation. */ 20 or (US mail) as Mike Haertel c/o Free Software Foundation. */
@@ -292,9 +290,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
292General Public License for more details. 290General Public License for more details.
293 291
294You should have received a copy of the GNU General Public 292You should have received a copy of the GNU General Public
295License along with this library; see the file COPYING. If 293License along with this library. If not, see <http://www.gnu.org/licenses/>.
296not, write to the Free Software Foundation, Inc., 51 Franklin Street,
297Fifth Floor, Boston, MA 02110-1301, USA.
298 294
299 The author may be reached (Email) at the address mike@ai.mit.edu, 295 The author may be reached (Email) at the address mike@ai.mit.edu,
300 or (US mail) as Mike Haertel c/o Free Software Foundation. */ 296 or (US mail) as Mike Haertel c/o Free Software Foundation. */
@@ -972,9 +968,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
972General Public License for more details. 968General Public License for more details.
973 969
974You should have received a copy of the GNU General Public 970You should have received a copy of the GNU General Public
975License along with this library; see the file COPYING. If 971License along with this library. If not, see <http://www.gnu.org/licenses/>.
976not, write to the Free Software Foundation, Inc., 51 Franklin Street,
977Fifth Floor, Boston, MA 02110-1301, USA.
978 972
979 The author may be reached (Email) at the address mike@ai.mit.edu, 973 The author may be reached (Email) at the address mike@ai.mit.edu,
980 or (US mail) as Mike Haertel c/o Free Software Foundation. */ 974 or (US mail) as Mike Haertel c/o Free Software Foundation. */
@@ -1286,9 +1280,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1286General Public License for more details. 1280General Public License for more details.
1287 1281
1288You should have received a copy of the GNU General Public 1282You should have received a copy of the GNU General Public
1289License along with this library; see the file COPYING. If 1283License along with this library. If not, see <http://www.gnu.org/licenses/>.
1290not, write to the Free Software Foundation, Inc., 51 Franklin Street,
1291Fifth Floor, Boston, MA 02110-1301, USA.
1292 1284
1293 The author may be reached (Email) at the address mike@ai.mit.edu, 1285 The author may be reached (Email) at the address mike@ai.mit.edu,
1294 or (US mail) as Mike Haertel c/o Free Software Foundation. */ 1286 or (US mail) as Mike Haertel c/o Free Software Foundation. */
@@ -1487,9 +1479,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1487General Public License for more details. 1479General Public License for more details.
1488 1480
1489You should have received a copy of the GNU General Public 1481You should have received a copy of the GNU General Public
1490License along with this library; see the file COPYING. If 1482License along with this library. If not, see <http://www.gnu.org/licenses/>.
1491not, write to the Free Software Foundation, Inc., 51 Franklin Street,
1492Fifth Floor, Boston, MA 02110-1301, USA.
1493 1483
1494 The author may be reached (Email) at the address mike@ai.mit.edu, 1484 The author may be reached (Email) at the address mike@ai.mit.edu,
1495 or (US mail) as Mike Haertel c/o Free Software Foundation. */ 1485 or (US mail) as Mike Haertel c/o Free Software Foundation. */
@@ -1520,9 +1510,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1520GNU General Public License for more details. 1510GNU General Public License for more details.
1521 1511
1522You should have received a copy of the GNU General Public License 1512You should have received a copy of the GNU General Public License
1523along with the GNU C Library; see the file COPYING. If not, write to 1513along with the GNU C Library. If not, see <http://www.gnu.org/licenses/>. */
1524the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
1525MA 02110-1301, USA. */
1526 1514
1527/* uClibc defines __GNU_LIBRARY__, but it is not completely 1515/* uClibc defines __GNU_LIBRARY__, but it is not completely
1528 compatible. */ 1516 compatible. */
@@ -1566,9 +1554,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1566General Public License for more details. 1554General Public License for more details.
1567 1555
1568You should have received a copy of the GNU General Public 1556You should have received a copy of the GNU General Public
1569License along with this library; see the file COPYING. If 1557License along with this library. If not, see <http://www.gnu.org/licenses/>. */
1570not, write to the Free Software Foundation, Inc., 51 Franklin Street,
1571Fifth Floor, Boston, MA 02110-1301, USA. */
1572 1558
1573void *(*__memalign_hook) (size_t size, size_t alignment); 1559void *(*__memalign_hook) (size_t size, size_t alignment);
1574 1560
@@ -1678,9 +1664,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1678General Public License for more details. 1664General Public License for more details.
1679 1665
1680You should have received a copy of the GNU General Public 1666You should have received a copy of the GNU General Public
1681License along with this library; see the file COPYING. If 1667License along with this library. If not, see <http://www.gnu.org/licenses/>.
1682not, write to the Free Software Foundation, Inc., 51 Franklin Street,
1683Fifth Floor, Boston, MA 02110-1301, USA.
1684 1668
1685 The author may be reached (Email) at the address mike@ai.mit.edu, 1669 The author may be reached (Email) at the address mike@ai.mit.edu,
1686 or (US mail) as Mike Haertel c/o Free Software Foundation. */ 1670 or (US mail) as Mike Haertel c/o Free Software Foundation. */
@@ -1722,9 +1706,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1722General Public License for more details. 1706General Public License for more details.
1723 1707
1724You should have received a copy of the GNU General Public 1708You should have received a copy of the GNU General Public
1725License along with this library; see the file COPYING. If 1709License along with this library. If not, see <http://www.gnu.org/licenses/>.
1726not, write to the Free Software Foundation, Inc., 51 Franklin Street,
1727Fifth Floor, Boston, MA 02110-1301, USA.
1728 1710
1729 The author may be reached (Email) at the address mike@ai.mit.edu, 1711 The author may be reached (Email) at the address mike@ai.mit.edu,
1730 or (US mail) as Mike Haertel c/o Free Software Foundation. */ 1712 or (US mail) as Mike Haertel c/o Free Software Foundation. */
diff --git a/src/gnutls.c b/src/gnutls.c
index 03f753fa8cc..db0a6dac01c 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -1,5 +1,5 @@
1/* GnuTLS glue for GNU Emacs. 1/* GnuTLS glue for GNU Emacs.
2 Copyright (C) 2010-2012 Free Software Foundation, Inc. 2 Copyright (C) 2010-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/gnutls.h b/src/gnutls.h
index 2b13908a748..f1a337e7b3e 100644
--- a/src/gnutls.h
+++ b/src/gnutls.h
@@ -1,5 +1,5 @@
1/* GnuTLS glue for GNU Emacs. 1/* GnuTLS glue for GNU Emacs.
2 Copyright (C) 2010-2012 Free Software Foundation, Inc. 2 Copyright (C) 2010-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 9f2b652525f..95ac04b8ff0 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -1,6 +1,6 @@
1/* Functions for creating and updating GTK widgets. 1/* Functions for creating and updating GTK widgets.
2 2
3Copyright (C) 2003-2012 Free Software Foundation, Inc. 3Copyright (C) 2003-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -2416,6 +2416,8 @@ make_menu_item (const char *utf8_label,
2416 return w; 2416 return w;
2417} 2417}
2418 2418
2419#ifdef HAVE_GTK_TEAROFF_MENU_ITEM_NEW
2420
2419static int xg_detached_menus; 2421static int xg_detached_menus;
2420 2422
2421/* Return true if there are detached menus. */ 2423/* Return true if there are detached menus. */
@@ -2454,7 +2456,13 @@ tearoff_activate (GtkWidget *widget, gpointer client_data)
2454 G_CALLBACK (tearoff_remove), 0); 2456 G_CALLBACK (tearoff_remove), 0);
2455 } 2457 }
2456} 2458}
2457 2459#else /* ! HAVE_GTK_TEAROFF_MENU_ITEM_NEW */
2460bool
2461xg_have_tear_offs (void)
2462{
2463 return false;
2464}
2465#endif /* ! HAVE_GTK_TEAROFF_MENU_ITEM_NEW */
2458 2466
2459/* Create a menu item widget, and connect the callbacks. 2467/* Create a menu item widget, and connect the callbacks.
2460 ITEM describes the menu item. 2468 ITEM describes the menu item.
@@ -2526,7 +2534,8 @@ xg_create_one_menuitem (widget_value *item,
2526 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. 2534 HIGHLIGHT_CB is the callback to call when entering/leaving menu items.
2527 If POP_UP_P, create a popup menu. 2535 If POP_UP_P, create a popup menu.
2528 If MENU_BAR_P, create a menu bar. 2536 If MENU_BAR_P, create a menu bar.
2529 If ADD_TEAROFF_P, add a tearoff menu item. Ignored if MENU_BAR_P. 2537 If ADD_TEAROFF_P, add a tearoff menu item. Ignored if MENU_BAR_P or
2538 the Gtk+ version used does not have tearoffs.
2530 TOPMENU is the topmost GtkWidget that others shall be placed under. 2539 TOPMENU is the topmost GtkWidget that others shall be placed under.
2531 It may be NULL, in that case we create the appropriate widget 2540 It may be NULL, in that case we create the appropriate widget
2532 (menu bar or menu item depending on POP_UP_P and MENU_BAR_P) 2541 (menu bar or menu item depending on POP_UP_P and MENU_BAR_P)
@@ -2599,6 +2608,7 @@ create_menus (widget_value *data,
2599 "selection-done", deactivate_cb, 0); 2608 "selection-done", deactivate_cb, 0);
2600 } 2609 }
2601 2610
2611#ifdef HAVE_GTK_TEAROFF_MENU_ITEM_NEW
2602 if (! menu_bar_p && add_tearoff_p) 2612 if (! menu_bar_p && add_tearoff_p)
2603 { 2613 {
2604 GtkWidget *tearoff = gtk_tearoff_menu_item_new (); 2614 GtkWidget *tearoff = gtk_tearoff_menu_item_new ();
@@ -2607,6 +2617,7 @@ create_menus (widget_value *data,
2607 g_signal_connect (G_OBJECT (tearoff), "activate", 2617 g_signal_connect (G_OBJECT (tearoff), "activate",
2608 G_CALLBACK (tearoff_activate), 0); 2618 G_CALLBACK (tearoff_activate), 0);
2609 } 2619 }
2620#endif
2610 2621
2611 for (item = data; item; item = item->next) 2622 for (item = data; item; item = item->next)
2612 { 2623 {
@@ -2897,11 +2908,13 @@ xg_update_menubar (GtkWidget *menubar,
2897 2908
2898 gtk_label_set_text (wlabel, utf8_label); 2909 gtk_label_set_text (wlabel, utf8_label);
2899 2910
2911#ifdef HAVE_GTK_TEAROFF_MENU_ITEM_NEW
2900 /* If this item has a submenu that has been detached, change 2912 /* If this item has a submenu that has been detached, change
2901 the title in the WM decorations also. */ 2913 the title in the WM decorations also. */
2902 if (submenu && gtk_menu_get_tearoff_state (GTK_MENU (submenu))) 2914 if (submenu && gtk_menu_get_tearoff_state (GTK_MENU (submenu)))
2903 /* Set the title of the detached window. */ 2915 /* Set the title of the detached window. */
2904 gtk_menu_set_title (GTK_MENU (submenu), utf8_label); 2916 gtk_menu_set_title (GTK_MENU (submenu), utf8_label);
2917#endif
2905 2918
2906 if (utf8_label) g_free (utf8_label); 2919 if (utf8_label) g_free (utf8_label);
2907 iter = g_list_next (iter); 2920 iter = g_list_next (iter);
@@ -3129,7 +3142,8 @@ xg_update_submenu (GtkWidget *submenu,
3129 { 3142 {
3130 GtkWidget *w = GTK_WIDGET (iter->data); 3143 GtkWidget *w = GTK_WIDGET (iter->data);
3131 3144
3132 /* Skip tearoff items, they have no counterpart in val. */ 3145#ifdef HAVE_GTK_TEAROFF_MENU_ITEM_NEW
3146 /* Skip tearoff items, they have no counterpart in val. */
3133 if (GTK_IS_TEAROFF_MENU_ITEM (w)) 3147 if (GTK_IS_TEAROFF_MENU_ITEM (w))
3134 { 3148 {
3135 has_tearoff_p = 1; 3149 has_tearoff_p = 1;
@@ -3137,6 +3151,7 @@ xg_update_submenu (GtkWidget *submenu,
3137 if (iter) w = GTK_WIDGET (iter->data); 3151 if (iter) w = GTK_WIDGET (iter->data);
3138 else break; 3152 else break;
3139 } 3153 }
3154#endif
3140 3155
3141 /* Remember first radio button in a group. If we get a mismatch in 3156 /* Remember first radio button in a group. If we get a mismatch in
3142 a radio group we must rebuild the whole group so that the connections 3157 a radio group we must rebuild the whole group so that the connections
@@ -4138,7 +4153,7 @@ xg_tool_bar_detach_callback (GtkHandleBox *wbox,
4138 if (f) 4153 if (f)
4139 { 4154 {
4140 GtkRequisition req, req2; 4155 GtkRequisition req, req2;
4141 FRAME_X_OUTPUT (f)->toolbar_detached = 1; 4156
4142 gtk_widget_get_preferred_size (GTK_WIDGET (wbox), NULL, &req); 4157 gtk_widget_get_preferred_size (GTK_WIDGET (wbox), NULL, &req);
4143 gtk_widget_get_preferred_size (w, NULL, &req2); 4158 gtk_widget_get_preferred_size (w, NULL, &req2);
4144 req.width -= req2.width; 4159 req.width -= req2.width;
@@ -4173,7 +4188,7 @@ xg_tool_bar_attach_callback (GtkHandleBox *wbox,
4173 if (f) 4188 if (f)
4174 { 4189 {
4175 GtkRequisition req, req2; 4190 GtkRequisition req, req2;
4176 FRAME_X_OUTPUT (f)->toolbar_detached = 0; 4191
4177 gtk_widget_get_preferred_size (GTK_WIDGET (wbox), NULL, &req); 4192 gtk_widget_get_preferred_size (GTK_WIDGET (wbox), NULL, &req);
4178 gtk_widget_get_preferred_size (w, NULL, &req2); 4193 gtk_widget_get_preferred_size (w, NULL, &req2);
4179 req.width += req2.width; 4194 req.width += req2.width;
@@ -4269,6 +4284,12 @@ xg_tool_bar_item_expose_callback (GtkWidget *w,
4269 gtk_toolbar_set_orientation (GTK_TOOLBAR (w), o) 4284 gtk_toolbar_set_orientation (GTK_TOOLBAR (w), o)
4270#endif 4285#endif
4271 4286
4287#ifdef HAVE_GTK_HANDLE_BOX_NEW
4288#define TOOLBAR_TOP_WIDGET(x) ((x)->handlebox_widget)
4289#else
4290#define TOOLBAR_TOP_WIDGET(x) ((x)->toolbar_widget)
4291#endif
4292
4272/* Attach a tool bar to frame F. */ 4293/* Attach a tool bar to frame F. */
4273 4294
4274static void 4295static void
@@ -4276,14 +4297,16 @@ xg_pack_tool_bar (FRAME_PTR f, Lisp_Object pos)
4276{ 4297{
4277 struct x_output *x = f->output_data.x; 4298 struct x_output *x = f->output_data.x;
4278 bool into_hbox = EQ (pos, Qleft) || EQ (pos, Qright); 4299 bool into_hbox = EQ (pos, Qleft) || EQ (pos, Qright);
4300 GtkWidget *top_widget = TOOLBAR_TOP_WIDGET (x);
4279 4301
4280 toolbar_set_orientation (x->toolbar_widget, 4302 toolbar_set_orientation (x->toolbar_widget,
4281 into_hbox 4303 into_hbox
4282 ? GTK_ORIENTATION_VERTICAL 4304 ? GTK_ORIENTATION_VERTICAL
4283 : GTK_ORIENTATION_HORIZONTAL); 4305 : GTK_ORIENTATION_HORIZONTAL);
4306#ifdef HAVE_GTK_HANDLE_BOX_NEW
4284 if (!x->handlebox_widget) 4307 if (!x->handlebox_widget)
4285 { 4308 {
4286 x->handlebox_widget = gtk_handle_box_new (); 4309 top_widget = x->handlebox_widget = gtk_handle_box_new ();
4287 g_signal_connect (G_OBJECT (x->handlebox_widget), "child-detached", 4310 g_signal_connect (G_OBJECT (x->handlebox_widget), "child-detached",
4288 G_CALLBACK (xg_tool_bar_detach_callback), f); 4311 G_CALLBACK (xg_tool_bar_detach_callback), f);
4289 g_signal_connect (G_OBJECT (x->handlebox_widget), "child-attached", 4312 g_signal_connect (G_OBJECT (x->handlebox_widget), "child-attached",
@@ -4291,34 +4314,40 @@ xg_pack_tool_bar (FRAME_PTR f, Lisp_Object pos)
4291 gtk_container_add (GTK_CONTAINER (x->handlebox_widget), 4314 gtk_container_add (GTK_CONTAINER (x->handlebox_widget),
4292 x->toolbar_widget); 4315 x->toolbar_widget);
4293 } 4316 }
4317#endif
4294 4318
4295 if (into_hbox) 4319 if (into_hbox)
4296 { 4320 {
4321#ifdef HAVE_GTK_HANDLE_BOX_NEW
4297 gtk_handle_box_set_handle_position (GTK_HANDLE_BOX (x->handlebox_widget), 4322 gtk_handle_box_set_handle_position (GTK_HANDLE_BOX (x->handlebox_widget),
4298 GTK_POS_TOP); 4323 GTK_POS_TOP);
4299 gtk_box_pack_start (GTK_BOX (x->hbox_widget), x->handlebox_widget, 4324#endif
4325 gtk_box_pack_start (GTK_BOX (x->hbox_widget), top_widget,
4300 FALSE, FALSE, 0); 4326 FALSE, FALSE, 0);
4301 4327
4302 if (EQ (pos, Qleft)) 4328 if (EQ (pos, Qleft))
4303 gtk_box_reorder_child (GTK_BOX (x->hbox_widget), 4329 gtk_box_reorder_child (GTK_BOX (x->hbox_widget),
4304 x->handlebox_widget, 4330 top_widget,
4305 0); 4331 0);
4306 x->toolbar_in_hbox = 1; 4332 x->toolbar_in_hbox = true;
4307 } 4333 }
4308 else 4334 else
4309 { 4335 {
4310 bool vbox_pos = x->menubar_widget != 0; 4336 bool vbox_pos = x->menubar_widget != 0;
4337#ifdef HAVE_GTK_HANDLE_BOX_NEW
4311 gtk_handle_box_set_handle_position (GTK_HANDLE_BOX (x->handlebox_widget), 4338 gtk_handle_box_set_handle_position (GTK_HANDLE_BOX (x->handlebox_widget),
4312 GTK_POS_LEFT); 4339 GTK_POS_LEFT);
4313 gtk_box_pack_start (GTK_BOX (x->vbox_widget), x->handlebox_widget, 4340#endif
4341 gtk_box_pack_start (GTK_BOX (x->vbox_widget), top_widget,
4314 FALSE, FALSE, 0); 4342 FALSE, FALSE, 0);
4315 4343
4316 if (EQ (pos, Qtop)) 4344 if (EQ (pos, Qtop))
4317 gtk_box_reorder_child (GTK_BOX (x->vbox_widget), 4345 gtk_box_reorder_child (GTK_BOX (x->vbox_widget),
4318 x->handlebox_widget, 4346 top_widget,
4319 vbox_pos); 4347 vbox_pos);
4320 x->toolbar_in_hbox = 0; 4348 x->toolbar_in_hbox = false;
4321 } 4349 }
4350 x->toolbar_is_packed = true;
4322} 4351}
4323 4352
4324/* Create a tool bar for frame F. */ 4353/* Create a tool bar for frame F. */
@@ -4347,7 +4376,6 @@ xg_create_tool_bar (FRAME_PTR f)
4347 } 4376 }
4348 4377
4349 x->toolbar_widget = gtk_toolbar_new (); 4378 x->toolbar_widget = gtk_toolbar_new ();
4350 x->toolbar_detached = 0;
4351 4379
4352 gtk_widget_set_name (x->toolbar_widget, "emacs-toolbar"); 4380 gtk_widget_set_name (x->toolbar_widget, "emacs-toolbar");
4353 4381
@@ -4562,13 +4590,14 @@ xg_update_tool_bar_sizes (FRAME_PTR f)
4562 struct x_output *x = f->output_data.x; 4590 struct x_output *x = f->output_data.x;
4563 GtkRequisition req; 4591 GtkRequisition req;
4564 int nl = 0, nr = 0, nt = 0, nb = 0; 4592 int nl = 0, nr = 0, nt = 0, nb = 0;
4593 GtkWidget *top_widget = TOOLBAR_TOP_WIDGET (x);
4565 4594
4566 gtk_widget_get_preferred_size (GTK_WIDGET (x->handlebox_widget), NULL, &req); 4595 gtk_widget_get_preferred_size (GTK_WIDGET (top_widget), NULL, &req);
4567 if (x->toolbar_in_hbox) 4596 if (x->toolbar_in_hbox)
4568 { 4597 {
4569 int pos; 4598 int pos;
4570 gtk_container_child_get (GTK_CONTAINER (x->hbox_widget), 4599 gtk_container_child_get (GTK_CONTAINER (x->hbox_widget),
4571 x->handlebox_widget, 4600 top_widget,
4572 "position", &pos, NULL); 4601 "position", &pos, NULL);
4573 if (pos == 0) nl = req.width; 4602 if (pos == 0) nl = req.width;
4574 else nr = req.width; 4603 else nr = req.width;
@@ -4577,7 +4606,7 @@ xg_update_tool_bar_sizes (FRAME_PTR f)
4577 { 4606 {
4578 int pos; 4607 int pos;
4579 gtk_container_child_get (GTK_CONTAINER (x->vbox_widget), 4608 gtk_container_child_get (GTK_CONTAINER (x->vbox_widget),
4580 x->handlebox_widget, 4609 top_widget,
4581 "position", &pos, NULL); 4610 "position", &pos, NULL);
4582 if (pos == 0 || (pos == 1 && x->menubar_widget)) nt = req.height; 4611 if (pos == 0 || (pos == 1 && x->menubar_widget)) nt = req.height;
4583 else nb = req.height; 4612 else nb = req.height;
@@ -4612,7 +4641,6 @@ update_frame_tool_bar (FRAME_PTR f)
4612 GtkToolbar *wtoolbar; 4641 GtkToolbar *wtoolbar;
4613 GtkToolItem *ti; 4642 GtkToolItem *ti;
4614 GtkTextDirection dir; 4643 GtkTextDirection dir;
4615 bool pack_tool_bar = x->handlebox_widget == NULL;
4616 Lisp_Object style; 4644 Lisp_Object style;
4617 bool text_image, horiz; 4645 bool text_image, horiz;
4618 struct xg_frame_tb_info *tbinfo; 4646 struct xg_frame_tb_info *tbinfo;
@@ -4866,9 +4894,9 @@ update_frame_tool_bar (FRAME_PTR f)
4866 4894
4867 if (f->n_tool_bar_items != 0) 4895 if (f->n_tool_bar_items != 0)
4868 { 4896 {
4869 if (pack_tool_bar) 4897 if (! x->toolbar_is_packed)
4870 xg_pack_tool_bar (f, f->tool_bar_position); 4898 xg_pack_tool_bar (f, f->tool_bar_position);
4871 gtk_widget_show_all (GTK_WIDGET (x->handlebox_widget)); 4899 gtk_widget_show_all (TOOLBAR_TOP_WIDGET (x));
4872 if (xg_update_tool_bar_sizes (f)) 4900 if (xg_update_tool_bar_sizes (f))
4873 xg_height_or_width_changed (f); 4901 xg_height_or_width_changed (f);
4874 } 4902 }
@@ -4887,24 +4915,26 @@ free_frame_tool_bar (FRAME_PTR f)
4887 if (x->toolbar_widget) 4915 if (x->toolbar_widget)
4888 { 4916 {
4889 struct xg_frame_tb_info *tbinfo; 4917 struct xg_frame_tb_info *tbinfo;
4890 bool is_packed = x->handlebox_widget != 0; 4918 GtkWidget *top_widget = TOOLBAR_TOP_WIDGET (x);
4919
4891 block_input (); 4920 block_input ();
4892 /* We may have created the toolbar_widget in xg_create_tool_bar, but 4921 /* We may have created the toolbar_widget in xg_create_tool_bar, but
4893 not the x->handlebox_widget which is created in xg_pack_tool_bar. */ 4922 not the x->handlebox_widget which is created in xg_pack_tool_bar. */
4894 if (is_packed) 4923 if (x->toolbar_is_packed)
4895 { 4924 {
4896 if (x->toolbar_in_hbox) 4925 if (x->toolbar_in_hbox)
4897 gtk_container_remove (GTK_CONTAINER (x->hbox_widget), 4926 gtk_container_remove (GTK_CONTAINER (x->hbox_widget),
4898 x->handlebox_widget); 4927 top_widget);
4899 else 4928 else
4900 gtk_container_remove (GTK_CONTAINER (x->vbox_widget), 4929 gtk_container_remove (GTK_CONTAINER (x->vbox_widget),
4901 x->handlebox_widget); 4930 top_widget);
4902 } 4931 }
4903 else 4932 else
4904 gtk_widget_destroy (x->toolbar_widget); 4933 gtk_widget_destroy (x->toolbar_widget);
4905 4934
4906 x->toolbar_widget = 0; 4935 x->toolbar_widget = 0;
4907 x->handlebox_widget = 0; 4936 TOOLBAR_TOP_WIDGET (x) = 0;
4937 x->toolbar_is_packed = false;
4908 FRAME_TOOLBAR_TOP_HEIGHT (f) = FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = 0; 4938 FRAME_TOOLBAR_TOP_HEIGHT (f) = FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = 0;
4909 FRAME_TOOLBAR_LEFT_WIDTH (f) = FRAME_TOOLBAR_RIGHT_WIDTH (f) = 0; 4939 FRAME_TOOLBAR_LEFT_WIDTH (f) = FRAME_TOOLBAR_RIGHT_WIDTH (f) = 0;
4910 4940
@@ -4928,20 +4958,25 @@ void
4928xg_change_toolbar_position (FRAME_PTR f, Lisp_Object pos) 4958xg_change_toolbar_position (FRAME_PTR f, Lisp_Object pos)
4929{ 4959{
4930 struct x_output *x = f->output_data.x; 4960 struct x_output *x = f->output_data.x;
4961 GtkWidget *top_widget = TOOLBAR_TOP_WIDGET (x);
4931 4962
4932 if (! x->toolbar_widget || ! x->handlebox_widget) 4963 if (! x->toolbar_widget || ! top_widget)
4933 return; 4964 return;
4934 4965
4935 block_input (); 4966 block_input ();
4936 g_object_ref (x->handlebox_widget); 4967 g_object_ref (top_widget);
4937 if (x->toolbar_in_hbox) 4968 if (x->toolbar_is_packed)
4938 gtk_container_remove (GTK_CONTAINER (x->hbox_widget), 4969 {
4939 x->handlebox_widget); 4970 if (x->toolbar_in_hbox)
4940 else 4971 gtk_container_remove (GTK_CONTAINER (x->hbox_widget),
4941 gtk_container_remove (GTK_CONTAINER (x->vbox_widget), 4972 top_widget);
4942 x->handlebox_widget); 4973 else
4974 gtk_container_remove (GTK_CONTAINER (x->vbox_widget),
4975 top_widget);
4976 }
4977
4943 xg_pack_tool_bar (f, pos); 4978 xg_pack_tool_bar (f, pos);
4944 g_object_unref (x->handlebox_widget); 4979 g_object_unref (top_widget);
4945 if (xg_update_tool_bar_sizes (f)) 4980 if (xg_update_tool_bar_sizes (f))
4946 xg_height_or_width_changed (f); 4981 xg_height_or_width_changed (f);
4947 4982
@@ -4967,7 +5002,9 @@ xg_initialize (void)
4967 5002
4968 gdpy_def = NULL; 5003 gdpy_def = NULL;
4969 xg_ignore_gtk_scrollbar = 0; 5004 xg_ignore_gtk_scrollbar = 0;
5005#ifdef HAVE_GTK_TEAROFF_MENU_ITEM_NEW
4970 xg_detached_menus = 0; 5006 xg_detached_menus = 0;
5007#endif
4971 xg_menu_cb_list.prev = xg_menu_cb_list.next = 5008 xg_menu_cb_list.prev = xg_menu_cb_list.next =
4972 xg_menu_item_cb_list.prev = xg_menu_item_cb_list.next = 0; 5009 xg_menu_item_cb_list.prev = xg_menu_item_cb_list.next = 0;
4973 5010
diff --git a/src/gtkutil.h b/src/gtkutil.h
index 43f2b237a68..288b3e99299 100644
--- a/src/gtkutil.h
+++ b/src/gtkutil.h
@@ -1,6 +1,6 @@
1/* Definitions and headers for GTK widgets. 1/* Definitions and headers for GTK widgets.
2 2
3Copyright (C) 2003-2012 Free Software Foundation, Inc. 3Copyright (C) 2003-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/image.c b/src/image.c
index 07db6cece1f..726b65d7338 100644
--- a/src/image.c
+++ b/src/image.c
@@ -1,6 +1,6 @@
1/* Functions for image support on window system. 1/* Functions for image support on window system.
2 2
3Copyright (C) 1989, 1992-2012 Free Software Foundation, Inc. 3Copyright (C) 1989, 1992-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/indent.c b/src/indent.c
index 3dbf372cf17..4a30c00dd27 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -1,6 +1,6 @@
1/* Indentation functions. 1/* Indentation functions.
2 Copyright (C) 1985-1988, 1993-1995, 1998, 2000-2012 2 Copyright (C) 1985-1988, 1993-1995, 1998, 2000-2013 Free Software
3 Free Software Foundation, Inc. 3 Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -571,7 +571,8 @@ scan_for_column (ptrdiff_t *endpos, EMACS_INT *goalcol, ptrdiff_t *prevcol)
571 col += width; 571 col += width;
572 if (endp > scan) /* Avoid infinite loops with 0-width overlays. */ 572 if (endp > scan) /* Avoid infinite loops with 0-width overlays. */
573 { 573 {
574 scan = endp; scan_byte = charpos_to_bytepos (scan); 574 scan = endp;
575 scan_byte = CHAR_TO_BYTE (scan);
575 continue; 576 continue;
576 } 577 }
577 } 578 }
diff --git a/src/indent.h b/src/indent.h
index abcd06036d1..acfd952754e 100644
--- a/src/indent.h
+++ b/src/indent.h
@@ -1,5 +1,5 @@
1/* Definitions for interface to indent.c 1/* Definitions for interface to indent.c
2 Copyright (C) 1985-1986, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1985-1986, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/inotify.c b/src/inotify.c
index 8a52c27985c..4efef9e55b7 100644
--- a/src/inotify.c
+++ b/src/inotify.c
@@ -1,7 +1,6 @@
1/* Inotify support for Emacs 1/* Inotify support for Emacs
2 2
3Copyright (C) 2012 3Copyright (C) 2012-2013 Free Software Foundation, Inc.
4 Free Software Foundation, Inc.
5 4
6This file is part of GNU Emacs. 5This file is part of GNU Emacs.
7 6
diff --git a/src/insdel.c b/src/insdel.c
index 74e938c4b8c..52a017a62a2 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -1,6 +1,6 @@
1/* Buffer insertion/deletion and gap motion for GNU Emacs. 1/* Buffer insertion/deletion and gap motion for GNU Emacs.
2 Copyright (C) 1985-1986, 1993-1995, 1997-2012 2 Copyright (C) 1985-1986, 1993-1995, 1997-2013 Free Software
3 Free Software Foundation, Inc. 3 Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -90,7 +90,7 @@ check_markers (void)
90void 90void
91move_gap (ptrdiff_t charpos) 91move_gap (ptrdiff_t charpos)
92{ 92{
93 move_gap_both (charpos, charpos_to_bytepos (charpos)); 93 move_gap_both (charpos, CHAR_TO_BYTE (charpos));
94} 94}
95 95
96/* Move gap to byte position BYTEPOS, which is also char position CHARPOS. 96/* Move gap to byte position BYTEPOS, which is also char position CHARPOS.
diff --git a/src/intervals.c b/src/intervals.c
index 1ed93e1302d..db38c86c00b 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -1,5 +1,6 @@
1/* Code for doing intervals. 1/* Code for doing intervals.
2 Copyright (C) 1993-1995, 1997-1998, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1993-1995, 1997-1998, 2001-2013 Free Software
3 Foundation, Inc.
3 4
4This file is part of GNU Emacs. 5This file is part of GNU Emacs.
5 6
@@ -1624,7 +1625,8 @@ graft_intervals_into_buffer (INTERVAL source, ptrdiff_t position,
1624 XSETBUFFER (buf, buffer); 1625 XSETBUFFER (buf, buffer);
1625 set_text_properties_1 (make_number (position), 1626 set_text_properties_1 (make_number (position),
1626 make_number (position + length), 1627 make_number (position + length),
1627 Qnil, buf, 0); 1628 Qnil, buf,
1629 find_interval (tree, position));
1628 } 1630 }
1629 /* Shouldn't be necessary. --Stef */ 1631 /* Shouldn't be necessary. --Stef */
1630 buffer_balance_intervals (buffer); 1632 buffer_balance_intervals (buffer);
diff --git a/src/intervals.h b/src/intervals.h
index 2b30101d0fa..cded8c0abb2 100644
--- a/src/intervals.h
+++ b/src/intervals.h
@@ -1,5 +1,5 @@
1/* Definitions and global variables for intervals. 1/* Definitions and global variables for intervals.
2 Copyright (C) 1993-1994, 2000-2012 Free Software Foundation, Inc. 2 Copyright (C) 1993-1994, 2000-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/keyboard.c b/src/keyboard.c
index e2a0e23dd4a..8edd705135f 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1,6 +1,7 @@
1/* Keyboard and mouse input; editor command loop. 1/* Keyboard and mouse input; editor command loop.
2 2
3Copyright (C) 1985-1989, 1993-1997, 1999-2012 Free Software Foundation, Inc. 3Copyright (C) 1985-1989, 1993-1997, 1999-2013 Free Software Foundation,
4Inc.
4 5
5This file is part of GNU Emacs. 6This file is part of GNU Emacs.
6 7
@@ -6700,37 +6701,35 @@ get_input_pending (int flags)
6700void 6701void
6701record_asynch_buffer_change (void) 6702record_asynch_buffer_change (void)
6702{ 6703{
6703 struct input_event event;
6704 Lisp_Object tem;
6705 EVENT_INIT (event);
6706
6707 event.kind = BUFFER_SWITCH_EVENT;
6708 event.frame_or_window = Qnil;
6709 event.arg = Qnil;
6710
6711 /* We don't need a buffer-switch event unless Emacs is waiting for input. 6704 /* We don't need a buffer-switch event unless Emacs is waiting for input.
6712 The purpose of the event is to make read_key_sequence look up the 6705 The purpose of the event is to make read_key_sequence look up the
6713 keymaps again. If we aren't in read_key_sequence, we don't need one, 6706 keymaps again. If we aren't in read_key_sequence, we don't need one,
6714 and the event could cause trouble by messing up (input-pending-p). 6707 and the event could cause trouble by messing up (input-pending-p).
6715 Note: Fwaiting_for_user_input_p always returns nil when async 6708 Note: Fwaiting_for_user_input_p always returns nil when async
6716 subprocesses aren't supported. */ 6709 subprocesses aren't supported. */
6717 tem = Fwaiting_for_user_input_p (); 6710 if (!NILP (Fwaiting_for_user_input_p ()))
6718 if (NILP (tem)) 6711 {
6719 return; 6712 struct input_event event;
6713
6714 EVENT_INIT (event);
6715 event.kind = BUFFER_SWITCH_EVENT;
6716 event.frame_or_window = Qnil;
6717 event.arg = Qnil;
6720 6718
6721 /* Make sure no interrupt happens while storing the event. */ 6719 /* Make sure no interrupt happens while storing the event. */
6722#ifdef USABLE_SIGIO 6720#ifdef USABLE_SIGIO
6723 if (interrupt_input) 6721 if (interrupt_input)
6724 kbd_buffer_store_event (&event); 6722 kbd_buffer_store_event (&event);
6725 else 6723 else
6726#endif 6724#endif
6727 { 6725 {
6728 stop_polling (); 6726 stop_polling ();
6729 kbd_buffer_store_event (&event); 6727 kbd_buffer_store_event (&event);
6730 start_polling (); 6728 start_polling ();
6729 }
6731 } 6730 }
6732} 6731}
6733 6732
6734/* Read any terminal input already buffered up by the system 6733/* Read any terminal input already buffered up by the system
6735 into the kbd_buffer, but do not wait. 6734 into the kbd_buffer, but do not wait.
6736 6735
diff --git a/src/keyboard.h b/src/keyboard.h
index e57c8cc7193..7ffb436754b 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -1,5 +1,6 @@
1/* Declarations useful when processing input. 1/* Declarations useful when processing input.
2 Copyright (C) 1985-1987, 1993, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1985-1987, 1993, 2001-2013 Free Software Foundation,
3 Inc.
3 4
4This file is part of GNU Emacs. 5This file is part of GNU Emacs.
5 6
diff --git a/src/keymap.c b/src/keymap.c
index fbdd31e0de3..d1ddd55a358 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1,5 +1,6 @@
1/* Manipulation of keymaps 1/* Manipulation of keymaps
2 Copyright (C) 1985-1988, 1993-1995, 1998-2012 Free Software Foundation, Inc. 2 Copyright (C) 1985-1988, 1993-1995, 1998-2013 Free Software
3 Foundation, Inc.
3 4
4This file is part of GNU Emacs. 5This file is part of GNU Emacs.
5 6
@@ -2047,7 +2048,7 @@ DEFUN ("key-description", Fkey_description, Skey_description, 1, 2, 0,
2047Optional arg PREFIX is the sequence of keys leading up to KEYS. 2048Optional arg PREFIX is the sequence of keys leading up to KEYS.
2048For example, [?\C-x ?l] is converted into the string \"C-x l\". 2049For example, [?\C-x ?l] is converted into the string \"C-x l\".
2049 2050
2050The `kbd' macro is an approximate inverse of this. */) 2051For an approximate inverse of this, see `kbd'. */)
2051 (Lisp_Object keys, Lisp_Object prefix) 2052 (Lisp_Object keys, Lisp_Object prefix)
2052{ 2053{
2053 ptrdiff_t len = 0; 2054 ptrdiff_t len = 0;
diff --git a/src/keymap.h b/src/keymap.h
index c704ee0b050..eca0f1b4108 100644
--- a/src/keymap.h
+++ b/src/keymap.h
@@ -1,5 +1,5 @@
1/* Functions to manipulate keymaps. 1/* Functions to manipulate keymaps.
2 Copyright (C) 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/lastfile.c b/src/lastfile.c
index f8a64797362..019a6a99763 100644
--- a/src/lastfile.c
+++ b/src/lastfile.c
@@ -1,5 +1,5 @@
1/* Mark end of data space to dump as pure, for GNU Emacs. 1/* Mark end of data space to dump as pure, for GNU Emacs.
2 Copyright (C) 1985, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1985, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/lisp.h b/src/lisp.h
index 82bf621b62f..e96c9664743 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -1,6 +1,7 @@
1/* Fundamental definitions for GNU Emacs Lisp interpreter. 1/* Fundamental definitions for GNU Emacs Lisp interpreter.
2 2
3Copyright (C) 1985-1987, 1993-1995, 1997-2012 Free Software Foundation, Inc. 3Copyright (C) 1985-1987, 1993-1995, 1997-2013 Free Software Foundation,
4Inc.
4 5
5This file is part of GNU Emacs. 6This file is part of GNU Emacs.
6 7
@@ -327,6 +328,10 @@ enum Lisp_Fwd_Type
327 members that are accessible only from C. A Lisp_Misc object is a 328 members that are accessible only from C. A Lisp_Misc object is a
328 wrapper for a C struct that can contain anything you like. 329 wrapper for a C struct that can contain anything you like.
329 330
331 Explicit freeing is discouraged for Lisp objects in general. But if
332 you really need to exploit this, use Lisp_Misc (check free_misc in
333 alloc.c to see why). There is no way to free a vectorlike object.
334
330 To add a new pseudovector type, extend the pvec_type enumeration; 335 To add a new pseudovector type, extend the pvec_type enumeration;
331 to add a new Lisp_Misc, extend the Lisp_Misc_Type enumeration. 336 to add a new Lisp_Misc, extend the Lisp_Misc_Type enumeration.
332 337
@@ -336,6 +341,10 @@ enum Lisp_Fwd_Type
336 enumeration and a 1-bit GC markbit) and make sure the overall size 341 enumeration and a 1-bit GC markbit) and make sure the overall size
337 of the union is not increased by your addition. 342 of the union is not increased by your addition.
338 343
344 For a new pseudovector, it's highly desirable to limit the size
345 of your data type by VBLOCK_BYTES_MAX bytes (defined in alloc.c).
346 Otherwise you will need to change sweep_vectors (also in alloc.c).
347
339 Then you will need to add switch branches in print.c (in 348 Then you will need to add switch branches in print.c (in
340 print_object, to print your object, and possibly also in 349 print_object, to print your object, and possibly also in
341 print_preprocess) and to alloc.c, to mark your object (in 350 print_preprocess) and to alloc.c, to mark your object (in
@@ -3196,7 +3205,6 @@ extern void keys_of_buffer (void);
3196extern ptrdiff_t marker_position (Lisp_Object); 3205extern ptrdiff_t marker_position (Lisp_Object);
3197extern ptrdiff_t marker_byte_position (Lisp_Object); 3206extern ptrdiff_t marker_byte_position (Lisp_Object);
3198extern void clear_charpos_cache (struct buffer *); 3207extern void clear_charpos_cache (struct buffer *);
3199extern ptrdiff_t charpos_to_bytepos (ptrdiff_t);
3200extern ptrdiff_t buf_charpos_to_bytepos (struct buffer *, ptrdiff_t); 3208extern ptrdiff_t buf_charpos_to_bytepos (struct buffer *, ptrdiff_t);
3201extern ptrdiff_t buf_bytepos_to_charpos (struct buffer *, ptrdiff_t); 3209extern ptrdiff_t buf_bytepos_to_charpos (struct buffer *, ptrdiff_t);
3202extern void unchain_marker (struct Lisp_Marker *marker); 3210extern void unchain_marker (struct Lisp_Marker *marker);
diff --git a/src/lisp.mk b/src/lisp.mk
index 8c2710110e3..174e53ed561 100644
--- a/src/lisp.mk
+++ b/src/lisp.mk
@@ -1,7 +1,7 @@
1### lisp.mk --- src/Makefile fragment for GNU Emacs 1### lisp.mk --- src/Makefile fragment for GNU Emacs
2 2
3## Copyright (C) 1985, 1987-1988, 1993-1995, 1999-2012 3## Copyright (C) 1985, 1987-1988, 1993-1995, 1999-2013 Free Software
4## Free Software Foundation, Inc. 4## Foundation, Inc.
5 5
6## This file is part of GNU Emacs. 6## This file is part of GNU Emacs.
7 7
diff --git a/src/lread.c b/src/lread.c
index 2f385797ca0..2b96dc16359 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1,6 +1,7 @@
1/* Lisp parsing and input streams. 1/* Lisp parsing and input streams.
2 2
3Copyright (C) 1985-1989, 1993-1995, 1997-2012 Free Software Foundation, Inc. 3Copyright (C) 1985-1989, 1993-1995, 1997-2013 Free Software Foundation,
4Inc.
4 5
5This file is part of GNU Emacs. 6This file is part of GNU Emacs.
6 7
@@ -3569,9 +3570,8 @@ read_list (bool flag, Lisp_Object readcharfun)
3569 doc string, caller must make it 3570 doc string, caller must make it
3570 multibyte. */ 3571 multibyte. */
3571 3572
3572 EMACS_INT pos = XINT (XCDR (val));
3573 /* Position is negative for user variables. */ 3573 /* Position is negative for user variables. */
3574 if (pos < 0) pos = -pos; 3574 EMACS_INT pos = eabs (XINT (XCDR (val)));
3575 if (pos >= saved_doc_string_position 3575 if (pos >= saved_doc_string_position
3576 && pos < (saved_doc_string_position 3576 && pos < (saved_doc_string_position
3577 + saved_doc_string_length)) 3577 + saved_doc_string_length))
diff --git a/src/macros.c b/src/macros.c
index 632c851ee8c..1eef9b678f4 100644
--- a/src/macros.c
+++ b/src/macros.c
@@ -1,6 +1,6 @@
1/* Keyboard macros. 1/* Keyboard macros.
2 2
3Copyright (C) 1985-1986, 1993, 2000-2012 Free Software Foundation, Inc. 3Copyright (C) 1985-1986, 1993, 2000-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/macros.h b/src/macros.h
index d66784a0246..57cd1c4f2fd 100644
--- a/src/macros.h
+++ b/src/macros.h
@@ -1,5 +1,5 @@
1/* Definitions for keyboard macro interpretation in GNU Emacs. 1/* Definitions for keyboard macro interpretation in GNU Emacs.
2 Copyright (C) 1985, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1985, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/makefile.w32-in b/src/makefile.w32-in
index b595defdf6b..bbd9fd907b6 100644
--- a/src/makefile.w32-in
+++ b/src/makefile.w32-in
@@ -1,5 +1,5 @@
1# -*- Makefile -*- for GNU Emacs on the Microsoft Windows API. 1# -*- Makefile -*- for GNU Emacs on the Microsoft Windows API.
2# Copyright (C) 2000-2012 Free Software Foundation, Inc. 2# Copyright (C) 2000-2013 Free Software Foundation, Inc.
3 3
4# This file is part of GNU Emacs. 4# This file is part of GNU Emacs.
5 5
@@ -781,7 +781,6 @@ $(BLD)/editfns.$(O) : \
781 $(SRC)/editfns.c \ 781 $(SRC)/editfns.c \
782 $(SRC)/blockinput.h \ 782 $(SRC)/blockinput.h \
783 $(NT_INC)/pwd.h \ 783 $(NT_INC)/pwd.h \
784 $(NT_INC)/grp.h \
785 $(NT_INC)/unistd.h \ 784 $(NT_INC)/unistd.h \
786 $(GNU_LIB)/intprops.h \ 785 $(GNU_LIB)/intprops.h \
787 $(GNU_LIB)/strftime.h \ 786 $(GNU_LIB)/strftime.h \
@@ -791,6 +790,7 @@ $(BLD)/editfns.$(O) : \
791 $(CODING_H) \ 790 $(CODING_H) \
792 $(CONFIG_H) \ 791 $(CONFIG_H) \
793 $(FRAME_H) \ 792 $(FRAME_H) \
793 $(GRP_H) \
794 $(INTERVALS_H) \ 794 $(INTERVALS_H) \
795 $(LISP_H) \ 795 $(LISP_H) \
796 $(SYSTIME_H) \ 796 $(SYSTIME_H) \
@@ -843,6 +843,7 @@ $(BLD)/fileio.$(O) : \
843 $(SRC)/commands.h \ 843 $(SRC)/commands.h \
844 $(SRC)/w32.h \ 844 $(SRC)/w32.h \
845 $(NT_INC)/pwd.h \ 845 $(NT_INC)/pwd.h \
846 $(NT_INC)/sys/acl.h \
846 $(NT_INC)/sys/file.h \ 847 $(NT_INC)/sys/file.h \
847 $(NT_INC)/sys/stat.h \ 848 $(NT_INC)/sys/stat.h \
848 $(NT_INC)/unistd.h \ 849 $(NT_INC)/unistd.h \
@@ -1185,6 +1186,7 @@ $(BLD)/w32.$(O) : \
1185 $(SRC)/w32select.h \ 1186 $(SRC)/w32select.h \
1186 $(NT_INC)/dirent.h \ 1187 $(NT_INC)/dirent.h \
1187 $(NT_INC)/pwd.h \ 1188 $(NT_INC)/pwd.h \
1189 $(NT_INC)/sys/acl.h \
1188 $(NT_INC)/sys/file.h \ 1190 $(NT_INC)/sys/file.h \
1189 $(NT_INC)/sys/time.h \ 1191 $(NT_INC)/sys/time.h \
1190 $(GNU_LIB)/allocator.h \ 1192 $(GNU_LIB)/allocator.h \
diff --git a/src/marker.c b/src/marker.c
index 69be4faec3a..a03a0b104ca 100644
--- a/src/marker.c
+++ b/src/marker.c
@@ -1,5 +1,6 @@
1/* Markers: examining, setting and deleting. 1/* Markers: examining, setting and deleting.
2 Copyright (C) 1985, 1997-1998, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1985, 1997-1998, 2001-2013 Free Software Foundation,
3 Inc.
3 4
4This file is part of GNU Emacs. 5This file is part of GNU Emacs.
5 6
@@ -82,9 +83,7 @@ clear_charpos_cache (struct buffer *b)
82 and everywhere there is a marker. So we find the one of these places 83 and everywhere there is a marker. So we find the one of these places
83 that is closest to the specified position, and scan from there. */ 84 that is closest to the specified position, and scan from there. */
84 85
85/* charpos_to_bytepos returns the byte position corresponding to CHARPOS. */ 86/* This macro is a subroutine of buf_charpos_to_bytepos.
86
87/* This macro is a subroutine of charpos_to_bytepos.
88 Note that it is desirable that BYTEPOS is not evaluated 87 Note that it is desirable that BYTEPOS is not evaluated
89 except when we really want its value. */ 88 except when we really want its value. */
90 89
@@ -128,11 +127,7 @@ clear_charpos_cache (struct buffer *b)
128 } \ 127 } \
129} 128}
130 129
131ptrdiff_t 130/* Return the byte position corresponding to CHARPOS in B. */
132charpos_to_bytepos (ptrdiff_t charpos)
133{
134 return buf_charpos_to_bytepos (current_buffer, charpos);
135}
136 131
137ptrdiff_t 132ptrdiff_t
138buf_charpos_to_bytepos (struct buffer *b, ptrdiff_t charpos) 133buf_charpos_to_bytepos (struct buffer *b, ptrdiff_t charpos)
@@ -141,8 +136,7 @@ buf_charpos_to_bytepos (struct buffer *b, ptrdiff_t charpos)
141 ptrdiff_t best_above, best_above_byte; 136 ptrdiff_t best_above, best_above_byte;
142 ptrdiff_t best_below, best_below_byte; 137 ptrdiff_t best_below, best_below_byte;
143 138
144 if (charpos < BUF_BEG (b) || charpos > BUF_Z (b)) 139 eassert (BUF_BEG (b) <= charpos && charpos <= BUF_Z (b));
145 emacs_abort ();
146 140
147 best_above = BUF_Z (b); 141 best_above = BUF_Z (b);
148 best_above_byte = BUF_Z_BYTE (b); 142 best_above_byte = BUF_Z_BYTE (b);
@@ -242,9 +236,6 @@ buf_charpos_to_bytepos (struct buffer *b, ptrdiff_t charpos)
242 236
243#undef CONSIDER 237#undef CONSIDER
244 238
245/* buf_bytepos_to_charpos returns the char position corresponding to
246 BYTEPOS. */
247
248/* This macro is a subroutine of buf_bytepos_to_charpos. 239/* This macro is a subroutine of buf_bytepos_to_charpos.
249 It is used when BYTEPOS is actually the byte position. */ 240 It is used when BYTEPOS is actually the byte position. */
250 241
@@ -288,6 +279,8 @@ buf_charpos_to_bytepos (struct buffer *b, ptrdiff_t charpos)
288 } \ 279 } \
289} 280}
290 281
282/* Return the character position corresponding to BYTEPOS in B. */
283
291ptrdiff_t 284ptrdiff_t
292buf_bytepos_to_charpos (struct buffer *b, ptrdiff_t bytepos) 285buf_bytepos_to_charpos (struct buffer *b, ptrdiff_t bytepos)
293{ 286{
@@ -295,8 +288,7 @@ buf_bytepos_to_charpos (struct buffer *b, ptrdiff_t bytepos)
295 ptrdiff_t best_above, best_above_byte; 288 ptrdiff_t best_above, best_above_byte;
296 ptrdiff_t best_below, best_below_byte; 289 ptrdiff_t best_below, best_below_byte;
297 290
298 if (bytepos < BUF_BEG_BYTE (b) || bytepos > BUF_Z_BYTE (b)) 291 eassert (BUF_BEG_BYTE (b) <= bytepos && bytepos <= BUF_Z_BYTE (b));
299 emacs_abort ();
300 292
301 best_above = BUF_Z (b); 293 best_above = BUF_Z (b);
302 best_above_byte = BUF_Z_BYTE (b); 294 best_above_byte = BUF_Z_BYTE (b);
diff --git a/src/mem-limits.h b/src/mem-limits.h
index 57a0ca6fefd..941ccf5f121 100644
--- a/src/mem-limits.h
+++ b/src/mem-limits.h
@@ -1,5 +1,6 @@
1/* Includes for memory limit warnings. 1/* Includes for memory limit warnings.
2 Copyright (C) 1990, 1993-1996, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1990, 1993-1996, 2001-2013 Free Software Foundation,
3 Inc.
3 4
4This file is part of GNU Emacs. 5This file is part of GNU Emacs.
5 6
diff --git a/src/menu.c b/src/menu.c
index 7cc110ce7e2..fdef54dd657 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -1,7 +1,7 @@
1/* Platform-independent code for terminal communications. 1/* Platform-independent code for terminal communications.
2 2
3Copyright (C) 1986, 1988, 1993-1994, 1996, 1999-2012 3Copyright (C) 1986, 1988, 1993-1994, 1996, 1999-2013 Free Software
4 Free Software Foundation, Inc. 4Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
diff --git a/src/menu.h b/src/menu.h
index 67934c42d76..f60873eadb3 100644
--- a/src/menu.h
+++ b/src/menu.h
@@ -1,5 +1,5 @@
1/* Functions to manipulate menus. 1/* Functions to manipulate menus.
2 Copyright (C) 2008-2012 Free Software Foundation, Inc. 2 Copyright (C) 2008-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/minibuf.c b/src/minibuf.c
index dcc4af37c13..25425cb97dc 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -1,6 +1,6 @@
1/* Minibuffer input and completion. 1/* Minibuffer input and completion.
2 2
3Copyright (C) 1985-1986, 1993-2012 Free Software Foundation, Inc. 3Copyright (C) 1985-1986, 1993-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -1398,12 +1398,7 @@ is used to further constrain the set of candidates. */)
1398 eltstring, zero, 1398 eltstring, zero,
1399 make_number (compare), 1399 make_number (compare),
1400 completion_ignore_case ? Qt : Qnil); 1400 completion_ignore_case ? Qt : Qnil);
1401 if (EQ (tem, Qt)) 1401 matchsize = EQ (tem, Qt) ? compare : eabs (XINT (tem)) - 1;
1402 matchsize = compare;
1403 else if (XINT (tem) < 0)
1404 matchsize = - XINT (tem) - 1;
1405 else
1406 matchsize = XINT (tem) - 1;
1407 1402
1408 if (completion_ignore_case) 1403 if (completion_ignore_case)
1409 { 1404 {
diff --git a/src/msdos.c b/src/msdos.c
index 433bf1074d8..5174bc4dfcd 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -1,6 +1,6 @@
1/* MS-DOS specific C utilities. -*- coding: raw-text -*- 1/* MS-DOS specific C utilities. -*- coding: raw-text -*-
2 2
3Copyright (C) 1993-1997, 1999-2012 Free Software Foundation, Inc. 3Copyright (C) 1993-1997, 1999-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/msdos.h b/src/msdos.h
index a73c1f2901f..57609d62218 100644
--- a/src/msdos.h
+++ b/src/msdos.h
@@ -1,5 +1,5 @@
1/* MS-DOS specific C utilities, interface. 1/* MS-DOS specific C utilities, interface.
2 Copyright (C) 1993, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1993, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/nsfns.m b/src/nsfns.m
index 428cfcb9a10..1750eb62cdf 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -1,7 +1,7 @@
1/* Functions for the NeXT/Open/GNUstep and MacOSX window system. 1/* Functions for the NeXT/Open/GNUstep and MacOSX window system.
2 2
3Copyright (C) 1989, 1992-1994, 2005-2006, 2008-2012 3Copyright (C) 1989, 1992-1994, 2005-2006, 2008-2013 Free Software
4 Free Software Foundation, Inc. 4Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
@@ -2106,7 +2106,9 @@ ns_do_applescript (Lisp_Object script, Lisp_Object *result)
2106void 2106void
2107ns_run_ascript (void) 2107ns_run_ascript (void)
2108{ 2108{
2109 as_status = ns_do_applescript (as_script, as_result); 2109 if (! NILP (as_script))
2110 as_status = ns_do_applescript (as_script, as_result);
2111 as_script = Qnil;
2110} 2112}
2111 2113
2112DEFUN ("ns-do-applescript", Fns_do_applescript, Sns_do_applescript, 1, 1, 0, 2114DEFUN ("ns-do-applescript", Fns_do_applescript, Sns_do_applescript, 1, 1, 0,
@@ -2143,11 +2145,14 @@ In case the execution fails, an error is signaled. */)
2143 data2: NSAPP_DATA2_RUNASSCRIPT]; 2145 data2: NSAPP_DATA2_RUNASSCRIPT];
2144 2146
2145 [NSApp postEvent: nxev atStart: NO]; 2147 [NSApp postEvent: nxev atStart: NO];
2146 [NSApp run]; 2148
2149 // If there are other events, the event loop may exit. Keep running
2150 // until the script has been handeled. */
2151 while (! NILP (as_script))
2152 [NSApp run];
2147 2153
2148 status = as_status; 2154 status = as_status;
2149 as_status = 0; 2155 as_status = 0;
2150 as_script = Qnil;
2151 as_result = 0; 2156 as_result = 0;
2152 unblock_input (); 2157 unblock_input ();
2153 if (status == 0) 2158 if (status == 0)
diff --git a/src/nsfont.m b/src/nsfont.m
index 2ba38b7570e..c0bea2e225c 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -1,6 +1,6 @@
1/* Font back-end driver for the NeXT/Open/GNUstep and MacOSX window system. 1/* Font back-end driver for the NeXT/Open/GNUstep and MacOSX window system.
2 See font.h 2 See font.h
3 Copyright (C) 2006-2012 Free Software Foundation, Inc. 3 Copyright (C) 2006-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/nsgui.h b/src/nsgui.h
index 60c38b221fb..53d0c8b7c8d 100644
--- a/src/nsgui.h
+++ b/src/nsgui.h
@@ -1,5 +1,5 @@
1/* Definitions and headers for communication on the NeXT/Open/GNUstep API. 1/* Definitions and headers for communication on the NeXT/Open/GNUstep API.
2 Copyright (C) 1995, 2005, 2008-2012 Free Software Foundation, Inc. 2 Copyright (C) 1995, 2005, 2008-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/nsimage.m b/src/nsimage.m
index 884c0763fd4..9d21ba8afca 100644
--- a/src/nsimage.m
+++ b/src/nsimage.m
@@ -1,6 +1,6 @@
1/* Image support for the NeXT/Open/GNUstep and MacOSX window system. 1/* Image support for the NeXT/Open/GNUstep and MacOSX window system.
2 Copyright (C) 1989, 1992-1994, 2005-2006, 2008-2012 2 Copyright (C) 1989, 1992-1994, 2005-2006, 2008-2013 Free Software
3 Free Software Foundation, Inc. 3 Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/nsmenu.m b/src/nsmenu.m
index d0ea8f5a47a..39797d414f0 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -1,5 +1,5 @@
1/* NeXT/Open/GNUstep and MacOSX Cocoa menu and toolbar module. 1/* NeXT/Open/GNUstep and MacOSX Cocoa menu and toolbar module.
2 Copyright (C) 2007-2012 Free Software Foundation, Inc. 2 Copyright (C) 2007-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/nsselect.m b/src/nsselect.m
index c0c412c6fb2..903448ce0a5 100644
--- a/src/nsselect.m
+++ b/src/nsselect.m
@@ -1,6 +1,6 @@
1/* NeXT/Open/GNUstep / MacOSX Cocoa selection processing for emacs. 1/* NeXT/Open/GNUstep / MacOSX Cocoa selection processing for emacs.
2 Copyright (C) 1993-1994, 2005-2006, 2008-2012 2 Copyright (C) 1993-1994, 2005-2006, 2008-2013 Free Software
3 Free Software Foundation, Inc. 3 Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/nsterm.h b/src/nsterm.h
index 005701ed415..e58b8493c94 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -1,5 +1,6 @@
1/* Definitions and headers for communication with NeXT/Open/GNUstep API. 1/* Definitions and headers for communication with NeXT/Open/GNUstep API.
2 Copyright (C) 1989, 1993, 2005, 2008-2012 Free Software Foundation, Inc. 2 Copyright (C) 1989, 1993, 2005, 2008-2013 Free Software Foundation,
3 Inc.
3 4
4This file is part of GNU Emacs. 5This file is part of GNU Emacs.
5 6
diff --git a/src/nsterm.m b/src/nsterm.m
index 80dc0ba6fc3..0fd062b7f17 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -1,7 +1,7 @@
1/* NeXT/Open/GNUstep / MacOSX communication module. 1/* NeXT/Open/GNUstep / MacOSX communication module.
2 2
3Copyright (C) 1989, 1993-1994, 2005-2006, 2008-2012 3Copyright (C) 1989, 1993-1994, 2005-2006, 2008-2013 Free Software
4 Free Software Foundation, Inc. 4Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
@@ -2566,7 +2566,7 @@ ns_get_glyph_string_clip_rect (struct glyph_string *s, NativeRectangle *nr)
2566 Draw a wavy line under glyph string s. The wave fills wave_height 2566 Draw a wavy line under glyph string s. The wave fills wave_height
2567 pixels from y. 2567 pixels from y.
2568 2568
2569 x wave_length = 3 2569 x wave_length = 2
2570 -- 2570 --
2571 y * * * * * 2571 y * * * * *
2572 |* * * * * * * * * 2572 |* * * * * * * * *
@@ -2576,14 +2576,14 @@ ns_get_glyph_string_clip_rect (struct glyph_string *s, NativeRectangle *nr)
2576static void 2576static void
2577ns_draw_underwave (struct glyph_string *s, CGFloat width, CGFloat x) 2577ns_draw_underwave (struct glyph_string *s, CGFloat width, CGFloat x)
2578{ 2578{
2579 int wave_height = 3, wave_length = 3; 2579 int wave_height = 3, wave_length = 2;
2580 int y, dx, dy, odd, xmax; 2580 int y, dx, dy, odd, xmax;
2581 NSPoint a, b; 2581 NSPoint a, b;
2582 NSRect waveClip; 2582 NSRect waveClip;
2583 2583
2584 dx = wave_length; 2584 dx = wave_length;
2585 dy = wave_height - 1; 2585 dy = wave_height - 1;
2586 y = s->ybase + 1; 2586 y = s->ybase - wave_height + 3;
2587 xmax = x + width; 2587 xmax = x + width;
2588 2588
2589 /* Find and set clipping rectangle */ 2589 /* Find and set clipping rectangle */
@@ -2592,10 +2592,10 @@ ns_draw_underwave (struct glyph_string *s, CGFloat width, CGFloat x)
2592 NSRectClip (waveClip); 2592 NSRectClip (waveClip);
2593 2593
2594 /* Draw the waves */ 2594 /* Draw the waves */
2595 a.x = x - ((int)(x) % dx); 2595 a.x = x - ((int)(x) % dx) + 0.5;
2596 b.x = a.x + dx; 2596 b.x = a.x + dx;
2597 odd = (int)(a.x/dx) % 2; 2597 odd = (int)(a.x/dx) % 2;
2598 a.y = b.y = y; 2598 a.y = b.y = y + 0.5;
2599 2599
2600 if (odd) 2600 if (odd)
2601 a.y += dy; 2601 a.y += dy;
@@ -2606,7 +2606,7 @@ ns_draw_underwave (struct glyph_string *s, CGFloat width, CGFloat x)
2606 { 2606 {
2607 [NSBezierPath strokeLineFromPoint:a toPoint:b]; 2607 [NSBezierPath strokeLineFromPoint:a toPoint:b];
2608 a.x = b.x, a.y = b.y; 2608 a.x = b.x, a.y = b.y;
2609 b.x += dx, b.y = y + odd*dy; 2609 b.x += dx, b.y = y + 0.5 + odd*dy;
2610 odd = !odd; 2610 odd = !odd;
2611 } 2611 }
2612 2612
@@ -2646,6 +2646,7 @@ ns_draw_text_decoration (struct glyph_string *s, struct face *face,
2646 2646
2647 /* If the prev was underlined, match its appearance. */ 2647 /* If the prev was underlined, match its appearance. */
2648 if (s->prev && s->prev->face->underline_p 2648 if (s->prev && s->prev->face->underline_p
2649 && s->prev->face->underline_type == FACE_UNDER_LINE
2649 && s->prev->underline_thickness > 0) 2650 && s->prev->underline_thickness > 0)
2650 { 2651 {
2651 thickness = s->prev->underline_thickness; 2652 thickness = s->prev->underline_thickness;
diff --git a/src/print.c b/src/print.c
index 71efb61e732..2ffe7def396 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1,7 +1,7 @@
1/* Lisp object printing and output streams. 1/* Lisp object printing and output streams.
2 2
3Copyright (C) 1985-1986, 1988, 1993-1995, 1997-2012 3Copyright (C) 1985-1986, 1988, 1993-1995, 1997-2013 Free Software
4 Free Software Foundation, Inc. 4Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
@@ -2070,14 +2070,44 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
2070 break; 2070 break;
2071 2071
2072 case Lisp_Misc_Save_Value: 2072 case Lisp_Misc_Save_Value:
2073 strout ("#<save_value ", -1, -1, printcharfun);
2074 { 2073 {
2075 int len = sprintf (buf, "ptr=%p int=%"pD"d", 2074 int i;
2076 XSAVE_VALUE (obj)->pointer, 2075 struct Lisp_Save_Value *v = XSAVE_VALUE (obj);
2077 XSAVE_VALUE (obj)->integer); 2076
2078 strout (buf, len, len, printcharfun); 2077 strout ("#<save-value ", -1, -1, printcharfun);
2078 if (v->dogc)
2079 {
2080 int lim = min (v->integer, 8);
2081
2082 /* Try to print up to 8 objects we have saved. Although
2083 valid_lisp_object_p is slow, this shouldn't be a real
2084 bottleneck because such a saved values are quite rare. */
2085
2086 i = sprintf (buf, "with %"pD"d objects", v->integer);
2087 strout (buf, i, i, printcharfun);
2088
2089 for (i = 0; i < lim; i++)
2090 {
2091 Lisp_Object maybe = ((Lisp_Object *) v->pointer)[i];
2092
2093 if (valid_lisp_object_p (maybe) > 0)
2094 {
2095 PRINTCHAR (' ');
2096 print_object (maybe, printcharfun, escapeflag);
2097 }
2098 else
2099 strout (" <invalid>", -1, -1, printcharfun);
2100 }
2101 if (i == lim && i < v->integer)
2102 strout (" ...", 4, 4, printcharfun);
2103 }
2104 else
2105 {
2106 i = sprintf (buf, "ptr=%p int=%"pD"d", v->pointer, v->integer);
2107 strout (buf, i, i, printcharfun);
2108 }
2109 PRINTCHAR ('>');
2079 } 2110 }
2080 PRINTCHAR ('>');
2081 break; 2111 break;
2082 2112
2083 default: 2113 default:
diff --git a/src/process.c b/src/process.c
index 788c9176349..d56819da67a 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1,7 +1,7 @@
1/* Asynchronous subprocess control for GNU Emacs. 1/* Asynchronous subprocess control for GNU Emacs.
2 2
3Copyright (C) 1985-1988, 1993-1996, 1998-1999, 2001-2012 3Copyright (C) 1985-1988, 1993-1996, 1998-1999, 2001-2013 Free Software
4 Free Software Foundation, Inc. 4Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
@@ -4941,11 +4941,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4941 Therefore, if we get an error reading and errno = 4941 Therefore, if we get an error reading and errno =
4942 EIO, just continue, because the child process has 4942 EIO, just continue, because the child process has
4943 exited and should clean itself up soon (e.g. when we 4943 exited and should clean itself up soon (e.g. when we
4944 get a SIGCHLD). 4944 get a SIGCHLD). */
4945
4946 However, it has been known to happen that the SIGCHLD
4947 got lost. So raise the signal again just in case.
4948 It can't hurt. */
4949 else if (nread == -1 && errno == EIO) 4945 else if (nread == -1 && errno == EIO)
4950 { 4946 {
4951 struct Lisp_Process *p = XPROCESS (proc); 4947 struct Lisp_Process *p = XPROCESS (proc);
@@ -4962,8 +4958,6 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4962 p->tick = ++process_tick; 4958 p->tick = ++process_tick;
4963 pset_status (p, Qfailed); 4959 pset_status (p, Qfailed);
4964 } 4960 }
4965 else
4966 handle_child_signal (SIGCHLD);
4967 } 4961 }
4968#endif /* HAVE_PTYS */ 4962#endif /* HAVE_PTYS */
4969 /* If we can detect process termination, don't consider the 4963 /* If we can detect process termination, don't consider the
@@ -5724,19 +5718,19 @@ it is sent in several bunches. This may happen even for shorter regions.
5724Output from processes can arrive in between bunches. */) 5718Output from processes can arrive in between bunches. */)
5725 (Lisp_Object process, Lisp_Object start, Lisp_Object end) 5719 (Lisp_Object process, Lisp_Object start, Lisp_Object end)
5726{ 5720{
5727 Lisp_Object proc; 5721 Lisp_Object proc = get_process (process);
5728 ptrdiff_t start1, end1; 5722 ptrdiff_t start_byte, end_byte;
5729 5723
5730 proc = get_process (process);
5731 validate_region (&start, &end); 5724 validate_region (&start, &end);
5732 5725
5726 start_byte = CHAR_TO_BYTE (XINT (start));
5727 end_byte = CHAR_TO_BYTE (XINT (end));
5728
5733 if (XINT (start) < GPT && XINT (end) > GPT) 5729 if (XINT (start) < GPT && XINT (end) > GPT)
5734 move_gap (XINT (start)); 5730 move_gap_both (XINT (start), start_byte);
5735 5731
5736 start1 = CHAR_TO_BYTE (XINT (start)); 5732 send_process (proc, (char *) BYTE_POS_ADDR (start_byte),
5737 end1 = CHAR_TO_BYTE (XINT (end)); 5733 end_byte - start_byte, Fcurrent_buffer ());
5738 send_process (proc, (char *) BYTE_POS_ADDR (start1), end1 - start1,
5739 Fcurrent_buffer ());
5740 5734
5741 return Qnil; 5735 return Qnil;
5742} 5736}
diff --git a/src/process.h b/src/process.h
index 01f7fd50ffa..0dc35f42993 100644
--- a/src/process.h
+++ b/src/process.h
@@ -1,5 +1,5 @@
1/* Definitions for asynchronous process control in GNU Emacs. 1/* Definitions for asynchronous process control in GNU Emacs.
2 Copyright (C) 1985, 1994, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1985, 1994, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/profiler.c b/src/profiler.c
index 3d8f7243d2f..f6503cf182e 100644
--- a/src/profiler.c
+++ b/src/profiler.c
@@ -1,6 +1,6 @@
1/* Profiler implementation. 1/* Profiler implementation.
2 2
3Copyright (C) 2012 Free Software Foundation, Inc. 3Copyright (C) 2012-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/puresize.h b/src/puresize.h
index 26395a5729d..2f717571c7c 100644
--- a/src/puresize.h
+++ b/src/puresize.h
@@ -1,5 +1,5 @@
1/* How much read-only Lisp storage a dumped Emacs needs. 1/* How much read-only Lisp storage a dumped Emacs needs.
2 Copyright (C) 1993, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1993, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/ralloc.c b/src/ralloc.c
index e5bf76b0e6d..ec1ac40414c 100644
--- a/src/ralloc.c
+++ b/src/ralloc.c
@@ -1,5 +1,5 @@
1/* Block-relocating memory allocator. 1/* Block-relocating memory allocator.
2 Copyright (C) 1993, 1995, 2000-2012 Free Software Foundation, Inc. 2 Copyright (C) 1993, 1995, 2000-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/regex.c b/src/regex.c
index 878b629fbbf..b5522f19079 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -2,7 +2,7 @@
2 0.12. (Implements POSIX draft P1003.2/D11.2, except for some of the 2 0.12. (Implements POSIX draft P1003.2/D11.2, except for some of the
3 internationalization features.) 3 internationalization features.)
4 4
5 Copyright (C) 1993-2012 Free Software Foundation, Inc. 5 Copyright (C) 1993-2013 Free Software Foundation, Inc.
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
@@ -15,9 +15,7 @@
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 USA. */
21 19
22/* TODO: 20/* TODO:
23 - structure the opcode space into opcode+flag. 21 - structure the opcode space into opcode+flag.
diff --git a/src/regex.h b/src/regex.h
index 91886a80549..36fb4321027 100644
--- a/src/regex.h
+++ b/src/regex.h
@@ -1,8 +1,8 @@
1/* Definitions for data structures and routines for the regular 1/* Definitions for data structures and routines for the regular
2 expression library, version 0.12. 2 expression library, version 0.12.
3 3
4 Copyright (C) 1985, 1989-1993, 1995, 2000-2012 4 Copyright (C) 1985, 1989-1993, 1995, 2000-2013 Free Software
5 Free Software Foundation, Inc. 5 Foundation, Inc.
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
@@ -15,9 +15,7 @@
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 USA. */
21 19
22#ifndef _REGEX_H 20#ifndef _REGEX_H
23#define _REGEX_H 1 21#define _REGEX_H 1
diff --git a/src/region-cache.c b/src/region-cache.c
index 832f4bfd214..14e6982cd9a 100644
--- a/src/region-cache.c
+++ b/src/region-cache.c
@@ -1,7 +1,7 @@
1/* Caching facts about regions of the buffer, for optimization. 1/* Caching facts about regions of the buffer, for optimization.
2 2
3Copyright (C) 1985-1989, 1993, 1995, 2001-2012 3Copyright (C) 1985-1989, 1993, 1995, 2001-2013 Free Software Foundation,
4 Free Software Foundation, Inc. 4Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
diff --git a/src/region-cache.h b/src/region-cache.h
index 7aebdbec262..697ae1c791f 100644
--- a/src/region-cache.h
+++ b/src/region-cache.h
@@ -1,7 +1,7 @@
1/* Header file: Caching facts about regions of the buffer, for optimization. 1/* Header file: Caching facts about regions of the buffer, for optimization.
2 2
3Copyright (C) 1985-1986, 1993, 1995, 2001-2012 3Copyright (C) 1985-1986, 1993, 1995, 2001-2013 Free Software Foundation,
4 Free Software Foundation, Inc. 4Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
diff --git a/src/scroll.c b/src/scroll.c
index 71ce43b2e48..9e11feb64d4 100644
--- a/src/scroll.c
+++ b/src/scroll.c
@@ -1,7 +1,7 @@
1/* Calculate what line insertion or deletion to do, and do it 1/* Calculate what line insertion or deletion to do, and do it
2 2
3Copyright (C) 1985-1986, 1990, 1993-1994, 2001-2012 3Copyright (C) 1985-1986, 1990, 1993-1994, 2001-2013 Free Software
4 Free Software Foundation, Inc. 4Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
diff --git a/src/search.c b/src/search.c
index ae038a45f9c..a7fabf19399 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1,7 +1,7 @@
1/* String search routines for GNU Emacs. 1/* String search routines for GNU Emacs.
2 2
3Copyright (C) 1985-1987, 1993-1994, 1997-1999, 2001-2012 3Copyright (C) 1985-1987, 1993-1994, 1997-1999, 2001-2013 Free Software
4 Free Software Foundation, Inc. 4Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
@@ -1313,8 +1313,11 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
1313 non-nil, we can use boyer-moore search only if TRT can be 1313 non-nil, we can use boyer-moore search only if TRT can be
1314 represented by the byte array of 256 elements. For that, 1314 represented by the byte array of 256 elements. For that,
1315 all non-ASCII case-equivalents of all case-sensitive 1315 all non-ASCII case-equivalents of all case-sensitive
1316 characters in STRING must belong to the same charset and 1316 characters in STRING must belong to the same character
1317 row. */ 1317 group (two characters belong to the same group iff their
1318 multibyte forms are the same except for the last byte;
1319 i.e. every 64 characters form a group; U+0000..U+003F,
1320 U+0040..U+007F, U+0080..U+00BF, ...). */
1318 1321
1319 while (--len >= 0) 1322 while (--len >= 0)
1320 { 1323 {
@@ -2599,7 +2602,7 @@ since only regular expressions have distinguished subexpressions. */)
2599 ptrdiff_t begbyte = CHAR_TO_BYTE (search_regs.start[idx]); 2602 ptrdiff_t begbyte = CHAR_TO_BYTE (search_regs.start[idx]);
2600 add_len = CHAR_TO_BYTE (search_regs.end[idx]) - begbyte; 2603 add_len = CHAR_TO_BYTE (search_regs.end[idx]) - begbyte;
2601 if (search_regs.start[idx] < GPT && GPT < search_regs.end[idx]) 2604 if (search_regs.start[idx] < GPT && GPT < search_regs.end[idx])
2602 move_gap (search_regs.start[idx]); 2605 move_gap_both (search_regs.start[idx], begbyte);
2603 add_stuff = BYTE_POS_ADDR (begbyte); 2606 add_stuff = BYTE_POS_ADDR (begbyte);
2604 } 2607 }
2605 2608
diff --git a/src/sheap.c b/src/sheap.c
index f6022ea3ce7..972c04c9552 100644
--- a/src/sheap.c
+++ b/src/sheap.c
@@ -1,7 +1,7 @@
1/* simulate `sbrk' with an array in .bss, for `unexec' support for Cygwin; 1/* simulate `sbrk' with an array in .bss, for `unexec' support for Cygwin;
2 complete rewrite of xemacs Cygwin `unexec' code 2 complete rewrite of xemacs Cygwin `unexec' code
3 3
4 Copyright (C) 2004-2012 Free Software Foundation, Inc. 4 Copyright (C) 2004-2013 Free Software Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
diff --git a/src/sound.c b/src/sound.c
index 0ee85312fd3..802f1ce740d 100644
--- a/src/sound.c
+++ b/src/sound.c
@@ -1,6 +1,6 @@
1/* sound.c -- sound support. 1/* sound.c -- sound support.
2 2
3Copyright (C) 1998-1999, 2001-2012 Free Software Foundation, Inc. 3Copyright (C) 1998-1999, 2001-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/syntax.c b/src/syntax.c
index d3cafcc472e..72d904914ec 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -1,6 +1,6 @@
1/* GNU Emacs routines to deal with syntax tables; also word and list parsing. 1/* GNU Emacs routines to deal with syntax tables; also word and list parsing.
2 Copyright (C) 1985, 1987, 1993-1995, 1997-1999, 2001-2012 2 Copyright (C) 1985, 1987, 1993-1995, 1997-1999, 2001-2013 Free
3 Free Software Foundation, Inc. 3 Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/syntax.h b/src/syntax.h
index 6edb1585795..c9af240df0c 100644
--- a/src/syntax.h
+++ b/src/syntax.h
@@ -1,7 +1,7 @@
1/* Declarations having to do with GNU Emacs syntax tables. 1/* Declarations having to do with GNU Emacs syntax tables.
2 2
3Copyright (C) 1985, 1993-1994, 1997-1998, 2001-2012 3Copyright (C) 1985, 1993-1994, 1997-1998, 2001-2013 Free Software
4 Free Software Foundation, Inc. 4Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
diff --git a/src/sysdep.c b/src/sysdep.c
index 5291c5d59aa..049eb85afe5 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -1,6 +1,6 @@
1/* Interfaces to system-dependent kernel and library entries. 1/* Interfaces to system-dependent kernel and library entries.
2 Copyright (C) 1985-1988, 1993-1995, 1999-2012 2 Copyright (C) 1985-1988, 1993-1995, 1999-2013 Free Software
3 Free Software Foundation, Inc. 3 Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -2110,7 +2110,7 @@ emacs_backtrace (int backtrace_limit)
2110void 2110void
2111emacs_abort (void) 2111emacs_abort (void)
2112{ 2112{
2113 terminate_due_to_signal (SIGABRT, 10); 2113 terminate_due_to_signal (SIGABRT, 40);
2114} 2114}
2115#endif 2115#endif
2116 2116
diff --git a/src/sysselect.h b/src/sysselect.h
index 24bdf469ced..0a4f7e3ad96 100644
--- a/src/sysselect.h
+++ b/src/sysselect.h
@@ -1,5 +1,5 @@
1/* sysselect.h - System-dependent definitions for the select function. 1/* sysselect.h - System-dependent definitions for the select function.
2 Copyright (C) 1995, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1995, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/syssignal.h b/src/syssignal.h
index 8f9b5f0546a..d7399c6cb8c 100644
--- a/src/syssignal.h
+++ b/src/syssignal.h
@@ -1,6 +1,6 @@
1/* syssignal.h - System-dependent definitions for signals. 1/* syssignal.h - System-dependent definitions for signals.
2 2
3Copyright (C) 1993, 1999, 2001-2012 Free Software Foundation, Inc. 3Copyright (C) 1993, 1999, 2001-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/systime.h b/src/systime.h
index 9ce7ce646fb..fa5e7270cb5 100644
--- a/src/systime.h
+++ b/src/systime.h
@@ -1,5 +1,5 @@
1/* systime.h - System-dependent definitions for time manipulations. 1/* systime.h - System-dependent definitions for time manipulations.
2 Copyright (C) 1993-1994, 2002-2012 Free Software Foundation, Inc. 2 Copyright (C) 1993-1994, 2002-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/systty.h b/src/systty.h
index 80bcaedf740..6d38c980725 100644
--- a/src/systty.h
+++ b/src/systty.h
@@ -1,5 +1,5 @@
1/* systty.h - System-dependent definitions for terminals. 1/* systty.h - System-dependent definitions for terminals.
2 Copyright (C) 1993-1994, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1993-1994, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/syswait.h b/src/syswait.h
index 360407d558e..03e5cb5fe2e 100644
--- a/src/syswait.h
+++ b/src/syswait.h
@@ -1,5 +1,5 @@
1/* Define wait system call interface for Emacs. 1/* Define wait system call interface for Emacs.
2 Copyright (C) 1993-1995, 2000-2012 Free Software Foundation, Inc. 2 Copyright (C) 1993-1995, 2000-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/term.c b/src/term.c
index 241875de52f..d76562bb4db 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1,6 +1,6 @@
1/* Terminal control module for terminals described by TERMCAP 1/* Terminal control module for terminals described by TERMCAP
2 Copyright (C) 1985-1987, 1993-1995, 1998, 2000-2012 2 Copyright (C) 1985-1987, 1993-1995, 1998, 2000-2013 Free Software
3 Free Software Foundation, Inc. 3 Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -953,8 +953,8 @@ tty_ins_del_lines (struct frame *f, int vpos, int n)
953 const char *single = n > 0 ? tty->TS_ins_line : tty->TS_del_line; 953 const char *single = n > 0 ? tty->TS_ins_line : tty->TS_del_line;
954 const char *scroll = n > 0 ? tty->TS_rev_scroll : tty->TS_fwd_scroll; 954 const char *scroll = n > 0 ? tty->TS_rev_scroll : tty->TS_fwd_scroll;
955 955
956 register int i = n > 0 ? n : -n; 956 int i = eabs (n);
957 register char *buf; 957 char *buf;
958 958
959 /* If the lines below the insertion are being pushed 959 /* If the lines below the insertion are being pushed
960 into the end of the window, this is the same as clearing; 960 into the end of the window, this is the same as clearing;
diff --git a/src/termcap.c b/src/termcap.c
index e494cd113d9..82c2b1fda07 100644
--- a/src/termcap.c
+++ b/src/termcap.c
@@ -1,6 +1,6 @@
1/* Work-alike for termcap, plus extra features. 1/* Work-alike for termcap, plus extra features.
2 Copyright (C) 1985, 1986, 1993, 1994, 1995, 2000, 2001, 2002, 2003, 2 Copyright (C) 1985-1986, 1993-1995, 2000-2008, 2011, 2013 Free
3 2004, 2005, 2006, 2007, 2008, 2011 Free Software Foundation, Inc. 3 Software Foundation, Inc.
4 4
5This program is free software; you can redistribute it and/or modify 5This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by 6it under the terms of the GNU General Public License as published by
@@ -13,9 +13,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details. 13GNU General Public License for more details.
14 14
15You should have received a copy of the GNU General Public License 15You should have received a copy of the GNU General Public License
16along with this program; see the file COPYING. If not, write to 16along with this program. If not, see <http://www.gnu.org/licenses/>. */
17the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18Boston, MA 02110-1301, USA. */
19 17
20/* Emacs config.h may rename various library functions such as malloc. */ 18/* Emacs config.h may rename various library functions such as malloc. */
21#include <config.h> 19#include <config.h>
diff --git a/src/termchar.h b/src/termchar.h
index 8bffd3e546b..1c8e8646d4e 100644
--- a/src/termchar.h
+++ b/src/termchar.h
@@ -1,5 +1,5 @@
1/* Flags and parameters describing terminal's characteristics. 1/* Flags and parameters describing terminal's characteristics.
2 Copyright (C) 1985-1986, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1985-1986, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/termhooks.h b/src/termhooks.h
index 1a261bacdc5..7385298d3d4 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -1,6 +1,7 @@
1/* Parameters and display hooks for terminal devices. 1/* Parameters and display hooks for terminal devices.
2 2
3Copyright (C) 1985-1986, 1993-1994, 2001-2012 Free Software Foundation, Inc. 3Copyright (C) 1985-1986, 1993-1994, 2001-2013 Free Software Foundation,
4Inc.
4 5
5This file is part of GNU Emacs. 6This file is part of GNU Emacs.
6 7
diff --git a/src/terminal.c b/src/terminal.c
index 854ca61f19c..5e1f1ff77f7 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -1,5 +1,5 @@
1/* Functions related to terminal devices. 1/* Functions related to terminal devices.
2 Copyright (C) 2005-2012 Free Software Foundation, Inc. 2 Copyright (C) 2005-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
@@ -398,8 +398,6 @@ possible return values. */)
398 return Qw32; 398 return Qw32;
399 case output_msdos_raw: 399 case output_msdos_raw:
400 return Qpc; 400 return Qpc;
401 case output_mac:
402 return Qmac;
403 case output_ns: 401 case output_ns:
404 return Qns; 402 return Qns;
405 default: 403 default:
diff --git a/src/terminfo.c b/src/terminfo.c
index 124c452a4a9..0e5e1985461 100644
--- a/src/terminfo.c
+++ b/src/terminfo.c
@@ -1,5 +1,5 @@
1/* Interface from Emacs to terminfo. 1/* Interface from Emacs to terminfo.
2 Copyright (C) 1985-1986, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1985-1986, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/termopts.h b/src/termopts.h
index 05fa0a52eee..8b702b9bf6d 100644
--- a/src/termopts.h
+++ b/src/termopts.h
@@ -1,5 +1,6 @@
1/* Flags and parameters describing user options for handling the terminal. 1/* Flags and parameters describing user options for handling the terminal.
2 Copyright (C) 1985-1986, 1990, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1985-1986, 1990, 2001-2013 Free Software Foundation,
3 Inc.
3 4
4This file is part of GNU Emacs. 5This file is part of GNU Emacs.
5 6
diff --git a/src/textprop.c b/src/textprop.c
index 1ce44ad60ac..c1f6e59bf2e 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -1,5 +1,6 @@
1/* Interface code for dealing with text properties. 1/* Interface code for dealing with text properties.
2 Copyright (C) 1993-1995, 1997, 1999-2012 Free Software Foundation, Inc. 2 Copyright (C) 1993-1995, 1997, 1999-2013 Free Software Foundation,
3 Inc.
3 4
4This file is part of GNU Emacs. 5This file is part of GNU Emacs.
5 6
@@ -1323,14 +1324,13 @@ set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties,
1323} 1324}
1324 1325
1325/* Replace properties of text from START to END with new list of 1326/* Replace properties of text from START to END with new list of
1326 properties PROPERTIES. BUFFER is the buffer containing 1327 properties PROPERTIES. OBJECT is the buffer or string containing
1327 the text. This does not obey any hooks. 1328 the text. This does not obey any hooks.
1328 You can provide the interval that START is located in as I, 1329 You should provide the interval that START is located in as I.
1329 or pass NULL for I and this function will find it.
1330 START and END can be in any order. */ 1330 START and END can be in any order. */
1331 1331
1332void 1332void
1333set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object buffer, INTERVAL i) 1333set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object, INTERVAL i)
1334{ 1334{
1335 register INTERVAL prev_changed = NULL; 1335 register INTERVAL prev_changed = NULL;
1336 register ptrdiff_t s, len; 1336 register ptrdiff_t s, len;
@@ -1349,8 +1349,7 @@ set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object propertie
1349 else 1349 else
1350 return; 1350 return;
1351 1351
1352 if (i == NULL) 1352 eassert (i);
1353 i = find_interval (buffer_intervals (XBUFFER (buffer)), s);
1354 1353
1355 if (i->position != s) 1354 if (i->position != s)
1356 { 1355 {
@@ -1361,11 +1360,11 @@ set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object propertie
1361 { 1360 {
1362 copy_properties (unchanged, i); 1361 copy_properties (unchanged, i);
1363 i = split_interval_left (i, len); 1362 i = split_interval_left (i, len);
1364 set_properties (properties, i, buffer); 1363 set_properties (properties, i, object);
1365 return; 1364 return;
1366 } 1365 }
1367 1366
1368 set_properties (properties, i, buffer); 1367 set_properties (properties, i, object);
1369 1368
1370 if (LENGTH (i) == len) 1369 if (LENGTH (i) == len)
1371 return; 1370 return;
@@ -1388,7 +1387,7 @@ set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object propertie
1388 /* We have to call set_properties even if we are going to 1387 /* We have to call set_properties even if we are going to
1389 merge the intervals, so as to make the undo records 1388 merge the intervals, so as to make the undo records
1390 and cause redisplay to happen. */ 1389 and cause redisplay to happen. */
1391 set_properties (properties, i, buffer); 1390 set_properties (properties, i, object);
1392 if (prev_changed) 1391 if (prev_changed)
1393 merge_interval_left (i); 1392 merge_interval_left (i);
1394 return; 1393 return;
@@ -1399,7 +1398,7 @@ set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object propertie
1399 /* We have to call set_properties even if we are going to 1398 /* We have to call set_properties even if we are going to
1400 merge the intervals, so as to make the undo records 1399 merge the intervals, so as to make the undo records
1401 and cause redisplay to happen. */ 1400 and cause redisplay to happen. */
1402 set_properties (properties, i, buffer); 1401 set_properties (properties, i, object);
1403 if (!prev_changed) 1402 if (!prev_changed)
1404 prev_changed = i; 1403 prev_changed = i;
1405 else 1404 else
diff --git a/src/tparam.c b/src/tparam.c
index 164f61d471b..c3ecfb9e3a3 100644
--- a/src/tparam.c
+++ b/src/tparam.c
@@ -1,6 +1,6 @@
1/* Merge parameters into a termcap entry string. 1/* Merge parameters into a termcap entry string.
2 Copyright (C) 1985, 1987, 1993, 1995, 2000, 2001, 2002, 2003, 2004, 2 Copyright (C) 1985, 1987, 1993, 1995, 2000-2008, 2013 Free Software
3 2005, 2006, 2007, 2008 Free Software Foundation, Inc. 3 Foundation, Inc.
4 4
5This program is free software; you can redistribute it and/or modify 5This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by 6it under the terms of the GNU General Public License as published by
@@ -13,9 +13,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details. 13GNU General Public License for more details.
14 14
15You should have received a copy of the GNU General Public License 15You should have received a copy of the GNU General Public License
16along with this program; see the file COPYING. If not, write to 16along with this program. If not, see <http://www.gnu.org/licenses/>. */
17the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18Boston, MA 02110-1301, USA. */
19 17
20/* Emacs config.h may rename various library functions such as malloc. */ 18/* Emacs config.h may rename various library functions such as malloc. */
21#include <config.h> 19#include <config.h>
diff --git a/src/tparam.h b/src/tparam.h
index e845f3e8202..94f226d7d6a 100644
--- a/src/tparam.h
+++ b/src/tparam.h
@@ -1,6 +1,6 @@
1/* Interface definitions for termcap entries. 1/* Interface definitions for termcap entries.
2 2
3Copyright (C) 2011-2012 Free Software Foundation, Inc. 3Copyright (C) 2011-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/undo.c b/src/undo.c
index e878ef4dcf9..2626fd4ccfe 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -1,5 +1,6 @@
1/* undo handling for GNU Emacs. 1/* undo handling for GNU Emacs.
2 Copyright (C) 1990, 1993-1994, 2000-2012 Free Software Foundation, Inc. 2 Copyright (C) 1990, 1993-1994, 2000-2013 Free Software Foundation,
3 Inc.
3 4
4This file is part of GNU Emacs. 5This file is part of GNU Emacs.
5 6
diff --git a/src/unexaix.c b/src/unexaix.c
index c01a22a79f6..92ebd2e3ceb 100644
--- a/src/unexaix.c
+++ b/src/unexaix.c
@@ -1,5 +1,6 @@
1/* Dump an executable image. 1/* Dump an executable image.
2 Copyright (C) 1985-1988, 1999, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1985-1988, 1999, 2001-2013 Free Software Foundation,
3 Inc.
3 4
4This file is part of GNU Emacs. 5This file is part of GNU Emacs.
5 6
diff --git a/src/unexcoff.c b/src/unexcoff.c
index 6e29951a962..466a5c0e491 100644
--- a/src/unexcoff.c
+++ b/src/unexcoff.c
@@ -1,4 +1,5 @@
1/* Copyright (C) 1985-1988, 1992-1994, 2001-2012 Free Software Foundation, Inc. 1/* Copyright (C) 1985-1988, 1992-1994, 2001-2013 Free Software
2 * Foundation, Inc.
2 3
3This file is part of GNU Emacs. 4This file is part of GNU Emacs.
4 5
diff --git a/src/unexcw.c b/src/unexcw.c
index 7d1a72e0009..af93e158e14 100644
--- a/src/unexcw.c
+++ b/src/unexcw.c
@@ -1,7 +1,7 @@
1/* unexec() support for Cygwin; 1/* unexec() support for Cygwin;
2 complete rewrite of xemacs Cygwin unexec() code 2 complete rewrite of xemacs Cygwin unexec() code
3 3
4 Copyright (C) 2004-2012 Free Software Foundation, Inc. 4 Copyright (C) 2004-2013 Free Software Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
diff --git a/src/unexelf.c b/src/unexelf.c
index b9f8e05e959..d3659404f9c 100644
--- a/src/unexelf.c
+++ b/src/unexelf.c
@@ -1,5 +1,5 @@
1/* Copyright (C) 1985-1988, 1990, 1992, 1999-2012 1/* Copyright (C) 1985-1988, 1990, 1992, 1999-2013 Free Software
2 Free Software Foundation, Inc. 2 Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/unexmacosx.c b/src/unexmacosx.c
index d304e85d490..8d4e636fa5c 100644
--- a/src/unexmacosx.c
+++ b/src/unexmacosx.c
@@ -1,5 +1,5 @@
1/* Dump Emacs in Mach-O format for use on Mac OS X. 1/* Dump Emacs in Mach-O format for use on Mac OS X.
2 Copyright (C) 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/unexw32.c b/src/unexw32.c
index ee1deb5f92e..66071295727 100644
--- a/src/unexw32.c
+++ b/src/unexw32.c
@@ -1,5 +1,5 @@
1/* unexec for GNU Emacs on Windows NT. 1/* unexec for GNU Emacs on Windows NT.
2 Copyright (C) 1994, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1994, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/vm-limit.c b/src/vm-limit.c
index befc01d400f..9dbb1b884b7 100644
--- a/src/vm-limit.c
+++ b/src/vm-limit.c
@@ -1,5 +1,5 @@
1/* Functions for memory limit warnings. 1/* Functions for memory limit warnings.
2 Copyright (C) 1990, 1992, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1990, 1992, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/w16select.c b/src/w16select.c
index b8aaa3619ba..c92276b1d29 100644
--- a/src/w16select.c
+++ b/src/w16select.c
@@ -1,6 +1,6 @@
1/* 16-bit Windows Selection processing for emacs on MS-Windows 1/* 16-bit Windows Selection processing for emacs on MS-Windows
2 2
3Copyright (C) 1996-1997, 2001-2012 Free Software Foundation, Inc. 3Copyright (C) 1996-1997, 2001-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/w32.c b/src/w32.c
index 50c81f88c72..55581a17de5 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -1,5 +1,5 @@
1/* Utility and Unix shadow routines for GNU Emacs on the Microsoft Windows API. 1/* Utility and Unix shadow routines for GNU Emacs on the Microsoft Windows API.
2 Copyright (C) 1994-1995, 2000-2012 Free Software Foundation, Inc. 2 Copyright (C) 1994-1995, 2000-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
@@ -117,6 +117,15 @@ typedef struct _PROCESS_MEMORY_COUNTERS_EX {
117 117
118#include <winioctl.h> 118#include <winioctl.h>
119#include <aclapi.h> 119#include <aclapi.h>
120#include <sddl.h>
121
122#include <sys/acl.h>
123
124/* This is not in MinGW's sddl.h (but they are in MSVC headers), so we
125 define them by hand if not already defined. */
126#ifndef SDDL_REVISION_1
127#define SDDL_REVISION_1 1
128#endif /* SDDL_REVISION_1 */
120 129
121#ifdef _MSC_VER 130#ifdef _MSC_VER
122/* MSVC doesn't provide the definition of REPARSE_DATA_BUFFER and the 131/* MSVC doesn't provide the definition of REPARSE_DATA_BUFFER and the
@@ -257,6 +266,11 @@ static BOOL g_b_init_copy_sid;
257static BOOL g_b_init_get_native_system_info; 266static BOOL g_b_init_get_native_system_info;
258static BOOL g_b_init_get_system_times; 267static BOOL g_b_init_get_system_times;
259static BOOL g_b_init_create_symbolic_link; 268static BOOL g_b_init_create_symbolic_link;
269static BOOL g_b_init_get_security_descriptor_dacl;
270static BOOL g_b_init_convert_sd_to_sddl;
271static BOOL g_b_init_convert_sddl_to_sd;
272static BOOL g_b_init_is_valid_security_descriptor;
273static BOOL g_b_init_set_file_security;
260 274
261/* 275/*
262 BEGIN: Wrapper functions around OpenProcessToken 276 BEGIN: Wrapper functions around OpenProcessToken
@@ -286,9 +300,11 @@ GetProcessTimes_Proc get_process_times_fn = NULL;
286#ifdef _UNICODE 300#ifdef _UNICODE
287const char * const LookupAccountSid_Name = "LookupAccountSidW"; 301const char * const LookupAccountSid_Name = "LookupAccountSidW";
288const char * const GetFileSecurity_Name = "GetFileSecurityW"; 302const char * const GetFileSecurity_Name = "GetFileSecurityW";
303const char * const SetFileSecurity_Name = "SetFileSecurityW";
289#else 304#else
290const char * const LookupAccountSid_Name = "LookupAccountSidA"; 305const char * const LookupAccountSid_Name = "LookupAccountSidA";
291const char * const GetFileSecurity_Name = "GetFileSecurityA"; 306const char * const GetFileSecurity_Name = "GetFileSecurityA";
307const char * const SetFileSecurity_Name = "SetFileSecurityA";
292#endif 308#endif
293typedef BOOL (WINAPI * LookupAccountSid_Proc) ( 309typedef BOOL (WINAPI * LookupAccountSid_Proc) (
294 LPCTSTR lpSystemName, 310 LPCTSTR lpSystemName,
@@ -318,6 +334,10 @@ typedef BOOL (WINAPI * GetFileSecurity_Proc) (
318 PSECURITY_DESCRIPTOR pSecurityDescriptor, 334 PSECURITY_DESCRIPTOR pSecurityDescriptor,
319 DWORD nLength, 335 DWORD nLength,
320 LPDWORD lpnLengthNeeded); 336 LPDWORD lpnLengthNeeded);
337typedef BOOL (WINAPI *SetFileSecurity_Proc) (
338 LPCTSTR lpFileName,
339 SECURITY_INFORMATION SecurityInformation,
340 PSECURITY_DESCRIPTOR pSecurityDescriptor);
321typedef BOOL (WINAPI * GetSecurityDescriptorOwner_Proc) ( 341typedef BOOL (WINAPI * GetSecurityDescriptorOwner_Proc) (
322 PSECURITY_DESCRIPTOR pSecurityDescriptor, 342 PSECURITY_DESCRIPTOR pSecurityDescriptor,
323 PSID *pOwner, 343 PSID *pOwner,
@@ -326,6 +346,11 @@ typedef BOOL (WINAPI * GetSecurityDescriptorGroup_Proc) (
326 PSECURITY_DESCRIPTOR pSecurityDescriptor, 346 PSECURITY_DESCRIPTOR pSecurityDescriptor,
327 PSID *pGroup, 347 PSID *pGroup,
328 LPBOOL lpbGroupDefaulted); 348 LPBOOL lpbGroupDefaulted);
349typedef BOOL (WINAPI *GetSecurityDescriptorDacl_Proc) (
350 PSECURITY_DESCRIPTOR pSecurityDescriptor,
351 LPBOOL lpbDaclPresent,
352 PACL *pDacl,
353 LPBOOL lpbDaclDefaulted);
329typedef BOOL (WINAPI * IsValidSid_Proc) ( 354typedef BOOL (WINAPI * IsValidSid_Proc) (
330 PSID sid); 355 PSID sid);
331typedef HANDLE (WINAPI * CreateToolhelp32Snapshot_Proc) ( 356typedef HANDLE (WINAPI * CreateToolhelp32Snapshot_Proc) (
@@ -376,6 +401,18 @@ typedef BOOLEAN (WINAPI *CreateSymbolicLink_Proc) (
376 LPTSTR lpSymlinkFileName, 401 LPTSTR lpSymlinkFileName,
377 LPTSTR lpTargetFileName, 402 LPTSTR lpTargetFileName,
378 DWORD dwFlags); 403 DWORD dwFlags);
404typedef BOOL (WINAPI *ConvertStringSecurityDescriptorToSecurityDescriptor_Proc) (
405 LPCTSTR StringSecurityDescriptor,
406 DWORD StringSDRevision,
407 PSECURITY_DESCRIPTOR *SecurityDescriptor,
408 PULONG SecurityDescriptorSize);
409typedef BOOL (WINAPI *ConvertSecurityDescriptorToStringSecurityDescriptor_Proc) (
410 PSECURITY_DESCRIPTOR SecurityDescriptor,
411 DWORD RequestedStringSDRevision,
412 SECURITY_INFORMATION SecurityInformation,
413 LPTSTR *StringSecurityDescriptor,
414 PULONG StringSecurityDescriptorLen);
415typedef BOOL (WINAPI *IsValidSecurityDescriptor_Proc) (PSECURITY_DESCRIPTOR);
379 416
380 /* ** A utility function ** */ 417 /* ** A utility function ** */
381static BOOL 418static BOOL
@@ -621,6 +658,7 @@ get_file_security (LPCTSTR lpFileName,
621 HMODULE hm_advapi32 = NULL; 658 HMODULE hm_advapi32 = NULL;
622 if (is_windows_9x () == TRUE) 659 if (is_windows_9x () == TRUE)
623 { 660 {
661 errno = ENOTSUP;
624 return FALSE; 662 return FALSE;
625 } 663 }
626 if (g_b_init_get_file_security == 0) 664 if (g_b_init_get_file_security == 0)
@@ -633,6 +671,7 @@ get_file_security (LPCTSTR lpFileName,
633 } 671 }
634 if (s_pfn_Get_File_Security == NULL) 672 if (s_pfn_Get_File_Security == NULL)
635 { 673 {
674 errno = ENOTSUP;
636 return FALSE; 675 return FALSE;
637 } 676 }
638 return (s_pfn_Get_File_Security (lpFileName, RequestedInformation, 677 return (s_pfn_Get_File_Security (lpFileName, RequestedInformation,
@@ -641,6 +680,35 @@ get_file_security (LPCTSTR lpFileName,
641} 680}
642 681
643static BOOL WINAPI 682static BOOL WINAPI
683set_file_security (LPCTSTR lpFileName,
684 SECURITY_INFORMATION SecurityInformation,
685 PSECURITY_DESCRIPTOR pSecurityDescriptor)
686{
687 static SetFileSecurity_Proc s_pfn_Set_File_Security = NULL;
688 HMODULE hm_advapi32 = NULL;
689 if (is_windows_9x () == TRUE)
690 {
691 errno = ENOTSUP;
692 return FALSE;
693 }
694 if (g_b_init_set_file_security == 0)
695 {
696 g_b_init_set_file_security = 1;
697 hm_advapi32 = LoadLibrary ("Advapi32.dll");
698 s_pfn_Set_File_Security =
699 (SetFileSecurity_Proc) GetProcAddress (
700 hm_advapi32, SetFileSecurity_Name);
701 }
702 if (s_pfn_Set_File_Security == NULL)
703 {
704 errno = ENOTSUP;
705 return FALSE;
706 }
707 return (s_pfn_Set_File_Security (lpFileName, SecurityInformation,
708 pSecurityDescriptor));
709}
710
711static BOOL WINAPI
644get_security_descriptor_owner (PSECURITY_DESCRIPTOR pSecurityDescriptor, 712get_security_descriptor_owner (PSECURITY_DESCRIPTOR pSecurityDescriptor,
645 PSID *pOwner, 713 PSID *pOwner,
646 LPBOOL lpbOwnerDefaulted) 714 LPBOOL lpbOwnerDefaulted)
@@ -649,6 +717,7 @@ get_security_descriptor_owner (PSECURITY_DESCRIPTOR pSecurityDescriptor,
649 HMODULE hm_advapi32 = NULL; 717 HMODULE hm_advapi32 = NULL;
650 if (is_windows_9x () == TRUE) 718 if (is_windows_9x () == TRUE)
651 { 719 {
720 errno = ENOTSUP;
652 return FALSE; 721 return FALSE;
653 } 722 }
654 if (g_b_init_get_security_descriptor_owner == 0) 723 if (g_b_init_get_security_descriptor_owner == 0)
@@ -661,6 +730,7 @@ get_security_descriptor_owner (PSECURITY_DESCRIPTOR pSecurityDescriptor,
661 } 730 }
662 if (s_pfn_Get_Security_Descriptor_Owner == NULL) 731 if (s_pfn_Get_Security_Descriptor_Owner == NULL)
663 { 732 {
733 errno = ENOTSUP;
664 return FALSE; 734 return FALSE;
665 } 735 }
666 return (s_pfn_Get_Security_Descriptor_Owner (pSecurityDescriptor, pOwner, 736 return (s_pfn_Get_Security_Descriptor_Owner (pSecurityDescriptor, pOwner,
@@ -676,6 +746,7 @@ get_security_descriptor_group (PSECURITY_DESCRIPTOR pSecurityDescriptor,
676 HMODULE hm_advapi32 = NULL; 746 HMODULE hm_advapi32 = NULL;
677 if (is_windows_9x () == TRUE) 747 if (is_windows_9x () == TRUE)
678 { 748 {
749 errno = ENOTSUP;
679 return FALSE; 750 return FALSE;
680 } 751 }
681 if (g_b_init_get_security_descriptor_group == 0) 752 if (g_b_init_get_security_descriptor_group == 0)
@@ -688,6 +759,7 @@ get_security_descriptor_group (PSECURITY_DESCRIPTOR pSecurityDescriptor,
688 } 759 }
689 if (s_pfn_Get_Security_Descriptor_Group == NULL) 760 if (s_pfn_Get_Security_Descriptor_Group == NULL)
690 { 761 {
762 errno = ENOTSUP;
691 return FALSE; 763 return FALSE;
692 } 764 }
693 return (s_pfn_Get_Security_Descriptor_Group (pSecurityDescriptor, pGroup, 765 return (s_pfn_Get_Security_Descriptor_Group (pSecurityDescriptor, pGroup,
@@ -695,6 +767,37 @@ get_security_descriptor_group (PSECURITY_DESCRIPTOR pSecurityDescriptor,
695} 767}
696 768
697static BOOL WINAPI 769static BOOL WINAPI
770get_security_descriptor_dacl (PSECURITY_DESCRIPTOR pSecurityDescriptor,
771 LPBOOL lpbDaclPresent,
772 PACL *pDacl,
773 LPBOOL lpbDaclDefaulted)
774{
775 static GetSecurityDescriptorDacl_Proc s_pfn_Get_Security_Descriptor_Dacl = NULL;
776 HMODULE hm_advapi32 = NULL;
777 if (is_windows_9x () == TRUE)
778 {
779 errno = ENOTSUP;
780 return FALSE;
781 }
782 if (g_b_init_get_security_descriptor_dacl == 0)
783 {
784 g_b_init_get_security_descriptor_dacl = 1;
785 hm_advapi32 = LoadLibrary ("Advapi32.dll");
786 s_pfn_Get_Security_Descriptor_Dacl =
787 (GetSecurityDescriptorDacl_Proc) GetProcAddress (
788 hm_advapi32, "GetSecurityDescriptorDacl");
789 }
790 if (s_pfn_Get_Security_Descriptor_Dacl == NULL)
791 {
792 errno = ENOTSUP;
793 return FALSE;
794 }
795 return (s_pfn_Get_Security_Descriptor_Dacl (pSecurityDescriptor,
796 lpbDaclPresent, pDacl,
797 lpbDaclDefaulted));
798}
799
800static BOOL WINAPI
698is_valid_sid (PSID sid) 801is_valid_sid (PSID sid)
699{ 802{
700 static IsValidSid_Proc s_pfn_Is_Valid_Sid = NULL; 803 static IsValidSid_Proc s_pfn_Is_Valid_Sid = NULL;
@@ -888,6 +991,120 @@ create_symbolic_link (LPTSTR lpSymlinkFilename,
888 } 991 }
889 return retval; 992 return retval;
890} 993}
994
995static BOOL WINAPI
996is_valid_security_descriptor (PSECURITY_DESCRIPTOR pSecurityDescriptor)
997{
998 static IsValidSecurityDescriptor_Proc s_pfn_Is_Valid_Security_Descriptor_Proc = NULL;
999
1000 if (is_windows_9x () == TRUE)
1001 {
1002 errno = ENOTSUP;
1003 return FALSE;
1004 }
1005
1006 if (g_b_init_is_valid_security_descriptor == 0)
1007 {
1008 g_b_init_is_valid_security_descriptor = 1;
1009 s_pfn_Is_Valid_Security_Descriptor_Proc =
1010 (IsValidSecurityDescriptor_Proc)GetProcAddress (GetModuleHandle ("Advapi32.dll"),
1011 "IsValidSecurityDescriptor");
1012 }
1013 if (s_pfn_Is_Valid_Security_Descriptor_Proc == NULL)
1014 {
1015 errno = ENOTSUP;
1016 return FALSE;
1017 }
1018
1019 return s_pfn_Is_Valid_Security_Descriptor_Proc (pSecurityDescriptor);
1020}
1021
1022static BOOL WINAPI
1023convert_sd_to_sddl (PSECURITY_DESCRIPTOR SecurityDescriptor,
1024 DWORD RequestedStringSDRevision,
1025 SECURITY_INFORMATION SecurityInformation,
1026 LPTSTR *StringSecurityDescriptor,
1027 PULONG StringSecurityDescriptorLen)
1028{
1029 static ConvertSecurityDescriptorToStringSecurityDescriptor_Proc s_pfn_Convert_SD_To_SDDL = NULL;
1030 BOOL retval;
1031
1032 if (is_windows_9x () == TRUE)
1033 {
1034 errno = ENOTSUP;
1035 return FALSE;
1036 }
1037
1038 if (g_b_init_convert_sd_to_sddl == 0)
1039 {
1040 g_b_init_convert_sd_to_sddl = 1;
1041#ifdef _UNICODE
1042 s_pfn_Convert_SD_To_SDDL =
1043 (ConvertSecurityDescriptorToStringSecurityDescriptor_Proc)GetProcAddress (GetModuleHandle ("Advapi32.dll"),
1044 "ConvertSecurityDescriptorToStringSecurityDescriptorW");
1045#else
1046 s_pfn_Convert_SD_To_SDDL =
1047 (ConvertSecurityDescriptorToStringSecurityDescriptor_Proc)GetProcAddress (GetModuleHandle ("Advapi32.dll"),
1048 "ConvertSecurityDescriptorToStringSecurityDescriptorA");
1049#endif
1050 }
1051 if (s_pfn_Convert_SD_To_SDDL == NULL)
1052 {
1053 errno = ENOTSUP;
1054 return FALSE;
1055 }
1056
1057 retval = s_pfn_Convert_SD_To_SDDL (SecurityDescriptor,
1058 RequestedStringSDRevision,
1059 SecurityInformation,
1060 StringSecurityDescriptor,
1061 StringSecurityDescriptorLen);
1062
1063 return retval;
1064}
1065
1066static BOOL WINAPI
1067convert_sddl_to_sd (LPCTSTR StringSecurityDescriptor,
1068 DWORD StringSDRevision,
1069 PSECURITY_DESCRIPTOR *SecurityDescriptor,
1070 PULONG SecurityDescriptorSize)
1071{
1072 static ConvertStringSecurityDescriptorToSecurityDescriptor_Proc s_pfn_Convert_SDDL_To_SD = NULL;
1073 BOOL retval;
1074
1075 if (is_windows_9x () == TRUE)
1076 {
1077 errno = ENOTSUP;
1078 return FALSE;
1079 }
1080
1081 if (g_b_init_convert_sddl_to_sd == 0)
1082 {
1083 g_b_init_convert_sddl_to_sd = 1;
1084#ifdef _UNICODE
1085 s_pfn_Convert_SDDL_To_SD =
1086 (ConvertStringSecurityDescriptorToSecurityDescriptor_Proc)GetProcAddress (GetModuleHandle ("Advapi32.dll"),
1087 "ConvertStringSecurityDescriptorToSecurityDescriptorW");
1088#else
1089 s_pfn_Convert_SDDL_To_SD =
1090 (ConvertStringSecurityDescriptorToSecurityDescriptor_Proc)GetProcAddress (GetModuleHandle ("Advapi32.dll"),
1091 "ConvertStringSecurityDescriptorToSecurityDescriptorA");
1092#endif
1093 }
1094 if (s_pfn_Convert_SDDL_To_SD == NULL)
1095 {
1096 errno = ENOTSUP;
1097 return FALSE;
1098 }
1099
1100 retval = s_pfn_Convert_SDDL_To_SD (StringSecurityDescriptor,
1101 StringSDRevision,
1102 SecurityDescriptor,
1103 SecurityDescriptorSize);
1104
1105 return retval;
1106}
1107
891 1108
892 1109
893/* Return 1 if P is a valid pointer to an object of size SIZE. Return 1110/* Return 1 if P is a valid pointer to an object of size SIZE. Return
@@ -1567,6 +1784,7 @@ unsetenv (const char *name)
1567 /* It is safe to use 'alloca' with 32K size, since the stack is at 1784 /* It is safe to use 'alloca' with 32K size, since the stack is at
1568 least 2MB, and we set it to 8MB in the link command line. */ 1785 least 2MB, and we set it to 8MB in the link command line. */
1569 var = alloca (name_len + 2); 1786 var = alloca (name_len + 2);
1787 strncpy (var, name, name_len);
1570 var[name_len++] = '='; 1788 var[name_len++] = '=';
1571 var[name_len] = '\0'; 1789 var[name_len] = '\0';
1572 return _putenv (var); 1790 return _putenv (var);
@@ -3427,8 +3645,7 @@ w32_add_to_cache (PSID sid, unsigned id, char *name)
3427#define GID 2 3645#define GID 2
3428 3646
3429static int 3647static int
3430get_name_and_id (PSECURITY_DESCRIPTOR psd, const char *fname, 3648get_name_and_id (PSECURITY_DESCRIPTOR psd, unsigned *id, char *nm, int what)
3431 unsigned *id, char *nm, int what)
3432{ 3649{
3433 PSID sid = NULL; 3650 PSID sid = NULL;
3434 char machine[MAX_COMPUTERNAME_LENGTH+1]; 3651 char machine[MAX_COMPUTERNAME_LENGTH+1];
@@ -3438,7 +3655,6 @@ get_name_and_id (PSECURITY_DESCRIPTOR psd, const char *fname,
3438 DWORD name_len = sizeof (name); 3655 DWORD name_len = sizeof (name);
3439 char domain[1024]; 3656 char domain[1024];
3440 DWORD domain_len = sizeof (domain); 3657 DWORD domain_len = sizeof (domain);
3441 char *mp = NULL;
3442 int use_dflt = 0; 3658 int use_dflt = 0;
3443 int result; 3659 int result;
3444 3660
@@ -3453,22 +3669,7 @@ get_name_and_id (PSECURITY_DESCRIPTOR psd, const char *fname,
3453 use_dflt = 1; 3669 use_dflt = 1;
3454 else if (!w32_cached_id (sid, id, nm)) 3670 else if (!w32_cached_id (sid, id, nm))
3455 { 3671 {
3456 /* If FNAME is a UNC, we need to lookup account on the 3672 if (!lookup_account_sid (NULL, sid, name, &name_len,
3457 specified machine. */
3458 if (IS_DIRECTORY_SEP (fname[0]) && IS_DIRECTORY_SEP (fname[1])
3459 && fname[2] != '\0')
3460 {
3461 const char *s;
3462 char *p;
3463
3464 for (s = fname + 2, p = machine;
3465 *s && !IS_DIRECTORY_SEP (*s); s++, p++)
3466 *p = *s;
3467 *p = '\0';
3468 mp = machine;
3469 }
3470
3471 if (!lookup_account_sid (mp, sid, name, &name_len,
3472 domain, &domain_len, &ignore) 3673 domain, &domain_len, &ignore)
3473 || name_len > UNLEN+1) 3674 || name_len > UNLEN+1)
3474 use_dflt = 1; 3675 use_dflt = 1;
@@ -3483,9 +3684,7 @@ get_name_and_id (PSECURITY_DESCRIPTOR psd, const char *fname,
3483} 3684}
3484 3685
3485static void 3686static void
3486get_file_owner_and_group (PSECURITY_DESCRIPTOR psd, 3687get_file_owner_and_group (PSECURITY_DESCRIPTOR psd, struct stat *st)
3487 const char *fname,
3488 struct stat *st)
3489{ 3688{
3490 int dflt_usr = 0, dflt_grp = 0; 3689 int dflt_usr = 0, dflt_grp = 0;
3491 3690
@@ -3496,9 +3695,9 @@ get_file_owner_and_group (PSECURITY_DESCRIPTOR psd,
3496 } 3695 }
3497 else 3696 else
3498 { 3697 {
3499 if (get_name_and_id (psd, fname, &st->st_uid, st->st_uname, UID)) 3698 if (get_name_and_id (psd, &st->st_uid, st->st_uname, UID))
3500 dflt_usr = 1; 3699 dflt_usr = 1;
3501 if (get_name_and_id (psd, fname, &st->st_gid, st->st_gname, GID)) 3700 if (get_name_and_id (psd, &st->st_gid, st->st_gname, GID))
3502 dflt_grp = 1; 3701 dflt_grp = 1;
3503 } 3702 }
3504 /* Consider files to belong to current user/group, if we cannot get 3703 /* Consider files to belong to current user/group, if we cannot get
@@ -3722,23 +3921,23 @@ stat_worker (const char * path, struct stat * buf, int follow_symlinks)
3722 If getting security by handle fails, and we don't need to 3921 If getting security by handle fails, and we don't need to
3723 resolve symlinks, we try getting security by name. */ 3922 resolve symlinks, we try getting security by name. */
3724 if (!w32_stat_get_owner_group || is_windows_9x () == TRUE) 3923 if (!w32_stat_get_owner_group || is_windows_9x () == TRUE)
3725 get_file_owner_and_group (NULL, name, buf); 3924 get_file_owner_and_group (NULL, buf);
3726 else 3925 else
3727 { 3926 {
3728 psd = get_file_security_desc_by_handle (fh); 3927 psd = get_file_security_desc_by_handle (fh);
3729 if (psd) 3928 if (psd)
3730 { 3929 {
3731 get_file_owner_and_group (psd, name, buf); 3930 get_file_owner_and_group (psd, buf);
3732 LocalFree (psd); 3931 LocalFree (psd);
3733 } 3932 }
3734 else if (!(is_a_symlink && follow_symlinks)) 3933 else if (!(is_a_symlink && follow_symlinks))
3735 { 3934 {
3736 psd = get_file_security_desc_by_name (name); 3935 psd = get_file_security_desc_by_name (name);
3737 get_file_owner_and_group (psd, name, buf); 3936 get_file_owner_and_group (psd, buf);
3738 xfree (psd); 3937 xfree (psd);
3739 } 3938 }
3740 else 3939 else
3741 get_file_owner_and_group (NULL, name, buf); 3940 get_file_owner_and_group (NULL, buf);
3742 } 3941 }
3743 CloseHandle (fh); 3942 CloseHandle (fh);
3744 } 3943 }
@@ -3847,7 +4046,7 @@ stat_worker (const char * path, struct stat * buf, int follow_symlinks)
3847 else 4046 else
3848 buf->st_mode = S_IFREG; 4047 buf->st_mode = S_IFREG;
3849 4048
3850 get_file_owner_and_group (NULL, name, buf); 4049 get_file_owner_and_group (NULL, buf);
3851 } 4050 }
3852 4051
3853#if 0 4052#if 0
@@ -4301,7 +4500,7 @@ readlink (const char *name, char *buf, size_t buf_size)
4301 errno = EINVAL; 4500 errno = EINVAL;
4302 else 4501 else
4303 { 4502 {
4304 /* Copy the link target name, in wide characters, fro 4503 /* Copy the link target name, in wide characters, from
4305 reparse_data, then convert it to multibyte encoding in 4504 reparse_data, then convert it to multibyte encoding in
4306 the current locale's codepage. */ 4505 the current locale's codepage. */
4307 WCHAR *lwname; 4506 WCHAR *lwname;
@@ -4477,6 +4676,239 @@ chase_symlinks (const char *file)
4477 return target; 4676 return target;
4478} 4677}
4479 4678
4679
4680/* Posix ACL emulation. */
4681
4682int
4683acl_valid (acl_t acl)
4684{
4685 return is_valid_security_descriptor ((PSECURITY_DESCRIPTOR)acl) ? 0 : -1;
4686}
4687
4688char *
4689acl_to_text (acl_t acl, ssize_t *size)
4690{
4691 LPTSTR str_acl;
4692 SECURITY_INFORMATION flags =
4693 OWNER_SECURITY_INFORMATION |
4694 GROUP_SECURITY_INFORMATION |
4695 DACL_SECURITY_INFORMATION;
4696 char *retval = NULL;
4697 ULONG local_size;
4698 int e = errno;
4699
4700 errno = 0;
4701
4702 if (convert_sd_to_sddl ((PSECURITY_DESCRIPTOR)acl, SDDL_REVISION_1, flags, &str_acl, &local_size))
4703 {
4704 errno = e;
4705 /* We don't want to mix heaps, so we duplicate the string in our
4706 heap and free the one allocated by the API. */
4707 retval = xstrdup (str_acl);
4708 if (size)
4709 *size = local_size;
4710 LocalFree (str_acl);
4711 }
4712 else if (errno != ENOTSUP)
4713 errno = EINVAL;
4714
4715 return retval;
4716}
4717
4718acl_t
4719acl_from_text (const char *acl_str)
4720{
4721 PSECURITY_DESCRIPTOR psd, retval = NULL;
4722 ULONG sd_size;
4723 int e = errno;
4724
4725 errno = 0;
4726
4727 if (convert_sddl_to_sd (acl_str, SDDL_REVISION_1, &psd, &sd_size))
4728 {
4729 errno = e;
4730 retval = xmalloc (sd_size);
4731 memcpy (retval, psd, sd_size);
4732 LocalFree (psd);
4733 }
4734 else if (errno != ENOTSUP)
4735 errno = EINVAL;
4736
4737 return retval;
4738}
4739
4740int
4741acl_free (void *ptr)
4742{
4743 xfree (ptr);
4744 return 0;
4745}
4746
4747acl_t
4748acl_get_file (const char *fname, acl_type_t type)
4749{
4750 PSECURITY_DESCRIPTOR psd = NULL;
4751 const char *filename;
4752
4753 if (type == ACL_TYPE_ACCESS)
4754 {
4755 DWORD sd_len, err;
4756 SECURITY_INFORMATION si =
4757 OWNER_SECURITY_INFORMATION |
4758 GROUP_SECURITY_INFORMATION |
4759 DACL_SECURITY_INFORMATION ;
4760 int e = errno;
4761
4762 filename = map_w32_filename (fname, NULL);
4763 if ((volume_info.flags & FILE_SUPPORTS_REPARSE_POINTS) != 0)
4764 fname = chase_symlinks (filename);
4765 else
4766 fname = filename;
4767
4768 errno = 0;
4769 if (!get_file_security (fname, si, psd, 0, &sd_len)
4770 && errno != ENOTSUP)
4771 {
4772 err = GetLastError ();
4773 if (err == ERROR_INSUFFICIENT_BUFFER)
4774 {
4775 psd = xmalloc (sd_len);
4776 if (!get_file_security (fname, si, psd, sd_len, &sd_len))
4777 {
4778 xfree (psd);
4779 errno = EIO;
4780 psd = NULL;
4781 }
4782 }
4783 else if (err == ERROR_FILE_NOT_FOUND
4784 || err == ERROR_PATH_NOT_FOUND)
4785 errno = ENOENT;
4786 else
4787 errno = EIO;
4788 }
4789 else if (!errno)
4790 errno = e;
4791 }
4792 else if (type != ACL_TYPE_DEFAULT)
4793 errno = EINVAL;
4794
4795 return psd;
4796}
4797
4798int
4799acl_set_file (const char *fname, acl_type_t type, acl_t acl)
4800{
4801 TOKEN_PRIVILEGES old1, old2;
4802 DWORD err;
4803 BOOL res;
4804 int st = 0, retval = -1;
4805 SECURITY_INFORMATION flags = 0;
4806 PSID psid;
4807 PACL pacl;
4808 BOOL dflt;
4809 BOOL dacl_present;
4810 int e;
4811 const char *filename;
4812
4813 if (acl_valid (acl) != 0
4814 || (type != ACL_TYPE_DEFAULT && type != ACL_TYPE_ACCESS))
4815 {
4816 errno = EINVAL;
4817 return -1;
4818 }
4819
4820 if (type == ACL_TYPE_DEFAULT)
4821 {
4822 errno = ENOSYS;
4823 return -1;
4824 }
4825
4826 filename = map_w32_filename (fname, NULL);
4827 if ((volume_info.flags & FILE_SUPPORTS_REPARSE_POINTS) != 0)
4828 fname = chase_symlinks (filename);
4829 else
4830 fname = filename;
4831
4832 if (get_security_descriptor_owner ((PSECURITY_DESCRIPTOR)acl, &psid, &dflt)
4833 && psid)
4834 flags |= OWNER_SECURITY_INFORMATION;
4835 if (get_security_descriptor_group ((PSECURITY_DESCRIPTOR)acl, &psid, &dflt)
4836 && psid)
4837 flags |= GROUP_SECURITY_INFORMATION;
4838 if (get_security_descriptor_dacl ((PSECURITY_DESCRIPTOR)acl, &dacl_present,
4839 &pacl, &dflt)
4840 && dacl_present)
4841 flags |= DACL_SECURITY_INFORMATION;
4842 if (!flags)
4843 return 0;
4844
4845 /* According to KB-245153, setting the owner will succeed if either:
4846 (1) the caller is the user who will be the new owner, and has the
4847 SE_TAKE_OWNERSHIP privilege, or
4848 (2) the caller has the SE_RESTORE privilege, in which case she can
4849 set any valid user or group as the owner
4850
4851 We request below both SE_TAKE_OWNERSHIP and SE_RESTORE
4852 privileges, and disregard any failures in obtaining them. If
4853 these privileges cannot be obtained, and do not already exist in
4854 the calling thread's security token, this function could fail
4855 with EPERM. */
4856 if (enable_privilege (SE_TAKE_OWNERSHIP_NAME, TRUE, &old1))
4857 st++;
4858 if (enable_privilege (SE_RESTORE_NAME, TRUE, &old2))
4859 st++;
4860
4861 e = errno;
4862 errno = 0;
4863 set_file_security ((char *)fname, flags, (PSECURITY_DESCRIPTOR)acl);
4864 err = GetLastError ();
4865 if (st)
4866 {
4867 if (st >= 2)
4868 restore_privilege (&old2);
4869 restore_privilege (&old1);
4870 revert_to_self ();
4871 }
4872
4873 if (errno == ENOTSUP)
4874 ;
4875 else if (err == ERROR_SUCCESS)
4876 {
4877 retval = 0;
4878 errno = e;
4879 }
4880 else if (err == ERROR_INVALID_OWNER || err == ERROR_NOT_ALL_ASSIGNED)
4881 {
4882 /* Maybe the requested ACL and the one the file already has are
4883 identical, in which case we can silently ignore the
4884 failure. (And no, Windows doesn't.) */
4885 acl_t current_acl = acl_get_file (fname, ACL_TYPE_ACCESS);
4886
4887 errno = EPERM;
4888 if (current_acl)
4889 {
4890 char *acl_from = acl_to_text (current_acl, NULL);
4891 char *acl_to = acl_to_text (acl, NULL);
4892
4893 if (acl_from && acl_to && xstrcasecmp (acl_from, acl_to) == 0)
4894 {
4895 retval = 0;
4896 errno = e;
4897 }
4898 if (acl_from)
4899 acl_free (acl_from);
4900 if (acl_to)
4901 acl_free (acl_to);
4902 acl_free (current_acl);
4903 }
4904 }
4905 else if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND)
4906 errno = ENOENT;
4907
4908 return retval;
4909}
4910
4911
4480/* MS-Windows version of careadlinkat (cf. ../lib/careadlinkat.c). We 4912/* MS-Windows version of careadlinkat (cf. ../lib/careadlinkat.c). We
4481 have a fixed max size for file names, so we don't need the kind of 4913 have a fixed max size for file names, so we don't need the kind of
4482 alloc/malloc/realloc dance the gnulib version does. We also don't 4914 alloc/malloc/realloc dance the gnulib version does. We also don't
@@ -5993,7 +6425,21 @@ sys_close (int fd)
5993 6425
5994 winsock_inuse--; /* count open sockets */ 6426 winsock_inuse--; /* count open sockets */
5995 } 6427 }
5996 delete_child (cp); 6428 /* If the process handle is NULL, it's either a socket
6429 or serial connection, or a subprocess that was
6430 already reaped by reap_subprocess, but whose
6431 resources were not yet freed, because its output was
6432 not fully read yet by the time it was reaped. (This
6433 usually happens with async subprocesses whose output
6434 is being read by Emacs.) Otherwise, this process was
6435 not reaped yet, so we set its FD to a negative value
6436 to make sure sys_select will eventually get to
6437 calling the SIGCHLD handler for it, which will then
6438 invoke waitpid and reap_subprocess. */
6439 if (cp->procinfo.hProcess == NULL)
6440 delete_child (cp);
6441 else
6442 cp->fd = -1;
5997 } 6443 }
5998 } 6444 }
5999 } 6445 }
@@ -6848,6 +7294,11 @@ globals_of_w32 (void)
6848 g_b_init_get_native_system_info = 0; 7294 g_b_init_get_native_system_info = 0;
6849 g_b_init_get_system_times = 0; 7295 g_b_init_get_system_times = 0;
6850 g_b_init_create_symbolic_link = 0; 7296 g_b_init_create_symbolic_link = 0;
7297 g_b_init_get_security_descriptor_dacl = 0;
7298 g_b_init_convert_sd_to_sddl = 0;
7299 g_b_init_convert_sddl_to_sd = 0;
7300 g_b_init_is_valid_security_descriptor = 0;
7301 g_b_init_set_file_security = 0;
6851 num_of_processors = 0; 7302 num_of_processors = 0;
6852 /* The following sets a handler for shutdown notifications for 7303 /* The following sets a handler for shutdown notifications for
6853 console apps. This actually applies to Emacs in both console and 7304 console apps. This actually applies to Emacs in both console and
diff --git a/src/w32.h b/src/w32.h
index a43a5133eb4..895e7f31d63 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -2,7 +2,7 @@
2#define EMACS_W32_H 2#define EMACS_W32_H
3 3
4/* Support routines for the NT version of Emacs. 4/* Support routines for the NT version of Emacs.
5 Copyright (C) 1994, 2001-2012 Free Software Foundation, Inc. 5 Copyright (C) 1994, 2001-2013 Free Software Foundation, Inc.
6 6
7This file is part of GNU Emacs. 7This file is part of GNU Emacs.
8 8
diff --git a/src/w32common.h b/src/w32common.h
index 5e9b61824ae..79fe5cc367c 100644
--- a/src/w32common.h
+++ b/src/w32common.h
@@ -1,5 +1,5 @@
1/* Common functions for Microsoft Windows builds of Emacs 1/* Common functions for Microsoft Windows builds of Emacs
2 Copyright (C) 2012 Free Software Foundation, Inc. 2 Copyright (C) 2012-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/w32console.c b/src/w32console.c
index f201ff190c2..06b2c7aa24e 100644
--- a/src/w32console.c
+++ b/src/w32console.c
@@ -1,5 +1,5 @@
1/* Terminal hooks for GNU Emacs on the Microsoft Windows API. 1/* Terminal hooks for GNU Emacs on the Microsoft Windows API.
2 Copyright (C) 1992, 1999, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1992, 1999, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/w32fns.c b/src/w32fns.c
index f69fbe05a6d..355ee96b9f3 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -1,6 +1,6 @@
1/* Graphical user interface functions for the Microsoft Windows API. 1/* Graphical user interface functions for the Microsoft Windows API.
2 2
3Copyright (C) 1989, 1992-2012 Free Software Foundation, Inc. 3Copyright (C) 1989, 1992-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/w32font.c b/src/w32font.c
index d7d25d89939..5c5a15cc340 100644
--- a/src/w32font.c
+++ b/src/w32font.c
@@ -1,5 +1,5 @@
1/* Font backend for the Microsoft Windows API. 1/* Font backend for the Microsoft Windows API.
2 Copyright (C) 2007-2012 Free Software Foundation, Inc. 2 Copyright (C) 2007-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/w32font.h b/src/w32font.h
index 8fa00a9b524..b4345478a22 100644
--- a/src/w32font.h
+++ b/src/w32font.h
@@ -1,5 +1,5 @@
1/* Shared GDI and Uniscribe Font backend declarations for the Windows API. 1/* Shared GDI and Uniscribe Font backend declarations for the Windows API.
2 Copyright (C) 2007-2012 Free Software Foundation, Inc. 2 Copyright (C) 2007-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/w32gui.h b/src/w32gui.h
index fe2bb2334b5..739ff3c92e9 100644
--- a/src/w32gui.h
+++ b/src/w32gui.h
@@ -1,5 +1,5 @@
1/* Definitions and headers for communication on the Microsoft Windows API. 1/* Definitions and headers for communication on the Microsoft Windows API.
2 Copyright (C) 1995, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1995, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/w32heap.c b/src/w32heap.c
index 311e1064434..9c189dbda6d 100644
--- a/src/w32heap.c
+++ b/src/w32heap.c
@@ -1,5 +1,5 @@
1/* Heap management routines for GNU Emacs on the Microsoft Windows API. 1/* Heap management routines for GNU Emacs on the Microsoft Windows API.
2 Copyright (C) 1994, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1994, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/w32heap.h b/src/w32heap.h
index 1630864875f..82b59dd027f 100644
--- a/src/w32heap.h
+++ b/src/w32heap.h
@@ -1,5 +1,5 @@
1/* Heap management routines (including unexec) for GNU Emacs on Windows NT. 1/* Heap management routines (including unexec) for GNU Emacs on Windows NT.
2 Copyright (C) 1994, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1994, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/w32inevt.c b/src/w32inevt.c
index 2cbf31efda3..3c38cf806e8 100644
--- a/src/w32inevt.c
+++ b/src/w32inevt.c
@@ -1,5 +1,6 @@
1/* Input event support for Emacs on the Microsoft Windows API. 1/* Input event support for Emacs on the Microsoft Windows API.
2 Copyright (C) 1992-1993, 1995, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1992-1993, 1995, 2001-2013 Free Software Foundation,
3 Inc.
3 4
4This file is part of GNU Emacs. 5This file is part of GNU Emacs.
5 6
diff --git a/src/w32inevt.h b/src/w32inevt.h
index 319688b877b..8a7e4fed06a 100644
--- a/src/w32inevt.h
+++ b/src/w32inevt.h
@@ -1,5 +1,5 @@
1/* Input routines for GNU Emacs on the Microsoft Windows API. 1/* Input routines for GNU Emacs on the Microsoft Windows API.
2 Copyright (C) 1995, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1995, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/w32menu.c b/src/w32menu.c
index 84fb1bdc71e..03904cf20b8 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -1,6 +1,6 @@
1/* Menu support for GNU Emacs on the Microsoft Windows API. 1/* Menu support for GNU Emacs on the Microsoft Windows API.
2 Copyright (C) 1986, 1988, 1993-1994, 1996, 1998-1999, 2001-2012 2 Copyright (C) 1986, 1988, 1993-1994, 1996, 1998-1999, 2001-2013 Free
3 Free Software Foundation, Inc. 3 Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/w32notify.c b/src/w32notify.c
index 0b7dc9a1110..d78e55f43ed 100644
--- a/src/w32notify.c
+++ b/src/w32notify.c
@@ -1,5 +1,5 @@
1/* Filesystem notifications support for GNU Emacs on the Microsoft Windows API. 1/* Filesystem notifications support for GNU Emacs on the Microsoft Windows API.
2 Copyright (C) 2012 Free Software Foundation, Inc. 2 Copyright (C) 2012-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/w32proc.c b/src/w32proc.c
index 43ecf4d68f3..0fcb2993020 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -1,5 +1,5 @@
1/* Process support for GNU Emacs on the Microsoft Windows API. 1/* Process support for GNU Emacs on the Microsoft Windows API.
2 Copyright (C) 1992, 1995, 1999-2012 Free Software Foundation, Inc. 2 Copyright (C) 1992, 1995, 1999-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
@@ -800,7 +800,7 @@ new_child (void)
800 DWORD id; 800 DWORD id;
801 801
802 for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--) 802 for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--)
803 if (!CHILD_ACTIVE (cp)) 803 if (!CHILD_ACTIVE (cp) && cp->procinfo.hProcess == NULL)
804 goto Initialize; 804 goto Initialize;
805 if (child_proc_count == MAX_CHILDREN) 805 if (child_proc_count == MAX_CHILDREN)
806 return NULL; 806 return NULL;
@@ -859,7 +859,7 @@ delete_child (child_process *cp)
859 if (fd_info[i].cp == cp) 859 if (fd_info[i].cp == cp)
860 emacs_abort (); 860 emacs_abort ();
861 861
862 if (!CHILD_ACTIVE (cp)) 862 if (!CHILD_ACTIVE (cp) && cp->procinfo.hProcess == NULL)
863 return; 863 return;
864 864
865 /* Delete the child's temporary input file, if any, that is pending 865 /* Delete the child's temporary input file, if any, that is pending
@@ -918,7 +918,8 @@ delete_child (child_process *cp)
918 if (cp == child_procs + child_proc_count - 1) 918 if (cp == child_procs + child_proc_count - 1)
919 { 919 {
920 for (i = child_proc_count-1; i >= 0; i--) 920 for (i = child_proc_count-1; i >= 0; i--)
921 if (CHILD_ACTIVE (&child_procs[i])) 921 if (CHILD_ACTIVE (&child_procs[i])
922 || child_procs[i].procinfo.hProcess != NULL)
922 { 923 {
923 child_proc_count = i + 1; 924 child_proc_count = i + 1;
924 break; 925 break;
@@ -935,7 +936,8 @@ find_child_pid (DWORD pid)
935 child_process *cp; 936 child_process *cp;
936 937
937 for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--) 938 for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--)
938 if (CHILD_ACTIVE (cp) && pid == cp->pid) 939 if ((CHILD_ACTIVE (cp) || cp->procinfo.hProcess != NULL)
940 && pid == cp->pid)
939 return cp; 941 return cp;
940 return NULL; 942 return NULL;
941} 943}
@@ -963,11 +965,16 @@ reader_thread (void *arg)
963 { 965 {
964 int rc; 966 int rc;
965 967
966 if (fd_info[cp->fd].flags & FILE_LISTEN) 968 if (cp->fd >= 0 && fd_info[cp->fd].flags & FILE_LISTEN)
967 rc = _sys_wait_accept (cp->fd); 969 rc = _sys_wait_accept (cp->fd);
968 else 970 else
969 rc = _sys_read_ahead (cp->fd); 971 rc = _sys_read_ahead (cp->fd);
970 972
973 /* Don't bother waiting for the event if we already have been
974 told to exit by delete_child. */
975 if (cp->status == STATUS_READ_ERROR || !cp->char_avail)
976 break;
977
971 /* The name char_avail is a misnomer - it really just means the 978 /* The name char_avail is a misnomer - it really just means the
972 read-ahead has completed, whether successfully or not. */ 979 read-ahead has completed, whether successfully or not. */
973 if (!SetEvent (cp->char_avail)) 980 if (!SetEvent (cp->char_avail))
@@ -984,6 +991,11 @@ reader_thread (void *arg)
984 if (rc == STATUS_READ_FAILED) 991 if (rc == STATUS_READ_FAILED)
985 break; 992 break;
986 993
994 /* Don't bother waiting for the acknowledge if we already have
995 been told to exit by delete_child. */
996 if (cp->status == STATUS_READ_ERROR || !cp->char_consumed)
997 break;
998
987 /* Wait until our input is acknowledged before reading again */ 999 /* Wait until our input is acknowledged before reading again */
988 if (WaitForSingleObject (cp->char_consumed, INFINITE) != WAIT_OBJECT_0) 1000 if (WaitForSingleObject (cp->char_consumed, INFINITE) != WAIT_OBJECT_0)
989 { 1001 {
@@ -991,6 +1003,10 @@ reader_thread (void *arg)
991 "%lu for fd %ld\n", GetLastError (), cp->fd)); 1003 "%lu for fd %ld\n", GetLastError (), cp->fd));
992 break; 1004 break;
993 } 1005 }
1006 /* delete_child sets status to STATUS_READ_ERROR when it wants
1007 us to exit. */
1008 if (cp->status == STATUS_READ_ERROR)
1009 break;
994 } 1010 }
995 return 0; 1011 return 0;
996} 1012}
@@ -1161,11 +1177,11 @@ reap_subprocess (child_process *cp)
1161 cp->procinfo.hThread = NULL; 1177 cp->procinfo.hThread = NULL;
1162 } 1178 }
1163 1179
1164 /* For asynchronous children, the child_proc resources will be freed 1180 /* If cp->fd was not closed yet, we might be still reading the
1165 when the last pipe read descriptor is closed; for synchronous 1181 process output, so don't free its resources just yet. The call
1166 children, we must explicitly free the resources now because 1182 to delete_child on behalf of this subprocess will be made by
1167 register_child has not been called. */ 1183 sys_read when the subprocess output is fully read. */
1168 if (cp->fd == -1) 1184 if (cp->fd < 0)
1169 delete_child (cp); 1185 delete_child (cp);
1170} 1186}
1171 1187
diff --git a/src/w32reg.c b/src/w32reg.c
index 8b6c76503a6..e7c4e9ea351 100644
--- a/src/w32reg.c
+++ b/src/w32reg.c
@@ -1,5 +1,6 @@
1/* Emulate the X Resource Manager through the registry. 1/* Emulate the X Resource Manager through the registry.
2 Copyright (C) 1990, 1993-1994, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1990, 1993-1994, 2001-2013 Free Software Foundation,
3 Inc.
3 4
4This file is part of GNU Emacs. 5This file is part of GNU Emacs.
5 6
diff --git a/src/w32select.c b/src/w32select.c
index 6a2a840f914..3c966595d6d 100644
--- a/src/w32select.c
+++ b/src/w32select.c
@@ -1,6 +1,6 @@
1/* Selection processing for Emacs on the Microsoft Windows API. 1/* Selection processing for Emacs on the Microsoft Windows API.
2 2
3Copyright (C) 1993-1994, 2001-2012 Free Software Foundation, Inc. 3Copyright (C) 1993-1994, 2001-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/w32select.h b/src/w32select.h
index 4f4de59f7fe..f6223b881d2 100644
--- a/src/w32select.h
+++ b/src/w32select.h
@@ -1,6 +1,6 @@
1/* Selection processing for Emacs on the Microsoft W32 API. 1/* Selection processing for Emacs on the Microsoft W32 API.
2 2
3Copyright (C) 1993-1994, 2001-2012 Free Software Foundation, Inc. 3Copyright (C) 1993-1994, 2001-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/w32term.c b/src/w32term.c
index 7c53097e313..36ae4d7797f 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -1,6 +1,6 @@
1/* Implementation of GUI terminal on the Microsoft Windows API. 1/* Implementation of GUI terminal on the Microsoft Windows API.
2 2
3Copyright (C) 1989, 1993-2012 Free Software Foundation, Inc. 3Copyright (C) 1989, 1993-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -358,7 +358,7 @@ w32_restore_glyph_string_clip (struct glyph_string *s)
358void 358void
359w32_draw_underwave (struct glyph_string *s, COLORREF color) 359w32_draw_underwave (struct glyph_string *s, COLORREF color)
360{ 360{
361 int wave_height = 2, wave_length = 3; 361 int wave_height = 3, wave_length = 2;
362 int dx, dy, x0, y0, width, x1, y1, x2, y2, odd, xmax; 362 int dx, dy, x0, y0, width, x1, y1, x2, y2, odd, xmax;
363 XRectangle wave_clip, string_clip, final_clip; 363 XRectangle wave_clip, string_clip, final_clip;
364 RECT w32_final_clip, w32_string_clip; 364 RECT w32_final_clip, w32_string_clip;
@@ -367,7 +367,7 @@ w32_draw_underwave (struct glyph_string *s, COLORREF color)
367 dx = wave_length; 367 dx = wave_length;
368 dy = wave_height - 1; 368 dy = wave_height - 1;
369 x0 = s->x; 369 x0 = s->x;
370 y0 = s->ybase + 1; 370 y0 = s->ybase - wave_height + 3;
371 width = s->width; 371 width = s->width;
372 xmax = x0 + width; 372 xmax = x0 + width;
373 373
@@ -2456,7 +2456,8 @@ x_draw_glyph_string (struct glyph_string *s)
2456 unsigned long thickness, position; 2456 unsigned long thickness, position;
2457 int y; 2457 int y;
2458 2458
2459 if (s->prev && s->prev->face->underline_p) 2459 if (s->prev && s->prev->face->underline_p
2460 && s->prev->face->underline_type == FACE_UNDER_LINE)
2460 { 2461 {
2461 /* We use the same underline style as the previous one. */ 2462 /* We use the same underline style as the previous one. */
2462 thickness = s->prev->underline_thickness; 2463 thickness = s->prev->underline_thickness;
@@ -5648,6 +5649,77 @@ x_check_fullscreen (struct frame *f)
5648 } 5649 }
5649} 5650}
5650 5651
5652static void
5653w32fullscreen_hook (FRAME_PTR f)
5654{
5655 static int normal_width, normal_height, normal_top, normal_left;
5656
5657 if (f->async_visible)
5658 {
5659 int width, height, top_pos, left_pos, pixel_height, pixel_width;
5660 int cur_w = FRAME_COLS (f), cur_h = FRAME_LINES (f);
5661 RECT workarea_rect;
5662
5663 block_input ();
5664 if (normal_height <= 0)
5665 normal_height = cur_h;
5666 if (normal_width <= 0)
5667 normal_width = cur_w;
5668 x_real_positions (f, &f->left_pos, &f->top_pos);
5669 x_fullscreen_adjust (f, &width, &height, &top_pos, &left_pos);
5670
5671 SystemParametersInfo (SPI_GETWORKAREA, 0, &workarea_rect, 0);
5672 pixel_height = workarea_rect.bottom - workarea_rect.top;
5673 pixel_width = workarea_rect.right - workarea_rect.left;
5674
5675 switch (f->want_fullscreen)
5676 {
5677 /* No difference between these two when there is no WM */
5678 case FULLSCREEN_MAXIMIZED:
5679 PostMessage (FRAME_W32_WINDOW (f), WM_SYSCOMMAND, 0xf030, 0);
5680 break;
5681 case FULLSCREEN_BOTH:
5682 height = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, pixel_height) - 2;
5683 width = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pixel_width);
5684 left_pos = workarea_rect.left;
5685 top_pos = workarea_rect.top;
5686 break;
5687 case FULLSCREEN_WIDTH:
5688 width = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pixel_width);
5689 if (normal_height > 0)
5690 height = normal_height;
5691 left_pos = workarea_rect.left;
5692 break;
5693 case FULLSCREEN_HEIGHT:
5694 height = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, pixel_height) - 2;
5695 if (normal_width > 0)
5696 width = normal_width;
5697 top_pos = workarea_rect.top;
5698 break;
5699 case FULLSCREEN_NONE:
5700 if (normal_height > 0)
5701 height = normal_height;
5702 else
5703 normal_height = height;
5704 if (normal_width > 0)
5705 width = normal_width;
5706 else
5707 normal_width = width;
5708 /* FIXME: Should restore the original position of the frame. */
5709 top_pos = left_pos = 0;
5710 break;
5711 }
5712
5713 if (cur_w != width || cur_h != height)
5714 {
5715 x_set_offset (f, left_pos, top_pos, 1);
5716 x_set_window_size (f, 1, width, height);
5717 do_pending_window_change (0);
5718 }
5719 unblock_input ();
5720 }
5721}
5722
5651/* Call this to change the size of frame F's x-window. 5723/* Call this to change the size of frame F's x-window.
5652 If CHANGE_GRAVITY is 1, we change to top-left-corner window gravity 5724 If CHANGE_GRAVITY is 1, we change to top-left-corner window gravity
5653 for this size change and subsequent size changes. 5725 for this size change and subsequent size changes.
@@ -6338,7 +6410,7 @@ w32_create_terminal (struct w32_display_info *dpyinfo)
6338 terminal->mouse_position_hook = w32_mouse_position; 6410 terminal->mouse_position_hook = w32_mouse_position;
6339 terminal->frame_rehighlight_hook = w32_frame_rehighlight; 6411 terminal->frame_rehighlight_hook = w32_frame_rehighlight;
6340 terminal->frame_raise_lower_hook = w32_frame_raise_lower; 6412 terminal->frame_raise_lower_hook = w32_frame_raise_lower;
6341 /* terminal->fullscreen_hook = XTfullscreen_hook; */ 6413 terminal->fullscreen_hook = w32fullscreen_hook;
6342 terminal->set_vertical_scroll_bar_hook = w32_set_vertical_scroll_bar; 6414 terminal->set_vertical_scroll_bar_hook = w32_set_vertical_scroll_bar;
6343 terminal->condemn_scroll_bars_hook = w32_condemn_scroll_bars; 6415 terminal->condemn_scroll_bars_hook = w32_condemn_scroll_bars;
6344 terminal->redeem_scroll_bar_hook = w32_redeem_scroll_bar; 6416 terminal->redeem_scroll_bar_hook = w32_redeem_scroll_bar;
diff --git a/src/w32term.h b/src/w32term.h
index 35842e60c16..7154d549f21 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -1,5 +1,5 @@
1/* Definitions and headers for communication on the Microsoft Windows API. 1/* Definitions and headers for communication on the Microsoft Windows API.
2 Copyright (C) 1995, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1995, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/w32uniscribe.c b/src/w32uniscribe.c
index 5d160b9d42f..88227487d35 100644
--- a/src/w32uniscribe.c
+++ b/src/w32uniscribe.c
@@ -1,5 +1,5 @@
1/* Font backend for the Microsoft W32 Uniscribe API. 1/* Font backend for the Microsoft W32 Uniscribe API.
2 Copyright (C) 2008-2012 Free Software Foundation, Inc. 2 Copyright (C) 2008-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/w32xfns.c b/src/w32xfns.c
index 8820edda6c2..03611e19768 100644
--- a/src/w32xfns.c
+++ b/src/w32xfns.c
@@ -1,5 +1,6 @@
1/* Functions taken directly from X sources for use with the Microsoft Windows API. 1/* Functions taken directly from X sources for use with the Microsoft Windows API.
2 Copyright (C) 1989, 1992-1995, 1999, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1989, 1992-1995, 1999, 2001-2013 Free Software
3 Foundation, Inc.
3 4
4This file is part of GNU Emacs. 5This file is part of GNU Emacs.
5 6
diff --git a/src/widget.c b/src/widget.c
index b4f7335c652..28e9fc29a91 100644
--- a/src/widget.c
+++ b/src/widget.c
@@ -1,5 +1,5 @@
1/* The emacs frame widget. 1/* The emacs frame widget.
2 Copyright (C) 1992-1993, 2000-2012 Free Software Foundation, Inc. 2 Copyright (C) 1992-1993, 2000-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/widget.h b/src/widget.h
index 03838a01415..e04c31c259b 100644
--- a/src/widget.h
+++ b/src/widget.h
@@ -1,5 +1,5 @@
1/* The emacs frame widget public header file. 1/* The emacs frame widget public header file.
2 Copyright (C) 1993, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1993, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/widgetprv.h b/src/widgetprv.h
index 00e3eeb1ee1..b617654e7f2 100644
--- a/src/widgetprv.h
+++ b/src/widgetprv.h
@@ -1,5 +1,5 @@
1/* The emacs frame widget private header file. 1/* The emacs frame widget private header file.
2 Copyright (C) 1993, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1993, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/window.c b/src/window.c
index 7fa55df3c5e..71d8eb7f778 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1,7 +1,7 @@
1/* Window creation, deletion and examination for GNU Emacs. 1/* Window creation, deletion and examination for GNU Emacs.
2 Does not include redisplay. 2 Does not include redisplay.
3 Copyright (C) 1985-1987, 1993-1998, 2000-2012 3 Copyright (C) 1985-1987, 1993-1998, 2000-2013 Free Software
4 Free Software Foundation, Inc. 4 Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
@@ -87,6 +87,7 @@ static Lisp_Object window_list_1 (Lisp_Object, Lisp_Object, Lisp_Object);
87static int window_resize_check (struct window *, int); 87static int window_resize_check (struct window *, int);
88static void window_resize_apply (struct window *, int); 88static void window_resize_apply (struct window *, int);
89static Lisp_Object select_window (Lisp_Object, Lisp_Object, int); 89static Lisp_Object select_window (Lisp_Object, Lisp_Object, int);
90static void select_window_1 (Lisp_Object, bool);
90 91
91/* This is the window in which the terminal's cursor should 92/* This is the window in which the terminal's cursor should
92 be left when nothing is being done with it. This must 93 be left when nothing is being done with it. This must
@@ -280,7 +281,7 @@ adjust_window_count (struct window *w, int arg)
280 if (BUFFERP (w->buffer)) 281 if (BUFFERP (w->buffer))
281 { 282 {
282 struct buffer *b = XBUFFER (w->buffer); 283 struct buffer *b = XBUFFER (w->buffer);
283 284
284 if (b->base_buffer) 285 if (b->base_buffer)
285 b = b->base_buffer; 286 b = b->base_buffer;
286 b->window_count += arg; 287 b->window_count += arg;
@@ -487,7 +488,6 @@ static Lisp_Object
487select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) 488select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap)
488{ 489{
489 register struct window *w; 490 register struct window *w;
490 register struct window *ow;
491 struct frame *sf; 491 struct frame *sf;
492 492
493 CHECK_LIVE_WINDOW (window); 493 CHECK_LIVE_WINDOW (window);
@@ -523,12 +523,25 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap)
523 else 523 else
524 fset_selected_window (sf, window); 524 fset_selected_window (sf, window);
525 525
526 select_window_1 (window, inhibit_point_swap);
527
528 bset_last_selected_window (XBUFFER (w->buffer), window);
529 windows_or_buffers_changed++;
530 return window;
531}
532
533/* Select window with a minimum of fuss, i.e. don't record the change anywhere
534 (not even for redisplay's benefit), and assume that the window's frame is
535 already selected. */
536static void
537select_window_1 (Lisp_Object window, bool inhibit_point_swap)
538{
526 /* Store the old selected window's buffer's point in pointm of the old 539 /* Store the old selected window's buffer's point in pointm of the old
527 selected window. It belongs to that window, and when the window is 540 selected window. It belongs to that window, and when the window is
528 not selected, must be in the window. */ 541 not selected, must be in the window. */
529 if (!inhibit_point_swap) 542 if (!inhibit_point_swap)
530 { 543 {
531 ow = XWINDOW (selected_window); 544 struct window *ow = XWINDOW (selected_window);
532 if (! NILP (ow->buffer)) 545 if (! NILP (ow->buffer))
533 set_marker_both (ow->pointm, ow->buffer, 546 set_marker_both (ow->pointm, ow->buffer,
534 BUF_PT (XBUFFER (ow->buffer)), 547 BUF_PT (XBUFFER (ow->buffer)),
@@ -536,7 +549,6 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap)
536 } 549 }
537 550
538 selected_window = window; 551 selected_window = window;
539 bset_last_selected_window (XBUFFER (w->buffer), window);
540 552
541 /* Go to the point recorded in the window. 553 /* Go to the point recorded in the window.
542 This is important when the buffer is in more 554 This is important when the buffer is in more
@@ -544,7 +556,7 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap)
544 redisplay_window has altered point after scrolling, 556 redisplay_window has altered point after scrolling,
545 because it makes the change only in the window. */ 557 because it makes the change only in the window. */
546 { 558 {
547 register ptrdiff_t new_point = marker_position (w->pointm); 559 register ptrdiff_t new_point = marker_position (XWINDOW (window)->pointm);
548 if (new_point < BEGV) 560 if (new_point < BEGV)
549 SET_PT (BEGV); 561 SET_PT (BEGV);
550 else if (new_point > ZV) 562 else if (new_point > ZV)
@@ -552,15 +564,14 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap)
552 else 564 else
553 SET_PT (new_point); 565 SET_PT (new_point);
554 } 566 }
555
556 windows_or_buffers_changed++;
557 return window;
558} 567}
559 568
560DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0, 569DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0,
561 doc: /* Select WINDOW. Most editing will apply to WINDOW's buffer. 570 doc: /* Select WINDOW which must be a live window.
562Also make WINDOW's buffer current and make WINDOW the frame's selected 571Also make WINDOW's frame the selected frame and WINDOW that frame's
563window. Return WINDOW. 572selected window. In addition, make WINDOW's buffer current and set that
573buffer's value of `point' to the value of WINDOW's `window-point'.
574Return WINDOW.
564 575
565Optional second arg NORECORD non-nil means do not put this buffer at the 576Optional second arg NORECORD non-nil means do not put this buffer at the
566front of the buffer list and do not make this window the most recently 577front of the buffer list and do not make this window the most recently
@@ -791,12 +802,12 @@ window_body_cols (struct window *w)
791 occupies one column only. */ 802 occupies one column only. */
792 width -= 1; 803 width -= 1;
793 804
805 /* Display margins cannot be used for normal text. */
806 width -= WINDOW_LEFT_MARGIN_COLS (w) + WINDOW_RIGHT_MARGIN_COLS (w);
807
794 if (FRAME_WINDOW_P (f)) 808 if (FRAME_WINDOW_P (f))
795 /* On window-systems, fringes and display margins cannot be 809 /* On window-systems, fringes cannot be used for normal text. */
796 used for normal text. */ 810 width -= WINDOW_FRINGE_COLS (w);
797 width -= (WINDOW_FRINGE_COLS (w)
798 + WINDOW_LEFT_MARGIN_COLS (w)
799 + WINDOW_RIGHT_MARGIN_COLS (w));
800 811
801 return width; 812 return width;
802} 813}
diff --git a/src/window.h b/src/window.h
index f4f42a25af4..1ebd35a7c64 100644
--- a/src/window.h
+++ b/src/window.h
@@ -1,6 +1,6 @@
1/* Window definitions for GNU Emacs. 1/* Window definitions for GNU Emacs.
2 Copyright (C) 1985-1986, 1993, 1995, 1997-2012 2 Copyright (C) 1985-1986, 1993, 1995, 1997-2013 Free Software
3 Free Software Foundation, Inc. 3 Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -261,7 +261,7 @@ struct window
261 EMACS_INT last_overlay_modified; 261 EMACS_INT last_overlay_modified;
262 262
263 /* Value of point at that time. Since this is a position in a buffer, 263 /* Value of point at that time. Since this is a position in a buffer,
264 it should be positive. */ 264 it should be positive. */
265 ptrdiff_t last_point; 265 ptrdiff_t last_point;
266 266
267 /* Scaling factor for the glyph_matrix size calculation in this window. 267 /* Scaling factor for the glyph_matrix size calculation in this window.
@@ -290,7 +290,7 @@ struct window
290 /* Non-zero if this window is a minibuffer window. */ 290 /* Non-zero if this window is a minibuffer window. */
291 unsigned mini : 1; 291 unsigned mini : 1;
292 292
293 /* Non-zero means must regenerate mode line of this window */ 293 /* Non-zero means must regenerate mode line of this window. */
294 unsigned update_mode_line : 1; 294 unsigned update_mode_line : 1;
295 295
296 /* Non-nil if the buffer was "modified" when the window 296 /* Non-nil if the buffer was "modified" when the window
@@ -343,7 +343,7 @@ struct window
343 y-direction (smooth scrolling). */ 343 y-direction (smooth scrolling). */
344 int vscroll; 344 int vscroll;
345 345
346 /* Z_BYTE - the buffer position of the last glyph in the current matrix of W. 346 /* Z_BYTE - Buffer position of the last glyph in the current matrix of W.
347 Should be nonnegative, and only valid if window_end_valid is not nil. */ 347 Should be nonnegative, and only valid if window_end_valid is not nil. */
348 ptrdiff_t window_end_bytepos; 348 ptrdiff_t window_end_bytepos;
349}; 349};
@@ -934,7 +934,7 @@ extern EMACS_INT minibuf_level;
934extern int update_mode_lines; 934extern int update_mode_lines;
935 935
936/* Nonzero if window sizes or contents have changed since last 936/* Nonzero if window sizes or contents have changed since last
937 redisplay that finished */ 937 redisplay that finished. */
938 938
939extern int windows_or_buffers_changed; 939extern int windows_or_buffers_changed;
940 940
diff --git a/src/xdisp.c b/src/xdisp.c
index f7fc75f8c25..b75362b1446 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -1,6 +1,7 @@
1/* Display generation from window structure and buffer text. 1/* Display generation from window structure and buffer text.
2 2
3Copyright (C) 1985-1988, 1993-1995, 1997-2012 Free Software Foundation, Inc. 3Copyright (C) 1985-1988, 1993-1995, 1997-2013 Free Software Foundation,
4Inc.
4 5
5This file is part of GNU Emacs. 6This file is part of GNU Emacs.
6 7
@@ -869,7 +870,6 @@ static void push_it (struct it *, struct text_pos *);
869static void iterate_out_of_display_property (struct it *); 870static void iterate_out_of_display_property (struct it *);
870static void pop_it (struct it *); 871static void pop_it (struct it *);
871static void sync_frame_with_window_matrix_rows (struct window *); 872static void sync_frame_with_window_matrix_rows (struct window *);
872static void select_frame_for_redisplay (Lisp_Object);
873static void redisplay_internal (void); 873static void redisplay_internal (void);
874static int echo_area_display (int); 874static int echo_area_display (int);
875static void redisplay_windows (Lisp_Object); 875static void redisplay_windows (Lisp_Object);
@@ -1330,7 +1330,7 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y,
1330 BVAR (current_buffer, header_line_format)); 1330 BVAR (current_buffer, header_line_format));
1331 1331
1332 start_display (&it, w, top); 1332 start_display (&it, w, top);
1333 move_it_to (&it, charpos, -1, it.last_visible_y-1, -1, 1333 move_it_to (&it, charpos, -1, it.last_visible_y - 1, -1,
1334 (charpos >= 0 ? MOVE_TO_POS : 0) | MOVE_TO_Y); 1334 (charpos >= 0 ? MOVE_TO_POS : 0) | MOVE_TO_Y);
1335 1335
1336 if (charpos >= 0 1336 if (charpos >= 0
@@ -1338,7 +1338,7 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y,
1338 && IT_CHARPOS (it) >= charpos) 1338 && IT_CHARPOS (it) >= charpos)
1339 /* When scanning backwards under bidi iteration, move_it_to 1339 /* When scanning backwards under bidi iteration, move_it_to
1340 stops at or _before_ CHARPOS, because it stops at or to 1340 stops at or _before_ CHARPOS, because it stops at or to
1341 the _right_ of the character at CHARPOS. */ 1341 the _right_ of the character at CHARPOS. */
1342 || (it.bidi_p && it.bidi_it.scan_dir == -1 1342 || (it.bidi_p && it.bidi_it.scan_dir == -1
1343 && IT_CHARPOS (it) <= charpos))) 1343 && IT_CHARPOS (it) <= charpos)))
1344 { 1344 {
@@ -9398,7 +9398,8 @@ message_dolog (const char *m, ptrdiff_t nbytes, int nlflag, int multibyte)
9398 int old_windows_or_buffers_changed = windows_or_buffers_changed; 9398 int old_windows_or_buffers_changed = windows_or_buffers_changed;
9399 ptrdiff_t point_at_end = 0; 9399 ptrdiff_t point_at_end = 0;
9400 ptrdiff_t zv_at_end = 0; 9400 ptrdiff_t zv_at_end = 0;
9401 Lisp_Object old_deactivate_mark, tem; 9401 Lisp_Object old_deactivate_mark;
9402 bool shown;
9402 struct gcpro gcpro1; 9403 struct gcpro gcpro1;
9403 9404
9404 old_deactivate_mark = Vdeactivate_mark; 9405 old_deactivate_mark = Vdeactivate_mark;
@@ -9540,9 +9541,9 @@ message_dolog (const char *m, ptrdiff_t nbytes, int nlflag, int multibyte)
9540 unchain_marker (XMARKER (oldbegv)); 9541 unchain_marker (XMARKER (oldbegv));
9541 unchain_marker (XMARKER (oldzv)); 9542 unchain_marker (XMARKER (oldzv));
9542 9543
9543 tem = Fget_buffer_window (Fcurrent_buffer (), Qt); 9544 shown = buffer_window_count (current_buffer) > 0;
9544 set_buffer_internal (oldbuf); 9545 set_buffer_internal (oldbuf);
9545 if (NILP (tem)) 9546 if (!shown)
9546 windows_or_buffers_changed = old_windows_or_buffers_changed; 9547 windows_or_buffers_changed = old_windows_or_buffers_changed;
9547 message_log_need_newline = !nlflag; 9548 message_log_need_newline = !nlflag;
9548 Vdeactivate_mark = old_deactivate_mark; 9549 Vdeactivate_mark = old_deactivate_mark;
@@ -12952,47 +12953,6 @@ reconsider_clip_changes (struct window *w, struct buffer *b)
12952} 12953}
12953 12954
12954 12955
12955/* Select FRAME to forward the values of frame-local variables into C
12956 variables so that the redisplay routines can access those values
12957 directly. */
12958
12959static void
12960select_frame_for_redisplay (Lisp_Object frame)
12961{
12962 Lisp_Object tail, tem;
12963 Lisp_Object old = selected_frame;
12964 struct Lisp_Symbol *sym;
12965
12966 eassert (FRAMEP (frame) && FRAME_LIVE_P (XFRAME (frame)));
12967
12968 selected_frame = frame;
12969 selected_window = XFRAME (frame)->selected_window;
12970
12971 do {
12972 for (tail = XFRAME (frame)->param_alist;
12973 CONSP (tail); tail = XCDR (tail))
12974 if (CONSP (XCAR (tail))
12975 && (tem = XCAR (XCAR (tail)),
12976 SYMBOLP (tem))
12977 && (sym = indirect_variable (XSYMBOL (tem)),
12978 sym->redirect == SYMBOL_LOCALIZED)
12979 && sym->val.blv->frame_local)
12980 /* Use find_symbol_value rather than Fsymbol_value
12981 to avoid an error if it is void. */
12982 find_symbol_value (tem);
12983 } while (!EQ (frame, old) && (frame = old, 1));
12984}
12985
12986/* Make sure that previously selected OLD_FRAME is selected unless it has been
12987 deleted (by an X connection failure during redisplay, for example). */
12988
12989static void
12990ensure_selected_frame (Lisp_Object frame)
12991{
12992 if (!EQ (frame, selected_frame) && FRAME_LIVE_P (XFRAME (frame)))
12993 select_frame_for_redisplay (frame);
12994}
12995
12996#define STOP_POLLING \ 12956#define STOP_POLLING \
12997do { if (! polling_stopped_here) stop_polling (); \ 12957do { if (! polling_stopped_here) stop_polling (); \
12998 polling_stopped_here = 1; } while (0) 12958 polling_stopped_here = 1; } while (0)
@@ -13018,7 +12978,7 @@ redisplay_internal (void)
13018 ptrdiff_t count, count1; 12978 ptrdiff_t count, count1;
13019 struct frame *sf; 12979 struct frame *sf;
13020 int polling_stopped_here = 0; 12980 int polling_stopped_here = 0;
13021 Lisp_Object tail, frame, old_frame = selected_frame; 12981 Lisp_Object tail, frame;
13022 struct backtrace backtrace; 12982 struct backtrace backtrace;
13023 12983
13024 /* Non-zero means redisplay has to consider all windows on all 12984 /* Non-zero means redisplay has to consider all windows on all
@@ -13077,12 +13037,6 @@ redisplay_internal (void)
13077 /* Remember the currently selected window. */ 13037 /* Remember the currently selected window. */
13078 sw = w; 13038 sw = w;
13079 13039
13080 /* When running redisplay, we play a bit fast-and-loose and allow e.g.
13081 selected_frame and selected_window to be temporarily out-of-sync so
13082 when we come back here via `goto retry', we need to resync because we
13083 may need to run Elisp code (via prepare_menu_bars). */
13084 ensure_selected_frame (old_frame);
13085
13086 pending = 0; 13040 pending = 0;
13087 reconsider_clip_changes (w, current_buffer); 13041 reconsider_clip_changes (w, current_buffer);
13088 last_escape_glyph_frame = NULL; 13042 last_escape_glyph_frame = NULL;
@@ -13490,11 +13444,6 @@ redisplay_internal (void)
13490 13444
13491 if (FRAME_WINDOW_P (f) || FRAME_TERMCAP_P (f) || f == sf) 13445 if (FRAME_WINDOW_P (f) || FRAME_TERMCAP_P (f) || f == sf)
13492 { 13446 {
13493 if (! EQ (frame, selected_frame))
13494 /* Select the frame, for the sake of frame-local
13495 variables. */
13496 select_frame_for_redisplay (frame);
13497
13498 /* Mark all the scroll bars to be removed; we'll redeem 13447 /* Mark all the scroll bars to be removed; we'll redeem
13499 the ones we want when we redisplay their windows. */ 13448 the ones we want when we redisplay their windows. */
13500 if (FRAME_TERMINAL (f)->condemn_scroll_bars_hook) 13449 if (FRAME_TERMINAL (f)->condemn_scroll_bars_hook)
@@ -13544,10 +13493,6 @@ redisplay_internal (void)
13544 } 13493 }
13545 } 13494 }
13546 13495
13547 /* We played a bit fast-and-loose above and allowed selected_frame
13548 and selected_window to be temporarily out-of-sync but let's make
13549 sure this stays contained. */
13550 ensure_selected_frame (old_frame);
13551 eassert (EQ (XFRAME (selected_frame)->selected_window, selected_window)); 13496 eassert (EQ (XFRAME (selected_frame)->selected_window, selected_window));
13552 13497
13553 if (!pending) 13498 if (!pending)
@@ -13773,7 +13718,6 @@ static Lisp_Object
13773unwind_redisplay (Lisp_Object old_frame) 13718unwind_redisplay (Lisp_Object old_frame)
13774{ 13719{
13775 redisplaying_p = 0; 13720 redisplaying_p = 0;
13776 ensure_selected_frame (old_frame);
13777 return Qnil; 13721 return Qnil;
13778} 13722}
13779 13723
@@ -13790,8 +13734,8 @@ mark_window_display_accurate_1 (struct window *w, int accurate_p)
13790 { 13734 {
13791 struct buffer *b = XBUFFER (w->buffer); 13735 struct buffer *b = XBUFFER (w->buffer);
13792 13736
13793 w->last_modified = accurate_p ? BUF_MODIFF(b) : 0; 13737 w->last_modified = accurate_p ? BUF_MODIFF (b) : 0;
13794 w->last_overlay_modified = accurate_p ? BUF_OVERLAY_MODIFF(b) : 0; 13738 w->last_overlay_modified = accurate_p ? BUF_OVERLAY_MODIFF (b) : 0;
13795 w->last_had_star 13739 w->last_had_star
13796 = BUF_MODIFF (b) > BUF_SAVE_MODIFF (b); 13740 = BUF_MODIFF (b) > BUF_SAVE_MODIFF (b);
13797 13741
@@ -14246,7 +14190,12 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
14246 CHARPOS is zero or negative. */ 14190 CHARPOS is zero or negative. */
14247 int empty_line_p = 14191 int empty_line_p =
14248 (row->reversed_p ? glyph > glyphs_end : glyph < glyphs_end) 14192 (row->reversed_p ? glyph > glyphs_end : glyph < glyphs_end)
14249 && INTEGERP (glyph->object) && glyph->charpos > 0; 14193 && INTEGERP (glyph->object) && glyph->charpos > 0
14194 /* On a TTY, continued and truncated rows also have a glyph at
14195 their end whose OBJECT is zero and whose CHARPOS is
14196 positive (the continuation and truncation glyphs), but such
14197 rows are obviously not "empty". */
14198 && !(row->continued_p || row->truncated_on_right_p);
14250 14199
14251 if (row->ends_in_ellipsis_p && pos_after == last_pos) 14200 if (row->ends_in_ellipsis_p && pos_after == last_pos)
14252 { 14201 {
@@ -15706,7 +15655,6 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15706 /* Some people insist on not letting point enter the scroll 15655 /* Some people insist on not letting point enter the scroll
15707 margin, even though this part handles windows that didn't 15656 margin, even though this part handles windows that didn't
15708 scroll at all. */ 15657 scroll at all. */
15709 struct frame *f = XFRAME (w->frame);
15710 int margin = min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4); 15658 int margin = min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4);
15711 int pixel_margin = margin * FRAME_LINE_HEIGHT (f); 15659 int pixel_margin = margin * FRAME_LINE_HEIGHT (f);
15712 bool header_line = WINDOW_WANTS_HEADER_LINE_P (w); 15660 bool header_line = WINDOW_WANTS_HEADER_LINE_P (w);
@@ -17977,18 +17925,23 @@ dump_glyph_matrix (struct glyph_matrix *matrix, int glyphs)
17977void 17925void
17978dump_glyph (struct glyph_row *row, struct glyph *glyph, int area) 17926dump_glyph (struct glyph_row *row, struct glyph *glyph, int area)
17979{ 17927{
17980 if (glyph->type == CHAR_GLYPH) 17928 if (glyph->type == CHAR_GLYPH
17929 || glyph->type == GLYPHLESS_GLYPH)
17981 { 17930 {
17982 fprintf (stderr, 17931 fprintf (stderr,
17983 " %5td %4c %6"pI"d %c %3d 0x%05x %c %4d %1.1d%1.1d\n", 17932 " %5"pD"d %c %9"pI"d %c %3d 0x%06x %c %4d %1.1d%1.1d\n",
17984 glyph - row->glyphs[TEXT_AREA], 17933 glyph - row->glyphs[TEXT_AREA],
17985 'C', 17934 (glyph->type == CHAR_GLYPH
17935 ? 'C'
17936 : 'G'),
17986 glyph->charpos, 17937 glyph->charpos,
17987 (BUFFERP (glyph->object) 17938 (BUFFERP (glyph->object)
17988 ? 'B' 17939 ? 'B'
17989 : (STRINGP (glyph->object) 17940 : (STRINGP (glyph->object)
17990 ? 'S' 17941 ? 'S'
17991 : '-')), 17942 : (INTEGERP (glyph->object)
17943 ? '0'
17944 : '-'))),
17992 glyph->pixel_width, 17945 glyph->pixel_width,
17993 glyph->u.ch, 17946 glyph->u.ch,
17994 (glyph->u.ch < 0x80 && glyph->u.ch >= ' ' 17947 (glyph->u.ch < 0x80 && glyph->u.ch >= ' '
@@ -18001,7 +17954,7 @@ dump_glyph (struct glyph_row *row, struct glyph *glyph, int area)
18001 else if (glyph->type == STRETCH_GLYPH) 17954 else if (glyph->type == STRETCH_GLYPH)
18002 { 17955 {
18003 fprintf (stderr, 17956 fprintf (stderr,
18004 " %5td %4c %6"pI"d %c %3d 0x%05x %c %4d %1.1d%1.1d\n", 17957 " %5"pD"d %c %9"pI"d %c %3d 0x%06x %c %4d %1.1d%1.1d\n",
18005 glyph - row->glyphs[TEXT_AREA], 17958 glyph - row->glyphs[TEXT_AREA],
18006 'S', 17959 'S',
18007 glyph->charpos, 17960 glyph->charpos,
@@ -18009,10 +17962,12 @@ dump_glyph (struct glyph_row *row, struct glyph *glyph, int area)
18009 ? 'B' 17962 ? 'B'
18010 : (STRINGP (glyph->object) 17963 : (STRINGP (glyph->object)
18011 ? 'S' 17964 ? 'S'
18012 : '-')), 17965 : (INTEGERP (glyph->object)
17966 ? '0'
17967 : '-'))),
18013 glyph->pixel_width, 17968 glyph->pixel_width,
18014 0, 17969 0,
18015 '.', 17970 ' ',
18016 glyph->face_id, 17971 glyph->face_id,
18017 glyph->left_box_line_p, 17972 glyph->left_box_line_p,
18018 glyph->right_box_line_p); 17973 glyph->right_box_line_p);
@@ -18020,7 +17975,7 @@ dump_glyph (struct glyph_row *row, struct glyph *glyph, int area)
18020 else if (glyph->type == IMAGE_GLYPH) 17975 else if (glyph->type == IMAGE_GLYPH)
18021 { 17976 {
18022 fprintf (stderr, 17977 fprintf (stderr,
18023 " %5td %4c %6"pI"d %c %3d 0x%05x %c %4d %1.1d%1.1d\n", 17978 " %5"pD"d %c %9"pI"d %c %3d 0x%06x %c %4d %1.1d%1.1d\n",
18024 glyph - row->glyphs[TEXT_AREA], 17979 glyph - row->glyphs[TEXT_AREA],
18025 'I', 17980 'I',
18026 glyph->charpos, 17981 glyph->charpos,
@@ -18028,7 +17983,9 @@ dump_glyph (struct glyph_row *row, struct glyph *glyph, int area)
18028 ? 'B' 17983 ? 'B'
18029 : (STRINGP (glyph->object) 17984 : (STRINGP (glyph->object)
18030 ? 'S' 17985 ? 'S'
18031 : '-')), 17986 : (INTEGERP (glyph->object)
17987 ? '0'
17988 : '-'))),
18032 glyph->pixel_width, 17989 glyph->pixel_width,
18033 glyph->u.img_id, 17990 glyph->u.img_id,
18034 '.', 17991 '.',
@@ -18039,7 +17996,7 @@ dump_glyph (struct glyph_row *row, struct glyph *glyph, int area)
18039 else if (glyph->type == COMPOSITE_GLYPH) 17996 else if (glyph->type == COMPOSITE_GLYPH)
18040 { 17997 {
18041 fprintf (stderr, 17998 fprintf (stderr,
18042 " %5td %4c %6"pI"d %c %3d 0x%05x", 17999 " %5"pD"d %c %9"pI"d %c %3d 0x%06x",
18043 glyph - row->glyphs[TEXT_AREA], 18000 glyph - row->glyphs[TEXT_AREA],
18044 '+', 18001 '+',
18045 glyph->charpos, 18002 glyph->charpos,
@@ -18047,7 +18004,9 @@ dump_glyph (struct glyph_row *row, struct glyph *glyph, int area)
18047 ? 'B' 18004 ? 'B'
18048 : (STRINGP (glyph->object) 18005 : (STRINGP (glyph->object)
18049 ? 'S' 18006 ? 'S'
18050 : '-')), 18007 : (INTEGERP (glyph->object)
18008 ? '0'
18009 : '-'))),
18051 glyph->pixel_width, 18010 glyph->pixel_width,
18052 glyph->u.cmp.id); 18011 glyph->u.cmp.id);
18053 if (glyph->u.cmp.automatic) 18012 if (glyph->u.cmp.automatic)
@@ -18072,10 +18031,10 @@ dump_glyph_row (struct glyph_row *row, int vpos, int glyphs)
18072{ 18031{
18073 if (glyphs != 1) 18032 if (glyphs != 1)
18074 { 18033 {
18075 fprintf (stderr, "Row Start End Used oE><\\CTZFesm X Y W H V A P\n"); 18034 fprintf (stderr, "Row Start End Used oE><\\CTZFesm X Y W H V A P\n");
18076 fprintf (stderr, "======================================================================\n"); 18035 fprintf (stderr, "==============================================================================\n");
18077 18036
18078 fprintf (stderr, "%3d %5"pI"d %5"pI"d %4d %1.1d%1.1d%1.1d%1.1d\ 18037 fprintf (stderr, "%3d %9"pI"d %9"pI"d %4d %1.1d%1.1d%1.1d%1.1d\
18079%1.1d%1.1d%1.1d%1.1d%1.1d%1.1d%1.1d%1.1d %4d %4d %4d %4d %4d %4d %4d\n", 18038%1.1d%1.1d%1.1d%1.1d%1.1d%1.1d%1.1d%1.1d %4d %4d %4d %4d %4d %4d %4d\n",
18080 vpos, 18039 vpos,
18081 MATRIX_ROW_START_CHARPOS (row), 18040 MATRIX_ROW_START_CHARPOS (row),
@@ -18100,13 +18059,14 @@ dump_glyph_row (struct glyph_row *row, int vpos, int glyphs)
18100 row->visible_height, 18059 row->visible_height,
18101 row->ascent, 18060 row->ascent,
18102 row->phys_ascent); 18061 row->phys_ascent);
18103 fprintf (stderr, "%9"pD"d %5"pD"d\t%5d\n", row->start.overlay_string_index, 18062 /* The next 3 lines should align to "Start" in the header. */
18063 fprintf (stderr, " %9"pD"d %9"pD"d\t%5d\n", row->start.overlay_string_index,
18104 row->end.overlay_string_index, 18064 row->end.overlay_string_index,
18105 row->continuation_lines_width); 18065 row->continuation_lines_width);
18106 fprintf (stderr, "%9"pI"d %5"pI"d\n", 18066 fprintf (stderr, " %9"pI"d %9"pI"d\n",
18107 CHARPOS (row->start.string_pos), 18067 CHARPOS (row->start.string_pos),
18108 CHARPOS (row->end.string_pos)); 18068 CHARPOS (row->end.string_pos));
18109 fprintf (stderr, "%9d %5d\n", row->start.dpvec_index, 18069 fprintf (stderr, " %9d %9d\n", row->start.dpvec_index,
18110 row->end.dpvec_index); 18070 row->end.dpvec_index);
18111 } 18071 }
18112 18072
@@ -18124,7 +18084,7 @@ dump_glyph_row (struct glyph_row *row, int vpos, int glyphs)
18124 ++glyph_end; 18084 ++glyph_end;
18125 18085
18126 if (glyph < glyph_end) 18086 if (glyph < glyph_end)
18127 fprintf (stderr, " Glyph Type Pos O W Code C Face LR\n"); 18087 fprintf (stderr, " Glyph# Type Pos O W Code C Face LR\n");
18128 18088
18129 for (; glyph < glyph_end; ++glyph) 18089 for (; glyph < glyph_end; ++glyph)
18130 dump_glyph (row, glyph, area); 18090 dump_glyph (row, glyph, area);
@@ -18136,15 +18096,24 @@ dump_glyph_row (struct glyph_row *row, int vpos, int glyphs)
18136 18096
18137 for (area = LEFT_MARGIN_AREA; area < LAST_AREA; ++area) 18097 for (area = LEFT_MARGIN_AREA; area < LAST_AREA; ++area)
18138 { 18098 {
18139 char *s = alloca (row->used[area] + 1); 18099 char *s = alloca (row->used[area] + 4);
18140 int i; 18100 int i;
18141 18101
18142 for (i = 0; i < row->used[area]; ++i) 18102 for (i = 0; i < row->used[area]; ++i)
18143 { 18103 {
18144 struct glyph *glyph = row->glyphs[area] + i; 18104 struct glyph *glyph = row->glyphs[area] + i;
18145 if (glyph->type == CHAR_GLYPH 18105 if (i == row->used[area] - 1
18146 && glyph->u.ch < 0x80 18106 && area == TEXT_AREA
18147 && glyph->u.ch >= ' ') 18107 && INTEGERP (glyph->object)
18108 && glyph->type == CHAR_GLYPH
18109 && glyph->u.ch == ' ')
18110 {
18111 strcpy (&s[i], "[\\n]");
18112 i += 4;
18113 }
18114 else if (glyph->type == CHAR_GLYPH
18115 && glyph->u.ch < 0x80
18116 && glyph->u.ch >= ' ')
18148 s[i] = glyph->u.ch; 18117 s[i] = glyph->u.ch;
18149 else 18118 else
18150 s[i] = '.'; 18119 s[i] = '.';
@@ -20360,8 +20329,11 @@ display_mode_lines (struct window *w)
20360 Lisp_Object old_frame_selected_window = XFRAME (new_frame)->selected_window; 20329 Lisp_Object old_frame_selected_window = XFRAME (new_frame)->selected_window;
20361 int n = 0; 20330 int n = 0;
20362 20331
20363 selected_frame = w->frame; 20332 selected_frame = new_frame;
20333 /* FIXME: If we were to allow the mode-line's computation changing the buffer
20334 or window's point, then we'd need select_window_1 here as well. */
20364 XSETWINDOW (selected_window, w); 20335 XSETWINDOW (selected_window, w);
20336 XFRAME (new_frame)->selected_window = selected_window;
20365 20337
20366 /* These will be set while the mode line specs are processed. */ 20338 /* These will be set while the mode line specs are processed. */
20367 line_number_displayed = 0; 20339 line_number_displayed = 0;
diff --git a/src/xfaces.c b/src/xfaces.c
index 1e27d5cc043..ed2895c014c 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -1,6 +1,6 @@
1/* xfaces.c -- "Face" primitives. 1/* xfaces.c -- "Face" primitives.
2 2
3Copyright (C) 1993-1994, 1998-2012 Free Software Foundation, Inc. 3Copyright (C) 1993-1994, 1998-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/xfns.c b/src/xfns.c
index 7e832c3a95f..315d5093716 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1,6 +1,6 @@
1/* Functions for the X window system. 1/* Functions for the X window system.
2 2
3Copyright (C) 1989, 1992-2012 Free Software Foundation, Inc. 3Copyright (C) 1989, 1992-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/xfont.c b/src/xfont.c
index 2d493088b0b..9978aba76de 100644
--- a/src/xfont.c
+++ b/src/xfont.c
@@ -1,5 +1,5 @@
1/* xfont.c -- X core font driver. 1/* xfont.c -- X core font driver.
2 Copyright (C) 2006-2012 Free Software Foundation, Inc. 2 Copyright (C) 2006-2013 Free Software Foundation, Inc.
3 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 3 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
4 National Institute of Advanced Industrial Science and Technology (AIST) 4 National Institute of Advanced Industrial Science and Technology (AIST)
5 Registration Number H13PRO009 5 Registration Number H13PRO009
diff --git a/src/xftfont.c b/src/xftfont.c
index 181a1da9b38..166a70acd85 100644
--- a/src/xftfont.c
+++ b/src/xftfont.c
@@ -1,5 +1,5 @@
1/* xftfont.c -- XFT font driver. 1/* xftfont.c -- XFT font driver.
2 Copyright (C) 2006-2012 Free Software Foundation, Inc. 2 Copyright (C) 2006-2013 Free Software Foundation, Inc.
3 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 3 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
4 National Institute of Advanced Industrial Science and Technology (AIST) 4 National Institute of Advanced Industrial Science and Technology (AIST)
5 Registration Number H13PRO009 5 Registration Number H13PRO009
diff --git a/src/xgselect.c b/src/xgselect.c
index c161564a322..db7dce10ad0 100644
--- a/src/xgselect.c
+++ b/src/xgselect.c
@@ -1,6 +1,6 @@
1/* Function for handling the GLib event loop. 1/* Function for handling the GLib event loop.
2 2
3Copyright (C) 2009-2012 Free Software Foundation, Inc. 3Copyright (C) 2009-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/xgselect.h b/src/xgselect.h
index 5509e23c5c0..f142e85d877 100644
--- a/src/xgselect.h
+++ b/src/xgselect.h
@@ -1,6 +1,6 @@
1/* Header for xg_select. 1/* Header for xg_select.
2 2
3Copyright (C) 2009-2012 Free Software Foundation, Inc. 3Copyright (C) 2009-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/xmenu.c b/src/xmenu.c
index b585df2125b..3d76070c336 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -1,7 +1,7 @@
1/* X Communication module for terminals which understand the X protocol. 1/* X Communication module for terminals which understand the X protocol.
2 2
3Copyright (C) 1986, 1988, 1993-1994, 1996, 1999-2012 3Copyright (C) 1986, 1988, 1993-1994, 1996, 1999-2013 Free Software
4 Free Software Foundation, Inc. 4Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
diff --git a/src/xml.c b/src/xml.c
index a0c4fe17fc4..5939c58a564 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -1,5 +1,5 @@
1/* Interface to libxml2. 1/* Interface to libxml2.
2 Copyright (C) 2010-2012 Free Software Foundation, Inc. 2 Copyright (C) 2010-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/xrdb.c b/src/xrdb.c
index 59b0876ebf8..c25c25d6f33 100644
--- a/src/xrdb.c
+++ b/src/xrdb.c
@@ -1,5 +1,6 @@
1/* Deal with the X Resource Manager. 1/* Deal with the X Resource Manager.
2 Copyright (C) 1990, 1993-1994, 2000-2012 Free Software Foundation, Inc. 2 Copyright (C) 1990, 1993-1994, 2000-2013 Free Software Foundation,
3 Inc.
3 4
4Author: Joseph Arceneaux 5Author: Joseph Arceneaux
5Created: 4/90 6Created: 4/90
diff --git a/src/xselect.c b/src/xselect.c
index 64c64fa0c76..f43efab827b 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -1,5 +1,5 @@
1/* X Selection processing for Emacs. 1/* X Selection processing for Emacs.
2 Copyright (C) 1993-1997, 2000-2012 Free Software Foundation, Inc. 2 Copyright (C) 1993-1997, 2000-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/src/xsettings.c b/src/xsettings.c
index d23070791d8..576a5032eac 100644
--- a/src/xsettings.c
+++ b/src/xsettings.c
@@ -1,6 +1,6 @@
1/* Functions for handling font and other changes dynamically. 1/* Functions for handling font and other changes dynamically.
2 2
3Copyright (C) 2009-2012 Free Software Foundation, Inc. 3Copyright (C) 2009-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/xsettings.h b/src/xsettings.h
index 10dc7ef926a..e3738c593bd 100644
--- a/src/xsettings.h
+++ b/src/xsettings.h
@@ -1,6 +1,6 @@
1/* Functions for handle font changes dynamically. 1/* Functions for handle font changes dynamically.
2 2
3Copyright (C) 2009-2012 Free Software Foundation, Inc. 3Copyright (C) 2009-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/src/xsmfns.c b/src/xsmfns.c
index 289aac8492b..fe2dfbaf83e 100644
--- a/src/xsmfns.c
+++ b/src/xsmfns.c
@@ -1,7 +1,7 @@
1/* Session management module for systems which understand the X Session 1/* Session management module for systems which understand the X Session
2 management protocol. 2 management protocol.
3 3
4Copyright (C) 2002-2012 Free Software Foundation, Inc. 4Copyright (C) 2002-2013 Free Software Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
diff --git a/src/xterm.c b/src/xterm.c
index 374b6287458..f63f10566f6 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1,6 +1,6 @@
1/* X Communication module for terminals which understand the X protocol. 1/* X Communication module for terminals which understand the X protocol.
2 2
3Copyright (C) 1989, 1993-2012 Free Software Foundation, Inc. 3Copyright (C) 1989, 1993-2013 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -2236,8 +2236,7 @@ x_draw_image_foreground (struct glyph_string *s)
2236 nothing here for mouse-face. */ 2236 nothing here for mouse-face. */
2237 if (s->hl == DRAW_CURSOR) 2237 if (s->hl == DRAW_CURSOR)
2238 { 2238 {
2239 int relief = s->img->relief; 2239 int relief = eabs (s->img->relief);
2240 if (relief < 0) relief = -relief;
2241 XDrawRectangle (s->display, s->window, s->gc, 2240 XDrawRectangle (s->display, s->window, s->gc,
2242 x - relief, y - relief, 2241 x - relief, y - relief,
2243 s->slice.width + relief*2 - 1, 2242 s->slice.width + relief*2 - 1,
@@ -2368,8 +2367,7 @@ x_draw_image_foreground_1 (struct glyph_string *s, Pixmap pixmap)
2368 nothing here for mouse-face. */ 2367 nothing here for mouse-face. */
2369 if (s->hl == DRAW_CURSOR) 2368 if (s->hl == DRAW_CURSOR)
2370 { 2369 {
2371 int r = s->img->relief; 2370 int r = eabs (s->img->relief);
2372 if (r < 0) r = -r;
2373 XDrawRectangle (s->display, s->window, s->gc, x - r, y - r, 2371 XDrawRectangle (s->display, s->window, s->gc, x - r, y - r,
2374 s->slice.width + r*2 - 1, 2372 s->slice.width + r*2 - 1,
2375 s->slice.height + r*2 - 1); 2373 s->slice.height + r*2 - 1);
@@ -2633,14 +2631,14 @@ x_draw_stretch_glyph_string (struct glyph_string *s)
2633static void 2631static void
2634x_draw_underwave (struct glyph_string *s) 2632x_draw_underwave (struct glyph_string *s)
2635{ 2633{
2636 int wave_height = 2, wave_length = 3; 2634 int wave_height = 3, wave_length = 2;
2637 int dx, dy, x0, y0, width, x1, y1, x2, y2, odd, xmax; 2635 int dx, dy, x0, y0, width, x1, y1, x2, y2, odd, xmax;
2638 XRectangle wave_clip, string_clip, final_clip; 2636 XRectangle wave_clip, string_clip, final_clip;
2639 2637
2640 dx = wave_length; 2638 dx = wave_length;
2641 dy = wave_height - 1; 2639 dy = wave_height - 1;
2642 x0 = s->x; 2640 x0 = s->x;
2643 y0 = s->ybase + 1; 2641 y0 = s->ybase - wave_height + 3;
2644 width = s->width; 2642 width = s->width;
2645 xmax = x0 + width; 2643 xmax = x0 + width;
2646 2644
@@ -2802,7 +2800,8 @@ x_draw_glyph_string (struct glyph_string *s)
2802 unsigned long thickness, position; 2800 unsigned long thickness, position;
2803 int y; 2801 int y;
2804 2802
2805 if (s->prev && s->prev->face->underline_p) 2803 if (s->prev && s->prev->face->underline_p
2804 && s->prev->face->underline_type == FACE_UNDER_LINE)
2806 { 2805 {
2807 /* We use the same underline style as the previous one. */ 2806 /* We use the same underline style as the previous one. */
2808 thickness = s->prev->underline_thickness; 2807 thickness = s->prev->underline_thickness;
diff --git a/src/xterm.h b/src/xterm.h
index d63ed1c4583..b241ff23559 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -1,5 +1,6 @@
1/* Definitions and headers for communication with X protocol. 1/* Definitions and headers for communication with X protocol.
2 Copyright (C) 1989, 1993-1994, 1998-2012 Free Software Foundation, Inc. 2 Copyright (C) 1989, 1993-1994, 1998-2013 Free Software Foundation,
3 Inc.
3 4
4This file is part of GNU Emacs. 5This file is part of GNU Emacs.
5 6
@@ -473,12 +474,13 @@ struct x_output
473 GtkWidget *menubar_widget; 474 GtkWidget *menubar_widget;
474 /* The tool bar in this frame */ 475 /* The tool bar in this frame */
475 GtkWidget *toolbar_widget; 476 GtkWidget *toolbar_widget;
476 /* The handle box that makes the tool bar detachable. */ 477#ifdef HAVE_GTK_HANDLE_BOX_NEW
478/* The handle box that makes the tool bar detachable. */
477 GtkWidget *handlebox_widget; 479 GtkWidget *handlebox_widget;
478 /* Non-zero if the tool bar is detached. */ 480#endif
479 int toolbar_detached;
480 /* Non-zero if tool bar is packed into the hbox widget (i.e. vertical). */ 481 /* Non-zero if tool bar is packed into the hbox widget (i.e. vertical). */
481 int toolbar_in_hbox; 482 bool toolbar_in_hbox;
483 bool toolbar_is_packed;
482 484
483 /* The last size hints set. */ 485 /* The last size hints set. */
484 GdkGeometry size_hints; 486 GdkGeometry size_hints;