private List<PreprocChunk> GetPPC(string line) { // Get chunks to process List<PreprocChunk> chunks = new List<PreprocChunk>(); bool inString = false; bool inMultiString = false; //int bracketLevel = 0; // "[dongs]" char lastC = char.MinValue; PreprocChunk ppc = new PreprocChunk(); ppc.start = 0; for (int i = 0; i < line.Length; i++) { char c = line[i]; switch (c) { case '"': if (inString && i < line.Length - 1) { if (inMultiString) continue; ppc = new PreprocChunk(); ppc.start = i; } else { inMultiString = lastC == '{'; ppc.end = i - 1; if (inMultiString) ppc.end--; if (ppc.end - ppc.end > 0) chunks.Add(ppc); } inString = !inString; break; case '}': if (inString) { if (inMultiString && i < line.Length - 1) { ppc = new PreprocChunk(); ppc.start = i; inString = !inString; } } break; } } if (!inString) { ppc.end = line.Length; if (ppc.end - ppc.start > 0) chunks.Add(ppc); } return chunks; }
private List <PreprocChunk> GetPPC(string line) { // Get chunks to process List <PreprocChunk> chunks = new List <PreprocChunk>(); bool inString = false; bool inMultiString = false; //int bracketLevel = 0; // "[dongs]" char lastC = char.MinValue; PreprocChunk ppc = new PreprocChunk(); ppc.start = 0; for (int i = 0; i < line.Length; i++) { char c = line[i]; switch (c) { case '"': if (inString && i < line.Length - 1) { if (inMultiString) { continue; } ppc = new PreprocChunk(); ppc.start = i; } else { inMultiString = lastC == '{'; ppc.end = i - 1; if (inMultiString) { ppc.end--; } if (ppc.end - ppc.end > 0) { chunks.Add(ppc); } } inString = !inString; break; case '}': if (inString) { if (inMultiString && i < line.Length - 1) { ppc = new PreprocChunk(); ppc.start = i; inString = !inString; } } break; } } if (!inString) { ppc.end = line.Length; if (ppc.end - ppc.start > 0) { chunks.Add(ppc); } } return(chunks); }