#include "htmltable.h"
#include <limits.h>
+static char *strdup_and_subst_obj0 (char *str, void *obj, int escBackslash);
+
static void storeline(graph_t *g, textlabel_t *lp, char *line, char terminator)
{
pointf size;
}
else {
assert(kind == LT_NONE);
- rv->text = strdup_and_subst_obj(str, obj);
+ /* This call just processes the graph object based escape sequences. The formatting escape
+ * sequences (\n, \l, \r) are processed in make_simple_label. That call also replaces \\ with \.
+ */
+ rv->text = strdup_and_subst_obj0(str, obj, 0);
switch (rv->charset) {
case CHAR_LATIN1:
s = latin1ToUTF8(rv->text);
obj->emit_state = old_emit_state;
}
-char *strdup_and_subst_obj(char *str, void *obj)
+/* strdup_and_subst_obj0:
+ * Replace various escape sequences with the name of the associated
+ * graph object. A double backslash \\ can be used to avoid a replacement.
+ * If escBackslash is true, convert \\ to \; else leave alone. All other dyads
+ * of the form \. are passed through unchanged.
+ */
+static char *strdup_and_subst_obj0 (char *str, void *obj, int escBackslash)
{
char c, *s, *p, *t, *newstr;
char *tp_str = "", *hp_str = "";
case 'L':
newlen += l_len;
break;
-#ifdef ESCAPE_BACKSLASH
case '\\':
- newlen += 1;
- break;
-#endif
+ if (escBackslash) {
+ newlen += 1;
+ break;
+ }
+ /* Fall through */
default: /* leave other escape sequences unmodified, e.g. \n \l \r */
newlen += 2;
}
case 'L':
for (t = l_str; (*p = *t++); p++);
break;
-#ifdef ESCAPE_BACKSLASH
case '\\':
- *p++ = '\\';
- break;
-#endif
+ if (escBackslash) {
+ *p++ = '\\';
+ break;
+ }
+ /* Fall through */
default: /* leave other escape sequences unmodified, e.g. \n \l \r */
*p++ = '\\';
*p++ = c;
return newstr;
}
+/* strdup_and_subst_obj:
+ * Processes graph object escape sequences; also collapses \\ to \.
+ */
+char *strdup_and_subst_obj(char *str, void *obj)
+{
+ return strdup_and_subst_obj0 (str, obj, 1);
+}
+
/* return true if *s points to &[A-Za-z]*; (e.g. Ç )
* or &#[0-9]*; (e.g. & )
* or &#x[0-9a-fA-F]*; (e.g. 水 )