From f53e6ce60d200c6a1a7d73a080a89d804839850b Mon Sep 17 00:00:00 2001 From: ghizard <50744617+ghizard@users.noreply.github.com> Date: Wed, 10 Jul 2019 11:40:29 -0400 Subject: [PATCH] GT-2961 - Adjust DataTypeManagerDB --- .../database/data/DataTypeManagerDB.java | 31 ++++++------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeManagerDB.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeManagerDB.java index 81310f47f5..d000c7d03a 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeManagerDB.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeManagerDB.java @@ -1255,17 +1255,17 @@ abstract public class DataTypeManagerDB implements DataTypeManager { return null; } - // try to deal with datatypes that have '/' chars in their name. - Category category = getLowestLevelCategory(dataTypePath); + // Use a category path to parse the datatype path because it knows how to deal with + // escaped forward slashes. + CategoryPath parsedPath = new CategoryPath(dataTypePath); + CategoryPath categoryPath = parsedPath.getParent(); + String dataTypeName = parsedPath.getName(); + Category category = getCategory(categoryPath); - if (category != null) { - CategoryPath categoryPath = category.getCategoryPath(); - String path = categoryPath.getPath(); - int dataTypeNameStartIndex = path.endsWith("/") ? path.length() : path.length() + 1; // +1 to get past the last '/' - String dataTypeName = dataTypePath.substring(dataTypeNameStartIndex); - return category.getDataType(dataTypeName); + if (category == null) { + return null; } - return null; + return category.getDataType(dataTypeName); } @Override @@ -1273,19 +1273,6 @@ abstract public class DataTypeManagerDB implements DataTypeManager { return getDataType(dataTypePath); } - private Category getLowestLevelCategory(String dataTypePath) { - CategoryPath pathParser = new CategoryPath(dataTypePath); // Use a category path to parse the path. - while (pathParser != null) { - CategoryPath path = pathParser.getParent(); - Category category = getCategory(path); - if (category != null) { - return category; - } - pathParser = path; - } - return null; - } - @Override public void findEnumValueNames(long value, Set enumValueNames) { buildEnumValueMap();