-/*
- * Routines for the perfect-hash hashtable used by the parser to look up
- * tokens by their string-ified names (`.Fl' -> MDOC_Fl). The
- * allocation penalty for this is 27 * 26 * sizeof(ptr).
- */
+#define ADJUST_MAJOR(x) \
+ do if (37 == (x)) \
+ (x) = 0; /* % -> 00 */ \
+ else if (91 > (x)) \
+ (x) -= 64; /* A-Z -> 01 - 26 */ \
+ else \
+ (x) -= 70; /* a-z -> 27 - 52 */ \
+ while (/*CONSTCOND*/0)
+
+#define ADJUST_MINOR(y) \
+ do if (49 == (y)) \
+ (y) = 0; /* 1 -> 00 */ \
+ else if (91 > (y)) \
+ (y) -= 65; /* A-Z -> 00 - 25 */ \
+ else \
+ (y) -= 97; /* a-z -> 00 - 25 */ \
+ while (/*CONSTCOND*/0)
+
+#define INDEX(maj, min) \
+ ((maj) * 26 * 3) + ((min) * 3)
+
+#define SLOTCMP(slot, val) \
+ (mdoc_macronames[(slot)][0] == (val)[0] && \
+ mdoc_macronames[(slot)][1] == (val)[1] && \
+ (0 == (val)[2] || \
+ mdoc_macronames[(slot)][2] == (val)[2]))
+