summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/slang-generate/main.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/tools/slang-generate/main.cpp b/tools/slang-generate/main.cpp
index 979127f8d..5fca7c21a 100644
--- a/tools/slang-generate/main.cpp
+++ b/tools/slang-generate/main.cpp
@@ -8,6 +8,7 @@
#include "../../source/core/slang-list.h"
#include "../../source/core/slang-string.h"
#include "../../source/core/slang-string-util.h"
+#include "../../source/core/slang-io.h"
using namespace Slang;
@@ -38,7 +39,7 @@ struct Node
// Information about a source file
struct SourceFile
{
- char const* inputPath;
+ String inputPath;
StringSpan text;
Node* node;
};
@@ -761,7 +762,7 @@ Node* parseSourceFile(SourceFile* file)
for (auto hh : kHandlers)
{
- if (UnownedTerminatedStringSlice(path).endsWith(hh.extension))
+ if (path.endsWith(hh.extension))
{
return hh.handler(text);
}
@@ -772,10 +773,10 @@ Node* parseSourceFile(SourceFile* file)
-SourceFile* parseSourceFile(char const* path)
+SourceFile* parseSourceFile(const String& path)
{
FILE* inputStream;
- fopen_s(&inputStream, path, "rb");
+ fopen_s(&inputStream, path.getBuffer(), "rb");
fseek(inputStream, 0, SEEK_END);
size_t inputSize = ftell(inputStream);
fseek(inputStream, 0, SEEK_SET);
@@ -804,7 +805,7 @@ int main(
const char*const* argv)
{
// Parse command-line arguments.
- List<const char*> inputPaths;
+ List<String> inputPaths;
char const* appName = "slang-generate";
{
@@ -818,7 +819,9 @@ int main(
// Copy the input paths
for (; argCursor != argEnd; ++argCursor)
{
- inputPaths.add(*argCursor);
+ // We simplify here because doing so also means paths separators are set to /
+ // and that makes path emitting work correctly
+ inputPaths.add(Path::simplify(UnownedStringSlice(*argCursor)));
}
}
@@ -830,7 +833,7 @@ int main(
// Read each input file and process it according
// to the type of treatment it requires.
- for (const char* inputPath: inputPaths)
+ for (auto& inputPath: inputPaths)
{
SourceFile* sourceFile = parseSourceFile(inputPath);
if (sourceFile)
@@ -866,7 +869,7 @@ int main(
readAllText(outputPath.getBuffer(), allTextNew);
if (allTextOld != allTextNew)
{
- writeAllText(inputPath, outputPathFinal.getBuffer(), allTextNew.getBuffer());
+ writeAllText(inputPath.getBuffer(), outputPathFinal.getBuffer(), allTextNew.getBuffer());
}
remove(outputPath.getBuffer());
}