aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2019-07-09 13:10:27 -0700
committerPaul Eggert2019-07-09 13:11:45 -0700
commit412139f1be7415791a0d964f95f319c86eded426 (patch)
treef6f2326b39ea44a93004df25ba98ab210246860f /src
parentce59b41a28aba629dd126e7af3c6e45909de6a83 (diff)
downloademacs-412139f1be7415791a0d964f95f319c86eded426.tar.gz
emacs-412139f1be7415791a0d964f95f319c86eded426.zip
Do not alter match data in Fcapitalize etc.
Without this patch, (capitalize "x") can alter the match data, which is not what users expect. Problem found by running morse-tests-unnato-region in a stripped-down Emacs. Perhaps ‘load’ should also save and restore the match data? That would be a simpler fix, though arguably incompatible. * src/lread.c (save_match_data_load): New function. * src/chartab.c (uniprop_table): * src/doc.c (reread_doc_file): * src/eval.c (Fautoload_do_load): * src/fns.c (Frequire): Use it.
Diffstat (limited to 'src')
-rw-r--r--src/chartab.c2
-rw-r--r--src/doc.c2
-rw-r--r--src/eval.c5
-rw-r--r--src/fns.c5
-rw-r--r--src/lisp.h2
-rw-r--r--src/lread.c11
6 files changed, 19 insertions, 8 deletions
diff --git a/src/chartab.c b/src/chartab.c
index bf8e34b2529..04205ac1032 100644
--- a/src/chartab.c
+++ b/src/chartab.c
@@ -1288,7 +1288,7 @@ uniprop_table (Lisp_Object prop)
1288 if (STRINGP (table)) 1288 if (STRINGP (table))
1289 { 1289 {
1290 AUTO_STRING (intl, "international/"); 1290 AUTO_STRING (intl, "international/");
1291 result = Fload (concat2 (intl, table), Qt, Qt, Qt, Qt); 1291 result = save_match_data_load (concat2 (intl, table), Qt, Qt, Qt, Qt);
1292 if (NILP (result)) 1292 if (NILP (result))
1293 return Qnil; 1293 return Qnil;
1294 table = XCDR (val); 1294 table = XCDR (val);
diff --git a/src/doc.c b/src/doc.c
index 8875360d6e6..8b663f0f249 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -302,7 +302,7 @@ reread_doc_file (Lisp_Object file)
302 if (NILP (file)) 302 if (NILP (file))
303 Fsnarf_documentation (Vdoc_file_name); 303 Fsnarf_documentation (Vdoc_file_name);
304 else 304 else
305 Fload (file, Qt, Qt, Qt, Qnil); 305 save_match_data_load (file, Qt, Qt, Qt, Qnil);
306 306
307 return 1; 307 return 1;
308} 308}
diff --git a/src/eval.c b/src/eval.c
index 8f569949036..02a6c3555a9 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2049,9 +2049,6 @@ it defines a macro. */)
2049 2049
2050 CHECK_SYMBOL (funname); 2050 CHECK_SYMBOL (funname);
2051 2051
2052 /* Preserve the match data. */
2053 record_unwind_save_match_data ();
2054
2055 /* If autoloading gets an error (which includes the error of failing 2052 /* If autoloading gets an error (which includes the error of failing
2056 to define the function being called), we use Vautoload_queue 2053 to define the function being called), we use Vautoload_queue
2057 to undo function definitions and `provide' calls made by 2054 to undo function definitions and `provide' calls made by
@@ -2067,7 +2064,7 @@ it defines a macro. */)
2067 so don't signal an error if autoloading fails. */ 2064 so don't signal an error if autoloading fails. */
2068 Lisp_Object ignore_errors 2065 Lisp_Object ignore_errors
2069 = (EQ (kind, Qt) || EQ (kind, Qmacro)) ? Qnil : macro_only; 2066 = (EQ (kind, Qt) || EQ (kind, Qmacro)) ? Qnil : macro_only;
2070 Fload (Fcar (Fcdr (fundef)), ignore_errors, Qt, Qnil, Qt); 2067 save_match_data_load (Fcar (Fcdr (fundef)), ignore_errors, Qt, Qnil, Qt);
2071 2068
2072 /* Once loading finishes, don't undo it. */ 2069 /* Once loading finishes, don't undo it. */
2073 Vautoload_queue = Qt; 2070 Vautoload_queue = Qt;
diff --git a/src/fns.c b/src/fns.c
index 77c0b15037f..11f5dddc858 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -2984,8 +2984,9 @@ suppressed. */)
2984 Vautoload_queue = Qt; 2984 Vautoload_queue = Qt;
2985 2985
2986 /* Load the file. */ 2986 /* Load the file. */
2987 tem = Fload (NILP (filename) ? Fsymbol_name (feature) : filename, 2987 tem = save_match_data_load
2988 noerror, Qt, Qnil, (NILP (filename) ? Qt : Qnil)); 2988 (NILP (filename) ? Fsymbol_name (feature) : filename,
2989 noerror, Qt, Qnil, (NILP (filename) ? Qt : Qnil));
2989 2990
2990 /* If load failed entirely, return nil. */ 2991 /* If load failed entirely, return nil. */
2991 if (NILP (tem)) 2992 if (NILP (tem))
diff --git a/src/lisp.h b/src/lisp.h
index 8acf63fe227..fa57cad8a60 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4019,6 +4019,8 @@ LOADHIST_ATTACH (Lisp_Object x)
4019 if (initialized) 4019 if (initialized)
4020 Vcurrent_load_list = Fcons (x, Vcurrent_load_list); 4020 Vcurrent_load_list = Fcons (x, Vcurrent_load_list);
4021} 4021}
4022extern Lisp_Object save_match_data_load (Lisp_Object, Lisp_Object, Lisp_Object,
4023 Lisp_Object, Lisp_Object);
4022extern int openp (Lisp_Object, Lisp_Object, Lisp_Object, 4024extern int openp (Lisp_Object, Lisp_Object, Lisp_Object,
4023 Lisp_Object *, Lisp_Object, bool); 4025 Lisp_Object *, Lisp_Object, bool);
4024enum { S2N_IGNORE_TRAILING = 1 }; 4026enum { S2N_IGNORE_TRAILING = 1 };
diff --git a/src/lread.c b/src/lread.c
index e06eafcf6cf..3152fcf867d 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1508,6 +1508,17 @@ Return t if the file exists and loads successfully. */)
1508 1508
1509 return Qt; 1509 return Qt;
1510} 1510}
1511
1512Lisp_Object
1513save_match_data_load (Lisp_Object file, Lisp_Object noerror,
1514 Lisp_Object nomessage, Lisp_Object nosuffix,
1515 Lisp_Object must_suffix)
1516{
1517 ptrdiff_t count = SPECPDL_INDEX ();
1518 record_unwind_save_match_data ();
1519 Lisp_Object result = Fload (file, noerror, nomessage, nosuffix, must_suffix);
1520 return unbind_to (count, result);
1521}
1511 1522
1512static bool 1523static bool
1513complete_filename_p (Lisp_Object pathname) 1524complete_filename_p (Lisp_Object pathname)