aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorPip Cet2024-07-10 16:07:38 +0000
committerPip Cet2024-07-10 16:44:52 +0000
commit2416148bf238f7807e1aacccc3e6c2d475faed31 (patch)
treed416801e807e3cb9171dba0d00e4d55b6363968b /src/alloc.c
parent1b810e1b9e3d8a7bef5ed6d1d30a51e8c2547273 (diff)
downloademacs-2416148bf238f7807e1aacccc3e6c2d475faed31.tar.gz
emacs-2416148bf238f7807e1aacccc3e6c2d475faed31.zip
Ensure empty strings are unique and pure
This showed up as differences in .elc files produced by this branch. * src/alloc.c (init_strings): Ensure empty strings are pure. (make_clear_multibyte_string): Return `empty_multibyte_string' when asked for an empty string.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 576850c0029..f67f32f7bc9 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -1771,13 +1771,8 @@ static ptrdiff_t const STRING_BYTES_MAX =
1771static void 1771static void
1772init_strings (void) 1772init_strings (void)
1773{ 1773{
1774#ifdef HAVE_MPS
1775 empty_multibyte_string = igc_make_multibyte_string (0, 0, false);
1776 empty_unibyte_string = igc_make_unibyte_string (0, 0, false);
1777#else
1778 empty_unibyte_string = make_pure_string ("", 0, 0, 0); 1774 empty_unibyte_string = make_pure_string ("", 0, 0, 0);
1779 empty_multibyte_string = make_pure_string ("", 0, 0, 1); 1775 empty_multibyte_string = make_pure_string ("", 0, 0, 1);
1780#endif
1781 staticpro (&empty_unibyte_string); 1776 staticpro (&empty_unibyte_string);
1782 staticpro (&empty_multibyte_string); 1777 staticpro (&empty_multibyte_string);
1783} 1778}
@@ -2631,17 +2626,17 @@ make_uninit_string (EMACS_INT length)
2631static Lisp_Object 2626static Lisp_Object
2632make_clear_multibyte_string (EMACS_INT nchars, EMACS_INT nbytes, bool clearit) 2627make_clear_multibyte_string (EMACS_INT nchars, EMACS_INT nbytes, bool clearit)
2633{ 2628{
2629 if (nchars < 0)
2630 emacs_abort ();
2631 if (!nbytes)
2632 return empty_multibyte_string;
2633
2634#ifdef HAVE_MPS 2634#ifdef HAVE_MPS
2635 return igc_make_multibyte_string (nchars, nbytes, clearit); 2635 return igc_make_multibyte_string (nchars, nbytes, clearit);
2636#else 2636#else
2637 Lisp_Object string; 2637 Lisp_Object string;
2638 struct Lisp_String *s; 2638 struct Lisp_String *s;
2639 2639
2640 if (nchars < 0)
2641 emacs_abort ();
2642 if (!nbytes)
2643 return empty_multibyte_string;
2644
2645 s = allocate_string (); 2640 s = allocate_string ();
2646 s->u.s.intervals = NULL; 2641 s->u.s.intervals = NULL;
2647 allocate_string_data (s, nchars, nbytes, clearit, false); 2642 allocate_string_data (s, nchars, nbytes, clearit, false);