groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 22/34: Un-indirect token concatenation via macro.


From: G. Branden Robinson
Subject: [groff] 22/34: Un-indirect token concatenation via macro.
Date: Thu, 2 Sep 2021 02:48:37 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 4153e4da24f088b29da5e801042cb0a5164a1156
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Aug 28 10:33:48 2021 +1000

    Un-indirect token concatenation via macro.
    
    * src/include/itable.h:
    * src/include/ptable.h: Do it.
---
 ChangeLog            |  7 +++++++
 src/include/itable.h | 10 +++-------
 src/include/ptable.h | 10 +++-------
 3 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 71f5e64..ff3b5ab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2021-08-28  G. Branden Robinson <g.branden.robinson@gmail.com>
 
+       [libgroff]: Un-indirect token concatenation through macro.
+
+       * src/include/itable.h:
+       * src/include/ptable.h: Do it.
+
+2021-08-28  G. Branden Robinson <g.branden.robinson@gmail.com>
+
        [libgroff]: Drop support for `TRADITIONAL_CPP`.  This means a C
        preprocessor that does not support the ANSI C89/ISO C90
        token concatenation operator "##".
diff --git a/src/include/itable.h b/src/include/itable.h
index 29745b9..6ea8670 100644
--- a/src/include/itable.h
+++ b/src/include/itable.h
@@ -19,10 +19,6 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 
 #include <assert.h>
 
-// name2(a,b) concatenates two C identifiers.
-#define name2(a,b) name2x(a,b)
-#define name2x(a,b) a ## b
-
 // 'class ITABLE(T)' is the type of a hash table mapping an integer (int >= 0)
 // to an object of type T.
 //
@@ -34,9 +30,9 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 //
 // Nowadays one would use templates for this; this code predates the addition
 // of templates to C++.
-#define ITABLE(T) name2(T,_itable)
-#define IASSOC(T) name2(T,_iassoc)
-#define ITABLE_ITERATOR(T) name2(T,_itable_iterator)
+#define ITABLE(T) T ## _itable
+#define IASSOC(T) T ## _iassoc
+#define ITABLE_ITERATOR(T) T ## _itable_iterator
 
 // ptable.h declares this too
 #ifndef NEXT_PTABLE_SIZE_DEFINED
diff --git a/src/include/ptable.h b/src/include/ptable.h
index 4bcbefb..edbf74f 100644
--- a/src/include/ptable.h
+++ b/src/include/ptable.h
@@ -20,10 +20,6 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 #include <assert.h>
 #include <string.h>
 
-// name2(a,b) concatenates two C identifiers.
-#define name2(a,b) name2x(a,b)
-#define name2x(a,b) a ## b
-
 // 'class PTABLE(T)' is the type of a hash table mapping a string
 // (const char *) to an object of type T.
 //
@@ -35,9 +31,9 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 //
 // Nowadays one would use templates for this; this code predates the addition
 // of templates to C++.
-#define PTABLE(T) name2(T,_ptable)
-#define PASSOC(T) name2(T,_passoc)
-#define PTABLE_ITERATOR(T) name2(T,_ptable_iterator)
+#define PTABLE(T) T ## _ptable
+#define PASSOC(T) T ## _passoc
+#define PTABLE_ITERATOR(T) T ## _ptable_iterator
 
 // itable.h declares this too
 #ifndef NEXT_PTABLE_SIZE_DEFINED



reply via email to

[Prev in Thread] Current Thread [Next in Thread]