diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/SymbolPathParser.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/SymbolPathParser.java index 21241a53a7..27a6fb943c 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/SymbolPathParser.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/SymbolPathParser.java @@ -72,8 +72,8 @@ public class SymbolPathParser { int endIndex = i; // could be 0 if i == 0. if (endIndex > startIndex) { list.add(name.substring(startIndex, endIndex)); - i += 2; - startIndex = i; + startIndex = i + 2; + i++; // Only increment one, because the loop also has an increment. } } } @@ -100,8 +100,8 @@ public class SymbolPathParser { int endIndex = i; // could be 0 if i == 0. if (endIndex > startIndex) { list.add(name.substring(startIndex, endIndex)); - i += 2; - startIndex = i; + startIndex = i + 2; + i++; // Only increment one, because the loop also has an increment. } } } diff --git a/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/app/util/SymbolPathParserTest.java b/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/app/util/SymbolPathParserTest.java index e76878d7d4..3ad581be35 100644 --- a/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/app/util/SymbolPathParserTest.java +++ b/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/app/util/SymbolPathParserTest.java @@ -15,7 +15,7 @@ */ package ghidra.app.util; -import static org.junit.Assert.*; +import static org.junit.Assert.fail; import java.util.ArrayList; import java.util.List; @@ -68,10 +68,10 @@ public class SymbolPathParserTest extends AbstractGTest { @Test public void testNamespaceInFunctionArgument() { - List list = SymbolPathParser.parse( "Foo7::Bar5(class Foo1d::Bar1,int)"); - List expected = new ArrayList<>(); - expected.add("Foo7"); - expected.add("Bar5(class Foo1d::Bar1,int)"); + List list = SymbolPathParser.parse("Foo7::Bar5(class Foo1d::Bar1,int)"); + List expected = new ArrayList<>(); + expected.add("Foo7"); + expected.add("Bar5(class Foo1d::Bar1,int)"); assertListEqualOrdered(expected, list); } @@ -118,4 +118,32 @@ public class SymbolPathParserTest extends AbstractGTest { assertListEqualOrdered(expected, list); } + @Test + public void testSpecialCharAfterDelimiter1() { + String name = "A::B::C,A::B::E >::"; + List list = SymbolPathParser.parse(name); + List expected = new ArrayList<>(); + expected.add("A"); + expected.add("B"); + expected.add("C,A::B::E >"); + expected.add(""); + assertListEqualOrdered(expected, list); + } + + @Test + public void testUnmatchedAngleBracketFallback1() { + // Contrived example to test naive parsing going into fallback mode due to unmatched + // angle brackets. The expected result here is not an accurate result that we would + // expect from a more sophisticated parser. + String name = "A::operator<=::B::>::E"; + List list = SymbolPathParser.parse(name); + List expected = new ArrayList<>(); + expected.add("A"); + expected.add("operator<="); + expected.add("B"); + expected.add(">"); + expected.add("E"); + assertListEqualOrdered(expected, list); + } + } diff --git a/Ghidra/Processors/PIC/data/languages/PIC24.pspec b/Ghidra/Processors/PIC/data/languages/PIC24.pspec index 7c9b664cef..2a65a73d52 100644 --- a/Ghidra/Processors/PIC/data/languages/PIC24.pspec +++ b/Ghidra/Processors/PIC/data/languages/PIC24.pspec @@ -3,7 +3,8 @@ - +