From f29a141ab4c4308aed66f930a6f3a42cd20a482d Mon Sep 17 00:00:00 2001 From: rtk0c Date: Sat, 11 Jun 2022 11:37:45 -0700 Subject: Changeset: 70 Fix cmake and codegen infra - Invoke codegen.exe once with a list of changed files, instead of individually for each changed file (this gives the codegen global access to all the code, allowing more things) - Initial support for outputting an archive SQLite database that contains all the code info --- source/10-common/Utils.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'source/10-common/Utils.cpp') diff --git a/source/10-common/Utils.cpp b/source/10-common/Utils.cpp index dc76b0a..f0ff76d 100644 --- a/source/10-common/Utils.cpp +++ b/source/10-common/Utils.cpp @@ -77,6 +77,29 @@ std::string Utils::ReadFileAsString(const fs::path& path) { return result; } +bool Utils::ReadCstdioLine(FILE* file, std::string& buffer) { + buffer.clear(); + while (true) { + int c = fgetc(file); + if (c == EOF) { + if (buffer.empty() || buffer.back() != '\n') { + buffer += '\n'; + } + return false; + } else if (c == '\n') { + buffer += '\n'; + return true; + } else { + buffer += c; + } + } +} + +bool Utils::ReadCstdioLine(FILE* file, char* buffer, size_t bufferSize, size_t* outLineLength) { + // TODO + assert(false && "Unimplemented"); +} + bool Utils::InRangeInclusive(int n, int lower, int upper) { if (lower > upper) { std::swap(lower, upper); -- cgit v1.2.3-70-g09d2