On some architectures, symbols have an extra underscore prepended (e.g. OS X), and e.g. C++ symbols look like: `__ZZN4llvm14MCObjectWriter10WriteZerosEjE5Zeros`.
DMD does not prepend the extra `_` for D symbols: `_D6object9Throwable8toStringMFZAya` and ddemangle works fine.
LDC does prepend the extra `_`: `__D6object9Throwable8toStringMFZAya` and ddemangle does not demangle the symbol.
c++filt has the option `--strip-underscore Ignore first leading underscore (default)` for this issue.
I could not come up with a case where it would do harm so instead of adding such a commandline switch, this commit makes ddemangle recognize both `_D...` and `__D...` during the same execution run.
It doesn't work well with getopt anyway, and apparently causes utf8
errors on Windows. Reading from stdin is achieved by omitting the
inputfile anyway.
This one uses std.regex to replace all occurrences of mangled symbols
per line. Sometimes this is needed when the line just happens to contain
the wrong character sequences (_D...), which cause a real symbol later
on in the line not to be demangled, if only the first match is
attempted.
It also uses std.getopt for future extensions (ala c++filt, if we ever
decide to do that).