make some formatting changes in utils.c.
}
#endif
-void initHTMLlexer(char *src, agxbuf * xb)
+int initHTMLlexer(char *src, agxbuf * xb)
{
#ifdef HAVE_LIBEXPAT
state.xb = xb;
(XML_StartElementHandler) startElement,
endElement);
XML_SetCharacterDataHandler(state.parser, characterData);
+ return 0;
#else
static int first;
- if (first) {
+ if (!first) {
agerr(AGWARN,
"Not built with libexpat. Table formatting is not available.\n");
first++;
}
+ return 1;
#endif
}
#include <agxbuf.h>
- extern void initHTMLlexer(char *, agxbuf *);
+ extern int initHTMLlexer(char *, agxbuf *);
extern int htmllex();
extern int htmllineno();
extern int clearHTMLlexer();
lp->just = 'n';
}
- dtclear (lines);
+ if (lines) dtclear (lines);
return tp;
}
%%
+htmllabel_t*
+simpleHTML (char* txt)
+{
+ htmltxt_t* tobj = mkText (txt);
+ htmllabel_t* l = mkLabel(tobj,HTML_TEXT);
+ return l;
+}
+
+/* parseHTML:
+ * Return parsed label or NULL if failure.
+ * Set warn to 0 on success; 1 for warning message; 2 if no expat.
+ */
htmllabel_t*
parseHTML (char* txt, int* warn)
{
unsigned char buf[SMALLBUF];
agxbuf str;
+ htmllabel_t* l;
HTMLstate.tblstack = 0;
HTMLstate.lbl = 0;
agxbinit (&str, SMALLBUF, buf);
HTMLstate.str = &str;
- initHTMLlexer (txt, &str);
- yyparse();
- *warn = clearHTMLlexer ();
+ if (initHTMLlexer (txt, &str)) {/* failed: no libexpat - give up */
+ *warn = 2;
+ l = NULL;
+ }
+ else {
+ yyparse();
+ *warn = clearHTMLlexer ();
+ l = HTMLstate.lbl;
+ }
dtclose (HTMLstate.lines);
+ HTMLstate.lines = NULL;
agxbfree (&str);
- return HTMLstate.lbl;
+ return l;
}
}
/* make_html_label:
- * Return 1 if problem parsing HTML. In this case, use object name.
+ * Return non-zero if problem parsing HTML. In this case, use object name.
*/
int make_html_label(textlabel_t * lp, void *obj)
{
agxbuf xb;
unsigned char buf[SMALLBUF];
agxbinit(&xb, SMALLBUF, buf);
- lbl = parseHTML(nameOf(obj, &xb), &rv);
- assert(lbl);
- rv = 1;
+ lbl = simpleHTML(nameOf(obj, &xb));
agxbfree(&xb);
}
} pitem;
extern htmllabel_t *parseHTML(char *, int *);
+ extern htmllabel_t *simpleHTML(char *);
extern int make_html_label(textlabel_t * lp, void *obj);
extern void emit_html_label(GVC_t * gvc, htmllabel_t * lp,
"fontcolor"),
DEFAULT_COLOR), sg);
if (html) {
- if (make_html_label(GD_label(sg), sg))
+ if (make_html_label(GD_label(sg), sg) == 1)
agerr(AGPREV, "in label of graph %s\n", sg->name);
}
late_nnstring(n, N_fontcolor, DEFAULT_COLOR),
n->graph);
if (html) {
- if (make_html_label(ND_label(n), n))
+ if (make_html_label(ND_label(n), n) == 1)
agerr(AGPREV, "in label of node %s\n", n->name);
}
ND_shape(n) =
static boolean
wantClip(edge_t *e, attrsym_t* sym)
{
- char *str;
- boolean rv = TRUE;
+ char *str;
+ boolean rv = TRUE;
- if (sym) { /* mapbool isn't a good fit, because we want "" to mean TRUE */
- str = agxget(e,sym->index);
- if (str && str[0]) rv = mapbool(str);
- else rv = TRUE;
- }
- return rv;
+ if (sym) { /* mapbool isn't a good fit, because we want "" to mean TRUE */
+ str = agxget(e,sym->index);
+ if (str && str[0]) rv = mapbool(str);
+ else rv = TRUE;
+ }
+ return rv;
}
/*chkPort:
fi.fontsize, fi.fontname, fi.fontcolor,
e->tail->graph);
if (html) {
- if (make_html_label(ED_label(e), e))
+ if (make_html_label(ED_label(e), e) == 1)
edgeError(e, "label");
}
GD_has_labels(e->tail->graph) |= EDGE_LABEL;
lfi.fontsize, lfi.fontname,
lfi.fontcolor, e->tail->graph);
if (html) {
- if (make_html_label(ED_head_label(e), e))
+ if (make_html_label(ED_head_label(e), e) == 1)
edgeError(e, "head label");
}
GD_has_labels(e->tail->graph) |= HEAD_LABEL;
lfi.fontsize, lfi.fontname,
lfi.fontcolor, e->tail->graph);
if (html) {
- if (make_html_label(ED_tail_label(e), e))
+ if (make_html_label(ED_tail_label(e), e) == 1)
edgeError(e, "tail label");
}
GD_has_labels(e->tail->graph) |= TAIL_LABEL;
return p;
}
-/* invflip_ptf:
+/* invflip_pt:
* Transform point =>
* LR - rotate cw by 90
* BT - reflect across x axis