aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2023-02-15 12:24:22 +0800
committerPo Lu2023-02-15 12:24:22 +0800
commita62fa69ec9ee847bd0031f3e39a36d00305d3fba (patch)
treed5f03a4823ac88a1386d7017904f32be1ce5c481 /src
parenta158c1d5b964fda36f752998cef076d581dc4df4 (diff)
parent51e3f91f50da43f18706410bf6cd096684379daa (diff)
downloademacs-a62fa69ec9ee847bd0031f3e39a36d00305d3fba.tar.gz
emacs-a62fa69ec9ee847bd0031f3e39a36d00305d3fba.zip
Merge remote-tracking branch 'origin/master' into feature/android
Diffstat (limited to 'src')
-rw-r--r--src/.gdbinit2
-rw-r--r--src/comp.c3
-rw-r--r--src/fileio.c100
-rw-r--r--src/pdumper.c2
4 files changed, 48 insertions, 59 deletions
diff --git a/src/.gdbinit b/src/.gdbinit
index c96c2b597bd..c97e78559f1 100644
--- a/src/.gdbinit
+++ b/src/.gdbinit
@@ -926,7 +926,7 @@ Print the contents of $ as an Emacs Lisp cons.
926end 926end
927 927
928define nextcons 928define nextcons
929 p $.u.cdr 929 p $.u.s.u.cdr
930 xcons 930 xcons
931end 931end
932document nextcons 932document nextcons
diff --git a/src/comp.c b/src/comp.c
index ba549155925..7d2987605d9 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -4991,7 +4991,8 @@ DEFUN ("comp--compile-ctxt-to-file", Fcomp__compile_ctxt_to_file,
4991 format_string ("%s_libgccjit_repro.c", SSDATA (ebase_name))); 4991 format_string ("%s_libgccjit_repro.c", SSDATA (ebase_name)));
4992 4992
4993 Lisp_Object tmp_file = 4993 Lisp_Object tmp_file =
4994 Fmake_temp_file_internal (base_name, Qnil, build_string (".eln.tmp"), Qnil); 4994 Fmake_temp_file_internal (base_name, make_fixnum (0),
4995 build_string (".eln.tmp"), Qnil);
4995 Lisp_Object encoded_tmp_file = ENCODE_FILE (tmp_file); 4996 Lisp_Object encoded_tmp_file = ENCODE_FILE (tmp_file);
4996#ifdef WINDOWSNT 4997#ifdef WINDOWSNT
4997 encoded_tmp_file = ansi_encode_filename (encoded_tmp_file); 4998 encoded_tmp_file = ansi_encode_filename (encoded_tmp_file);
diff --git a/src/fileio.c b/src/fileio.c
index 71f83ea6daf..375019c6fb6 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3979,8 +3979,6 @@ by calling `format-decode', which see. */)
3979 struct timespec mtime; 3979 struct timespec mtime;
3980 int fd; 3980 int fd;
3981 ptrdiff_t inserted = 0; 3981 ptrdiff_t inserted = 0;
3982 ptrdiff_t how_much;
3983 off_t beg_offset, end_offset;
3984 int unprocessed; 3982 int unprocessed;
3985 specpdl_ref count = SPECPDL_INDEX (); 3983 specpdl_ref count = SPECPDL_INDEX ();
3986 Lisp_Object handler, val, insval, orig_filename, old_undo; 3984 Lisp_Object handler, val, insval, orig_filename, old_undo;
@@ -3993,7 +3991,8 @@ by calling `format-decode', which see. */)
3993 bool replace_handled = false; 3991 bool replace_handled = false;
3994 bool set_coding_system = false; 3992 bool set_coding_system = false;
3995 Lisp_Object coding_system; 3993 Lisp_Object coding_system;
3996 bool read_quit = false; 3994 /* Negative if read error, 0 if OK so far, positive if quit. */
3995 ptrdiff_t read_quit = 0;
3997 /* If the undo log only contains the insertion, there's no point 3996 /* If the undo log only contains the insertion, there's no point
3998 keeping it. It's typically when we first fill a file-buffer. */ 3997 keeping it. It's typically when we first fill a file-buffer. */
3999 bool empty_undo_list_p 3998 bool empty_undo_list_p
@@ -4042,6 +4041,17 @@ by calling `format-decode', which see. */)
4042 goto handled; 4041 goto handled;
4043 } 4042 }
4044 4043
4044 if (!NILP (visit))
4045 {
4046 if (!NILP (beg) || !NILP (end))
4047 error ("Attempt to visit less than an entire file");
4048 if (BEG < Z && NILP (replace))
4049 error ("Cannot do file visiting in a non-empty buffer");
4050 }
4051
4052 off_t beg_offset = !NILP (beg) ? file_offset (beg) : 0;
4053 off_t end_offset = !NILP (end) ? file_offset (end) : -1;
4054
4045 orig_filename = filename; 4055 orig_filename = filename;
4046 filename = ENCODE_FILE (filename); 4056 filename = ENCODE_FILE (filename);
4047 4057
@@ -4084,7 +4094,6 @@ by calling `format-decode', which see. */)
4084 if (!S_ISREG (st.st_mode)) 4094 if (!S_ISREG (st.st_mode))
4085 { 4095 {
4086 regular = false; 4096 regular = false;
4087 seekable = lseek (fd, 0, SEEK_CUR) < 0;
4088 4097
4089 if (! NILP (visit)) 4098 if (! NILP (visit))
4090 { 4099 {
@@ -4092,32 +4101,18 @@ by calling `format-decode', which see. */)
4092 goto notfound; 4101 goto notfound;
4093 } 4102 }
4094 4103
4095 if (!NILP (beg) && !seekable)
4096 xsignal2 (Qfile_error,
4097 build_string ("cannot use a start position in a non-seekable file/device"),
4098 orig_filename);
4099
4100 if (!NILP (replace)) 4104 if (!NILP (replace))
4101 xsignal2 (Qfile_error, 4105 xsignal2 (Qfile_error,
4102 build_string ("not a regular file"), orig_filename); 4106 build_string ("not a regular file"), orig_filename);
4103 }
4104 4107
4105 if (!NILP (visit)) 4108 seekable = lseek (fd, 0, SEEK_CUR) < 0;
4106 { 4109 if (!NILP (beg) && !seekable)
4107 if (!NILP (beg) || !NILP (end)) 4110 xsignal2 (Qfile_error,
4108 error ("Attempt to visit less than an entire file"); 4111 build_string ("cannot use a start position in a non-seekable file/device"),
4109 if (BEG < Z && NILP (replace)) 4112 orig_filename);
4110 error ("Cannot do file visiting in a non-empty buffer");
4111 } 4113 }
4112 4114
4113 if (!NILP (beg)) 4115 if (end_offset < 0)
4114 beg_offset = file_offset (beg);
4115 else
4116 beg_offset = 0;
4117
4118 if (!NILP (end))
4119 end_offset = file_offset (end);
4120 else
4121 { 4116 {
4122 if (!regular) 4117 if (!regular)
4123 end_offset = TYPE_MAXIMUM (off_t); 4118 end_offset = TYPE_MAXIMUM (off_t);
@@ -4178,7 +4173,7 @@ by calling `format-decode', which see. */)
4178 else 4173 else
4179 { 4174 {
4180 /* Don't try looking inside a file for a coding system 4175 /* Don't try looking inside a file for a coding system
4181 specification if it is not seekable. */ 4176 specification if it is not a regular file. */
4182 if (regular && !NILP (Vset_auto_coding_function)) 4177 if (regular && !NILP (Vset_auto_coding_function))
4183 { 4178 {
4184 /* Find a coding system specified in the heading two 4179 /* Find a coding system specified in the heading two
@@ -4196,7 +4191,7 @@ by calling `format-decode', which see. */)
4196 if (nread == 1024) 4191 if (nread == 1024)
4197 { 4192 {
4198 int ntail; 4193 int ntail;
4199 if (lseek (fd, - (1024 * 3), SEEK_END) < 0) 4194 if (lseek (fd, st.st_size - 1024 * 3, SEEK_CUR) < 0)
4200 report_file_error ("Setting file position", 4195 report_file_error ("Setting file position",
4201 orig_filename); 4196 orig_filename);
4202 ntail = emacs_read_quit (fd, read_buf + nread, 1024 * 3); 4197 ntail = emacs_read_quit (fd, read_buf + nread, 1024 * 3);
@@ -4481,7 +4476,7 @@ by calling `format-decode', which see. */)
4481 ptrdiff_t bufpos; 4476 ptrdiff_t bufpos;
4482 unsigned char *decoded; 4477 unsigned char *decoded;
4483 ptrdiff_t temp; 4478 ptrdiff_t temp;
4484 ptrdiff_t this = 0; 4479 ptrdiff_t this;
4485 specpdl_ref this_count = SPECPDL_INDEX (); 4480 specpdl_ref this_count = SPECPDL_INDEX ();
4486 bool multibyte 4481 bool multibyte
4487 = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); 4482 = ! NILP (BVAR (current_buffer, enable_multibyte_characters));
@@ -4657,8 +4652,12 @@ by calling `format-decode', which see. */)
4657 } 4652 }
4658 4653
4659 move_gap_both (PT, PT_BYTE); 4654 move_gap_both (PT, PT_BYTE);
4660 if (GAP_SIZE < total) 4655
4661 make_gap (total - GAP_SIZE); 4656 /* Ensure the gap is at least one byte larger than needed for the
4657 estimated file size, so that in the usual case we read to EOF
4658 without reallocating. */
4659 if (GAP_SIZE <= total)
4660 make_gap (total - GAP_SIZE + 1);
4662 4661
4663 if (beg_offset != 0 || !NILP (replace)) 4662 if (beg_offset != 0 || !NILP (replace))
4664 { 4663 {
@@ -4666,12 +4665,6 @@ by calling `format-decode', which see. */)
4666 report_file_error ("Setting file position", orig_filename); 4665 report_file_error ("Setting file position", orig_filename);
4667 } 4666 }
4668 4667
4669 /* In the following loop, HOW_MUCH contains the total bytes read so
4670 far for a regular file, and not changed for a special file. But,
4671 before exiting the loop, it is set to a negative value if I/O
4672 error occurs. */
4673 how_much = 0;
4674
4675 /* Total bytes inserted. */ 4668 /* Total bytes inserted. */
4676 inserted = 0; 4669 inserted = 0;
4677 4670
@@ -4680,23 +4673,26 @@ by calling `format-decode', which see. */)
4680 { 4673 {
4681 ptrdiff_t gap_size = GAP_SIZE; 4674 ptrdiff_t gap_size = GAP_SIZE;
4682 4675
4683 while (how_much < total) 4676 while (NILP (end) || inserted < total)
4684 { 4677 {
4685 /* `try' is reserved in some compilers (Microsoft C). */
4686 ptrdiff_t trytry = min (total - how_much, READ_BUF_SIZE);
4687 ptrdiff_t this; 4678 ptrdiff_t this;
4688 4679
4680 if (gap_size == 0)
4681 {
4682 /* The size estimate was wrong. Make the gap 50% larger. */
4683 make_gap (GAP_SIZE >> 1);
4684 gap_size = GAP_SIZE - inserted;
4685 }
4686
4687 /* 'try' is reserved in some compilers (Microsoft C). */
4688 ptrdiff_t trytry = min (gap_size, READ_BUF_SIZE);
4689 if (!NILP (end))
4690 trytry = min (trytry, total - inserted);
4691
4689 if (!seekable && NILP (end)) 4692 if (!seekable && NILP (end))
4690 { 4693 {
4691 Lisp_Object nbytes; 4694 Lisp_Object nbytes;
4692 4695
4693 /* Maybe make more room. */
4694 if (gap_size < trytry)
4695 {
4696 make_gap (trytry - gap_size);
4697 gap_size = GAP_SIZE - inserted;
4698 }
4699
4700 /* Read from the file, capturing `quit'. When an 4696 /* Read from the file, capturing `quit'. When an
4701 error occurs, end the loop, and arrange for a quit 4697 error occurs, end the loop, and arrange for a quit
4702 to be signaled after decoding the text we read. */ 4698 to be signaled after decoding the text we read. */
@@ -4707,7 +4703,7 @@ by calling `format-decode', which see. */)
4707 4703
4708 if (NILP (nbytes)) 4704 if (NILP (nbytes))
4709 { 4705 {
4710 read_quit = true; 4706 read_quit = 1;
4711 break; 4707 break;
4712 } 4708 }
4713 4709
@@ -4726,19 +4722,11 @@ by calling `format-decode', which see. */)
4726 4722
4727 if (this <= 0) 4723 if (this <= 0)
4728 { 4724 {
4729 how_much = this; 4725 read_quit = this;
4730 break; 4726 break;
4731 } 4727 }
4732 4728
4733 gap_size -= this; 4729 gap_size -= this;
4734
4735 /* For a regular file, where TOTAL is the real size,
4736 count HOW_MUCH to compare with it.
4737 For a special file, where TOTAL is just a buffer size,
4738 so don't bother counting in HOW_MUCH.
4739 (INSERTED is where we count the number of characters inserted.) */
4740 if (seekable || !NILP (end))
4741 how_much += this;
4742 inserted += this; 4730 inserted += this;
4743 } 4731 }
4744 } 4732 }
@@ -4759,7 +4747,7 @@ by calling `format-decode', which see. */)
4759 emacs_close (fd); 4747 emacs_close (fd);
4760 clear_unwind_protect (fd_index); 4748 clear_unwind_protect (fd_index);
4761 4749
4762 if (how_much < 0) 4750 if (read_quit < 0)
4763 report_file_error ("Read error", orig_filename); 4751 report_file_error ("Read error", orig_filename);
4764 4752
4765 notfound: 4753 notfound:
diff --git a/src/pdumper.c b/src/pdumper.c
index dbdeae9a799..baa33c4f647 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -2748,7 +2748,7 @@ dump_hash_table (struct dump_context *ctx,
2748static dump_off 2748static dump_off
2749dump_buffer (struct dump_context *ctx, const struct buffer *in_buffer) 2749dump_buffer (struct dump_context *ctx, const struct buffer *in_buffer)
2750{ 2750{
2751#if CHECK_STRUCTS && !defined HASH_buffer_DB34E5D09F 2751#if CHECK_STRUCTS && !defined HASH_buffer_85D317CE74
2752# error "buffer changed. See CHECK_STRUCTS comment in config.h." 2752# error "buffer changed. See CHECK_STRUCTS comment in config.h."
2753#endif 2753#endif
2754 struct buffer munged_buffer = *in_buffer; 2754 struct buffer munged_buffer = *in_buffer;