Step 1: Use "`using namespace std`", polluting your global namespace.
Step 2: Define identifiers like "`hash`" and "`runtime_error`".
Step 3: Wait years for C++ to incorporate those identifiers.
Step 4: Watch modern compilers trip over the resulting collisions.
Step 5: ???
Step 6: Profit!
Index: src/instance.cc
===================================================================
--- src/instance.cc.orig
+++ src/instance.cc
@@ -287,7 +287,7 @@ void HashSet::Clear(int new_ar)
}
/* the hash algorithm is from
- http://ourworld.compuserve.com/homepages/bob_jenkins/evahash.htm */
+ https://web.archive.org/web/19990218144446/http://ourworld.compuserve.com/homepages/bob_jenkins/evahash.htm */
/* The mixing step */
@@ -305,7 +305,7 @@ void HashSet::Clear(int new_ar)
}
-unsigned long hash(const char *key, unsigned long length,
+unsigned long lparseHash(const char *key, unsigned long length,
unsigned long initval)
{
u4 a, b, c; /* internal state */
@@ -362,9 +362,9 @@ unsigned long HashSet::FindIndex(Instanc
else
table = items;
- ind1 = hash((char *)key, arity*4, SEED_1) % mask;
+ ind1 = lparseHash((char *)key, arity*4, SEED_1) % mask;
if (table[ind1] && !equal_item(key, table[ind1], arity))
- ind2 = (hash((char *)key, arity*4, SEED_2) % mask) + 1;
+ ind2 = (lparseHash((char *)key, arity*4, SEED_2) % mask) + 1;
else
return ind1;
Index: src/error.h
===================================================================
--- src/error.h.orig
+++ src/error.h
@@ -98,6 +98,6 @@ const char *error_file_and_line(long lin
// target system.
#include "term.h"
-void runtime_error(InternalFunction f, ErrorType t, long a1 = 0, long a2 = 0);
+void lparse_runtime_error(InternalFunction f, ErrorType t, long a1 = 0, long a2 = 0);
#endif
Index: src/library.cc
===================================================================
--- src/library.cc.orig
+++ src/library.cc
@@ -164,7 +164,7 @@ long int_plus(int nargs, long *args )
for (i=0; i < nargs; i++) {
if (IS_CONSTANT(args[i]))
- runtime_error(FUN_PLUS, ERR_ARGUMENT, args[i]);
+ lparse_runtime_error(FUN_PLUS, ERR_ARGUMENT, args[i]);
result += args[i];
}
@@ -175,25 +175,25 @@ long int_plus(int nargs, long *args )
long int_exp(int nargs, long *args )
{
if (nargs != 2) {
- runtime_error(FUN_EXP, ERR_NUMARGS, 2);
+ lparse_runtime_error(FUN_EXP, ERR_NUMARGS, 2);
}
long base = args[0];
long power = args[1];
long result = 1;
if (IS_CONSTANT(args[0]))
- runtime_error(FUN_EXP, ERR_ARGUMENT, args[0]);
+ lparse_runtime_error(FUN_EXP, ERR_ARGUMENT, args[0]);
if (IS_CONSTANT(args[1]))
- runtime_error(FUN_EXP, ERR_ARGUMENT, args[1]);
+ lparse_runtime_error(FUN_EXP, ERR_ARGUMENT, args[1]);
if (power < 0)
- runtime_error(FUN_EXP, ERR_ARGUMENT, args[1]);
+ lparse_runtime_error(FUN_EXP, ERR_ARGUMENT, args[1]);
while (power--) {
result *= base;