tazel
A build system for C, C++, Objective-C, Objective-C++ and Zig, with C# project files.
Clonegit clone https://git.progmasoft.com/tazel
refactor(cadre-celeste): move verbatim token copying out of StepNormalize
- Commit
1640cfe70d6ba37be9cf18b57fd5b9828e88b65b- Author
- Leitwolf11 ·
- Parents
18825fb2f8ce
Changes
.../AbiFingerprint.cs | 26 +++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/Progmasoft.Tazel.CadreCeleste/AbiFingerprint.cs b/src/Progmasoft.Tazel.CadreCeleste/AbiFingerprint.cs index a42cb78..03ca037 100644 --- a/src/Progmasoft.Tazel.CadreCeleste/AbiFingerprint.cs +++ b/src/Progmasoft.Tazel.CadreCeleste/AbiFingerprint.cs @@ -85,26 +85,42 @@ public static class AbiFingerprint pendingSpace = false; } + if (TryCopyVerbatim(source, ref i, sb)) + { + return i; + } + + sb.Append(ch); + return i + 1; + } + + /// <summary> + /// Copies, unchanged, a token whose text is never a comment and whose spacing matters: a raw string, a header name + /// of an include line, or a string or character literal. Returns false when the character at + /// <paramref name="i"/> starts none of them. + /// </summary> + private static bool TryCopyVerbatim(string source, ref int i, StringBuilder sb) + { + var ch = source[i]; if (ch == '"' && IsRawStringStart(source, i)) { CopyRawStringLiteral(source, ref i, sb); - return i; + return true; } if (ch == '<' && IsIncludeLine(sb)) { CopyHeaderName(source, ref i, sb); - return i; + return true; } if (ch == '"' || (ch == '\'' && !IsDigitSeparator(source, i))) { CopyQuotedLiteral(source, ref i, ch, sb); - return i; + return true; } - sb.Append(ch); - return i + 1; + return false; } /// <summary>