aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.in6
-rw-r--r--src/ccl.c115
-rw-r--r--src/charset.c9
-rw-r--r--src/coding.c12
-rw-r--r--src/comp.c150
-rw-r--r--src/comp.h2
-rw-r--r--src/composite.c4
-rw-r--r--src/emacs.c16
-rw-r--r--src/fns.c30
-rw-r--r--src/font.c74
-rw-r--r--src/fontset.c27
-rw-r--r--src/ftfont.c12
-rw-r--r--src/hbfont.c11
-rw-r--r--src/image.c71
-rw-r--r--src/lisp.h18
-rw-r--r--src/lread.c214
-rw-r--r--src/macfont.m6
-rw-r--r--src/minibuf.c2
-rw-r--r--src/nsselect.m2
-rw-r--r--src/nsterm.m23
-rw-r--r--src/nsxwidget.m4
-rw-r--r--src/pdumper.c38
-rw-r--r--src/search.c13
-rw-r--r--src/syntax.c4
-rw-r--r--src/sysdep.c35
-rw-r--r--src/timefns.c33
-rw-r--r--src/window.c2
-rw-r--r--src/xdisp.c8
-rw-r--r--src/xfaces.c28
-rw-r--r--src/xfns.c13
-rw-r--r--src/xrdb.c4
-rw-r--r--src/xselect.c21
-rw-r--r--src/xterm.c21
-rw-r--r--src/xterm.h1
-rw-r--r--src/xwidget.c4
35 files changed, 599 insertions, 434 deletions
diff --git a/src/Makefile.in b/src/Makefile.in
index 63a4aa80e93..31a5a7e7709 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -587,7 +587,7 @@ endif
587ifeq ($(DUMPING),pdumper) 587ifeq ($(DUMPING),pdumper)
588$(pdmp): emacs$(EXEEXT) 588$(pdmp): emacs$(EXEEXT)
589 LC_ALL=C $(RUN_TEMACS) -batch $(BUILD_DETAILS) -l loadup --temacs=pdump \ 589 LC_ALL=C $(RUN_TEMACS) -batch $(BUILD_DETAILS) -l loadup --temacs=pdump \
590 --bin-dest $(BIN_DESTDIR) --lisp-dest $(LISP_DESTDIR) 590 --bin-dest $(BIN_DESTDIR) --eln-dest $(ELN_DESTDIR)
591 cp -f $@ $(bootstrap_pdmp) 591 cp -f $@ $(bootstrap_pdmp)
592endif 592endif
593 593
@@ -790,10 +790,6 @@ tags: TAGS ../lisp/TAGS $(lwlibdir)/TAGS
790 @$(MAKE) $(AM_V_NO_PD) -C ../lisp EMACS="$(bootstrap_exe)"\ 790 @$(MAKE) $(AM_V_NO_PD) -C ../lisp EMACS="$(bootstrap_exe)"\
791 THEFILE=$< $<c 791 THEFILE=$< $<c
792 792
793%.eln: %.el | bootstrap-emacs$(EXEEXT) $(bootstrap_pdmp)
794 @$(MAKE) $(AM_V_NO_PD) -C ../lisp EMACS="$(bootstrap_exe)"\
795 THEFILE=$< $<n
796
797## VCSWITNESS points to the file that holds info about the current checkout. 793## VCSWITNESS points to the file that holds info about the current checkout.
798## We use it as a heuristic to decide when to rebuild loaddefs.el. 794## We use it as a heuristic to decide when to rebuild loaddefs.el.
799## If empty it is ignored; the parent makefile can set it to some other value. 795## If empty it is ignored; the parent makefile can set it to some other value.
diff --git a/src/ccl.c b/src/ccl.c
index ef059ffff25..86debeef0e5 100644
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -1142,19 +1142,52 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1142 ccl_expr_self: 1142 ccl_expr_self:
1143 switch (op) 1143 switch (op)
1144 { 1144 {
1145 case CCL_PLUS: reg[rrr] += i; break; 1145 case CCL_PLUS: INT_ADD_WRAPV (reg[rrr], i, &reg[rrr]); break;
1146 case CCL_MINUS: reg[rrr] -= i; break; 1146 case CCL_MINUS: INT_SUBTRACT_WRAPV (reg[rrr], i, &reg[rrr]); break;
1147 case CCL_MUL: reg[rrr] *= i; break; 1147 case CCL_MUL: INT_MULTIPLY_WRAPV (reg[rrr], i, &reg[rrr]); break;
1148 case CCL_DIV: reg[rrr] /= i; break; 1148 case CCL_DIV:
1149 if (!i)
1150 CCL_INVALID_CMD;
1151 if (!INT_DIVIDE_OVERFLOW (reg[rrr], i))
1152 reg[rrr] /= i;
1153 break;
1149 case CCL_MOD: reg[rrr] %= i; break; 1154 case CCL_MOD: reg[rrr] %= i; break;
1155 if (!i)
1156 CCL_INVALID_CMD;
1157 reg[rrr] = i == -1 ? 0 : reg[rrr] % i;
1158 break;
1150 case CCL_AND: reg[rrr] &= i; break; 1159 case CCL_AND: reg[rrr] &= i; break;
1151 case CCL_OR: reg[rrr] |= i; break; 1160 case CCL_OR: reg[rrr] |= i; break;
1152 case CCL_XOR: reg[rrr] ^= i; break; 1161 case CCL_XOR: reg[rrr] ^= i; break;
1153 case CCL_LSH: reg[rrr] <<= i; break; 1162 case CCL_LSH:
1154 case CCL_RSH: reg[rrr] >>= i; break; 1163 if (i < 0)
1155 case CCL_LSH8: reg[rrr] <<= 8; reg[rrr] |= i; break; 1164 CCL_INVALID_CMD;
1165 reg[rrr] = i < UINT_WIDTH ? (unsigned) reg[rrr] << i : 0;
1166 break;
1167 case CCL_RSH:
1168 if (i < 0)
1169 CCL_INVALID_CMD;
1170 reg[rrr] = reg[rrr] >> min (i, INT_WIDTH - 1);
1171 break;
1172 case CCL_LSH8:
1173 reg[rrr] = (unsigned) reg[rrr] << 8;
1174 reg[rrr] |= i;
1175 break;
1156 case CCL_RSH8: reg[7] = reg[rrr] & 0xFF; reg[rrr] >>= 8; break; 1176 case CCL_RSH8: reg[7] = reg[rrr] & 0xFF; reg[rrr] >>= 8; break;
1157 case CCL_DIVMOD: reg[7] = reg[rrr] % i; reg[rrr] /= i; break; 1177 case CCL_DIVMOD:
1178 if (!i)
1179 CCL_INVALID_CMD;
1180 if (i == -1)
1181 {
1182 reg[7] = 0;
1183 INT_SUBTRACT_WRAPV (0, reg[rrr], &reg[rrr]);
1184 }
1185 else
1186 {
1187 reg[7] = reg[rrr] % i;
1188 reg[rrr] /= i;
1189 }
1190 break;
1158 case CCL_LS: reg[rrr] = reg[rrr] < i; break; 1191 case CCL_LS: reg[rrr] = reg[rrr] < i; break;
1159 case CCL_GT: reg[rrr] = reg[rrr] > i; break; 1192 case CCL_GT: reg[rrr] = reg[rrr] > i; break;
1160 case CCL_EQ: reg[rrr] = reg[rrr] == i; break; 1193 case CCL_EQ: reg[rrr] = reg[rrr] == i; break;
@@ -1204,19 +1237,52 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1204 ccl_set_expr: 1237 ccl_set_expr:
1205 switch (op) 1238 switch (op)
1206 { 1239 {
1207 case CCL_PLUS: reg[rrr] = i + j; break; 1240 case CCL_PLUS: INT_ADD_WRAPV (i, j, &reg[rrr]); break;
1208 case CCL_MINUS: reg[rrr] = i - j; break; 1241 case CCL_MINUS: INT_SUBTRACT_WRAPV (i, j, &reg[rrr]); break;
1209 case CCL_MUL: reg[rrr] = i * j; break; 1242 case CCL_MUL: INT_MULTIPLY_WRAPV (i, j, &reg[rrr]); break;
1210 case CCL_DIV: reg[rrr] = i / j; break; 1243 case CCL_DIV:
1211 case CCL_MOD: reg[rrr] = i % j; break; 1244 if (!j)
1245 CCL_INVALID_CMD;
1246 if (!INT_DIVIDE_OVERFLOW (i, j))
1247 i /= j;
1248 reg[rrr] = i;
1249 break;
1250 case CCL_MOD:
1251 if (!j)
1252 CCL_INVALID_CMD;
1253 reg[rrr] = j == -1 ? 0 : i % j;
1254 break;
1212 case CCL_AND: reg[rrr] = i & j; break; 1255 case CCL_AND: reg[rrr] = i & j; break;
1213 case CCL_OR: reg[rrr] = i | j; break; 1256 case CCL_OR: reg[rrr] = i | j; break;
1214 case CCL_XOR: reg[rrr] = i ^ j; break; 1257 case CCL_XOR: reg[rrr] = i ^ j; break;
1215 case CCL_LSH: reg[rrr] = i << j; break; 1258 case CCL_LSH:
1216 case CCL_RSH: reg[rrr] = i >> j; break; 1259 if (j < 0)
1217 case CCL_LSH8: reg[rrr] = (i << 8) | j; break; 1260 CCL_INVALID_CMD;
1261 reg[rrr] = j < UINT_WIDTH ? (unsigned) i << j : 0;
1262 break;
1263 case CCL_RSH:
1264 if (j < 0)
1265 CCL_INVALID_CMD;
1266 reg[rrr] = i >> min (j, INT_WIDTH - 1);
1267 break;
1268 case CCL_LSH8:
1269 reg[rrr] = ((unsigned) i << 8) | j;
1270 break;
1218 case CCL_RSH8: reg[rrr] = i >> 8; reg[7] = i & 0xFF; break; 1271 case CCL_RSH8: reg[rrr] = i >> 8; reg[7] = i & 0xFF; break;
1219 case CCL_DIVMOD: reg[rrr] = i / j; reg[7] = i % j; break; 1272 case CCL_DIVMOD:
1273 if (!j)
1274 CCL_INVALID_CMD;
1275 if (j == -1)
1276 {
1277 INT_SUBTRACT_WRAPV (0, reg[rrr], &reg[rrr]);
1278 reg[7] = 0;
1279 }
1280 else
1281 {
1282 reg[rrr] = i / j;
1283 reg[7] = i % j;
1284 }
1285 break;
1220 case CCL_LS: reg[rrr] = i < j; break; 1286 case CCL_LS: reg[rrr] = i < j; break;
1221 case CCL_GT: reg[rrr] = i > j; break; 1287 case CCL_GT: reg[rrr] = i > j; break;
1222 case CCL_EQ: reg[rrr] = i == j; break; 1288 case CCL_EQ: reg[rrr] = i == j; break;
@@ -1225,7 +1291,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1225 case CCL_NE: reg[rrr] = i != j; break; 1291 case CCL_NE: reg[rrr] = i != j; break;
1226 case CCL_DECODE_SJIS: 1292 case CCL_DECODE_SJIS:
1227 { 1293 {
1228 i = (i << 8) | j; 1294 i = ((unsigned) i << 8) | j;
1229 SJIS_TO_JIS (i); 1295 SJIS_TO_JIS (i);
1230 reg[rrr] = i >> 8; 1296 reg[rrr] = i >> 8;
1231 reg[7] = i & 0xFF; 1297 reg[7] = i & 0xFF;
@@ -1233,7 +1299,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1233 } 1299 }
1234 case CCL_ENCODE_SJIS: 1300 case CCL_ENCODE_SJIS:
1235 { 1301 {
1236 i = (i << 8) | j; 1302 i = ((unsigned) i << 8) | j;
1237 JIS_TO_SJIS (i); 1303 JIS_TO_SJIS (i);
1238 reg[rrr] = i >> 8; 1304 reg[rrr] = i >> 8;
1239 reg[7] = i & 0xFF; 1305 reg[7] = i & 0xFF;
@@ -2219,15 +2285,8 @@ Return index number of the registered CCL program. */)
2219 /* Extend the table. */ 2285 /* Extend the table. */
2220 Vccl_program_table = larger_vector (Vccl_program_table, 1, -1); 2286 Vccl_program_table = larger_vector (Vccl_program_table, 1, -1);
2221 2287
2222 { 2288 ASET (Vccl_program_table, idx,
2223 Lisp_Object elt = make_uninit_vector (4); 2289 CALLN (Fvector, name, ccl_prog, resolved, Qt));
2224
2225 ASET (elt, 0, name);
2226 ASET (elt, 1, ccl_prog);
2227 ASET (elt, 2, resolved);
2228 ASET (elt, 3, Qt);
2229 ASET (Vccl_program_table, idx, elt);
2230 }
2231 2290
2232 Fput (name, Qccl_program_idx, make_fixnum (idx)); 2291 Fput (name, Qccl_program_idx, make_fixnum (idx));
2233 return make_fixnum (idx); 2292 return make_fixnum (idx);
diff --git a/src/charset.c b/src/charset.c
index 8635aad3ed6..520dd3a9605 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1035,12 +1035,9 @@ usage: (define-charset-internal ...) */)
1035 CHECK_FIXNAT (parent_max_code); 1035 CHECK_FIXNAT (parent_max_code);
1036 parent_code_offset = Fnth (make_fixnum (3), val); 1036 parent_code_offset = Fnth (make_fixnum (3), val);
1037 CHECK_FIXNUM (parent_code_offset); 1037 CHECK_FIXNUM (parent_code_offset);
1038 val = make_uninit_vector (4); 1038 ASET (attrs, charset_subset,
1039 ASET (val, 0, make_fixnum (parent_charset->id)); 1039 CALLN (Fvector, make_fixnum (parent_charset->id),
1040 ASET (val, 1, parent_min_code); 1040 parent_min_code, parent_max_code, parent_code_offset));
1041 ASET (val, 2, parent_max_code);
1042 ASET (val, 3, parent_code_offset);
1043 ASET (attrs, charset_subset, val);
1044 1041
1045 charset.method = CHARSET_METHOD_SUBSET; 1042 charset.method = CHARSET_METHOD_SUBSET;
1046 /* Here, we just copy the parent's fast_map. It's not accurate, 1043 /* Here, we just copy the parent's fast_map. It's not accurate,
diff --git a/src/coding.c b/src/coding.c
index 071124b4ef1..51bd441de9d 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -10856,20 +10856,17 @@ HIGHESTP non-nil means just return the highest priority one. */)
10856 return Fnreverse (val); 10856 return Fnreverse (val);
10857} 10857}
10858 10858
10859static const char *const suffixes[] = { "-unix", "-dos", "-mac" };
10860
10861static Lisp_Object 10859static Lisp_Object
10862make_subsidiaries (Lisp_Object base) 10860make_subsidiaries (Lisp_Object base)
10863{ 10861{
10864 Lisp_Object subsidiaries; 10862 static char const suffixes[][8] = { "-unix", "-dos", "-mac" };
10865 ptrdiff_t base_name_len = SBYTES (SYMBOL_NAME (base)); 10863 ptrdiff_t base_name_len = SBYTES (SYMBOL_NAME (base));
10866 USE_SAFE_ALLOCA; 10864 USE_SAFE_ALLOCA;
10867 char *buf = SAFE_ALLOCA (base_name_len + 6); 10865 char *buf = SAFE_ALLOCA (base_name_len + 6);
10868 int i;
10869 10866
10870 memcpy (buf, SDATA (SYMBOL_NAME (base)), base_name_len); 10867 memcpy (buf, SDATA (SYMBOL_NAME (base)), base_name_len);
10871 subsidiaries = make_uninit_vector (3); 10868 Lisp_Object subsidiaries = make_nil_vector (3);
10872 for (i = 0; i < 3; i++) 10869 for (int i = 0; i < 3; i++)
10873 { 10870 {
10874 strcpy (buf + base_name_len, suffixes[i]); 10871 strcpy (buf + base_name_len, suffixes[i]);
10875 ASET (subsidiaries, i, intern (buf)); 10872 ASET (subsidiaries, i, intern (buf));
@@ -11829,8 +11826,7 @@ Each element is one element list of coding system name.
11829This variable is given to `completing-read' as COLLECTION argument. 11826This variable is given to `completing-read' as COLLECTION argument.
11830 11827
11831Do not alter the value of this variable manually. This variable should be 11828Do not alter the value of this variable manually. This variable should be
11832updated by the functions `make-coding-system' and 11829updated by `define-coding-system-alias'. */);
11833`define-coding-system-alias'. */);
11834 Vcoding_system_alist = Qnil; 11830 Vcoding_system_alist = Qnil;
11835 11831
11836 DEFVAR_LISP ("coding-category-list", Vcoding_category_list, 11832 DEFVAR_LISP ("coding-category-list", Vcoding_category_list,
diff --git a/src/comp.c b/src/comp.c
index 704bd4b6b35..ff73245b8de 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -29,6 +29,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
29#include <stdio.h> 29#include <stdio.h>
30#include <signal.h> 30#include <signal.h>
31#include <libgccjit.h> 31#include <libgccjit.h>
32#include <epaths.h>
32 33
33#include "puresize.h" 34#include "puresize.h"
34#include "window.h" 35#include "window.h"
@@ -393,6 +394,8 @@ load_gccjit_if_necessary (bool mandatory)
393} 394}
394 395
395 396
397#define ELN_FILENAME_HASH_LEN 64
398
396/* C symbols emitted for the load relocation mechanism. */ 399/* C symbols emitted for the load relocation mechanism. */
397#define CURRENT_THREAD_RELOC_SYM "current_thread_reloc" 400#define CURRENT_THREAD_RELOC_SYM "current_thread_reloc"
398#define PURE_RELOC_SYM "pure_reloc" 401#define PURE_RELOC_SYM "pure_reloc"
@@ -634,6 +637,16 @@ format_string (const char *format, ...)
634 return scratch_area; 637 return scratch_area;
635} 638}
636 639
640static Lisp_Object
641comp_hash_string (Lisp_Object string)
642{
643 Lisp_Object digest = make_uninit_string (SHA512_DIGEST_SIZE * 2);
644 sha512_buffer (SSDATA (string), SCHARS (string), SSDATA (digest));
645 hexbuf_digest (SSDATA (digest), SDATA (digest), SHA512_DIGEST_SIZE);
646
647 return digest;
648}
649
637/* Produce a key hashing Vcomp_subr_list. */ 650/* Produce a key hashing Vcomp_subr_list. */
638 651
639void 652void
@@ -641,10 +654,7 @@ hash_native_abi (void)
641{ 654{
642 Lisp_Object string = Fmapconcat (intern_c_string ("subr-name"), 655 Lisp_Object string = Fmapconcat (intern_c_string ("subr-name"),
643 Vcomp_subr_list, build_string (" ")); 656 Vcomp_subr_list, build_string (" "));
644 Lisp_Object digest = make_uninit_string (SHA512_DIGEST_SIZE * 2); 657 Lisp_Object digest = comp_hash_string (string);
645
646 sha512_buffer (SSDATA (string), SCHARS (string), SSDATA (digest));
647 hexbuf_digest (SSDATA (digest), SDATA (digest), SHA512_DIGEST_SIZE);
648 658
649 /* Check runs once. */ 659 /* Check runs once. */
650 eassert (NILP (Vcomp_abi_hash)); 660 eassert (NILP (Vcomp_abi_hash));
@@ -652,8 +662,7 @@ hash_native_abi (void)
652 /* If 10 characters are usually sufficient for git I guess 16 are 662 /* If 10 characters are usually sufficient for git I guess 16 are
653 fine for us here. */ 663 fine for us here. */
654 Vcomp_native_path_postfix = 664 Vcomp_native_path_postfix =
655 concat3 (make_string ("eln-", 4), 665 concat2 (Vsystem_configuration,
656 Vsystem_configuration,
657 concat2 (make_string ("-", 1), 666 concat2 (make_string ("-", 1),
658 Fsubstring_no_properties (Vcomp_abi_hash, 667 Fsubstring_no_properties (Vcomp_abi_hash,
659 make_fixnum (0), 668 make_fixnum (0),
@@ -3852,6 +3861,71 @@ compile_function (Lisp_Object func)
3852/* Entry points exposed to lisp. */ 3861/* Entry points exposed to lisp. */
3853/**********************************/ 3862/**********************************/
3854 3863
3864/* In use by Fcomp_el_to_eln_filename. */
3865static Lisp_Object loadsearch_re_list;
3866
3867DEFUN ("comp-el-to-eln-filename", Fcomp_el_to_eln_filename,
3868 Scomp_el_to_eln_filename, 1, 2, 0,
3869 doc: /* Given a source file return the corresponding .eln true filename.
3870If BASE-DIR is nil use the first entry in `comp-eln-load-path'. */)
3871 (Lisp_Object filename, Lisp_Object base_dir)
3872{
3873 CHECK_STRING (filename);
3874
3875 if (suffix_p (filename, ".gz"))
3876 filename = Fsubstring (filename, Qnil, make_fixnum (-3));
3877 filename = Fexpand_file_name (filename, Qnil);
3878
3879 /* We create eln filenames with an hash in order to look-up these
3880 starting from the source filename, IOW have a relation
3881 /absolute/path/filename.el -> eln-cache/filename-hash.eln.
3882
3883 As installing .eln files compiled during the build changes their
3884 absolute path we need an hashing mechanism that is not sensitive
3885 to that. For this we replace if match PATH_DUMPLOADSEARCH or
3886 PATH_LOADSEARCH with '//' before generating the hash.
3887
3888 Another approach would be to hash using the source file content
3889 but this may have a measurable performance impact. */
3890
3891 if (NILP (loadsearch_re_list))
3892 {
3893 Lisp_Object loadsearch_list =
3894 Fcons (build_string (PATH_DUMPLOADSEARCH),
3895 Fcons (build_string (PATH_LOADSEARCH), Qnil));
3896 FOR_EACH_TAIL (loadsearch_list)
3897 loadsearch_re_list =
3898 Fcons (Fregexp_quote (XCAR (loadsearch_list)), loadsearch_re_list);
3899 }
3900 Lisp_Object loadsearch_res = loadsearch_re_list;
3901 FOR_EACH_TAIL (loadsearch_res)
3902 {
3903 Lisp_Object match_idx =
3904 Fstring_match (XCAR (loadsearch_res), filename, Qnil);
3905 if (EQ (match_idx, make_fixnum (0)))
3906 {
3907 filename =
3908 Freplace_match (build_string ("//"), Qt, Qt, filename, Qnil);
3909 break;
3910 }
3911 }
3912
3913 Lisp_Object hash = Fsubstring (comp_hash_string (filename), Qnil,
3914 make_fixnum (ELN_FILENAME_HASH_LEN));
3915 filename = concat2 (Ffile_name_nondirectory (Fsubstring (filename, Qnil,
3916 make_fixnum (-3))),
3917 build_string ("-"));
3918 filename = concat3 (filename, hash, build_string (NATIVE_ELISP_SUFFIX));
3919 if (NILP (base_dir))
3920 base_dir = XCAR (Vcomp_eln_load_path);
3921
3922 if (!file_name_absolute_p (SSDATA (base_dir)))
3923 base_dir = Fexpand_file_name (base_dir, Vinvocation_directory);
3924
3925 return Fexpand_file_name (filename,
3926 concat2 (base_dir, Vcomp_native_path_postfix));
3927}
3928
3855DEFUN ("comp--init-ctxt", Fcomp__init_ctxt, Scomp__init_ctxt, 3929DEFUN ("comp--init-ctxt", Fcomp__init_ctxt, Scomp__init_ctxt,
3856 0, 0, 0, 3930 0, 0, 0,
3857 doc: /* Initialize the native compiler context. Return t on success. */) 3931 doc: /* Initialize the native compiler context. Return t on success. */)
@@ -4039,11 +4113,12 @@ DEFUN ("comp--compile-ctxt-to-file", Fcomp__compile_ctxt_to_file,
4039 Scomp__compile_ctxt_to_file, 4113 Scomp__compile_ctxt_to_file,
4040 1, 1, 0, 4114 1, 1, 0,
4041 doc: /* Compile as native code the current context to file. */) 4115 doc: /* Compile as native code the current context to file. */)
4042 (Lisp_Object base_name) 4116 (Lisp_Object file_name)
4043{ 4117{
4044 load_gccjit_if_necessary (true); 4118 load_gccjit_if_necessary (true);
4045 4119
4046 CHECK_STRING (base_name); 4120 CHECK_STRING (file_name);
4121 Lisp_Object base_name = Fsubstring (file_name, Qnil, make_fixnum (-4));
4047 4122
4048 gcc_jit_context_set_int_option (comp.ctxt, 4123 gcc_jit_context_set_int_option (comp.ctxt,
4049 GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL, 4124 GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL,
@@ -4105,19 +4180,18 @@ DEFUN ("comp--compile-ctxt-to-file", Fcomp__compile_ctxt_to_file,
4105 4180
4106 AUTO_STRING (dot_so, NATIVE_ELISP_SUFFIX); 4181 AUTO_STRING (dot_so, NATIVE_ELISP_SUFFIX);
4107 4182
4108 Lisp_Object out_file = CALLN (Fconcat, base_name, dot_so);
4109 Lisp_Object tmp_file = 4183 Lisp_Object tmp_file =
4110 Fmake_temp_file_internal (base_name, Qnil, dot_so, Qnil); 4184 Fmake_temp_file_internal (base_name, Qnil, dot_so, Qnil);
4111 gcc_jit_context_compile_to_file (comp.ctxt, 4185 gcc_jit_context_compile_to_file (comp.ctxt,
4112 GCC_JIT_OUTPUT_KIND_DYNAMIC_LIBRARY, 4186 GCC_JIT_OUTPUT_KIND_DYNAMIC_LIBRARY,
4113 SSDATA (tmp_file)); 4187 SSDATA (tmp_file));
4114 4188
4115 CALL2I (comp--replace-output-file, out_file, tmp_file); 4189 CALL2I (comp--replace-output-file, file_name, tmp_file);
4116 4190
4117 if (!noninteractive) 4191 if (!noninteractive)
4118 unbind_to (count, Qnil); 4192 unbind_to (count, Qnil);
4119 4193
4120 return out_file; 4194 return file_name;
4121} 4195}
4122 4196
4123DEFUN ("comp-libgccjit-version", Fcomp_libgccjit_version, 4197DEFUN ("comp-libgccjit-version", Fcomp_libgccjit_version,
@@ -4462,7 +4536,11 @@ maybe_defer_native_compilation (Lisp_Object function_name,
4462 concat2 (CALL1I (file-name-sans-extension, Vload_true_file_name), 4536 concat2 (CALL1I (file-name-sans-extension, Vload_true_file_name),
4463 build_pure_c_string (".el")); 4537 build_pure_c_string (".el"));
4464 if (NILP (Ffile_exists_p (src))) 4538 if (NILP (Ffile_exists_p (src)))
4465 return; 4539 {
4540 src = concat2 (src, build_pure_c_string (".gz"));
4541 if (NILP (Ffile_exists_p (src)))
4542 return;
4543 }
4466 4544
4467 /* This is to have deferred compilaiton able to compile comp 4545 /* This is to have deferred compilaiton able to compile comp
4468 dependecies breaking circularity. */ 4546 dependecies breaking circularity. */
@@ -4497,6 +4575,27 @@ maybe_defer_native_compilation (Lisp_Object function_name,
4497/* Functions used to load eln files. */ 4575/* Functions used to load eln files. */
4498/**************************************/ 4576/**************************************/
4499 4577
4578/* Fixup the system eln-cache dir. This is the last entry in
4579 `comp-eln-load-path'. */
4580void
4581fixup_eln_load_path (Lisp_Object directory)
4582{
4583 Lisp_Object last_cell = Qnil;
4584 Lisp_Object tmp = Vcomp_eln_load_path;
4585 FOR_EACH_TAIL (tmp)
4586 if (CONSP (tmp))
4587 last_cell = tmp;
4588
4589 Lisp_Object eln_cache_sys =
4590 Ffile_name_directory (concat2 (Vinvocation_directory,
4591 directory));
4592 /* One directory up... */
4593 eln_cache_sys =
4594 Ffile_name_directory (Fsubstring (eln_cache_sys, Qnil,
4595 make_fixnum (-1)));
4596 Fsetcar (last_cell, eln_cache_sys);
4597}
4598
4500typedef char *(*comp_lit_str_func) (void); 4599typedef char *(*comp_lit_str_func) (void);
4501 4600
4502/* Deserialize read and return static object. */ 4601/* Deserialize read and return static object. */
@@ -4869,7 +4968,13 @@ syms_of_comp (void)
4869#ifdef HAVE_NATIVE_COMP 4968#ifdef HAVE_NATIVE_COMP
4870 /* Compiler control customizes. */ 4969 /* Compiler control customizes. */
4871 DEFVAR_BOOL ("comp-deferred-compilation", comp_deferred_compilation, 4970 DEFVAR_BOOL ("comp-deferred-compilation", comp_deferred_compilation,
4872 doc: /* If t compile asyncronously every .elc file loaded. */); 4971 doc: /* If non-nil compile asyncronously all .elc files
4972being loaded.
4973
4974Once compilation happened each function definition is updated to the
4975native compiled one. */);
4976 comp_deferred_compilation = true;
4977
4873 DEFSYM (Qcomp_speed, "comp-speed"); 4978 DEFSYM (Qcomp_speed, "comp-speed");
4874 DEFSYM (Qcomp_debug, "comp-debug"); 4979 DEFSYM (Qcomp_debug, "comp-debug");
4875 4980
@@ -4971,6 +5076,7 @@ syms_of_comp (void)
4971 build_pure_c_string ("eln file inconsistent with current runtime " 5076 build_pure_c_string ("eln file inconsistent with current runtime "
4972 "configuration, please recompile")); 5077 "configuration, please recompile"));
4973 5078
5079 defsubr (&Scomp_el_to_eln_filename);
4974 defsubr (&Scomp__init_ctxt); 5080 defsubr (&Scomp__init_ctxt);
4975 defsubr (&Scomp__release_ctxt); 5081 defsubr (&Scomp__release_ctxt);
4976 defsubr (&Scomp__compile_ctxt_to_file); 5082 defsubr (&Scomp__compile_ctxt_to_file);
@@ -4989,6 +5095,8 @@ syms_of_comp (void)
4989 comp.emitter_dispatcher = Qnil; 5095 comp.emitter_dispatcher = Qnil;
4990 staticpro (&delayed_sources); 5096 staticpro (&delayed_sources);
4991 delayed_sources = Qnil; 5097 delayed_sources = Qnil;
5098 staticpro (&loadsearch_re_list);
5099 loadsearch_re_list = Qnil;
4992 5100
4993#ifdef WINDOWSNT 5101#ifdef WINDOWSNT
4994 staticpro (&all_loaded_comp_units_h); 5102 staticpro (&all_loaded_comp_units_h);
@@ -5015,6 +5123,22 @@ syms_of_comp (void)
5015 internal use during */); 5123 internal use during */);
5016 Vcomp_deferred_pending_h = CALLN (Fmake_hash_table, QCtest, Qeq); 5124 Vcomp_deferred_pending_h = CALLN (Fmake_hash_table, QCtest, Qeq);
5017 5125
5126 DEFVAR_LISP ("comp-eln-to-el-h", Vcomp_eln_to_el_h,
5127 doc: /* Hash table eln-filename -> el-filename. */);
5128 Vcomp_eln_to_el_h = CALLN (Fmake_hash_table, QCtest, Qequal);
5129
5130 DEFVAR_LISP ("comp-eln-load-path", Vcomp_eln_load_path,
5131 doc: /* List of eln cache directories.
5132
5133If a directory is non absolute is assumed to be relative to
5134`invocation-directory'.
5135The last directory of this list is assumed to be the system one. */);
5136
5137 /* Temporary value in use for boostrap. We can't do better as
5138 `invocation-directory' is still unset, will be fixed up during
5139 dump reload. */
5140 Vcomp_eln_load_path = Fcons (build_string ("../eln-cache/"), Qnil);
5141
5018#endif /* #ifdef HAVE_NATIVE_COMP */ 5142#endif /* #ifdef HAVE_NATIVE_COMP */
5019 5143
5020 defsubr (&Snative_comp_available_p); 5144 defsubr (&Snative_comp_available_p);
diff --git a/src/comp.h b/src/comp.h
index 687e426b1ef..9270f8bf664 100644
--- a/src/comp.h
+++ b/src/comp.h
@@ -101,6 +101,8 @@ extern void dispose_all_remaining_comp_units (void);
101 101
102extern void clean_package_user_dir_of_old_comp_units (void); 102extern void clean_package_user_dir_of_old_comp_units (void);
103 103
104extern void fixup_eln_load_path (Lisp_Object directory);
105
104#else /* #ifdef HAVE_NATIVE_COMP */ 106#else /* #ifdef HAVE_NATIVE_COMP */
105 107
106static inline void 108static inline void
diff --git a/src/composite.c b/src/composite.c
index ec2b8328f78..984e0d9cda8 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -1258,7 +1258,7 @@ composition_reseat_it (struct composition_it *cmp_it, ptrdiff_t charpos,
1258 is backward in the buffer, which can only happen if the 1258 is backward in the buffer, which can only happen if the
1259 display routines were called to perform the bidi 1259 display routines were called to perform the bidi
1260 reordering. But it doesn't harm to test for that, and 1260 reordering. But it doesn't harm to test for that, and
1261 avoid someon raising their brows and thinking it's a 1261 avoid someone raising their brows and thinking it's a
1262 subtle bug... */ 1262 subtle bug... */
1263 if (bidi_level < 0) 1263 if (bidi_level < 0)
1264 direction = Qnil; 1264 direction = Qnil;
@@ -1939,7 +1939,7 @@ syms_of_composite (void)
1939 staticpro (&gstring_hash_table); 1939 staticpro (&gstring_hash_table);
1940 1940
1941 staticpro (&gstring_work_headers); 1941 staticpro (&gstring_work_headers);
1942 gstring_work_headers = make_uninit_vector (8); 1942 gstring_work_headers = make_nil_vector (8);
1943 for (i = 0; i < 8; i++) 1943 for (i = 0; i < 8; i++)
1944 ASET (gstring_work_headers, i, make_nil_vector (i + 2)); 1944 ASET (gstring_work_headers, i, make_nil_vector (i + 2));
1945 staticpro (&gstring_work); 1945 staticpro (&gstring_work);
diff --git a/src/emacs.c b/src/emacs.c
index 288ddb47bd7..8e52da75926 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1643,23 +1643,27 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1643 { 1643 {
1644#ifdef NS_IMPL_COCOA 1644#ifdef NS_IMPL_COCOA
1645 /* Started from GUI? */ 1645 /* Started from GUI? */
1646 /* FIXME: Do the right thing if get_homedir returns "", or if 1646 bool go_home = (!ch_to_dir && !inhibit_window_system
1647 chdir fails. */ 1647 && !isatty (STDIN_FILENO));
1648 if (! inhibit_window_system && ! isatty (STDIN_FILENO) && ! ch_to_dir)
1649 chdir (get_homedir ());
1650 if (skip_args < argc) 1648 if (skip_args < argc)
1651 { 1649 {
1652 if (!strncmp (argv[skip_args], "-psn", 4)) 1650 if (!strncmp (argv[skip_args], "-psn", 4))
1653 { 1651 {
1654 skip_args += 1; 1652 skip_args += 1;
1655 if (! ch_to_dir) chdir (get_homedir ()); 1653 go_home |= !ch_to_dir;
1656 } 1654 }
1657 else if (skip_args+1 < argc && !strncmp (argv[skip_args+1], "-psn", 4)) 1655 else if (skip_args+1 < argc && !strncmp (argv[skip_args+1], "-psn", 4))
1658 { 1656 {
1659 skip_args += 2; 1657 skip_args += 2;
1660 if (! ch_to_dir) chdir (get_homedir ()); 1658 go_home |= !ch_to_dir;
1661 } 1659 }
1662 } 1660 }
1661 if (go_home)
1662 {
1663 char const *home = get_homedir ();
1664 if (*home && chdir (home) == 0)
1665 emacs_wd = emacs_get_current_dir_name ();
1666 }
1663#endif /* COCOA */ 1667#endif /* COCOA */
1664 } 1668 }
1665#endif /* HAVE_NS */ 1669#endif /* HAVE_NS */
diff --git a/src/fns.c b/src/fns.c
index 91991782124..a3b8d6ef57d 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -1747,25 +1747,27 @@ changing the value of a sequence `foo'. */)
1747{ 1747{
1748 if (VECTORP (seq)) 1748 if (VECTORP (seq))
1749 { 1749 {
1750 ptrdiff_t i, n; 1750 ptrdiff_t n = 0;
1751 ptrdiff_t size = ASIZE (seq);
1752 USE_SAFE_ALLOCA;
1753 Lisp_Object *kept = SAFE_ALLOCA (size * sizeof *kept);
1751 1754
1752 for (i = n = 0; i < ASIZE (seq); ++i) 1755 for (ptrdiff_t i = 0; i < size; i++)
1753 if (NILP (Fequal (AREF (seq, i), elt)))
1754 ++n;
1755
1756 if (n != ASIZE (seq))
1757 { 1756 {
1758 struct Lisp_Vector *p = allocate_vector (n); 1757 kept[n] = AREF (seq, i);
1758 n += NILP (Fequal (AREF (seq, i), elt));
1759 }
1759 1760
1760 for (i = n = 0; i < ASIZE (seq); ++i) 1761 if (n != size)
1761 if (NILP (Fequal (AREF (seq, i), elt))) 1762 seq = Fvector (n, kept);
1762 p->contents[n++] = AREF (seq, i);
1763 1763
1764 XSETVECTOR (seq, p); 1764 SAFE_FREE ();
1765 }
1766 } 1765 }
1767 else if (STRINGP (seq)) 1766 else if (STRINGP (seq))
1768 { 1767 {
1768 if (!CHARACTERP (elt))
1769 return seq;
1770
1769 ptrdiff_t i, ibyte, nchars, nbytes, cbytes; 1771 ptrdiff_t i, ibyte, nchars, nbytes, cbytes;
1770 int c; 1772 int c;
1771 1773
@@ -1784,7 +1786,7 @@ changing the value of a sequence `foo'. */)
1784 cbytes = 1; 1786 cbytes = 1;
1785 } 1787 }
1786 1788
1787 if (!FIXNUMP (elt) || c != XFIXNUM (elt)) 1789 if (c != XFIXNUM (elt))
1788 { 1790 {
1789 ++nchars; 1791 ++nchars;
1790 nbytes += cbytes; 1792 nbytes += cbytes;
@@ -1814,7 +1816,7 @@ changing the value of a sequence `foo'. */)
1814 cbytes = 1; 1816 cbytes = 1;
1815 } 1817 }
1816 1818
1817 if (!FIXNUMP (elt) || c != XFIXNUM (elt)) 1819 if (c != XFIXNUM (elt))
1818 { 1820 {
1819 unsigned char *from = SDATA (seq) + ibyte; 1821 unsigned char *from = SDATA (seq) + ibyte;
1820 unsigned char *to = SDATA (tem) + nbytes; 1822 unsigned char *to = SDATA (tem) + nbytes;
diff --git a/src/font.c b/src/font.c
index ab00402b40b..5c01c7ff796 100644
--- a/src/font.c
+++ b/src/font.c
@@ -4847,21 +4847,18 @@ If the font is not OpenType font, CAPABILITY is nil. */)
4847 (Lisp_Object font_object) 4847 (Lisp_Object font_object)
4848{ 4848{
4849 struct font *font = CHECK_FONT_GET_OBJECT (font_object); 4849 struct font *font = CHECK_FONT_GET_OBJECT (font_object);
4850 Lisp_Object val = make_uninit_vector (9); 4850 return CALLN (Fvector,
4851 4851 AREF (font_object, FONT_NAME_INDEX),
4852 ASET (val, 0, AREF (font_object, FONT_NAME_INDEX)); 4852 AREF (font_object, FONT_FILE_INDEX),
4853 ASET (val, 1, AREF (font_object, FONT_FILE_INDEX)); 4853 make_fixnum (font->pixel_size),
4854 ASET (val, 2, make_fixnum (font->pixel_size)); 4854 make_fixnum (font->max_width),
4855 ASET (val, 3, make_fixnum (font->max_width)); 4855 make_fixnum (font->ascent),
4856 ASET (val, 4, make_fixnum (font->ascent)); 4856 make_fixnum (font->descent),
4857 ASET (val, 5, make_fixnum (font->descent)); 4857 make_fixnum (font->space_width),
4858 ASET (val, 6, make_fixnum (font->space_width)); 4858 make_fixnum (font->average_width),
4859 ASET (val, 7, make_fixnum (font->average_width)); 4859 (font->driver->otf_capability
4860 if (font->driver->otf_capability) 4860 ? Fcons (Qopentype, font->driver->otf_capability (font))
4861 ASET (val, 8, Fcons (Qopentype, font->driver->otf_capability (font))); 4861 : Qnil));
4862 else
4863 ASET (val, 8, Qnil);
4864 return val;
4865} 4862}
4866 4863
4867DEFUN ("font-get-glyphs", Ffont_get_glyphs, Sfont_get_glyphs, 3, 4, 0, 4864DEFUN ("font-get-glyphs", Ffont_get_glyphs, Sfont_get_glyphs, 3, 4, 0,
@@ -4889,7 +4886,7 @@ the corresponding element is nil. */)
4889{ 4886{
4890 struct font *font = CHECK_FONT_GET_OBJECT (font_object); 4887 struct font *font = CHECK_FONT_GET_OBJECT (font_object);
4891 ptrdiff_t len; 4888 ptrdiff_t len;
4892 Lisp_Object *chars, vec; 4889 Lisp_Object *chars;
4893 USE_SAFE_ALLOCA; 4890 USE_SAFE_ALLOCA;
4894 4891
4895 if (NILP (object)) 4892 if (NILP (object))
@@ -4957,7 +4954,7 @@ the corresponding element is nil. */)
4957 else 4954 else
4958 wrong_type_argument (Qarrayp, object); 4955 wrong_type_argument (Qarrayp, object);
4959 4956
4960 vec = make_uninit_vector (len); 4957 Lisp_Object vec = make_nil_vector (len);
4961 for (ptrdiff_t i = 0; i < len; i++) 4958 for (ptrdiff_t i = 0; i < len; i++)
4962 { 4959 {
4963 Lisp_Object g; 4960 Lisp_Object g;
@@ -5168,24 +5165,23 @@ If the named font cannot be opened and loaded, return nil. */)
5168 return Qnil; 5165 return Qnil;
5169 font = XFONT_OBJECT (font_object); 5166 font = XFONT_OBJECT (font_object);
5170 5167
5171 info = make_uninit_vector (14); 5168 info = CALLN (Fvector,
5172 ASET (info, 0, AREF (font_object, FONT_NAME_INDEX)); 5169 AREF (font_object, FONT_NAME_INDEX),
5173 ASET (info, 1, AREF (font_object, FONT_FULLNAME_INDEX)); 5170 AREF (font_object, FONT_FULLNAME_INDEX),
5174 ASET (info, 2, make_fixnum (font->pixel_size)); 5171 make_fixnum (font->pixel_size),
5175 ASET (info, 3, make_fixnum (font->height)); 5172 make_fixnum (font->height),
5176 ASET (info, 4, make_fixnum (font->baseline_offset)); 5173 make_fixnum (font->baseline_offset),
5177 ASET (info, 5, make_fixnum (font->relative_compose)); 5174 make_fixnum (font->relative_compose),
5178 ASET (info, 6, make_fixnum (font->default_ascent)); 5175 make_fixnum (font->default_ascent),
5179 ASET (info, 7, make_fixnum (font->max_width)); 5176 make_fixnum (font->max_width),
5180 ASET (info, 8, make_fixnum (font->ascent)); 5177 make_fixnum (font->ascent),
5181 ASET (info, 9, make_fixnum (font->descent)); 5178 make_fixnum (font->descent),
5182 ASET (info, 10, make_fixnum (font->space_width)); 5179 make_fixnum (font->space_width),
5183 ASET (info, 11, make_fixnum (font->average_width)); 5180 make_fixnum (font->average_width),
5184 ASET (info, 12, AREF (font_object, FONT_FILE_INDEX)); 5181 AREF (font_object, FONT_FILE_INDEX),
5185 if (font->driver->otf_capability) 5182 (font->driver->otf_capability
5186 ASET (info, 13, Fcons (Qopentype, font->driver->otf_capability (font))); 5183 ? Fcons (Qopentype, font->driver->otf_capability (font))
5187 else 5184 : Qnil));
5188 ASET (info, 13, Qnil);
5189 5185
5190#if 0 5186#if 0
5191 /* As font_object is still in FONT_OBJLIST of the entity, we can't 5187 /* As font_object is still in FONT_OBJLIST of the entity, we can't
@@ -5203,7 +5199,7 @@ If the named font cannot be opened and loaded, return nil. */)
5203static Lisp_Object 5199static Lisp_Object
5204build_style_table (const struct table_entry *entry, int nelement) 5200build_style_table (const struct table_entry *entry, int nelement)
5205{ 5201{
5206 Lisp_Object table = make_uninit_vector (nelement); 5202 Lisp_Object table = make_nil_vector (nelement);
5207 for (int i = 0; i < nelement; i++) 5203 for (int i = 0; i < nelement; i++)
5208 { 5204 {
5209 int j; 5205 int j;
@@ -5494,10 +5490,8 @@ This variable cannot be set; trying to do so will signal an error. */);
5494 make_symbol_constant (intern_c_string ("font-width-table")); 5490 make_symbol_constant (intern_c_string ("font-width-table"));
5495 5491
5496 staticpro (&font_style_table); 5492 staticpro (&font_style_table);
5497 font_style_table = make_uninit_vector (3); 5493 font_style_table = CALLN (Fvector, Vfont_weight_table, Vfont_slant_table,
5498 ASET (font_style_table, 0, Vfont_weight_table); 5494 Vfont_width_table);
5499 ASET (font_style_table, 1, Vfont_slant_table);
5500 ASET (font_style_table, 2, Vfont_width_table);
5501 5495
5502 DEFVAR_LISP ("font-log", Vfont_log, doc: /* 5496 DEFVAR_LISP ("font-log", Vfont_log, doc: /*
5503A list that logs font-related actions and results, for debugging. 5497A list that logs font-related actions and results, for debugging.
diff --git a/src/fontset.c b/src/fontset.c
index c2bb8b21f26..8c86075c07e 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -252,14 +252,13 @@ set_fontset_fallback (Lisp_Object fontset, Lisp_Object fallback)
252 252
253#define BASE_FONTSET_P(fontset) (NILP (FONTSET_BASE (fontset))) 253#define BASE_FONTSET_P(fontset) (NILP (FONTSET_BASE (fontset)))
254 254
255/* Macros for FONT-DEF and RFONT-DEF of fontset. */ 255/* Definitions for FONT-DEF and RFONT-DEF of fontset. */
256#define FONT_DEF_NEW(font_def, font_spec, encoding, repertory) \ 256static Lisp_Object
257 do { \ 257font_def_new (Lisp_Object font_spec, Lisp_Object encoding,
258 (font_def) = make_uninit_vector (3); \ 258 Lisp_Object repertory)
259 ASET ((font_def), 0, font_spec); \ 259{
260 ASET ((font_def), 1, encoding); \ 260 return CALLN (Fvector, font_spec, encoding, repertory);
261 ASET ((font_def), 2, repertory); \ 261}
262 } while (0)
263 262
264#define FONT_DEF_SPEC(font_def) AREF (font_def, 0) 263#define FONT_DEF_SPEC(font_def) AREF (font_def, 0)
265#define FONT_DEF_ENCODING(font_def) AREF (font_def, 1) 264#define FONT_DEF_ENCODING(font_def) AREF (font_def, 1)
@@ -1547,7 +1546,7 @@ appended. By default, FONT-SPEC overrides the previous settings. */)
1547 repertory = CHARSET_SYMBOL_ID (repertory); 1546 repertory = CHARSET_SYMBOL_ID (repertory);
1548 } 1547 }
1549 } 1548 }
1550 FONT_DEF_NEW (font_def, font_spec, encoding, repertory); 1549 font_def = font_def_new (font_spec, encoding, repertory);
1551 } 1550 }
1552 else 1551 else
1553 font_def = Qnil; 1552 font_def = Qnil;
@@ -1619,14 +1618,8 @@ appended. By default, FONT-SPEC overrides the previous settings. */)
1619 1618
1620 if (charset) 1619 if (charset)
1621 { 1620 {
1622 Lisp_Object arg; 1621 Lisp_Object arg = CALLN (Fvector, fontset, font_def, add,
1623 1622 ascii_changed ? Qt : Qnil, range_list);
1624 arg = make_uninit_vector (5);
1625 ASET (arg, 0, fontset);
1626 ASET (arg, 1, font_def);
1627 ASET (arg, 2, add);
1628 ASET (arg, 3, ascii_changed ? Qt : Qnil);
1629 ASET (arg, 4, range_list);
1630 1623
1631 map_charset_chars (set_fontset_font, Qnil, arg, charset, 1624 map_charset_chars (set_fontset_font, Qnil, arg, charset,
1632 CHARSET_MIN_CODE (charset), 1625 CHARSET_MIN_CODE (charset),
diff --git a/src/ftfont.c b/src/ftfont.c
index 696f5e65341..a904007a329 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -2826,14 +2826,10 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font,
2826 LGLYPH_SET_ASCENT (lglyph, g->g.ascent >> 6); 2826 LGLYPH_SET_ASCENT (lglyph, g->g.ascent >> 6);
2827 LGLYPH_SET_DESCENT (lglyph, g->g.descent >> 6); 2827 LGLYPH_SET_DESCENT (lglyph, g->g.descent >> 6);
2828 if (g->g.adjusted) 2828 if (g->g.adjusted)
2829 { 2829 LGLYPH_SET_ADJUSTMENT (lglyph, CALLN (Fvector,
2830 Lisp_Object vec = make_uninit_vector (3); 2830 make_fixnum (g->g.xoff >> 6),
2831 2831 make_fixnum (g->g.yoff >> 6),
2832 ASET (vec, 0, make_fixnum (g->g.xoff >> 6)); 2832 make_fixnum (g->g.xadv >> 6)));
2833 ASET (vec, 1, make_fixnum (g->g.yoff >> 6));
2834 ASET (vec, 2, make_fixnum (g->g.xadv >> 6));
2835 LGLYPH_SET_ADJUSTMENT (lglyph, vec);
2836 }
2837 } 2833 }
2838 return make_fixnum (i); 2834 return make_fixnum (i);
2839} 2835}
diff --git a/src/hbfont.c b/src/hbfont.c
index 4b3f64ef504..82b115e6868 100644
--- a/src/hbfont.c
+++ b/src/hbfont.c
@@ -594,13 +594,10 @@ hbfont_shape (Lisp_Object lgstring, Lisp_Object direction)
594 yoff = - lround (pos[i].y_offset * position_unit); 594 yoff = - lround (pos[i].y_offset * position_unit);
595 wadjust = lround (pos[i].x_advance * position_unit); 595 wadjust = lround (pos[i].x_advance * position_unit);
596 if (xoff || yoff || wadjust != metrics.width) 596 if (xoff || yoff || wadjust != metrics.width)
597 { 597 LGLYPH_SET_ADJUSTMENT (lglyph, CALLN (Fvector,
598 Lisp_Object vec = make_uninit_vector (3); 598 make_fixnum (xoff),
599 ASET (vec, 0, make_fixnum (xoff)); 599 make_fixnum (yoff),
600 ASET (vec, 1, make_fixnum (yoff)); 600 make_fixnum (wadjust)));
601 ASET (vec, 2, make_fixnum (wadjust));
602 LGLYPH_SET_ADJUSTMENT (lglyph, vec);
603 }
604 } 601 }
605 602
606 return make_fixnum (glyph_len); 603 return make_fixnum (glyph_len);
diff --git a/src/image.c b/src/image.c
index e236b389210..643b3d0a1f4 100644
--- a/src/image.c
+++ b/src/image.c
@@ -803,17 +803,23 @@ valid_image_p (Lisp_Object object)
803 { 803 {
804 Lisp_Object tail = XCDR (object); 804 Lisp_Object tail = XCDR (object);
805 FOR_EACH_TAIL_SAFE (tail) 805 FOR_EACH_TAIL_SAFE (tail)
806 if (EQ (XCAR (tail), QCtype)) 806 {
807 { 807 if (EQ (XCAR (tail), QCtype))
808 tail = XCDR (tail); 808 {
809 if (CONSP (tail)) 809 tail = XCDR (tail);
810 { 810 if (CONSP (tail))
811 struct image_type const *type = lookup_image_type (XCAR (tail)); 811 {
812 if (type) 812 struct image_type const *type =
813 return type->valid_p (object); 813 lookup_image_type (XCAR (tail));
814 } 814 if (type)
815 break; 815 return type->valid_p (object);
816 } 816 }
817 break;
818 }
819 tail = XCDR (tail);
820 if (! CONSP (tail))
821 return false;
822 }
817 } 823 }
818 824
819 return false; 825 return false;
@@ -899,7 +905,7 @@ parse_image_spec (Lisp_Object spec, struct image_keyword *keywords,
899 return false; 905 return false;
900 906
901 plist = XCDR (spec); 907 plist = XCDR (spec);
902 while (CONSP (plist)) 908 FOR_EACH_TAIL_SAFE (plist)
903 { 909 {
904 Lisp_Object key, value; 910 Lisp_Object key, value;
905 911
@@ -913,7 +919,6 @@ parse_image_spec (Lisp_Object spec, struct image_keyword *keywords,
913 if (!CONSP (plist)) 919 if (!CONSP (plist))
914 return false; 920 return false;
915 value = XCAR (plist); 921 value = XCAR (plist);
916 plist = XCDR (plist);
917 922
918 /* Find key in KEYWORDS. Error if not found. */ 923 /* Find key in KEYWORDS. Error if not found. */
919 for (i = 0; i < nkeywords; ++i) 924 for (i = 0; i < nkeywords; ++i)
@@ -921,7 +926,7 @@ parse_image_spec (Lisp_Object spec, struct image_keyword *keywords,
921 break; 926 break;
922 927
923 if (i == nkeywords) 928 if (i == nkeywords)
924 continue; 929 goto maybe_done;
925 930
926 /* Record that we recognized the keyword. If a keyword 931 /* Record that we recognized the keyword. If a keyword
927 was found more than once, it's an error. */ 932 was found more than once, it's an error. */
@@ -1009,14 +1014,20 @@ parse_image_spec (Lisp_Object spec, struct image_keyword *keywords,
1009 if (EQ (key, QCtype) 1014 if (EQ (key, QCtype)
1010 && !(EQ (type, value) || EQ (type, Qnative_image))) 1015 && !(EQ (type, value) || EQ (type, Qnative_image)))
1011 return false; 1016 return false;
1012 }
1013 1017
1014 /* Check that all mandatory fields are present. */ 1018 maybe_done:
1015 for (i = 0; i < nkeywords; ++i) 1019 if (EQ (XCDR (plist), Qnil))
1016 if (keywords[i].count < keywords[i].mandatory_p) 1020 {
1017 return false; 1021 /* Check that all mandatory fields are present. */
1022 for (i = 0; i < nkeywords; ++i)
1023 if (keywords[i].mandatory_p && keywords[i].count == 0)
1024 return false;
1025
1026 return true;
1027 }
1028 }
1018 1029
1019 return NILP (plist); 1030 return false;
1020} 1031}
1021 1032
1022 1033
@@ -1031,9 +1042,8 @@ image_spec_value (Lisp_Object spec, Lisp_Object key, bool *found)
1031 1042
1032 eassert (valid_image_p (spec)); 1043 eassert (valid_image_p (spec));
1033 1044
1034 for (tail = XCDR (spec); 1045 tail = XCDR (spec);
1035 CONSP (tail) && CONSP (XCDR (tail)); 1046 FOR_EACH_TAIL_SAFE (tail)
1036 tail = XCDR (XCDR (tail)))
1037 { 1047 {
1038 if (EQ (XCAR (tail), key)) 1048 if (EQ (XCAR (tail), key))
1039 { 1049 {
@@ -1041,6 +1051,9 @@ image_spec_value (Lisp_Object spec, Lisp_Object key, bool *found)
1041 *found = 1; 1051 *found = 1;
1042 return XCAR (XCDR (tail)); 1052 return XCAR (XCDR (tail));
1043 } 1053 }
1054 tail = XCDR (tail);
1055 if (! CONSP (tail))
1056 break;
1044 } 1057 }
1045 1058
1046 if (found) 1059 if (found)
@@ -1584,6 +1597,16 @@ make_image_cache (void)
1584 return c; 1597 return c;
1585} 1598}
1586 1599
1600/* Compare two lists (one of which must be proper), comparing each
1601 element with `eq'. */
1602static bool
1603equal_lists (Lisp_Object a, Lisp_Object b)
1604{
1605 while (CONSP (a) && CONSP (b) && EQ (XCAR (a), XCAR (b)))
1606 a = XCDR (a), b = XCDR (b);
1607
1608 return EQ (a, b);
1609}
1587 1610
1588/* Find an image matching SPEC in the cache, and return it. If no 1611/* Find an image matching SPEC in the cache, and return it. If no
1589 image is found, return NULL. */ 1612 image is found, return NULL. */
@@ -1610,7 +1633,7 @@ search_image_cache (struct frame *f, Lisp_Object spec, EMACS_UINT hash)
1610 1633
1611 for (img = c->buckets[i]; img; img = img->next) 1634 for (img = c->buckets[i]; img; img = img->next)
1612 if (img->hash == hash 1635 if (img->hash == hash
1613 && !NILP (Fequal (img->spec, spec)) 1636 && !equal_lists (img->spec, spec)
1614 && img->frame_foreground == FRAME_FOREGROUND_PIXEL (f) 1637 && img->frame_foreground == FRAME_FOREGROUND_PIXEL (f)
1615 && img->frame_background == FRAME_BACKGROUND_PIXEL (f)) 1638 && img->frame_background == FRAME_BACKGROUND_PIXEL (f))
1616 break; 1639 break;
diff --git a/src/lisp.h b/src/lisp.h
index 5f913b72b45..ddaeb0c1517 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -1812,7 +1812,8 @@ bool_vector_uchar_data (Lisp_Object a)
1812INLINE bool 1812INLINE bool
1813bool_vector_bitref (Lisp_Object a, EMACS_INT i) 1813bool_vector_bitref (Lisp_Object a, EMACS_INT i)
1814{ 1814{
1815 eassume (0 <= i && i < bool_vector_size (a)); 1815 eassume (0 <= i);
1816 eassert (i < bool_vector_size (a));
1816 return !! (bool_vector_uchar_data (a)[i / BOOL_VECTOR_BITS_PER_CHAR] 1817 return !! (bool_vector_uchar_data (a)[i / BOOL_VECTOR_BITS_PER_CHAR]
1817 & (1 << (i % BOOL_VECTOR_BITS_PER_CHAR))); 1818 & (1 << (i % BOOL_VECTOR_BITS_PER_CHAR)));
1818} 1819}
@@ -1828,11 +1829,11 @@ bool_vector_ref (Lisp_Object a, EMACS_INT i)
1828INLINE void 1829INLINE void
1829bool_vector_set (Lisp_Object a, EMACS_INT i, bool b) 1830bool_vector_set (Lisp_Object a, EMACS_INT i, bool b)
1830{ 1831{
1831 unsigned char *addr; 1832 eassume (0 <= i);
1832 1833 eassert (i < bool_vector_size (a));
1833 eassume (0 <= i && i < bool_vector_size (a));
1834 addr = &bool_vector_uchar_data (a)[i / BOOL_VECTOR_BITS_PER_CHAR];
1835 1834
1835 unsigned char *addr
1836 = &bool_vector_uchar_data (a)[i / BOOL_VECTOR_BITS_PER_CHAR];
1836 if (b) 1837 if (b)
1837 *addr |= 1 << (i % BOOL_VECTOR_BITS_PER_CHAR); 1838 *addr |= 1 << (i % BOOL_VECTOR_BITS_PER_CHAR);
1838 else 1839 else
@@ -3926,7 +3927,6 @@ build_string (const char *str)
3926 3927
3927extern Lisp_Object pure_cons (Lisp_Object, Lisp_Object); 3928extern Lisp_Object pure_cons (Lisp_Object, Lisp_Object);
3928extern Lisp_Object make_vector (ptrdiff_t, Lisp_Object); 3929extern Lisp_Object make_vector (ptrdiff_t, Lisp_Object);
3929extern struct Lisp_Vector *allocate_vector (ptrdiff_t);
3930extern struct Lisp_Vector *allocate_nil_vector (ptrdiff_t); 3930extern struct Lisp_Vector *allocate_nil_vector (ptrdiff_t);
3931 3931
3932/* Make an uninitialized vector for SIZE objects. NOTE: you must 3932/* Make an uninitialized vector for SIZE objects. NOTE: you must
@@ -3936,7 +3936,11 @@ extern struct Lisp_Vector *allocate_nil_vector (ptrdiff_t);
3936 v = make_uninit_vector (3); 3936 v = make_uninit_vector (3);
3937 ASET (v, 0, obj0); 3937 ASET (v, 0, obj0);
3938 ASET (v, 1, Ffunction_can_gc ()); 3938 ASET (v, 1, Ffunction_can_gc ());
3939 ASET (v, 2, obj1); */ 3939 ASET (v, 2, obj1);
3940
3941 allocate_vector has a similar problem. */
3942
3943extern struct Lisp_Vector *allocate_vector (ptrdiff_t);
3940 3944
3941INLINE Lisp_Object 3945INLINE Lisp_Object
3942make_uninit_vector (ptrdiff_t size) 3946make_uninit_vector (ptrdiff_t size)
diff --git a/src/lread.c b/src/lread.c
index f5a7d44a1e0..521da4e1d81 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1099,7 +1099,7 @@ close_infile_unwind (void *arg)
1099 infile = prev_infile; 1099 infile = prev_infile;
1100} 1100}
1101 1101
1102static Lisp_Object 1102static ATTRIBUTE_UNUSED Lisp_Object
1103parent_directory (Lisp_Object directory) 1103parent_directory (Lisp_Object directory)
1104{ 1104{
1105 return Ffile_name_directory (Fsubstring (directory, 1105 return Ffile_name_directory (Fsubstring (directory,
@@ -1231,8 +1231,7 @@ Return t if the file exists and loads successfully. */)
1231 suffixes = CALLN (Fappend, suffixes, Vload_file_rep_suffixes); 1231 suffixes = CALLN (Fappend, suffixes, Vload_file_rep_suffixes);
1232 } 1232 }
1233 1233
1234 fd = 1234 fd = openp (Vload_path, file, suffixes, &found, Qnil, load_prefer_newer);
1235 openp (Vload_path, file, suffixes, &found, Qnil, load_prefer_newer);
1236 } 1235 }
1237 1236
1238 if (fd == -1) 1237 if (fd == -1)
@@ -1478,9 +1477,8 @@ Return t if the file exists and loads successfully. */)
1478 same folder of their respective sources therfore not to break 1477 same folder of their respective sources therfore not to break
1479 packages we fake `load-file-name' here. The non faked 1478 packages we fake `load-file-name' here. The non faked
1480 version of it is `load-true-file-name'. */ 1479 version of it is `load-true-file-name'. */
1481 specbind (Qload_file_name, 1480 specbind (Qload_file_name, Fgethash (Ffile_name_nondirectory (found),
1482 concat2 (parent_directory (Ffile_name_directory (found)), 1481 Vcomp_eln_to_el_h, Qnil));
1483 Ffile_name_nondirectory (found)));
1484 } 1482 }
1485 else 1483 else
1486 specbind (Qload_file_name, found); 1484 specbind (Qload_file_name, found);
@@ -1608,118 +1606,52 @@ directories, make sure the PREDICATE function returns `dir-ok' for them. */)
1608 return file; 1606 return file;
1609} 1607}
1610 1608
1611/* This function turns a list of suffixes into a list of middle dirs 1609/* Look for a suitable .eln file to be loaded in place of FILENAME.
1612 and suffixes. If the suffix is not NATIVE_ELISP_SUFFIX then its 1610 If found replace the content of FILENAME and FD. */
1613 suffix is nil and it is added to the list as is. Instead, if it
1614 suffix is NATIVE_ELISP_SUFFIX then two elements are added to the
1615 list. The first one has middledir equal to nil and the second uses
1616 comp-native-path-postfix as middledir. This is because we'd like
1617 to search for dir/foo.eln before dir/middledir/foo.eln.
1618
1619For example, it turns this:
1620
1621(".eln" ".elc" ".elc.gz" ".el" ".el.gz")
1622 1611
1623 into this: 1612static void
1624 1613maybe_swap_for_eln (Lisp_Object *filename, int *fd, struct timespec mtime)
1625((nil . ".eln")
1626 (comp-native-path-postfix . ".eln")
1627 (nil . ".elc")
1628 (nil . ".elc.gz")
1629 (nil . ".el")
1630 (nil . ".el.gz"))
1631*/
1632static Lisp_Object
1633openp_add_middle_dir_to_suffixes (Lisp_Object suffixes)
1634{ 1614{
1635 Lisp_Object tail = suffixes;
1636 Lisp_Object extended_suf = Qnil;
1637 FOR_EACH_TAIL_SAFE (tail)
1638 {
1639 /* suffixes may be a stack-based cons pointing to stack-based
1640 strings. We must copy the suffix if we are putting it into
1641 a heap-based cons to avoid a dangling reference. This would
1642 lead to crashes during the GC. */
1643 CHECK_STRING_CAR (tail);
1644 char * suf = SSDATA (XCAR (tail));
1645 Lisp_Object copied_suffix = build_string (suf);
1646#ifdef HAVE_NATIVE_COMP 1615#ifdef HAVE_NATIVE_COMP
1647 if (strcmp (NATIVE_ELISP_SUFFIX, suf) == 0) 1616 struct stat eln_st;
1648 {
1649 CHECK_STRING (Vcomp_native_path_postfix);
1650 /* Here we add them in the opposite order so that nreverse
1651 corrects it. */
1652 extended_suf = Fcons (Fcons (Qnil, copied_suffix), extended_suf);
1653 extended_suf = Fcons (Fcons (Vcomp_native_path_postfix,
1654 copied_suffix),
1655 extended_suf);
1656 }
1657 else
1658#endif
1659 extended_suf = Fcons (Fcons (Qnil, copied_suffix), extended_suf);
1660 }
1661 1617
1662 suffixes = Fnreverse (extended_suf); 1618 if (load_no_native
1663 return suffixes; 1619 || !suffix_p (*filename, ".elc"))
1664} 1620 return;
1665 1621
1666/* This function takes a list of middledirs and suffixes and returns 1622 /* Search eln in the eln-cache directories. */
1667 the maximum buffer space that this part of the filename will 1623 Lisp_Object eln_path_tail = Vcomp_eln_load_path;
1668 need. */ 1624 FOR_EACH_TAIL_SAFE (eln_path_tail)
1669static ptrdiff_t
1670openp_max_middledir_and_suffix_len (Lisp_Object middledir_and_suffixes)
1671{
1672 ptrdiff_t max_extra_len = 0;
1673 Lisp_Object tail = middledir_and_suffixes;
1674 FOR_EACH_TAIL_SAFE (tail)
1675 { 1625 {
1676 Lisp_Object middledir_and_suffix = XCAR (tail); 1626 Lisp_Object el_name =
1677 Lisp_Object middledir = XCAR (middledir_and_suffix); 1627 Fsubstring (*filename, Qnil, make_fixnum (-1));
1678 Lisp_Object suffix = XCDR (middledir_and_suffix); 1628 Lisp_Object eln_name =
1679 ptrdiff_t len = SBYTES (suffix); 1629 Fcomp_el_to_eln_filename (el_name, XCAR (eln_path_tail));
1680 if (!NILP (middledir)) 1630 int eln_fd = emacs_open (SSDATA (ENCODE_FILE (eln_name)), O_RDONLY, 0);
1681 len += 2 + SBYTES (middledir); /* Add two slashes. */
1682 max_extra_len = max (max_extra_len, len);
1683 }
1684 return max_extra_len;
1685}
1686 1631
1687/* This function completes the FN buffer with the middledir, 1632 if (eln_fd > 0)
1688 basenameme, and suffix. It takes the directory length in DIRNAME, 1633 {
1689 but it requires that it has been copied already to the start of 1634 if (fstat (eln_fd, &eln_st) || S_ISDIR (eln_st.st_mode))
1690 the buffer. 1635 emacs_close (eln_fd);
1691 1636 else
1692 After this function the FN buffer will be (depending on middledir) 1637 {
1693 dirname/middledir/basename.suffix 1638 struct timespec eln_mtime = get_stat_mtime (&eln_st);
1694 or 1639 if (timespec_cmp (eln_mtime, mtime) > 0)
1695 dirname/basename.suffix 1640 {
1696*/ 1641 *filename = eln_name;
1697static ptrdiff_t 1642 emacs_close (*fd);
1698openp_fill_filename_buffer (char *fn, ptrdiff_t dirnamelen, 1643 *fd = eln_fd;
1699 Lisp_Object basenamewext, 1644 /* Store the eln -> el relation. */
1700 Lisp_Object middledir_and_suffix) 1645 Fputhash (Ffile_name_nondirectory (eln_name),
1701{ 1646 el_name, Vcomp_eln_to_el_h);
1702 Lisp_Object middledir = XCAR (middledir_and_suffix); 1647 return;
1703 Lisp_Object suffix = XCDR (middledir_and_suffix); 1648 }
1704 ptrdiff_t basenamewext_len = SBYTES (basenamewext); 1649 else
1705 ptrdiff_t fnlen, lsuffix = SBYTES (suffix); 1650 emacs_close (eln_fd);
1706 ptrdiff_t lmiddledir = 0; 1651 }
1707 if (!NILP (middledir)) 1652 }
1708 {
1709 /* Add 1 for the slash. */
1710 lmiddledir = SBYTES (middledir) + 1;
1711 memcpy (fn + dirnamelen, SDATA (middledir),
1712 lmiddledir - 1);
1713 fn[dirnamelen + (lmiddledir - 1)] = '/';
1714 } 1653 }
1715 1654#endif
1716 memcpy (fn + dirnamelen + lmiddledir, SDATA (basenamewext),
1717 basenamewext_len);
1718 /* Make complete filename by appending SUFFIX. */
1719 memcpy (fn + dirnamelen + lmiddledir + basenamewext_len,
1720 SDATA (suffix), lsuffix + 1);
1721 fnlen = dirnamelen + lmiddledir + basenamewext_len + lsuffix;
1722 return fnlen;
1723} 1655}
1724 1656
1725/* Search for a file whose name is STR, looking in directories 1657/* Search for a file whose name is STR, looking in directories
@@ -1759,21 +1691,23 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes,
1759 ptrdiff_t want_length; 1691 ptrdiff_t want_length;
1760 Lisp_Object filename; 1692 Lisp_Object filename;
1761 Lisp_Object string, tail, encoded_fn, save_string; 1693 Lisp_Object string, tail, encoded_fn, save_string;
1762 Lisp_Object middledir_and_suffixes; 1694 ptrdiff_t max_suffix_len = 0;
1763 ptrdiff_t max_extra_len = 0;
1764 int last_errno = ENOENT; 1695 int last_errno = ENOENT;
1765 int save_fd = -1; 1696 int save_fd = -1;
1766 USE_SAFE_ALLOCA; 1697 USE_SAFE_ALLOCA;
1767
1768 /* The last-modified time of the newest matching file found. 1698 /* The last-modified time of the newest matching file found.
1769 Initialize it to something less than all valid timestamps. */ 1699 Initialize it to something less than all valid timestamps. */
1770 struct timespec save_mtime = make_timespec (TYPE_MINIMUM (time_t), -1); 1700 struct timespec save_mtime = make_timespec (TYPE_MINIMUM (time_t), -1);
1771 1701
1772 CHECK_STRING (str); 1702 CHECK_STRING (str);
1773 1703
1774 middledir_and_suffixes = openp_add_middle_dir_to_suffixes (suffixes); 1704 tail = suffixes;
1775 1705 FOR_EACH_TAIL_SAFE (tail)
1776 max_extra_len = openp_max_middledir_and_suffix_len (middledir_and_suffixes); 1706 {
1707 CHECK_STRING_CAR (tail);
1708 max_suffix_len = max (max_suffix_len,
1709 SBYTES (XCAR (tail)));
1710 }
1777 1711
1778 string = filename = encoded_fn = save_string = Qnil; 1712 string = filename = encoded_fn = save_string = Qnil;
1779 1713
@@ -1790,7 +1724,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes,
1790 executable. */ 1724 executable. */
1791 FOR_EACH_TAIL_SAFE (path) 1725 FOR_EACH_TAIL_SAFE (path)
1792 { 1726 {
1793 ptrdiff_t dirnamelen, prefixlen; 1727 ptrdiff_t baselen, prefixlen;
1794 1728
1795 if (EQ (path, just_use_str)) 1729 if (EQ (path, just_use_str))
1796 filename = str; 1730 filename = str;
@@ -1807,40 +1741,35 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes,
1807 continue; 1741 continue;
1808 } 1742 }
1809 1743
1810
1811 /* Calculate maximum length of any filename made from 1744 /* Calculate maximum length of any filename made from
1812 this path element/specified file name and any possible suffix. */ 1745 this path element/specified file name and any possible suffix. */
1813 want_length = max_extra_len + SBYTES (filename); 1746 want_length = max_suffix_len + SBYTES (filename);
1814 if (fn_size <= want_length) 1747 if (fn_size <= want_length)
1815 { 1748 {
1816 fn_size = 100 + want_length; 1749 fn_size = 100 + want_length;
1817 fn = SAFE_ALLOCA (fn_size); 1750 fn = SAFE_ALLOCA (fn_size);
1818 } 1751 }
1819 1752
1820 Lisp_Object dirnamewslash = Ffile_name_directory (filename);
1821 Lisp_Object basenamewext = Ffile_name_nondirectory (filename);
1822
1823 /* Copy FILENAME's data to FN but remove starting /: if any. */ 1753 /* Copy FILENAME's data to FN but remove starting /: if any. */
1824 prefixlen = ((SCHARS (dirnamewslash) > 2 1754 prefixlen = ((SCHARS (filename) > 2
1825 && SREF (dirnamewslash, 0) == '/' 1755 && SREF (filename, 0) == '/'
1826 && SREF (dirnamewslash, 1) == ':') 1756 && SREF (filename, 1) == ':')
1827 ? 2 : 0); 1757 ? 2 : 0);
1828 dirnamelen = SBYTES (dirnamewslash) - prefixlen; 1758 baselen = SBYTES (filename) - prefixlen;
1829 memcpy (fn, SDATA (dirnamewslash) + prefixlen, dirnamelen); 1759 memcpy (fn, SDATA (filename) + prefixlen, baselen);
1830 1760
1831 /* Loop over middledir_and_suffixes. */ 1761 /* Loop over suffixes. */
1832 AUTO_LIST1 (empty_string_only, Fcons (Qnil, empty_unibyte_string)); 1762 AUTO_LIST1 (empty_string_only, empty_unibyte_string);
1833 tail = NILP (middledir_and_suffixes) ? empty_string_only 1763 tail = NILP (suffixes) ? empty_string_only : suffixes;
1834 : middledir_and_suffixes;
1835 FOR_EACH_TAIL_SAFE (tail) 1764 FOR_EACH_TAIL_SAFE (tail)
1836 { 1765 {
1837 Lisp_Object middledir_and_suffix = XCAR (tail); 1766 Lisp_Object suffix = XCAR (tail);
1838 Lisp_Object suffix = XCDR (middledir_and_suffix); 1767 ptrdiff_t fnlen, lsuffix = SBYTES (suffix);
1839 Lisp_Object handler; 1768 Lisp_Object handler;
1840 1769
1841 ptrdiff_t fnlen = openp_fill_filename_buffer (fn, dirnamelen, 1770 /* Make complete filename by appending SUFFIX. */
1842 basenamewext, 1771 memcpy (fn + baselen, SDATA (suffix), lsuffix + 1);
1843 middledir_and_suffix); 1772 fnlen = baselen + lsuffix;
1844 1773
1845 /* Check that the file exists and is not a directory. */ 1774 /* Check that the file exists and is not a directory. */
1846 /* We used to only check for handlers on non-absolute file names: 1775 /* We used to only check for handlers on non-absolute file names:
@@ -1962,9 +1891,11 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes,
1962 } 1891 }
1963 else 1892 else
1964 { 1893 {
1894 maybe_swap_for_eln (&string, &fd, get_stat_mtime (&st));
1965 /* We succeeded; return this descriptor and filename. */ 1895 /* We succeeded; return this descriptor and filename. */
1966 if (storeptr) 1896 if (storeptr)
1967 *storeptr = string; 1897 *storeptr = string;
1898
1968 SAFE_FREE (); 1899 SAFE_FREE ();
1969 return fd; 1900 return fd;
1970 } 1901 }
@@ -1973,6 +1904,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes,
1973 /* No more suffixes. Return the newest. */ 1904 /* No more suffixes. Return the newest. */
1974 if (0 <= save_fd && ! CONSP (XCDR (tail))) 1905 if (0 <= save_fd && ! CONSP (XCDR (tail)))
1975 { 1906 {
1907 maybe_swap_for_eln (&save_string, &save_fd, save_mtime);
1976 if (storeptr) 1908 if (storeptr)
1977 *storeptr = save_string; 1909 *storeptr = save_string;
1978 SAFE_FREE (); 1910 SAFE_FREE ();
@@ -5030,11 +4962,8 @@ to the specified file name if a suffix is allowed or required. */);
5030 Vload_suffixes = 4962 Vload_suffixes =
5031 Fcons (build_pure_c_string (MODULES_SECONDARY_SUFFIX), Vload_suffixes); 4963 Fcons (build_pure_c_string (MODULES_SECONDARY_SUFFIX), Vload_suffixes);
5032#endif 4964#endif
5033#endif
5034#ifdef HAVE_NATIVE_COMP
5035 Vload_suffixes = Fcons (build_pure_c_string (NATIVE_ELISP_SUFFIX), Vload_suffixes);
5036#endif
5037 4965
4966#endif
5038 DEFVAR_LISP ("module-file-suffix", Vmodule_file_suffix, 4967 DEFVAR_LISP ("module-file-suffix", Vmodule_file_suffix,
5039 doc: /* Suffix of loadable module file, or nil if modules are not supported. */); 4968 doc: /* Suffix of loadable module file, or nil if modules are not supported. */);
5040#ifdef HAVE_MODULES 4969#ifdef HAVE_MODULES
@@ -5228,6 +5157,11 @@ Note that if you customize this, obviously it will not affect files
5228that are loaded before your customizations are read! */); 5157that are loaded before your customizations are read! */);
5229 load_prefer_newer = 0; 5158 load_prefer_newer = 0;
5230 5159
5160 DEFVAR_BOOL ("load-no-native", load_no_native,
5161 doc: /* Do not try to load the a .eln file in place of
5162 a .elc one. */);
5163 load_no_native = false;
5164
5231 /* Vsource_directory was initialized in init_lread. */ 5165 /* Vsource_directory was initialized in init_lread. */
5232 5166
5233 DEFSYM (Qcurrent_load_list, "current-load-list"); 5167 DEFSYM (Qcurrent_load_list, "current-load-list");
diff --git a/src/macfont.m b/src/macfont.m
index c7430d32772..904814647f9 100644
--- a/src/macfont.m
+++ b/src/macfont.m
@@ -3137,10 +3137,8 @@ macfont_shape (Lisp_Object lgstring, Lisp_Object direction)
3137 wadjust = lround (gl->advance); 3137 wadjust = lround (gl->advance);
3138 if (xoff != 0 || yoff != 0 || wadjust != metrics.width) 3138 if (xoff != 0 || yoff != 0 || wadjust != metrics.width)
3139 { 3139 {
3140 Lisp_Object vec = make_uninit_vector (3); 3140 Lisp_Object vec = CALLN (Fvector, make_fixnum (xoff),
3141 ASET (vec, 0, make_fixnum (xoff)); 3141 make_fixnum (yoff), make_fixnum (wadjust));
3142 ASET (vec, 1, make_fixnum (yoff));
3143 ASET (vec, 2, make_fixnum (wadjust));
3144 LGLYPH_SET_ADJUSTMENT (lglyph, vec); 3142 LGLYPH_SET_ADJUSTMENT (lglyph, vec);
3145 } 3143 }
3146 } 3144 }
diff --git a/src/minibuf.c b/src/minibuf.c
index cb302c5a605..e18ff17abbf 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -251,7 +251,7 @@ read_minibuf_noninteractive (Lisp_Object prompt, bool expflag,
251 else 251 else
252 { 252 {
253 xfree (line); 253 xfree (line);
254 error ("Error reading from stdin"); 254 xsignal1 (Qend_of_file, build_string ("Error reading from stdin"));
255 } 255 }
256 256
257 /* If Lisp form desired instead of string, parse it. */ 257 /* If Lisp form desired instead of string, parse it. */
diff --git a/src/nsselect.m b/src/nsselect.m
index 38ac66e9c7b..7b1937f5d99 100644
--- a/src/nsselect.m
+++ b/src/nsselect.m
@@ -114,7 +114,7 @@ clean_local_selection_data (Lisp_Object obj)
114 114
115 if (size == 1) 115 if (size == 1)
116 return clean_local_selection_data (AREF (obj, 0)); 116 return clean_local_selection_data (AREF (obj, 0));
117 copy = make_uninit_vector (size); 117 copy = make_nil_vector (size);
118 for (i = 0; i < size; i++) 118 for (i = 0; i < size; i++)
119 ASET (copy, i, clean_local_selection_data (AREF (obj, i))); 119 ASET (copy, i, clean_local_selection_data (AREF (obj, i)));
120 return copy; 120 return copy;
diff --git a/src/nsterm.m b/src/nsterm.m
index 9f5916d78ed..98c5b69d681 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7669,11 +7669,8 @@ not_in_argv (NSString *arg)
7669 /* macOS Sierra automatically enables tabbed windows. We can't 7669 /* macOS Sierra automatically enables tabbed windows. We can't
7670 allow this to be enabled until it's available on a Free system. 7670 allow this to be enabled until it's available on a Free system.
7671 Currently it only happens by accident and is buggy anyway. */ 7671 Currently it only happens by accident and is buggy anyway. */
7672#if defined (NS_IMPL_COCOA) \ 7672#ifdef NS_IMPL_COCOA
7673 && MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
7674#if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
7675 if ([win respondsToSelector: @selector(setTabbingMode:)]) 7673 if ([win respondsToSelector: @selector(setTabbingMode:)])
7676#endif
7677 [win setTabbingMode: NSWindowTabbingModeDisallowed]; 7674 [win setTabbingMode: NSWindowTabbingModeDisallowed];
7678#endif 7675#endif
7679 7676
@@ -8424,25 +8421,17 @@ not_in_argv (NSString *arg)
8424 8421
8425 8422
8426- (void)windowDidChangeBackingProperties:(NSNotification *)notification 8423- (void)windowDidChangeBackingProperties:(NSNotification *)notification
8427 /* Update the drawing buffer when the backing scale factor changes. */ 8424 /* Update the drawing buffer when the backing properties change. */
8428{ 8425{
8429 NSTRACE ("EmacsView windowDidChangeBackingProperties:]"); 8426 NSTRACE ("EmacsView windowDidChangeBackingProperties:]");
8430 8427
8431 if (! [self wantsUpdateLayer]) 8428 if (! [self wantsUpdateLayer])
8432 return; 8429 return;
8433 8430
8434 CGFloat old = [[[notification userInfo] 8431 NSRect frame = [self frame];
8435 objectForKey:@"NSBackingPropertyOldScaleFactorKey"] 8432 [self createDrawingBuffer];
8436 doubleValue]; 8433 ns_clear_frame (emacsframe);
8437 CGFloat new = [[self window] backingScaleFactor]; 8434 expose_frame (emacsframe, 0, 0, NSWidth (frame), NSHeight (frame));
8438
8439 if (old != new)
8440 {
8441 NSRect frame = [self frame];
8442 [self createDrawingBuffer];
8443 ns_clear_frame (emacsframe);
8444 expose_frame (emacsframe, 0, 0, NSWidth (frame), NSHeight (frame));
8445 }
8446} 8435}
8447#endif /* NS_DRAW_TO_BUFFER */ 8436#endif /* NS_DRAW_TO_BUFFER */
8448 8437
diff --git a/src/nsxwidget.m b/src/nsxwidget.m
index 370abee395c..e81ca7fc0cb 100644
--- a/src/nsxwidget.m
+++ b/src/nsxwidget.m
@@ -388,7 +388,7 @@ js_to_lisp (id value)
388 NSArray *nsarr = (NSArray *) value; 388 NSArray *nsarr = (NSArray *) value;
389 EMACS_INT n = nsarr.count; 389 EMACS_INT n = nsarr.count;
390 Lisp_Object obj; 390 Lisp_Object obj;
391 struct Lisp_Vector *p = allocate_vector (n); 391 struct Lisp_Vector *p = allocate_nil_vector (n);
392 392
393 for (ptrdiff_t i = 0; i < n; ++i) 393 for (ptrdiff_t i = 0; i < n; ++i)
394 p->contents[i] = js_to_lisp ([nsarr objectAtIndex:i]); 394 p->contents[i] = js_to_lisp ([nsarr objectAtIndex:i]);
@@ -401,7 +401,7 @@ js_to_lisp (id value)
401 NSArray *keys = nsdict.allKeys; 401 NSArray *keys = nsdict.allKeys;
402 ptrdiff_t n = keys.count; 402 ptrdiff_t n = keys.count;
403 Lisp_Object obj; 403 Lisp_Object obj;
404 struct Lisp_Vector *p = allocate_vector (n); 404 struct Lisp_Vector *p = allocate_nil_vector (n);
405 405
406 for (ptrdiff_t i = 0; i < n; ++i) 406 for (ptrdiff_t i = 0; i < n; ++i)
407 { 407 {
diff --git a/src/pdumper.c b/src/pdumper.c
index 629d0969346..9c615a9a1a7 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -4903,14 +4903,19 @@ struct dump_bitset
4903}; 4903};
4904 4904
4905static bool 4905static bool
4906dump_bitset_init (struct dump_bitset *bitset, size_t number_bits) 4906dump_bitsets_init (struct dump_bitset bitset[2], size_t number_bits)
4907{ 4907{
4908 int xword_size = sizeof (bitset->bits[0]); 4908 int xword_size = sizeof (bitset[0].bits[0]);
4909 int bits_per_word = xword_size * CHAR_BIT; 4909 int bits_per_word = xword_size * CHAR_BIT;
4910 ptrdiff_t words_needed = divide_round_up (number_bits, bits_per_word); 4910 ptrdiff_t words_needed = divide_round_up (number_bits, bits_per_word);
4911 bitset->number_words = words_needed; 4911 dump_bitset_word *bits = calloc (words_needed, 2 * xword_size);
4912 bitset->bits = calloc (words_needed, xword_size); 4912 if (!bits)
4913 return bitset->bits != NULL; 4913 return false;
4914 bitset[0].bits = bits;
4915 bitset[0].number_words = bitset[1].number_words = words_needed;
4916 bitset[1].bits = memset (bits + words_needed, UCHAR_MAX,
4917 words_needed * xword_size);
4918 return true;
4914} 4919}
4915 4920
4916static dump_bitset_word * 4921static dump_bitset_word *
@@ -4971,7 +4976,7 @@ struct pdumper_loaded_dump_private
4971 /* Copy of the header we read from the dump. */ 4976 /* Copy of the header we read from the dump. */
4972 struct dump_header header; 4977 struct dump_header header;
4973 /* Mark bits for objects in the dump; used during GC. */ 4978 /* Mark bits for objects in the dump; used during GC. */
4974 struct dump_bitset mark_bits; 4979 struct dump_bitset mark_bits, last_mark_bits;
4975 /* Time taken to load the dump. */ 4980 /* Time taken to load the dump. */
4976 double load_time; 4981 double load_time;
4977 /* Dump file name. */ 4982 /* Dump file name. */
@@ -5094,6 +5099,10 @@ pdumper_find_object_type_impl (const void *obj)
5094 dump_off offset = ptrdiff_t_to_dump_off ((uintptr_t) obj - dump_public.start); 5099 dump_off offset = ptrdiff_t_to_dump_off ((uintptr_t) obj - dump_public.start);
5095 if (offset % DUMP_ALIGNMENT != 0) 5100 if (offset % DUMP_ALIGNMENT != 0)
5096 return PDUMPER_NO_OBJECT; 5101 return PDUMPER_NO_OBJECT;
5102 ptrdiff_t bitno = offset / DUMP_ALIGNMENT;
5103 if (offset < dump_private.header.discardable_start
5104 && !dump_bitset_bit_set_p (&dump_private.last_mark_bits, bitno))
5105 return PDUMPER_NO_OBJECT;
5097 const struct dump_reloc *reloc = 5106 const struct dump_reloc *reloc =
5098 dump_find_relocation (&dump_private.header.object_starts, offset); 5107 dump_find_relocation (&dump_private.header.object_starts, offset);
5099 return (reloc != NULL && dump_reloc_get_offset (*reloc) == offset) 5108 return (reloc != NULL && dump_reloc_get_offset (*reloc) == offset)
@@ -5122,12 +5131,16 @@ pdumper_set_marked_impl (const void *obj)
5122 eassert (offset < dump_private.header.cold_start); 5131 eassert (offset < dump_private.header.cold_start);
5123 eassert (offset < dump_private.header.discardable_start); 5132 eassert (offset < dump_private.header.discardable_start);
5124 ptrdiff_t bitno = offset / DUMP_ALIGNMENT; 5133 ptrdiff_t bitno = offset / DUMP_ALIGNMENT;
5134 eassert (dump_bitset_bit_set_p (&dump_private.last_mark_bits, bitno));
5125 dump_bitset_set_bit (&dump_private.mark_bits, bitno); 5135 dump_bitset_set_bit (&dump_private.mark_bits, bitno);
5126} 5136}
5127 5137
5128void 5138void
5129pdumper_clear_marks_impl (void) 5139pdumper_clear_marks_impl (void)
5130{ 5140{
5141 dump_bitset_word *swap = dump_private.last_mark_bits.bits;
5142 dump_private.last_mark_bits.bits = dump_private.mark_bits.bits;
5143 dump_private.mark_bits.bits = swap;
5131 dump_bitset_clear (&dump_private.mark_bits); 5144 dump_bitset_clear (&dump_private.mark_bits);
5132} 5145}
5133 5146
@@ -5249,9 +5262,13 @@ dump_do_dump_relocation (const uintptr_t dump_base,
5249 { 5262 {
5250 fclose (file); 5263 fclose (file);
5251 installation_state = INSTALLED; 5264 installation_state = INSTALLED;
5265 fixup_eln_load_path (XCAR (comp_u->file));
5252 } 5266 }
5253 else 5267 else
5254 installation_state = LOCAL_BUILD; 5268 {
5269 installation_state = LOCAL_BUILD;
5270 fixup_eln_load_path (XCDR (comp_u->file));
5271 }
5255 } 5272 }
5256 5273
5257 comp_u->file = 5274 comp_u->file =
@@ -5423,7 +5440,7 @@ pdumper_load (const char *dump_filename, char *argv0, char const *original_pwd)
5423 int dump_page_size; 5440 int dump_page_size;
5424 dump_off adj_discardable_start; 5441 dump_off adj_discardable_start;
5425 5442
5426 struct dump_bitset mark_bits; 5443 struct dump_bitset mark_bits[2];
5427 size_t mark_bits_needed; 5444 size_t mark_bits_needed;
5428 5445
5429 struct dump_header header_buf = { 0 }; 5446 struct dump_header header_buf = { 0 };
@@ -5537,7 +5554,7 @@ pdumper_load (const char *dump_filename, char *argv0, char const *original_pwd)
5537 err = PDUMPER_LOAD_ERROR; 5554 err = PDUMPER_LOAD_ERROR;
5538 mark_bits_needed = 5555 mark_bits_needed =
5539 divide_round_up (header->discardable_start, DUMP_ALIGNMENT); 5556 divide_round_up (header->discardable_start, DUMP_ALIGNMENT);
5540 if (!dump_bitset_init (&mark_bits, mark_bits_needed)) 5557 if (!dump_bitsets_init (mark_bits, mark_bits_needed))
5541 goto out; 5558 goto out;
5542 5559
5543 /* Point of no return. */ 5560 /* Point of no return. */
@@ -5545,7 +5562,8 @@ pdumper_load (const char *dump_filename, char *argv0, char const *original_pwd)
5545 dump_base = (uintptr_t) sections[DS_HOT].mapping; 5562 dump_base = (uintptr_t) sections[DS_HOT].mapping;
5546 gflags.dumped_with_pdumper_ = true; 5563 gflags.dumped_with_pdumper_ = true;
5547 dump_private.header = *header; 5564 dump_private.header = *header;
5548 dump_private.mark_bits = mark_bits; 5565 dump_private.mark_bits = mark_bits[0];
5566 dump_private.last_mark_bits = mark_bits[1];
5549 dump_public.start = dump_base; 5567 dump_public.start = dump_base;
5550 dump_public.end = dump_public.start + dump_size; 5568 dump_public.end = dump_public.start + dump_size;
5551 5569
diff --git a/src/search.c b/src/search.c
index 38c64caf7c0..6fb3716cd43 100644
--- a/src/search.c
+++ b/src/search.c
@@ -3271,7 +3271,7 @@ the buffer. If the buffer doesn't have a cache, the value is nil. */)
3271 TYPE_MAXIMUM (ptrdiff_t), &nl_count_cache, NULL, true); 3271 TYPE_MAXIMUM (ptrdiff_t), &nl_count_cache, NULL, true);
3272 3272
3273 /* Create vector and populate it. */ 3273 /* Create vector and populate it. */
3274 cache_newlines = make_uninit_vector (nl_count_cache); 3274 cache_newlines = make_vector (nl_count_cache, make_fixnum (-1));
3275 3275
3276 if (nl_count_cache) 3276 if (nl_count_cache)
3277 { 3277 {
@@ -3285,15 +3285,12 @@ the buffer. If the buffer doesn't have a cache, the value is nil. */)
3285 break; 3285 break;
3286 ASET (cache_newlines, i, make_fixnum (found - 1)); 3286 ASET (cache_newlines, i, make_fixnum (found - 1));
3287 } 3287 }
3288 /* Fill the rest of slots with an invalid position. */
3289 for ( ; i < nl_count_cache; i++)
3290 ASET (cache_newlines, i, make_fixnum (-1));
3291 } 3288 }
3292 3289
3293 /* Now do the same, but without using the cache. */ 3290 /* Now do the same, but without using the cache. */
3294 find_newline1 (BEGV, BEGV_BYTE, ZV, ZV_BYTE, 3291 find_newline1 (BEGV, BEGV_BYTE, ZV, ZV_BYTE,
3295 TYPE_MAXIMUM (ptrdiff_t), &nl_count_buf, NULL, true); 3292 TYPE_MAXIMUM (ptrdiff_t), &nl_count_buf, NULL, true);
3296 buf_newlines = make_uninit_vector (nl_count_buf); 3293 buf_newlines = make_vector (nl_count_buf, make_fixnum (-1));
3297 if (nl_count_buf) 3294 if (nl_count_buf)
3298 { 3295 {
3299 for (from = BEGV, found = from, i = 0; from < ZV; from = found, i++) 3296 for (from = BEGV, found = from, i = 0; from < ZV; from = found, i++)
@@ -3306,14 +3303,10 @@ the buffer. If the buffer doesn't have a cache, the value is nil. */)
3306 break; 3303 break;
3307 ASET (buf_newlines, i, make_fixnum (found - 1)); 3304 ASET (buf_newlines, i, make_fixnum (found - 1));
3308 } 3305 }
3309 for ( ; i < nl_count_buf; i++)
3310 ASET (buf_newlines, i, make_fixnum (-1));
3311 } 3306 }
3312 3307
3313 /* Construct the value and return it. */ 3308 /* Construct the value and return it. */
3314 val = make_uninit_vector (2); 3309 val = CALLN (Fvector, cache_newlines, buf_newlines);
3315 ASET (val, 0, cache_newlines);
3316 ASET (val, 1, buf_newlines);
3317 3310
3318 if (old != NULL) 3311 if (old != NULL)
3319 set_buffer_internal_1 (old); 3312 set_buffer_internal_1 (old);
diff --git a/src/syntax.c b/src/syntax.c
index a03202d386c..9f77ea5f9b0 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -3617,9 +3617,9 @@ init_syntax_once (void)
3617 DEFSYM (Qsyntax_table, "syntax-table"); 3617 DEFSYM (Qsyntax_table, "syntax-table");
3618 3618
3619 /* Create objects which can be shared among syntax tables. */ 3619 /* Create objects which can be shared among syntax tables. */
3620 Vsyntax_code_object = make_uninit_vector (Smax); 3620 Vsyntax_code_object = make_nil_vector (Smax);
3621 for (i = 0; i < Smax; i++) 3621 for (i = 0; i < Smax; i++)
3622 ASET (Vsyntax_code_object, i, Fcons (make_fixnum (i), Qnil)); 3622 ASET (Vsyntax_code_object, i, list1 (make_fixnum (i)));
3623 3623
3624 /* Now we are ready to set up this property, so we can 3624 /* Now we are ready to set up this property, so we can
3625 create syntax tables. */ 3625 create syntax tables. */
diff --git a/src/sysdep.c b/src/sysdep.c
index 6b54ed3b6ec..a1050c4309a 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -49,10 +49,14 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
49# include <cygwin/fs.h> 49# include <cygwin/fs.h>
50#endif 50#endif
51 51
52#if defined DARWIN_OS || defined __FreeBSD__ 52#if defined DARWIN_OS || defined __FreeBSD__ || defined __OpenBSD__
53# include <sys/sysctl.h> 53# include <sys/sysctl.h>
54#endif 54#endif
55 55
56#ifdef DARWIN_OS
57# include <libproc.h>
58#endif
59
56#ifdef __FreeBSD__ 60#ifdef __FreeBSD__
57/* Sparc/ARM machine/frame.h has 'struct frame' which conflicts with Emacs's 61/* Sparc/ARM machine/frame.h has 'struct frame' which conflicts with Emacs's
58 'struct frame', so rename it. */ 62 'struct frame', so rename it. */
@@ -3061,37 +3065,43 @@ list_system_processes (void)
3061 return proclist; 3065 return proclist;
3062} 3066}
3063 3067
3064#elif defined DARWIN_OS || defined __FreeBSD__ 3068#elif defined DARWIN_OS || defined __FreeBSD__ || defined __OpenBSD__
3065 3069
3066Lisp_Object 3070Lisp_Object
3067list_system_processes (void) 3071list_system_processes (void)
3068{ 3072{
3069#ifdef DARWIN_OS 3073#ifdef DARWIN_OS
3070 int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL}; 3074 int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL};
3075#elif defined __OpenBSD__
3076 int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0,
3077 sizeof (struct kinfo_proc), 4096};
3071#else 3078#else
3072 int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PROC}; 3079 int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PROC};
3073#endif 3080#endif
3074 size_t len; 3081 size_t len;
3082 size_t mibsize = sizeof mib / sizeof mib[0];
3075 struct kinfo_proc *procs; 3083 struct kinfo_proc *procs;
3076 size_t i; 3084 size_t i;
3077 3085
3078 Lisp_Object proclist = Qnil; 3086 Lisp_Object proclist = Qnil;
3079 3087
3080 if (sysctl (mib, 3, NULL, &len, NULL, 0) != 0 || len == 0) 3088 if (sysctl (mib, mibsize, NULL, &len, NULL, 0) != 0 || len == 0)
3081 return proclist; 3089 return proclist;
3082 3090
3083 procs = xmalloc (len); 3091 procs = xmalloc (len);
3084 if (sysctl (mib, 3, procs, &len, NULL, 0) != 0 || len == 0) 3092 if (sysctl (mib, mibsize, procs, &len, NULL, 0) != 0 || len == 0)
3085 { 3093 {
3086 xfree (procs); 3094 xfree (procs);
3087 return proclist; 3095 return proclist;
3088 } 3096 }
3089 3097
3090 len /= sizeof (struct kinfo_proc); 3098 len /= sizeof procs[0];
3091 for (i = 0; i < len; i++) 3099 for (i = 0; i < len; i++)
3092 { 3100 {
3093#ifdef DARWIN_OS 3101#ifdef DARWIN_OS
3094 proclist = Fcons (INT_TO_INTEGER (procs[i].kp_proc.p_pid), proclist); 3102 proclist = Fcons (INT_TO_INTEGER (procs[i].kp_proc.p_pid), proclist);
3103#elif defined __OpenBSD__
3104 proclist = Fcons (INT_TO_INTEGER (procs[i].p_pid), proclist);
3095#else 3105#else
3096 proclist = Fcons (INT_TO_INTEGER (procs[i].ki_pid), proclist); 3106 proclist = Fcons (INT_TO_INTEGER (procs[i].ki_pid), proclist);
3097#endif 3107#endif
@@ -3865,8 +3875,21 @@ system_process_attributes (Lisp_Object pid)
3865 if (gr) 3875 if (gr)
3866 attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs); 3876 attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs);
3867 3877
3878 char pathbuf[PROC_PIDPATHINFO_MAXSIZE];
3879 char *comm;
3880
3881 if (proc_pidpath (proc_id, pathbuf, sizeof(pathbuf)) > 0)
3882 {
3883 if ((comm = strrchr (pathbuf, '/')))
3884 comm++;
3885 else
3886 comm = pathbuf;
3887 }
3888 else
3889 comm = proc.kp_proc.p_comm;
3890
3868 decoded_comm = (code_convert_string_norecord 3891 decoded_comm = (code_convert_string_norecord
3869 (build_unibyte_string (proc.kp_proc.p_comm), 3892 (build_unibyte_string (comm),
3870 Vlocale_coding_system, 0)); 3893 Vlocale_coding_system, 0));
3871 3894
3872 attrs = Fcons (Fcons (Qcomm, decoded_comm), attrs); 3895 attrs = Fcons (Fcons (Qcomm, decoded_comm), attrs);
diff --git a/src/timefns.c b/src/timefns.c
index 94cfddf0da9..71d5e10872a 100644
--- a/src/timefns.c
+++ b/src/timefns.c
@@ -1312,11 +1312,12 @@ or (if you need time as a string) `format-time-string'. */)
1312 ((size_t) -1) for MAXSIZE. 1312 ((size_t) -1) for MAXSIZE.
1313 1313
1314 This function behaves like nstrftime, except it allows NUL 1314 This function behaves like nstrftime, except it allows NUL
1315 bytes in FORMAT and it does not support nanoseconds. */ 1315 bytes in FORMAT. */
1316static size_t 1316static size_t
1317emacs_nmemftime (char *s, size_t maxsize, const char *format, 1317emacs_nmemftime (char *s, size_t maxsize, const char *format,
1318 size_t format_len, const struct tm *tp, timezone_t tz, int ns) 1318 size_t format_len, const struct tm *tp, timezone_t tz, int ns)
1319{ 1319{
1320 int saved_errno = errno;
1320 size_t total = 0; 1321 size_t total = 0;
1321 1322
1322 /* Loop through all the NUL-terminated strings in the format 1323 /* Loop through all the NUL-terminated strings in the format
@@ -1326,30 +1327,25 @@ emacs_nmemftime (char *s, size_t maxsize, const char *format,
1326 '\0' byte so we must invoke it separately for each such string. */ 1327 '\0' byte so we must invoke it separately for each such string. */
1327 for (;;) 1328 for (;;)
1328 { 1329 {
1329 size_t len; 1330 errno = 0;
1330 size_t result; 1331 size_t result = nstrftime (s, maxsize, format, tp, tz, ns);
1331 1332 if (result == 0 && errno != 0)
1333 return result;
1332 if (s) 1334 if (s)
1333 s[0] = '\1'; 1335 s += result + 1;
1334
1335 result = nstrftime (s, maxsize, format, tp, tz, ns);
1336
1337 if (s)
1338 {
1339 if (result == 0 && s[0] != '\0')
1340 return 0;
1341 s += result + 1;
1342 }
1343 1336
1344 maxsize -= result + 1; 1337 maxsize -= result + 1;
1345 total += result; 1338 total += result;
1346 len = strlen (format); 1339 size_t len = strlen (format);
1347 if (len == format_len) 1340 if (len == format_len)
1348 return total; 1341 break;
1349 total++; 1342 total++;
1350 format += len + 1; 1343 format += len + 1;
1351 format_len -= len + 1; 1344 format_len -= len + 1;
1352 } 1345 }
1346
1347 errno = saved_errno;
1348 return total;
1353} 1349}
1354 1350
1355static Lisp_Object 1351static Lisp_Object
@@ -1379,10 +1375,11 @@ format_time_string (char const *format, ptrdiff_t formatlen,
1379 1375
1380 while (true) 1376 while (true)
1381 { 1377 {
1382 buf[0] = '\1'; 1378 errno = 0;
1383 len = emacs_nmemftime (buf, size, format, formatlen, tmp, tz, ns); 1379 len = emacs_nmemftime (buf, size, format, formatlen, tmp, tz, ns);
1384 if ((0 < len && len < size) || (len == 0 && buf[0] == '\0')) 1380 if (len != 0 || errno == 0)
1385 break; 1381 break;
1382 eassert (errno == ERANGE);
1386 1383
1387 /* Buffer was too small, so make it bigger and try again. */ 1384 /* Buffer was too small, so make it bigger and try again. */
1388 len = emacs_nmemftime (NULL, SIZE_MAX, format, formatlen, tmp, tz, ns); 1385 len = emacs_nmemftime (NULL, SIZE_MAX, format, formatlen, tmp, tz, ns);
diff --git a/src/window.c b/src/window.c
index e2dea8b70ef..ef58f43a0bd 100644
--- a/src/window.c
+++ b/src/window.c
@@ -7465,7 +7465,7 @@ saved by this function. */)
7465 data->minibuf_selected_window = minibuf_level > 0 ? minibuf_selected_window : Qnil; 7465 data->minibuf_selected_window = minibuf_level > 0 ? minibuf_selected_window : Qnil;
7466 data->root_window = FRAME_ROOT_WINDOW (f); 7466 data->root_window = FRAME_ROOT_WINDOW (f);
7467 data->focus_frame = FRAME_FOCUS_FRAME (f); 7467 data->focus_frame = FRAME_FOCUS_FRAME (f);
7468 Lisp_Object tem = make_uninit_vector (n_windows); 7468 Lisp_Object tem = make_nil_vector (n_windows);
7469 data->saved_windows = tem; 7469 data->saved_windows = tem;
7470 for (ptrdiff_t i = 0; i < n_windows; i++) 7470 for (ptrdiff_t i = 0; i < n_windows; i++)
7471 ASET (tem, i, make_nil_vector (VECSIZE (struct saved_window))); 7471 ASET (tem, i, make_nil_vector (VECSIZE (struct saved_window)));
diff --git a/src/xdisp.c b/src/xdisp.c
index 4fe1c4288af..ad03ac46054 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -180,8 +180,8 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
180 present (non-empty) only if the corresponding display margin is 180 present (non-empty) only if the corresponding display margin is
181 shown in the window. If the glyph array for a marginal area is not 181 shown in the window. If the glyph array for a marginal area is not
182 present its beginning and end coincide, i.e. such arrays are 182 present its beginning and end coincide, i.e. such arrays are
183 actually empty (they contain no glyphs). Frame glyph matrics, used 183 actually empty (they contain no glyphs). Frame glyph matrices, used
184 on text-mode terminals (see below) never have marginal areas, they 184 on text-mode terminals (see below) never have marginal areas; they
185 treat the entire frame-wide row of glyphs as a single large "text 185 treat the entire frame-wide row of glyphs as a single large "text
186 area". 186 area".
187 187
@@ -7555,7 +7555,7 @@ get_next_display_element (struct it *it)
7555 /* Merge `nobreak-space' into the current face. */ 7555 /* Merge `nobreak-space' into the current face. */
7556 face_id = merge_faces (it->w, Qnobreak_space, 0, 7556 face_id = merge_faces (it->w, Qnobreak_space, 0,
7557 it->face_id); 7557 it->face_id);
7558 XSETINT (it->ctl_chars[0], ' '); 7558 XSETINT (it->ctl_chars[0], it->c);
7559 ctl_len = 1; 7559 ctl_len = 1;
7560 goto display_control; 7560 goto display_control;
7561 } 7561 }
@@ -7568,7 +7568,7 @@ get_next_display_element (struct it *it)
7568 /* Merge `nobreak-space' into the current face. */ 7568 /* Merge `nobreak-space' into the current face. */
7569 face_id = merge_faces (it->w, Qnobreak_hyphen, 0, 7569 face_id = merge_faces (it->w, Qnobreak_hyphen, 0,
7570 it->face_id); 7570 it->face_id);
7571 XSETINT (it->ctl_chars[0], '-'); 7571 XSETINT (it->ctl_chars[0], it->c);
7572 ctl_len = 1; 7572 ctl_len = 1;
7573 goto display_control; 7573 goto display_control;
7574 } 7574 }
diff --git a/src/xfaces.c b/src/xfaces.c
index 2c6e593f631..06d2f994de6 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -1572,22 +1572,18 @@ the face font sort order. */)
1572 for (i = nfonts - 1; i >= 0; --i) 1572 for (i = nfonts - 1; i >= 0; --i)
1573 { 1573 {
1574 Lisp_Object font = AREF (vec, i); 1574 Lisp_Object font = AREF (vec, i);
1575 Lisp_Object v = make_uninit_vector (8); 1575 int point = PIXEL_TO_POINT (XFIXNUM (AREF (font, FONT_SIZE_INDEX)) * 10,
1576 int point; 1576 FRAME_RES_Y (f));
1577 Lisp_Object spacing; 1577 Lisp_Object spacing = Ffont_get (font, QCspacing);
1578 1578 Lisp_Object v = CALLN (Fvector,
1579 ASET (v, 0, AREF (font, FONT_FAMILY_INDEX)); 1579 AREF (font, FONT_FAMILY_INDEX),
1580 ASET (v, 1, FONT_WIDTH_SYMBOLIC (font)); 1580 FONT_WIDTH_SYMBOLIC (font),
1581 point = PIXEL_TO_POINT (XFIXNUM (AREF (font, FONT_SIZE_INDEX)) * 10, 1581 make_fixnum (point),
1582 FRAME_RES_Y (f)); 1582 FONT_WEIGHT_SYMBOLIC (font),
1583 ASET (v, 2, make_fixnum (point)); 1583 FONT_SLANT_SYMBOLIC (font),
1584 ASET (v, 3, FONT_WEIGHT_SYMBOLIC (font)); 1584 NILP (spacing) || EQ (spacing, Qp) ? Qnil : Qt,
1585 ASET (v, 4, FONT_SLANT_SYMBOLIC (font)); 1585 Ffont_xlfd_name (font, Qnil),
1586 spacing = Ffont_get (font, QCspacing); 1586 AREF (font, FONT_REGISTRY_INDEX));
1587 ASET (v, 5, (NILP (spacing) || EQ (spacing, Qp)) ? Qnil : Qt);
1588 ASET (v, 6, Ffont_xlfd_name (font, Qnil));
1589 ASET (v, 7, AREF (font, FONT_REGISTRY_INDEX));
1590
1591 result = Fcons (v, result); 1587 result = Fcons (v, result);
1592 } 1588 }
1593 1589
diff --git a/src/xfns.c b/src/xfns.c
index 09dcbbfb92d..78f977bf0aa 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -5890,7 +5890,8 @@ If WINDOW-ID is non-nil, change the property of that window instead
5890 elsize = element_format == 32 ? sizeof (long) : element_format >> 3; 5890 elsize = element_format == 32 ? sizeof (long) : element_format >> 3;
5891 data = xnmalloc (nelements, elsize); 5891 data = xnmalloc (nelements, elsize);
5892 5892
5893 x_fill_property_data (FRAME_X_DISPLAY (f), value, data, element_format); 5893 x_fill_property_data (FRAME_X_DISPLAY (f), value, data, nelements,
5894 element_format);
5894 } 5895 }
5895 else 5896 else
5896 { 5897 {
@@ -6196,10 +6197,10 @@ Otherwise, the return value is a vector with the following fields:
6196 { 6197 {
6197 XFree (tmp_data); 6198 XFree (tmp_data);
6198 6199
6199 prop_attr = make_uninit_vector (3); 6200 prop_attr = CALLN (Fvector,
6200 ASET (prop_attr, 0, make_fixnum (actual_type)); 6201 make_fixnum (actual_type),
6201 ASET (prop_attr, 1, make_fixnum (actual_format)); 6202 make_fixnum (actual_format),
6202 ASET (prop_attr, 2, make_fixnum (bytes_remaining / (actual_format >> 3))); 6203 make_fixnum (bytes_remaining / (actual_format >> 3)));
6203 } 6204 }
6204 6205
6205 unblock_input (); 6206 unblock_input ();
@@ -8027,7 +8028,7 @@ If this equals the symbol 'resize-mode', Emacs uses GTK's resize mode to
8027always trigger an immediate resize of the child frame. This method is 8028always trigger an immediate resize of the child frame. This method is
8028deprecated by GTK and may not work in future versions of that toolkit. 8029deprecated by GTK and may not work in future versions of that toolkit.
8029It also may freeze Emacs when used with other desktop environments. It 8030It also may freeze Emacs when used with other desktop environments. It
8030avoids, however, the unpleasent flicker induced by the hiding approach. 8031avoids, however, the unpleasant flicker induced by the hiding approach.
8031 8032
8032This variable is considered a temporary workaround and will be hopefully 8033This variable is considered a temporary workaround and will be hopefully
8033eliminated in future versions of Emacs. */); 8034eliminated in future versions of Emacs. */);
diff --git a/src/xrdb.c b/src/xrdb.c
index e3a1fcb15a9..3d7f715c88f 100644
--- a/src/xrdb.c
+++ b/src/xrdb.c
@@ -289,9 +289,9 @@ get_user_app (const char *class)
289 /* Check in the home directory. This is a bit of a hack; let's 289 /* Check in the home directory. This is a bit of a hack; let's
290 hope one's home directory doesn't contain ':' or '%'. */ 290 hope one's home directory doesn't contain ':' or '%'. */
291 char const *home = get_homedir (); 291 char const *home = get_homedir ();
292 db = search_magic_path (home, class, "%L/%N"); 292 db = search_magic_path (home, class, "/%L/%N");
293 if (! db) 293 if (! db)
294 db = search_magic_path (home, class, "%N"); 294 db = search_magic_path (home, class, "/%N");
295 } 295 }
296 296
297 return db; 297 return db;
diff --git a/src/xselect.c b/src/xselect.c
index 48d6215a7bb..383aebf96c8 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -1594,7 +1594,7 @@ selection_data_to_lisp_data (struct x_display_info *dpyinfo,
1594 return x_atom_to_symbol (dpyinfo, (Atom) idata[0]); 1594 return x_atom_to_symbol (dpyinfo, (Atom) idata[0]);
1595 else 1595 else
1596 { 1596 {
1597 Lisp_Object v = make_uninit_vector (size / sizeof (int)); 1597 Lisp_Object v = make_nil_vector (size / sizeof (int));
1598 1598
1599 for (i = 0; i < size / sizeof (int); i++) 1599 for (i = 0; i < size / sizeof (int); i++)
1600 ASET (v, i, x_atom_to_symbol (dpyinfo, (Atom) idata[i])); 1600 ASET (v, i, x_atom_to_symbol (dpyinfo, (Atom) idata[i]));
@@ -1653,7 +1653,7 @@ selection_data_to_lisp_data (struct x_display_info *dpyinfo,
1653 else 1653 else
1654 { 1654 {
1655 ptrdiff_t i; 1655 ptrdiff_t i;
1656 Lisp_Object v = make_uninit_vector (size / X_LONG_SIZE); 1656 Lisp_Object v = make_nil_vector (size / X_LONG_SIZE);
1657 1657
1658 if (type == XA_INTEGER) 1658 if (type == XA_INTEGER)
1659 { 1659 {
@@ -1860,7 +1860,7 @@ clean_local_selection_data (Lisp_Object obj)
1860 Lisp_Object copy; 1860 Lisp_Object copy;
1861 if (size == 1) 1861 if (size == 1)
1862 return clean_local_selection_data (AREF (obj, 0)); 1862 return clean_local_selection_data (AREF (obj, 0));
1863 copy = make_uninit_vector (size); 1863 copy = make_nil_vector (size);
1864 for (i = 0; i < size; i++) 1864 for (i = 0; i < size; i++)
1865 ASET (copy, i, clean_local_selection_data (AREF (obj, i))); 1865 ASET (copy, i, clean_local_selection_data (AREF (obj, i)));
1866 return copy; 1866 return copy;
@@ -2276,23 +2276,28 @@ x_check_property_data (Lisp_Object data)
2276 2276
2277 DPY is the display use to look up X atoms. 2277 DPY is the display use to look up X atoms.
2278 DATA is a Lisp list of values to be converted. 2278 DATA is a Lisp list of values to be converted.
2279 RET is the C array that contains the converted values. It is assumed 2279 RET is the C array that contains the converted values.
2280 it is big enough to hold all values. 2280 NELEMENTS_MAX is the number of values that will fit in RET.
2281 Any excess values in DATA are ignored.
2281 FORMAT is 8, 16 or 32 and denotes char/short/long for each C value to 2282 FORMAT is 8, 16 or 32 and denotes char/short/long for each C value to
2282 be stored in RET. Note that long is used for 32 even if long is more 2283 be stored in RET. Note that long is used for 32 even if long is more
2283 than 32 bits (see man pages for XChangeProperty, XGetWindowProperty and 2284 than 32 bits (see man pages for XChangeProperty, XGetWindowProperty and
2284 XClientMessageEvent). */ 2285 XClientMessageEvent). */
2285 2286
2286void 2287void
2287x_fill_property_data (Display *dpy, Lisp_Object data, void *ret, int format) 2288x_fill_property_data (Display *dpy, Lisp_Object data, void *ret,
2289 int nelements_max, int format)
2288{ 2290{
2289 unsigned long val; 2291 unsigned long val;
2290 unsigned long *d32 = (unsigned long *) ret; 2292 unsigned long *d32 = (unsigned long *) ret;
2291 unsigned short *d16 = (unsigned short *) ret; 2293 unsigned short *d16 = (unsigned short *) ret;
2292 unsigned char *d08 = (unsigned char *) ret; 2294 unsigned char *d08 = (unsigned char *) ret;
2295 int nelements;
2293 Lisp_Object iter; 2296 Lisp_Object iter;
2294 2297
2295 for (iter = data; CONSP (iter); iter = XCDR (iter)) 2298 for (iter = data, nelements = 0;
2299 CONSP (iter) && nelements < nelements_max;
2300 iter = XCDR (iter), nelements++)
2296 { 2301 {
2297 Lisp_Object o = XCAR (iter); 2302 Lisp_Object o = XCAR (iter);
2298 2303
@@ -2593,7 +2598,9 @@ x_send_client_event (Lisp_Object display, Lisp_Object dest, Lisp_Object from,
2593 event.xclient.window = to_root ? FRAME_OUTER_WINDOW (f) : wdest; 2598 event.xclient.window = to_root ? FRAME_OUTER_WINDOW (f) : wdest;
2594 2599
2595 memset (event.xclient.data.l, 0, sizeof (event.xclient.data.l)); 2600 memset (event.xclient.data.l, 0, sizeof (event.xclient.data.l));
2601 /* event.xclient.data can hold 20 chars, 10 shorts, or 5 longs. */
2596 x_fill_property_data (dpyinfo->display, values, event.xclient.data.b, 2602 x_fill_property_data (dpyinfo->display, values, event.xclient.data.b,
2603 5 * 32 / event.xclient.format,
2597 event.xclient.format); 2604 event.xclient.format);
2598 2605
2599 /* If event mask is 0 the event is sent to the client that created 2606 /* If event mask is 0 the event is sent to the client that created
diff --git a/src/xterm.c b/src/xterm.c
index 6340700cb89..2e0407aff40 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -8760,6 +8760,20 @@ handle_one_xevent (struct x_display_info *dpyinfo,
8760 goto OTHER; 8760 goto OTHER;
8761 8761
8762 case FocusIn: 8762 case FocusIn:
8763 /* Some WMs (e.g. Mutter in Gnome Shell), don't unmap
8764 minimized/iconified windows; thus, for those WMs we won't get
8765 a MapNotify when unminimizing/deconifying. Check here if we
8766 are deconizing a window (Bug42655). */
8767 f = any;
8768 if (f && FRAME_ICONIFIED_P (f))
8769 {
8770 SET_FRAME_VISIBLE (f, 1);
8771 SET_FRAME_ICONIFIED (f, false);
8772 f->output_data.x->has_been_visible = true;
8773 inev.ie.kind = DEICONIFY_EVENT;
8774 XSETFRAME (inev.ie.frame_or_window, f);
8775 }
8776
8763 x_detect_focus_change (dpyinfo, any, event, &inev.ie); 8777 x_detect_focus_change (dpyinfo, any, event, &inev.ie);
8764 goto OTHER; 8778 goto OTHER;
8765 8779
@@ -9907,6 +9921,13 @@ x_uncatch_errors (void)
9907{ 9921{
9908 struct x_error_message_stack *tmp; 9922 struct x_error_message_stack *tmp;
9909 9923
9924 /* In rare situations when running Emacs run in daemon mode,
9925 shutting down an emacsclient via delete-frame can cause
9926 x_uncatch_errors to be called when x_error_message is set to
9927 NULL. */
9928 if (x_error_message == NULL)
9929 return;
9930
9910 block_input (); 9931 block_input ();
9911 9932
9912 /* The display may have been closed before this function is called. 9933 /* The display may have been closed before this function is called.
diff --git a/src/xterm.h b/src/xterm.h
index bc10043c54c..db8d5847814 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -1207,6 +1207,7 @@ extern int x_check_property_data (Lisp_Object);
1207extern void x_fill_property_data (Display *, 1207extern void x_fill_property_data (Display *,
1208 Lisp_Object, 1208 Lisp_Object,
1209 void *, 1209 void *,
1210 int,
1210 int); 1211 int);
1211extern Lisp_Object x_property_data_to_lisp (struct frame *, 1212extern Lisp_Object x_property_data_to_lisp (struct frame *,
1212 const unsigned char *, 1213 const unsigned char *,
diff --git a/src/xwidget.c b/src/xwidget.c
index c61f5bef88d..154b3e9c82c 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -343,7 +343,7 @@ webkit_js_to_lisp (JSCValue *value)
343 memory_full (SIZE_MAX); 343 memory_full (SIZE_MAX);
344 344
345 ptrdiff_t n = dlen; 345 ptrdiff_t n = dlen;
346 struct Lisp_Vector *p = allocate_vector (n); 346 struct Lisp_Vector *p = allocate_nil_vector (n);
347 347
348 for (ptrdiff_t i = 0; i < n; ++i) 348 for (ptrdiff_t i = 0; i < n; ++i)
349 { 349 {
@@ -361,7 +361,7 @@ webkit_js_to_lisp (JSCValue *value)
361 Lisp_Object obj; 361 Lisp_Object obj;
362 if (PTRDIFF_MAX < n) 362 if (PTRDIFF_MAX < n)
363 memory_full (n); 363 memory_full (n);
364 struct Lisp_Vector *p = allocate_vector (n); 364 struct Lisp_Vector *p = allocate_nil_vector (n);
365 365
366 for (ptrdiff_t i = 0; i < n; ++i) 366 for (ptrdiff_t i = 0; i < n; ++i)
367 { 367 {