diff options
| author | Kenichi Handa | 2012-10-14 17:06:11 +0900 |
|---|---|---|
| committer | Kenichi Handa | 2012-10-14 17:06:11 +0900 |
| commit | 9fe32d61c5655878f877522ac4bcc251d092f732 (patch) | |
| tree | 584f4c85fd2e44e8e7d597382f177359b737acb1 /src | |
| parent | f5772b8eaee90d0b50a60bd55d9d28805a2543cb (diff) | |
| parent | 8111f5e6f05228e36496f3bdccad711f569acb9b (diff) | |
| download | emacs-9fe32d61c5655878f877522ac4bcc251d092f732.tar.gz emacs-9fe32d61c5655878f877522ac4bcc251d092f732.zip | |
merge trunk
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 105 | ||||
| -rw-r--r-- | src/buffer.c | 33 | ||||
| -rw-r--r-- | src/coding.c | 3 | ||||
| -rw-r--r-- | src/doc.c | 3 | ||||
| -rw-r--r-- | src/editfns.c | 17 | ||||
| -rw-r--r-- | src/eval.c | 8 | ||||
| -rw-r--r-- | src/fileio.c | 100 | ||||
| -rw-r--r-- | src/gtkutil.c | 6 | ||||
| -rw-r--r-- | src/image.c | 44 | ||||
| -rw-r--r-- | src/lisp.h | 3 | ||||
| -rw-r--r-- | src/lread.c | 174 | ||||
| -rw-r--r-- | src/macros.c | 2 | ||||
| -rw-r--r-- | src/makefile.w32-in | 2 | ||||
| -rw-r--r-- | src/marker.c | 16 | ||||
| -rw-r--r-- | src/menu.c | 27 | ||||
| -rw-r--r-- | src/menu.h | 8 | ||||
| -rw-r--r-- | src/minibuf.c | 27 | ||||
| -rw-r--r-- | src/nsfont.m | 34 | ||||
| -rw-r--r-- | src/nsmenu.m | 9 | ||||
| -rw-r--r-- | src/nsterm.h | 4 | ||||
| -rw-r--r-- | src/nsterm.m | 39 | ||||
| -rw-r--r-- | src/process.c | 17 | ||||
| -rw-r--r-- | src/w32.c | 3 | ||||
| -rw-r--r-- | src/w32fns.c | 4 | ||||
| -rw-r--r-- | src/w32inevt.c | 32 | ||||
| -rw-r--r-- | src/xmenu.c | 25 |
26 files changed, 435 insertions, 310 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 0b274598986..346fe0e86b3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,108 @@ | |||
| 1 | 2012-10-13 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * gtkutil.c (xg_set_widget_bg): Divide by 65535 (Bug#12612). | ||
| 4 | |||
| 5 | 2012-10-13 HANATAKA, Shinya <bogytech@gmail.com> (tiny change) | ||
| 6 | |||
| 7 | * coding.c (detect_coding): Set coding->id before calling | ||
| 8 | this->detector. | ||
| 9 | |||
| 10 | 2012-10-13 Andreas Schwab <schwab@linux-m68k.org> | ||
| 11 | |||
| 12 | * fileio.c: Formatting fixes. | ||
| 13 | |||
| 14 | 2012-10-13 Paul Eggert <eggert@cs.ucla.edu> | ||
| 15 | |||
| 16 | Fix some stat-related races. | ||
| 17 | * fileio.c (Fwrite_region): Avoid race condition if a file is | ||
| 18 | removed or renamed by some other process immediately after Emacs | ||
| 19 | writes it but before Emacs stats it. Do not assume that stat (or | ||
| 20 | fstat) succeeds. | ||
| 21 | * image.c (slurp_file): Resolve the file name with fopen + fstat | ||
| 22 | rather than stat + fopen. | ||
| 23 | (pbm_read_file) [0]: Remove unused code with stat race. | ||
| 24 | * process.c (allocate_pty) [HAVE_PTYS && !PTY_ITERATION && !PTY_OPEN]: | ||
| 25 | Remove ineffective code with stat race. | ||
| 26 | |||
| 27 | 2012-10-12 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 28 | |||
| 29 | * doc.c (get_doc_string): Don't signal an error if the file is missing. | ||
| 30 | |||
| 31 | 2012-10-12 Jan Djärv <jan.h.d@swipnet.se> | ||
| 32 | |||
| 33 | * nsterm.m (hold_event_q): New static variable. | ||
| 34 | (EV_TRAILER, sendScrollEventAtLoc:fromEvent:): Call hold_event if | ||
| 35 | ! q_event_ptr. | ||
| 36 | (hold_event): New function. | ||
| 37 | (ns_read_socket): If hold_event_q have events, store them and | ||
| 38 | return (Bug#12384). | ||
| 39 | (setPosition:portion:whole:): Send SIGIO to ourselves if apploopnr | ||
| 40 | is zero (Bug#12384). | ||
| 41 | |||
| 42 | 2012-10-12 Juanma Barranquero <lekktu@gmail.com> | ||
| 43 | |||
| 44 | * makefile.w32-in ($(BLD)/w32select.$(O)): Update dependencies. | ||
| 45 | |||
| 46 | 2012-10-12 Eli Zaretskii <eliz@gnu.org> | ||
| 47 | |||
| 48 | * makefile.w32-in ($(BLD)/fileio.$(O)): Add sys/file.h. | ||
| 49 | |||
| 50 | * fileio.c (check_existing): New function. | ||
| 51 | (make_temp_name, Ffile_exists_p, Ffile_writable_p): Call it | ||
| 52 | instead of calling 'stat', when what's needed is to check whether | ||
| 53 | a file exists. This avoids expensive system calls on MS-Windows. | ||
| 54 | (Bug#12587) | ||
| 55 | |||
| 56 | * w32.c (init_environment): Call 'check_existing' instead of | ||
| 57 | 'stat'. | ||
| 58 | |||
| 59 | * lread.c (openp) [WINDOWSNT]: Call 'access' instead of 'stat' to | ||
| 60 | determine whether a file exists and is not a directory. | ||
| 61 | |||
| 62 | * lisp.h (check_existing): Add prototype. | ||
| 63 | |||
| 64 | 2012-10-12 Jan Djärv <jan.h.d@swipnet.se> | ||
| 65 | |||
| 66 | * nsfont.m (nsfont_open): Remove font cache, it is not GC correct. | ||
| 67 | |||
| 68 | 2012-10-12 Glenn Morris <rgm@gnu.org> | ||
| 69 | |||
| 70 | * buffer.c (Fset_buffer): Doc fix. (Bug#12624) | ||
| 71 | |||
| 72 | 2012-10-11 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 73 | |||
| 74 | * buffer.c (Fkill_buffer): Null out the overlay list(s) as well. | ||
| 75 | |||
| 76 | * eval.c (Fautoload): Remember previous autoload status in load-history. | ||
| 77 | |||
| 78 | 2012-10-11 Paul Eggert <eggert@cs.ucla.edu> | ||
| 79 | |||
| 80 | lread.c, macros.c, marker.c, menu.c, minibuf.c: Use bool for booleans. | ||
| 81 | * lread.c (load_each_byte, new_backquote_flag, readchar) | ||
| 82 | (read_filtered_event, lisp_file_lexically_bound_p) | ||
| 83 | (safe_to_load_version, Fload, complete_filename_p, openp) | ||
| 84 | (build_load_history, readevalloop, read_escape, read1) | ||
| 85 | (string_to_number, read_vector, read_list): | ||
| 86 | * macros.c (Fstart_kbd_macro): | ||
| 87 | * marker.c (CONSIDER): | ||
| 88 | * menu.c (parse_single_submenu, digest_single_submenu) | ||
| 89 | (find_and_return_menu_selection, Fx_popup_menu): | ||
| 90 | * minibuf.c (read_minibuf_noninteractive, read_minibuf) | ||
| 91 | (Ftry_completion): | ||
| 92 | * nsmenu.m (ns_update_menubar, runMenuAt:forFrame:keymaps:): | ||
| 93 | (ns_menu_show): | ||
| 94 | * xmenu.c (set_frame_menubar, create_and_show_popup_menu) | ||
| 95 | (xmenu_show, xdialog_show): | ||
| 96 | Use bool for booleans. | ||
| 97 | * lread.c (safe_to_load_version): Rename from safe_to_load_p, | ||
| 98 | as it's not a predicate. All uses changed. Omit unnecessary | ||
| 99 | buffer termination. | ||
| 100 | |||
| 101 | 2012-10-11 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 102 | |||
| 103 | * editfns.c (save_excursion_save): Use nil if mark points to nowhere. | ||
| 104 | (save_excursion_restore): Do not restore mark if it was not saved. | ||
| 105 | |||
| 1 | 2012-10-11 Paul Eggert <eggert@cs.ucla.edu> | 106 | 2012-10-11 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 107 | ||
| 3 | * marker.c (cached_modiff): EMACS_INT, not int. | 108 | * marker.c (cached_modiff): EMACS_INT, not int. |
diff --git a/src/buffer.c b/src/buffer.c index 425d05ca790..861a89b5a0f 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -897,6 +897,8 @@ delete_all_overlays (struct buffer *b) | |||
| 897 | { | 897 | { |
| 898 | struct Lisp_Overlay *ov, *next; | 898 | struct Lisp_Overlay *ov, *next; |
| 899 | 899 | ||
| 900 | /* FIXME: Since each drop_overlay will scan BUF_MARKERS to unlink its | ||
| 901 | markers, we have an unneeded O(N^2) behavior here. */ | ||
| 900 | for (ov = b->overlays_before; ov; ov = next) | 902 | for (ov = b->overlays_before; ov; ov = next) |
| 901 | { | 903 | { |
| 902 | drop_overlay (b, ov); | 904 | drop_overlay (b, ov); |
| @@ -1886,16 +1888,19 @@ cleaning up all windows currently displaying the buffer to be killed. */) | |||
| 1886 | 1888 | ||
| 1887 | if (b->base_buffer) | 1889 | if (b->base_buffer) |
| 1888 | { | 1890 | { |
| 1889 | /* Unchain all markers that belong to this indirect buffer. | 1891 | { /* Unchain all markers that belong to this indirect buffer. |
| 1890 | Don't unchain the markers that belong to the base buffer | 1892 | Don't unchain the markers that belong to the base buffer |
| 1891 | or its other indirect buffers. */ | 1893 | or its other indirect buffers. */ |
| 1892 | for (m = BUF_MARKERS (b); m; ) | 1894 | struct Lisp_Marker **mp; |
| 1893 | { | 1895 | for (mp = &BUF_MARKERS (b); *mp; ) |
| 1894 | struct Lisp_Marker *next = m->next; | 1896 | { |
| 1895 | if (m->buffer == b) | 1897 | struct Lisp_Marker *m = *mp; |
| 1896 | unchain_marker (m); | 1898 | if (m->buffer == b) |
| 1897 | m = next; | 1899 | *mp = m->next; |
| 1898 | } | 1900 | else |
| 1901 | mp = &m->next; | ||
| 1902 | } | ||
| 1903 | } | ||
| 1899 | } | 1904 | } |
| 1900 | else | 1905 | else |
| 1901 | { | 1906 | { |
| @@ -1911,8 +1916,12 @@ cleaning up all windows currently displaying the buffer to be killed. */) | |||
| 1911 | BUF_MARKERS (b) = NULL; | 1916 | BUF_MARKERS (b) = NULL; |
| 1912 | set_buffer_intervals (b, NULL); | 1917 | set_buffer_intervals (b, NULL); |
| 1913 | 1918 | ||
| 1914 | /* Perhaps we should explicitly free the interval tree here... */ | 1919 | /* Perhaps we should explicitly free the interval tree here... */ |
| 1915 | } | 1920 | } |
| 1921 | /* Since we've unlinked the markers, the overlays can't be here any more | ||
| 1922 | either. */ | ||
| 1923 | b->overlays_before = NULL; | ||
| 1924 | b->overlays_after = NULL; | ||
| 1916 | 1925 | ||
| 1917 | /* Reset the local variables, so that this buffer's local values | 1926 | /* Reset the local variables, so that this buffer's local values |
| 1918 | won't be protected from GC. They would be protected | 1927 | won't be protected from GC. They would be protected |
| @@ -2176,7 +2185,7 @@ set_buffer_temp (struct buffer *b) | |||
| 2176 | DEFUN ("set-buffer", Fset_buffer, Sset_buffer, 1, 1, 0, | 2185 | DEFUN ("set-buffer", Fset_buffer, Sset_buffer, 1, 1, 0, |
| 2177 | doc: /* Make buffer BUFFER-OR-NAME current for editing operations. | 2186 | doc: /* Make buffer BUFFER-OR-NAME current for editing operations. |
| 2178 | BUFFER-OR-NAME may be a buffer or the name of an existing buffer. See | 2187 | BUFFER-OR-NAME may be a buffer or the name of an existing buffer. See |
| 2179 | also `save-excursion' when you want to make a buffer current | 2188 | also `with-current-buffer' when you want to make a buffer current |
| 2180 | temporarily. This function does not display the buffer, so its effect | 2189 | temporarily. This function does not display the buffer, so its effect |
| 2181 | ends when the current command terminates. Use `switch-to-buffer' or | 2190 | ends when the current command terminates. Use `switch-to-buffer' or |
| 2182 | `pop-to-buffer' to switch buffers permanently. */) | 2191 | `pop-to-buffer' to switch buffers permanently. */) |
diff --git a/src/coding.c b/src/coding.c index d9606cf5710..412d7245223 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -6301,6 +6301,9 @@ detect_coding (struct coding_system *coding) | |||
| 6301 | { | 6301 | { |
| 6302 | category = coding_priorities[i]; | 6302 | category = coding_priorities[i]; |
| 6303 | this = coding_categories + category; | 6303 | this = coding_categories + category; |
| 6304 | /* Some of this->detector (e.g. detect_coding_sjis) | ||
| 6305 | require this information. */ | ||
| 6306 | coding->id = this->id; | ||
| 6304 | if (this->id < 0) | 6307 | if (this->id < 0) |
| 6305 | { | 6308 | { |
| 6306 | /* No coding system of this category is defined. */ | 6309 | /* No coding system of this category is defined. */ |
| @@ -144,7 +144,8 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition) | |||
| 144 | } | 144 | } |
| 145 | #endif | 145 | #endif |
| 146 | if (fd < 0) | 146 | if (fd < 0) |
| 147 | error ("Cannot open doc string file \"%s\"", name); | 147 | return concat3 (build_string ("Cannot open doc string file \""), |
| 148 | file, build_string ("\"\n")); | ||
| 148 | } | 149 | } |
| 149 | 150 | ||
| 150 | /* Seek only to beginning of disk block. */ | 151 | /* Seek only to beginning of disk block. */ |
diff --git a/src/editfns.c b/src/editfns.c index fc6465a3d46..19fad7130a7 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -819,9 +819,13 @@ save_excursion_save (void) | |||
| 819 | { | 819 | { |
| 820 | bool visible = (XBUFFER (XWINDOW (selected_window)->buffer) | 820 | bool visible = (XBUFFER (XWINDOW (selected_window)->buffer) |
| 821 | == current_buffer); | 821 | == current_buffer); |
| 822 | /* Do not copy the mark if it points to nowhere. */ | ||
| 823 | Lisp_Object mark = (XMARKER (BVAR (current_buffer, mark))->buffer | ||
| 824 | ? Fcopy_marker (BVAR (current_buffer, mark), Qnil) | ||
| 825 | : Qnil); | ||
| 822 | 826 | ||
| 823 | return Fcons (Fpoint_marker (), | 827 | return Fcons (Fpoint_marker (), |
| 824 | Fcons (Fcopy_marker (BVAR (current_buffer, mark), Qnil), | 828 | Fcons (mark, |
| 825 | Fcons (visible ? Qt : Qnil, | 829 | Fcons (visible ? Qt : Qnil, |
| 826 | Fcons (BVAR (current_buffer, mark_active), | 830 | Fcons (BVAR (current_buffer, mark_active), |
| 827 | selected_window)))); | 831 | selected_window)))); |
| @@ -856,9 +860,14 @@ save_excursion_restore (Lisp_Object info) | |||
| 856 | info = XCDR (info); | 860 | info = XCDR (info); |
| 857 | tem = XCAR (info); | 861 | tem = XCAR (info); |
| 858 | omark = Fmarker_position (BVAR (current_buffer, mark)); | 862 | omark = Fmarker_position (BVAR (current_buffer, mark)); |
| 859 | Fset_marker (BVAR (current_buffer, mark), tem, Fcurrent_buffer ()); | 863 | if (NILP (tem)) |
| 860 | nmark = Fmarker_position (tem); | 864 | unchain_marker (XMARKER (BVAR (current_buffer, mark))); |
| 861 | unchain_marker (XMARKER (tem)); | 865 | else |
| 866 | { | ||
| 867 | Fset_marker (BVAR (current_buffer, mark), tem, Fcurrent_buffer ()); | ||
| 868 | nmark = Fmarker_position (tem); | ||
| 869 | unchain_marker (XMARKER (tem)); | ||
| 870 | } | ||
| 862 | 871 | ||
| 863 | /* visible */ | 872 | /* visible */ |
| 864 | info = XCDR (info); | 873 | info = XCDR (info); |
diff --git a/src/eval.c b/src/eval.c index 4d200fbc2bd..975204da017 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -1876,9 +1876,11 @@ this does nothing and returns nil. */) | |||
| 1876 | CHECK_STRING (file); | 1876 | CHECK_STRING (file); |
| 1877 | 1877 | ||
| 1878 | /* If function is defined and not as an autoload, don't override. */ | 1878 | /* If function is defined and not as an autoload, don't override. */ |
| 1879 | if (!EQ (XSYMBOL (function)->function, Qunbound) | 1879 | if ((CONSP (XSYMBOL (function)->function) |
| 1880 | && !(CONSP (XSYMBOL (function)->function) | 1880 | && EQ (XCAR (XSYMBOL (function)->function), Qautoload))) |
| 1881 | && EQ (XCAR (XSYMBOL (function)->function), Qautoload))) | 1881 | /* Remember that the function was already an autoload. */ |
| 1882 | LOADHIST_ATTACH (Fcons (Qt, function)); | ||
| 1883 | else if (!EQ (XSYMBOL (function)->function, Qunbound)) | ||
| 1882 | return Qnil; | 1884 | return Qnil; |
| 1883 | 1885 | ||
| 1884 | if (NILP (Vpurify_flag)) | 1886 | if (NILP (Vpurify_flag)) |
diff --git a/src/fileio.c b/src/fileio.c index b4eda01afcc..e3a91c2c9da 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -52,6 +52,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 52 | #define NOMINMAX 1 | 52 | #define NOMINMAX 1 |
| 53 | #include <windows.h> | 53 | #include <windows.h> |
| 54 | #include <fcntl.h> | 54 | #include <fcntl.h> |
| 55 | #include <sys/file.h> | ||
| 55 | #endif /* not WINDOWSNT */ | 56 | #endif /* not WINDOWSNT */ |
| 56 | 57 | ||
| 57 | #ifdef MSDOS | 58 | #ifdef MSDOS |
| @@ -668,7 +669,6 @@ make_temp_name (Lisp_Object prefix, bool base64_p) | |||
| 668 | 669 | ||
| 669 | while (1) | 670 | while (1) |
| 670 | { | 671 | { |
| 671 | struct stat ignored; | ||
| 672 | unsigned num = make_temp_name_count; | 672 | unsigned num = make_temp_name_count; |
| 673 | 673 | ||
| 674 | p[0] = make_temp_name_tbl[num & 63], num >>= 6; | 674 | p[0] = make_temp_name_tbl[num & 63], num >>= 6; |
| @@ -680,7 +680,7 @@ make_temp_name (Lisp_Object prefix, bool base64_p) | |||
| 680 | make_temp_name_count += 25229; | 680 | make_temp_name_count += 25229; |
| 681 | make_temp_name_count %= 225307; | 681 | make_temp_name_count %= 225307; |
| 682 | 682 | ||
| 683 | if (stat (data, &ignored) < 0) | 683 | if (!check_existing (data)) |
| 684 | { | 684 | { |
| 685 | /* We want to return only if errno is ENOENT. */ | 685 | /* We want to return only if errno is ENOENT. */ |
| 686 | if (errno == ENOENT) | 686 | if (errno == ENOENT) |
| @@ -1370,8 +1370,7 @@ See also the function `substitute-in-file-name'.") | |||
| 1370 | p = nm; | 1370 | p = nm; |
| 1371 | while (*p) | 1371 | while (*p) |
| 1372 | { | 1372 | { |
| 1373 | if (p[0] == '/' && p[1] == '/' | 1373 | if (p[0] == '/' && p[1] == '/') |
| 1374 | ) | ||
| 1375 | nm = p + 1; | 1374 | nm = p + 1; |
| 1376 | if (p[0] == '/' && p[1] == '~') | 1375 | if (p[0] == '/' && p[1] == '~') |
| 1377 | nm = p + 1, lose = 1; | 1376 | nm = p + 1, lose = 1; |
| @@ -1510,17 +1509,16 @@ search_embedded_absfilename (char *nm, char *endp) | |||
| 1510 | 1509 | ||
| 1511 | for (p = nm + 1; p < endp; p++) | 1510 | for (p = nm + 1; p < endp; p++) |
| 1512 | { | 1511 | { |
| 1513 | if ((0 | 1512 | if (IS_DIRECTORY_SEP (p[-1]) |
| 1514 | || IS_DIRECTORY_SEP (p[-1])) | ||
| 1515 | && file_name_absolute_p (p) | 1513 | && file_name_absolute_p (p) |
| 1516 | #if defined (WINDOWSNT) || defined (CYGWIN) | 1514 | #if defined (WINDOWSNT) || defined (CYGWIN) |
| 1517 | /* // at start of file name is meaningful in Apollo, | 1515 | /* // at start of file name is meaningful in Apollo, |
| 1518 | WindowsNT and Cygwin systems. */ | 1516 | WindowsNT and Cygwin systems. */ |
| 1519 | && !(IS_DIRECTORY_SEP (p[0]) && p - 1 == nm) | 1517 | && !(IS_DIRECTORY_SEP (p[0]) && p - 1 == nm) |
| 1520 | #endif /* not (WINDOWSNT || CYGWIN) */ | 1518 | #endif /* not (WINDOWSNT || CYGWIN) */ |
| 1521 | ) | 1519 | ) |
| 1522 | { | 1520 | { |
| 1523 | for (s = p; *s && (!IS_DIRECTORY_SEP (*s)); s++); | 1521 | for (s = p; *s && !IS_DIRECTORY_SEP (*s); s++); |
| 1524 | if (p[0] == '~' && s > p + 1) /* We've got "/~something/". */ | 1522 | if (p[0] == '~' && s > p + 1) /* We've got "/~something/". */ |
| 1525 | { | 1523 | { |
| 1526 | char *o = alloca (s - p + 1); | 1524 | char *o = alloca (s - p + 1); |
| @@ -1735,7 +1733,7 @@ those `/' is discarded. */) | |||
| 1735 | *x = 0; | 1733 | *x = 0; |
| 1736 | 1734 | ||
| 1737 | /* If /~ or // appears, discard everything through first slash. */ | 1735 | /* If /~ or // appears, discard everything through first slash. */ |
| 1738 | while ((p = search_embedded_absfilename (xnm, x))) | 1736 | while ((p = search_embedded_absfilename (xnm, x)) != NULL) |
| 1739 | /* This time we do not start over because we've already expanded envvars | 1737 | /* This time we do not start over because we've already expanded envvars |
| 1740 | and replaced $$ with $. Maybe we should start over as well, but we'd | 1738 | and replaced $$ with $. Maybe we should start over as well, but we'd |
| 1741 | need to quote some $ to $$ first. */ | 1739 | need to quote some $ to $$ first. */ |
| @@ -2169,7 +2167,7 @@ With a prefix argument, TRASH is nil. */) | |||
| 2169 | 2167 | ||
| 2170 | encoded_file = ENCODE_FILE (filename); | 2168 | encoded_file = ENCODE_FILE (filename); |
| 2171 | 2169 | ||
| 2172 | if (0 > unlink (SSDATA (encoded_file))) | 2170 | if (unlink (SSDATA (encoded_file)) < 0) |
| 2173 | report_file_error ("Removing old name", list1 (filename)); | 2171 | report_file_error ("Removing old name", list1 (filename)); |
| 2174 | return Qnil; | 2172 | return Qnil; |
| 2175 | } | 2173 | } |
| @@ -2218,8 +2216,8 @@ This is what happens in interactive use with M-x. */) | |||
| 2218 | #endif | 2216 | #endif |
| 2219 | ) | 2217 | ) |
| 2220 | { | 2218 | { |
| 2221 | Lisp_Object fname = NILP (Ffile_directory_p (file)) | 2219 | Lisp_Object fname = (NILP (Ffile_directory_p (file)) |
| 2222 | ? file : Fdirectory_file_name (file); | 2220 | ? file : Fdirectory_file_name (file)); |
| 2223 | newname = Fexpand_file_name (Ffile_name_nondirectory (fname), newname); | 2221 | newname = Fexpand_file_name (Ffile_name_nondirectory (fname), newname); |
| 2224 | } | 2222 | } |
| 2225 | else | 2223 | else |
| @@ -2247,7 +2245,7 @@ This is what happens in interactive use with M-x. */) | |||
| 2247 | || INTEGERP (ok_if_already_exists)) | 2245 | || INTEGERP (ok_if_already_exists)) |
| 2248 | barf_or_query_if_file_exists (newname, "rename to it", | 2246 | barf_or_query_if_file_exists (newname, "rename to it", |
| 2249 | INTEGERP (ok_if_already_exists), 0, 0); | 2247 | INTEGERP (ok_if_already_exists), 0, 0); |
| 2250 | if (0 > rename (SSDATA (encoded_file), SSDATA (encoded_newname))) | 2248 | if (rename (SSDATA (encoded_file), SSDATA (encoded_newname)) < 0) |
| 2251 | { | 2249 | { |
| 2252 | if (errno == EXDEV) | 2250 | if (errno == EXDEV) |
| 2253 | { | 2251 | { |
| @@ -2328,7 +2326,7 @@ This is what happens in interactive use with M-x. */) | |||
| 2328 | INTEGERP (ok_if_already_exists), 0, 0); | 2326 | INTEGERP (ok_if_already_exists), 0, 0); |
| 2329 | 2327 | ||
| 2330 | unlink (SSDATA (newname)); | 2328 | unlink (SSDATA (newname)); |
| 2331 | if (0 > link (SSDATA (encoded_file), SSDATA (encoded_newname))) | 2329 | if (link (SSDATA (encoded_file), SSDATA (encoded_newname)) < 0) |
| 2332 | report_file_error ("Adding new name", list2 (file, newname)); | 2330 | report_file_error ("Adding new name", list2 (file, newname)); |
| 2333 | 2331 | ||
| 2334 | UNGCPRO; | 2332 | UNGCPRO; |
| @@ -2385,15 +2383,14 @@ This happens for interactive use with M-x. */) | |||
| 2385 | || INTEGERP (ok_if_already_exists)) | 2383 | || INTEGERP (ok_if_already_exists)) |
| 2386 | barf_or_query_if_file_exists (linkname, "make it a link", | 2384 | barf_or_query_if_file_exists (linkname, "make it a link", |
| 2387 | INTEGERP (ok_if_already_exists), 0, 0); | 2385 | INTEGERP (ok_if_already_exists), 0, 0); |
| 2388 | if (0 > symlink (SSDATA (encoded_filename), | 2386 | if (symlink (SSDATA (encoded_filename), SSDATA (encoded_linkname)) < 0) |
| 2389 | SSDATA (encoded_linkname))) | ||
| 2390 | { | 2387 | { |
| 2391 | /* If we didn't complain already, silently delete existing file. */ | 2388 | /* If we didn't complain already, silently delete existing file. */ |
| 2392 | if (errno == EEXIST) | 2389 | if (errno == EEXIST) |
| 2393 | { | 2390 | { |
| 2394 | unlink (SSDATA (encoded_linkname)); | 2391 | unlink (SSDATA (encoded_linkname)); |
| 2395 | if (0 <= symlink (SSDATA (encoded_filename), | 2392 | if (symlink (SSDATA (encoded_filename), SSDATA (encoded_linkname)) |
| 2396 | SSDATA (encoded_linkname))) | 2393 | >= 0) |
| 2397 | { | 2394 | { |
| 2398 | UNGCPRO; | 2395 | UNGCPRO; |
| 2399 | return Qnil; | 2396 | return Qnil; |
| @@ -2423,6 +2420,21 @@ On Unix, this is a name starting with a `/' or a `~'. */) | |||
| 2423 | return file_name_absolute_p (SSDATA (filename)) ? Qt : Qnil; | 2420 | return file_name_absolute_p (SSDATA (filename)) ? Qt : Qnil; |
| 2424 | } | 2421 | } |
| 2425 | 2422 | ||
| 2423 | /* Return true if FILENAME exists. */ | ||
| 2424 | bool | ||
| 2425 | check_existing (const char *filename) | ||
| 2426 | { | ||
| 2427 | #ifdef DOS_NT | ||
| 2428 | /* The full emulation of Posix 'stat' is too expensive on | ||
| 2429 | DOS/Windows, when all we want to know is whether the file exists. | ||
| 2430 | So we use 'access' instead, which is much more lightweight. */ | ||
| 2431 | return (access (filename, F_OK) >= 0); | ||
| 2432 | #else | ||
| 2433 | struct stat st; | ||
| 2434 | return (stat (filename, &st) >= 0); | ||
| 2435 | #endif | ||
| 2436 | } | ||
| 2437 | |||
| 2426 | /* Return true if file FILENAME exists and can be executed. */ | 2438 | /* Return true if file FILENAME exists and can be executed. */ |
| 2427 | 2439 | ||
| 2428 | static bool | 2440 | static bool |
| @@ -2490,7 +2502,6 @@ Use `file-symlink-p' to test for such links. */) | |||
| 2490 | { | 2502 | { |
| 2491 | Lisp_Object absname; | 2503 | Lisp_Object absname; |
| 2492 | Lisp_Object handler; | 2504 | Lisp_Object handler; |
| 2493 | struct stat statbuf; | ||
| 2494 | 2505 | ||
| 2495 | CHECK_STRING (filename); | 2506 | CHECK_STRING (filename); |
| 2496 | absname = Fexpand_file_name (filename, Qnil); | 2507 | absname = Fexpand_file_name (filename, Qnil); |
| @@ -2503,7 +2514,7 @@ Use `file-symlink-p' to test for such links. */) | |||
| 2503 | 2514 | ||
| 2504 | absname = ENCODE_FILE (absname); | 2515 | absname = ENCODE_FILE (absname); |
| 2505 | 2516 | ||
| 2506 | return (stat (SSDATA (absname), &statbuf) >= 0) ? Qt : Qnil; | 2517 | return (check_existing (SSDATA (absname))) ? Qt : Qnil; |
| 2507 | } | 2518 | } |
| 2508 | 2519 | ||
| 2509 | DEFUN ("file-executable-p", Ffile_executable_p, Sfile_executable_p, 1, 1, 0, | 2520 | DEFUN ("file-executable-p", Ffile_executable_p, Sfile_executable_p, 1, 1, 0, |
| @@ -2584,7 +2595,6 @@ DEFUN ("file-writable-p", Ffile_writable_p, Sfile_writable_p, 1, 1, 0, | |||
| 2584 | { | 2595 | { |
| 2585 | Lisp_Object absname, dir, encoded; | 2596 | Lisp_Object absname, dir, encoded; |
| 2586 | Lisp_Object handler; | 2597 | Lisp_Object handler; |
| 2587 | struct stat statbuf; | ||
| 2588 | 2598 | ||
| 2589 | CHECK_STRING (filename); | 2599 | CHECK_STRING (filename); |
| 2590 | absname = Fexpand_file_name (filename, Qnil); | 2600 | absname = Fexpand_file_name (filename, Qnil); |
| @@ -2596,7 +2606,7 @@ DEFUN ("file-writable-p", Ffile_writable_p, Sfile_writable_p, 1, 1, 0, | |||
| 2596 | return call2 (handler, Qfile_writable_p, absname); | 2606 | return call2 (handler, Qfile_writable_p, absname); |
| 2597 | 2607 | ||
| 2598 | encoded = ENCODE_FILE (absname); | 2608 | encoded = ENCODE_FILE (absname); |
| 2599 | if (stat (SSDATA (encoded), &statbuf) >= 0) | 2609 | if (check_existing (SSDATA (encoded))) |
| 2600 | return (check_writable (SSDATA (encoded)) | 2610 | return (check_writable (SSDATA (encoded)) |
| 2601 | ? Qt : Qnil); | 2611 | ? Qt : Qnil); |
| 2602 | 2612 | ||
| @@ -2611,9 +2621,7 @@ DEFUN ("file-writable-p", Ffile_writable_p, Sfile_writable_p, 1, 1, 0, | |||
| 2611 | /* The read-only attribute of the parent directory doesn't affect | 2621 | /* The read-only attribute of the parent directory doesn't affect |
| 2612 | whether a file or directory can be created within it. Some day we | 2622 | whether a file or directory can be created within it. Some day we |
| 2613 | should check ACLs though, which do affect this. */ | 2623 | should check ACLs though, which do affect this. */ |
| 2614 | if (stat (SDATA (dir), &statbuf) < 0) | 2624 | return (access (SDATA (dir), D_OK) < 0) ? Qnil : Qt; |
| 2615 | return Qnil; | ||
| 2616 | return S_ISDIR (statbuf.st_mode) ? Qt : Qnil; | ||
| 2617 | #else | 2625 | #else |
| 2618 | return (check_writable (!NILP (dir) ? SSDATA (dir) : "") | 2626 | return (check_writable (!NILP (dir) ? SSDATA (dir) : "") |
| 2619 | ? Qt : Qnil); | 2627 | ? Qt : Qnil); |
| @@ -3192,7 +3200,7 @@ emacs_lseek (int fd, EMACS_INT offset, int whence) | |||
| 3192 | { | 3200 | { |
| 3193 | /* Use "&" rather than "&&" to suppress a bogus GCC warning; see | 3201 | /* Use "&" rather than "&&" to suppress a bogus GCC warning; see |
| 3194 | <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43772>. */ | 3202 | <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43772>. */ |
| 3195 | if (! ((TYPE_MINIMUM (off_t) <= offset) & (offset <= TYPE_MAXIMUM (off_t)))) | 3203 | if (! ((offset >= TYPE_MINIMUM (off_t)) & (offset <= TYPE_MAXIMUM (off_t)))) |
| 3196 | { | 3204 | { |
| 3197 | errno = EINVAL; | 3205 | errno = EINVAL; |
| 3198 | return -1; | 3206 | return -1; |
| @@ -3365,7 +3373,7 @@ variable `last-coding-system-used' to the coding system actually used. */) | |||
| 3365 | 3373 | ||
| 3366 | if (!NILP (beg)) | 3374 | if (!NILP (beg)) |
| 3367 | { | 3375 | { |
| 3368 | if (! (RANGED_INTEGERP (0, beg, TYPE_MAXIMUM (off_t)))) | 3376 | if (! RANGED_INTEGERP (0, beg, TYPE_MAXIMUM (off_t))) |
| 3369 | wrong_type_argument (intern ("file-offset"), beg); | 3377 | wrong_type_argument (intern ("file-offset"), beg); |
| 3370 | beg_offset = XFASTINT (beg); | 3378 | beg_offset = XFASTINT (beg); |
| 3371 | } | 3379 | } |
| @@ -3374,7 +3382,7 @@ variable `last-coding-system-used' to the coding system actually used. */) | |||
| 3374 | 3382 | ||
| 3375 | if (!NILP (end)) | 3383 | if (!NILP (end)) |
| 3376 | { | 3384 | { |
| 3377 | if (! (RANGED_INTEGERP (0, end, TYPE_MAXIMUM (off_t)))) | 3385 | if (! RANGED_INTEGERP (0, end, TYPE_MAXIMUM (off_t))) |
| 3378 | wrong_type_argument (intern ("file-offset"), end); | 3386 | wrong_type_argument (intern ("file-offset"), end); |
| 3379 | end_offset = XFASTINT (end); | 3387 | end_offset = XFASTINT (end); |
| 3380 | } | 3388 | } |
| @@ -3410,8 +3418,8 @@ variable `last-coding-system-used' to the coding system actually used. */) | |||
| 3410 | 3418 | ||
| 3411 | if (beg_offset < likely_end) | 3419 | if (beg_offset < likely_end) |
| 3412 | { | 3420 | { |
| 3413 | ptrdiff_t buf_bytes = | 3421 | ptrdiff_t buf_bytes |
| 3414 | Z_BYTE - (!NILP (replace) ? ZV_BYTE - BEGV_BYTE : 0); | 3422 | = Z_BYTE - (!NILP (replace) ? ZV_BYTE - BEGV_BYTE : 0); |
| 3415 | ptrdiff_t buf_growth_max = BUF_BYTES_MAX - buf_bytes; | 3423 | ptrdiff_t buf_growth_max = BUF_BYTES_MAX - buf_bytes; |
| 3416 | off_t likely_growth = likely_end - beg_offset; | 3424 | off_t likely_growth = likely_end - beg_offset; |
| 3417 | if (buf_growth_max < likely_growth) | 3425 | if (buf_growth_max < likely_growth) |
| @@ -4534,6 +4542,7 @@ This calls `write-region-annotate-functions' at the start, and | |||
| 4534 | int save_errno = 0; | 4542 | int save_errno = 0; |
| 4535 | const char *fn; | 4543 | const char *fn; |
| 4536 | struct stat st; | 4544 | struct stat st; |
| 4545 | EMACS_TIME modtime; | ||
| 4537 | ptrdiff_t count = SPECPDL_INDEX (); | 4546 | ptrdiff_t count = SPECPDL_INDEX (); |
| 4538 | int count1; | 4547 | int count1; |
| 4539 | Lisp_Object handler; | 4548 | Lisp_Object handler; |
| @@ -4746,12 +4755,19 @@ This calls `write-region-annotate-functions' at the start, and | |||
| 4746 | } | 4755 | } |
| 4747 | #endif | 4756 | #endif |
| 4748 | 4757 | ||
| 4758 | modtime = invalid_emacs_time (); | ||
| 4759 | if (visiting) | ||
| 4760 | { | ||
| 4761 | if (fstat (desc, &st) == 0) | ||
| 4762 | modtime = get_stat_mtime (&st); | ||
| 4763 | else | ||
| 4764 | ok = 0, save_errno = errno; | ||
| 4765 | } | ||
| 4766 | |||
| 4749 | /* NFS can report a write failure now. */ | 4767 | /* NFS can report a write failure now. */ |
| 4750 | if (emacs_close (desc) < 0) | 4768 | if (emacs_close (desc) < 0) |
| 4751 | ok = 0, save_errno = errno; | 4769 | ok = 0, save_errno = errno; |
| 4752 | 4770 | ||
| 4753 | stat (fn, &st); | ||
| 4754 | |||
| 4755 | /* Discard the unwind protect for close_file_unwind. */ | 4771 | /* Discard the unwind protect for close_file_unwind. */ |
| 4756 | specpdl_ptr = specpdl + count1; | 4772 | specpdl_ptr = specpdl + count1; |
| 4757 | 4773 | ||
| @@ -4779,9 +4795,9 @@ This calls `write-region-annotate-functions' at the start, and | |||
| 4779 | /* Do this before reporting IO error | 4795 | /* Do this before reporting IO error |
| 4780 | to avoid a "file has changed on disk" warning on | 4796 | to avoid a "file has changed on disk" warning on |
| 4781 | next attempt to save. */ | 4797 | next attempt to save. */ |
| 4782 | if (visiting) | 4798 | if (EMACS_TIME_VALID_P (modtime)) |
| 4783 | { | 4799 | { |
| 4784 | current_buffer->modtime = get_stat_mtime (&st); | 4800 | current_buffer->modtime = modtime; |
| 4785 | current_buffer->modtime_size = st.st_size; | 4801 | current_buffer->modtime_size = st.st_size; |
| 4786 | } | 4802 | } |
| 4787 | 4803 | ||
| @@ -5031,12 +5047,12 @@ e_write (int desc, Lisp_Object string, ptrdiff_t start, ptrdiff_t end, | |||
| 5031 | 5047 | ||
| 5032 | if (coding->produced > 0) | 5048 | if (coding->produced > 0) |
| 5033 | { | 5049 | { |
| 5034 | coding->produced -= | 5050 | coding->produced |
| 5035 | emacs_write (desc, | 5051 | -= emacs_write (desc, |
| 5036 | STRINGP (coding->dst_object) | 5052 | STRINGP (coding->dst_object) |
| 5037 | ? SSDATA (coding->dst_object) | 5053 | ? SSDATA (coding->dst_object) |
| 5038 | : (char *) BYTE_POS_ADDR (coding->dst_pos_byte), | 5054 | : (char *) BYTE_POS_ADDR (coding->dst_pos_byte), |
| 5039 | coding->produced); | 5055 | coding->produced); |
| 5040 | 5056 | ||
| 5041 | if (coding->produced) | 5057 | if (coding->produced) |
| 5042 | return 0; | 5058 | return 0; |
| @@ -5215,8 +5231,8 @@ auto_save_1 (void) | |||
| 5215 | if (stat (SSDATA (BVAR (current_buffer, filename)), &st) >= 0) | 5231 | if (stat (SSDATA (BVAR (current_buffer, filename)), &st) >= 0) |
| 5216 | /* But make sure we can overwrite it later! */ | 5232 | /* But make sure we can overwrite it later! */ |
| 5217 | auto_save_mode_bits = (st.st_mode | 0600) & 0777; | 5233 | auto_save_mode_bits = (st.st_mode | 0600) & 0777; |
| 5218 | else if ((modes = Ffile_modes (BVAR (current_buffer, filename)), | 5234 | else if (modes = Ffile_modes (BVAR (current_buffer, filename)), |
| 5219 | INTEGERP (modes))) | 5235 | INTEGERP (modes)) |
| 5220 | /* Remote files don't cooperate with stat. */ | 5236 | /* Remote files don't cooperate with stat. */ |
| 5221 | auto_save_mode_bits = (XINT (modes) | 0600) & 0777; | 5237 | auto_save_mode_bits = (XINT (modes) | 0600) & 0777; |
| 5222 | } | 5238 | } |
diff --git a/src/gtkutil.c b/src/gtkutil.c index 1bf2b533b41..4367b534cb9 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -1035,9 +1035,9 @@ xg_set_widget_bg (FRAME_PTR f, GtkWidget *w, long unsigned int pixel) | |||
| 1035 | xbg.pixel = pixel; | 1035 | xbg.pixel = pixel; |
| 1036 | if (XQueryColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), &xbg)) | 1036 | if (XQueryColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), &xbg)) |
| 1037 | { | 1037 | { |
| 1038 | bg.red = (double)xbg.red/65536.0; | 1038 | bg.red = (double)xbg.red/65535.0; |
| 1039 | bg.green = (double)xbg.green/65536.0; | 1039 | bg.green = (double)xbg.green/65535.0; |
| 1040 | bg.blue = (double)xbg.blue/65536.0; | 1040 | bg.blue = (double)xbg.blue/65535.0; |
| 1041 | bg.alpha = 1.0; | 1041 | bg.alpha = 1.0; |
| 1042 | gtk_widget_override_background_color (w, GTK_STATE_FLAG_NORMAL, &bg); | 1042 | gtk_widget_override_background_color (w, GTK_STATE_FLAG_NORMAL, &bg); |
| 1043 | } | 1043 | } |
diff --git a/src/image.c b/src/image.c index 9b41cf74993..d52c3a29a27 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -2140,12 +2140,11 @@ x_find_image_file (Lisp_Object file) | |||
| 2140 | static unsigned char * | 2140 | static unsigned char * |
| 2141 | slurp_file (char *file, ptrdiff_t *size) | 2141 | slurp_file (char *file, ptrdiff_t *size) |
| 2142 | { | 2142 | { |
| 2143 | FILE *fp = NULL; | 2143 | FILE *fp = fopen (file, "rb"); |
| 2144 | unsigned char *buf = NULL; | 2144 | unsigned char *buf = NULL; |
| 2145 | struct stat st; | 2145 | struct stat st; |
| 2146 | 2146 | ||
| 2147 | if (stat (file, &st) == 0 | 2147 | if (fp && fstat (fileno (fp), &st) == 0 |
| 2148 | && (fp = fopen (file, "rb")) != NULL | ||
| 2149 | && 0 <= st.st_size && st.st_size <= min (PTRDIFF_MAX, SIZE_MAX) | 2148 | && 0 <= st.st_size && st.st_size <= min (PTRDIFF_MAX, SIZE_MAX) |
| 2150 | && (buf = xmalloc (st.st_size), | 2149 | && (buf = xmalloc (st.st_size), |
| 2151 | fread (buf, 1, st.st_size, fp) == st.st_size)) | 2150 | fread (buf, 1, st.st_size, fp) == st.st_size)) |
| @@ -5004,45 +5003,6 @@ pbm_scan_number (unsigned char **s, unsigned char *end) | |||
| 5004 | } | 5003 | } |
| 5005 | 5004 | ||
| 5006 | 5005 | ||
| 5007 | #ifdef HAVE_NTGUI | ||
| 5008 | #if 0 /* Unused. ++kfs */ | ||
| 5009 | |||
| 5010 | /* Read FILE into memory. Value is a pointer to a buffer allocated | ||
| 5011 | with xmalloc holding FILE's contents. Value is null if an error | ||
| 5012 | occurred. *SIZE is set to the size of the file. */ | ||
| 5013 | |||
| 5014 | static char * | ||
| 5015 | pbm_read_file (Lisp_Object file, int *size) | ||
| 5016 | { | ||
| 5017 | FILE *fp = NULL; | ||
| 5018 | char *buf = NULL; | ||
| 5019 | struct stat st; | ||
| 5020 | |||
| 5021 | if (stat (SDATA (file), &st) == 0 | ||
| 5022 | && (fp = fopen (SDATA (file), "rb")) != NULL | ||
| 5023 | && 0 <= st.st_size && st.st_size <= min (PTRDIFF_MAX, SIZE_MAX) | ||
| 5024 | && (buf = xmalloc (st.st_size), | ||
| 5025 | fread (buf, 1, st.st_size, fp) == st.st_size)) | ||
| 5026 | { | ||
| 5027 | *size = st.st_size; | ||
| 5028 | fclose (fp); | ||
| 5029 | } | ||
| 5030 | else | ||
| 5031 | { | ||
| 5032 | if (fp) | ||
| 5033 | fclose (fp); | ||
| 5034 | if (buf) | ||
| 5035 | { | ||
| 5036 | xfree (buf); | ||
| 5037 | buf = NULL; | ||
| 5038 | } | ||
| 5039 | } | ||
| 5040 | |||
| 5041 | return buf; | ||
| 5042 | } | ||
| 5043 | #endif | ||
| 5044 | #endif /* HAVE_NTGUI */ | ||
| 5045 | |||
| 5046 | /* Load PBM image IMG for use on frame F. */ | 5006 | /* Load PBM image IMG for use on frame F. */ |
| 5047 | 5007 | ||
| 5048 | static bool | 5008 | static bool |
diff --git a/src/lisp.h b/src/lisp.h index 1de9ec74d9f..7afe7b373fe 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -3027,7 +3027,7 @@ extern Lisp_Object oblookup (Lisp_Object, const char *, ptrdiff_t, ptrdiff_t); | |||
| 3027 | } while (0) | 3027 | } while (0) |
| 3028 | extern int openp (Lisp_Object, Lisp_Object, Lisp_Object, | 3028 | extern int openp (Lisp_Object, Lisp_Object, Lisp_Object, |
| 3029 | Lisp_Object *, Lisp_Object); | 3029 | Lisp_Object *, Lisp_Object); |
| 3030 | Lisp_Object string_to_number (char const *, int, int); | 3030 | extern Lisp_Object string_to_number (char const *, int, bool); |
| 3031 | extern void map_obarray (Lisp_Object, void (*) (Lisp_Object, Lisp_Object), | 3031 | extern void map_obarray (Lisp_Object, void (*) (Lisp_Object, Lisp_Object), |
| 3032 | Lisp_Object); | 3032 | Lisp_Object); |
| 3033 | extern void dir_warning (const char *, Lisp_Object); | 3033 | extern void dir_warning (const char *, Lisp_Object); |
| @@ -3182,6 +3182,7 @@ extern void internal_delete_file (Lisp_Object); | |||
| 3182 | extern void syms_of_fileio (void); | 3182 | extern void syms_of_fileio (void); |
| 3183 | extern Lisp_Object make_temp_name (Lisp_Object, bool); | 3183 | extern Lisp_Object make_temp_name (Lisp_Object, bool); |
| 3184 | extern Lisp_Object Qdelete_file; | 3184 | extern Lisp_Object Qdelete_file; |
| 3185 | extern bool check_existing (const char *); | ||
| 3185 | 3186 | ||
| 3186 | /* Defined in search.c. */ | 3187 | /* Defined in search.c. */ |
| 3187 | extern void shrink_regexp_cache (void); | 3188 | extern void shrink_regexp_cache (void); |
diff --git a/src/lread.c b/src/lread.c index a2b6d1f26d9..6d4c0d990af 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -95,10 +95,10 @@ static Lisp_Object Qload_in_progress; | |||
| 95 | It must be set to nil before all top-level calls to read0. */ | 95 | It must be set to nil before all top-level calls to read0. */ |
| 96 | static Lisp_Object read_objects; | 96 | static Lisp_Object read_objects; |
| 97 | 97 | ||
| 98 | /* Nonzero means READCHAR should read bytes one by one (not character) | 98 | /* True means READCHAR should read bytes one by one (not character) |
| 99 | when READCHARFUN is Qget_file_char or Qget_emacs_mule_file_char. | 99 | when READCHARFUN is Qget_file_char or Qget_emacs_mule_file_char. |
| 100 | This is set to 1 by read1 temporarily while handling #@NUMBER. */ | 100 | This is set by read1 temporarily while handling #@NUMBER. */ |
| 101 | static int load_each_byte; | 101 | static bool load_each_byte; |
| 102 | 102 | ||
| 103 | /* List of descriptors now open for Fload. */ | 103 | /* List of descriptors now open for Fload. */ |
| 104 | static Lisp_Object load_descriptor_list; | 104 | static Lisp_Object load_descriptor_list; |
| @@ -135,11 +135,11 @@ static ptrdiff_t prev_saved_doc_string_length; | |||
| 135 | /* This is the file position that string came from. */ | 135 | /* This is the file position that string came from. */ |
| 136 | static file_offset prev_saved_doc_string_position; | 136 | static file_offset prev_saved_doc_string_position; |
| 137 | 137 | ||
| 138 | /* Nonzero means inside a new-style backquote | 138 | /* True means inside a new-style backquote |
| 139 | with no surrounding parentheses. | 139 | with no surrounding parentheses. |
| 140 | Fread initializes this to zero, so we need not specbind it | 140 | Fread initializes this to false, so we need not specbind it |
| 141 | or worry about what happens to it when there is an error. */ | 141 | or worry about what happens to it when there is an error. */ |
| 142 | static int new_backquote_flag; | 142 | static bool new_backquote_flag; |
| 143 | static Lisp_Object Qold_style_backquotes; | 143 | static Lisp_Object Qold_style_backquotes; |
| 144 | 144 | ||
| 145 | /* A list of file names for files being loaded in Fload. Used to | 145 | /* A list of file names for files being loaded in Fload. Used to |
| @@ -150,7 +150,7 @@ static Lisp_Object Vloads_in_progress; | |||
| 150 | static int read_emacs_mule_char (int, int (*) (int, Lisp_Object), | 150 | static int read_emacs_mule_char (int, int (*) (int, Lisp_Object), |
| 151 | Lisp_Object); | 151 | Lisp_Object); |
| 152 | 152 | ||
| 153 | static void readevalloop (Lisp_Object, FILE*, Lisp_Object, int, | 153 | static void readevalloop (Lisp_Object, FILE *, Lisp_Object, bool, |
| 154 | Lisp_Object, Lisp_Object, | 154 | Lisp_Object, Lisp_Object, |
| 155 | Lisp_Object, Lisp_Object); | 155 | Lisp_Object, Lisp_Object); |
| 156 | static Lisp_Object load_unwind (Lisp_Object); | 156 | static Lisp_Object load_unwind (Lisp_Object); |
| @@ -192,7 +192,7 @@ readchar (Lisp_Object readcharfun, bool *multibyte) | |||
| 192 | int (*readbyte) (int, Lisp_Object); | 192 | int (*readbyte) (int, Lisp_Object); |
| 193 | unsigned char buf[MAX_MULTIBYTE_LENGTH]; | 193 | unsigned char buf[MAX_MULTIBYTE_LENGTH]; |
| 194 | int i, len; | 194 | int i, len; |
| 195 | int emacs_mule_encoding = 0; | 195 | bool emacs_mule_encoding = 0; |
| 196 | 196 | ||
| 197 | if (multibyte) | 197 | if (multibyte) |
| 198 | *multibyte = 0; | 198 | *multibyte = 0; |
| @@ -546,10 +546,10 @@ read_emacs_mule_char (int c, int (*readbyte) (int, Lisp_Object), Lisp_Object rea | |||
| 546 | static Lisp_Object read_internal_start (Lisp_Object, Lisp_Object, | 546 | static Lisp_Object read_internal_start (Lisp_Object, Lisp_Object, |
| 547 | Lisp_Object); | 547 | Lisp_Object); |
| 548 | static Lisp_Object read0 (Lisp_Object); | 548 | static Lisp_Object read0 (Lisp_Object); |
| 549 | static Lisp_Object read1 (Lisp_Object, int *, int); | 549 | static Lisp_Object read1 (Lisp_Object, int *, bool); |
| 550 | 550 | ||
| 551 | static Lisp_Object read_list (int, Lisp_Object); | 551 | static Lisp_Object read_list (bool, Lisp_Object); |
| 552 | static Lisp_Object read_vector (Lisp_Object, int); | 552 | static Lisp_Object read_vector (Lisp_Object, bool); |
| 553 | 553 | ||
| 554 | static Lisp_Object substitute_object_recurse (Lisp_Object, Lisp_Object, | 554 | static Lisp_Object substitute_object_recurse (Lisp_Object, Lisp_Object, |
| 555 | Lisp_Object); | 555 | Lisp_Object); |
| @@ -562,28 +562,28 @@ static void substitute_in_interval (INTERVAL, Lisp_Object); | |||
| 562 | 562 | ||
| 563 | /* Read input events until we get one that's acceptable for our purposes. | 563 | /* Read input events until we get one that's acceptable for our purposes. |
| 564 | 564 | ||
| 565 | If NO_SWITCH_FRAME is non-zero, switch-frame events are stashed | 565 | If NO_SWITCH_FRAME, switch-frame events are stashed |
| 566 | until we get a character we like, and then stuffed into | 566 | until we get a character we like, and then stuffed into |
| 567 | unread_switch_frame. | 567 | unread_switch_frame. |
| 568 | 568 | ||
| 569 | If ASCII_REQUIRED is non-zero, we check function key events to see | 569 | If ASCII_REQUIRED, check function key events to see |
| 570 | if the unmodified version of the symbol has a Qascii_character | 570 | if the unmodified version of the symbol has a Qascii_character |
| 571 | property, and use that character, if present. | 571 | property, and use that character, if present. |
| 572 | 572 | ||
| 573 | If ERROR_NONASCII is non-zero, we signal an error if the input we | 573 | If ERROR_NONASCII, signal an error if the input we |
| 574 | get isn't an ASCII character with modifiers. If it's zero but | 574 | get isn't an ASCII character with modifiers. If it's false but |
| 575 | ASCII_REQUIRED is non-zero, we just re-read until we get an ASCII | 575 | ASCII_REQUIRED is true, just re-read until we get an ASCII |
| 576 | character. | 576 | character. |
| 577 | 577 | ||
| 578 | If INPUT_METHOD is nonzero, we invoke the current input method | 578 | If INPUT_METHOD, invoke the current input method |
| 579 | if the character warrants that. | 579 | if the character warrants that. |
| 580 | 580 | ||
| 581 | If SECONDS is a number, we wait that many seconds for input, and | 581 | If SECONDS is a number, wait that many seconds for input, and |
| 582 | return Qnil if no input arrives within that time. */ | 582 | return Qnil if no input arrives within that time. */ |
| 583 | 583 | ||
| 584 | static Lisp_Object | 584 | static Lisp_Object |
| 585 | read_filtered_event (int no_switch_frame, int ascii_required, | 585 | read_filtered_event (bool no_switch_frame, bool ascii_required, |
| 586 | int error_nonascii, int input_method, Lisp_Object seconds) | 586 | bool error_nonascii, bool input_method, Lisp_Object seconds) |
| 587 | { | 587 | { |
| 588 | Lisp_Object val, delayed_switch_frame; | 588 | Lisp_Object val, delayed_switch_frame; |
| 589 | EMACS_TIME end_time; | 589 | EMACS_TIME end_time; |
| @@ -767,7 +767,7 @@ DEFUN ("get-file-char", Fget_file_char, Sget_file_char, 0, 0, 0, | |||
| 767 | positioned following the first line, if it is a comment or #! line, | 767 | positioned following the first line, if it is a comment or #! line, |
| 768 | otherwise nothing is read. */ | 768 | otherwise nothing is read. */ |
| 769 | 769 | ||
| 770 | static int | 770 | static bool |
| 771 | lisp_file_lexically_bound_p (Lisp_Object readcharfun) | 771 | lisp_file_lexically_bound_p (Lisp_Object readcharfun) |
| 772 | { | 772 | { |
| 773 | int ch = READCHAR; | 773 | int ch = READCHAR; |
| @@ -797,11 +797,11 @@ lisp_file_lexically_bound_p (Lisp_Object readcharfun) | |||
| 797 | else | 797 | else |
| 798 | /* Look for an appropriate file-variable in the first line. */ | 798 | /* Look for an appropriate file-variable in the first line. */ |
| 799 | { | 799 | { |
| 800 | int rv = 0; | 800 | bool rv = 0; |
| 801 | enum { | 801 | enum { |
| 802 | NOMINAL, AFTER_FIRST_DASH, AFTER_ASTERIX, | 802 | NOMINAL, AFTER_FIRST_DASH, AFTER_ASTERIX, |
| 803 | } beg_end_state = NOMINAL; | 803 | } beg_end_state = NOMINAL; |
| 804 | int in_file_vars = 0; | 804 | bool in_file_vars = 0; |
| 805 | 805 | ||
| 806 | #define UPDATE_BEG_END_STATE(ch) \ | 806 | #define UPDATE_BEG_END_STATE(ch) \ |
| 807 | if (beg_end_state == NOMINAL) \ | 807 | if (beg_end_state == NOMINAL) \ |
| @@ -897,20 +897,17 @@ lisp_file_lexically_bound_p (Lisp_Object readcharfun) | |||
| 897 | because of an incompatible change in the byte compiler. */ | 897 | because of an incompatible change in the byte compiler. */ |
| 898 | 898 | ||
| 899 | static int | 899 | static int |
| 900 | safe_to_load_p (int fd) | 900 | safe_to_load_version (int fd) |
| 901 | { | 901 | { |
| 902 | char buf[512]; | 902 | char buf[512]; |
| 903 | int nbytes, i; | 903 | int nbytes, i; |
| 904 | int safe_p = 1; | ||
| 905 | int version = 1; | 904 | int version = 1; |
| 906 | 905 | ||
| 907 | /* Read the first few bytes from the file, and look for a line | 906 | /* Read the first few bytes from the file, and look for a line |
| 908 | specifying the byte compiler version used. */ | 907 | specifying the byte compiler version used. */ |
| 909 | nbytes = emacs_read (fd, buf, sizeof buf - 1); | 908 | nbytes = emacs_read (fd, buf, sizeof buf); |
| 910 | if (nbytes > 0) | 909 | if (nbytes > 0) |
| 911 | { | 910 | { |
| 912 | buf[nbytes] = '\0'; | ||
| 913 | |||
| 914 | /* Skip to the next newline, skipping over the initial `ELC' | 911 | /* Skip to the next newline, skipping over the initial `ELC' |
| 915 | with NUL bytes following it, but note the version. */ | 912 | with NUL bytes following it, but note the version. */ |
| 916 | for (i = 0; i < nbytes && buf[i] != '\n'; ++i) | 913 | for (i = 0; i < nbytes && buf[i] != '\n'; ++i) |
| @@ -920,13 +917,11 @@ safe_to_load_p (int fd) | |||
| 920 | if (i >= nbytes | 917 | if (i >= nbytes |
| 921 | || fast_c_string_match_ignore_case (Vbytecomp_version_regexp, | 918 | || fast_c_string_match_ignore_case (Vbytecomp_version_regexp, |
| 922 | buf + i, nbytes - i) < 0) | 919 | buf + i, nbytes - i) < 0) |
| 923 | safe_p = 0; | 920 | version = 0; |
| 924 | } | 921 | } |
| 925 | if (safe_p) | ||
| 926 | safe_p = version; | ||
| 927 | 922 | ||
| 928 | lseek (fd, 0, SEEK_SET); | 923 | lseek (fd, 0, SEEK_SET); |
| 929 | return safe_p; | 924 | return version; |
| 930 | } | 925 | } |
| 931 | 926 | ||
| 932 | 927 | ||
| @@ -1030,12 +1025,12 @@ Return t if the file exists and loads successfully. */) | |||
| 1030 | ptrdiff_t count = SPECPDL_INDEX (); | 1025 | ptrdiff_t count = SPECPDL_INDEX (); |
| 1031 | struct gcpro gcpro1, gcpro2, gcpro3; | 1026 | struct gcpro gcpro1, gcpro2, gcpro3; |
| 1032 | Lisp_Object found, efound, hist_file_name; | 1027 | Lisp_Object found, efound, hist_file_name; |
| 1033 | /* 1 means we printed the ".el is newer" message. */ | 1028 | /* True means we printed the ".el is newer" message. */ |
| 1034 | int newer = 0; | 1029 | bool newer = 0; |
| 1035 | /* 1 means we are loading a compiled file. */ | 1030 | /* True means we are loading a compiled file. */ |
| 1036 | int compiled = 0; | 1031 | bool compiled = 0; |
| 1037 | Lisp_Object handler; | 1032 | Lisp_Object handler; |
| 1038 | int safe_p = 1; | 1033 | bool safe_p = 1; |
| 1039 | const char *fmode = "r"; | 1034 | const char *fmode = "r"; |
| 1040 | Lisp_Object tmp[2]; | 1035 | Lisp_Object tmp[2]; |
| 1041 | int version; | 1036 | int version; |
| @@ -1190,7 +1185,7 @@ Return t if the file exists and loads successfully. */) | |||
| 1190 | record_unwind_protect (load_warn_old_style_backquotes, file); | 1185 | record_unwind_protect (load_warn_old_style_backquotes, file); |
| 1191 | 1186 | ||
| 1192 | if (!memcmp (SDATA (found) + SBYTES (found) - 4, ".elc", 4) | 1187 | if (!memcmp (SDATA (found) + SBYTES (found) - 4, ".elc", 4) |
| 1193 | || (fd >= 0 && (version = safe_to_load_p (fd)) > 0)) | 1188 | || (fd >= 0 && (version = safe_to_load_version (fd)) > 0)) |
| 1194 | /* Load .elc files directly, but not when they are | 1189 | /* Load .elc files directly, but not when they are |
| 1195 | remote and have no handler! */ | 1190 | remote and have no handler! */ |
| 1196 | { | 1191 | { |
| @@ -1202,7 +1197,7 @@ Return t if the file exists and loads successfully. */) | |||
| 1202 | GCPRO3 (file, found, hist_file_name); | 1197 | GCPRO3 (file, found, hist_file_name); |
| 1203 | 1198 | ||
| 1204 | if (version < 0 | 1199 | if (version < 0 |
| 1205 | && ! (version = safe_to_load_p (fd))) | 1200 | && ! (version = safe_to_load_version (fd))) |
| 1206 | { | 1201 | { |
| 1207 | safe_p = 0; | 1202 | safe_p = 0; |
| 1208 | if (!load_dangerous_libraries) | 1203 | if (!load_dangerous_libraries) |
| @@ -1394,10 +1389,10 @@ close_load_descs (void) | |||
| 1394 | #endif | 1389 | #endif |
| 1395 | } | 1390 | } |
| 1396 | 1391 | ||
| 1397 | static int | 1392 | static bool |
| 1398 | complete_filename_p (Lisp_Object pathname) | 1393 | complete_filename_p (Lisp_Object pathname) |
| 1399 | { | 1394 | { |
| 1400 | register const unsigned char *s = SDATA (pathname); | 1395 | const unsigned char *s = SDATA (pathname); |
| 1401 | return (IS_DIRECTORY_SEP (s[0]) | 1396 | return (IS_DIRECTORY_SEP (s[0]) |
| 1402 | || (SCHARS (pathname) > 2 | 1397 | || (SCHARS (pathname) > 2 |
| 1403 | && IS_DEVICE_SEP (s[1]) && IS_DIRECTORY_SEP (s[2]))); | 1398 | && IS_DEVICE_SEP (s[1]) && IS_DIRECTORY_SEP (s[2]))); |
| @@ -1447,14 +1442,13 @@ static Lisp_Object Qdir_ok; | |||
| 1447 | int | 1442 | int |
| 1448 | openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *storeptr, Lisp_Object predicate) | 1443 | openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *storeptr, Lisp_Object predicate) |
| 1449 | { | 1444 | { |
| 1450 | register int fd; | 1445 | int fd; |
| 1451 | ptrdiff_t fn_size = 100; | 1446 | ptrdiff_t fn_size = 100; |
| 1452 | char buf[100]; | 1447 | char buf[100]; |
| 1453 | register char *fn = buf; | 1448 | char *fn = buf; |
| 1454 | int absolute = 0; | 1449 | bool absolute = 0; |
| 1455 | ptrdiff_t want_length; | 1450 | ptrdiff_t want_length; |
| 1456 | Lisp_Object filename; | 1451 | Lisp_Object filename; |
| 1457 | struct stat st; | ||
| 1458 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; | 1452 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; |
| 1459 | Lisp_Object string, tail, encoded_fn; | 1453 | Lisp_Object string, tail, encoded_fn; |
| 1460 | ptrdiff_t max_suffix_len = 0; | 1454 | ptrdiff_t max_suffix_len = 0; |
| @@ -1503,7 +1497,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto | |||
| 1503 | { | 1497 | { |
| 1504 | ptrdiff_t fnlen, lsuffix = SBYTES (XCAR (tail)); | 1498 | ptrdiff_t fnlen, lsuffix = SBYTES (XCAR (tail)); |
| 1505 | Lisp_Object handler; | 1499 | Lisp_Object handler; |
| 1506 | int exists; | 1500 | bool exists; |
| 1507 | 1501 | ||
| 1508 | /* Concatenate path element/specified name with the suffix. | 1502 | /* Concatenate path element/specified name with the suffix. |
| 1509 | If the directory starts with /:, remove that. */ | 1503 | If the directory starts with /:, remove that. */ |
| @@ -1548,11 +1542,18 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto | |||
| 1548 | } | 1542 | } |
| 1549 | else | 1543 | else |
| 1550 | { | 1544 | { |
| 1545 | #ifndef WINDOWSNT | ||
| 1546 | struct stat st; | ||
| 1547 | #endif | ||
| 1551 | const char *pfn; | 1548 | const char *pfn; |
| 1552 | 1549 | ||
| 1553 | encoded_fn = ENCODE_FILE (string); | 1550 | encoded_fn = ENCODE_FILE (string); |
| 1554 | pfn = SSDATA (encoded_fn); | 1551 | pfn = SSDATA (encoded_fn); |
| 1552 | #ifdef WINDOWSNT | ||
| 1553 | exists = access (pfn, F_OK) == 0 && access (pfn, D_OK) < 0; | ||
| 1554 | #else | ||
| 1555 | exists = (stat (pfn, &st) == 0 && ! S_ISDIR (st.st_mode)); | 1555 | exists = (stat (pfn, &st) == 0 && ! S_ISDIR (st.st_mode)); |
| 1556 | #endif | ||
| 1556 | if (exists) | 1557 | if (exists) |
| 1557 | { | 1558 | { |
| 1558 | /* Check that we can access or open it. */ | 1559 | /* Check that we can access or open it. */ |
| @@ -1588,14 +1589,16 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto | |||
| 1588 | the source has an associated file name or not. | 1589 | the source has an associated file name or not. |
| 1589 | 1590 | ||
| 1590 | FILENAME is the file name that we are loading from. | 1591 | FILENAME is the file name that we are loading from. |
| 1591 | ENTIRE is 1 if loading that entire file, 0 if evaluating part of it. */ | 1592 | |
| 1593 | ENTIRE is true if loading that entire file, false if evaluating | ||
| 1594 | part of it. */ | ||
| 1592 | 1595 | ||
| 1593 | static void | 1596 | static void |
| 1594 | build_load_history (Lisp_Object filename, int entire) | 1597 | build_load_history (Lisp_Object filename, bool entire) |
| 1595 | { | 1598 | { |
| 1596 | register Lisp_Object tail, prev, newelt; | 1599 | Lisp_Object tail, prev, newelt; |
| 1597 | register Lisp_Object tem, tem2; | 1600 | Lisp_Object tem, tem2; |
| 1598 | register int foundit = 0; | 1601 | bool foundit = 0; |
| 1599 | 1602 | ||
| 1600 | tail = Vload_history; | 1603 | tail = Vload_history; |
| 1601 | prev = Qnil; | 1604 | prev = Qnil; |
| @@ -1680,7 +1683,7 @@ static void | |||
| 1680 | readevalloop (Lisp_Object readcharfun, | 1683 | readevalloop (Lisp_Object readcharfun, |
| 1681 | FILE *stream, | 1684 | FILE *stream, |
| 1682 | Lisp_Object sourcename, | 1685 | Lisp_Object sourcename, |
| 1683 | int printflag, | 1686 | bool printflag, |
| 1684 | Lisp_Object unibyte, Lisp_Object readfun, | 1687 | Lisp_Object unibyte, Lisp_Object readfun, |
| 1685 | Lisp_Object start, Lisp_Object end) | 1688 | Lisp_Object start, Lisp_Object end) |
| 1686 | { | 1689 | { |
| @@ -1689,12 +1692,12 @@ readevalloop (Lisp_Object readcharfun, | |||
| 1689 | ptrdiff_t count = SPECPDL_INDEX (); | 1692 | ptrdiff_t count = SPECPDL_INDEX (); |
| 1690 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 1693 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
| 1691 | struct buffer *b = 0; | 1694 | struct buffer *b = 0; |
| 1692 | int continue_reading_p; | 1695 | bool continue_reading_p; |
| 1693 | Lisp_Object lex_bound; | 1696 | Lisp_Object lex_bound; |
| 1694 | /* Nonzero if reading an entire buffer. */ | 1697 | /* True if reading an entire buffer. */ |
| 1695 | int whole_buffer = 0; | 1698 | bool whole_buffer = 0; |
| 1696 | /* 1 on the first time around. */ | 1699 | /* True on the first time around. */ |
| 1697 | int first_sexp = 1; | 1700 | bool first_sexp = 1; |
| 1698 | Lisp_Object macroexpand = intern ("internal-macroexpand-for-load"); | 1701 | Lisp_Object macroexpand = intern ("internal-macroexpand-for-load"); |
| 1699 | 1702 | ||
| 1700 | if (NILP (Ffboundp (macroexpand)) | 1703 | if (NILP (Ffboundp (macroexpand)) |
| @@ -2072,9 +2075,9 @@ static char *read_buffer; | |||
| 2072 | If the escape sequence forces unibyte, return eight-bit char. */ | 2075 | If the escape sequence forces unibyte, return eight-bit char. */ |
| 2073 | 2076 | ||
| 2074 | static int | 2077 | static int |
| 2075 | read_escape (Lisp_Object readcharfun, int stringp) | 2078 | read_escape (Lisp_Object readcharfun, bool stringp) |
| 2076 | { | 2079 | { |
| 2077 | register int c = READCHAR; | 2080 | int c = READCHAR; |
| 2078 | /* \u allows up to four hex digits, \U up to eight. Default to the | 2081 | /* \u allows up to four hex digits, \U up to eight. Default to the |
| 2079 | behavior for \u, and change this value in the case that \U is seen. */ | 2082 | behavior for \u, and change this value in the case that \U is seen. */ |
| 2080 | int unicode_hex_count = 4; | 2083 | int unicode_hex_count = 4; |
| @@ -2375,10 +2378,10 @@ read_integer (Lisp_Object readcharfun, EMACS_INT radix) | |||
| 2375 | in *PCH and the return value is not interesting. Else, we store | 2378 | in *PCH and the return value is not interesting. Else, we store |
| 2376 | zero in *PCH and we read and return one lisp object. | 2379 | zero in *PCH and we read and return one lisp object. |
| 2377 | 2380 | ||
| 2378 | FIRST_IN_LIST is nonzero if this is the first element of a list. */ | 2381 | FIRST_IN_LIST is true if this is the first element of a list. */ |
| 2379 | 2382 | ||
| 2380 | static Lisp_Object | 2383 | static Lisp_Object |
| 2381 | read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | 2384 | read1 (Lisp_Object readcharfun, int *pch, bool first_in_list) |
| 2382 | { | 2385 | { |
| 2383 | int c; | 2386 | int c; |
| 2384 | bool uninterned_symbol = 0; | 2387 | bool uninterned_symbol = 0; |
| @@ -2803,10 +2806,11 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2803 | else | 2806 | else |
| 2804 | { | 2807 | { |
| 2805 | Lisp_Object value; | 2808 | Lisp_Object value; |
| 2809 | bool saved_new_backquote_flag = new_backquote_flag; | ||
| 2806 | 2810 | ||
| 2807 | new_backquote_flag++; | 2811 | new_backquote_flag = 1; |
| 2808 | value = read0 (readcharfun); | 2812 | value = read0 (readcharfun); |
| 2809 | new_backquote_flag--; | 2813 | new_backquote_flag = saved_new_backquote_flag; |
| 2810 | 2814 | ||
| 2811 | return Fcons (Qbackquote, Fcons (value, Qnil)); | 2815 | return Fcons (Qbackquote, Fcons (value, Qnil)); |
| 2812 | } | 2816 | } |
| @@ -2858,7 +2862,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2858 | { | 2862 | { |
| 2859 | int modifiers; | 2863 | int modifiers; |
| 2860 | int next_char; | 2864 | int next_char; |
| 2861 | int ok; | 2865 | bool ok; |
| 2862 | 2866 | ||
| 2863 | c = READCHAR; | 2867 | c = READCHAR; |
| 2864 | if (c < 0) | 2868 | if (c < 0) |
| @@ -2894,14 +2898,14 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2894 | { | 2898 | { |
| 2895 | char *p = read_buffer; | 2899 | char *p = read_buffer; |
| 2896 | char *end = read_buffer + read_buffer_size; | 2900 | char *end = read_buffer + read_buffer_size; |
| 2897 | register int ch; | 2901 | int ch; |
| 2898 | /* Nonzero if we saw an escape sequence specifying | 2902 | /* True if we saw an escape sequence specifying |
| 2899 | a multibyte character. */ | 2903 | a multibyte character. */ |
| 2900 | int force_multibyte = 0; | 2904 | bool force_multibyte = 0; |
| 2901 | /* Nonzero if we saw an escape sequence specifying | 2905 | /* True if we saw an escape sequence specifying |
| 2902 | a single-byte character. */ | 2906 | a single-byte character. */ |
| 2903 | int force_singlebyte = 0; | 2907 | bool force_singlebyte = 0; |
| 2904 | int cancel = 0; | 2908 | bool cancel = 0; |
| 2905 | ptrdiff_t nchars = 0; | 2909 | ptrdiff_t nchars = 0; |
| 2906 | 2910 | ||
| 2907 | while ((ch = READCHAR) >= 0 | 2911 | while ((ch = READCHAR) >= 0 |
| @@ -3033,7 +3037,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 3033 | read_symbol: | 3037 | read_symbol: |
| 3034 | { | 3038 | { |
| 3035 | char *p = read_buffer; | 3039 | char *p = read_buffer; |
| 3036 | int quoted = 0; | 3040 | bool quoted = 0; |
| 3037 | EMACS_INT start_position = readchar_count - 1; | 3041 | EMACS_INT start_position = readchar_count - 1; |
| 3038 | 3042 | ||
| 3039 | { | 3043 | { |
| @@ -3250,17 +3254,17 @@ substitute_in_interval (INTERVAL interval, Lisp_Object arg) | |||
| 3250 | /* Convert STRING to a number, assuming base BASE. Return a fixnum if CP has | 3254 | /* Convert STRING to a number, assuming base BASE. Return a fixnum if CP has |
| 3251 | integer syntax and fits in a fixnum, else return the nearest float if CP has | 3255 | integer syntax and fits in a fixnum, else return the nearest float if CP has |
| 3252 | either floating point or integer syntax and BASE is 10, else return nil. If | 3256 | either floating point or integer syntax and BASE is 10, else return nil. If |
| 3253 | IGNORE_TRAILING is nonzero, consider just the longest prefix of CP that has | 3257 | IGNORE_TRAILING, consider just the longest prefix of CP that has |
| 3254 | valid floating point syntax. Signal an overflow if BASE is not 10 and the | 3258 | valid floating point syntax. Signal an overflow if BASE is not 10 and the |
| 3255 | number has integer syntax but does not fit. */ | 3259 | number has integer syntax but does not fit. */ |
| 3256 | 3260 | ||
| 3257 | Lisp_Object | 3261 | Lisp_Object |
| 3258 | string_to_number (char const *string, int base, int ignore_trailing) | 3262 | string_to_number (char const *string, int base, bool ignore_trailing) |
| 3259 | { | 3263 | { |
| 3260 | int state; | 3264 | int state; |
| 3261 | char const *cp = string; | 3265 | char const *cp = string; |
| 3262 | int leading_digit; | 3266 | int leading_digit; |
| 3263 | int float_syntax = 0; | 3267 | bool float_syntax = 0; |
| 3264 | double value = 0; | 3268 | double value = 0; |
| 3265 | 3269 | ||
| 3266 | /* Compute NaN and infinities using a variable, to cope with compilers that | 3270 | /* Compute NaN and infinities using a variable, to cope with compilers that |
| @@ -3270,9 +3274,9 @@ string_to_number (char const *string, int base, int ignore_trailing) | |||
| 3270 | /* Negate the value ourselves. This treats 0, NaNs, and infinity properly on | 3274 | /* Negate the value ourselves. This treats 0, NaNs, and infinity properly on |
| 3271 | IEEE floating point hosts, and works around a formerly-common bug where | 3275 | IEEE floating point hosts, and works around a formerly-common bug where |
| 3272 | atof ("-0.0") drops the sign. */ | 3276 | atof ("-0.0") drops the sign. */ |
| 3273 | int negative = *cp == '-'; | 3277 | bool negative = *cp == '-'; |
| 3274 | 3278 | ||
| 3275 | int signedp = negative || *cp == '+'; | 3279 | bool signedp = negative || *cp == '+'; |
| 3276 | cp += signedp; | 3280 | cp += signedp; |
| 3277 | 3281 | ||
| 3278 | state = 0; | 3282 | state = 0; |
| @@ -3365,7 +3369,7 @@ string_to_number (char const *string, int base, int ignore_trailing) | |||
| 3365 | uintmax_t n; | 3369 | uintmax_t n; |
| 3366 | 3370 | ||
| 3367 | /* Fast special case for single-digit integers. This also avoids a | 3371 | /* Fast special case for single-digit integers. This also avoids a |
| 3368 | glitch when BASE is 16 and IGNORE_TRAILING is nonzero, because in that | 3372 | glitch when BASE is 16 and IGNORE_TRAILING, because in that |
| 3369 | case some versions of strtoumax accept numbers like "0x1" that Emacs | 3373 | case some versions of strtoumax accept numbers like "0x1" that Emacs |
| 3370 | does not allow. */ | 3374 | does not allow. */ |
| 3371 | if (digit_to_number (string[signedp + 1], base) < 0) | 3375 | if (digit_to_number (string[signedp + 1], base) < 0) |
| @@ -3401,12 +3405,12 @@ string_to_number (char const *string, int base, int ignore_trailing) | |||
| 3401 | 3405 | ||
| 3402 | 3406 | ||
| 3403 | static Lisp_Object | 3407 | static Lisp_Object |
| 3404 | read_vector (Lisp_Object readcharfun, int bytecodeflag) | 3408 | read_vector (Lisp_Object readcharfun, bool bytecodeflag) |
| 3405 | { | 3409 | { |
| 3406 | ptrdiff_t i, size; | 3410 | ptrdiff_t i, size; |
| 3407 | register Lisp_Object *ptr; | 3411 | Lisp_Object *ptr; |
| 3408 | register Lisp_Object tem, item, vector; | 3412 | Lisp_Object tem, item, vector; |
| 3409 | register struct Lisp_Cons *otem; | 3413 | struct Lisp_Cons *otem; |
| 3410 | Lisp_Object len; | 3414 | Lisp_Object len; |
| 3411 | 3415 | ||
| 3412 | tem = read_list (1, readcharfun); | 3416 | tem = read_list (1, readcharfun); |
| @@ -3478,13 +3482,13 @@ read_vector (Lisp_Object readcharfun, int bytecodeflag) | |||
| 3478 | return vector; | 3482 | return vector; |
| 3479 | } | 3483 | } |
| 3480 | 3484 | ||
| 3481 | /* FLAG = 1 means check for ] to terminate rather than ) and . */ | 3485 | /* FLAG means check for ] to terminate rather than ) and . */ |
| 3482 | 3486 | ||
| 3483 | static Lisp_Object | 3487 | static Lisp_Object |
| 3484 | read_list (int flag, register Lisp_Object readcharfun) | 3488 | read_list (bool flag, Lisp_Object readcharfun) |
| 3485 | { | 3489 | { |
| 3486 | Lisp_Object val, tail; | 3490 | Lisp_Object val, tail; |
| 3487 | register Lisp_Object elt, tem; | 3491 | Lisp_Object elt, tem; |
| 3488 | struct gcpro gcpro1, gcpro2; | 3492 | struct gcpro gcpro1, gcpro2; |
| 3489 | /* 0 is the normal case. | 3493 | /* 0 is the normal case. |
| 3490 | 1 means this list is a doc reference; replace it with the number 0. | 3494 | 1 means this list is a doc reference; replace it with the number 0. |
| @@ -3492,7 +3496,7 @@ read_list (int flag, register Lisp_Object readcharfun) | |||
| 3492 | int doc_reference = 0; | 3496 | int doc_reference = 0; |
| 3493 | 3497 | ||
| 3494 | /* Initialize this to 1 if we are reading a list. */ | 3498 | /* Initialize this to 1 if we are reading a list. */ |
| 3495 | int first_in_list = flag <= 0; | 3499 | bool first_in_list = flag <= 0; |
| 3496 | 3500 | ||
| 3497 | val = Qnil; | 3501 | val = Qnil; |
| 3498 | tail = Qnil; | 3502 | tail = Qnil; |
diff --git a/src/macros.c b/src/macros.c index a507f12e343..632c851ee8c 100644 --- a/src/macros.c +++ b/src/macros.c | |||
| @@ -84,7 +84,7 @@ macro before appending to it. */) | |||
| 84 | { | 84 | { |
| 85 | ptrdiff_t i; | 85 | ptrdiff_t i; |
| 86 | EMACS_INT len; | 86 | EMACS_INT len; |
| 87 | int cvt; | 87 | bool cvt; |
| 88 | 88 | ||
| 89 | /* Check the type of last-kbd-macro in case Lisp code changed it. */ | 89 | /* Check the type of last-kbd-macro in case Lisp code changed it. */ |
| 90 | CHECK_VECTOR_OR_STRING (KVAR (current_kboard, Vlast_kbd_macro)); | 90 | CHECK_VECTOR_OR_STRING (KVAR (current_kboard, Vlast_kbd_macro)); |
diff --git a/src/makefile.w32-in b/src/makefile.w32-in index 40a075dbf3c..2acce9c123f 100644 --- a/src/makefile.w32-in +++ b/src/makefile.w32-in | |||
| @@ -833,6 +833,7 @@ $(BLD)/fileio.$(O) : \ | |||
| 833 | $(SRC)/blockinput.h \ | 833 | $(SRC)/blockinput.h \ |
| 834 | $(SRC)/commands.h \ | 834 | $(SRC)/commands.h \ |
| 835 | $(NT_INC)/pwd.h \ | 835 | $(NT_INC)/pwd.h \ |
| 836 | $(NT_INC)/sys/file.h \ | ||
| 836 | $(NT_INC)/sys/stat.h \ | 837 | $(NT_INC)/sys/stat.h \ |
| 837 | $(NT_INC)/unistd.h \ | 838 | $(NT_INC)/unistd.h \ |
| 838 | $(BUFFER_H) \ | 839 | $(BUFFER_H) \ |
| @@ -1632,6 +1633,7 @@ $(BLD)/w32select.$(O) : \ | |||
| 1632 | $(CHARSET_H) \ | 1633 | $(CHARSET_H) \ |
| 1633 | $(CODING_H) \ | 1634 | $(CODING_H) \ |
| 1634 | $(CONFIG_H) \ | 1635 | $(CONFIG_H) \ |
| 1636 | $(KEYBOARD_H) \ | ||
| 1635 | $(LISP_H) \ | 1637 | $(LISP_H) \ |
| 1636 | $(W32TERM_H) | 1638 | $(W32TERM_H) |
| 1637 | 1639 | ||
diff --git a/src/marker.c b/src/marker.c index 2e2aba579db..69be4faec3a 100644 --- a/src/marker.c +++ b/src/marker.c | |||
| @@ -91,7 +91,7 @@ clear_charpos_cache (struct buffer *b) | |||
| 91 | #define CONSIDER(CHARPOS, BYTEPOS) \ | 91 | #define CONSIDER(CHARPOS, BYTEPOS) \ |
| 92 | { \ | 92 | { \ |
| 93 | ptrdiff_t this_charpos = (CHARPOS); \ | 93 | ptrdiff_t this_charpos = (CHARPOS); \ |
| 94 | int changed = 0; \ | 94 | bool changed = 0; \ |
| 95 | \ | 95 | \ |
| 96 | if (this_charpos == charpos) \ | 96 | if (this_charpos == charpos) \ |
| 97 | { \ | 97 | { \ |
| @@ -190,7 +190,7 @@ buf_charpos_to_bytepos (struct buffer *b, ptrdiff_t charpos) | |||
| 190 | 190 | ||
| 191 | if (charpos - best_below < best_above - charpos) | 191 | if (charpos - best_below < best_above - charpos) |
| 192 | { | 192 | { |
| 193 | int record = charpos - best_below > 5000; | 193 | bool record = charpos - best_below > 5000; |
| 194 | 194 | ||
| 195 | while (best_below != charpos) | 195 | while (best_below != charpos) |
| 196 | { | 196 | { |
| @@ -215,7 +215,7 @@ buf_charpos_to_bytepos (struct buffer *b, ptrdiff_t charpos) | |||
| 215 | } | 215 | } |
| 216 | else | 216 | else |
| 217 | { | 217 | { |
| 218 | int record = best_above - charpos > 5000; | 218 | bool record = best_above - charpos > 5000; |
| 219 | 219 | ||
| 220 | while (best_above != charpos) | 220 | while (best_above != charpos) |
| 221 | { | 221 | { |
| @@ -335,7 +335,7 @@ buf_bytepos_to_charpos (struct buffer *b, ptrdiff_t bytepos) | |||
| 335 | 335 | ||
| 336 | if (bytepos - best_below_byte < best_above_byte - bytepos) | 336 | if (bytepos - best_below_byte < best_above_byte - bytepos) |
| 337 | { | 337 | { |
| 338 | int record = bytepos - best_below_byte > 5000; | 338 | bool record = bytepos - best_below_byte > 5000; |
| 339 | 339 | ||
| 340 | while (best_below_byte < bytepos) | 340 | while (best_below_byte < bytepos) |
| 341 | { | 341 | { |
| @@ -362,7 +362,7 @@ buf_bytepos_to_charpos (struct buffer *b, ptrdiff_t bytepos) | |||
| 362 | } | 362 | } |
| 363 | else | 363 | else |
| 364 | { | 364 | { |
| 365 | int record = best_above_byte - bytepos > 5000; | 365 | bool record = best_above_byte - bytepos > 5000; |
| 366 | 366 | ||
| 367 | while (best_above_byte > bytepos) | 367 | while (best_above_byte > bytepos) |
| 368 | { | 368 | { |
| @@ -479,10 +479,10 @@ live_buffer (Lisp_Object buffer) | |||
| 479 | 479 | ||
| 480 | static Lisp_Object | 480 | static Lisp_Object |
| 481 | set_marker_internal (Lisp_Object marker, Lisp_Object position, | 481 | set_marker_internal (Lisp_Object marker, Lisp_Object position, |
| 482 | Lisp_Object buffer, int restricted) | 482 | Lisp_Object buffer, bool restricted) |
| 483 | { | 483 | { |
| 484 | register struct Lisp_Marker *m; | 484 | struct Lisp_Marker *m; |
| 485 | register struct buffer *b = live_buffer (buffer); | 485 | struct buffer *b = live_buffer (buffer); |
| 486 | 486 | ||
| 487 | CHECK_MARKER (marker); | 487 | CHECK_MARKER (marker); |
| 488 | m = XMARKER (marker); | 488 | m = XMARKER (marker); |
diff --git a/src/menu.c b/src/menu.c index 6e052dc65a9..7cc110ce7e2 100644 --- a/src/menu.c +++ b/src/menu.c | |||
| @@ -519,14 +519,15 @@ list_of_panes (Lisp_Object menu) | |||
| 519 | /* Set up data in menu_items for a menu bar item | 519 | /* Set up data in menu_items for a menu bar item |
| 520 | whose event type is ITEM_KEY (with string ITEM_NAME) | 520 | whose event type is ITEM_KEY (with string ITEM_NAME) |
| 521 | and whose contents come from the list of keymaps MAPS. */ | 521 | and whose contents come from the list of keymaps MAPS. */ |
| 522 | int | 522 | bool |
| 523 | parse_single_submenu (Lisp_Object item_key, Lisp_Object item_name, Lisp_Object maps) | 523 | parse_single_submenu (Lisp_Object item_key, Lisp_Object item_name, |
| 524 | Lisp_Object maps) | ||
| 524 | { | 525 | { |
| 525 | Lisp_Object length; | 526 | Lisp_Object length; |
| 526 | EMACS_INT len; | 527 | EMACS_INT len; |
| 527 | Lisp_Object *mapvec; | 528 | Lisp_Object *mapvec; |
| 528 | ptrdiff_t i; | 529 | ptrdiff_t i; |
| 529 | int top_level_items = 0; | 530 | bool top_level_items = 0; |
| 530 | USE_SAFE_ALLOCA; | 531 | USE_SAFE_ALLOCA; |
| 531 | 532 | ||
| 532 | length = Flength (maps); | 533 | length = Flength (maps); |
| @@ -616,13 +617,13 @@ free_menubar_widget_value_tree (widget_value *wv) | |||
| 616 | in menu_items starting at index START, up to index END. */ | 617 | in menu_items starting at index START, up to index END. */ |
| 617 | 618 | ||
| 618 | widget_value * | 619 | widget_value * |
| 619 | digest_single_submenu (int start, int end, int top_level_items) | 620 | digest_single_submenu (int start, int end, bool top_level_items) |
| 620 | { | 621 | { |
| 621 | widget_value *wv, *prev_wv, *save_wv, *first_wv; | 622 | widget_value *wv, *prev_wv, *save_wv, *first_wv; |
| 622 | int i; | 623 | int i; |
| 623 | int submenu_depth = 0; | 624 | int submenu_depth = 0; |
| 624 | widget_value **submenu_stack; | 625 | widget_value **submenu_stack; |
| 625 | int panes_seen = 0; | 626 | bool panes_seen = 0; |
| 626 | 627 | ||
| 627 | submenu_stack = alloca (menu_items_used * sizeof *submenu_stack); | 628 | submenu_stack = alloca (menu_items_used * sizeof *submenu_stack); |
| 628 | wv = xmalloc_widget_value (); | 629 | wv = xmalloc_widget_value (); |
| @@ -668,7 +669,7 @@ digest_single_submenu (int start, int end, int top_level_items) | |||
| 668 | Lisp_Object pane_name; | 669 | Lisp_Object pane_name; |
| 669 | const char *pane_string; | 670 | const char *pane_string; |
| 670 | 671 | ||
| 671 | panes_seen++; | 672 | panes_seen = 1; |
| 672 | 673 | ||
| 673 | pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME); | 674 | pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME); |
| 674 | 675 | ||
| @@ -735,7 +736,7 @@ digest_single_submenu (int start, int end, int top_level_items) | |||
| 735 | Lisp_Object help; | 736 | Lisp_Object help; |
| 736 | 737 | ||
| 737 | /* All items should be contained in panes. */ | 738 | /* All items should be contained in panes. */ |
| 738 | if (panes_seen == 0) | 739 | if (! panes_seen) |
| 739 | emacs_abort (); | 740 | emacs_abort (); |
| 740 | 741 | ||
| 741 | item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME); | 742 | item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME); |
| @@ -957,9 +958,9 @@ find_and_call_menu_selection (FRAME_PTR f, int menu_bar_items_used, Lisp_Object | |||
| 957 | 958 | ||
| 958 | #ifdef HAVE_NS | 959 | #ifdef HAVE_NS |
| 959 | /* As above, but return the menu selection instead of storing in kb buffer. | 960 | /* As above, but return the menu selection instead of storing in kb buffer. |
| 960 | If keymaps==1, return full prefixes to selection. */ | 961 | If KEYMAPS, return full prefixes to selection. */ |
| 961 | Lisp_Object | 962 | Lisp_Object |
| 962 | find_and_return_menu_selection (FRAME_PTR f, int keymaps, void *client_data) | 963 | find_and_return_menu_selection (FRAME_PTR f, bool keymaps, void *client_data) |
| 963 | { | 964 | { |
| 964 | Lisp_Object prefix, entry; | 965 | Lisp_Object prefix, entry; |
| 965 | int i; | 966 | int i; |
| @@ -999,7 +1000,7 @@ find_and_return_menu_selection (FRAME_PTR f, int keymaps, void *client_data) | |||
| 999 | = AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE); | 1000 | = AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE); |
| 1000 | if (aref_addr (menu_items, i) == client_data) | 1001 | if (aref_addr (menu_items, i) == client_data) |
| 1001 | { | 1002 | { |
| 1002 | if (keymaps != 0) | 1003 | if (keymaps) |
| 1003 | { | 1004 | { |
| 1004 | int j; | 1005 | int j; |
| 1005 | 1006 | ||
| @@ -1071,8 +1072,8 @@ no quit occurs and `x-popup-menu' returns nil. */) | |||
| 1071 | Lisp_Object selection = Qnil; | 1072 | Lisp_Object selection = Qnil; |
| 1072 | FRAME_PTR f = NULL; | 1073 | FRAME_PTR f = NULL; |
| 1073 | Lisp_Object x, y, window; | 1074 | Lisp_Object x, y, window; |
| 1074 | int keymaps = 0; | 1075 | bool keymaps = 0; |
| 1075 | int for_click = 0; | 1076 | bool for_click = 0; |
| 1076 | ptrdiff_t specpdl_count = SPECPDL_INDEX (); | 1077 | ptrdiff_t specpdl_count = SPECPDL_INDEX (); |
| 1077 | struct gcpro gcpro1; | 1078 | struct gcpro gcpro1; |
| 1078 | 1079 | ||
| @@ -1083,7 +1084,7 @@ no quit occurs and `x-popup-menu' returns nil. */) | |||
| 1083 | 1084 | ||
| 1084 | #ifdef HAVE_MENUS | 1085 | #ifdef HAVE_MENUS |
| 1085 | { | 1086 | { |
| 1086 | int get_current_pos_p = 0; | 1087 | bool get_current_pos_p = 0; |
| 1087 | /* FIXME!! check_w32 (); or check_x (); or check_ns (); */ | 1088 | /* FIXME!! check_w32 (); or check_x (); or check_ns (); */ |
| 1088 | 1089 | ||
| 1089 | /* Decode the first argument: find the window and the coordinates. */ | 1090 | /* Decode the first argument: find the window and the coordinates. */ |
diff --git a/src/menu.h b/src/menu.h index 3406928a8d5..67934c42d76 100644 --- a/src/menu.h +++ b/src/menu.h | |||
| @@ -29,7 +29,7 @@ extern void init_menu_items (void); | |||
| 29 | extern void finish_menu_items (void) ATTRIBUTE_CONST; | 29 | extern void finish_menu_items (void) ATTRIBUTE_CONST; |
| 30 | extern void discard_menu_items (void); | 30 | extern void discard_menu_items (void); |
| 31 | extern void save_menu_items (void); | 31 | extern void save_menu_items (void); |
| 32 | extern int parse_single_submenu (Lisp_Object, Lisp_Object, Lisp_Object); | 32 | extern bool parse_single_submenu (Lisp_Object, Lisp_Object, Lisp_Object); |
| 33 | extern void list_of_panes (Lisp_Object); | 33 | extern void list_of_panes (Lisp_Object); |
| 34 | #if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI) \ | 34 | #if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI) \ |
| 35 | || defined (HAVE_NS) | 35 | || defined (HAVE_NS) |
| @@ -38,7 +38,7 @@ extern void update_submenu_strings (widget_value *); | |||
| 38 | extern void find_and_call_menu_selection (FRAME_PTR, int, | 38 | extern void find_and_call_menu_selection (FRAME_PTR, int, |
| 39 | Lisp_Object, void *); | 39 | Lisp_Object, void *); |
| 40 | extern widget_value *xmalloc_widget_value (void); | 40 | extern widget_value *xmalloc_widget_value (void); |
| 41 | extern widget_value *digest_single_submenu (int, int, int); | 41 | extern widget_value *digest_single_submenu (int, int, bool); |
| 42 | #endif | 42 | #endif |
| 43 | 43 | ||
| 44 | #ifdef HAVE_X_WINDOWS | 44 | #ifdef HAVE_X_WINDOWS |
| @@ -47,8 +47,8 @@ extern void mouse_position_for_popup (FRAME_PTR f, int *x, int *y); | |||
| 47 | 47 | ||
| 48 | extern Lisp_Object w32_menu_show (FRAME_PTR, int, int, int, int, | 48 | extern Lisp_Object w32_menu_show (FRAME_PTR, int, int, int, int, |
| 49 | Lisp_Object, const char **); | 49 | Lisp_Object, const char **); |
| 50 | extern Lisp_Object ns_menu_show (FRAME_PTR, int, int, int, int, | 50 | extern Lisp_Object ns_menu_show (FRAME_PTR, int, int, bool, bool, |
| 51 | Lisp_Object, const char **); | 51 | Lisp_Object, const char **); |
| 52 | extern Lisp_Object xmenu_show (FRAME_PTR, int, int, int, int, | 52 | extern Lisp_Object xmenu_show (FRAME_PTR, int, int, bool, bool, |
| 53 | Lisp_Object, const char **, Time); | 53 | Lisp_Object, const char **, Time); |
| 54 | #endif /* MENU_H */ | 54 | #endif /* MENU_H */ |
diff --git a/src/minibuf.c b/src/minibuf.c index dd4ca34c3fb..2cc89e75680 100644 --- a/src/minibuf.c +++ b/src/minibuf.c | |||
| @@ -173,17 +173,6 @@ without invoking the usual minibuffer commands. */) | |||
| 173 | 173 | ||
| 174 | static Lisp_Object read_minibuf_unwind (Lisp_Object); | 174 | static Lisp_Object read_minibuf_unwind (Lisp_Object); |
| 175 | static Lisp_Object run_exit_minibuf_hook (Lisp_Object); | 175 | static Lisp_Object run_exit_minibuf_hook (Lisp_Object); |
| 176 | static Lisp_Object read_minibuf (Lisp_Object, Lisp_Object, | ||
| 177 | Lisp_Object, | ||
| 178 | int, Lisp_Object, | ||
| 179 | Lisp_Object, Lisp_Object, | ||
| 180 | int, int); | ||
| 181 | static Lisp_Object read_minibuf_noninteractive (Lisp_Object, Lisp_Object, | ||
| 182 | Lisp_Object, Lisp_Object, | ||
| 183 | int, Lisp_Object, | ||
| 184 | Lisp_Object, Lisp_Object, | ||
| 185 | int, int); | ||
| 186 | static Lisp_Object string_to_object (Lisp_Object, Lisp_Object); | ||
| 187 | 176 | ||
| 188 | 177 | ||
| 189 | /* Read a Lisp object from VAL and return it. If VAL is an empty | 178 | /* Read a Lisp object from VAL and return it. If VAL is an empty |
| @@ -233,10 +222,10 @@ string_to_object (Lisp_Object val, Lisp_Object defalt) | |||
| 233 | static Lisp_Object | 222 | static Lisp_Object |
| 234 | read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial, | 223 | read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial, |
| 235 | Lisp_Object prompt, Lisp_Object backup_n, | 224 | Lisp_Object prompt, Lisp_Object backup_n, |
| 236 | int expflag, | 225 | bool expflag, |
| 237 | Lisp_Object histvar, Lisp_Object histpos, | 226 | Lisp_Object histvar, Lisp_Object histpos, |
| 238 | Lisp_Object defalt, | 227 | Lisp_Object defalt, |
| 239 | int allow_props, int inherit_input_method) | 228 | bool allow_props, bool inherit_input_method) |
| 240 | { | 229 | { |
| 241 | ptrdiff_t size, len; | 230 | ptrdiff_t size, len; |
| 242 | char *line; | 231 | char *line; |
| @@ -376,23 +365,23 @@ If the current buffer is not a minibuffer, return its entire contents. */) | |||
| 376 | beginning of INITIAL if N <= 0. | 365 | beginning of INITIAL if N <= 0. |
| 377 | 366 | ||
| 378 | Normally return the result as a string (the text that was read), | 367 | Normally return the result as a string (the text that was read), |
| 379 | but if EXPFLAG is nonzero, read it and return the object read. | 368 | but if EXPFLAG, read it and return the object read. |
| 380 | If HISTVAR is given, save the value read on that history only if it doesn't | 369 | If HISTVAR is given, save the value read on that history only if it doesn't |
| 381 | match the front of that history list exactly. The value is pushed onto | 370 | match the front of that history list exactly. The value is pushed onto |
| 382 | the list as the string that was read. | 371 | the list as the string that was read. |
| 383 | 372 | ||
| 384 | DEFALT specifies the default value for the sake of history commands. | 373 | DEFALT specifies the default value for the sake of history commands. |
| 385 | 374 | ||
| 386 | If ALLOW_PROPS is nonzero, we do not throw away text properties. | 375 | If ALLOW_PROPS, do not throw away text properties. |
| 387 | 376 | ||
| 388 | if INHERIT_INPUT_METHOD is nonzero, the minibuffer inherits the | 377 | if INHERIT_INPUT_METHOD, the minibuffer inherits the |
| 389 | current input method. */ | 378 | current input method. */ |
| 390 | 379 | ||
| 391 | static Lisp_Object | 380 | static Lisp_Object |
| 392 | read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, | 381 | read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, |
| 393 | int expflag, | 382 | bool expflag, |
| 394 | Lisp_Object histvar, Lisp_Object histpos, Lisp_Object defalt, | 383 | Lisp_Object histvar, Lisp_Object histpos, Lisp_Object defalt, |
| 395 | int allow_props, int inherit_input_method) | 384 | bool allow_props, bool inherit_input_method) |
| 396 | { | 385 | { |
| 397 | Lisp_Object val; | 386 | Lisp_Object val; |
| 398 | ptrdiff_t count = SPECPDL_INDEX (); | 387 | ptrdiff_t count = SPECPDL_INDEX (); |
| @@ -1447,7 +1436,7 @@ is used to further constrain the set of candidates. */) | |||
| 1447 | if (bestmatchsize != SCHARS (eltstring) | 1436 | if (bestmatchsize != SCHARS (eltstring) |
| 1448 | || bestmatchsize != matchsize) | 1437 | || bestmatchsize != matchsize) |
| 1449 | /* Don't count the same string multiple times. */ | 1438 | /* Don't count the same string multiple times. */ |
| 1450 | matchcount++; | 1439 | matchcount += matchcount <= 1; |
| 1451 | bestmatchsize = matchsize; | 1440 | bestmatchsize = matchsize; |
| 1452 | if (matchsize <= SCHARS (string) | 1441 | if (matchsize <= SCHARS (string) |
| 1453 | /* If completion-ignore-case is non-nil, don't | 1442 | /* If completion-ignore-case is non-nil, don't |
diff --git a/src/nsfont.m b/src/nsfont.m index a820b60ac58..7c9f05aa0bb 100644 --- a/src/nsfont.m +++ b/src/nsfont.m | |||
| @@ -729,16 +729,6 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) | |||
| 729 | NSRect brect; | 729 | NSRect brect; |
| 730 | Lisp_Object font_object; | 730 | Lisp_Object font_object; |
| 731 | int fixLeopardBug; | 731 | int fixLeopardBug; |
| 732 | static NSMutableDictionary *fontCache = nil; | ||
| 733 | NSNumber *cached; | ||
| 734 | |||
| 735 | /* 2008/03/08: The same font may end up being requested for different | ||
| 736 | entities, due to small differences in numeric values or other issues, | ||
| 737 | or for different copies of the same entity. Therefore we cache to | ||
| 738 | avoid creating multiple struct font objects (with metrics cache, etc.) | ||
| 739 | for the same NSFont object. */ | ||
| 740 | if (fontCache == nil) | ||
| 741 | fontCache = [[NSMutableDictionary alloc] init]; | ||
| 742 | 732 | ||
| 743 | if (NSFONT_TRACE) | 733 | if (NSFONT_TRACE) |
| 744 | { | 734 | { |
| @@ -794,28 +784,8 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) | |||
| 794 | if (NSFONT_TRACE) | 784 | if (NSFONT_TRACE) |
| 795 | NSLog (@"%@\n", nsfont); | 785 | NSLog (@"%@\n", nsfont); |
| 796 | 786 | ||
| 797 | /* Check the cache */ | 787 | font_object = font_make_object (VECSIZE (struct nsfont_info), |
| 798 | cached = [fontCache objectForKey: nsfont]; | 788 | font_entity, pixel_size); |
| 799 | if (cached != nil && !synthItal) | ||
| 800 | { | ||
| 801 | if (NSFONT_TRACE) | ||
| 802 | fprintf(stderr, "*** nsfont_open CACHE HIT!\n"); | ||
| 803 | XHASH (font_object) = [cached unsignedLongLongValue]; | ||
| 804 | return font_object; | ||
| 805 | } | ||
| 806 | else | ||
| 807 | { | ||
| 808 | font_object = font_make_object (VECSIZE (struct nsfont_info), | ||
| 809 | font_entity, pixel_size); | ||
| 810 | if (!synthItal) | ||
| 811 | { | ||
| 812 | [fontCache setObject: [NSNumber | ||
| 813 | numberWithUnsignedLongLong: | ||
| 814 | (unsigned long long) XHASH (font_object)] | ||
| 815 | forKey: nsfont]; | ||
| 816 | } | ||
| 817 | } | ||
| 818 | |||
| 819 | font_info = (struct nsfont_info *) XFONT_OBJECT (font_object); | 789 | font_info = (struct nsfont_info *) XFONT_OBJECT (font_object); |
| 820 | font = (struct font *) font_info; | 790 | font = (struct font *) font_info; |
| 821 | if (!font) | 791 | if (!font) |
diff --git a/src/nsmenu.m b/src/nsmenu.m index a5983c70cdb..d0ea8f5a47a 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m | |||
| @@ -181,7 +181,8 @@ ns_update_menubar (struct frame *f, bool deep_p, EmacsMenu *submenu) | |||
| 181 | /* Fully parse one or more of the submenus. */ | 181 | /* Fully parse one or more of the submenus. */ |
| 182 | int n = 0; | 182 | int n = 0; |
| 183 | int *submenu_start, *submenu_end; | 183 | int *submenu_start, *submenu_end; |
| 184 | int *submenu_top_level_items, *submenu_n_panes; | 184 | bool *submenu_top_level_items; |
| 185 | int *submenu_n_panes; | ||
| 185 | struct buffer *prev = current_buffer; | 186 | struct buffer *prev = current_buffer; |
| 186 | Lisp_Object buffer; | 187 | Lisp_Object buffer; |
| 187 | ptrdiff_t specpdl_count = SPECPDL_INDEX (); | 188 | ptrdiff_t specpdl_count = SPECPDL_INDEX (); |
| @@ -740,7 +741,7 @@ extern NSString *NSMenuDidBeginTrackingNotification; | |||
| 740 | 741 | ||
| 741 | /* run a menu in popup mode */ | 742 | /* run a menu in popup mode */ |
| 742 | - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f | 743 | - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f |
| 743 | keymaps: (int)keymaps | 744 | keymaps: (bool)keymaps |
| 744 | { | 745 | { |
| 745 | EmacsView *view = FRAME_NS_VIEW (f); | 746 | EmacsView *view = FRAME_NS_VIEW (f); |
| 746 | NSEvent *e, *event; | 747 | NSEvent *e, *event; |
| @@ -779,7 +780,7 @@ extern NSString *NSMenuDidBeginTrackingNotification; | |||
| 779 | ========================================================================== */ | 780 | ========================================================================== */ |
| 780 | 781 | ||
| 781 | Lisp_Object | 782 | Lisp_Object |
| 782 | ns_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, | 783 | ns_menu_show (FRAME_PTR f, int x, int y, bool for_click, bool keymaps, |
| 783 | Lisp_Object title, const char **error) | 784 | Lisp_Object title, const char **error) |
| 784 | { | 785 | { |
| 785 | EmacsMenu *pmenu; | 786 | EmacsMenu *pmenu; |
| @@ -801,7 +802,7 @@ ns_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, | |||
| 801 | 802 | ||
| 802 | #if 0 | 803 | #if 0 |
| 803 | /* FIXME: a couple of one-line differences prevent reuse */ | 804 | /* FIXME: a couple of one-line differences prevent reuse */ |
| 804 | wv = digest_single_submenu (0, menu_items_used, Qnil); | 805 | wv = digest_single_submenu (0, menu_items_used, 0); |
| 805 | #else | 806 | #else |
| 806 | { | 807 | { |
| 807 | widget_value *save_wv = 0, *prev_wv = 0; | 808 | widget_value *save_wv = 0, *prev_wv = 0; |
diff --git a/src/nsterm.h b/src/nsterm.h index 958d1ce7853..2e868b86caf 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -161,7 +161,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 161 | - (EmacsMenu *)addSubmenuWithTitle: (const char *)title forFrame: (struct frame *)f; | 161 | - (EmacsMenu *)addSubmenuWithTitle: (const char *)title forFrame: (struct frame *)f; |
| 162 | - (void) clear; | 162 | - (void) clear; |
| 163 | - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f | 163 | - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f |
| 164 | keymaps: (int)keymaps; | 164 | keymaps: (bool)keymaps; |
| 165 | @end | 165 | @end |
| 166 | 166 | ||
| 167 | 167 | ||
| @@ -792,7 +792,7 @@ extern void free_frame_tool_bar (FRAME_PTR f); | |||
| 792 | extern void find_and_call_menu_selection (FRAME_PTR f, | 792 | extern void find_and_call_menu_selection (FRAME_PTR f, |
| 793 | int menu_bar_items_used, Lisp_Object vector, void *client_data); | 793 | int menu_bar_items_used, Lisp_Object vector, void *client_data); |
| 794 | extern Lisp_Object find_and_return_menu_selection (FRAME_PTR f, | 794 | extern Lisp_Object find_and_return_menu_selection (FRAME_PTR f, |
| 795 | int keymaps, | 795 | bool keymaps, |
| 796 | void *client_data); | 796 | void *client_data); |
| 797 | extern Lisp_Object ns_popup_dialog (Lisp_Object position, Lisp_Object contents, | 797 | extern Lisp_Object ns_popup_dialog (Lisp_Object position, Lisp_Object contents, |
| 798 | Lisp_Object header); | 798 | Lisp_Object header); |
diff --git a/src/nsterm.m b/src/nsterm.m index 1d935fc76de..98dd0a8aab1 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -208,6 +208,13 @@ static NSMutableArray *ns_pending_files, *ns_pending_service_names, | |||
| 208 | *ns_pending_service_args; | 208 | *ns_pending_service_args; |
| 209 | static BOOL ns_do_open_file = NO; | 209 | static BOOL ns_do_open_file = NO; |
| 210 | 210 | ||
| 211 | static struct { | ||
| 212 | struct input_event *q; | ||
| 213 | int nr, cap; | ||
| 214 | } hold_event_q = { | ||
| 215 | NULL, 0, 0 | ||
| 216 | }; | ||
| 217 | |||
| 211 | /* Convert modifiers in a NeXTstep event to emacs style modifiers. */ | 218 | /* Convert modifiers in a NeXTstep event to emacs style modifiers. */ |
| 212 | #define NS_FUNCTION_KEY_MASK 0x800000 | 219 | #define NS_FUNCTION_KEY_MASK 0x800000 |
| 213 | #define NSLeftControlKeyMask (0x000001 | NSControlKeyMask) | 220 | #define NSLeftControlKeyMask (0x000001 | NSControlKeyMask) |
| @@ -273,7 +280,7 @@ static BOOL ns_do_open_file = NO; | |||
| 273 | kbd_buffer_store_event_hold (emacs_event, q_event_ptr); \ | 280 | kbd_buffer_store_event_hold (emacs_event, q_event_ptr); \ |
| 274 | } \ | 281 | } \ |
| 275 | else \ | 282 | else \ |
| 276 | kbd_buffer_store_event (emacs_event); \ | 283 | hold_event (emacs_event); \ |
| 277 | EVENT_INIT (*emacs_event); \ | 284 | EVENT_INIT (*emacs_event); \ |
| 278 | ns_send_appdefined (-1); \ | 285 | ns_send_appdefined (-1); \ |
| 279 | } | 286 | } |
| @@ -292,6 +299,19 @@ void x_set_frame_alpha (struct frame *f); | |||
| 292 | 299 | ||
| 293 | ========================================================================== */ | 300 | ========================================================================== */ |
| 294 | 301 | ||
| 302 | static void | ||
| 303 | hold_event (struct input_event *event) | ||
| 304 | { | ||
| 305 | if (hold_event_q.nr == hold_event_q.cap) | ||
| 306 | { | ||
| 307 | if (hold_event_q.cap == 0) hold_event_q.cap = 10; | ||
| 308 | else hold_event_q.cap *= 2; | ||
| 309 | hold_event_q.q = (struct input_event *) | ||
| 310 | xrealloc (hold_event_q.q, hold_event_q.cap * sizeof (*hold_event_q.q)); | ||
| 311 | } | ||
| 312 | |||
| 313 | hold_event_q.q[hold_event_q.nr++] = *event; | ||
| 314 | } | ||
| 295 | 315 | ||
| 296 | static Lisp_Object | 316 | static Lisp_Object |
| 297 | append2 (Lisp_Object list, Lisp_Object item) | 317 | append2 (Lisp_Object list, Lisp_Object item) |
| @@ -3348,6 +3368,15 @@ ns_read_socket (struct terminal *terminal, struct input_event *hold_quit) | |||
| 3348 | if ([NSApp modalWindow] != nil) | 3368 | if ([NSApp modalWindow] != nil) |
| 3349 | return -1; | 3369 | return -1; |
| 3350 | 3370 | ||
| 3371 | if (hold_event_q.nr > 0) | ||
| 3372 | { | ||
| 3373 | int i; | ||
| 3374 | for (i = 0; i < hold_event_q.nr; ++i) | ||
| 3375 | kbd_buffer_store_event_hold (&hold_event_q.q[i], hold_quit); | ||
| 3376 | hold_event_q.nr = 0; | ||
| 3377 | return i; | ||
| 3378 | } | ||
| 3379 | |||
| 3351 | block_input (); | 3380 | block_input (); |
| 3352 | n_emacs_events_pending = 0; | 3381 | n_emacs_events_pending = 0; |
| 3353 | EVENT_INIT (ev); | 3382 | EVENT_INIT (ev); |
| @@ -6645,6 +6674,12 @@ not_in_argv (NSString *arg) | |||
| 6645 | [self setFloatValue: pos knobProportion: por]; | 6674 | [self setFloatValue: pos knobProportion: por]; |
| 6646 | #endif | 6675 | #endif |
| 6647 | } | 6676 | } |
| 6677 | |||
| 6678 | /* Events may come here even if the event loop is not running. | ||
| 6679 | If we don't enter the event loop, the scroll bar will not update. | ||
| 6680 | So send SIGIO to ourselves. */ | ||
| 6681 | if (apploopnr == 0) kill (0, SIGIO); | ||
| 6682 | |||
| 6648 | return self; | 6683 | return self; |
| 6649 | } | 6684 | } |
| 6650 | 6685 | ||
| @@ -6685,7 +6720,7 @@ not_in_argv (NSString *arg) | |||
| 6685 | kbd_buffer_store_event_hold (emacs_event, q_event_ptr); | 6720 | kbd_buffer_store_event_hold (emacs_event, q_event_ptr); |
| 6686 | } | 6721 | } |
| 6687 | else | 6722 | else |
| 6688 | kbd_buffer_store_event (emacs_event); | 6723 | hold_event (emacs_event); |
| 6689 | EVENT_INIT (*emacs_event); | 6724 | EVENT_INIT (*emacs_event); |
| 6690 | ns_send_appdefined (-1); | 6725 | ns_send_appdefined (-1); |
| 6691 | } | 6726 | } |
diff --git a/src/process.c b/src/process.c index 2cbce9d28ea..d45a2c6e8e0 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -646,23 +646,6 @@ allocate_pty (void) | |||
| 646 | PTY_OPEN; | 646 | PTY_OPEN; |
| 647 | #else /* no PTY_OPEN */ | 647 | #else /* no PTY_OPEN */ |
| 648 | { | 648 | { |
| 649 | { /* Some systems name their pseudoterminals so that there are gaps in | ||
| 650 | the usual sequence - for example, on HP9000/S700 systems, there | ||
| 651 | are no pseudoterminals with names ending in 'f'. So we wait for | ||
| 652 | three failures in a row before deciding that we've reached the | ||
| 653 | end of the ptys. */ | ||
| 654 | int failed_count = 0; | ||
| 655 | struct stat stb; | ||
| 656 | |||
| 657 | if (stat (pty_name, &stb) < 0) | ||
| 658 | { | ||
| 659 | failed_count++; | ||
| 660 | if (failed_count >= 3) | ||
| 661 | return -1; | ||
| 662 | } | ||
| 663 | else | ||
| 664 | failed_count = 0; | ||
| 665 | } | ||
| 666 | # ifdef O_NONBLOCK | 649 | # ifdef O_NONBLOCK |
| 667 | fd = emacs_open (pty_name, O_RDWR | O_NONBLOCK, 0); | 650 | fd = emacs_open (pty_name, O_RDWR | O_NONBLOCK, 0); |
| 668 | # else | 651 | # else |
| @@ -1612,7 +1612,6 @@ init_environment (char ** argv) | |||
| 1612 | LPBYTE lpval; | 1612 | LPBYTE lpval; |
| 1613 | DWORD dwType; | 1613 | DWORD dwType; |
| 1614 | char locale_name[32]; | 1614 | char locale_name[32]; |
| 1615 | struct stat ignored; | ||
| 1616 | char default_home[MAX_PATH]; | 1615 | char default_home[MAX_PATH]; |
| 1617 | int appdata = 0; | 1616 | int appdata = 0; |
| 1618 | 1617 | ||
| @@ -1653,7 +1652,7 @@ init_environment (char ** argv) | |||
| 1653 | /* For backwards compatibility, check if a .emacs file exists in C:/ | 1652 | /* For backwards compatibility, check if a .emacs file exists in C:/ |
| 1654 | If not, then we can try to default to the appdata directory under the | 1653 | If not, then we can try to default to the appdata directory under the |
| 1655 | user's profile, which is more likely to be writable. */ | 1654 | user's profile, which is more likely to be writable. */ |
| 1656 | if (stat ("C:/.emacs", &ignored) < 0) | 1655 | if (!check_existing ("C:/.emacs")) |
| 1657 | { | 1656 | { |
| 1658 | HRESULT profile_result; | 1657 | HRESULT profile_result; |
| 1659 | /* Dynamically load ShGetFolderPath, as it won't exist on versions | 1658 | /* Dynamically load ShGetFolderPath, as it won't exist on versions |
diff --git a/src/w32fns.c b/src/w32fns.c index 28a689ddc6c..c5e4be4ffc9 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -2333,7 +2333,9 @@ w32_name_of_message (UINT msg) | |||
| 2333 | } | 2333 | } |
| 2334 | #endif /* EMACSDEBUG */ | 2334 | #endif /* EMACSDEBUG */ |
| 2335 | 2335 | ||
| 2336 | /* Here's an overview of how Emacs input works on MS-Windows. | 2336 | /* Here's an overview of how Emacs input works in GUI sessions on |
| 2337 | MS-Windows. (For description of non-GUI input, see the commentary | ||
| 2338 | before w32_console_read_socket in w32inevt.c.) | ||
| 2337 | 2339 | ||
| 2338 | System messages are read and processed by w32_msg_pump below. This | 2340 | System messages are read and processed by w32_msg_pump below. This |
| 2339 | function runs in a separate thread. It handles a small number of | 2341 | function runs in a separate thread. It handles a small number of |
diff --git a/src/w32inevt.c b/src/w32inevt.c index c322d3a0b44..899a6fb89bf 100644 --- a/src/w32inevt.c +++ b/src/w32inevt.c | |||
| @@ -576,6 +576,38 @@ maybe_generate_resize_event (void) | |||
| 576 | 0, 0, 0); | 576 | 0, 0, 0); |
| 577 | } | 577 | } |
| 578 | 578 | ||
| 579 | /* Here's an overview of how Emacs input works in non-GUI sessions on | ||
| 580 | MS-Windows. (For description of the GUI input, see the commentary | ||
| 581 | before w32_msg_pump in w32fns.c.) | ||
| 582 | |||
| 583 | When Emacs is idle, it loops inside wait_reading_process_output, | ||
| 584 | calling pselect periodically to check whether any input is | ||
| 585 | available. On Windows, pselect is redirected to sys_select, which | ||
| 586 | uses MsgWaitForMultipleObjects to wait for input, either from the | ||
| 587 | keyboard or from any of the Emacs subprocesses. In addition, | ||
| 588 | MsgWaitForMultipleObjects wakes up when some Windows message is | ||
| 589 | posted to the input queue of the Emacs's main thread (which is the | ||
| 590 | thread in which sys_select runs). | ||
| 591 | |||
| 592 | When the Emacs's console window has focus, Windows sends input | ||
| 593 | events that originate from the keyboard or the mouse; these events | ||
| 594 | wake up MsgWaitForMultipleObjects, which reports that input is | ||
| 595 | available. Emacs then calls w32_console_read_socket, below, to | ||
| 596 | read the input. w32_console_read_socket uses | ||
| 597 | GetNumberOfConsoleInputEvents and ReadConsoleInput to peek at and | ||
| 598 | read the console input events. | ||
| 599 | |||
| 600 | One type of non-keyboard input event that gets reported as input | ||
| 601 | available is due to the Emacs's console window receiving focus. | ||
| 602 | When that happens, Emacs gets the FOCUS_EVENT event and sys_select | ||
| 603 | reports some input; however, w32_console_read_socket ignores such | ||
| 604 | events when called to read them. | ||
| 605 | |||
| 606 | Note that any other Windows message sent to the main thread will | ||
| 607 | also wake up MsgWaitForMultipleObjects. These messages get | ||
| 608 | immediately dispatched to their destinations by calling | ||
| 609 | drain_message_queue. */ | ||
| 610 | |||
| 579 | int | 611 | int |
| 580 | w32_console_read_socket (struct terminal *terminal, | 612 | w32_console_read_socket (struct terminal *terminal, |
| 581 | struct input_event *hold_quit) | 613 | struct input_event *hold_quit) |
diff --git a/src/xmenu.c b/src/xmenu.c index 96a1ae87fdc..01d932cf8d8 100644 --- a/src/xmenu.c +++ b/src/xmenu.c | |||
| @@ -111,7 +111,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 111 | static Lisp_Object Qdebug_on_next_call; | 111 | static Lisp_Object Qdebug_on_next_call; |
| 112 | 112 | ||
| 113 | #if defined (USE_X_TOOLKIT) || defined (USE_GTK) | 113 | #if defined (USE_X_TOOLKIT) || defined (USE_GTK) |
| 114 | static Lisp_Object xdialog_show (FRAME_PTR, int, Lisp_Object, Lisp_Object, | 114 | static Lisp_Object xdialog_show (FRAME_PTR, bool, Lisp_Object, Lisp_Object, |
| 115 | const char **); | 115 | const char **); |
| 116 | #endif | 116 | #endif |
| 117 | 117 | ||
| @@ -930,7 +930,8 @@ set_frame_menubar (FRAME_PTR f, bool first_time, bool deep_p) | |||
| 930 | widget_value *wv, *first_wv, *prev_wv = 0; | 930 | widget_value *wv, *first_wv, *prev_wv = 0; |
| 931 | int i; | 931 | int i; |
| 932 | int *submenu_start, *submenu_end; | 932 | int *submenu_start, *submenu_end; |
| 933 | int *submenu_top_level_items, *submenu_n_panes; | 933 | bool *submenu_top_level_items; |
| 934 | int *submenu_n_panes; | ||
| 934 | 935 | ||
| 935 | if (! FRAME_X_P (f)) | 936 | if (! FRAME_X_P (f)) |
| 936 | emacs_abort (); | 937 | emacs_abort (); |
| @@ -1346,8 +1347,8 @@ free_frame_menubar (FRAME_PTR f) | |||
| 1346 | /* F is the frame the menu is for. | 1347 | /* F is the frame the menu is for. |
| 1347 | X and Y are the frame-relative specified position, | 1348 | X and Y are the frame-relative specified position, |
| 1348 | relative to the inside upper left corner of the frame F. | 1349 | relative to the inside upper left corner of the frame F. |
| 1349 | FOR_CLICK is nonzero if this menu was invoked for a mouse click. | 1350 | FOR_CLICK is true if this menu was invoked for a mouse click. |
| 1350 | KEYMAPS is 1 if this menu was specified with keymaps; | 1351 | KEYMAPS is true if this menu was specified with keymaps; |
| 1351 | in that case, we return a list containing the chosen item's value | 1352 | in that case, we return a list containing the chosen item's value |
| 1352 | and perhaps also the pane's prefix. | 1353 | and perhaps also the pane's prefix. |
| 1353 | TITLE is the specified menu title. | 1354 | TITLE is the specified menu title. |
| @@ -1427,14 +1428,14 @@ pop_down_menu (Lisp_Object arg) | |||
| 1427 | menu_item_selection will be set to the selection. */ | 1428 | menu_item_selection will be set to the selection. */ |
| 1428 | static void | 1429 | static void |
| 1429 | create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv, int x, int y, | 1430 | create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv, int x, int y, |
| 1430 | int for_click, Time timestamp) | 1431 | bool for_click, Time timestamp) |
| 1431 | { | 1432 | { |
| 1432 | int i; | 1433 | int i; |
| 1433 | GtkWidget *menu; | 1434 | GtkWidget *menu; |
| 1434 | GtkMenuPositionFunc pos_func = 0; /* Pop up at pointer. */ | 1435 | GtkMenuPositionFunc pos_func = 0; /* Pop up at pointer. */ |
| 1435 | struct next_popup_x_y popup_x_y; | 1436 | struct next_popup_x_y popup_x_y; |
| 1436 | ptrdiff_t specpdl_count = SPECPDL_INDEX (); | 1437 | ptrdiff_t specpdl_count = SPECPDL_INDEX (); |
| 1437 | int use_pos_func = ! for_click; | 1438 | bool use_pos_func = ! for_click; |
| 1438 | 1439 | ||
| 1439 | #ifdef HAVE_GTK3 | 1440 | #ifdef HAVE_GTK3 |
| 1440 | /* Always use position function for Gtk3. Otherwise menus may become | 1441 | /* Always use position function for Gtk3. Otherwise menus may become |
| @@ -1539,7 +1540,7 @@ pop_down_menu (Lisp_Object arg) | |||
| 1539 | menu_item_selection will be set to the selection. */ | 1540 | menu_item_selection will be set to the selection. */ |
| 1540 | static void | 1541 | static void |
| 1541 | create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv, | 1542 | create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv, |
| 1542 | int x, int y, int for_click, Time timestamp) | 1543 | int x, int y, bool for_click, Time timestamp) |
| 1543 | { | 1544 | { |
| 1544 | int i; | 1545 | int i; |
| 1545 | Arg av[2]; | 1546 | Arg av[2]; |
| @@ -1623,7 +1624,7 @@ cleanup_widget_value_tree (Lisp_Object arg) | |||
| 1623 | } | 1624 | } |
| 1624 | 1625 | ||
| 1625 | Lisp_Object | 1626 | Lisp_Object |
| 1626 | xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, | 1627 | xmenu_show (FRAME_PTR f, int x, int y, bool for_click, bool keymaps, |
| 1627 | Lisp_Object title, const char **error_name, Time timestamp) | 1628 | Lisp_Object title, const char **error_name, Time timestamp) |
| 1628 | { | 1629 | { |
| 1629 | int i; | 1630 | int i; |
| @@ -1878,7 +1879,7 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, | |||
| 1878 | = AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE); | 1879 | = AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE); |
| 1879 | if (menu_item_selection == aref_addr (menu_items, i)) | 1880 | if (menu_item_selection == aref_addr (menu_items, i)) |
| 1880 | { | 1881 | { |
| 1881 | if (keymaps != 0) | 1882 | if (keymaps) |
| 1882 | { | 1883 | { |
| 1883 | int j; | 1884 | int j; |
| 1884 | 1885 | ||
| @@ -2011,7 +2012,7 @@ static const char * button_names [] = { | |||
| 2011 | 2012 | ||
| 2012 | static Lisp_Object | 2013 | static Lisp_Object |
| 2013 | xdialog_show (FRAME_PTR f, | 2014 | xdialog_show (FRAME_PTR f, |
| 2014 | int keymaps, | 2015 | bool keymaps, |
| 2015 | Lisp_Object title, | 2016 | Lisp_Object title, |
| 2016 | Lisp_Object header, | 2017 | Lisp_Object header, |
| 2017 | const char **error_name) | 2018 | const char **error_name) |
| @@ -2277,7 +2278,7 @@ pop_down_menu (Lisp_Object arg) | |||
| 2277 | 2278 | ||
| 2278 | 2279 | ||
| 2279 | Lisp_Object | 2280 | Lisp_Object |
| 2280 | xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, | 2281 | xmenu_show (FRAME_PTR f, int x, int y, bool for_click, bool keymaps, |
| 2281 | Lisp_Object title, const char **error_name, Time timestamp) | 2282 | Lisp_Object title, const char **error_name, Time timestamp) |
| 2282 | { | 2283 | { |
| 2283 | Window root; | 2284 | Window root; |
| @@ -2528,7 +2529,7 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, | |||
| 2528 | { | 2529 | { |
| 2529 | entry | 2530 | entry |
| 2530 | = AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE); | 2531 | = AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE); |
| 2531 | if (keymaps != 0) | 2532 | if (keymaps) |
| 2532 | { | 2533 | { |
| 2533 | entry = Fcons (entry, Qnil); | 2534 | entry = Fcons (entry, Qnil); |
| 2534 | if (!NILP (pane_prefix)) | 2535 | if (!NILP (pane_prefix)) |