diff options
| author | Eli Zaretskii | 2012-10-14 10:03:16 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2012-10-14 10:03:16 +0200 |
| commit | dd8c2f5adeba029790a007ec829e18442a4ade36 (patch) | |
| tree | ea6045c78021c965e34bbfafa4ca36e8b8533c84 /src | |
| parent | 4f0800ec2ffdfee7b56062aeac263e5071cf8868 (diff) | |
| parent | 8111f5e6f05228e36496f3bdccad711f569acb9b (diff) | |
| download | emacs-dd8c2f5adeba029790a007ec829e18442a4ade36.tar.gz emacs-dd8c2f5adeba029790a007ec829e18442a4ade36.zip | |
Merge from trunk.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 67 | ||||
| -rw-r--r-- | src/coding.c | 3 | ||||
| -rw-r--r-- | src/doc.c | 3 | ||||
| -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 | 1 | ||||
| -rw-r--r-- | src/lread.c | 8 | ||||
| -rw-r--r-- | src/makefile.w32-in | 2 | ||||
| -rw-r--r-- | src/nsfont.m | 34 | ||||
| -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 |
15 files changed, 220 insertions, 143 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 34e730183de..b573f8c1476 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,70 @@ | |||
| 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 | |||
| 1 | 2012-10-12 Glenn Morris <rgm@gnu.org> | 68 | 2012-10-12 Glenn Morris <rgm@gnu.org> |
| 2 | 69 | ||
| 3 | * buffer.c (Fset_buffer): Doc fix. (Bug#12624) | 70 | * buffer.c (Fset_buffer): Doc fix. (Bug#12624) |
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/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 756d08fda33..113ae16fc14 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -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 dbbde694cf6..6d4c0d990af 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -1449,7 +1449,6 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto | |||
| 1449 | bool absolute = 0; | 1449 | bool absolute = 0; |
| 1450 | ptrdiff_t want_length; | 1450 | ptrdiff_t want_length; |
| 1451 | Lisp_Object filename; | 1451 | Lisp_Object filename; |
| 1452 | struct stat st; | ||
| 1453 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; | 1452 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; |
| 1454 | Lisp_Object string, tail, encoded_fn; | 1453 | Lisp_Object string, tail, encoded_fn; |
| 1455 | ptrdiff_t max_suffix_len = 0; | 1454 | ptrdiff_t max_suffix_len = 0; |
| @@ -1543,11 +1542,18 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto | |||
| 1543 | } | 1542 | } |
| 1544 | else | 1543 | else |
| 1545 | { | 1544 | { |
| 1545 | #ifndef WINDOWSNT | ||
| 1546 | struct stat st; | ||
| 1547 | #endif | ||
| 1546 | const char *pfn; | 1548 | const char *pfn; |
| 1547 | 1549 | ||
| 1548 | encoded_fn = ENCODE_FILE (string); | 1550 | encoded_fn = ENCODE_FILE (string); |
| 1549 | 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 | ||
| 1550 | exists = (stat (pfn, &st) == 0 && ! S_ISDIR (st.st_mode)); | 1555 | exists = (stat (pfn, &st) == 0 && ! S_ISDIR (st.st_mode)); |
| 1556 | #endif | ||
| 1551 | if (exists) | 1557 | if (exists) |
| 1552 | { | 1558 | { |
| 1553 | /* Check that we can access or open it. */ | 1559 | /* Check that we can access or open it. */ |
diff --git a/src/makefile.w32-in b/src/makefile.w32-in index e4a77cc87a3..3e817fd58ca 100644 --- a/src/makefile.w32-in +++ b/src/makefile.w32-in | |||
| @@ -834,6 +834,7 @@ $(BLD)/fileio.$(O) : \ | |||
| 834 | $(SRC)/blockinput.h \ | 834 | $(SRC)/blockinput.h \ |
| 835 | $(SRC)/commands.h \ | 835 | $(SRC)/commands.h \ |
| 836 | $(NT_INC)/pwd.h \ | 836 | $(NT_INC)/pwd.h \ |
| 837 | $(NT_INC)/sys/file.h \ | ||
| 837 | $(NT_INC)/sys/stat.h \ | 838 | $(NT_INC)/sys/stat.h \ |
| 838 | $(NT_INC)/unistd.h \ | 839 | $(NT_INC)/unistd.h \ |
| 839 | $(BUFFER_H) \ | 840 | $(BUFFER_H) \ |
| @@ -1633,6 +1634,7 @@ $(BLD)/w32select.$(O) : \ | |||
| 1633 | $(CHARSET_H) \ | 1634 | $(CHARSET_H) \ |
| 1634 | $(CODING_H) \ | 1635 | $(CODING_H) \ |
| 1635 | $(CONFIG_H) \ | 1636 | $(CONFIG_H) \ |
| 1637 | $(KEYBOARD_H) \ | ||
| 1636 | $(LISP_H) \ | 1638 | $(LISP_H) \ |
| 1637 | $(W32TERM_H) | 1639 | $(W32TERM_H) |
| 1638 | 1640 | ||
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/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 aa1647fcaa4..df0a16fc2a3 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 7d60c06d78d..a5868be612c 100644 --- a/src/w32inevt.c +++ b/src/w32inevt.c | |||
| @@ -644,6 +644,38 @@ handle_file_notifications (struct input_event *hold_quit) | |||
| 644 | return nevents; | 644 | return nevents; |
| 645 | } | 645 | } |
| 646 | 646 | ||
| 647 | /* Here's an overview of how Emacs input works in non-GUI sessions on | ||
| 648 | MS-Windows. (For description of the GUI input, see the commentary | ||
| 649 | before w32_msg_pump in w32fns.c.) | ||
| 650 | |||
| 651 | When Emacs is idle, it loops inside wait_reading_process_output, | ||
| 652 | calling pselect periodically to check whether any input is | ||
| 653 | available. On Windows, pselect is redirected to sys_select, which | ||
| 654 | uses MsgWaitForMultipleObjects to wait for input, either from the | ||
| 655 | keyboard or from any of the Emacs subprocesses. In addition, | ||
| 656 | MsgWaitForMultipleObjects wakes up when some Windows message is | ||
| 657 | posted to the input queue of the Emacs's main thread (which is the | ||
| 658 | thread in which sys_select runs). | ||
| 659 | |||
| 660 | When the Emacs's console window has focus, Windows sends input | ||
| 661 | events that originate from the keyboard or the mouse; these events | ||
| 662 | wake up MsgWaitForMultipleObjects, which reports that input is | ||
| 663 | available. Emacs then calls w32_console_read_socket, below, to | ||
| 664 | read the input. w32_console_read_socket uses | ||
| 665 | GetNumberOfConsoleInputEvents and ReadConsoleInput to peek at and | ||
| 666 | read the console input events. | ||
| 667 | |||
| 668 | One type of non-keyboard input event that gets reported as input | ||
| 669 | available is due to the Emacs's console window receiving focus. | ||
| 670 | When that happens, Emacs gets the FOCUS_EVENT event and sys_select | ||
| 671 | reports some input; however, w32_console_read_socket ignores such | ||
| 672 | events when called to read them. | ||
| 673 | |||
| 674 | Note that any other Windows message sent to the main thread will | ||
| 675 | also wake up MsgWaitForMultipleObjects. These messages get | ||
| 676 | immediately dispatched to their destinations by calling | ||
| 677 | drain_message_queue. */ | ||
| 678 | |||
| 647 | int | 679 | int |
| 648 | w32_console_read_socket (struct terminal *terminal, | 680 | w32_console_read_socket (struct terminal *terminal, |
| 649 | struct input_event *hold_quit) | 681 | struct input_event *hold_quit) |