lat-lon / sep3-tools

SEP3-Tools
GNU Lesser General Public License v2.1
2 stars 1 forks source link

Possible problem in PetroVisitor.visitAufzaehlung_a #13

Closed tilmanb closed 2 years ago

tilmanb commented 2 years ago

While browsing and trying to understand the code I stubled accross this line in PetroVisitor: https://github.com/lat-lon/sep3-tools/blob/999e9087ff40a5a3c603854183adbc09c9a29625/src/main/java/org/sep3tools/PetroVisitor.java#L102

The function code (for context) is:

public String visitAufzaehlung_a(PetroGrammarParser.Aufzaehlung_aContext ctx) {
    String att1 = visit(ctx.attribute(0));
    String att2 = visit(ctx.attribute(1));
    if (att1.startsWith(" ("))
        att1 = att1.substring(2, att1.length() - 1);
    if (att2.startsWith(" ("))
        att1 = att2.substring(2, att2.length() - 1); // Line 102, should be att2=... ?
    return " (" + att1 + ", " + att2 + ")";
}

It looks to me that the variable written to should probably be att2, but I cannot find an example sep3 string that hits this line to see whether it really is a problem or not.

tfr42 commented 2 years ago

Yes, looks wrong. A unit test is missing here to verify the behaviour.

tfr42 commented 2 years ago

Bug was fixed with PR #27, change in https://github.com/lat-lon/sep3-tools/pull/27/files#diff-5f8efaba0689e8fc5a6310078404e28b7d5afa46aad8714f2cfa2b745003b5afR145