From ff2f6485a554db4b85be46704456bae2d8ffe1cf Mon Sep 17 00:00:00 2001 From: ellson Date: Fri, 19 Sep 2008 20:05:19 +0000 Subject: [PATCH] use the named-ports in \\E to help qualify mutiedge cases --- lib/common/labels.c | 37 +++++++++++++++++++++++++++++++++---- lib/common/types.h | 3 ++- lib/common/utils.c | 2 ++ 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/lib/common/labels.c b/lib/common/labels.c index 560a00252..268c6b725 100644 --- a/lib/common/labels.c +++ b/lib/common/labels.c @@ -262,9 +262,15 @@ void emit_label(GVJ_t * job, emit_state_t emit_state, textlabel_t * lp) char *strdup_and_subst_obj(char *str, void *obj) { char c, *s, *p, *t, *newstr; - char *g_str = "\\G", *n_str = "\\N", *e_str = "\\E", *h_str = "\\H", *t_str = "\\T", *l_str = "\\L"; - int g_len = 2, n_len = 2, e_len = 2, h_len = 2, t_len = 2, l_len, newlen = 0; + char *tp_str = "", *hp_str = "", *etag_str = ""; + char *g_str = "\\G", *n_str = "\\N", *e_str = "\\E", + *h_str = "\\H", *t_str = "\\T", *l_str = "\\L"; + int g_len = 2, n_len = 2, e_len = 2, + h_len = 2, t_len = 2, l_len = 2, + tp_len = 0, hp_len = 0, etag_len = 0; + int newlen = 0; textlabel_t *tl; + port pt; /* prepare substitution strings */ switch (agobjkind(obj)) { @@ -293,8 +299,17 @@ char *strdup_and_subst_obj(char *str, void *obj) g_len = strlen(g_str); t_str = ((edge_t *)obj)->tail->name; t_len = strlen(t_str); + pt = ED_tail_port((edge_t *)obj); + if ((tp_str = pt.name)) + tp_len = strlen(tp_str); h_str = ((edge_t *)obj)->head->name; h_len = strlen(h_str); + pt = ED_head_port((edge_t *)obj); + if ((hp_str = pt.name)) + hp_len = strlen(hp_str); +// etag_str = ((edge_t *)obj)->head->name; + etag_len = strlen(etag_str); + h_len = strlen(h_str); tl = ED_label((edge_t *)obj); if (tl) { l_str = tl->text; @@ -304,7 +319,8 @@ char *strdup_and_subst_obj(char *str, void *obj) e_str = "->"; else e_str = "--"; - e_len = t_len + 2 + h_len; + e_len = t_len + (tp_len?tp_len+1:0) + 2 + + h_len + (hp_len?hp_len+1:0) + (etag_len?etag_len+2:0); break; } @@ -332,7 +348,7 @@ char *strdup_and_subst_obj(char *str, void *obj) newlen += t_len; break; case 'L': - newlen += t_len; + newlen += l_len; break; default: /* leave other escape sequences unmodified, e.g. \n \l \r */ newlen += 2; @@ -356,8 +372,21 @@ char *strdup_and_subst_obj(char *str, void *obj) break; case 'E': for (t = t_str; (*p = *t++); p++); + if (tp_len) { + *p++ = ':'; + for (t = tp_str; (*p = *t++); p++); + } for (t = e_str; (*p = *t++); p++); for (t = h_str; (*p = *t++); p++); + if (hp_len) { + *p++ = ':'; + for (t = hp_str; (*p = *t++); p++); + } + if (etag_len) { + *p++ = '['; + for (t = etag_str; (*p = *t++); p++); + *p++ = ']'; + } break; case 'T': for (t = t_str; (*p = *t++); p++); diff --git a/lib/common/types.h b/lib/common/types.h index d1f37ecaa..0c7fcbf58 100644 --- a/lib/common/types.h +++ b/lib/common/types.h @@ -79,6 +79,7 @@ extern "C" { * contains the bitwise OR of the sides (TOP, * BOTTOM, etc.) it is on. */ + char *name; /* port name, if it was explicitly given, otherwise NULL */ } port; typedef struct { @@ -534,7 +535,7 @@ typedef enum {NATIVEFONTS,PSFONTS,SVGFONTS} fontname_kind; typedef struct Agedgeinfo_t { splines *spl; - port tail_port, head_port; /* might be used someday */ + port tail_port, head_port; textlabel_t *label, *head_label, *tail_label; char edge_type; char adjacent; /* true for flat edge with adjacent nodes */ diff --git a/lib/common/utils.c b/lib/common/utils.c index 1ff842e19..b61205308 100644 --- a/lib/common/utils.c +++ b/lib/common/utils.c @@ -628,9 +628,11 @@ chkPort (port (*pf)(node_t*, char*, char*), node_t* n, char* s) *cp = '\0'; pt = pf(n, s, cp+1); *cp = ':'; + pt.name = cp+1; } else pt = pf(n, s, NULL); + pt.name = s; return pt; } -- 2.40.0