From d1bed1f79107c8377ffaea160acd815008fab4f7 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 10 Sep 2014 13:56:05 -0700 Subject: [PATCH] Simplify lisp.h by removing the __COUNTER__ business. Problem reported by Dmitry Antipov in: http://lists.gnu.org/archive/html/emacs-devel/2014-09/msg00220.html * lisp.h (make_local_vector, make_local_string) (build_local_string): Simplify by not bothering with __COUNTER__. The __COUNTER__ business wasn't working properly, and was needed only for hypothetical future expansion anyway. --- src/ChangeLog | 10 ++++++++++ src/lisp.h | 52 ++++++++++++++++++++++----------------------------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 5498a07a0da..50f5fb8ca1e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2014-09-10 Paul Eggert + + Simplify lisp.h by removing the __COUNTER__ business. + Problem reported by Dmitry Antipov in: + http://lists.gnu.org/archive/html/emacs-devel/2014-09/msg00220.html + * lisp.h (make_local_vector, make_local_string) + (build_local_string): Simplify by not bothering with __COUNTER__. + The __COUNTER__ business wasn't working properly, and was needed + only for hypothetical future expansion anyway. + 2014-09-10 Alp Aker * nsterm.m (ns_draw_fringe_bitmap): Use the same logic as other diff --git a/src/lisp.h b/src/lisp.h index 1415ab270bc..468e8f9fa1c 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4563,58 +4563,50 @@ verify (sizeof (struct Lisp_Cons) == sizeof (union Aligned_Cons)); # define scoped_list3(x, y, z) list3 (x, y, z) #endif -#if USE_STACK_LISP_OBJECTS && HAVE_STATEMENT_EXPRESSIONS && defined __COUNTER__ +#if USE_STACK_LISP_OBJECTS && HAVE_STATEMENT_EXPRESSIONS # define USE_LOCAL_ALLOCATORS /* Return a function-scoped vector of length SIZE, with each element being INIT. */ -# define make_local_vector(size, init) \ - make_local_vector_n (size, init, __COUNTER__) -# define make_local_vector_n(size_arg, init_arg, n) \ +# define make_local_vector(size, init) \ ({ \ - ptrdiff_t size##n = size_arg; \ - Lisp_Object init##n = init_arg; \ - Lisp_Object vec##n; \ - if (size##n <= (MAX_ALLOCA - header_size) / word_size) \ + ptrdiff_t size_ = size; \ + Lisp_Object init_ = init; \ + Lisp_Object vec_; \ + if (size_ <= (MAX_ALLOCA - header_size) / word_size) \ { \ - void *ptr##n = alloca (size##n * word_size + header_size); \ - vec##n = local_vector_init (ptr##n, size##n, init##n); \ + void *ptr_ = alloca (size_ * word_size + header_size); \ + vec_ = local_vector_init (ptr_, size_, init_); \ } \ else \ - vec##n = Fmake_vector (make_number (size##n), init##n); \ - vec##n; \ + vec_ = Fmake_vector (make_number (size_), init_); \ + vec_; \ }) /* Return a function-scoped string with contents DATA and length NBYTES. */ -# define make_local_string(data, nbytes) \ - make_local_string (data, nbytes, __COUNTER__) -# define make_local_string_n(data_arg, nbytes_arg, n) \ +# define make_local_string(data, nbytes) \ ({ \ - char const *data##n = data_arg; \ - ptrdiff_t nbytes##n = nbytes_arg; \ - Lisp_Object string##n; \ - if (nbytes##n <= MAX_ALLOCA - sizeof (struct Lisp_String) - 1) \ + char const *data_ = data; \ + ptrdiff_t nbytes_ = nbytes; \ + Lisp_Object string_; \ + if (nbytes_ <= MAX_ALLOCA - sizeof (struct Lisp_String) - 1) \ { \ - struct Lisp_String *ptr##n \ - = alloca (sizeof (struct Lisp_String) + 1 + nbytes); \ - string##n = local_string_init (ptr##n, data##n, nbytes##n); \ + struct Lisp_String *ptr_ = alloca (sizeof (struct Lisp_String) + 1 \ + + nbytes_); \ + string_ = local_string_init (ptr_, data_, nbytes_); \ } \ else \ - string##n = make_string (data##n, nbytes##n); \ - string##n; \ + string_ = make_string (data_, nbytes_); \ + string_; \ }) /* Return a function-scoped string with contents DATA. */ -# define build_local_string(data) build_local_string_n (data, __COUNTER__) -# define build_local_string_n(data_arg, n) \ - ({ \ - char const *data##n = data_arg; \ - make_local_string (data##n, strlen (data##n)); \ - }) +# define build_local_string(data) \ + ({ char const *data_ = data; make_local_string (data_, strlen (data_)); }) #else -- 2.39.5