aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorVibhav Pant2023-06-06 19:30:27 +0530
committerVibhav Pant2023-06-06 19:30:27 +0530
commit49ffcbf86a32a8a217538d4df3736fe069ccf35d (patch)
treea5f16157cc20fb19a844473a6fbd2b434f4c8260 /src/buffer.c
parentaf569fa3d90a717983b743eb97adbf869c6d1736 (diff)
parent7ca1d782f5910d0c3978c6798a45c6854ec668c7 (diff)
downloademacs-49ffcbf86a32a8a217538d4df3736fe069ccf35d.tar.gz
emacs-49ffcbf86a32a8a217538d4df3736fe069ccf35d.zip
Merge branch 'master' into scratch/comp-static-data
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c52
1 files changed, 33 insertions, 19 deletions
diff --git a/src/buffer.c b/src/buffer.c
index df1f5206668..0c46b201586 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -50,6 +50,14 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
50#include "w32heap.h" /* for mmap_* */ 50#include "w32heap.h" /* for mmap_* */
51#endif 51#endif
52 52
53/* Work around GCC bug 109847
54 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109847
55 which causes GCC to mistakenly complain about
56 AUTO_STRING with "*scratch*". */
57#if GNUC_PREREQ (13, 0, 0)
58# pragma GCC diagnostic ignored "-Wanalyzer-out-of-bounds"
59#endif
60
53/* This structure holds the default values of the buffer-local variables 61/* This structure holds the default values of the buffer-local variables
54 defined with DEFVAR_PER_BUFFER, that have special slots in each buffer. 62 defined with DEFVAR_PER_BUFFER, that have special slots in each buffer.
55 The default value occupies the same slot in this structure 63 The default value occupies the same slot in this structure
@@ -1307,7 +1315,7 @@ buffer_local_value (Lisp_Object variable, Lisp_Object buffer)
1307 start: 1315 start:
1308 switch (sym->u.s.redirect) 1316 switch (sym->u.s.redirect)
1309 { 1317 {
1310 case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; 1318 case SYMBOL_VARALIAS: sym = SYMBOL_ALIAS (sym); goto start;
1311 case SYMBOL_PLAINVAL: result = SYMBOL_VAL (sym); break; 1319 case SYMBOL_PLAINVAL: result = SYMBOL_VAL (sym); break;
1312 case SYMBOL_LOCALIZED: 1320 case SYMBOL_LOCALIZED:
1313 { /* Look in local_var_alist. */ 1321 { /* Look in local_var_alist. */
@@ -2386,6 +2394,7 @@ Any narrowing restriction in effect (see `narrow-to-region') is removed,
2386so the buffer is truly empty after this. */) 2394so the buffer is truly empty after this. */)
2387 (void) 2395 (void)
2388{ 2396{
2397 labeled_restrictions_remove_in_current_buffer ();
2389 Fwiden (); 2398 Fwiden ();
2390 2399
2391 del_range (BEG, Z); 2400 del_range (BEG, Z);
@@ -3334,7 +3343,7 @@ record_overlay_string (struct sortstrlist *ssl, Lisp_Object str,
3334 else 3343 else
3335 nbytes = SBYTES (str); 3344 nbytes = SBYTES (str);
3336 3345
3337 if (INT_ADD_WRAPV (ssl->bytes, nbytes, &nbytes)) 3346 if (ckd_add (&nbytes, nbytes, ssl->bytes))
3338 memory_full (SIZE_MAX); 3347 memory_full (SIZE_MAX);
3339 ssl->bytes = nbytes; 3348 ssl->bytes = nbytes;
3340 3349
@@ -3348,7 +3357,7 @@ record_overlay_string (struct sortstrlist *ssl, Lisp_Object str,
3348 else 3357 else
3349 nbytes = SBYTES (str2); 3358 nbytes = SBYTES (str2);
3350 3359
3351 if (INT_ADD_WRAPV (ssl->bytes, nbytes, &nbytes)) 3360 if (ckd_add (&nbytes, nbytes, ssl->bytes))
3352 memory_full (SIZE_MAX); 3361 memory_full (SIZE_MAX);
3353 ssl->bytes = nbytes; 3362 ssl->bytes = nbytes;
3354 } 3363 }
@@ -3420,7 +3429,7 @@ overlay_strings (ptrdiff_t pos, struct window *w, unsigned char **pstr)
3420 unsigned char *p; 3429 unsigned char *p;
3421 ptrdiff_t total; 3430 ptrdiff_t total;
3422 3431
3423 if (INT_ADD_WRAPV (overlay_heads.bytes, overlay_tails.bytes, &total)) 3432 if (ckd_add (&total, overlay_heads.bytes, overlay_tails.bytes))
3424 memory_full (SIZE_MAX); 3433 memory_full (SIZE_MAX);
3425 if (total > overlay_str_len) 3434 if (total > overlay_str_len)
3426 overlay_str_buf = xpalloc (overlay_str_buf, &overlay_str_len, 3435 overlay_str_buf = xpalloc (overlay_str_buf, &overlay_str_len,
@@ -5124,33 +5133,38 @@ A list whose car is an integer is processed by processing the cadr of
5124 negative) to the width specified by that number. 5133 negative) to the width specified by that number.
5125 5134
5126A string is printed verbatim in the mode line except for %-constructs: 5135A string is printed verbatim in the mode line except for %-constructs:
5127 %b -- print buffer name. %f -- print visited file name. 5136 %b -- print buffer name.
5128 %F -- print frame name.
5129 %* -- print %, * or hyphen. %+ -- print *, % or hyphen.
5130 %& is like %*, but ignore read-only-ness.
5131 % means buffer is read-only and * means it is modified.
5132 For a modified read-only buffer, %* gives % and %+ gives *.
5133 %s -- print process status. %l -- print the current line number.
5134 %c -- print the current column number (this makes editing slower). 5137 %c -- print the current column number (this makes editing slower).
5135 Columns are numbered starting from the left margin, and the 5138 Columns are numbered starting from the left margin, and the
5136 leftmost column is displayed as zero. 5139 leftmost column is displayed as zero.
5137 To make the column number update correctly in all cases, 5140 To make the column number update correctly in all cases,
5138 `column-number-mode' must be non-nil. 5141 `column-number-mode' must be non-nil.
5139 %C -- Like %c, but the leftmost column is displayed as one. 5142 %C -- Like %c, but the leftmost column is displayed as one.
5143 %e -- print error message about full memory.
5144 %f -- print visited file name.
5145 %F -- print frame name.
5140 %i -- print the size of the buffer. 5146 %i -- print the size of the buffer.
5141 %I -- like %i, but use k, M, G, etc., to abbreviate. 5147 %I -- like %i, but use k, M, G, etc., to abbreviate.
5148 %l -- print the current line number.
5149 %n -- print Narrow if appropriate.
5150 %o -- print percent of window travel through buffer, or Top, Bot or All.
5142 %p -- print percent of buffer above top of window, or Top, Bot or All. 5151 %p -- print percent of buffer above top of window, or Top, Bot or All.
5143 %P -- print percent of buffer above bottom of window, perhaps plus Top, 5152 %P -- print percent of buffer above bottom of window, perhaps plus Top,
5144 or print Bottom or All. 5153 or print Bottom or All.
5145 %n -- print Narrow if appropriate. 5154 %q -- print percent of buffer above both the top and the bottom of the
5146 %t -- visited file is text or binary (if OS supports this distinction). 5155 window, separated by β€˜-’, or β€˜All’.
5156 %s -- print process status.
5147 %z -- print mnemonics of keyboard, terminal, and buffer coding systems. 5157 %z -- print mnemonics of keyboard, terminal, and buffer coding systems.
5148 %Z -- like %z, but including the end-of-line format. 5158 %Z -- like %z, but including the end-of-line format.
5149 %e -- print error message about full memory. 5159 %& -- print * if the buffer is modified, otherwise hyphen.
5150 %@ -- print @ or hyphen. @ means that default-directory is on a 5160 %+ -- print *, % or hyphen (modified, read-only, neither).
5151 remote machine. 5161 %* -- print %, * or hyphen (read-only, modified, neither).
5152 %[ -- print one [ for each recursive editing level. %] similar. 5162 For a modified read-only buffer, %+ prints * and %* prints %.
5153 %% -- print %. %- -- print infinitely many dashes. 5163 %@ -- print @ if default-directory is on a remote machine, else hyphen.
5164 %[ -- print one [ for each recursive editing level.
5165 %] -- print one ] for each recursive editing level.
5166 %- -- print enough dashes to fill the mode line.
5167 %% -- print %.
5154Decimal digits after the % specify field width to which to pad. */); 5168Decimal digits after the % specify field width to which to pad. */);
5155 5169
5156 DEFVAR_PER_BUFFER ("major-mode", &BVAR (current_buffer, major_mode), 5170 DEFVAR_PER_BUFFER ("major-mode", &BVAR (current_buffer, major_mode),