diff options
| author | Vibhav Pant | 2017-02-05 23:08:53 +0530 |
|---|---|---|
| committer | Vibhav Pant | 2017-02-05 23:08:53 +0530 |
| commit | ad70ca1dad26da79f0a95cc0ec687902ef20fa9b (patch) | |
| tree | 732e8e9ace1fdd7aaf982f0fa5ac6c8e4eb5f7c7 /src | |
| parent | 2db473bda8be72cf3c1e4694d70ce48f60492b0e (diff) | |
| parent | 148100d98319499f0ac6f57b8be08cbd14884a5c (diff) | |
| download | emacs-ad70ca1dad26da79f0a95cc0ec687902ef20fa9b.tar.gz emacs-ad70ca1dad26da79f0a95cc0ec687902ef20fa9b.zip | |
Merge remote-tracking branch 'origin/master' into feature/byte-switch
Diffstat (limited to 'src')
| -rw-r--r-- | src/alloc.c | 215 | ||||
| -rw-r--r-- | src/bytecode.c | 20 | ||||
| -rw-r--r-- | src/callproc.c | 18 | ||||
| -rw-r--r-- | src/dired.c | 3 | ||||
| -rw-r--r-- | src/dispextern.h | 1 | ||||
| -rw-r--r-- | src/doc.c | 9 | ||||
| -rw-r--r-- | src/editfns.c | 10 | ||||
| -rw-r--r-- | src/emacs.c | 2 | ||||
| -rw-r--r-- | src/eval.c | 15 | ||||
| -rw-r--r-- | src/fileio.c | 74 | ||||
| -rw-r--r-- | src/filelock.c | 7 | ||||
| -rw-r--r-- | src/fns.c | 96 | ||||
| -rw-r--r-- | src/indent.c | 13 | ||||
| -rw-r--r-- | src/keyboard.c | 93 | ||||
| -rw-r--r-- | src/lisp.h | 47 | ||||
| -rw-r--r-- | src/lread.c | 2 | ||||
| -rw-r--r-- | src/process.c | 10 | ||||
| -rw-r--r-- | src/regex.c | 10 | ||||
| -rw-r--r-- | src/search.c | 98 | ||||
| -rw-r--r-- | src/syntax.c | 140 | ||||
| -rw-r--r-- | src/sysdep.c | 129 | ||||
| -rw-r--r-- | src/w32fns.c | 11 | ||||
| -rw-r--r-- | src/window.c | 55 | ||||
| -rw-r--r-- | src/window.h | 2 | ||||
| -rw-r--r-- | src/xdisp.c | 104 |
25 files changed, 510 insertions, 674 deletions
diff --git a/src/alloc.c b/src/alloc.c index dd2b688f91e..62f43669f2a 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -2880,7 +2880,7 @@ DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0, | |||
| 2880 | for (EMACS_INT size = XFASTINT (length); 0 < size; size--) | 2880 | for (EMACS_INT size = XFASTINT (length); 0 < size; size--) |
| 2881 | { | 2881 | { |
| 2882 | val = Fcons (init, val); | 2882 | val = Fcons (init, val); |
| 2883 | maybe_quit (); | 2883 | rarely_quit (size); |
| 2884 | } | 2884 | } |
| 2885 | 2885 | ||
| 2886 | return val; | 2886 | return val; |
| @@ -4887,12 +4887,19 @@ mark_memory (void *start, void *end) | |||
| 4887 | } | 4887 | } |
| 4888 | } | 4888 | } |
| 4889 | 4889 | ||
| 4890 | #if !defined GC_SAVE_REGISTERS_ON_STACK && !defined GC_SETJMP_WORKS | 4890 | #ifndef HAVE___BUILTIN_UNWIND_INIT |
| 4891 | |||
| 4892 | # ifdef GC_SETJMP_WORKS | ||
| 4893 | static void | ||
| 4894 | test_setjmp (void) | ||
| 4895 | { | ||
| 4896 | } | ||
| 4897 | # else | ||
| 4891 | 4898 | ||
| 4892 | static bool setjmp_tested_p; | 4899 | static bool setjmp_tested_p; |
| 4893 | static int longjmps_done; | 4900 | static int longjmps_done; |
| 4894 | 4901 | ||
| 4895 | #define SETJMP_WILL_LIKELY_WORK "\ | 4902 | # define SETJMP_WILL_LIKELY_WORK "\ |
| 4896 | \n\ | 4903 | \n\ |
| 4897 | Emacs garbage collector has been changed to use conservative stack\n\ | 4904 | Emacs garbage collector has been changed to use conservative stack\n\ |
| 4898 | marking. Emacs has determined that the method it uses to do the\n\ | 4905 | marking. Emacs has determined that the method it uses to do the\n\ |
| @@ -4905,7 +4912,7 @@ verify that the methods used are appropriate for your system.\n\ | |||
| 4905 | Please mail the result to <emacs-devel@gnu.org>.\n\ | 4912 | Please mail the result to <emacs-devel@gnu.org>.\n\ |
| 4906 | " | 4913 | " |
| 4907 | 4914 | ||
| 4908 | #define SETJMP_WILL_NOT_WORK "\ | 4915 | # define SETJMP_WILL_NOT_WORK "\ |
| 4909 | \n\ | 4916 | \n\ |
| 4910 | Emacs garbage collector has been changed to use conservative stack\n\ | 4917 | Emacs garbage collector has been changed to use conservative stack\n\ |
| 4911 | marking. Emacs has determined that the default method it uses to do the\n\ | 4918 | marking. Emacs has determined that the default method it uses to do the\n\ |
| @@ -4931,6 +4938,9 @@ Please mail the result to <emacs-devel@gnu.org>.\n\ | |||
| 4931 | static void | 4938 | static void |
| 4932 | test_setjmp (void) | 4939 | test_setjmp (void) |
| 4933 | { | 4940 | { |
| 4941 | if (setjmp_tested_p) | ||
| 4942 | return; | ||
| 4943 | setjmp_tested_p = true; | ||
| 4934 | char buf[10]; | 4944 | char buf[10]; |
| 4935 | register int x; | 4945 | register int x; |
| 4936 | sys_jmp_buf jbuf; | 4946 | sys_jmp_buf jbuf; |
| @@ -4967,9 +4977,60 @@ test_setjmp (void) | |||
| 4967 | if (longjmps_done == 1) | 4977 | if (longjmps_done == 1) |
| 4968 | sys_longjmp (jbuf, 1); | 4978 | sys_longjmp (jbuf, 1); |
| 4969 | } | 4979 | } |
| 4980 | # endif /* ! GC_SETJMP_WORKS */ | ||
| 4981 | #endif /* ! HAVE___BUILTIN_UNWIND_INIT */ | ||
| 4970 | 4982 | ||
| 4971 | #endif /* not GC_SAVE_REGISTERS_ON_STACK && not GC_SETJMP_WORKS */ | 4983 | /* The type of an object near the stack top, whose address can be used |
| 4984 | as a stack scan limit. */ | ||
| 4985 | typedef union | ||
| 4986 | { | ||
| 4987 | /* Align the stack top properly. Even if !HAVE___BUILTIN_UNWIND_INIT, | ||
| 4988 | jmp_buf may not be aligned enough on darwin-ppc64. */ | ||
| 4989 | max_align_t o; | ||
| 4990 | #ifndef HAVE___BUILTIN_UNWIND_INIT | ||
| 4991 | sys_jmp_buf j; | ||
| 4992 | char c; | ||
| 4993 | #endif | ||
| 4994 | } stacktop_sentry; | ||
| 4995 | |||
| 4996 | /* Force callee-saved registers and register windows onto the stack. | ||
| 4997 | Use the platform-defined __builtin_unwind_init if available, | ||
| 4998 | obviating the need for machine dependent methods. */ | ||
| 4999 | #ifndef HAVE___BUILTIN_UNWIND_INIT | ||
| 5000 | # ifdef __sparc__ | ||
| 5001 | /* This trick flushes the register windows so that all the state of | ||
| 5002 | the process is contained in the stack. | ||
| 5003 | FreeBSD does not have a ta 3 handler, so handle it specially. | ||
| 5004 | FIXME: Code in the Boehm GC suggests flushing (with 'flushrs') is | ||
| 5005 | needed on ia64 too. See mach_dep.c, where it also says inline | ||
| 5006 | assembler doesn't work with relevant proprietary compilers. */ | ||
| 5007 | # if defined __sparc64__ && defined __FreeBSD__ | ||
| 5008 | # define __builtin_unwind_init() asm ("flushw") | ||
| 5009 | # else | ||
| 5010 | # define __builtin_unwind_init() asm ("ta 3") | ||
| 5011 | # endif | ||
| 5012 | # else | ||
| 5013 | # define __builtin_unwind_init() ((void) 0) | ||
| 5014 | # endif | ||
| 5015 | #endif | ||
| 4972 | 5016 | ||
| 5017 | /* Set *P to the address of the top of the stack. This must be a | ||
| 5018 | macro, not a function, so that it is executed in the caller’s | ||
| 5019 | environment. It is not inside a do-while so that its storage | ||
| 5020 | survives the macro. */ | ||
| 5021 | #ifdef HAVE___BUILTIN_UNWIND_INIT | ||
| 5022 | # define SET_STACK_TOP_ADDRESS(p) \ | ||
| 5023 | stacktop_sentry sentry; \ | ||
| 5024 | __builtin_unwind_init (); \ | ||
| 5025 | *(p) = &sentry | ||
| 5026 | #else | ||
| 5027 | # define SET_STACK_TOP_ADDRESS(p) \ | ||
| 5028 | stacktop_sentry sentry; \ | ||
| 5029 | __builtin_unwind_init (); \ | ||
| 5030 | test_setjmp (); \ | ||
| 5031 | sys_setjmp (sentry.j); \ | ||
| 5032 | *(p) = &sentry + (stack_bottom < &sentry.c) | ||
| 5033 | #endif | ||
| 4973 | 5034 | ||
| 4974 | /* Mark live Lisp objects on the C stack. | 5035 | /* Mark live Lisp objects on the C stack. |
| 4975 | 5036 | ||
| @@ -4981,12 +5042,7 @@ test_setjmp (void) | |||
| 4981 | We have to mark Lisp objects in CPU registers that can hold local | 5042 | We have to mark Lisp objects in CPU registers that can hold local |
| 4982 | variables or are used to pass parameters. | 5043 | variables or are used to pass parameters. |
| 4983 | 5044 | ||
| 4984 | If GC_SAVE_REGISTERS_ON_STACK is defined, it should expand to | 5045 | This code assumes that calling setjmp saves registers we need |
| 4985 | something that either saves relevant registers on the stack, or | ||
| 4986 | calls mark_maybe_object passing it each register's contents. | ||
| 4987 | |||
| 4988 | If GC_SAVE_REGISTERS_ON_STACK is not defined, the current | ||
| 4989 | implementation assumes that calling setjmp saves registers we need | ||
| 4990 | to see in a jmp_buf which itself lies on the stack. This doesn't | 5046 | to see in a jmp_buf which itself lies on the stack. This doesn't |
| 4991 | have to be true! It must be verified for each system, possibly | 5047 | have to be true! It must be verified for each system, possibly |
| 4992 | by taking a look at the source code of setjmp. | 5048 | by taking a look at the source code of setjmp. |
| @@ -5050,62 +5106,9 @@ flush_stack_call_func (void (*func) (void *arg), void *arg) | |||
| 5050 | { | 5106 | { |
| 5051 | void *end; | 5107 | void *end; |
| 5052 | struct thread_state *self = current_thread; | 5108 | struct thread_state *self = current_thread; |
| 5053 | 5109 | SET_STACK_TOP_ADDRESS (&end); | |
| 5054 | #ifdef HAVE___BUILTIN_UNWIND_INIT | ||
| 5055 | /* Force callee-saved registers and register windows onto the stack. | ||
| 5056 | This is the preferred method if available, obviating the need for | ||
| 5057 | machine dependent methods. */ | ||
| 5058 | __builtin_unwind_init (); | ||
| 5059 | end = &end; | ||
| 5060 | #else /* not HAVE___BUILTIN_UNWIND_INIT */ | ||
| 5061 | #ifndef GC_SAVE_REGISTERS_ON_STACK | ||
| 5062 | /* jmp_buf may not be aligned enough on darwin-ppc64 */ | ||
| 5063 | union aligned_jmpbuf { | ||
| 5064 | Lisp_Object o; | ||
| 5065 | sys_jmp_buf j; | ||
| 5066 | } j; | ||
| 5067 | volatile bool stack_grows_down_p = (char *) &j > (char *) stack_bottom; | ||
| 5068 | #endif | ||
| 5069 | /* This trick flushes the register windows so that all the state of | ||
| 5070 | the process is contained in the stack. */ | ||
| 5071 | /* Fixme: Code in the Boehm GC suggests flushing (with `flushrs') is | ||
| 5072 | needed on ia64 too. See mach_dep.c, where it also says inline | ||
| 5073 | assembler doesn't work with relevant proprietary compilers. */ | ||
| 5074 | #ifdef __sparc__ | ||
| 5075 | #if defined (__sparc64__) && defined (__FreeBSD__) | ||
| 5076 | /* FreeBSD does not have a ta 3 handler. */ | ||
| 5077 | asm ("flushw"); | ||
| 5078 | #else | ||
| 5079 | asm ("ta 3"); | ||
| 5080 | #endif | ||
| 5081 | #endif | ||
| 5082 | |||
| 5083 | /* Save registers that we need to see on the stack. We need to see | ||
| 5084 | registers used to hold register variables and registers used to | ||
| 5085 | pass parameters. */ | ||
| 5086 | #ifdef GC_SAVE_REGISTERS_ON_STACK | ||
| 5087 | GC_SAVE_REGISTERS_ON_STACK (end); | ||
| 5088 | #else /* not GC_SAVE_REGISTERS_ON_STACK */ | ||
| 5089 | |||
| 5090 | #ifndef GC_SETJMP_WORKS /* If it hasn't been checked yet that | ||
| 5091 | setjmp will definitely work, test it | ||
| 5092 | and print a message with the result | ||
| 5093 | of the test. */ | ||
| 5094 | if (!setjmp_tested_p) | ||
| 5095 | { | ||
| 5096 | setjmp_tested_p = 1; | ||
| 5097 | test_setjmp (); | ||
| 5098 | } | ||
| 5099 | #endif /* GC_SETJMP_WORKS */ | ||
| 5100 | |||
| 5101 | sys_setjmp (j.j); | ||
| 5102 | end = stack_grows_down_p ? (char *) &j + sizeof j : (char *) &j; | ||
| 5103 | #endif /* not GC_SAVE_REGISTERS_ON_STACK */ | ||
| 5104 | #endif /* not HAVE___BUILTIN_UNWIND_INIT */ | ||
| 5105 | |||
| 5106 | self->stack_top = end; | 5110 | self->stack_top = end; |
| 5107 | (*func) (arg); | 5111 | func (arg); |
| 5108 | |||
| 5109 | eassert (current_thread == self); | 5112 | eassert (current_thread == self); |
| 5110 | } | 5113 | } |
| 5111 | 5114 | ||
| @@ -5437,7 +5440,8 @@ make_pure_vector (ptrdiff_t len) | |||
| 5437 | /* Copy all contents and parameters of TABLE to a new table allocated | 5440 | /* Copy all contents and parameters of TABLE to a new table allocated |
| 5438 | from pure space, return the purified table. */ | 5441 | from pure space, return the purified table. */ |
| 5439 | static struct Lisp_Hash_Table * | 5442 | static struct Lisp_Hash_Table * |
| 5440 | purecopy_hash_table (struct Lisp_Hash_Table *table) { | 5443 | purecopy_hash_table (struct Lisp_Hash_Table *table) |
| 5444 | { | ||
| 5441 | eassert (NILP (table->weak)); | 5445 | eassert (NILP (table->weak)); |
| 5442 | eassert (!NILP (table->pure)); | 5446 | eassert (!NILP (table->pure)); |
| 5443 | 5447 | ||
| @@ -5480,14 +5484,12 @@ Does not copy symbols. Copies strings without text properties. */) | |||
| 5480 | return purecopy (obj); | 5484 | return purecopy (obj); |
| 5481 | } | 5485 | } |
| 5482 | 5486 | ||
| 5483 | struct pinned_object | 5487 | /* Pinned objects are marked before every GC cycle. */ |
| 5488 | static struct pinned_object | ||
| 5484 | { | 5489 | { |
| 5485 | Lisp_Object object; | 5490 | Lisp_Object object; |
| 5486 | struct pinned_object *next; | 5491 | struct pinned_object *next; |
| 5487 | }; | 5492 | } *pinned_objects; |
| 5488 | |||
| 5489 | /* Pinned objects are marked before every GC cycle. */ | ||
| 5490 | static struct pinned_object *pinned_objects; | ||
| 5491 | 5493 | ||
| 5492 | static Lisp_Object | 5494 | static Lisp_Object |
| 5493 | purecopy (Lisp_Object obj) | 5495 | purecopy (Lisp_Object obj) |
| @@ -5519,13 +5521,13 @@ purecopy (Lisp_Object obj) | |||
| 5519 | else if (HASH_TABLE_P (obj)) | 5521 | else if (HASH_TABLE_P (obj)) |
| 5520 | { | 5522 | { |
| 5521 | struct Lisp_Hash_Table *table = XHASH_TABLE (obj); | 5523 | struct Lisp_Hash_Table *table = XHASH_TABLE (obj); |
| 5522 | /* We cannot purify hash tables which haven't been defined with | 5524 | /* Do not purify hash tables which haven't been defined with |
| 5523 | :purecopy as non-nil or are weak - they aren't guaranteed to | 5525 | :purecopy as non-nil or are weak - they aren't guaranteed to |
| 5524 | not change. */ | 5526 | not change. */ |
| 5525 | if (!NILP (table->weak) || NILP (table->pure)) | 5527 | if (!NILP (table->weak) || NILP (table->pure)) |
| 5526 | { | 5528 | { |
| 5527 | /* Instead, the hash table is added to the list of pinned objects, | 5529 | /* Instead, add the hash table to the list of pinned objects, |
| 5528 | and is marked before GC. */ | 5530 | so that it will be marked during GC. */ |
| 5529 | struct pinned_object *o = xmalloc (sizeof *o); | 5531 | struct pinned_object *o = xmalloc (sizeof *o); |
| 5530 | o->object = obj; | 5532 | o->object = obj; |
| 5531 | o->next = pinned_objects; | 5533 | o->next = pinned_objects; |
| @@ -5755,11 +5757,8 @@ compact_undo_list (Lisp_Object list) | |||
| 5755 | static void | 5757 | static void |
| 5756 | mark_pinned_objects (void) | 5758 | mark_pinned_objects (void) |
| 5757 | { | 5759 | { |
| 5758 | struct pinned_object *pobj; | 5760 | for (struct pinned_object *pobj = pinned_objects; pobj; pobj = pobj->next) |
| 5759 | for (pobj = pinned_objects; pobj; pobj = pobj->next) | 5761 | mark_object (pobj->object); |
| 5760 | { | ||
| 5761 | mark_object (pobj->object); | ||
| 5762 | } | ||
| 5763 | } | 5762 | } |
| 5764 | 5763 | ||
| 5765 | static void | 5764 | static void |
| @@ -6051,58 +6050,7 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 6051 | (void) | 6050 | (void) |
| 6052 | { | 6051 | { |
| 6053 | void *end; | 6052 | void *end; |
| 6054 | 6053 | SET_STACK_TOP_ADDRESS (&end); | |
| 6055 | #ifdef HAVE___BUILTIN_UNWIND_INIT | ||
| 6056 | /* Force callee-saved registers and register windows onto the stack. | ||
| 6057 | This is the preferred method if available, obviating the need for | ||
| 6058 | machine dependent methods. */ | ||
| 6059 | __builtin_unwind_init (); | ||
| 6060 | end = &end; | ||
| 6061 | #else /* not HAVE___BUILTIN_UNWIND_INIT */ | ||
| 6062 | #ifndef GC_SAVE_REGISTERS_ON_STACK | ||
| 6063 | /* jmp_buf may not be aligned enough on darwin-ppc64 */ | ||
| 6064 | union aligned_jmpbuf { | ||
| 6065 | Lisp_Object o; | ||
| 6066 | sys_jmp_buf j; | ||
| 6067 | } j; | ||
| 6068 | volatile bool stack_grows_down_p = (char *) &j > (char *) stack_base; | ||
| 6069 | #endif | ||
| 6070 | /* This trick flushes the register windows so that all the state of | ||
| 6071 | the process is contained in the stack. */ | ||
| 6072 | /* Fixme: Code in the Boehm GC suggests flushing (with `flushrs') is | ||
| 6073 | needed on ia64 too. See mach_dep.c, where it also says inline | ||
| 6074 | assembler doesn't work with relevant proprietary compilers. */ | ||
| 6075 | #ifdef __sparc__ | ||
| 6076 | #if defined (__sparc64__) && defined (__FreeBSD__) | ||
| 6077 | /* FreeBSD does not have a ta 3 handler. */ | ||
| 6078 | asm ("flushw"); | ||
| 6079 | #else | ||
| 6080 | asm ("ta 3"); | ||
| 6081 | #endif | ||
| 6082 | #endif | ||
| 6083 | |||
| 6084 | /* Save registers that we need to see on the stack. We need to see | ||
| 6085 | registers used to hold register variables and registers used to | ||
| 6086 | pass parameters. */ | ||
| 6087 | #ifdef GC_SAVE_REGISTERS_ON_STACK | ||
| 6088 | GC_SAVE_REGISTERS_ON_STACK (end); | ||
| 6089 | #else /* not GC_SAVE_REGISTERS_ON_STACK */ | ||
| 6090 | |||
| 6091 | #ifndef GC_SETJMP_WORKS /* If it hasn't been checked yet that | ||
| 6092 | setjmp will definitely work, test it | ||
| 6093 | and print a message with the result | ||
| 6094 | of the test. */ | ||
| 6095 | if (!setjmp_tested_p) | ||
| 6096 | { | ||
| 6097 | setjmp_tested_p = 1; | ||
| 6098 | test_setjmp (); | ||
| 6099 | } | ||
| 6100 | #endif /* GC_SETJMP_WORKS */ | ||
| 6101 | |||
| 6102 | sys_setjmp (j.j); | ||
| 6103 | end = stack_grows_down_p ? (char *) &j + sizeof j : (char *) &j; | ||
| 6104 | #endif /* not GC_SAVE_REGISTERS_ON_STACK */ | ||
| 6105 | #endif /* not HAVE___BUILTIN_UNWIND_INIT */ | ||
| 6106 | return garbage_collect_1 (end); | 6054 | return garbage_collect_1 (end); |
| 6107 | } | 6055 | } |
| 6108 | 6056 | ||
| @@ -7412,9 +7360,6 @@ init_alloc_once (void) | |||
| 7412 | void | 7360 | void |
| 7413 | init_alloc (void) | 7361 | init_alloc (void) |
| 7414 | { | 7362 | { |
| 7415 | #if !defined GC_SAVE_REGISTERS_ON_STACK && !defined GC_SETJMP_WORKS | ||
| 7416 | setjmp_tested_p = longjmps_done = 0; | ||
| 7417 | #endif | ||
| 7418 | Vgc_elapsed = make_float (0.0); | 7363 | Vgc_elapsed = make_float (0.0); |
| 7419 | gcs_done = 0; | 7364 | gcs_done = 0; |
| 7420 | 7365 | ||
diff --git a/src/bytecode.c b/src/bytecode.c index 288d78efe41..f9531761b3c 100644 --- a/src/bytecode.c +++ b/src/bytecode.c | |||
| @@ -843,11 +843,11 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 843 | { | 843 | { |
| 844 | Lisp_Object v2 = POP, v1 = TOP; | 844 | Lisp_Object v2 = POP, v1 = TOP; |
| 845 | CHECK_NUMBER (v1); | 845 | CHECK_NUMBER (v1); |
| 846 | EMACS_INT n = XINT (v1); | 846 | for (EMACS_INT n = XINT (v1); 0 < n && CONSP (v2); n--) |
| 847 | immediate_quit = true; | 847 | { |
| 848 | while (--n >= 0 && CONSP (v2)) | 848 | v2 = XCDR (v2); |
| 849 | v2 = XCDR (v2); | 849 | rarely_quit (n); |
| 850 | immediate_quit = false; | 850 | } |
| 851 | TOP = CAR (v2); | 851 | TOP = CAR (v2); |
| 852 | NEXT; | 852 | NEXT; |
| 853 | } | 853 | } |
| @@ -1277,11 +1277,11 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 1277 | /* Exchange args and then do nth. */ | 1277 | /* Exchange args and then do nth. */ |
| 1278 | Lisp_Object v2 = POP, v1 = TOP; | 1278 | Lisp_Object v2 = POP, v1 = TOP; |
| 1279 | CHECK_NUMBER (v2); | 1279 | CHECK_NUMBER (v2); |
| 1280 | EMACS_INT n = XINT (v2); | 1280 | for (EMACS_INT n = XINT (v2); 0 < n && CONSP (v1); n--) |
| 1281 | immediate_quit = true; | 1281 | { |
| 1282 | while (--n >= 0 && CONSP (v1)) | 1282 | v1 = XCDR (v1); |
| 1283 | v1 = XCDR (v1); | 1283 | rarely_quit (n); |
| 1284 | immediate_quit = false; | 1284 | } |
| 1285 | TOP = CAR (v1); | 1285 | TOP = CAR (v1); |
| 1286 | } | 1286 | } |
| 1287 | else | 1287 | else |
diff --git a/src/callproc.c b/src/callproc.c index 301ccf383b5..84324c48dcf 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -198,11 +198,11 @@ call_process_cleanup (Lisp_Object buffer) | |||
| 198 | { | 198 | { |
| 199 | kill (-synch_process_pid, SIGINT); | 199 | kill (-synch_process_pid, SIGINT); |
| 200 | message1 ("Waiting for process to die...(type C-g again to kill it instantly)"); | 200 | message1 ("Waiting for process to die...(type C-g again to kill it instantly)"); |
| 201 | immediate_quit = true; | 201 | |
| 202 | maybe_quit (); | 202 | /* This will quit on C-g. */ |
| 203 | wait_for_termination (synch_process_pid, 0, 1); | 203 | wait_for_termination (synch_process_pid, 0, 1); |
| 204 | |||
| 204 | synch_process_pid = 0; | 205 | synch_process_pid = 0; |
| 205 | immediate_quit = false; | ||
| 206 | message1 ("Waiting for process to die...done"); | 206 | message1 ("Waiting for process to die...done"); |
| 207 | } | 207 | } |
| 208 | #endif /* !MSDOS */ | 208 | #endif /* !MSDOS */ |
| @@ -726,9 +726,6 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd, | |||
| 726 | process_coding.src_multibyte = 0; | 726 | process_coding.src_multibyte = 0; |
| 727 | } | 727 | } |
| 728 | 728 | ||
| 729 | immediate_quit = true; | ||
| 730 | maybe_quit (); | ||
| 731 | |||
| 732 | if (0 <= fd0) | 729 | if (0 <= fd0) |
| 733 | { | 730 | { |
| 734 | enum { CALLPROC_BUFFER_SIZE_MIN = 16 * 1024 }; | 731 | enum { CALLPROC_BUFFER_SIZE_MIN = 16 * 1024 }; |
| @@ -749,8 +746,8 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd, | |||
| 749 | nread = carryover; | 746 | nread = carryover; |
| 750 | while (nread < bufsize - 1024) | 747 | while (nread < bufsize - 1024) |
| 751 | { | 748 | { |
| 752 | int this_read = emacs_read (fd0, buf + nread, | 749 | int this_read = emacs_read_quit (fd0, buf + nread, |
| 753 | bufsize - nread); | 750 | bufsize - nread); |
| 754 | 751 | ||
| 755 | if (this_read < 0) | 752 | if (this_read < 0) |
| 756 | goto give_up; | 753 | goto give_up; |
| @@ -769,7 +766,6 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd, | |||
| 769 | } | 766 | } |
| 770 | 767 | ||
| 771 | /* Now NREAD is the total amount of data in the buffer. */ | 768 | /* Now NREAD is the total amount of data in the buffer. */ |
| 772 | immediate_quit = false; | ||
| 773 | 769 | ||
| 774 | if (!nread) | 770 | if (!nread) |
| 775 | ; | 771 | ; |
| @@ -842,8 +838,6 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd, | |||
| 842 | we should have already detected a coding system. */ | 838 | we should have already detected a coding system. */ |
| 843 | display_on_the_fly = true; | 839 | display_on_the_fly = true; |
| 844 | } | 840 | } |
| 845 | immediate_quit = true; | ||
| 846 | maybe_quit (); | ||
| 847 | } | 841 | } |
| 848 | give_up: ; | 842 | give_up: ; |
| 849 | 843 | ||
| @@ -860,8 +854,6 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd, | |||
| 860 | wait_for_termination (pid, &status, fd0 < 0); | 854 | wait_for_termination (pid, &status, fd0 < 0); |
| 861 | #endif | 855 | #endif |
| 862 | 856 | ||
| 863 | immediate_quit = false; | ||
| 864 | |||
| 865 | /* Don't kill any children that the subprocess may have left behind | 857 | /* Don't kill any children that the subprocess may have left behind |
| 866 | when exiting. */ | 858 | when exiting. */ |
| 867 | synch_process_pid = 0; | 859 | synch_process_pid = 0; |
diff --git a/src/dired.c b/src/dired.c index 52e81fb380b..5ea00fb8db4 100644 --- a/src/dired.c +++ b/src/dired.c | |||
| @@ -248,14 +248,11 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full, | |||
| 248 | 248 | ||
| 249 | /* Now that we have unwind_protect in place, we might as well | 249 | /* Now that we have unwind_protect in place, we might as well |
| 250 | allow matching to be interrupted. */ | 250 | allow matching to be interrupted. */ |
| 251 | immediate_quit = true; | ||
| 252 | maybe_quit (); | 251 | maybe_quit (); |
| 253 | 252 | ||
| 254 | bool wanted = (NILP (match) | 253 | bool wanted = (NILP (match) |
| 255 | || re_search (bufp, SSDATA (name), len, 0, len, 0) >= 0); | 254 | || re_search (bufp, SSDATA (name), len, 0, len, 0) >= 0); |
| 256 | 255 | ||
| 257 | immediate_quit = false; | ||
| 258 | |||
| 259 | if (wanted) | 256 | if (wanted) |
| 260 | { | 257 | { |
| 261 | if (!NILP (full)) | 258 | if (!NILP (full)) |
diff --git a/src/dispextern.h b/src/dispextern.h index 51222e636be..eb71a82311c 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -3263,6 +3263,7 @@ void move_it_past_eol (struct it *); | |||
| 3263 | void move_it_in_display_line (struct it *it, | 3263 | void move_it_in_display_line (struct it *it, |
| 3264 | ptrdiff_t to_charpos, int to_x, | 3264 | ptrdiff_t to_charpos, int to_x, |
| 3265 | enum move_operation_enum op); | 3265 | enum move_operation_enum op); |
| 3266 | int partial_line_height (struct it *it_origin); | ||
| 3266 | bool in_display_vector_p (struct it *); | 3267 | bool in_display_vector_p (struct it *); |
| 3267 | int frame_mode_line_height (struct frame *); | 3268 | int frame_mode_line_height (struct frame *); |
| 3268 | extern bool redisplaying_p; | 3269 | extern bool redisplaying_p; |
| @@ -186,7 +186,7 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition) | |||
| 186 | If we read the same block last time, maybe skip this? */ | 186 | If we read the same block last time, maybe skip this? */ |
| 187 | if (space_left > 1024 * 8) | 187 | if (space_left > 1024 * 8) |
| 188 | space_left = 1024 * 8; | 188 | space_left = 1024 * 8; |
| 189 | nread = emacs_read (fd, p, space_left); | 189 | nread = emacs_read_quit (fd, p, space_left); |
| 190 | if (nread < 0) | 190 | if (nread < 0) |
| 191 | report_file_error ("Read error on documentation file", file); | 191 | report_file_error ("Read error on documentation file", file); |
| 192 | p[nread] = 0; | 192 | p[nread] = 0; |
| @@ -590,16 +590,15 @@ the same file name is found in the `doc-directory'. */) | |||
| 590 | Vdoc_file_name = filename; | 590 | Vdoc_file_name = filename; |
| 591 | filled = 0; | 591 | filled = 0; |
| 592 | pos = 0; | 592 | pos = 0; |
| 593 | while (1) | 593 | while (true) |
| 594 | { | 594 | { |
| 595 | register char *end; | ||
| 596 | if (filled < 512) | 595 | if (filled < 512) |
| 597 | filled += emacs_read (fd, &buf[filled], sizeof buf - 1 - filled); | 596 | filled += emacs_read_quit (fd, &buf[filled], sizeof buf - 1 - filled); |
| 598 | if (!filled) | 597 | if (!filled) |
| 599 | break; | 598 | break; |
| 600 | 599 | ||
| 601 | buf[filled] = 0; | 600 | buf[filled] = 0; |
| 602 | end = buf + (filled < 512 ? filled : filled - 128); | 601 | char *end = buf + (filled < 512 ? filled : filled - 128); |
| 603 | p = memchr (buf, '\037', end - buf); | 602 | p = memchr (buf, '\037', end - buf); |
| 604 | /* p points to ^_Ffunctionname\n or ^_Vvarname\n or ^_Sfilename\n. */ | 603 | /* p points to ^_Ffunctionname\n or ^_Vvarname\n or ^_Sfilename\n. */ |
| 605 | if (p) | 604 | if (p) |
diff --git a/src/editfns.c b/src/editfns.c index 82c6abb9987..4618164d008 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -3053,7 +3053,6 @@ determines whether case is significant or ignored. */) | |||
| 3053 | i2 = begp2; | 3053 | i2 = begp2; |
| 3054 | i1_byte = buf_charpos_to_bytepos (bp1, i1); | 3054 | i1_byte = buf_charpos_to_bytepos (bp1, i1); |
| 3055 | i2_byte = buf_charpos_to_bytepos (bp2, i2); | 3055 | i2_byte = buf_charpos_to_bytepos (bp2, i2); |
| 3056 | immediate_quit = true; | ||
| 3057 | 3056 | ||
| 3058 | while (i1 < endp1 && i2 < endp2) | 3057 | while (i1 < endp1 && i2 < endp2) |
| 3059 | { | 3058 | { |
| @@ -3092,17 +3091,14 @@ determines whether case is significant or ignored. */) | |||
| 3092 | c1 = char_table_translate (trt, c1); | 3091 | c1 = char_table_translate (trt, c1); |
| 3093 | c2 = char_table_translate (trt, c2); | 3092 | c2 = char_table_translate (trt, c2); |
| 3094 | } | 3093 | } |
| 3094 | |||
| 3095 | if (c1 != c2) | 3095 | if (c1 != c2) |
| 3096 | { | 3096 | return make_number (c1 < c2 ? -1 - chars : chars + 1); |
| 3097 | immediate_quit = false; | ||
| 3098 | return make_number (c1 < c2 ? -1 - chars : chars + 1); | ||
| 3099 | } | ||
| 3100 | 3097 | ||
| 3101 | chars++; | 3098 | chars++; |
| 3099 | rarely_quit (chars); | ||
| 3102 | } | 3100 | } |
| 3103 | 3101 | ||
| 3104 | immediate_quit = false; | ||
| 3105 | |||
| 3106 | /* The strings match as far as they go. | 3102 | /* The strings match as far as they go. |
| 3107 | If one is shorter, that one is less. */ | 3103 | If one is shorter, that one is less. */ |
| 3108 | if (chars < endp1 - begp1) | 3104 | if (chars < endp1 - begp1) |
diff --git a/src/emacs.c b/src/emacs.c index 28b395c4fb4..3083d0df302 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -688,7 +688,7 @@ main (int argc, char **argv) | |||
| 688 | dumping = !initialized && (strcmp (argv[argc - 1], "dump") == 0 | 688 | dumping = !initialized && (strcmp (argv[argc - 1], "dump") == 0 |
| 689 | || strcmp (argv[argc - 1], "bootstrap") == 0 ); | 689 | || strcmp (argv[argc - 1], "bootstrap") == 0 ); |
| 690 | 690 | ||
| 691 | generating_ldefs_boot = getenv ("GENERATE_LDEFS_BOOT"); | 691 | generating_ldefs_boot = !!getenv ("GENERATE_LDEFS_BOOT"); |
| 692 | 692 | ||
| 693 | 693 | ||
| 694 | /* True if address randomization interferes with memory allocation. */ | 694 | /* True if address randomization interferes with memory allocation. */ |
diff --git a/src/eval.c b/src/eval.c index 62d4af15e27..22b02b49521 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -1131,7 +1131,6 @@ unwind_to_catch (struct handler *catch, Lisp_Object value) | |||
| 1131 | /* Restore certain special C variables. */ | 1131 | /* Restore certain special C variables. */ |
| 1132 | set_poll_suppress_count (catch->poll_suppress_count); | 1132 | set_poll_suppress_count (catch->poll_suppress_count); |
| 1133 | unblock_input_to (catch->interrupt_input_blocked); | 1133 | unblock_input_to (catch->interrupt_input_blocked); |
| 1134 | immediate_quit = false; | ||
| 1135 | 1134 | ||
| 1136 | do | 1135 | do |
| 1137 | { | 1136 | { |
| @@ -1462,6 +1461,19 @@ process_quit_flag (void) | |||
| 1462 | quit (); | 1461 | quit (); |
| 1463 | } | 1462 | } |
| 1464 | 1463 | ||
| 1464 | /* Check quit-flag and quit if it is non-nil. Typing C-g does not | ||
| 1465 | directly cause a quit; it only sets Vquit_flag. So the program | ||
| 1466 | needs to call maybe_quit at times when it is safe to quit. Every | ||
| 1467 | loop that might run for a long time or might not exit ought to call | ||
| 1468 | maybe_quit at least once, at a safe place. Unless that is | ||
| 1469 | impossible, of course. But it is very desirable to avoid creating | ||
| 1470 | loops where maybe_quit is impossible. | ||
| 1471 | |||
| 1472 | If quit-flag is set to `kill-emacs' the SIGINT handler has received | ||
| 1473 | a request to exit Emacs when it is safe to do. | ||
| 1474 | |||
| 1475 | When not quitting, process any pending signals. */ | ||
| 1476 | |||
| 1465 | void | 1477 | void |
| 1466 | maybe_quit (void) | 1478 | maybe_quit (void) |
| 1467 | { | 1479 | { |
| @@ -1517,7 +1529,6 @@ signal_or_quit (Lisp_Object error_symbol, Lisp_Object data, bool keyboard_quit) | |||
| 1517 | Lisp_Object clause = Qnil; | 1529 | Lisp_Object clause = Qnil; |
| 1518 | struct handler *h; | 1530 | struct handler *h; |
| 1519 | 1531 | ||
| 1520 | immediate_quit = false; | ||
| 1521 | if (gc_in_progress || waiting_for_input) | 1532 | if (gc_in_progress || waiting_for_input) |
| 1522 | emacs_abort (); | 1533 | emacs_abort (); |
| 1523 | 1534 | ||
diff --git a/src/fileio.c b/src/fileio.c index a46cfc7ac69..38400623793 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -1960,9 +1960,7 @@ permissions. */) | |||
| 1960 | report_file_error ("Copying permissions to", newname); | 1960 | report_file_error ("Copying permissions to", newname); |
| 1961 | } | 1961 | } |
| 1962 | #else /* not WINDOWSNT */ | 1962 | #else /* not WINDOWSNT */ |
| 1963 | immediate_quit = true; | ||
| 1964 | ifd = emacs_open (SSDATA (encoded_file), O_RDONLY, 0); | 1963 | ifd = emacs_open (SSDATA (encoded_file), O_RDONLY, 0); |
| 1965 | immediate_quit = false; | ||
| 1966 | 1964 | ||
| 1967 | if (ifd < 0) | 1965 | if (ifd < 0) |
| 1968 | report_file_error ("Opening input file", file); | 1966 | report_file_error ("Opening input file", file); |
| @@ -2024,7 +2022,6 @@ permissions. */) | |||
| 2024 | oldsize = out_st.st_size; | 2022 | oldsize = out_st.st_size; |
| 2025 | } | 2023 | } |
| 2026 | 2024 | ||
| 2027 | immediate_quit = true; | ||
| 2028 | maybe_quit (); | 2025 | maybe_quit (); |
| 2029 | 2026 | ||
| 2030 | if (clone_file (ofd, ifd)) | 2027 | if (clone_file (ofd, ifd)) |
| @@ -2033,9 +2030,9 @@ permissions. */) | |||
| 2033 | { | 2030 | { |
| 2034 | char buf[MAX_ALLOCA]; | 2031 | char buf[MAX_ALLOCA]; |
| 2035 | ptrdiff_t n; | 2032 | ptrdiff_t n; |
| 2036 | for (newsize = 0; 0 < (n = emacs_read (ifd, buf, sizeof buf)); | 2033 | for (newsize = 0; 0 < (n = emacs_read_quit (ifd, buf, sizeof buf)); |
| 2037 | newsize += n) | 2034 | newsize += n) |
| 2038 | if (emacs_write_sig (ofd, buf, n) != n) | 2035 | if (emacs_write_quit (ofd, buf, n) != n) |
| 2039 | report_file_error ("Write error", newname); | 2036 | report_file_error ("Write error", newname); |
| 2040 | if (n < 0) | 2037 | if (n < 0) |
| 2041 | report_file_error ("Read error", file); | 2038 | report_file_error ("Read error", file); |
| @@ -2047,8 +2044,6 @@ permissions. */) | |||
| 2047 | if (newsize < oldsize && ftruncate (ofd, newsize) != 0) | 2044 | if (newsize < oldsize && ftruncate (ofd, newsize) != 0) |
| 2048 | report_file_error ("Truncating output file", newname); | 2045 | report_file_error ("Truncating output file", newname); |
| 2049 | 2046 | ||
| 2050 | immediate_quit = false; | ||
| 2051 | |||
| 2052 | #ifndef MSDOS | 2047 | #ifndef MSDOS |
| 2053 | /* Preserve the original file permissions, and if requested, also its | 2048 | /* Preserve the original file permissions, and if requested, also its |
| 2054 | owner and group. */ | 2049 | owner and group. */ |
| @@ -3401,15 +3396,10 @@ decide_coding_unwind (Lisp_Object unwind_data) | |||
| 3401 | static Lisp_Object | 3396 | static Lisp_Object |
| 3402 | read_non_regular (Lisp_Object state) | 3397 | read_non_regular (Lisp_Object state) |
| 3403 | { | 3398 | { |
| 3404 | int nbytes; | 3399 | int nbytes = emacs_read_quit (XSAVE_INTEGER (state, 0), |
| 3405 | 3400 | ((char *) BEG_ADDR + PT_BYTE - BEG_BYTE | |
| 3406 | immediate_quit = true; | 3401 | + XSAVE_INTEGER (state, 1)), |
| 3407 | maybe_quit (); | 3402 | XSAVE_INTEGER (state, 2)); |
| 3408 | nbytes = emacs_read (XSAVE_INTEGER (state, 0), | ||
| 3409 | ((char *) BEG_ADDR + PT_BYTE - BEG_BYTE | ||
| 3410 | + XSAVE_INTEGER (state, 1)), | ||
| 3411 | XSAVE_INTEGER (state, 2)); | ||
| 3412 | immediate_quit = false; | ||
| 3413 | /* Fast recycle this object for the likely next call. */ | 3403 | /* Fast recycle this object for the likely next call. */ |
| 3414 | free_misc (state); | 3404 | free_misc (state); |
| 3415 | return make_number (nbytes); | 3405 | return make_number (nbytes); |
| @@ -3753,17 +3743,17 @@ by calling `format-decode', which see. */) | |||
| 3753 | int nread; | 3743 | int nread; |
| 3754 | 3744 | ||
| 3755 | if (st.st_size <= (1024 * 4)) | 3745 | if (st.st_size <= (1024 * 4)) |
| 3756 | nread = emacs_read (fd, read_buf, 1024 * 4); | 3746 | nread = emacs_read_quit (fd, read_buf, 1024 * 4); |
| 3757 | else | 3747 | else |
| 3758 | { | 3748 | { |
| 3759 | nread = emacs_read (fd, read_buf, 1024); | 3749 | nread = emacs_read_quit (fd, read_buf, 1024); |
| 3760 | if (nread == 1024) | 3750 | if (nread == 1024) |
| 3761 | { | 3751 | { |
| 3762 | int ntail; | 3752 | int ntail; |
| 3763 | if (lseek (fd, - (1024 * 3), SEEK_END) < 0) | 3753 | if (lseek (fd, - (1024 * 3), SEEK_END) < 0) |
| 3764 | report_file_error ("Setting file position", | 3754 | report_file_error ("Setting file position", |
| 3765 | orig_filename); | 3755 | orig_filename); |
| 3766 | ntail = emacs_read (fd, read_buf + nread, 1024 * 3); | 3756 | ntail = emacs_read_quit (fd, read_buf + nread, 1024 * 3); |
| 3767 | nread = ntail < 0 ? ntail : nread + ntail; | 3757 | nread = ntail < 0 ? ntail : nread + ntail; |
| 3768 | } | 3758 | } |
| 3769 | } | 3759 | } |
| @@ -3868,15 +3858,11 @@ by calling `format-decode', which see. */) | |||
| 3868 | report_file_error ("Setting file position", orig_filename); | 3858 | report_file_error ("Setting file position", orig_filename); |
| 3869 | } | 3859 | } |
| 3870 | 3860 | ||
| 3871 | immediate_quit = true; | ||
| 3872 | maybe_quit (); | ||
| 3873 | /* Count how many chars at the start of the file | 3861 | /* Count how many chars at the start of the file |
| 3874 | match the text at the beginning of the buffer. */ | 3862 | match the text at the beginning of the buffer. */ |
| 3875 | while (1) | 3863 | while (true) |
| 3876 | { | 3864 | { |
| 3877 | int nread, bufpos; | 3865 | int nread = emacs_read_quit (fd, read_buf, sizeof read_buf); |
| 3878 | |||
| 3879 | nread = emacs_read (fd, read_buf, sizeof read_buf); | ||
| 3880 | if (nread < 0) | 3866 | if (nread < 0) |
| 3881 | report_file_error ("Read error", orig_filename); | 3867 | report_file_error ("Read error", orig_filename); |
| 3882 | else if (nread == 0) | 3868 | else if (nread == 0) |
| @@ -3898,7 +3884,7 @@ by calling `format-decode', which see. */) | |||
| 3898 | break; | 3884 | break; |
| 3899 | } | 3885 | } |
| 3900 | 3886 | ||
| 3901 | bufpos = 0; | 3887 | int bufpos = 0; |
| 3902 | while (bufpos < nread && same_at_start < ZV_BYTE | 3888 | while (bufpos < nread && same_at_start < ZV_BYTE |
| 3903 | && FETCH_BYTE (same_at_start) == read_buf[bufpos]) | 3889 | && FETCH_BYTE (same_at_start) == read_buf[bufpos]) |
| 3904 | same_at_start++, bufpos++; | 3890 | same_at_start++, bufpos++; |
| @@ -3907,7 +3893,6 @@ by calling `format-decode', which see. */) | |||
| 3907 | if (bufpos != nread) | 3893 | if (bufpos != nread) |
| 3908 | break; | 3894 | break; |
| 3909 | } | 3895 | } |
| 3910 | immediate_quit = false; | ||
| 3911 | /* If the file matches the buffer completely, | 3896 | /* If the file matches the buffer completely, |
| 3912 | there's no need to replace anything. */ | 3897 | there's no need to replace anything. */ |
| 3913 | if (same_at_start - BEGV_BYTE == end_offset - beg_offset) | 3898 | if (same_at_start - BEGV_BYTE == end_offset - beg_offset) |
| @@ -3919,8 +3904,7 @@ by calling `format-decode', which see. */) | |||
| 3919 | del_range_1 (same_at_start, same_at_end, 0, 0); | 3904 | del_range_1 (same_at_start, same_at_end, 0, 0); |
| 3920 | goto handled; | 3905 | goto handled; |
| 3921 | } | 3906 | } |
| 3922 | immediate_quit = true; | 3907 | |
| 3923 | maybe_quit (); | ||
| 3924 | /* Count how many chars at the end of the file | 3908 | /* Count how many chars at the end of the file |
| 3925 | match the text at the end of the buffer. But, if we have | 3909 | match the text at the end of the buffer. But, if we have |
| 3926 | already found that decoding is necessary, don't waste time. */ | 3910 | already found that decoding is necessary, don't waste time. */ |
| @@ -3942,7 +3926,8 @@ by calling `format-decode', which see. */) | |||
| 3942 | total_read = nread = 0; | 3926 | total_read = nread = 0; |
| 3943 | while (total_read < trial) | 3927 | while (total_read < trial) |
| 3944 | { | 3928 | { |
| 3945 | nread = emacs_read (fd, read_buf + total_read, trial - total_read); | 3929 | nread = emacs_read_quit (fd, read_buf + total_read, |
| 3930 | trial - total_read); | ||
| 3946 | if (nread < 0) | 3931 | if (nread < 0) |
| 3947 | report_file_error ("Read error", orig_filename); | 3932 | report_file_error ("Read error", orig_filename); |
| 3948 | else if (nread == 0) | 3933 | else if (nread == 0) |
| @@ -3977,7 +3962,6 @@ by calling `format-decode', which see. */) | |||
| 3977 | if (nread == 0) | 3962 | if (nread == 0) |
| 3978 | break; | 3963 | break; |
| 3979 | } | 3964 | } |
| 3980 | immediate_quit = false; | ||
| 3981 | 3965 | ||
| 3982 | if (! giveup_match_end) | 3966 | if (! giveup_match_end) |
| 3983 | { | 3967 | { |
| @@ -4069,18 +4053,13 @@ by calling `format-decode', which see. */) | |||
| 4069 | inserted = 0; /* Bytes put into CONVERSION_BUFFER so far. */ | 4053 | inserted = 0; /* Bytes put into CONVERSION_BUFFER so far. */ |
| 4070 | unprocessed = 0; /* Bytes not processed in previous loop. */ | 4054 | unprocessed = 0; /* Bytes not processed in previous loop. */ |
| 4071 | 4055 | ||
| 4072 | while (1) | 4056 | while (true) |
| 4073 | { | 4057 | { |
| 4074 | /* Read at most READ_BUF_SIZE bytes at a time, to allow | 4058 | /* Read at most READ_BUF_SIZE bytes at a time, to allow |
| 4075 | quitting while reading a huge file. */ | 4059 | quitting while reading a huge file. */ |
| 4076 | 4060 | ||
| 4077 | /* Allow quitting out of the actual I/O. */ | 4061 | this = emacs_read_quit (fd, read_buf + unprocessed, |
| 4078 | immediate_quit = true; | 4062 | READ_BUF_SIZE - unprocessed); |
| 4079 | maybe_quit (); | ||
| 4080 | this = emacs_read (fd, read_buf + unprocessed, | ||
| 4081 | READ_BUF_SIZE - unprocessed); | ||
| 4082 | immediate_quit = false; | ||
| 4083 | |||
| 4084 | if (this <= 0) | 4063 | if (this <= 0) |
| 4085 | break; | 4064 | break; |
| 4086 | 4065 | ||
| @@ -4294,13 +4273,10 @@ by calling `format-decode', which see. */) | |||
| 4294 | /* Allow quitting out of the actual I/O. We don't make text | 4273 | /* Allow quitting out of the actual I/O. We don't make text |
| 4295 | part of the buffer until all the reading is done, so a C-g | 4274 | part of the buffer until all the reading is done, so a C-g |
| 4296 | here doesn't do any harm. */ | 4275 | here doesn't do any harm. */ |
| 4297 | immediate_quit = true; | 4276 | this = emacs_read_quit (fd, |
| 4298 | maybe_quit (); | 4277 | ((char *) BEG_ADDR + PT_BYTE - BEG_BYTE |
| 4299 | this = emacs_read (fd, | 4278 | + inserted), |
| 4300 | ((char *) BEG_ADDR + PT_BYTE - BEG_BYTE | 4279 | trytry); |
| 4301 | + inserted), | ||
| 4302 | trytry); | ||
| 4303 | immediate_quit = false; | ||
| 4304 | } | 4280 | } |
| 4305 | 4281 | ||
| 4306 | if (this <= 0) | 4282 | if (this <= 0) |
| @@ -5002,8 +4978,6 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename, | |||
| 5002 | } | 4978 | } |
| 5003 | } | 4979 | } |
| 5004 | 4980 | ||
| 5005 | immediate_quit = true; | ||
| 5006 | |||
| 5007 | if (STRINGP (start)) | 4981 | if (STRINGP (start)) |
| 5008 | ok = a_write (desc, start, 0, SCHARS (start), &annotations, &coding); | 4982 | ok = a_write (desc, start, 0, SCHARS (start), &annotations, &coding); |
| 5009 | else if (XINT (start) != XINT (end)) | 4983 | else if (XINT (start) != XINT (end)) |
| @@ -5026,8 +5000,6 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename, | |||
| 5026 | save_errno = errno; | 5000 | save_errno = errno; |
| 5027 | } | 5001 | } |
| 5028 | 5002 | ||
| 5029 | immediate_quit = false; | ||
| 5030 | |||
| 5031 | /* fsync is not crucial for temporary files. Nor for auto-save | 5003 | /* fsync is not crucial for temporary files. Nor for auto-save |
| 5032 | files, since they might lose some work anyway. */ | 5004 | files, since they might lose some work anyway. */ |
| 5033 | if (open_and_close_file && !auto_saving && !write_region_inhibit_fsync) | 5005 | if (open_and_close_file && !auto_saving && !write_region_inhibit_fsync) |
| @@ -5417,7 +5389,7 @@ e_write (int desc, Lisp_Object string, ptrdiff_t start, ptrdiff_t end, | |||
| 5417 | : (STRINGP (coding->dst_object) | 5389 | : (STRINGP (coding->dst_object) |
| 5418 | ? SSDATA (coding->dst_object) | 5390 | ? SSDATA (coding->dst_object) |
| 5419 | : (char *) BYTE_POS_ADDR (coding->dst_pos_byte))); | 5391 | : (char *) BYTE_POS_ADDR (coding->dst_pos_byte))); |
| 5420 | coding->produced -= emacs_write_sig (desc, buf, coding->produced); | 5392 | coding->produced -= emacs_write_quit (desc, buf, coding->produced); |
| 5421 | 5393 | ||
| 5422 | if (coding->raw_destination) | 5394 | if (coding->raw_destination) |
| 5423 | { | 5395 | { |
diff --git a/src/filelock.c b/src/filelock.c index de65c52efa1..67e8dbd34ed 100644 --- a/src/filelock.c +++ b/src/filelock.c | |||
| @@ -407,9 +407,7 @@ create_lock_file (char *lfname, char *lock_info_str, bool force) | |||
| 407 | fcntl (fd, F_SETFD, FD_CLOEXEC); | 407 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
| 408 | lock_info_len = strlen (lock_info_str); | 408 | lock_info_len = strlen (lock_info_str); |
| 409 | err = 0; | 409 | err = 0; |
| 410 | /* Use 'write', not 'emacs_write', as garbage collection | 410 | if (emacs_write (fd, lock_info_str, lock_info_len) != lock_info_len |
| 411 | might signal an error, which would leak FD. */ | ||
| 412 | if (write (fd, lock_info_str, lock_info_len) != lock_info_len | ||
| 413 | || fchmod (fd, S_IRUSR | S_IRGRP | S_IROTH) != 0) | 411 | || fchmod (fd, S_IRUSR | S_IRGRP | S_IROTH) != 0) |
| 414 | err = errno; | 412 | err = errno; |
| 415 | /* There is no need to call fsync here, as the contents of | 413 | /* There is no need to call fsync here, as the contents of |
| @@ -490,8 +488,7 @@ read_lock_data (char *lfname, char lfinfo[MAX_LFINFO + 1]) | |||
| 490 | int fd = emacs_open (lfname, O_RDONLY | O_NOFOLLOW, 0); | 488 | int fd = emacs_open (lfname, O_RDONLY | O_NOFOLLOW, 0); |
| 491 | if (0 <= fd) | 489 | if (0 <= fd) |
| 492 | { | 490 | { |
| 493 | /* Use read, not emacs_read, since FD isn't unwind-protected. */ | 491 | ptrdiff_t read_bytes = emacs_read (fd, lfinfo, MAX_LFINFO + 1); |
| 494 | ptrdiff_t read_bytes = read (fd, lfinfo, MAX_LFINFO + 1); | ||
| 495 | int read_errno = errno; | 492 | int read_errno = errno; |
| 496 | if (emacs_close (fd) != 0) | 493 | if (emacs_close (fd) != 0) |
| 497 | return -1; | 494 | return -1; |
| @@ -84,22 +84,6 @@ See Info node `(elisp)Random Numbers' for more details. */) | |||
| 84 | return make_number (val); | 84 | return make_number (val); |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | /* Heuristic on how many iterations of a tight loop can be safely done | ||
| 88 | before it's time to do a quit. This must be a power of 2. It | ||
| 89 | is nice but not necessary for it to equal USHRT_MAX + 1. */ | ||
| 90 | enum { QUIT_COUNT_HEURISTIC = 1 << 16 }; | ||
| 91 | |||
| 92 | /* Process a quit, but do it only rarely, for efficiency. "Rarely" | ||
| 93 | means once per QUIT_COUNT_HEURISTIC or per USHRT_MAX + 1 times, | ||
| 94 | whichever is smaller. Use *QUIT_COUNT to count this. */ | ||
| 95 | |||
| 96 | static void | ||
| 97 | rarely_quit (unsigned short int *quit_count) | ||
| 98 | { | ||
| 99 | if (! (++*quit_count & (QUIT_COUNT_HEURISTIC - 1))) | ||
| 100 | maybe_quit (); | ||
| 101 | } | ||
| 102 | |||
| 103 | /* Random data-structure functions. */ | 87 | /* Random data-structure functions. */ |
| 104 | 88 | ||
| 105 | DEFUN ("length", Flength, Slength, 1, 1, 0, | 89 | DEFUN ("length", Flength, Slength, 1, 1, 0, |
| @@ -1359,20 +1343,17 @@ DEFUN ("nthcdr", Fnthcdr, Snthcdr, 2, 2, 0, | |||
| 1359 | (Lisp_Object n, Lisp_Object list) | 1343 | (Lisp_Object n, Lisp_Object list) |
| 1360 | { | 1344 | { |
| 1361 | CHECK_NUMBER (n); | 1345 | CHECK_NUMBER (n); |
| 1362 | EMACS_INT num = XINT (n); | ||
| 1363 | Lisp_Object tail = list; | 1346 | Lisp_Object tail = list; |
| 1364 | immediate_quit = true; | 1347 | for (EMACS_INT num = XINT (n); 0 < num; num--) |
| 1365 | for (EMACS_INT i = 0; i < num; i++) | ||
| 1366 | { | 1348 | { |
| 1367 | if (! CONSP (tail)) | 1349 | if (! CONSP (tail)) |
| 1368 | { | 1350 | { |
| 1369 | immediate_quit = false; | ||
| 1370 | CHECK_LIST_END (tail, list); | 1351 | CHECK_LIST_END (tail, list); |
| 1371 | return Qnil; | 1352 | return Qnil; |
| 1372 | } | 1353 | } |
| 1373 | tail = XCDR (tail); | 1354 | tail = XCDR (tail); |
| 1355 | rarely_quit (num); | ||
| 1374 | } | 1356 | } |
| 1375 | immediate_quit = false; | ||
| 1376 | return tail; | 1357 | return tail; |
| 1377 | } | 1358 | } |
| 1378 | 1359 | ||
| @@ -1408,7 +1389,7 @@ The value is actually the tail of LIST whose car is ELT. */) | |||
| 1408 | { | 1389 | { |
| 1409 | if (! NILP (Fequal (elt, XCAR (tail)))) | 1390 | if (! NILP (Fequal (elt, XCAR (tail)))) |
| 1410 | return tail; | 1391 | return tail; |
| 1411 | rarely_quit (&quit_count); | 1392 | rarely_quit (++quit_count); |
| 1412 | } | 1393 | } |
| 1413 | CHECK_LIST_END (tail, list); | 1394 | CHECK_LIST_END (tail, list); |
| 1414 | return Qnil; | 1395 | return Qnil; |
| @@ -1419,17 +1400,14 @@ DEFUN ("memq", Fmemq, Smemq, 2, 2, 0, | |||
| 1419 | The value is actually the tail of LIST whose car is ELT. */) | 1400 | The value is actually the tail of LIST whose car is ELT. */) |
| 1420 | (Lisp_Object elt, Lisp_Object list) | 1401 | (Lisp_Object elt, Lisp_Object list) |
| 1421 | { | 1402 | { |
| 1422 | immediate_quit = true; | 1403 | unsigned short int quit_count = 0; |
| 1423 | Lisp_Object tail; | 1404 | Lisp_Object tail; |
| 1424 | for (tail = list; CONSP (tail); tail = XCDR (tail)) | 1405 | for (tail = list; CONSP (tail); tail = XCDR (tail)) |
| 1425 | { | 1406 | { |
| 1426 | if (EQ (XCAR (tail), elt)) | 1407 | if (EQ (XCAR (tail), elt)) |
| 1427 | { | 1408 | return tail; |
| 1428 | immediate_quit = false; | 1409 | rarely_quit (++quit_count); |
| 1429 | return tail; | ||
| 1430 | } | ||
| 1431 | } | 1410 | } |
| 1432 | immediate_quit = false; | ||
| 1433 | CHECK_LIST_END (tail, list); | 1411 | CHECK_LIST_END (tail, list); |
| 1434 | return Qnil; | 1412 | return Qnil; |
| 1435 | } | 1413 | } |
| @@ -1442,18 +1420,15 @@ The value is actually the tail of LIST whose car is ELT. */) | |||
| 1442 | if (!FLOATP (elt)) | 1420 | if (!FLOATP (elt)) |
| 1443 | return Fmemq (elt, list); | 1421 | return Fmemq (elt, list); |
| 1444 | 1422 | ||
| 1445 | immediate_quit = true; | 1423 | unsigned short int quit_count = 0; |
| 1446 | Lisp_Object tail; | 1424 | Lisp_Object tail; |
| 1447 | for (tail = list; CONSP (tail); tail = XCDR (tail)) | 1425 | for (tail = list; CONSP (tail); tail = XCDR (tail)) |
| 1448 | { | 1426 | { |
| 1449 | Lisp_Object tem = XCAR (tail); | 1427 | Lisp_Object tem = XCAR (tail); |
| 1450 | if (FLOATP (tem) && internal_equal (elt, tem, 0, 0, Qnil)) | 1428 | if (FLOATP (tem) && internal_equal (elt, tem, 0, 0, Qnil)) |
| 1451 | { | 1429 | return tail; |
| 1452 | immediate_quit = false; | 1430 | rarely_quit (++quit_count); |
| 1453 | return tail; | ||
| 1454 | } | ||
| 1455 | } | 1431 | } |
| 1456 | immediate_quit = false; | ||
| 1457 | CHECK_LIST_END (tail, list); | 1432 | CHECK_LIST_END (tail, list); |
| 1458 | return Qnil; | 1433 | return Qnil; |
| 1459 | } | 1434 | } |
| @@ -1464,15 +1439,14 @@ The value is actually the first element of LIST whose car is KEY. | |||
| 1464 | Elements of LIST that are not conses are ignored. */) | 1439 | Elements of LIST that are not conses are ignored. */) |
| 1465 | (Lisp_Object key, Lisp_Object list) | 1440 | (Lisp_Object key, Lisp_Object list) |
| 1466 | { | 1441 | { |
| 1467 | immediate_quit = true; | 1442 | unsigned short int quit_count = 0; |
| 1468 | Lisp_Object tail; | 1443 | Lisp_Object tail; |
| 1469 | for (tail = list; CONSP (tail); tail = XCDR (tail)) | 1444 | for (tail = list; CONSP (tail); tail = XCDR (tail)) |
| 1470 | if (CONSP (XCAR (tail)) && EQ (XCAR (XCAR (tail)), key)) | 1445 | { |
| 1471 | { | 1446 | if (CONSP (XCAR (tail)) && EQ (XCAR (XCAR (tail)), key)) |
| 1472 | immediate_quit = false; | ||
| 1473 | return XCAR (tail); | 1447 | return XCAR (tail); |
| 1474 | } | 1448 | rarely_quit (++quit_count); |
| 1475 | immediate_quit = true; | 1449 | } |
| 1476 | CHECK_LIST_END (tail, list); | 1450 | CHECK_LIST_END (tail, list); |
| 1477 | return Qnil; | 1451 | return Qnil; |
| 1478 | } | 1452 | } |
| @@ -1502,7 +1476,7 @@ The value is actually the first element of LIST whose car equals KEY. */) | |||
| 1502 | if (CONSP (car) | 1476 | if (CONSP (car) |
| 1503 | && (EQ (XCAR (car), key) || !NILP (Fequal (XCAR (car), key)))) | 1477 | && (EQ (XCAR (car), key) || !NILP (Fequal (XCAR (car), key)))) |
| 1504 | return car; | 1478 | return car; |
| 1505 | rarely_quit (&quit_count); | 1479 | rarely_quit (++quit_count); |
| 1506 | } | 1480 | } |
| 1507 | CHECK_LIST_END (tail, list); | 1481 | CHECK_LIST_END (tail, list); |
| 1508 | return Qnil; | 1482 | return Qnil; |
| @@ -1529,15 +1503,14 @@ DEFUN ("rassq", Frassq, Srassq, 2, 2, 0, | |||
| 1529 | The value is actually the first element of LIST whose cdr is KEY. */) | 1503 | The value is actually the first element of LIST whose cdr is KEY. */) |
| 1530 | (Lisp_Object key, Lisp_Object list) | 1504 | (Lisp_Object key, Lisp_Object list) |
| 1531 | { | 1505 | { |
| 1532 | immediate_quit = true; | 1506 | unsigned short int quit_count = 0; |
| 1533 | Lisp_Object tail; | 1507 | Lisp_Object tail; |
| 1534 | for (tail = list; CONSP (tail); tail = XCDR (tail)) | 1508 | for (tail = list; CONSP (tail); tail = XCDR (tail)) |
| 1535 | if (CONSP (XCAR (tail)) && EQ (XCDR (XCAR (tail)), key)) | 1509 | { |
| 1536 | { | 1510 | if (CONSP (XCAR (tail)) && EQ (XCDR (XCAR (tail)), key)) |
| 1537 | immediate_quit = false; | ||
| 1538 | return XCAR (tail); | 1511 | return XCAR (tail); |
| 1539 | } | 1512 | rarely_quit (++quit_count); |
| 1540 | immediate_quit = true; | 1513 | } |
| 1541 | CHECK_LIST_END (tail, list); | 1514 | CHECK_LIST_END (tail, list); |
| 1542 | return Qnil; | 1515 | return Qnil; |
| 1543 | } | 1516 | } |
| @@ -1555,7 +1528,7 @@ The value is actually the first element of LIST whose cdr equals KEY. */) | |||
| 1555 | if (CONSP (car) | 1528 | if (CONSP (car) |
| 1556 | && (EQ (XCDR (car), key) || !NILP (Fequal (XCDR (car), key)))) | 1529 | && (EQ (XCDR (car), key) || !NILP (Fequal (XCDR (car), key)))) |
| 1557 | return car; | 1530 | return car; |
| 1558 | rarely_quit (&quit_count); | 1531 | rarely_quit (++quit_count); |
| 1559 | } | 1532 | } |
| 1560 | CHECK_LIST_END (tail, list); | 1533 | CHECK_LIST_END (tail, list); |
| 1561 | return Qnil; | 1534 | return Qnil; |
| @@ -1589,6 +1562,7 @@ argument. */) | |||
| 1589 | else | 1562 | else |
| 1590 | prev = tail; | 1563 | prev = tail; |
| 1591 | } | 1564 | } |
| 1565 | CHECK_LIST_END (tail, list); | ||
| 1592 | return list; | 1566 | return list; |
| 1593 | } | 1567 | } |
| 1594 | 1568 | ||
| @@ -1710,7 +1684,7 @@ changing the value of a sequence `foo'. */) | |||
| 1710 | } | 1684 | } |
| 1711 | else | 1685 | else |
| 1712 | prev = tail; | 1686 | prev = tail; |
| 1713 | rarely_quit (&quit_count); | 1687 | rarely_quit (++quit_count); |
| 1714 | } | 1688 | } |
| 1715 | CHECK_LIST_END (tail, seq); | 1689 | CHECK_LIST_END (tail, seq); |
| 1716 | } | 1690 | } |
| @@ -1735,10 +1709,10 @@ This function may destructively modify SEQ to produce the value. */) | |||
| 1735 | 1709 | ||
| 1736 | for (prev = Qnil, tail = seq; CONSP (tail); tail = next) | 1710 | for (prev = Qnil, tail = seq; CONSP (tail); tail = next) |
| 1737 | { | 1711 | { |
| 1738 | rarely_quit (&quit_count); | ||
| 1739 | next = XCDR (tail); | 1712 | next = XCDR (tail); |
| 1740 | Fsetcdr (tail, prev); | 1713 | Fsetcdr (tail, prev); |
| 1741 | prev = tail; | 1714 | prev = tail; |
| 1715 | rarely_quit (++quit_count); | ||
| 1742 | } | 1716 | } |
| 1743 | CHECK_LIST_END (tail, seq); | 1717 | CHECK_LIST_END (tail, seq); |
| 1744 | seq = prev; | 1718 | seq = prev; |
| @@ -1784,8 +1758,8 @@ See also the function `nreverse', which is used more often. */) | |||
| 1784 | unsigned short int quit_count = 0; | 1758 | unsigned short int quit_count = 0; |
| 1785 | for (new = Qnil; CONSP (seq); seq = XCDR (seq)) | 1759 | for (new = Qnil; CONSP (seq); seq = XCDR (seq)) |
| 1786 | { | 1760 | { |
| 1787 | rarely_quit (&quit_count); | ||
| 1788 | new = Fcons (XCAR (seq), new); | 1761 | new = Fcons (XCAR (seq), new); |
| 1762 | rarely_quit (++quit_count); | ||
| 1789 | } | 1763 | } |
| 1790 | CHECK_LIST_END (seq, seq); | 1764 | CHECK_LIST_END (seq, seq); |
| 1791 | } | 1765 | } |
| @@ -2076,21 +2050,20 @@ use `(setq x (plist-put x prop val))' to be sure to use the new value. | |||
| 2076 | The PLIST is modified by side effects. */) | 2050 | The PLIST is modified by side effects. */) |
| 2077 | (Lisp_Object plist, Lisp_Object prop, Lisp_Object val) | 2051 | (Lisp_Object plist, Lisp_Object prop, Lisp_Object val) |
| 2078 | { | 2052 | { |
| 2079 | immediate_quit = true; | 2053 | unsigned short int quit_count = 0; |
| 2080 | Lisp_Object prev = Qnil; | 2054 | Lisp_Object prev = Qnil; |
| 2081 | for (Lisp_Object tail = plist; CONSP (tail) && CONSP (XCDR (tail)); | 2055 | for (Lisp_Object tail = plist; CONSP (tail) && CONSP (XCDR (tail)); |
| 2082 | tail = XCDR (XCDR (tail))) | 2056 | tail = XCDR (XCDR (tail))) |
| 2083 | { | 2057 | { |
| 2084 | if (EQ (prop, XCAR (tail))) | 2058 | if (EQ (prop, XCAR (tail))) |
| 2085 | { | 2059 | { |
| 2086 | immediate_quit = false; | ||
| 2087 | Fsetcar (XCDR (tail), val); | 2060 | Fsetcar (XCDR (tail), val); |
| 2088 | return plist; | 2061 | return plist; |
| 2089 | } | 2062 | } |
| 2090 | 2063 | ||
| 2091 | prev = tail; | 2064 | prev = tail; |
| 2065 | rarely_quit (++quit_count); | ||
| 2092 | } | 2066 | } |
| 2093 | immediate_quit = true; | ||
| 2094 | Lisp_Object newcell | 2067 | Lisp_Object newcell |
| 2095 | = Fcons (prop, Fcons (val, NILP (prev) ? plist : XCDR (XCDR (prev)))); | 2068 | = Fcons (prop, Fcons (val, NILP (prev) ? plist : XCDR (XCDR (prev)))); |
| 2096 | if (NILP (prev)) | 2069 | if (NILP (prev)) |
| @@ -2127,7 +2100,7 @@ one of the properties on the list. */) | |||
| 2127 | { | 2100 | { |
| 2128 | if (! NILP (Fequal (prop, XCAR (tail)))) | 2101 | if (! NILP (Fequal (prop, XCAR (tail)))) |
| 2129 | return XCAR (XCDR (tail)); | 2102 | return XCAR (XCDR (tail)); |
| 2130 | rarely_quit (&quit_count); | 2103 | rarely_quit (++quit_count); |
| 2131 | } | 2104 | } |
| 2132 | 2105 | ||
| 2133 | CHECK_LIST_END (tail, prop); | 2106 | CHECK_LIST_END (tail, prop); |
| @@ -2157,7 +2130,7 @@ The PLIST is modified by side effects. */) | |||
| 2157 | } | 2130 | } |
| 2158 | 2131 | ||
| 2159 | prev = tail; | 2132 | prev = tail; |
| 2160 | rarely_quit (&quit_count); | 2133 | rarely_quit (++quit_count); |
| 2161 | } | 2134 | } |
| 2162 | Lisp_Object newcell = list2 (prop, val); | 2135 | Lisp_Object newcell = list2 (prop, val); |
| 2163 | if (NILP (prev)) | 2136 | if (NILP (prev)) |
| @@ -2237,7 +2210,7 @@ internal_equal (Lisp_Object o1, Lisp_Object o2, int depth, bool props, | |||
| 2237 | 2210 | ||
| 2238 | unsigned short int quit_count = 0; | 2211 | unsigned short int quit_count = 0; |
| 2239 | tail_recurse: | 2212 | tail_recurse: |
| 2240 | rarely_quit (&quit_count); | 2213 | rarely_quit (++quit_count); |
| 2241 | if (EQ (o1, o2)) | 2214 | if (EQ (o1, o2)) |
| 2242 | return 1; | 2215 | return 1; |
| 2243 | if (XTYPE (o1) != XTYPE (o2)) | 2216 | if (XTYPE (o1) != XTYPE (o2)) |
| @@ -2441,18 +2414,15 @@ usage: (nconc &rest LISTS) */) | |||
| 2441 | 2414 | ||
| 2442 | CHECK_CONS (tem); | 2415 | CHECK_CONS (tem); |
| 2443 | 2416 | ||
| 2444 | immediate_quit = true; | ||
| 2445 | Lisp_Object tail; | 2417 | Lisp_Object tail; |
| 2446 | do | 2418 | do |
| 2447 | { | 2419 | { |
| 2448 | tail = tem; | 2420 | tail = tem; |
| 2449 | tem = XCDR (tail); | 2421 | tem = XCDR (tail); |
| 2422 | rarely_quit (++quit_count); | ||
| 2450 | } | 2423 | } |
| 2451 | while (CONSP (tem)); | 2424 | while (CONSP (tem)); |
| 2452 | 2425 | ||
| 2453 | immediate_quit = false; | ||
| 2454 | rarely_quit (&quit_count); | ||
| 2455 | |||
| 2456 | tem = args[argnum + 1]; | 2426 | tem = args[argnum + 1]; |
| 2457 | Fsetcdr (tail, tem); | 2427 | Fsetcdr (tail, tem); |
| 2458 | if (NILP (tem)) | 2428 | if (NILP (tem)) |
| @@ -2873,13 +2843,13 @@ property and a property with the value nil. | |||
| 2873 | The value is actually the tail of PLIST whose car is PROP. */) | 2843 | The value is actually the tail of PLIST whose car is PROP. */) |
| 2874 | (Lisp_Object plist, Lisp_Object prop) | 2844 | (Lisp_Object plist, Lisp_Object prop) |
| 2875 | { | 2845 | { |
| 2876 | immediate_quit = true; | 2846 | unsigned short int quit_count = 0; |
| 2877 | while (CONSP (plist) && !EQ (XCAR (plist), prop)) | 2847 | while (CONSP (plist) && !EQ (XCAR (plist), prop)) |
| 2878 | { | 2848 | { |
| 2879 | plist = XCDR (plist); | 2849 | plist = XCDR (plist); |
| 2880 | plist = CDR (plist); | 2850 | plist = CDR (plist); |
| 2851 | rarely_quit (++quit_count); | ||
| 2881 | } | 2852 | } |
| 2882 | immediate_quit = false; | ||
| 2883 | return plist; | 2853 | return plist; |
| 2884 | } | 2854 | } |
| 2885 | 2855 | ||
diff --git a/src/indent.c b/src/indent.c index 23951a16eb6..f630ebb847c 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -1200,9 +1200,6 @@ compute_motion (ptrdiff_t from, ptrdiff_t frombyte, EMACS_INT fromvpos, | |||
| 1200 | continuation_glyph_width = 0; /* In the fringe. */ | 1200 | continuation_glyph_width = 0; /* In the fringe. */ |
| 1201 | #endif | 1201 | #endif |
| 1202 | 1202 | ||
| 1203 | immediate_quit = true; | ||
| 1204 | maybe_quit (); | ||
| 1205 | |||
| 1206 | /* It's just impossible to be too paranoid here. */ | 1203 | /* It's just impossible to be too paranoid here. */ |
| 1207 | eassert (from == BYTE_TO_CHAR (frombyte) && frombyte == CHAR_TO_BYTE (from)); | 1204 | eassert (from == BYTE_TO_CHAR (frombyte) && frombyte == CHAR_TO_BYTE (from)); |
| 1208 | 1205 | ||
| @@ -1214,8 +1211,12 @@ compute_motion (ptrdiff_t from, ptrdiff_t frombyte, EMACS_INT fromvpos, | |||
| 1214 | cmp_it.id = -1; | 1211 | cmp_it.id = -1; |
| 1215 | composition_compute_stop_pos (&cmp_it, pos, pos_byte, to, Qnil); | 1212 | composition_compute_stop_pos (&cmp_it, pos, pos_byte, to, Qnil); |
| 1216 | 1213 | ||
| 1217 | while (1) | 1214 | unsigned short int quit_count = 0; |
| 1215 | |||
| 1216 | while (true) | ||
| 1218 | { | 1217 | { |
| 1218 | rarely_quit (++quit_count); | ||
| 1219 | |||
| 1219 | while (pos == next_boundary) | 1220 | while (pos == next_boundary) |
| 1220 | { | 1221 | { |
| 1221 | ptrdiff_t pos_here = pos; | 1222 | ptrdiff_t pos_here = pos; |
| @@ -1280,6 +1281,8 @@ compute_motion (ptrdiff_t from, ptrdiff_t frombyte, EMACS_INT fromvpos, | |||
| 1280 | pos = newpos; | 1281 | pos = newpos; |
| 1281 | pos_byte = CHAR_TO_BYTE (pos); | 1282 | pos_byte = CHAR_TO_BYTE (pos); |
| 1282 | } | 1283 | } |
| 1284 | |||
| 1285 | rarely_quit (++quit_count); | ||
| 1283 | } | 1286 | } |
| 1284 | 1287 | ||
| 1285 | /* Handle right margin. */ | 1288 | /* Handle right margin. */ |
| @@ -1602,6 +1605,7 @@ compute_motion (ptrdiff_t from, ptrdiff_t frombyte, EMACS_INT fromvpos, | |||
| 1602 | pos = find_before_next_newline (pos, to, 1, &pos_byte); | 1605 | pos = find_before_next_newline (pos, to, 1, &pos_byte); |
| 1603 | if (pos < to) | 1606 | if (pos < to) |
| 1604 | INC_BOTH (pos, pos_byte); | 1607 | INC_BOTH (pos, pos_byte); |
| 1608 | rarely_quit (++quit_count); | ||
| 1605 | } | 1609 | } |
| 1606 | while (pos < to | 1610 | while (pos < to |
| 1607 | && indented_beyond_p (pos, pos_byte, | 1611 | && indented_beyond_p (pos, pos_byte, |
| @@ -1694,7 +1698,6 @@ compute_motion (ptrdiff_t from, ptrdiff_t frombyte, EMACS_INT fromvpos, | |||
| 1694 | /* Nonzero if have just continued a line */ | 1698 | /* Nonzero if have just continued a line */ |
| 1695 | val_compute_motion.contin = (contin_hpos && prev_hpos == 0); | 1699 | val_compute_motion.contin = (contin_hpos && prev_hpos == 0); |
| 1696 | 1700 | ||
| 1697 | immediate_quit = false; | ||
| 1698 | return &val_compute_motion; | 1701 | return &val_compute_motion; |
| 1699 | } | 1702 | } |
| 1700 | 1703 | ||
diff --git a/src/keyboard.c b/src/keyboard.c index d41603b2e50..a86e7c5f8e4 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -169,9 +169,6 @@ struct kboard *echo_kboard; | |||
| 169 | 169 | ||
| 170 | Lisp_Object echo_message_buffer; | 170 | Lisp_Object echo_message_buffer; |
| 171 | 171 | ||
| 172 | /* True means C-g should cause immediate error-signal. */ | ||
| 173 | bool immediate_quit; | ||
| 174 | |||
| 175 | /* Character that causes a quit. Normally C-g. | 172 | /* Character that causes a quit. Normally C-g. |
| 176 | 173 | ||
| 177 | If we are running on an ordinary terminal, this must be an ordinary | 174 | If we are running on an ordinary terminal, this must be an ordinary |
| @@ -3584,16 +3581,7 @@ kbd_buffer_store_buffered_event (union buffered_input_event *event, | |||
| 3584 | as input, set quit-flag to cause an interrupt. */ | 3581 | as input, set quit-flag to cause an interrupt. */ |
| 3585 | if (!NILP (Vthrow_on_input) | 3582 | if (!NILP (Vthrow_on_input) |
| 3586 | && NILP (Fmemq (ignore_event, Vwhile_no_input_ignore_events))) | 3583 | && NILP (Fmemq (ignore_event, Vwhile_no_input_ignore_events))) |
| 3587 | { | 3584 | Vquit_flag = Vthrow_on_input; |
| 3588 | Vquit_flag = Vthrow_on_input; | ||
| 3589 | /* If we're inside a function that wants immediate quits, | ||
| 3590 | do it now. */ | ||
| 3591 | if (immediate_quit && NILP (Vinhibit_quit)) | ||
| 3592 | { | ||
| 3593 | immediate_quit = false; | ||
| 3594 | maybe_quit (); | ||
| 3595 | } | ||
| 3596 | } | ||
| 3597 | } | 3585 | } |
| 3598 | 3586 | ||
| 3599 | 3587 | ||
| @@ -7053,40 +7041,22 @@ tty_read_avail_input (struct terminal *terminal, | |||
| 7053 | 7041 | ||
| 7054 | /* Now read; for one reason or another, this will not block. | 7042 | /* Now read; for one reason or another, this will not block. |
| 7055 | NREAD is set to the number of chars read. */ | 7043 | NREAD is set to the number of chars read. */ |
| 7056 | do | 7044 | nread = emacs_read (fileno (tty->input), (char *) cbuf, n_to_read); |
| 7057 | { | 7045 | /* POSIX infers that processes which are not in the session leader's |
| 7058 | nread = emacs_read (fileno (tty->input), (char *) cbuf, n_to_read); | 7046 | process group won't get SIGHUPs at logout time. BSDI adheres to |
| 7059 | /* POSIX infers that processes which are not in the session leader's | 7047 | this part standard and returns -1 from read (0) with errno==EIO |
| 7060 | process group won't get SIGHUPs at logout time. BSDI adheres to | 7048 | when the control tty is taken away. |
| 7061 | this part standard and returns -1 from read (0) with errno==EIO | 7049 | Jeffrey Honig <jch@bsdi.com> says this is generally safe. */ |
| 7062 | when the control tty is taken away. | 7050 | if (nread == -1 && errno == EIO) |
| 7063 | Jeffrey Honig <jch@bsdi.com> says this is generally safe. */ | 7051 | return -2; /* Close this terminal. */ |
| 7064 | if (nread == -1 && errno == EIO) | 7052 | #if defined AIX && defined _BSD |
| 7065 | return -2; /* Close this terminal. */ | 7053 | /* The kernel sometimes fails to deliver SIGHUP for ptys. |
| 7066 | #if defined (AIX) && defined (_BSD) | 7054 | This looks incorrect, but it isn't, because _BSD causes |
| 7067 | /* The kernel sometimes fails to deliver SIGHUP for ptys. | 7055 | O_NDELAY to be defined in fcntl.h as O_NONBLOCK, |
| 7068 | This looks incorrect, but it isn't, because _BSD causes | 7056 | and that causes a value other than 0 when there is no input. */ |
| 7069 | O_NDELAY to be defined in fcntl.h as O_NONBLOCK, | 7057 | if (nread == 0) |
| 7070 | and that causes a value other than 0 when there is no input. */ | 7058 | return -2; /* Close this terminal. */ |
| 7071 | if (nread == 0) | ||
| 7072 | return -2; /* Close this terminal. */ | ||
| 7073 | #endif | ||
| 7074 | } | ||
| 7075 | while ( | ||
| 7076 | /* We used to retry the read if it was interrupted. | ||
| 7077 | But this does the wrong thing when O_NONBLOCK causes | ||
| 7078 | an EAGAIN error. Does anybody know of a situation | ||
| 7079 | where a retry is actually needed? */ | ||
| 7080 | #if 0 | ||
| 7081 | nread < 0 && (errno == EAGAIN || errno == EFAULT | ||
| 7082 | #ifdef EBADSLT | ||
| 7083 | || errno == EBADSLT | ||
| 7084 | #endif | ||
| 7085 | ) | ||
| 7086 | #else | ||
| 7087 | 0 | ||
| 7088 | #endif | 7059 | #endif |
| 7089 | ); | ||
| 7090 | 7060 | ||
| 7091 | #ifndef USABLE_FIONREAD | 7061 | #ifndef USABLE_FIONREAD |
| 7092 | #if defined (USG) || defined (CYGWIN) | 7062 | #if defined (USG) || defined (CYGWIN) |
| @@ -10445,30 +10415,12 @@ handle_interrupt (bool in_signal_handler) | |||
| 10445 | } | 10415 | } |
| 10446 | else | 10416 | else |
| 10447 | { | 10417 | { |
| 10448 | /* If executing a function that wants to be interrupted out of | 10418 | /* Request quit when it's safe. */ |
| 10449 | and the user has not deferred quitting by binding `inhibit-quit' | 10419 | int count = NILP (Vquit_flag) ? 1 : force_quit_count + 1; |
| 10450 | then quit right away. */ | 10420 | force_quit_count = count; |
| 10451 | if (immediate_quit && NILP (Vinhibit_quit)) | 10421 | if (count == 3) |
| 10452 | { | 10422 | Vinhibit_quit = Qnil; |
| 10453 | struct gl_state_s saved; | 10423 | Vquit_flag = Qt; |
| 10454 | |||
| 10455 | immediate_quit = false; | ||
| 10456 | pthread_sigmask (SIG_SETMASK, &empty_mask, 0); | ||
| 10457 | saved = gl_state; | ||
| 10458 | quit (); | ||
| 10459 | gl_state = saved; | ||
| 10460 | } | ||
| 10461 | else | ||
| 10462 | { /* Else request quit when it's safe. */ | ||
| 10463 | int count = NILP (Vquit_flag) ? 1 : force_quit_count + 1; | ||
| 10464 | force_quit_count = count; | ||
| 10465 | if (count == 3) | ||
| 10466 | { | ||
| 10467 | immediate_quit = true; | ||
| 10468 | Vinhibit_quit = Qnil; | ||
| 10469 | } | ||
| 10470 | Vquit_flag = Qt; | ||
| 10471 | } | ||
| 10472 | } | 10424 | } |
| 10473 | 10425 | ||
| 10474 | pthread_sigmask (SIG_SETMASK, &empty_mask, 0); | 10426 | pthread_sigmask (SIG_SETMASK, &empty_mask, 0); |
| @@ -10907,7 +10859,6 @@ init_keyboard (void) | |||
| 10907 | { | 10859 | { |
| 10908 | /* This is correct before outermost invocation of the editor loop. */ | 10860 | /* This is correct before outermost invocation of the editor loop. */ |
| 10909 | command_loop_level = -1; | 10861 | command_loop_level = -1; |
| 10910 | immediate_quit = false; | ||
| 10911 | quit_char = Ctl ('g'); | 10862 | quit_char = Ctl ('g'); |
| 10912 | Vunread_command_events = Qnil; | 10863 | Vunread_command_events = Qnil; |
| 10913 | timer_idleness_start_time = invalid_timespec (); | 10864 | timer_idleness_start_time = invalid_timespec (); |
diff --git a/src/lisp.h b/src/lisp.h index 91c430fe98d..a9011b4a8be 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -1995,8 +1995,8 @@ struct Lisp_Hash_Table | |||
| 1995 | hash table size to reduce collisions. */ | 1995 | hash table size to reduce collisions. */ |
| 1996 | Lisp_Object index; | 1996 | Lisp_Object index; |
| 1997 | 1997 | ||
| 1998 | /* Non-nil if the table can be purecopied. Any changes the table after | 1998 | /* Non-nil if the table can be purecopied. The table cannot be |
| 1999 | purecopy will result in an error. */ | 1999 | changed afterwards. */ |
| 2000 | Lisp_Object pure; | 2000 | Lisp_Object pure; |
| 2001 | 2001 | ||
| 2002 | /* Only the fields above are traced normally by the GC. The ones below | 2002 | /* Only the fields above are traced normally by the GC. The ones below |
| @@ -3123,29 +3123,28 @@ struct handler | |||
| 3123 | 3123 | ||
| 3124 | extern Lisp_Object memory_signal_data; | 3124 | extern Lisp_Object memory_signal_data; |
| 3125 | 3125 | ||
| 3126 | /* Check quit-flag and quit if it is non-nil. Typing C-g does not | 3126 | extern void maybe_quit (void); |
| 3127 | directly cause a quit; it only sets Vquit_flag. So the program | ||
| 3128 | needs to call maybe_quit at times when it is safe to quit. Every | ||
| 3129 | loop that might run for a long time or might not exit ought to call | ||
| 3130 | maybe_quit at least once, at a safe place. Unless that is | ||
| 3131 | impossible, of course. But it is very desirable to avoid creating | ||
| 3132 | loops where maybe_quit is impossible. | ||
| 3133 | 3127 | ||
| 3134 | Exception: if you set immediate_quit, the handler that responds to | 3128 | /* True if ought to quit now. */ |
| 3135 | the C-g does the quit itself. This is a good thing to do around a | ||
| 3136 | loop that has no side effects and (in particular) cannot call | ||
| 3137 | arbitrary Lisp code. | ||
| 3138 | 3129 | ||
| 3139 | If quit-flag is set to `kill-emacs' the SIGINT handler has received | 3130 | #define QUITP (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) |
| 3140 | a request to exit Emacs when it is safe to do. | ||
| 3141 | 3131 | ||
| 3142 | When not quitting, process any pending signals. */ | 3132 | /* Heuristic on how many iterations of a tight loop can be safely done |
| 3133 | before it's time to do a quit. This must be a power of 2. It | ||
| 3134 | is nice but not necessary for it to equal USHRT_MAX + 1. */ | ||
| 3143 | 3135 | ||
| 3144 | extern void maybe_quit (void); | 3136 | enum { QUIT_COUNT_HEURISTIC = 1 << 16 }; |
| 3145 | 3137 | ||
| 3146 | /* True if ought to quit now. */ | 3138 | /* Process a quit rarely, based on a counter COUNT, for efficiency. |
| 3139 | "Rarely" means once per QUIT_COUNT_HEURISTIC or per USHRT_MAX + 1 | ||
| 3140 | times, whichever is smaller (somewhat arbitrary, but often faster). */ | ||
| 3147 | 3141 | ||
| 3148 | #define QUITP (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) | 3142 | INLINE void |
| 3143 | rarely_quit (unsigned short int count) | ||
| 3144 | { | ||
| 3145 | if (! (count & (QUIT_COUNT_HEURISTIC - 1))) | ||
| 3146 | maybe_quit (); | ||
| 3147 | } | ||
| 3149 | 3148 | ||
| 3150 | extern Lisp_Object Vascii_downcase_table; | 3149 | extern Lisp_Object Vascii_downcase_table; |
| 3151 | extern Lisp_Object Vascii_canon_table; | 3150 | extern Lisp_Object Vascii_canon_table; |
| @@ -4221,8 +4220,10 @@ extern int emacs_open (const char *, int, int); | |||
| 4221 | extern int emacs_pipe (int[2]); | 4220 | extern int emacs_pipe (int[2]); |
| 4222 | extern int emacs_close (int); | 4221 | extern int emacs_close (int); |
| 4223 | extern ptrdiff_t emacs_read (int, void *, ptrdiff_t); | 4222 | extern ptrdiff_t emacs_read (int, void *, ptrdiff_t); |
| 4223 | extern ptrdiff_t emacs_read_quit (int, void *, ptrdiff_t); | ||
| 4224 | extern ptrdiff_t emacs_write (int, void const *, ptrdiff_t); | 4224 | extern ptrdiff_t emacs_write (int, void const *, ptrdiff_t); |
| 4225 | extern ptrdiff_t emacs_write_sig (int, void const *, ptrdiff_t); | 4225 | extern ptrdiff_t emacs_write_sig (int, void const *, ptrdiff_t); |
| 4226 | extern ptrdiff_t emacs_write_quit (int, void const *, ptrdiff_t); | ||
| 4226 | extern void emacs_perror (char const *); | 4227 | extern void emacs_perror (char const *); |
| 4227 | 4228 | ||
| 4228 | extern void unlock_all_files (void); | 4229 | extern void unlock_all_files (void); |
| @@ -4348,9 +4349,6 @@ extern char my_edata[]; | |||
| 4348 | extern char my_endbss[]; | 4349 | extern char my_endbss[]; |
| 4349 | extern char *my_endbss_static; | 4350 | extern char *my_endbss_static; |
| 4350 | 4351 | ||
| 4351 | /* True means ^G can quit instantly. */ | ||
| 4352 | extern bool immediate_quit; | ||
| 4353 | |||
| 4354 | extern void *xmalloc (size_t) ATTRIBUTE_MALLOC_SIZE ((1)); | 4352 | extern void *xmalloc (size_t) ATTRIBUTE_MALLOC_SIZE ((1)); |
| 4355 | extern void *xzalloc (size_t) ATTRIBUTE_MALLOC_SIZE ((1)); | 4353 | extern void *xzalloc (size_t) ATTRIBUTE_MALLOC_SIZE ((1)); |
| 4356 | extern void *xrealloc (void *, size_t) ATTRIBUTE_ALLOC_SIZE ((2)); | 4354 | extern void *xrealloc (void *, size_t) ATTRIBUTE_ALLOC_SIZE ((2)); |
| @@ -4537,7 +4535,7 @@ enum | |||
| 4537 | use these only in macros like AUTO_CONS that declare a local | 4535 | use these only in macros like AUTO_CONS that declare a local |
| 4538 | variable whose lifetime will be clear to the programmer. */ | 4536 | variable whose lifetime will be clear to the programmer. */ |
| 4539 | #define STACK_CONS(a, b) \ | 4537 | #define STACK_CONS(a, b) \ |
| 4540 | make_lisp_ptr (&(union Aligned_Cons) { { a, { b } } }.s, Lisp_Cons) | 4538 | make_lisp_ptr (&((union Aligned_Cons) { { a, { b } } }).s, Lisp_Cons) |
| 4541 | #define AUTO_CONS_EXPR(a, b) \ | 4539 | #define AUTO_CONS_EXPR(a, b) \ |
| 4542 | (USE_STACK_CONS ? STACK_CONS (a, b) : Fcons (a, b)) | 4540 | (USE_STACK_CONS ? STACK_CONS (a, b) : Fcons (a, b)) |
| 4543 | 4541 | ||
| @@ -4583,8 +4581,7 @@ enum | |||
| 4583 | Lisp_Object name = \ | 4581 | Lisp_Object name = \ |
| 4584 | (USE_STACK_STRING \ | 4582 | (USE_STACK_STRING \ |
| 4585 | ? (make_lisp_ptr \ | 4583 | ? (make_lisp_ptr \ |
| 4586 | ((&(union Aligned_String) \ | 4584 | ((&((union Aligned_String) {{len, -1, 0, (unsigned char *) (str)}}).s), \ |
| 4587 | {{len, -1, 0, (unsigned char *) (str)}}.s), \ | ||
| 4588 | Lisp_String)) \ | 4585 | Lisp_String)) \ |
| 4589 | : make_unibyte_string (str, len)) | 4586 | : make_unibyte_string (str, len)) |
| 4590 | 4587 | ||
diff --git a/src/lread.c b/src/lread.c index 17806922a8c..094aa628eec 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -910,7 +910,7 @@ safe_to_load_version (int fd) | |||
| 910 | 910 | ||
| 911 | /* Read the first few bytes from the file, and look for a line | 911 | /* Read the first few bytes from the file, and look for a line |
| 912 | specifying the byte compiler version used. */ | 912 | specifying the byte compiler version used. */ |
| 913 | nbytes = emacs_read (fd, buf, sizeof buf); | 913 | nbytes = emacs_read_quit (fd, buf, sizeof buf); |
| 914 | if (nbytes > 0) | 914 | if (nbytes > 0) |
| 915 | { | 915 | { |
| 916 | /* Skip to the next newline, skipping over the initial `ELC' | 916 | /* Skip to the next newline, skipping over the initial `ELC' |
diff --git a/src/process.c b/src/process.c index dbd4358dd1a..434a3955b2c 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -3431,7 +3431,6 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, | |||
| 3431 | break; | 3431 | break; |
| 3432 | } | 3432 | } |
| 3433 | 3433 | ||
| 3434 | immediate_quit = true; | ||
| 3435 | maybe_quit (); | 3434 | maybe_quit (); |
| 3436 | 3435 | ||
| 3437 | ret = connect (s, sa, addrlen); | 3436 | ret = connect (s, sa, addrlen); |
| @@ -3439,8 +3438,7 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, | |||
| 3439 | 3438 | ||
| 3440 | if (ret == 0 || xerrno == EISCONN) | 3439 | if (ret == 0 || xerrno == EISCONN) |
| 3441 | { | 3440 | { |
| 3442 | /* The unwind-protect will be discarded afterwards. | 3441 | /* The unwind-protect will be discarded afterwards. */ |
| 3443 | Likewise for immediate_quit. */ | ||
| 3444 | break; | 3442 | break; |
| 3445 | } | 3443 | } |
| 3446 | 3444 | ||
| @@ -3481,8 +3479,6 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, | |||
| 3481 | } | 3479 | } |
| 3482 | #endif /* !WINDOWSNT */ | 3480 | #endif /* !WINDOWSNT */ |
| 3483 | 3481 | ||
| 3484 | immediate_quit = false; | ||
| 3485 | |||
| 3486 | /* Discard the unwind protect closing S. */ | 3482 | /* Discard the unwind protect closing S. */ |
| 3487 | specpdl_ptr = specpdl + count; | 3483 | specpdl_ptr = specpdl + count; |
| 3488 | emacs_close (s); | 3484 | emacs_close (s); |
| @@ -3539,8 +3535,6 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, | |||
| 3539 | #endif | 3535 | #endif |
| 3540 | } | 3536 | } |
| 3541 | 3537 | ||
| 3542 | immediate_quit = false; | ||
| 3543 | |||
| 3544 | if (s < 0) | 3538 | if (s < 0) |
| 3545 | { | 3539 | { |
| 3546 | /* If non-blocking got this far - and failed - assume non-blocking is | 3540 | /* If non-blocking got this far - and failed - assume non-blocking is |
| @@ -4012,7 +4006,6 @@ usage: (make-network-process &rest ARGS) */) | |||
| 4012 | struct addrinfo *res, *lres; | 4006 | struct addrinfo *res, *lres; |
| 4013 | int ret; | 4007 | int ret; |
| 4014 | 4008 | ||
| 4015 | immediate_quit = true; | ||
| 4016 | maybe_quit (); | 4009 | maybe_quit (); |
| 4017 | 4010 | ||
| 4018 | struct addrinfo hints; | 4011 | struct addrinfo hints; |
| @@ -4034,7 +4027,6 @@ usage: (make-network-process &rest ARGS) */) | |||
| 4034 | #else | 4027 | #else |
| 4035 | error ("%s/%s getaddrinfo error %d", SSDATA (host), portstring, ret); | 4028 | error ("%s/%s getaddrinfo error %d", SSDATA (host), portstring, ret); |
| 4036 | #endif | 4029 | #endif |
| 4037 | immediate_quit = false; | ||
| 4038 | 4030 | ||
| 4039 | for (lres = res; lres; lres = lres->ai_next) | 4031 | for (lres = res; lres; lres = lres->ai_next) |
| 4040 | addrinfos = Fcons (conv_addrinfo_to_lisp (lres), addrinfos); | 4032 | addrinfos = Fcons (conv_addrinfo_to_lisp (lres), addrinfos); |
diff --git a/src/regex.c b/src/regex.c index f6e67afef4c..796f868d1c2 100644 --- a/src/regex.c +++ b/src/regex.c | |||
| @@ -1728,10 +1728,8 @@ typedef struct | |||
| 1728 | 1728 | ||
| 1729 | /* Explicit quit checking is needed for Emacs, which uses polling to | 1729 | /* Explicit quit checking is needed for Emacs, which uses polling to |
| 1730 | process input events. */ | 1730 | process input events. */ |
| 1731 | #ifdef emacs | 1731 | #ifndef emacs |
| 1732 | # define IMMEDIATE_QUIT_CHECK (immediate_quit ? maybe_quit () : (void) 0) | 1732 | static void maybe_quit (void) {} |
| 1733 | #else | ||
| 1734 | # define IMMEDIATE_QUIT_CHECK ((void) 0) | ||
| 1735 | #endif | 1733 | #endif |
| 1736 | 1734 | ||
| 1737 | /* Structure to manage work area for range table. */ | 1735 | /* Structure to manage work area for range table. */ |
| @@ -5820,7 +5818,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const_re_char *string1, | |||
| 5820 | /* Unconditionally jump (without popping any failure points). */ | 5818 | /* Unconditionally jump (without popping any failure points). */ |
| 5821 | case jump: | 5819 | case jump: |
| 5822 | unconditional_jump: | 5820 | unconditional_jump: |
| 5823 | IMMEDIATE_QUIT_CHECK; | 5821 | maybe_quit (); |
| 5824 | EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ | 5822 | EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ |
| 5825 | DEBUG_PRINT ("EXECUTING jump %d ", mcnt); | 5823 | DEBUG_PRINT ("EXECUTING jump %d ", mcnt); |
| 5826 | p += mcnt; /* Do the jump. */ | 5824 | p += mcnt; /* Do the jump. */ |
| @@ -6168,7 +6166,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const_re_char *string1, | |||
| 6168 | 6166 | ||
| 6169 | /* We goto here if a matching operation fails. */ | 6167 | /* We goto here if a matching operation fails. */ |
| 6170 | fail: | 6168 | fail: |
| 6171 | IMMEDIATE_QUIT_CHECK; | 6169 | maybe_quit (); |
| 6172 | if (!FAIL_STACK_EMPTY ()) | 6170 | if (!FAIL_STACK_EMPTY ()) |
| 6173 | { | 6171 | { |
| 6174 | re_char *str, *pat; | 6172 | re_char *str, *pat; |
diff --git a/src/search.c b/src/search.c index f54f44c8818..33cb02aa7af 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -99,6 +99,25 @@ matcher_overflow (void) | |||
| 99 | error ("Stack overflow in regexp matcher"); | 99 | error ("Stack overflow in regexp matcher"); |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | static void | ||
| 103 | freeze_buffer_relocation (void) | ||
| 104 | { | ||
| 105 | #ifdef REL_ALLOC | ||
| 106 | /* Prevent ralloc.c from relocating the current buffer while | ||
| 107 | searching it. */ | ||
| 108 | r_alloc_inhibit_buffer_relocation (1); | ||
| 109 | record_unwind_protect_int (r_alloc_inhibit_buffer_relocation, 0); | ||
| 110 | #endif | ||
| 111 | } | ||
| 112 | |||
| 113 | static void | ||
| 114 | thaw_buffer_relocation (void) | ||
| 115 | { | ||
| 116 | #ifdef REL_ALLOC | ||
| 117 | unbind_to (SPECPDL_INDEX () - 1, Qnil); | ||
| 118 | #endif | ||
| 119 | } | ||
| 120 | |||
| 102 | /* Compile a regexp and signal a Lisp error if anything goes wrong. | 121 | /* Compile a regexp and signal a Lisp error if anything goes wrong. |
| 103 | PATTERN is the pattern to compile. | 122 | PATTERN is the pattern to compile. |
| 104 | CP is the place to put the result. | 123 | CP is the place to put the result. |
| @@ -277,7 +296,6 @@ looking_at_1 (Lisp_Object string, bool posix) | |||
| 277 | !NILP (BVAR (current_buffer, enable_multibyte_characters))); | 296 | !NILP (BVAR (current_buffer, enable_multibyte_characters))); |
| 278 | 297 | ||
| 279 | /* Do a pending quit right away, to avoid paradoxical behavior */ | 298 | /* Do a pending quit right away, to avoid paradoxical behavior */ |
| 280 | immediate_quit = true; | ||
| 281 | maybe_quit (); | 299 | maybe_quit (); |
| 282 | 300 | ||
| 283 | /* Get pointers and sizes of the two strings | 301 | /* Get pointers and sizes of the two strings |
| @@ -301,20 +319,13 @@ looking_at_1 (Lisp_Object string, bool posix) | |||
| 301 | 319 | ||
| 302 | re_match_object = Qnil; | 320 | re_match_object = Qnil; |
| 303 | 321 | ||
| 304 | #ifdef REL_ALLOC | 322 | freeze_buffer_relocation (); |
| 305 | /* Prevent ralloc.c from relocating the current buffer while | ||
| 306 | searching it. */ | ||
| 307 | r_alloc_inhibit_buffer_relocation (1); | ||
| 308 | #endif | ||
| 309 | i = re_match_2 (bufp, (char *) p1, s1, (char *) p2, s2, | 323 | i = re_match_2 (bufp, (char *) p1, s1, (char *) p2, s2, |
| 310 | PT_BYTE - BEGV_BYTE, | 324 | PT_BYTE - BEGV_BYTE, |
| 311 | (NILP (Vinhibit_changing_match_data) | 325 | (NILP (Vinhibit_changing_match_data) |
| 312 | ? &search_regs : NULL), | 326 | ? &search_regs : NULL), |
| 313 | ZV_BYTE - BEGV_BYTE); | 327 | ZV_BYTE - BEGV_BYTE); |
| 314 | immediate_quit = false; | 328 | thaw_buffer_relocation (); |
| 315 | #ifdef REL_ALLOC | ||
| 316 | r_alloc_inhibit_buffer_relocation (0); | ||
| 317 | #endif | ||
| 318 | 329 | ||
| 319 | if (i == -2) | 330 | if (i == -2) |
| 320 | matcher_overflow (); | 331 | matcher_overflow (); |
| @@ -399,7 +410,6 @@ string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start, | |||
| 399 | ? BVAR (current_buffer, case_canon_table) : Qnil), | 410 | ? BVAR (current_buffer, case_canon_table) : Qnil), |
| 400 | posix, | 411 | posix, |
| 401 | STRING_MULTIBYTE (string)); | 412 | STRING_MULTIBYTE (string)); |
| 402 | immediate_quit = true; | ||
| 403 | re_match_object = string; | 413 | re_match_object = string; |
| 404 | 414 | ||
| 405 | val = re_search (bufp, SSDATA (string), | 415 | val = re_search (bufp, SSDATA (string), |
| @@ -407,7 +417,6 @@ string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start, | |||
| 407 | SBYTES (string) - pos_byte, | 417 | SBYTES (string) - pos_byte, |
| 408 | (NILP (Vinhibit_changing_match_data) | 418 | (NILP (Vinhibit_changing_match_data) |
| 409 | ? &search_regs : NULL)); | 419 | ? &search_regs : NULL)); |
| 410 | immediate_quit = false; | ||
| 411 | 420 | ||
| 412 | /* Set last_thing_searched only when match data is changed. */ | 421 | /* Set last_thing_searched only when match data is changed. */ |
| 413 | if (NILP (Vinhibit_changing_match_data)) | 422 | if (NILP (Vinhibit_changing_match_data)) |
| @@ -471,13 +480,11 @@ fast_string_match_internal (Lisp_Object regexp, Lisp_Object string, | |||
| 471 | 480 | ||
| 472 | bufp = compile_pattern (regexp, 0, table, | 481 | bufp = compile_pattern (regexp, 0, table, |
| 473 | 0, STRING_MULTIBYTE (string)); | 482 | 0, STRING_MULTIBYTE (string)); |
| 474 | immediate_quit = true; | ||
| 475 | re_match_object = string; | 483 | re_match_object = string; |
| 476 | 484 | ||
| 477 | val = re_search (bufp, SSDATA (string), | 485 | val = re_search (bufp, SSDATA (string), |
| 478 | SBYTES (string), 0, | 486 | SBYTES (string), 0, |
| 479 | SBYTES (string), 0); | 487 | SBYTES (string), 0); |
| 480 | immediate_quit = false; | ||
| 481 | return val; | 488 | return val; |
| 482 | } | 489 | } |
| 483 | 490 | ||
| @@ -498,9 +505,7 @@ fast_c_string_match_ignore_case (Lisp_Object regexp, | |||
| 498 | bufp = compile_pattern (regexp, 0, | 505 | bufp = compile_pattern (regexp, 0, |
| 499 | Vascii_canon_table, 0, | 506 | Vascii_canon_table, 0, |
| 500 | 0); | 507 | 0); |
| 501 | immediate_quit = true; | ||
| 502 | val = re_search (bufp, string, len, 0, len, 0); | 508 | val = re_search (bufp, string, len, 0, len, 0); |
| 503 | immediate_quit = false; | ||
| 504 | return val; | 509 | return val; |
| 505 | } | 510 | } |
| 506 | 511 | ||
| @@ -561,18 +566,10 @@ fast_looking_at (Lisp_Object regexp, ptrdiff_t pos, ptrdiff_t pos_byte, | |||
| 561 | } | 566 | } |
| 562 | 567 | ||
| 563 | buf = compile_pattern (regexp, 0, Qnil, 0, multibyte); | 568 | buf = compile_pattern (regexp, 0, Qnil, 0, multibyte); |
| 564 | immediate_quit = true; | 569 | freeze_buffer_relocation (); |
| 565 | #ifdef REL_ALLOC | ||
| 566 | /* Prevent ralloc.c from relocating the current buffer while | ||
| 567 | searching it. */ | ||
| 568 | r_alloc_inhibit_buffer_relocation (1); | ||
| 569 | #endif | ||
| 570 | len = re_match_2 (buf, (char *) p1, s1, (char *) p2, s2, | 570 | len = re_match_2 (buf, (char *) p1, s1, (char *) p2, s2, |
| 571 | pos_byte, NULL, limit_byte); | 571 | pos_byte, NULL, limit_byte); |
| 572 | #ifdef REL_ALLOC | 572 | thaw_buffer_relocation (); |
| 573 | r_alloc_inhibit_buffer_relocation (0); | ||
| 574 | #endif | ||
| 575 | immediate_quit = false; | ||
| 576 | 573 | ||
| 577 | return len; | 574 | return len; |
| 578 | } | 575 | } |
| @@ -649,7 +646,7 @@ newline_cache_on_off (struct buffer *buf) | |||
| 649 | If BYTEPOS is not NULL, set *BYTEPOS to the byte position corresponding | 646 | If BYTEPOS is not NULL, set *BYTEPOS to the byte position corresponding |
| 650 | to the returned character position. | 647 | to the returned character position. |
| 651 | 648 | ||
| 652 | If ALLOW_QUIT, set immediate_quit. That's good to do | 649 | If ALLOW_QUIT, check for quitting. That's good to do |
| 653 | except when inside redisplay. */ | 650 | except when inside redisplay. */ |
| 654 | 651 | ||
| 655 | ptrdiff_t | 652 | ptrdiff_t |
| @@ -685,8 +682,6 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end, | |||
| 685 | if (shortage != 0) | 682 | if (shortage != 0) |
| 686 | *shortage = 0; | 683 | *shortage = 0; |
| 687 | 684 | ||
| 688 | immediate_quit = allow_quit; | ||
| 689 | |||
| 690 | if (count > 0) | 685 | if (count > 0) |
| 691 | while (start != end) | 686 | while (start != end) |
| 692 | { | 687 | { |
| @@ -704,7 +699,6 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end, | |||
| 704 | ptrdiff_t next_change; | 699 | ptrdiff_t next_change; |
| 705 | int result = 1; | 700 | int result = 1; |
| 706 | 701 | ||
| 707 | immediate_quit = false; | ||
| 708 | while (start < end && result) | 702 | while (start < end && result) |
| 709 | { | 703 | { |
| 710 | ptrdiff_t lim1; | 704 | ptrdiff_t lim1; |
| @@ -757,7 +751,6 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end, | |||
| 757 | start_byte = end_byte; | 751 | start_byte = end_byte; |
| 758 | break; | 752 | break; |
| 759 | } | 753 | } |
| 760 | immediate_quit = allow_quit; | ||
| 761 | 754 | ||
| 762 | /* START should never be after END. */ | 755 | /* START should never be after END. */ |
| 763 | if (start_byte > ceiling_byte) | 756 | if (start_byte > ceiling_byte) |
| @@ -810,11 +803,12 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end, | |||
| 810 | 803 | ||
| 811 | if (--count == 0) | 804 | if (--count == 0) |
| 812 | { | 805 | { |
| 813 | immediate_quit = false; | ||
| 814 | if (bytepos) | 806 | if (bytepos) |
| 815 | *bytepos = lim_byte + next; | 807 | *bytepos = lim_byte + next; |
| 816 | return BYTE_TO_CHAR (lim_byte + next); | 808 | return BYTE_TO_CHAR (lim_byte + next); |
| 817 | } | 809 | } |
| 810 | if (allow_quit) | ||
| 811 | maybe_quit (); | ||
| 818 | } | 812 | } |
| 819 | 813 | ||
| 820 | start_byte = lim_byte; | 814 | start_byte = lim_byte; |
| @@ -833,7 +827,6 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end, | |||
| 833 | ptrdiff_t next_change; | 827 | ptrdiff_t next_change; |
| 834 | int result = 1; | 828 | int result = 1; |
| 835 | 829 | ||
| 836 | immediate_quit = false; | ||
| 837 | while (start > end && result) | 830 | while (start > end && result) |
| 838 | { | 831 | { |
| 839 | ptrdiff_t lim1; | 832 | ptrdiff_t lim1; |
| @@ -870,7 +863,6 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end, | |||
| 870 | start_byte = end_byte; | 863 | start_byte = end_byte; |
| 871 | break; | 864 | break; |
| 872 | } | 865 | } |
| 873 | immediate_quit = allow_quit; | ||
| 874 | 866 | ||
| 875 | /* Start should never be at or before end. */ | 867 | /* Start should never be at or before end. */ |
| 876 | if (start_byte <= ceiling_byte) | 868 | if (start_byte <= ceiling_byte) |
| @@ -918,11 +910,12 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end, | |||
| 918 | 910 | ||
| 919 | if (++count >= 0) | 911 | if (++count >= 0) |
| 920 | { | 912 | { |
| 921 | immediate_quit = false; | ||
| 922 | if (bytepos) | 913 | if (bytepos) |
| 923 | *bytepos = ceiling_byte + prev + 1; | 914 | *bytepos = ceiling_byte + prev + 1; |
| 924 | return BYTE_TO_CHAR (ceiling_byte + prev + 1); | 915 | return BYTE_TO_CHAR (ceiling_byte + prev + 1); |
| 925 | } | 916 | } |
| 917 | if (allow_quit) | ||
| 918 | maybe_quit (); | ||
| 926 | } | 919 | } |
| 927 | 920 | ||
| 928 | start_byte = ceiling_byte; | 921 | start_byte = ceiling_byte; |
| @@ -930,7 +923,6 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end, | |||
| 930 | } | 923 | } |
| 931 | } | 924 | } |
| 932 | 925 | ||
| 933 | immediate_quit = false; | ||
| 934 | if (shortage) | 926 | if (shortage) |
| 935 | *shortage = count * direction; | 927 | *shortage = count * direction; |
| 936 | if (bytepos) | 928 | if (bytepos) |
| @@ -954,7 +946,7 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end, | |||
| 954 | the number of line boundaries left unfound, and position at | 946 | the number of line boundaries left unfound, and position at |
| 955 | the limit we bumped up against. | 947 | the limit we bumped up against. |
| 956 | 948 | ||
| 957 | If ALLOW_QUIT, set immediate_quit. That's good to do | 949 | If ALLOW_QUIT, check for quitting. That's good to do |
| 958 | except in special cases. */ | 950 | except in special cases. */ |
| 959 | 951 | ||
| 960 | ptrdiff_t | 952 | ptrdiff_t |
| @@ -1197,9 +1189,6 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, | |||
| 1197 | trt, posix, | 1189 | trt, posix, |
| 1198 | !NILP (BVAR (current_buffer, enable_multibyte_characters))); | 1190 | !NILP (BVAR (current_buffer, enable_multibyte_characters))); |
| 1199 | 1191 | ||
| 1200 | immediate_quit = true; /* Quit immediately if user types ^G, | ||
| 1201 | because letting this function finish | ||
| 1202 | can take too long. */ | ||
| 1203 | maybe_quit (); /* Do a pending quit right away, | 1192 | maybe_quit (); /* Do a pending quit right away, |
| 1204 | to avoid paradoxical behavior */ | 1193 | to avoid paradoxical behavior */ |
| 1205 | /* Get pointers and sizes of the two strings | 1194 | /* Get pointers and sizes of the two strings |
| @@ -1222,11 +1211,7 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, | |||
| 1222 | } | 1211 | } |
| 1223 | re_match_object = Qnil; | 1212 | re_match_object = Qnil; |
| 1224 | 1213 | ||
| 1225 | #ifdef REL_ALLOC | 1214 | freeze_buffer_relocation (); |
| 1226 | /* Prevent ralloc.c from relocating the current buffer while | ||
| 1227 | searching it. */ | ||
| 1228 | r_alloc_inhibit_buffer_relocation (1); | ||
| 1229 | #endif | ||
| 1230 | 1215 | ||
| 1231 | while (n < 0) | 1216 | while (n < 0) |
| 1232 | { | 1217 | { |
| @@ -1268,13 +1253,11 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, | |||
| 1268 | } | 1253 | } |
| 1269 | else | 1254 | else |
| 1270 | { | 1255 | { |
| 1271 | immediate_quit = false; | 1256 | thaw_buffer_relocation (); |
| 1272 | #ifdef REL_ALLOC | ||
| 1273 | r_alloc_inhibit_buffer_relocation (0); | ||
| 1274 | #endif | ||
| 1275 | return (n); | 1257 | return (n); |
| 1276 | } | 1258 | } |
| 1277 | n++; | 1259 | n++; |
| 1260 | maybe_quit (); | ||
| 1278 | } | 1261 | } |
| 1279 | while (n > 0) | 1262 | while (n > 0) |
| 1280 | { | 1263 | { |
| @@ -1313,18 +1296,13 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, | |||
| 1313 | } | 1296 | } |
| 1314 | else | 1297 | else |
| 1315 | { | 1298 | { |
| 1316 | immediate_quit = false; | 1299 | thaw_buffer_relocation (); |
| 1317 | #ifdef REL_ALLOC | ||
| 1318 | r_alloc_inhibit_buffer_relocation (0); | ||
| 1319 | #endif | ||
| 1320 | return (0 - n); | 1300 | return (0 - n); |
| 1321 | } | 1301 | } |
| 1322 | n--; | 1302 | n--; |
| 1303 | maybe_quit (); | ||
| 1323 | } | 1304 | } |
| 1324 | immediate_quit = false; | 1305 | thaw_buffer_relocation (); |
| 1325 | #ifdef REL_ALLOC | ||
| 1326 | r_alloc_inhibit_buffer_relocation (0); | ||
| 1327 | #endif | ||
| 1328 | return (pos); | 1306 | return (pos); |
| 1329 | } | 1307 | } |
| 1330 | else /* non-RE case */ | 1308 | else /* non-RE case */ |
| @@ -3231,8 +3209,6 @@ find_newline1 (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end, | |||
| 3231 | if (shortage != 0) | 3209 | if (shortage != 0) |
| 3232 | *shortage = 0; | 3210 | *shortage = 0; |
| 3233 | 3211 | ||
| 3234 | immediate_quit = allow_quit; | ||
| 3235 | |||
| 3236 | if (count > 0) | 3212 | if (count > 0) |
| 3237 | while (start != end) | 3213 | while (start != end) |
| 3238 | { | 3214 | { |
| @@ -3275,11 +3251,12 @@ find_newline1 (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end, | |||
| 3275 | 3251 | ||
| 3276 | if (--count == 0) | 3252 | if (--count == 0) |
| 3277 | { | 3253 | { |
| 3278 | immediate_quit = false; | ||
| 3279 | if (bytepos) | 3254 | if (bytepos) |
| 3280 | *bytepos = lim_byte + next; | 3255 | *bytepos = lim_byte + next; |
| 3281 | return BYTE_TO_CHAR (lim_byte + next); | 3256 | return BYTE_TO_CHAR (lim_byte + next); |
| 3282 | } | 3257 | } |
| 3258 | if (allow_quit) | ||
| 3259 | maybe_quit (); | ||
| 3283 | } | 3260 | } |
| 3284 | 3261 | ||
| 3285 | start_byte = lim_byte; | 3262 | start_byte = lim_byte; |
| @@ -3287,7 +3264,6 @@ find_newline1 (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end, | |||
| 3287 | } | 3264 | } |
| 3288 | } | 3265 | } |
| 3289 | 3266 | ||
| 3290 | immediate_quit = false; | ||
| 3291 | if (shortage) | 3267 | if (shortage) |
| 3292 | *shortage = count; | 3268 | *shortage = count; |
| 3293 | if (bytepos) | 3269 | if (bytepos) |
diff --git a/src/syntax.c b/src/syntax.c index f9e4093765c..7aa43e6e5c7 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -621,11 +621,9 @@ find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte) | |||
| 621 | SETUP_BUFFER_SYNTAX_TABLE (); | 621 | SETUP_BUFFER_SYNTAX_TABLE (); |
| 622 | while (PT > BEGV) | 622 | while (PT > BEGV) |
| 623 | { | 623 | { |
| 624 | int c; | ||
| 625 | |||
| 626 | /* Open-paren at start of line means we may have found our | 624 | /* Open-paren at start of line means we may have found our |
| 627 | defun-start. */ | 625 | defun-start. */ |
| 628 | c = FETCH_CHAR_AS_MULTIBYTE (PT_BYTE); | 626 | int c = FETCH_CHAR_AS_MULTIBYTE (PT_BYTE); |
| 629 | if (SYNTAX (c) == Sopen) | 627 | if (SYNTAX (c) == Sopen) |
| 630 | { | 628 | { |
| 631 | SETUP_SYNTAX_TABLE (PT + 1, -1); /* Try again... */ | 629 | SETUP_SYNTAX_TABLE (PT + 1, -1); /* Try again... */ |
| @@ -715,6 +713,7 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, | |||
| 715 | ptrdiff_t nesting = 1; /* Current comment nesting. */ | 713 | ptrdiff_t nesting = 1; /* Current comment nesting. */ |
| 716 | int c; | 714 | int c; |
| 717 | int syntax = 0; | 715 | int syntax = 0; |
| 716 | unsigned short int quit_count = 0; | ||
| 718 | 717 | ||
| 719 | /* FIXME: A }} comment-ender style leads to incorrect behavior | 718 | /* FIXME: A }} comment-ender style leads to incorrect behavior |
| 720 | in the case of {{ c }}} because we ignore the last two chars which are | 719 | in the case of {{ c }}} because we ignore the last two chars which are |
| @@ -724,6 +723,8 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, | |||
| 724 | that determines quote parity to the comment-end. */ | 723 | that determines quote parity to the comment-end. */ |
| 725 | while (from != stop) | 724 | while (from != stop) |
| 726 | { | 725 | { |
| 726 | rarely_quit (++quit_count); | ||
| 727 | |||
| 727 | ptrdiff_t temp_byte; | 728 | ptrdiff_t temp_byte; |
| 728 | int prev_syntax; | 729 | int prev_syntax; |
| 729 | bool com2start, com2end, comstart; | 730 | bool com2start, com2end, comstart; |
| @@ -951,7 +952,9 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, | |||
| 951 | defun_start_byte = CHAR_TO_BYTE (defun_start); | 952 | defun_start_byte = CHAR_TO_BYTE (defun_start); |
| 952 | } | 953 | } |
| 953 | } | 954 | } |
| 954 | } while (defun_start < comment_end); | 955 | rarely_quit (++quit_count); |
| 956 | } | ||
| 957 | while (defun_start < comment_end); | ||
| 955 | 958 | ||
| 956 | from_byte = CHAR_TO_BYTE (from); | 959 | from_byte = CHAR_TO_BYTE (from); |
| 957 | UPDATE_SYNTAX_TABLE_FORWARD (from - 1); | 960 | UPDATE_SYNTAX_TABLE_FORWARD (from - 1); |
| @@ -1417,29 +1420,23 @@ DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value, | |||
| 1417 | COUNT negative means scan backward and stop at word beginning. */ | 1420 | COUNT negative means scan backward and stop at word beginning. */ |
| 1418 | 1421 | ||
| 1419 | ptrdiff_t | 1422 | ptrdiff_t |
| 1420 | scan_words (register ptrdiff_t from, register EMACS_INT count) | 1423 | scan_words (ptrdiff_t from, EMACS_INT count) |
| 1421 | { | 1424 | { |
| 1422 | register ptrdiff_t beg = BEGV; | 1425 | ptrdiff_t beg = BEGV; |
| 1423 | register ptrdiff_t end = ZV; | 1426 | ptrdiff_t end = ZV; |
| 1424 | register ptrdiff_t from_byte = CHAR_TO_BYTE (from); | 1427 | ptrdiff_t from_byte = CHAR_TO_BYTE (from); |
| 1425 | register enum syntaxcode code; | 1428 | enum syntaxcode code; |
| 1426 | int ch0, ch1; | 1429 | int ch0, ch1; |
| 1427 | Lisp_Object func, pos; | 1430 | Lisp_Object func, pos; |
| 1428 | 1431 | ||
| 1429 | immediate_quit = true; | ||
| 1430 | maybe_quit (); | ||
| 1431 | |||
| 1432 | SETUP_SYNTAX_TABLE (from, count); | 1432 | SETUP_SYNTAX_TABLE (from, count); |
| 1433 | 1433 | ||
| 1434 | while (count > 0) | 1434 | while (count > 0) |
| 1435 | { | 1435 | { |
| 1436 | while (1) | 1436 | while (true) |
| 1437 | { | 1437 | { |
| 1438 | if (from == end) | 1438 | if (from == end) |
| 1439 | { | 1439 | return 0; |
| 1440 | immediate_quit = false; | ||
| 1441 | return 0; | ||
| 1442 | } | ||
| 1443 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 1440 | UPDATE_SYNTAX_TABLE_FORWARD (from); |
| 1444 | ch0 = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 1441 | ch0 = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 1445 | code = SYNTAX (ch0); | 1442 | code = SYNTAX (ch0); |
| @@ -1449,6 +1446,7 @@ scan_words (register ptrdiff_t from, register EMACS_INT count) | |||
| 1449 | break; | 1446 | break; |
| 1450 | if (code == Sword) | 1447 | if (code == Sword) |
| 1451 | break; | 1448 | break; |
| 1449 | rarely_quit (from); | ||
| 1452 | } | 1450 | } |
| 1453 | /* Now CH0 is a character which begins a word and FROM is the | 1451 | /* Now CH0 is a character which begins a word and FROM is the |
| 1454 | position of the next character. */ | 1452 | position of the next character. */ |
| @@ -1477,19 +1475,17 @@ scan_words (register ptrdiff_t from, register EMACS_INT count) | |||
| 1477 | break; | 1475 | break; |
| 1478 | INC_BOTH (from, from_byte); | 1476 | INC_BOTH (from, from_byte); |
| 1479 | ch0 = ch1; | 1477 | ch0 = ch1; |
| 1478 | rarely_quit (from); | ||
| 1480 | } | 1479 | } |
| 1481 | } | 1480 | } |
| 1482 | count--; | 1481 | count--; |
| 1483 | } | 1482 | } |
| 1484 | while (count < 0) | 1483 | while (count < 0) |
| 1485 | { | 1484 | { |
| 1486 | while (1) | 1485 | while (true) |
| 1487 | { | 1486 | { |
| 1488 | if (from == beg) | 1487 | if (from == beg) |
| 1489 | { | 1488 | return 0; |
| 1490 | immediate_quit = false; | ||
| 1491 | return 0; | ||
| 1492 | } | ||
| 1493 | DEC_BOTH (from, from_byte); | 1489 | DEC_BOTH (from, from_byte); |
| 1494 | UPDATE_SYNTAX_TABLE_BACKWARD (from); | 1490 | UPDATE_SYNTAX_TABLE_BACKWARD (from); |
| 1495 | ch1 = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 1491 | ch1 = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| @@ -1499,6 +1495,7 @@ scan_words (register ptrdiff_t from, register EMACS_INT count) | |||
| 1499 | break; | 1495 | break; |
| 1500 | if (code == Sword) | 1496 | if (code == Sword) |
| 1501 | break; | 1497 | break; |
| 1498 | rarely_quit (from); | ||
| 1502 | } | 1499 | } |
| 1503 | /* Now CH1 is a character which ends a word and FROM is the | 1500 | /* Now CH1 is a character which ends a word and FROM is the |
| 1504 | position of it. */ | 1501 | position of it. */ |
| @@ -1531,13 +1528,12 @@ scan_words (register ptrdiff_t from, register EMACS_INT count) | |||
| 1531 | break; | 1528 | break; |
| 1532 | } | 1529 | } |
| 1533 | ch1 = ch0; | 1530 | ch1 = ch0; |
| 1531 | rarely_quit (from); | ||
| 1534 | } | 1532 | } |
| 1535 | } | 1533 | } |
| 1536 | count++; | 1534 | count++; |
| 1537 | } | 1535 | } |
| 1538 | 1536 | ||
| 1539 | immediate_quit = false; | ||
| 1540 | |||
| 1541 | return from; | 1537 | return from; |
| 1542 | } | 1538 | } |
| 1543 | 1539 | ||
| @@ -1921,7 +1917,6 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim, | |||
| 1921 | stop = (pos >= GPT && GPT > XINT (lim)) ? GAP_END_ADDR : endp; | 1917 | stop = (pos >= GPT && GPT > XINT (lim)) ? GAP_END_ADDR : endp; |
| 1922 | } | 1918 | } |
| 1923 | 1919 | ||
| 1924 | immediate_quit = true; | ||
| 1925 | /* This code may look up syntax tables using functions that rely on the | 1920 | /* This code may look up syntax tables using functions that rely on the |
| 1926 | gl_state object. To make sure this object is not out of date, | 1921 | gl_state object. To make sure this object is not out of date, |
| 1927 | let's initialize it manually. | 1922 | let's initialize it manually. |
| @@ -1971,9 +1966,10 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim, | |||
| 1971 | } | 1966 | } |
| 1972 | fwd_ok: | 1967 | fwd_ok: |
| 1973 | p += nbytes, pos++, pos_byte += nbytes; | 1968 | p += nbytes, pos++, pos_byte += nbytes; |
| 1969 | rarely_quit (pos); | ||
| 1974 | } | 1970 | } |
| 1975 | else | 1971 | else |
| 1976 | while (1) | 1972 | while (true) |
| 1977 | { | 1973 | { |
| 1978 | if (p >= stop) | 1974 | if (p >= stop) |
| 1979 | { | 1975 | { |
| @@ -1995,15 +1991,14 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim, | |||
| 1995 | break; | 1991 | break; |
| 1996 | fwd_unibyte_ok: | 1992 | fwd_unibyte_ok: |
| 1997 | p++, pos++, pos_byte++; | 1993 | p++, pos++, pos_byte++; |
| 1994 | rarely_quit (pos); | ||
| 1998 | } | 1995 | } |
| 1999 | } | 1996 | } |
| 2000 | else | 1997 | else |
| 2001 | { | 1998 | { |
| 2002 | if (multibyte) | 1999 | if (multibyte) |
| 2003 | while (1) | 2000 | while (true) |
| 2004 | { | 2001 | { |
| 2005 | unsigned char *prev_p; | ||
| 2006 | |||
| 2007 | if (p <= stop) | 2002 | if (p <= stop) |
| 2008 | { | 2003 | { |
| 2009 | if (p <= endp) | 2004 | if (p <= endp) |
| @@ -2011,8 +2006,11 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim, | |||
| 2011 | p = GPT_ADDR; | 2006 | p = GPT_ADDR; |
| 2012 | stop = endp; | 2007 | stop = endp; |
| 2013 | } | 2008 | } |
| 2014 | prev_p = p; | 2009 | unsigned char *prev_p = p; |
| 2015 | while (--p >= stop && ! CHAR_HEAD_P (*p)); | 2010 | do |
| 2011 | p--; | ||
| 2012 | while (stop <= p && ! CHAR_HEAD_P (*p)); | ||
| 2013 | |||
| 2016 | c = STRING_CHAR (p); | 2014 | c = STRING_CHAR (p); |
| 2017 | 2015 | ||
| 2018 | if (! NILP (iso_classes) && in_classes (c, iso_classes)) | 2016 | if (! NILP (iso_classes) && in_classes (c, iso_classes)) |
| @@ -2036,9 +2034,10 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim, | |||
| 2036 | } | 2034 | } |
| 2037 | back_ok: | 2035 | back_ok: |
| 2038 | pos--, pos_byte -= prev_p - p; | 2036 | pos--, pos_byte -= prev_p - p; |
| 2037 | rarely_quit (pos); | ||
| 2039 | } | 2038 | } |
| 2040 | else | 2039 | else |
| 2041 | while (1) | 2040 | while (true) |
| 2042 | { | 2041 | { |
| 2043 | if (p <= stop) | 2042 | if (p <= stop) |
| 2044 | { | 2043 | { |
| @@ -2060,11 +2059,11 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim, | |||
| 2060 | break; | 2059 | break; |
| 2061 | back_unibyte_ok: | 2060 | back_unibyte_ok: |
| 2062 | p--, pos--, pos_byte--; | 2061 | p--, pos--, pos_byte--; |
| 2062 | rarely_quit (pos); | ||
| 2063 | } | 2063 | } |
| 2064 | } | 2064 | } |
| 2065 | 2065 | ||
| 2066 | SET_PT_BOTH (pos, pos_byte); | 2066 | SET_PT_BOTH (pos, pos_byte); |
| 2067 | immediate_quit = false; | ||
| 2068 | 2067 | ||
| 2069 | SAFE_FREE (); | 2068 | SAFE_FREE (); |
| 2070 | return make_number (PT - start_point); | 2069 | return make_number (PT - start_point); |
| @@ -2138,7 +2137,6 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim) | |||
| 2138 | ptrdiff_t pos_byte = PT_BYTE; | 2137 | ptrdiff_t pos_byte = PT_BYTE; |
| 2139 | unsigned char *p, *endp, *stop; | 2138 | unsigned char *p, *endp, *stop; |
| 2140 | 2139 | ||
| 2141 | immediate_quit = true; | ||
| 2142 | SETUP_SYNTAX_TABLE (pos, forwardp ? 1 : -1); | 2140 | SETUP_SYNTAX_TABLE (pos, forwardp ? 1 : -1); |
| 2143 | 2141 | ||
| 2144 | if (forwardp) | 2142 | if (forwardp) |
| @@ -2167,6 +2165,7 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim) | |||
| 2167 | if (! fastmap[SYNTAX (c)]) | 2165 | if (! fastmap[SYNTAX (c)]) |
| 2168 | goto done; | 2166 | goto done; |
| 2169 | p += nbytes, pos++, pos_byte += nbytes; | 2167 | p += nbytes, pos++, pos_byte += nbytes; |
| 2168 | rarely_quit (pos); | ||
| 2170 | } | 2169 | } |
| 2171 | while (!parse_sexp_lookup_properties | 2170 | while (!parse_sexp_lookup_properties |
| 2172 | || pos < gl_state.e_property); | 2171 | || pos < gl_state.e_property); |
| @@ -2183,10 +2182,8 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim) | |||
| 2183 | 2182 | ||
| 2184 | if (multibyte) | 2183 | if (multibyte) |
| 2185 | { | 2184 | { |
| 2186 | while (1) | 2185 | while (true) |
| 2187 | { | 2186 | { |
| 2188 | unsigned char *prev_p; | ||
| 2189 | |||
| 2190 | if (p <= stop) | 2187 | if (p <= stop) |
| 2191 | { | 2188 | { |
| 2192 | if (p <= endp) | 2189 | if (p <= endp) |
| @@ -2195,17 +2192,22 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim) | |||
| 2195 | stop = endp; | 2192 | stop = endp; |
| 2196 | } | 2193 | } |
| 2197 | UPDATE_SYNTAX_TABLE_BACKWARD (pos - 1); | 2194 | UPDATE_SYNTAX_TABLE_BACKWARD (pos - 1); |
| 2198 | prev_p = p; | 2195 | |
| 2199 | while (--p >= stop && ! CHAR_HEAD_P (*p)); | 2196 | unsigned char *prev_p = p; |
| 2197 | do | ||
| 2198 | p--; | ||
| 2199 | while (stop <= p && ! CHAR_HEAD_P (*p)); | ||
| 2200 | |||
| 2200 | c = STRING_CHAR (p); | 2201 | c = STRING_CHAR (p); |
| 2201 | if (! fastmap[SYNTAX (c)]) | 2202 | if (! fastmap[SYNTAX (c)]) |
| 2202 | break; | 2203 | break; |
| 2203 | pos--, pos_byte -= prev_p - p; | 2204 | pos--, pos_byte -= prev_p - p; |
| 2205 | rarely_quit (pos); | ||
| 2204 | } | 2206 | } |
| 2205 | } | 2207 | } |
| 2206 | else | 2208 | else |
| 2207 | { | 2209 | { |
| 2208 | while (1) | 2210 | while (true) |
| 2209 | { | 2211 | { |
| 2210 | if (p <= stop) | 2212 | if (p <= stop) |
| 2211 | { | 2213 | { |
| @@ -2218,13 +2220,13 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim) | |||
| 2218 | if (! fastmap[SYNTAX (p[-1])]) | 2220 | if (! fastmap[SYNTAX (p[-1])]) |
| 2219 | break; | 2221 | break; |
| 2220 | p--, pos--, pos_byte--; | 2222 | p--, pos--, pos_byte--; |
| 2223 | rarely_quit (pos); | ||
| 2221 | } | 2224 | } |
| 2222 | } | 2225 | } |
| 2223 | } | 2226 | } |
| 2224 | 2227 | ||
| 2225 | done: | 2228 | done: |
| 2226 | SET_PT_BOTH (pos, pos_byte); | 2229 | SET_PT_BOTH (pos, pos_byte); |
| 2227 | immediate_quit = false; | ||
| 2228 | 2230 | ||
| 2229 | return make_number (PT - start_point); | 2231 | return make_number (PT - start_point); |
| 2230 | } | 2232 | } |
| @@ -2286,9 +2288,10 @@ forw_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, | |||
| 2286 | ptrdiff_t *charpos_ptr, ptrdiff_t *bytepos_ptr, | 2288 | ptrdiff_t *charpos_ptr, ptrdiff_t *bytepos_ptr, |
| 2287 | EMACS_INT *incomment_ptr, int *last_syntax_ptr) | 2289 | EMACS_INT *incomment_ptr, int *last_syntax_ptr) |
| 2288 | { | 2290 | { |
| 2289 | register int c, c1; | 2291 | unsigned short int quit_count = 0; |
| 2290 | register enum syntaxcode code; | 2292 | int c, c1; |
| 2291 | register int syntax, other_syntax; | 2293 | enum syntaxcode code; |
| 2294 | int syntax, other_syntax; | ||
| 2292 | 2295 | ||
| 2293 | if (nesting <= 0) nesting = -1; | 2296 | if (nesting <= 0) nesting = -1; |
| 2294 | 2297 | ||
| @@ -2380,6 +2383,8 @@ forw_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, | |||
| 2380 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 2383 | UPDATE_SYNTAX_TABLE_FORWARD (from); |
| 2381 | nesting++; | 2384 | nesting++; |
| 2382 | } | 2385 | } |
| 2386 | |||
| 2387 | rarely_quit (++quit_count); | ||
| 2383 | } | 2388 | } |
| 2384 | *charpos_ptr = from; | 2389 | *charpos_ptr = from; |
| 2385 | *bytepos_ptr = from_byte; | 2390 | *bytepos_ptr = from_byte; |
| @@ -2407,14 +2412,12 @@ between them, return t; otherwise return nil. */) | |||
| 2407 | ptrdiff_t out_charpos, out_bytepos; | 2412 | ptrdiff_t out_charpos, out_bytepos; |
| 2408 | EMACS_INT dummy; | 2413 | EMACS_INT dummy; |
| 2409 | int dummy2; | 2414 | int dummy2; |
| 2415 | unsigned short int quit_count = 0; | ||
| 2410 | 2416 | ||
| 2411 | CHECK_NUMBER (count); | 2417 | CHECK_NUMBER (count); |
| 2412 | count1 = XINT (count); | 2418 | count1 = XINT (count); |
| 2413 | stop = count1 > 0 ? ZV : BEGV; | 2419 | stop = count1 > 0 ? ZV : BEGV; |
| 2414 | 2420 | ||
| 2415 | immediate_quit = true; | ||
| 2416 | maybe_quit (); | ||
| 2417 | |||
| 2418 | from = PT; | 2421 | from = PT; |
| 2419 | from_byte = PT_BYTE; | 2422 | from_byte = PT_BYTE; |
| 2420 | 2423 | ||
| @@ -2429,7 +2432,6 @@ between them, return t; otherwise return nil. */) | |||
| 2429 | if (from == stop) | 2432 | if (from == stop) |
| 2430 | { | 2433 | { |
| 2431 | SET_PT_BOTH (from, from_byte); | 2434 | SET_PT_BOTH (from, from_byte); |
| 2432 | immediate_quit = false; | ||
| 2433 | return Qnil; | 2435 | return Qnil; |
| 2434 | } | 2436 | } |
| 2435 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 2437 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| @@ -2456,6 +2458,7 @@ between them, return t; otherwise return nil. */) | |||
| 2456 | INC_BOTH (from, from_byte); | 2458 | INC_BOTH (from, from_byte); |
| 2457 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 2459 | UPDATE_SYNTAX_TABLE_FORWARD (from); |
| 2458 | } | 2460 | } |
| 2461 | rarely_quit (++quit_count); | ||
| 2459 | } | 2462 | } |
| 2460 | while (code == Swhitespace || (code == Sendcomment && c == '\n')); | 2463 | while (code == Swhitespace || (code == Sendcomment && c == '\n')); |
| 2461 | 2464 | ||
| @@ -2463,7 +2466,6 @@ between them, return t; otherwise return nil. */) | |||
| 2463 | comstyle = ST_COMMENT_STYLE; | 2466 | comstyle = ST_COMMENT_STYLE; |
| 2464 | else if (code != Scomment) | 2467 | else if (code != Scomment) |
| 2465 | { | 2468 | { |
| 2466 | immediate_quit = false; | ||
| 2467 | DEC_BOTH (from, from_byte); | 2469 | DEC_BOTH (from, from_byte); |
| 2468 | SET_PT_BOTH (from, from_byte); | 2470 | SET_PT_BOTH (from, from_byte); |
| 2469 | return Qnil; | 2471 | return Qnil; |
| @@ -2474,7 +2476,6 @@ between them, return t; otherwise return nil. */) | |||
| 2474 | from = out_charpos; from_byte = out_bytepos; | 2476 | from = out_charpos; from_byte = out_bytepos; |
| 2475 | if (!found) | 2477 | if (!found) |
| 2476 | { | 2478 | { |
| 2477 | immediate_quit = false; | ||
| 2478 | SET_PT_BOTH (from, from_byte); | 2479 | SET_PT_BOTH (from, from_byte); |
| 2479 | return Qnil; | 2480 | return Qnil; |
| 2480 | } | 2481 | } |
| @@ -2486,23 +2487,19 @@ between them, return t; otherwise return nil. */) | |||
| 2486 | 2487 | ||
| 2487 | while (count1 < 0) | 2488 | while (count1 < 0) |
| 2488 | { | 2489 | { |
| 2489 | while (1) | 2490 | while (true) |
| 2490 | { | 2491 | { |
| 2491 | bool quoted; | ||
| 2492 | int syntax; | ||
| 2493 | |||
| 2494 | if (from <= stop) | 2492 | if (from <= stop) |
| 2495 | { | 2493 | { |
| 2496 | SET_PT_BOTH (BEGV, BEGV_BYTE); | 2494 | SET_PT_BOTH (BEGV, BEGV_BYTE); |
| 2497 | immediate_quit = false; | ||
| 2498 | return Qnil; | 2495 | return Qnil; |
| 2499 | } | 2496 | } |
| 2500 | 2497 | ||
| 2501 | DEC_BOTH (from, from_byte); | 2498 | DEC_BOTH (from, from_byte); |
| 2502 | /* char_quoted does UPDATE_SYNTAX_TABLE_BACKWARD (from). */ | 2499 | /* char_quoted does UPDATE_SYNTAX_TABLE_BACKWARD (from). */ |
| 2503 | quoted = char_quoted (from, from_byte); | 2500 | bool quoted = char_quoted (from, from_byte); |
| 2504 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 2501 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 2505 | syntax = SYNTAX_WITH_FLAGS (c); | 2502 | int syntax = SYNTAX_WITH_FLAGS (c); |
| 2506 | code = SYNTAX (c); | 2503 | code = SYNTAX (c); |
| 2507 | comstyle = 0; | 2504 | comstyle = 0; |
| 2508 | comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax); | 2505 | comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax); |
| @@ -2545,6 +2542,7 @@ between them, return t; otherwise return nil. */) | |||
| 2545 | } | 2542 | } |
| 2546 | else if (from == stop) | 2543 | else if (from == stop) |
| 2547 | break; | 2544 | break; |
| 2545 | rarely_quit (++quit_count); | ||
| 2548 | } | 2546 | } |
| 2549 | if (fence_found == 0) | 2547 | if (fence_found == 0) |
| 2550 | { | 2548 | { |
| @@ -2587,18 +2585,18 @@ between them, return t; otherwise return nil. */) | |||
| 2587 | else if (code != Swhitespace || quoted) | 2585 | else if (code != Swhitespace || quoted) |
| 2588 | { | 2586 | { |
| 2589 | leave: | 2587 | leave: |
| 2590 | immediate_quit = false; | ||
| 2591 | INC_BOTH (from, from_byte); | 2588 | INC_BOTH (from, from_byte); |
| 2592 | SET_PT_BOTH (from, from_byte); | 2589 | SET_PT_BOTH (from, from_byte); |
| 2593 | return Qnil; | 2590 | return Qnil; |
| 2594 | } | 2591 | } |
| 2592 | |||
| 2593 | rarely_quit (++quit_count); | ||
| 2595 | } | 2594 | } |
| 2596 | 2595 | ||
| 2597 | count1++; | 2596 | count1++; |
| 2598 | } | 2597 | } |
| 2599 | 2598 | ||
| 2600 | SET_PT_BOTH (from, from_byte); | 2599 | SET_PT_BOTH (from, from_byte); |
| 2601 | immediate_quit = false; | ||
| 2602 | return Qt; | 2600 | return Qt; |
| 2603 | } | 2601 | } |
| 2604 | 2602 | ||
| @@ -2632,6 +2630,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 2632 | EMACS_INT dummy; | 2630 | EMACS_INT dummy; |
| 2633 | int dummy2; | 2631 | int dummy2; |
| 2634 | bool multibyte_symbol_p = sexpflag && multibyte_syntax_as_symbol; | 2632 | bool multibyte_symbol_p = sexpflag && multibyte_syntax_as_symbol; |
| 2633 | unsigned short int quit_count = 0; | ||
| 2635 | 2634 | ||
| 2636 | if (depth > 0) min_depth = 0; | 2635 | if (depth > 0) min_depth = 0; |
| 2637 | 2636 | ||
| @@ -2640,7 +2639,6 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 2640 | 2639 | ||
| 2641 | from_byte = CHAR_TO_BYTE (from); | 2640 | from_byte = CHAR_TO_BYTE (from); |
| 2642 | 2641 | ||
| 2643 | immediate_quit = true; | ||
| 2644 | maybe_quit (); | 2642 | maybe_quit (); |
| 2645 | 2643 | ||
| 2646 | SETUP_SYNTAX_TABLE (from, count); | 2644 | SETUP_SYNTAX_TABLE (from, count); |
| @@ -2648,6 +2646,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 2648 | { | 2646 | { |
| 2649 | while (from < stop) | 2647 | while (from < stop) |
| 2650 | { | 2648 | { |
| 2649 | rarely_quit (++quit_count); | ||
| 2651 | bool comstart_first, prefix; | 2650 | bool comstart_first, prefix; |
| 2652 | int syntax, other_syntax; | 2651 | int syntax, other_syntax; |
| 2653 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 2652 | UPDATE_SYNTAX_TABLE_FORWARD (from); |
| @@ -2716,6 +2715,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 2716 | goto done; | 2715 | goto done; |
| 2717 | } | 2716 | } |
| 2718 | INC_BOTH (from, from_byte); | 2717 | INC_BOTH (from, from_byte); |
| 2718 | rarely_quit (++quit_count); | ||
| 2719 | } | 2719 | } |
| 2720 | goto done; | 2720 | goto done; |
| 2721 | 2721 | ||
| @@ -2787,6 +2787,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 2787 | if (c_code == Scharquote || c_code == Sescape) | 2787 | if (c_code == Scharquote || c_code == Sescape) |
| 2788 | INC_BOTH (from, from_byte); | 2788 | INC_BOTH (from, from_byte); |
| 2789 | INC_BOTH (from, from_byte); | 2789 | INC_BOTH (from, from_byte); |
| 2790 | rarely_quit (++quit_count); | ||
| 2790 | } | 2791 | } |
| 2791 | INC_BOTH (from, from_byte); | 2792 | INC_BOTH (from, from_byte); |
| 2792 | if (!depth && sexpflag) goto done; | 2793 | if (!depth && sexpflag) goto done; |
| @@ -2801,7 +2802,6 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 2801 | if (depth) | 2802 | if (depth) |
| 2802 | goto lose; | 2803 | goto lose; |
| 2803 | 2804 | ||
| 2804 | immediate_quit = false; | ||
| 2805 | return Qnil; | 2805 | return Qnil; |
| 2806 | 2806 | ||
| 2807 | /* End of object reached */ | 2807 | /* End of object reached */ |
| @@ -2813,11 +2813,11 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 2813 | { | 2813 | { |
| 2814 | while (from > stop) | 2814 | while (from > stop) |
| 2815 | { | 2815 | { |
| 2816 | int syntax; | 2816 | rarely_quit (++quit_count); |
| 2817 | DEC_BOTH (from, from_byte); | 2817 | DEC_BOTH (from, from_byte); |
| 2818 | UPDATE_SYNTAX_TABLE_BACKWARD (from); | 2818 | UPDATE_SYNTAX_TABLE_BACKWARD (from); |
| 2819 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 2819 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 2820 | syntax= SYNTAX_WITH_FLAGS (c); | 2820 | int syntax = SYNTAX_WITH_FLAGS (c); |
| 2821 | code = syntax_multibyte (c, multibyte_symbol_p); | 2821 | code = syntax_multibyte (c, multibyte_symbol_p); |
| 2822 | if (depth == min_depth) | 2822 | if (depth == min_depth) |
| 2823 | last_good = from; | 2823 | last_good = from; |
| @@ -2889,6 +2889,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 2889 | default: goto done2; | 2889 | default: goto done2; |
| 2890 | } | 2890 | } |
| 2891 | DEC_BOTH (from, from_byte); | 2891 | DEC_BOTH (from, from_byte); |
| 2892 | rarely_quit (++quit_count); | ||
| 2892 | } | 2893 | } |
| 2893 | goto done2; | 2894 | goto done2; |
| 2894 | 2895 | ||
| @@ -2951,13 +2952,14 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 2951 | if (syntax_multibyte (c, multibyte_symbol_p) == code) | 2952 | if (syntax_multibyte (c, multibyte_symbol_p) == code) |
| 2952 | break; | 2953 | break; |
| 2953 | } | 2954 | } |
| 2955 | rarely_quit (++quit_count); | ||
| 2954 | } | 2956 | } |
| 2955 | if (code == Sstring_fence && !depth && sexpflag) goto done2; | 2957 | if (code == Sstring_fence && !depth && sexpflag) goto done2; |
| 2956 | break; | 2958 | break; |
| 2957 | 2959 | ||
| 2958 | case Sstring: | 2960 | case Sstring: |
| 2959 | stringterm = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 2961 | stringterm = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 2960 | while (1) | 2962 | while (true) |
| 2961 | { | 2963 | { |
| 2962 | if (from == stop) | 2964 | if (from == stop) |
| 2963 | goto lose; | 2965 | goto lose; |
| @@ -2971,6 +2973,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 2971 | == Sstring)) | 2973 | == Sstring)) |
| 2972 | break; | 2974 | break; |
| 2973 | } | 2975 | } |
| 2976 | rarely_quit (++quit_count); | ||
| 2974 | } | 2977 | } |
| 2975 | if (!depth && sexpflag) goto done2; | 2978 | if (!depth && sexpflag) goto done2; |
| 2976 | break; | 2979 | break; |
| @@ -2984,7 +2987,6 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 2984 | if (depth) | 2987 | if (depth) |
| 2985 | goto lose; | 2988 | goto lose; |
| 2986 | 2989 | ||
| 2987 | immediate_quit = false; | ||
| 2988 | return Qnil; | 2990 | return Qnil; |
| 2989 | 2991 | ||
| 2990 | done2: | 2992 | done2: |
| @@ -2992,7 +2994,6 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) | |||
| 2992 | } | 2994 | } |
| 2993 | 2995 | ||
| 2994 | 2996 | ||
| 2995 | immediate_quit = false; | ||
| 2996 | XSETFASTINT (val, from); | 2997 | XSETFASTINT (val, from); |
| 2997 | return val; | 2998 | return val; |
| 2998 | 2999 | ||
| @@ -3085,6 +3086,7 @@ the prefix syntax flag (p). */) | |||
| 3085 | if (pos <= beg) | 3086 | if (pos <= beg) |
| 3086 | break; | 3087 | break; |
| 3087 | DEC_BOTH (pos, pos_byte); | 3088 | DEC_BOTH (pos, pos_byte); |
| 3089 | rarely_quit (pos); | ||
| 3088 | } | 3090 | } |
| 3089 | 3091 | ||
| 3090 | SET_PT_BOTH (opoint, opoint_byte); | 3092 | SET_PT_BOTH (opoint, opoint_byte); |
| @@ -3155,6 +3157,7 @@ scan_sexps_forward (struct lisp_parse_state *state, | |||
| 3155 | bool found; | 3157 | bool found; |
| 3156 | ptrdiff_t out_bytepos, out_charpos; | 3158 | ptrdiff_t out_bytepos, out_charpos; |
| 3157 | int temp; | 3159 | int temp; |
| 3160 | unsigned short int quit_count = 0; | ||
| 3158 | 3161 | ||
| 3159 | prev_from = from; | 3162 | prev_from = from; |
| 3160 | prev_from_byte = from_byte; | 3163 | prev_from_byte = from_byte; |
| @@ -3173,7 +3176,6 @@ do { prev_from = from; \ | |||
| 3173 | UPDATE_SYNTAX_TABLE_FORWARD (from); \ | 3176 | UPDATE_SYNTAX_TABLE_FORWARD (from); \ |
| 3174 | } while (0) | 3177 | } while (0) |
| 3175 | 3178 | ||
| 3176 | immediate_quit = true; | ||
| 3177 | maybe_quit (); | 3179 | maybe_quit (); |
| 3178 | 3180 | ||
| 3179 | depth = state->depth; | 3181 | depth = state->depth; |
| @@ -3225,6 +3227,7 @@ do { prev_from = from; \ | |||
| 3225 | 3227 | ||
| 3226 | while (from < end) | 3228 | while (from < end) |
| 3227 | { | 3229 | { |
| 3230 | rarely_quit (++quit_count); | ||
| 3228 | INC_FROM; | 3231 | INC_FROM; |
| 3229 | 3232 | ||
| 3230 | if ((from < end) | 3233 | if ((from < end) |
| @@ -3281,6 +3284,7 @@ do { prev_from = from; \ | |||
| 3281 | goto symdone; | 3284 | goto symdone; |
| 3282 | } | 3285 | } |
| 3283 | INC_FROM; | 3286 | INC_FROM; |
| 3287 | rarely_quit (++quit_count); | ||
| 3284 | } | 3288 | } |
| 3285 | symdone: | 3289 | symdone: |
| 3286 | curlevel->prev = curlevel->last; | 3290 | curlevel->prev = curlevel->last; |
| @@ -3391,6 +3395,7 @@ do { prev_from = from; \ | |||
| 3391 | break; | 3395 | break; |
| 3392 | } | 3396 | } |
| 3393 | INC_FROM; | 3397 | INC_FROM; |
| 3398 | rarely_quit (++quit_count); | ||
| 3394 | } | 3399 | } |
| 3395 | } | 3400 | } |
| 3396 | string_end: | 3401 | string_end: |
| @@ -3432,7 +3437,6 @@ do { prev_from = from; \ | |||
| 3432 | state->levelstarts); | 3437 | state->levelstarts); |
| 3433 | state->prev_syntax = (SYNTAX_FLAGS_COMSTARTEND_FIRST (prev_from_syntax) | 3438 | state->prev_syntax = (SYNTAX_FLAGS_COMSTARTEND_FIRST (prev_from_syntax) |
| 3434 | || state->quoted) ? prev_from_syntax : Smax; | 3439 | || state->quoted) ? prev_from_syntax : Smax; |
| 3435 | immediate_quit = false; | ||
| 3436 | } | 3440 | } |
| 3437 | 3441 | ||
| 3438 | /* Convert a (lisp) parse state to the internal form used in | 3442 | /* Convert a (lisp) parse state to the internal form used in |
diff --git a/src/sysdep.c b/src/sysdep.c index e172dc0aed4..91b2a5cb943 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -382,19 +382,23 @@ get_child_status (pid_t child, int *status, int options, bool interruptible) | |||
| 382 | so that another thread running glib won't find them. */ | 382 | so that another thread running glib won't find them. */ |
| 383 | eassert (child > 0); | 383 | eassert (child > 0); |
| 384 | 384 | ||
| 385 | while ((pid = waitpid (child, status, options)) < 0) | 385 | while (true) |
| 386 | { | 386 | { |
| 387 | /* Note: the MS-Windows emulation of waitpid calls maybe_quit | ||
| 388 | internally. */ | ||
| 389 | if (interruptible) | ||
| 390 | maybe_quit (); | ||
| 391 | |||
| 392 | pid = waitpid (child, status, options); | ||
| 393 | if (0 <= pid) | ||
| 394 | break; | ||
| 395 | |||
| 387 | /* Check that CHILD is a child process that has not been reaped, | 396 | /* Check that CHILD is a child process that has not been reaped, |
| 388 | and that STATUS and OPTIONS are valid. Otherwise abort, | 397 | and that STATUS and OPTIONS are valid. Otherwise abort, |
| 389 | as continuing after this internal error could cause Emacs to | 398 | as continuing after this internal error could cause Emacs to |
| 390 | become confused and kill innocent-victim processes. */ | 399 | become confused and kill innocent-victim processes. */ |
| 391 | if (errno != EINTR) | 400 | if (errno != EINTR) |
| 392 | emacs_abort (); | 401 | emacs_abort (); |
| 393 | |||
| 394 | /* Note: the MS-Windows emulation of waitpid calls maybe_quit | ||
| 395 | internally. */ | ||
| 396 | if (interruptible) | ||
| 397 | maybe_quit (); | ||
| 398 | } | 402 | } |
| 399 | 403 | ||
| 400 | /* If successful and status is requested, tell wait_reading_process_output | 404 | /* If successful and status is requested, tell wait_reading_process_output |
| @@ -2503,78 +2507,113 @@ emacs_close (int fd) | |||
| 2503 | #define MAX_RW_COUNT (INT_MAX >> 18 << 18) | 2507 | #define MAX_RW_COUNT (INT_MAX >> 18 << 18) |
| 2504 | #endif | 2508 | #endif |
| 2505 | 2509 | ||
| 2506 | /* Read from FILEDESC to a buffer BUF with size NBYTE, retrying if interrupted. | 2510 | /* Read from FD to a buffer BUF with size NBYTE. |
| 2511 | If interrupted, process any quits and pending signals immediately | ||
| 2512 | if INTERRUPTIBLE, and then retry the read unless quitting. | ||
| 2507 | Return the number of bytes read, which might be less than NBYTE. | 2513 | Return the number of bytes read, which might be less than NBYTE. |
| 2508 | On error, set errno and return -1. */ | 2514 | On error, set errno to a value other than EINTR, and return -1. */ |
| 2509 | ptrdiff_t | 2515 | static ptrdiff_t |
| 2510 | emacs_read (int fildes, void *buf, ptrdiff_t nbyte) | 2516 | emacs_intr_read (int fd, void *buf, ptrdiff_t nbyte, bool interruptible) |
| 2511 | { | 2517 | { |
| 2512 | ssize_t rtnval; | 2518 | ssize_t result; |
| 2513 | 2519 | ||
| 2514 | /* There is no need to check against MAX_RW_COUNT, since no caller ever | 2520 | /* There is no need to check against MAX_RW_COUNT, since no caller ever |
| 2515 | passes a size that large to emacs_read. */ | 2521 | passes a size that large to emacs_read. */ |
| 2522 | do | ||
| 2523 | { | ||
| 2524 | if (interruptible) | ||
| 2525 | maybe_quit (); | ||
| 2526 | result = read (fd, buf, nbyte); | ||
| 2527 | } | ||
| 2528 | while (result < 0 && errno == EINTR); | ||
| 2516 | 2529 | ||
| 2517 | while ((rtnval = read (fildes, buf, nbyte)) == -1 | 2530 | return result; |
| 2518 | && (errno == EINTR)) | ||
| 2519 | maybe_quit (); | ||
| 2520 | return (rtnval); | ||
| 2521 | } | 2531 | } |
| 2522 | 2532 | ||
| 2523 | /* Write to FILEDES from a buffer BUF with size NBYTE, retrying if interrupted | 2533 | /* Read from FD to a buffer BUF with size NBYTE. |
| 2524 | or if a partial write occurs. If interrupted, process pending | 2534 | If interrupted, retry the read. Return the number of bytes read, |
| 2525 | signals if PROCESS SIGNALS. Return the number of bytes written, setting | 2535 | which might be less than NBYTE. On error, set errno to a value |
| 2526 | errno if this is less than NBYTE. */ | 2536 | other than EINTR, and return -1. */ |
| 2537 | ptrdiff_t | ||
| 2538 | emacs_read (int fd, void *buf, ptrdiff_t nbyte) | ||
| 2539 | { | ||
| 2540 | return emacs_intr_read (fd, buf, nbyte, false); | ||
| 2541 | } | ||
| 2542 | |||
| 2543 | /* Like emacs_read, but also process quits and pending signals. */ | ||
| 2544 | ptrdiff_t | ||
| 2545 | emacs_read_quit (int fd, void *buf, ptrdiff_t nbyte) | ||
| 2546 | { | ||
| 2547 | return emacs_intr_read (fd, buf, nbyte, true); | ||
| 2548 | } | ||
| 2549 | |||
| 2550 | /* Write to FILEDES from a buffer BUF with size NBYTE, retrying if | ||
| 2551 | interrupted or if a partial write occurs. Process any quits | ||
| 2552 | immediately if INTERRUPTIBLE is positive, and process any pending | ||
| 2553 | signals immediately if INTERRUPTIBLE is nonzero. Return the number | ||
| 2554 | of bytes written; if this is less than NBYTE, set errno to a value | ||
| 2555 | other than EINTR. */ | ||
| 2527 | static ptrdiff_t | 2556 | static ptrdiff_t |
| 2528 | emacs_full_write (int fildes, char const *buf, ptrdiff_t nbyte, | 2557 | emacs_full_write (int fd, char const *buf, ptrdiff_t nbyte, |
| 2529 | bool process_signals) | 2558 | int interruptible) |
| 2530 | { | 2559 | { |
| 2531 | ptrdiff_t bytes_written = 0; | 2560 | ptrdiff_t bytes_written = 0; |
| 2532 | 2561 | ||
| 2533 | while (nbyte > 0) | 2562 | while (nbyte > 0) |
| 2534 | { | 2563 | { |
| 2535 | ssize_t n = write (fildes, buf, min (nbyte, MAX_RW_COUNT)); | 2564 | ssize_t n = write (fd, buf, min (nbyte, MAX_RW_COUNT)); |
| 2536 | 2565 | ||
| 2537 | if (n < 0) | 2566 | if (n < 0) |
| 2538 | { | 2567 | { |
| 2539 | if (errno == EINTR) | 2568 | if (errno != EINTR) |
| 2569 | break; | ||
| 2570 | |||
| 2571 | if (interruptible) | ||
| 2540 | { | 2572 | { |
| 2541 | /* I originally used maybe_quit but that might cause files to | 2573 | if (0 < interruptible) |
| 2542 | be truncated if you hit C-g in the middle of it. --Stef */ | 2574 | maybe_quit (); |
| 2543 | if (process_signals && pending_signals) | 2575 | if (pending_signals) |
| 2544 | process_pending_signals (); | 2576 | process_pending_signals (); |
| 2545 | continue; | ||
| 2546 | } | 2577 | } |
| 2547 | else | ||
| 2548 | break; | ||
| 2549 | } | 2578 | } |
| 2550 | 2579 | else | |
| 2551 | buf += n; | 2580 | { |
| 2552 | nbyte -= n; | 2581 | buf += n; |
| 2553 | bytes_written += n; | 2582 | nbyte -= n; |
| 2583 | bytes_written += n; | ||
| 2584 | } | ||
| 2554 | } | 2585 | } |
| 2555 | 2586 | ||
| 2556 | return bytes_written; | 2587 | return bytes_written; |
| 2557 | } | 2588 | } |
| 2558 | 2589 | ||
| 2559 | /* Write to FILEDES from a buffer BUF with size NBYTE, retrying if | 2590 | /* Write to FD from a buffer BUF with size NBYTE, retrying if |
| 2560 | interrupted or if a partial write occurs. Return the number of | 2591 | interrupted or if a partial write occurs. Do not process quits or |
| 2561 | bytes written, setting errno if this is less than NBYTE. */ | 2592 | pending signals. Return the number of bytes written, setting errno |
| 2593 | if this is less than NBYTE. */ | ||
| 2594 | ptrdiff_t | ||
| 2595 | emacs_write (int fd, void const *buf, ptrdiff_t nbyte) | ||
| 2596 | { | ||
| 2597 | return emacs_full_write (fd, buf, nbyte, 0); | ||
| 2598 | } | ||
| 2599 | |||
| 2600 | /* Like emacs_write, but also process pending signals. */ | ||
| 2562 | ptrdiff_t | 2601 | ptrdiff_t |
| 2563 | emacs_write (int fildes, void const *buf, ptrdiff_t nbyte) | 2602 | emacs_write_sig (int fd, void const *buf, ptrdiff_t nbyte) |
| 2564 | { | 2603 | { |
| 2565 | return emacs_full_write (fildes, buf, nbyte, 0); | 2604 | return emacs_full_write (fd, buf, nbyte, -1); |
| 2566 | } | 2605 | } |
| 2567 | 2606 | ||
| 2568 | /* Like emacs_write, but also process pending signals if interrupted. */ | 2607 | /* Like emacs_write, but also process quits and pending signals. */ |
| 2569 | ptrdiff_t | 2608 | ptrdiff_t |
| 2570 | emacs_write_sig (int fildes, void const *buf, ptrdiff_t nbyte) | 2609 | emacs_write_quit (int fd, void const *buf, ptrdiff_t nbyte) |
| 2571 | { | 2610 | { |
| 2572 | return emacs_full_write (fildes, buf, nbyte, 1); | 2611 | return emacs_full_write (fd, buf, nbyte, 1); |
| 2573 | } | 2612 | } |
| 2574 | 2613 | ||
| 2575 | /* Write a diagnostic to standard error that contains MESSAGE and a | 2614 | /* Write a diagnostic to standard error that contains MESSAGE and a |
| 2576 | string derived from errno. Preserve errno. Do not buffer stderr. | 2615 | string derived from errno. Preserve errno. Do not buffer stderr. |
| 2577 | Do not process pending signals if interrupted. */ | 2616 | Do not process quits or pending signals if interrupted. */ |
| 2578 | void | 2617 | void |
| 2579 | emacs_perror (char const *message) | 2618 | emacs_perror (char const *message) |
| 2580 | { | 2619 | { |
| @@ -3168,7 +3207,7 @@ system_process_attributes (Lisp_Object pid) | |||
| 3168 | else | 3207 | else |
| 3169 | { | 3208 | { |
| 3170 | record_unwind_protect_int (close_file_unwind, fd); | 3209 | record_unwind_protect_int (close_file_unwind, fd); |
| 3171 | nread = emacs_read (fd, procbuf, sizeof procbuf - 1); | 3210 | nread = emacs_read_quit (fd, procbuf, sizeof procbuf - 1); |
| 3172 | } | 3211 | } |
| 3173 | if (0 < nread) | 3212 | if (0 < nread) |
| 3174 | { | 3213 | { |
| @@ -3289,7 +3328,7 @@ system_process_attributes (Lisp_Object pid) | |||
| 3289 | /* Leave room even if every byte needs escaping below. */ | 3328 | /* Leave room even if every byte needs escaping below. */ |
| 3290 | readsize = (cmdline_size >> 1) - nread; | 3329 | readsize = (cmdline_size >> 1) - nread; |
| 3291 | 3330 | ||
| 3292 | nread_incr = emacs_read (fd, cmdline + nread, readsize); | 3331 | nread_incr = emacs_read_quit (fd, cmdline + nread, readsize); |
| 3293 | nread += max (0, nread_incr); | 3332 | nread += max (0, nread_incr); |
| 3294 | } | 3333 | } |
| 3295 | while (nread_incr == readsize); | 3334 | while (nread_incr == readsize); |
| @@ -3402,7 +3441,7 @@ system_process_attributes (Lisp_Object pid) | |||
| 3402 | else | 3441 | else |
| 3403 | { | 3442 | { |
| 3404 | record_unwind_protect_int (close_file_unwind, fd); | 3443 | record_unwind_protect_int (close_file_unwind, fd); |
| 3405 | nread = emacs_read (fd, &pinfo, sizeof pinfo); | 3444 | nread = emacs_read_quit (fd, &pinfo, sizeof pinfo); |
| 3406 | } | 3445 | } |
| 3407 | 3446 | ||
| 3408 | if (nread == sizeof pinfo) | 3447 | if (nread == sizeof pinfo) |
diff --git a/src/w32fns.c b/src/w32fns.c index 6a576fcec27..1b628b0b42e 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -3168,16 +3168,7 @@ signal_user_input (void) | |||
| 3168 | Vquit_flag = Vthrow_on_input; | 3168 | Vquit_flag = Vthrow_on_input; |
| 3169 | /* Calling maybe_quit from this thread is a bad idea, since this | 3169 | /* Calling maybe_quit from this thread is a bad idea, since this |
| 3170 | unwinds the stack of the Lisp thread, and the Windows runtime | 3170 | unwinds the stack of the Lisp thread, and the Windows runtime |
| 3171 | rightfully barfs. Disabled. */ | 3171 | rightfully barfs. */ |
| 3172 | #if 0 | ||
| 3173 | /* If we're inside a function that wants immediate quits, | ||
| 3174 | do it now. */ | ||
| 3175 | if (immediate_quit && NILP (Vinhibit_quit)) | ||
| 3176 | { | ||
| 3177 | immediate_quit = false; | ||
| 3178 | maybe_quit (); | ||
| 3179 | } | ||
| 3180 | #endif | ||
| 3181 | } | 3172 | } |
| 3182 | } | 3173 | } |
| 3183 | 3174 | ||
diff --git a/src/window.c b/src/window.c index 71a82b522c4..95690443f8e 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -4770,7 +4770,6 @@ window_scroll (Lisp_Object window, EMACS_INT n, bool whole, bool noerror) | |||
| 4770 | { | 4770 | { |
| 4771 | ptrdiff_t count = SPECPDL_INDEX (); | 4771 | ptrdiff_t count = SPECPDL_INDEX (); |
| 4772 | 4772 | ||
| 4773 | immediate_quit = true; | ||
| 4774 | n = clip_to_bounds (INT_MIN, n, INT_MAX); | 4773 | n = clip_to_bounds (INT_MIN, n, INT_MAX); |
| 4775 | 4774 | ||
| 4776 | wset_redisplay (XWINDOW (window)); | 4775 | wset_redisplay (XWINDOW (window)); |
| @@ -4789,7 +4788,36 @@ window_scroll (Lisp_Object window, EMACS_INT n, bool whole, bool noerror) | |||
| 4789 | 4788 | ||
| 4790 | /* Bug#15957. */ | 4789 | /* Bug#15957. */ |
| 4791 | XWINDOW (window)->window_end_valid = false; | 4790 | XWINDOW (window)->window_end_valid = false; |
| 4792 | immediate_quit = false; | 4791 | } |
| 4792 | |||
| 4793 | /* Compute scroll margin for WINDOW. | ||
| 4794 | We scroll when point is within this distance from the top or bottom | ||
| 4795 | of the window. The result is measured in lines or in pixels | ||
| 4796 | depending on the second parameter. */ | ||
| 4797 | int | ||
| 4798 | window_scroll_margin (struct window *window, enum margin_unit unit) | ||
| 4799 | { | ||
| 4800 | if (scroll_margin > 0) | ||
| 4801 | { | ||
| 4802 | int frame_line_height = default_line_pixel_height (window); | ||
| 4803 | int window_lines = window_box_height (window) / frame_line_height; | ||
| 4804 | |||
| 4805 | double ratio = 0.25; | ||
| 4806 | if (FLOATP (Vmaximum_scroll_margin)) | ||
| 4807 | { | ||
| 4808 | ratio = XFLOAT_DATA (Vmaximum_scroll_margin); | ||
| 4809 | ratio = max (0.0, ratio); | ||
| 4810 | ratio = min (ratio, 0.5); | ||
| 4811 | } | ||
| 4812 | int max_margin = min ((window_lines - 1)/2, | ||
| 4813 | (int) (window_lines * ratio)); | ||
| 4814 | int margin = clip_to_bounds (0, scroll_margin, max_margin); | ||
| 4815 | return (unit == MARGIN_IN_PIXELS) | ||
| 4816 | ? margin * frame_line_height | ||
| 4817 | : margin; | ||
| 4818 | } | ||
| 4819 | else | ||
| 4820 | return 0; | ||
| 4793 | } | 4821 | } |
| 4794 | 4822 | ||
| 4795 | 4823 | ||
| @@ -4808,7 +4836,6 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, bool noerror) | |||
| 4808 | bool vscrolled = false; | 4836 | bool vscrolled = false; |
| 4809 | int x, y, rtop, rbot, rowh, vpos; | 4837 | int x, y, rtop, rbot, rowh, vpos; |
| 4810 | void *itdata = NULL; | 4838 | void *itdata = NULL; |
| 4811 | int window_total_lines; | ||
| 4812 | int frame_line_height = default_line_pixel_height (w); | 4839 | int frame_line_height = default_line_pixel_height (w); |
| 4813 | bool adjust_old_pointm = !NILP (Fequal (Fwindow_point (window), | 4840 | bool adjust_old_pointm = !NILP (Fequal (Fwindow_point (window), |
| 4814 | Fwindow_old_point (window))); | 4841 | Fwindow_old_point (window))); |
| @@ -5064,12 +5091,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, bool noerror) | |||
| 5064 | /* Move PT out of scroll margins. | 5091 | /* Move PT out of scroll margins. |
| 5065 | This code wants current_y to be zero at the window start position | 5092 | This code wants current_y to be zero at the window start position |
| 5066 | even if there is a header line. */ | 5093 | even if there is a header line. */ |
| 5067 | window_total_lines | 5094 | this_scroll_margin = window_scroll_margin (w, MARGIN_IN_PIXELS); |
| 5068 | = w->total_lines * WINDOW_FRAME_LINE_HEIGHT (w) / frame_line_height; | ||
| 5069 | this_scroll_margin = max (0, scroll_margin); | ||
| 5070 | this_scroll_margin | ||
| 5071 | = min (this_scroll_margin, window_total_lines / 4); | ||
| 5072 | this_scroll_margin *= frame_line_height; | ||
| 5073 | 5095 | ||
| 5074 | if (n > 0) | 5096 | if (n > 0) |
| 5075 | { | 5097 | { |
| @@ -5125,7 +5147,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, bool noerror) | |||
| 5125 | in the scroll margin at the bottom. */ | 5147 | in the scroll margin at the bottom. */ |
| 5126 | move_it_to (&it, PT, -1, | 5148 | move_it_to (&it, PT, -1, |
| 5127 | (it.last_visible_y - WINDOW_HEADER_LINE_HEIGHT (w) | 5149 | (it.last_visible_y - WINDOW_HEADER_LINE_HEIGHT (w) |
| 5128 | - this_scroll_margin - 1), | 5150 | - partial_line_height (&it) - this_scroll_margin - 1), |
| 5129 | -1, | 5151 | -1, |
| 5130 | MOVE_TO_POS | MOVE_TO_Y); | 5152 | MOVE_TO_POS | MOVE_TO_Y); |
| 5131 | 5153 | ||
| @@ -5292,9 +5314,7 @@ window_scroll_line_based (Lisp_Object window, int n, bool whole, bool noerror) | |||
| 5292 | 5314 | ||
| 5293 | if (pos < ZV) | 5315 | if (pos < ZV) |
| 5294 | { | 5316 | { |
| 5295 | /* Don't use a scroll margin that is negative or too large. */ | 5317 | int this_scroll_margin = window_scroll_margin (w, MARGIN_IN_LINES); |
| 5296 | int this_scroll_margin = | ||
| 5297 | max (0, min (scroll_margin, w->total_lines / 4)); | ||
| 5298 | 5318 | ||
| 5299 | set_marker_restricted_both (w->start, w->contents, pos, pos_byte); | 5319 | set_marker_restricted_both (w->start, w->contents, pos, pos_byte); |
| 5300 | w->start_at_line_beg = !NILP (bolp); | 5320 | w->start_at_line_beg = !NILP (bolp); |
| @@ -5724,8 +5744,7 @@ and redisplay normally--don't erase and redraw the frame. */) | |||
| 5724 | 5744 | ||
| 5725 | /* Do this after making BUF current | 5745 | /* Do this after making BUF current |
| 5726 | in case scroll_margin is buffer-local. */ | 5746 | in case scroll_margin is buffer-local. */ |
| 5727 | this_scroll_margin | 5747 | this_scroll_margin = window_scroll_margin (w, MARGIN_IN_LINES); |
| 5728 | = max (0, min (scroll_margin, w->total_lines / 4)); | ||
| 5729 | 5748 | ||
| 5730 | /* Don't use redisplay code for initial frames, as the necessary | 5749 | /* Don't use redisplay code for initial frames, as the necessary |
| 5731 | data structures might not be set up yet then. */ | 5750 | data structures might not be set up yet then. */ |
| @@ -5964,10 +5983,6 @@ from the top of the window. */) | |||
| 5964 | 5983 | ||
| 5965 | lines = displayed_window_lines (w); | 5984 | lines = displayed_window_lines (w); |
| 5966 | 5985 | ||
| 5967 | #if false | ||
| 5968 | this_scroll_margin = max (0, min (scroll_margin, lines / 4)); | ||
| 5969 | #endif | ||
| 5970 | |||
| 5971 | if (NILP (arg)) | 5986 | if (NILP (arg)) |
| 5972 | XSETFASTINT (arg, lines / 2); | 5987 | XSETFASTINT (arg, lines / 2); |
| 5973 | else | 5988 | else |
| @@ -5983,6 +5998,8 @@ from the top of the window. */) | |||
| 5983 | it is probably better not to install it. However, it is here | 5998 | it is probably better not to install it. However, it is here |
| 5984 | inside #if false so as not to lose it. -- rms. */ | 5999 | inside #if false so as not to lose it. -- rms. */ |
| 5985 | 6000 | ||
| 6001 | this_scroll_margin = window_scroll_margin (w, MARGIN_IN_LINES); | ||
| 6002 | |||
| 5986 | /* Don't let it get into the margin at either top or bottom. */ | 6003 | /* Don't let it get into the margin at either top or bottom. */ |
| 5987 | iarg = max (iarg, this_scroll_margin); | 6004 | iarg = max (iarg, this_scroll_margin); |
| 5988 | iarg = min (iarg, lines - this_scroll_margin - 1); | 6005 | iarg = min (iarg, lines - this_scroll_margin - 1); |
diff --git a/src/window.h b/src/window.h index 061cf244943..acb8a5cabfa 100644 --- a/src/window.h +++ b/src/window.h | |||
| @@ -1120,6 +1120,8 @@ extern bool compare_window_configurations (Lisp_Object, Lisp_Object, bool); | |||
| 1120 | extern void mark_window_cursors_off (struct window *); | 1120 | extern void mark_window_cursors_off (struct window *); |
| 1121 | extern int window_internal_height (struct window *); | 1121 | extern int window_internal_height (struct window *); |
| 1122 | extern int window_body_width (struct window *w, bool); | 1122 | extern int window_body_width (struct window *w, bool); |
| 1123 | enum margin_unit { MARGIN_IN_LINES, MARGIN_IN_PIXELS }; | ||
| 1124 | extern int window_scroll_margin (struct window *, enum margin_unit); | ||
| 1123 | extern void temp_output_buffer_show (Lisp_Object); | 1125 | extern void temp_output_buffer_show (Lisp_Object); |
| 1124 | extern void replace_buffer_in_windows (Lisp_Object); | 1126 | extern void replace_buffer_in_windows (Lisp_Object); |
| 1125 | extern void replace_buffer_in_windows_safely (Lisp_Object); | 1127 | extern void replace_buffer_in_windows_safely (Lisp_Object); |
diff --git a/src/xdisp.c b/src/xdisp.c index 33661c882cd..0e329dfe6e9 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -9859,6 +9859,32 @@ move_it_by_lines (struct it *it, ptrdiff_t dvpos) | |||
| 9859 | } | 9859 | } |
| 9860 | } | 9860 | } |
| 9861 | 9861 | ||
| 9862 | int | ||
| 9863 | partial_line_height (struct it *it_origin) | ||
| 9864 | { | ||
| 9865 | int partial_height; | ||
| 9866 | void *it_data = NULL; | ||
| 9867 | struct it it; | ||
| 9868 | SAVE_IT (it, *it_origin, it_data); | ||
| 9869 | move_it_to (&it, ZV, -1, it.last_visible_y, -1, | ||
| 9870 | MOVE_TO_POS | MOVE_TO_Y); | ||
| 9871 | if (it.what == IT_EOB) | ||
| 9872 | { | ||
| 9873 | int vis_height = it.last_visible_y - it.current_y; | ||
| 9874 | int height = it.ascent + it.descent; | ||
| 9875 | partial_height = (vis_height < height) ? vis_height : 0; | ||
| 9876 | } | ||
| 9877 | else | ||
| 9878 | { | ||
| 9879 | int last_line_y = it.current_y; | ||
| 9880 | move_it_by_lines (&it, 1); | ||
| 9881 | partial_height = (it.current_y > it.last_visible_y) | ||
| 9882 | ? it.last_visible_y - last_line_y : 0; | ||
| 9883 | } | ||
| 9884 | RESTORE_IT (&it, &it, it_data); | ||
| 9885 | return partial_height; | ||
| 9886 | } | ||
| 9887 | |||
| 9862 | /* Return true if IT points into the middle of a display vector. */ | 9888 | /* Return true if IT points into the middle of a display vector. */ |
| 9863 | 9889 | ||
| 9864 | bool | 9890 | bool |
| @@ -15316,7 +15342,6 @@ try_scrolling (Lisp_Object window, bool just_this_one_p, | |||
| 15316 | bool temp_scroll_step, bool last_line_misfit) | 15342 | bool temp_scroll_step, bool last_line_misfit) |
| 15317 | { | 15343 | { |
| 15318 | struct window *w = XWINDOW (window); | 15344 | struct window *w = XWINDOW (window); |
| 15319 | struct frame *f = XFRAME (w->frame); | ||
| 15320 | struct text_pos pos, startp; | 15345 | struct text_pos pos, startp; |
| 15321 | struct it it; | 15346 | struct it it; |
| 15322 | int this_scroll_margin, scroll_max, rc, height; | 15347 | int this_scroll_margin, scroll_max, rc, height; |
| @@ -15327,8 +15352,6 @@ try_scrolling (Lisp_Object window, bool just_this_one_p, | |||
| 15327 | /* We will never try scrolling more than this number of lines. */ | 15352 | /* We will never try scrolling more than this number of lines. */ |
| 15328 | int scroll_limit = SCROLL_LIMIT; | 15353 | int scroll_limit = SCROLL_LIMIT; |
| 15329 | int frame_line_height = default_line_pixel_height (w); | 15354 | int frame_line_height = default_line_pixel_height (w); |
| 15330 | int window_total_lines | ||
| 15331 | = WINDOW_TOTAL_LINES (w) * FRAME_LINE_HEIGHT (f) / frame_line_height; | ||
| 15332 | 15355 | ||
| 15333 | #ifdef GLYPH_DEBUG | 15356 | #ifdef GLYPH_DEBUG |
| 15334 | debug_method_add (w, "try_scrolling"); | 15357 | debug_method_add (w, "try_scrolling"); |
| @@ -15336,13 +15359,7 @@ try_scrolling (Lisp_Object window, bool just_this_one_p, | |||
| 15336 | 15359 | ||
| 15337 | SET_TEXT_POS_FROM_MARKER (startp, w->start); | 15360 | SET_TEXT_POS_FROM_MARKER (startp, w->start); |
| 15338 | 15361 | ||
| 15339 | /* Compute scroll margin height in pixels. We scroll when point is | 15362 | this_scroll_margin = window_scroll_margin (w, MARGIN_IN_PIXELS); |
| 15340 | within this distance from the top or bottom of the window. */ | ||
| 15341 | if (scroll_margin > 0) | ||
| 15342 | this_scroll_margin = min (scroll_margin, window_total_lines / 4) | ||
| 15343 | * frame_line_height; | ||
| 15344 | else | ||
| 15345 | this_scroll_margin = 0; | ||
| 15346 | 15363 | ||
| 15347 | /* Force arg_scroll_conservatively to have a reasonable value, to | 15364 | /* Force arg_scroll_conservatively to have a reasonable value, to |
| 15348 | avoid scrolling too far away with slow move_it_* functions. Note | 15365 | avoid scrolling too far away with slow move_it_* functions. Note |
| @@ -15377,7 +15394,8 @@ try_scrolling (Lisp_Object window, bool just_this_one_p, | |||
| 15377 | /* Compute the pixel ypos of the scroll margin, then move IT to | 15394 | /* Compute the pixel ypos of the scroll margin, then move IT to |
| 15378 | either that ypos or PT, whichever comes first. */ | 15395 | either that ypos or PT, whichever comes first. */ |
| 15379 | start_display (&it, w, startp); | 15396 | start_display (&it, w, startp); |
| 15380 | scroll_margin_y = it.last_visible_y - this_scroll_margin | 15397 | scroll_margin_y = it.last_visible_y - partial_line_height (&it) |
| 15398 | - this_scroll_margin | ||
| 15381 | - frame_line_height * extra_scroll_margin_lines; | 15399 | - frame_line_height * extra_scroll_margin_lines; |
| 15382 | move_it_to (&it, PT, -1, scroll_margin_y - 1, -1, | 15400 | move_it_to (&it, PT, -1, scroll_margin_y - 1, -1, |
| 15383 | (MOVE_TO_POS | MOVE_TO_Y)); | 15401 | (MOVE_TO_POS | MOVE_TO_Y)); |
| @@ -15816,23 +15834,12 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, | |||
| 15816 | { | 15834 | { |
| 15817 | int this_scroll_margin, top_scroll_margin; | 15835 | int this_scroll_margin, top_scroll_margin; |
| 15818 | struct glyph_row *row = NULL; | 15836 | struct glyph_row *row = NULL; |
| 15819 | int frame_line_height = default_line_pixel_height (w); | ||
| 15820 | int window_total_lines | ||
| 15821 | = WINDOW_TOTAL_LINES (w) * FRAME_LINE_HEIGHT (f) / frame_line_height; | ||
| 15822 | 15837 | ||
| 15823 | #ifdef GLYPH_DEBUG | 15838 | #ifdef GLYPH_DEBUG |
| 15824 | debug_method_add (w, "cursor movement"); | 15839 | debug_method_add (w, "cursor movement"); |
| 15825 | #endif | 15840 | #endif |
| 15826 | 15841 | ||
| 15827 | /* Scroll if point within this distance from the top or bottom | 15842 | this_scroll_margin = window_scroll_margin (w, MARGIN_IN_PIXELS); |
| 15828 | of the window. This is a pixel value. */ | ||
| 15829 | if (scroll_margin > 0) | ||
| 15830 | { | ||
| 15831 | this_scroll_margin = min (scroll_margin, window_total_lines / 4); | ||
| 15832 | this_scroll_margin *= frame_line_height; | ||
| 15833 | } | ||
| 15834 | else | ||
| 15835 | this_scroll_margin = 0; | ||
| 15836 | 15843 | ||
| 15837 | top_scroll_margin = this_scroll_margin; | 15844 | top_scroll_margin = this_scroll_margin; |
| 15838 | if (WINDOW_WANTS_HEADER_LINE_P (w)) | 15845 | if (WINDOW_WANTS_HEADER_LINE_P (w)) |
| @@ -16280,7 +16287,7 @@ redisplay_window (Lisp_Object window, bool just_this_one_p) | |||
| 16280 | int centering_position = -1; | 16287 | int centering_position = -1; |
| 16281 | bool last_line_misfit = false; | 16288 | bool last_line_misfit = false; |
| 16282 | ptrdiff_t beg_unchanged, end_unchanged; | 16289 | ptrdiff_t beg_unchanged, end_unchanged; |
| 16283 | int frame_line_height; | 16290 | int frame_line_height, margin; |
| 16284 | bool use_desired_matrix; | 16291 | bool use_desired_matrix; |
| 16285 | void *itdata = NULL; | 16292 | void *itdata = NULL; |
| 16286 | 16293 | ||
| @@ -16310,6 +16317,8 @@ redisplay_window (Lisp_Object window, bool just_this_one_p) | |||
| 16310 | restart: | 16317 | restart: |
| 16311 | reconsider_clip_changes (w); | 16318 | reconsider_clip_changes (w); |
| 16312 | frame_line_height = default_line_pixel_height (w); | 16319 | frame_line_height = default_line_pixel_height (w); |
| 16320 | margin = window_scroll_margin (w, MARGIN_IN_LINES); | ||
| 16321 | |||
| 16313 | 16322 | ||
| 16314 | /* Has the mode line to be updated? */ | 16323 | /* Has the mode line to be updated? */ |
| 16315 | update_mode_line = (w->update_mode_line | 16324 | update_mode_line = (w->update_mode_line |
| @@ -16614,10 +16623,7 @@ redisplay_window (Lisp_Object window, bool just_this_one_p) | |||
| 16614 | /* Some people insist on not letting point enter the scroll | 16623 | /* Some people insist on not letting point enter the scroll |
| 16615 | margin, even though this part handles windows that didn't | 16624 | margin, even though this part handles windows that didn't |
| 16616 | scroll at all. */ | 16625 | scroll at all. */ |
| 16617 | int window_total_lines | 16626 | int pixel_margin = margin * frame_line_height; |
| 16618 | = WINDOW_TOTAL_LINES (w) * FRAME_LINE_HEIGHT (f) / frame_line_height; | ||
| 16619 | int margin = min (scroll_margin, window_total_lines / 4); | ||
| 16620 | int pixel_margin = margin * frame_line_height; | ||
| 16621 | bool header_line = WINDOW_WANTS_HEADER_LINE_P (w); | 16627 | bool header_line = WINDOW_WANTS_HEADER_LINE_P (w); |
| 16622 | 16628 | ||
| 16623 | /* Note: We add an extra FRAME_LINE_HEIGHT, because the loop | 16629 | /* Note: We add an extra FRAME_LINE_HEIGHT, because the loop |
| @@ -16901,12 +16907,6 @@ redisplay_window (Lisp_Object window, bool just_this_one_p) | |||
| 16901 | it.current_y = it.last_visible_y; | 16907 | it.current_y = it.last_visible_y; |
| 16902 | if (centering_position < 0) | 16908 | if (centering_position < 0) |
| 16903 | { | 16909 | { |
| 16904 | int window_total_lines | ||
| 16905 | = WINDOW_TOTAL_LINES (w) * FRAME_LINE_HEIGHT (f) / frame_line_height; | ||
| 16906 | int margin | ||
| 16907 | = scroll_margin > 0 | ||
| 16908 | ? min (scroll_margin, window_total_lines / 4) | ||
| 16909 | : 0; | ||
| 16910 | ptrdiff_t margin_pos = CHARPOS (startp); | 16910 | ptrdiff_t margin_pos = CHARPOS (startp); |
| 16911 | Lisp_Object aggressive; | 16911 | Lisp_Object aggressive; |
| 16912 | bool scrolling_up; | 16912 | bool scrolling_up; |
| @@ -17150,10 +17150,6 @@ redisplay_window (Lisp_Object window, bool just_this_one_p) | |||
| 17150 | { | 17150 | { |
| 17151 | int window_total_lines | 17151 | int window_total_lines |
| 17152 | = WINDOW_TOTAL_LINES (w) * FRAME_LINE_HEIGHT (f) / frame_line_height; | 17152 | = WINDOW_TOTAL_LINES (w) * FRAME_LINE_HEIGHT (f) / frame_line_height; |
| 17153 | int margin = | ||
| 17154 | scroll_margin > 0 | ||
| 17155 | ? min (scroll_margin, window_total_lines / 4) | ||
| 17156 | : 0; | ||
| 17157 | bool move_down = w->cursor.vpos >= window_total_lines / 2; | 17153 | bool move_down = w->cursor.vpos >= window_total_lines / 2; |
| 17158 | 17154 | ||
| 17159 | move_it_by_lines (&it, move_down ? margin + 1 : -(margin + 1)); | 17155 | move_it_by_lines (&it, move_down ? margin + 1 : -(margin + 1)); |
| @@ -17359,7 +17355,6 @@ try_window (Lisp_Object window, struct text_pos pos, int flags) | |||
| 17359 | struct it it; | 17355 | struct it it; |
| 17360 | struct glyph_row *last_text_row = NULL; | 17356 | struct glyph_row *last_text_row = NULL; |
| 17361 | struct frame *f = XFRAME (w->frame); | 17357 | struct frame *f = XFRAME (w->frame); |
| 17362 | int frame_line_height = default_line_pixel_height (w); | ||
| 17363 | 17358 | ||
| 17364 | /* Make POS the new window start. */ | 17359 | /* Make POS the new window start. */ |
| 17365 | set_marker_both (w->start, Qnil, CHARPOS (pos), BYTEPOS (pos)); | 17360 | set_marker_both (w->start, Qnil, CHARPOS (pos), BYTEPOS (pos)); |
| @@ -17385,17 +17380,7 @@ try_window (Lisp_Object window, struct text_pos pos, int flags) | |||
| 17385 | if ((flags & TRY_WINDOW_CHECK_MARGINS) | 17380 | if ((flags & TRY_WINDOW_CHECK_MARGINS) |
| 17386 | && !MINI_WINDOW_P (w)) | 17381 | && !MINI_WINDOW_P (w)) |
| 17387 | { | 17382 | { |
| 17388 | int this_scroll_margin; | 17383 | int this_scroll_margin = window_scroll_margin (w, MARGIN_IN_PIXELS); |
| 17389 | int window_total_lines | ||
| 17390 | = WINDOW_TOTAL_LINES (w) * FRAME_LINE_HEIGHT (f) / frame_line_height; | ||
| 17391 | |||
| 17392 | if (scroll_margin > 0) | ||
| 17393 | { | ||
| 17394 | this_scroll_margin = min (scroll_margin, window_total_lines / 4); | ||
| 17395 | this_scroll_margin *= frame_line_height; | ||
| 17396 | } | ||
| 17397 | else | ||
| 17398 | this_scroll_margin = 0; | ||
| 17399 | 17384 | ||
| 17400 | if ((w->cursor.y >= 0 /* not vscrolled */ | 17385 | if ((w->cursor.y >= 0 /* not vscrolled */ |
| 17401 | && w->cursor.y < this_scroll_margin | 17386 | && w->cursor.y < this_scroll_margin |
| @@ -18679,15 +18664,8 @@ try_window_id (struct window *w) | |||
| 18679 | 18664 | ||
| 18680 | /* Don't let the cursor end in the scroll margins. */ | 18665 | /* Don't let the cursor end in the scroll margins. */ |
| 18681 | { | 18666 | { |
| 18682 | int this_scroll_margin, cursor_height; | 18667 | int this_scroll_margin = window_scroll_margin (w, MARGIN_IN_PIXELS); |
| 18683 | int frame_line_height = default_line_pixel_height (w); | 18668 | int cursor_height = MATRIX_ROW (w->desired_matrix, w->cursor.vpos)->height; |
| 18684 | int window_total_lines | ||
| 18685 | = WINDOW_TOTAL_LINES (w) * FRAME_LINE_HEIGHT (it.f) / frame_line_height; | ||
| 18686 | |||
| 18687 | this_scroll_margin = | ||
| 18688 | max (0, min (scroll_margin, window_total_lines / 4)); | ||
| 18689 | this_scroll_margin *= frame_line_height; | ||
| 18690 | cursor_height = MATRIX_ROW (w->desired_matrix, w->cursor.vpos)->height; | ||
| 18691 | 18669 | ||
| 18692 | if ((w->cursor.y < this_scroll_margin | 18670 | if ((w->cursor.y < this_scroll_margin |
| 18693 | && CHARPOS (start) > BEGV) | 18671 | && CHARPOS (start) > BEGV) |
| @@ -31569,6 +31547,14 @@ Recenter the window whenever point gets within this many lines | |||
| 31569 | of the top or bottom of the window. */); | 31547 | of the top or bottom of the window. */); |
| 31570 | scroll_margin = 0; | 31548 | scroll_margin = 0; |
| 31571 | 31549 | ||
| 31550 | DEFVAR_LISP ("maximum-scroll-margin", Vmaximum_scroll_margin, | ||
| 31551 | doc: /* Maximum effective value of `scroll-margin'. | ||
| 31552 | Given as a fraction of the current window's lines. The value should | ||
| 31553 | be a floating point number between 0.0 and 0.5. The effective maximum | ||
| 31554 | is limited to (/ (1- window-lines) 2). Non-float values for this | ||
| 31555 | variable are ignored and the default 0.25 is used instead. */); | ||
| 31556 | Vmaximum_scroll_margin = make_float (0.25); | ||
| 31557 | |||
| 31572 | DEFVAR_LISP ("display-pixels-per-inch", Vdisplay_pixels_per_inch, | 31558 | DEFVAR_LISP ("display-pixels-per-inch", Vdisplay_pixels_per_inch, |
| 31573 | doc: /* Pixels per inch value for non-window system displays. | 31559 | doc: /* Pixels per inch value for non-window system displays. |
| 31574 | Value is a number or a cons (WIDTH-DPI . HEIGHT-DPI). */); | 31560 | Value is a number or a cons (WIDTH-DPI . HEIGHT-DPI). */); |