Skip to content

Commit

Permalink
ADBErrorHelpers: Poke the RegexBuilder.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaddTheSane committed Jan 14, 2024
1 parent 1442330 commit baa5063
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Boxer/Application Delegate/BXShelfAppearanceOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ - (void) _applyAppearanceToFolderAtURL: (NSURL *)folderURL
//If the folder doesn't have a custom icon of its own, apply our shelf icon to the folder
if (self.icon && ![[NSWorkspace sharedWorkspace] URLHasCustomIcon: folderURL])
{
[[NSWorkspace sharedWorkspace] setIcon: self.icon forFile: folderURL.path options: 0];
[[NSWorkspace sharedWorkspace] setIcon: self.icon forFile: folderURL.path options: NSExcludeQuickDrawElementsIconCreationOption];
}

FinderFinderWindow *window = [self _finderWindowForFolderAtURL: folderURL];
Expand Down
2 changes: 1 addition & 1 deletion Boxer/BXEmulator+BXDOSFileSystem.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1710,7 +1710,7 @@ - (BOOL) _localFileExists: (const char *)path
NSURL *localFileURL = [NSURL URLFromFileSystemRepresentation: path];

return [filesystem enumeratorAtFileURL: localFileURL
includingPropertiesForKeys: [NSArray arrayWithObjects: NSURLIsDirectoryKey, NSURLNameKey, nil]
includingPropertiesForKeys: @[NSURLIsDirectoryKey, NSURLNameKey]
options: NSDirectoryEnumerationSkipsSubdirectoryDescendants
errorHandler: NULL];
}
Expand Down
35 changes: 13 additions & 22 deletions Other Sources/ADBToolkit/NSError+ADBErrorHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private let cxxPrefixes = ["_Z"]
private let ADBCallstackSymbolPattern = #"^\d+\s+(\S+)\s+(0x[a-fA-F0-9]+)\s+(.+)\s+\+\s+(\d+)$"#
@available(macOS 13.0, *)
private let ADBCallstackSymbolPatternNew = Regex {
/^/
Anchor.startOfLine
OneOrMore(.digit)
OneOrMore(.whitespace)
Capture {
Expand All @@ -34,27 +34,19 @@ private let ADBCallstackSymbolPatternNew = Regex {
OneOrMore(.whitespace)
"0x"
Capture {
OneOrMore {
CharacterClass(
("a"..."f"),
("A"..."F"),
("0"..."9")
)
}
}
OneOrMore(.hexDigit)
} transform: { UInt64($0, radix: 16) }
OneOrMore(.whitespace)
Capture {
OneOrMore {
/./
}
OneOrMore (.anyNonNewline)
}
OneOrMore(.whitespace)
"+"
OneOrMore(.whitespace)
Capture {
OneOrMore(.digit)
}
/$/
} transform: { Int64($0) }
Anchor.endOfLine
}

extension NSException {
Expand Down Expand Up @@ -105,12 +97,11 @@ extension NSException {
return [.rawSymbol: symbol]
}
let libraryName = String(captures.1)
let hexAddress = captures.2
let rawSymbolName = captures.3
let offsetString = captures.4
let rawSymbolNameStr = String(rawSymbolName)

guard let address = UInt64(hexAddress, radix: 16),
let offset = Int64(offsetString) else {
guard let address = captures.2,
let offset = captures.4 else {
//If the string couldn't be parsed, make an effort to provide *something* back
//this should not happen!
return [.rawSymbol: symbol]
Expand All @@ -120,22 +111,22 @@ extension NSException {
var demangledSymbolName: String?
switch symbolType {
case .none:
demangledSymbolName = String(rawSymbolName)
demangledSymbolName = rawSymbolNameStr

case .cPlusPlus:
demangledSymbolName = NSException.demangledCPlusPlusFunctionName(String(rawSymbolName))
demangledSymbolName = NSException.demangledCPlusPlusFunctionName(rawSymbolNameStr)

case .swift:
demangledSymbolName = NSException.demangledSwiftFunctionName(rawSymbolName)
}
if demangledSymbolName == nil {
demangledSymbolName = String(rawSymbolName)
demangledSymbolName = rawSymbolNameStr
}

return [
.rawSymbol: symbol,
.libraryName: libraryName,
.functionName: String(rawSymbolName),
.functionName: rawSymbolNameStr,
.humanReadableFunctionName: demangledSymbolName!,
.address: address,
.symbolOffset: offset]
Expand Down

0 comments on commit baa5063

Please sign in to comment.