From eb35cf653ad77b51927e57945a83973427ef66d5 Mon Sep 17 00:00:00 2001 From: starlightduck Date: Thu, 12 May 2022 18:57:03 +0300 Subject: [PATCH] Use `td::realpath` and add re-inclusion tests --- crypto/func/parse-func.cpp | 6 ++---- crypto/func/test/i1.fc | 2 ++ crypto/func/test/i1sub1.fc | 2 ++ crypto/func/test/i1sub2.fc | 2 ++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/crypto/func/parse-func.cpp b/crypto/func/parse-func.cpp index c33a3cda..0d2aa985 100644 --- a/crypto/func/parse-func.cpp +++ b/crypto/func/parse-func.cpp @@ -23,7 +23,7 @@ #include "block/block.h" #include "block-parse.h" #include -#include +#include "td/utils/port/path.h" namespace sym { @@ -1657,9 +1657,7 @@ bool parse_source_file(const char* filename, src::Lexem lex) { throw src::Fatal{msg}; } } - char realpath_buf[PATH_MAX] = {0, }; - realpath(filename, realpath_buf); - std::string real_filename = std::string{realpath_buf}; + std::string real_filename = td::realpath(td::CSlice(filename)).move_as_ok(); if (std::count(source_files.begin(), source_files.end(), real_filename)) { if (verbosity >= 2) { if (lex.tp) { diff --git a/crypto/func/test/i1.fc b/crypto/func/test/i1.fc index 2b95e2dd..04f7889e 100644 --- a/crypto/func/test/i1.fc +++ b/crypto/func/test/i1.fc @@ -12,3 +12,5 @@ global int i; sub2(); i = 9; } + +#include "../test/i1sub2.fc"; \ No newline at end of file diff --git a/crypto/func/test/i1sub1.fc b/crypto/func/test/i1sub1.fc index c905bf22..62bdd177 100644 --- a/crypto/func/test/i1sub1.fc +++ b/crypto/func/test/i1sub1.fc @@ -1,6 +1,8 @@ ;; DO NOT COMPILE DIRECTLY! ;; Compile i1.fc +#include "i1sub1.fc"; + () sub1() impure { i = 1; } diff --git a/crypto/func/test/i1sub2.fc b/crypto/func/test/i1sub2.fc index b7f200db..0c48e192 100644 --- a/crypto/func/test/i1sub2.fc +++ b/crypto/func/test/i1sub2.fc @@ -1,6 +1,8 @@ ;; DO NOT COMPILE DIRECTLY! ;; Compile i1.fc +#include "./i1sub1.fc"; + () sub2() impure { sub1(); sub0();