summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorG. Branden Robinson <g.branden.robinson@gmail.com>2023-03-06 12:50:15 -0600
committerG. Branden Robinson <g.branden.robinson@gmail.com>2023-03-06 15:19:55 -0600
commit5848bf3a3ee43a8be529d5d8bcef7a80c1ef3934 (patch)
tree5f7c5b1c8ae31f8d4b53bd8ef79cbe285d19b162 /src
parent405fe32847a598962dc3ad8469b9ed0bac4c50ba (diff)
downloadgroff-git-5848bf3a3ee43a8be529d5d8bcef7a80c1ef3934.tar.gz
Use a better type for symbol hashes.
* bootstrap.conf: Add "stdint" module to ensure that the `uintptr_t` type is available. * src/include/symbol.h: Include <stdint.h> for `uintptr_t`. (class symbol): (symbol::hash): Change return type from `unsigned long`, which causes build failures on 64-bit MinGW, to `uintptr_t`. (symbol::hash): Use a C++ type cast, not a C-style one. Thanks to Bruno Haible for reporting the build failure in the 64-bit MinGW environment, and for suggesting a remedy. Also update editor aid comments; drop old style Emacs file-local variable setting. Any day you get to use the foot-Howitzer reinterpret_cast is a good one. Commits since 0221b657fe tested on: Debian bullseye Debian sid 2023-03-06 chroot macOS 12 OpenBSD 7.2 Solaris 10 Solaris 11
Diffstat (limited to 'src')
-rw-r--r--src/include/symbol.h17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/include/symbol.h b/src/include/symbol.h
index e8bf81946..047255d3b 100644
--- a/src/include/symbol.h
+++ b/src/include/symbol.h
@@ -1,5 +1,4 @@
-// -*- C++ -*-
-/* Copyright (C) 1989-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2023 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -17,6 +16,8 @@ for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#include <stdint.h> // uintptr_t
+
#define DONT_STORE 1
#define MUST_ALREADY_EXIST 2
@@ -30,7 +31,7 @@ class symbol {
public:
symbol(const char *p, int how = 0);
symbol();
- unsigned long hash() const;
+ uintptr_t hash() const;
int operator ==(symbol) const;
int operator !=(symbol) const;
const char *contents() const;
@@ -56,9 +57,9 @@ inline int symbol::operator!=(symbol p) const
return s != p.s;
}
-inline unsigned long symbol::hash() const
+inline uintptr_t symbol::hash() const
{
- return (unsigned long)s;
+ return reinterpret_cast<uintptr_t>(s);
}
inline const char *symbol::contents() const
@@ -79,3 +80,9 @@ inline int symbol::is_empty() const
symbol concat(symbol, symbol);
extern symbol default_symbol;
+
+// Local Variables:
+// fill-column: 72
+// mode: C++
+// End:
+// vim: set cindent noexpandtab shiftwidth=2 textwidth=72: