+void
+roff_setreg(struct roff *r, const char *name, int val, char sign)
+{
+ struct roffreg *reg;
+
+ /* Search for an existing register with the same name. */
+ reg = r->regtab;
+
+ while (reg && strcmp(name, reg->key.p))
+ reg = reg->next;
+
+ if (NULL == reg) {
+ /* Create a new register. */
+ reg = mandoc_malloc(sizeof(struct roffreg));
+ reg->key.p = mandoc_strdup(name);
+ reg->key.sz = strlen(name);
+ reg->val = 0;
+ reg->next = r->regtab;
+ r->regtab = reg;
+ }
+
+ if ('+' == sign)
+ reg->val += val;
+ else if ('-' == sign)
+ reg->val -= val;
+ else
+ reg->val = val;
+}
+
+/*
+ * Handle some predefined read-only number registers.
+ * For now, return -1 if the requested register is not predefined;
+ * in case a predefined read-only register having the value -1
+ * were to turn up, another special value would have to be chosen.
+ */
+static int
+roff_getregro(const char *name)
+{
+
+ switch (*name) {
+ case ('A'): /* ASCII approximation mode is always off. */
+ return(0);
+ case ('g'): /* Groff compatibility mode is always on. */
+ return(1);
+ case ('H'): /* Fixed horizontal resolution. */
+ return (24);
+ case ('j'): /* Always adjust left margin only. */
+ return(0);
+ case ('T'): /* Some output device is always defined. */
+ return(1);
+ case ('V'): /* Fixed vertical resolution. */
+ return (40);
+ default:
+ return (-1);
+ }
+}
+