From b8a90c8f9ae78e8bcb556ddbfb2def55515e1655 Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Mon, 28 Jan 2013 16:33:54 +0000 Subject: fix incorrect use of pointer equality when comparing anchor strings --- tikzit/src/common/Edge.m | 4 ++-- tikzit/src/common/Graph.m | 23 +++++++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) (limited to 'tikzit/src/common') diff --git a/tikzit/src/common/Edge.m b/tikzit/src/common/Edge.m index 3e25888..4ecb9bf 100644 --- a/tikzit/src/common/Edge.m +++ b/tikzit/src/common/Edge.m @@ -39,8 +39,8 @@ source = nil; target = nil; edgeNode = nil; - sourceAnchor = [[NSString alloc] initWithString:@""]; - targetAnchor = [[NSString alloc] initWithString:@""]; + sourceAnchor = @""; + targetAnchor = @""; return self; } diff --git a/tikzit/src/common/Graph.m b/tikzit/src/common/Graph.m index c8da128..767f307 100644 --- a/tikzit/src/common/Graph.m +++ b/tikzit/src/common/Graph.m @@ -722,14 +722,33 @@ } NSString *edata = [[e data] stringList]; + + NSString *srcAnchor; + NSString *tgtAnchor; + + if ([[e source] style] == nil) { + srcAnchor = @".center"; + } else if ([[e sourceAnchor] isEqual:@""]) { + srcAnchor = @""; + } else { + srcAnchor = [NSString stringWithFormat:@".%@", [e sourceAnchor]]; + } + + if ([[e target] style] == nil) { + tgtAnchor = @".center"; + } else if ([[e targetAnchor] isEqual:@""]) { + tgtAnchor = @""; + } else { + tgtAnchor = [NSString stringWithFormat:@".%@", [e targetAnchor]]; + } [code appendFormat:@"\t\t\\draw%@ (%@%@) to %@(%@%@);\n", ([edata isEqual:@""]) ? @"" : [NSString stringWithFormat:@" %@", edata], [[e source] name], - ([[e source] style] == nil) ? @".center" : ([e sourceAnchor] == @"") ? @"" : [NSString stringWithFormat:@".%@", [e sourceAnchor]], + srcAnchor, nodeStr, ([e source] == [e target]) ? @"" : [[e target] name], - ([e source] != [e target] && [[e target] style] == nil) ? @".center" : ([e targetAnchor] == @"") ? @"" : [NSString stringWithFormat:@".%@", [e targetAnchor]] + tgtAnchor ]; } -- cgit v1.2.3