From 0320492015172dd42ea919e8db33a66480d97c75 Mon Sep 17 00:00:00 2001 From: PhilipDeegan Date: Sun, 6 Aug 2023 22:15:20 +0200 Subject: [PATCH] fix env parsing = (#82) * fix env parsing = * better test finding regex / sample -x files --- .lgtm.yml | 9 ------- .sublime-project | 2 +- .travis.yml | 58 ----------------------------------------- inc/maiken/env.hpp | 6 ++--- mkn.yaml | 2 +- res/mkn/clang_asan.yaml | 18 +++++++++++++ res/mkn/clang_mold.yaml | 13 +++++++++ res/mkn/gcc_asan.yaml | 13 +++++++++ src/maiken/create.cpp | 2 +- src/regex.cpp | 13 ++++++--- 10 files changed, 58 insertions(+), 78 deletions(-) delete mode 100644 .lgtm.yml delete mode 100644 .travis.yml create mode 100644 res/mkn/clang_asan.yaml create mode 100644 res/mkn/clang_mold.yaml create mode 100644 res/mkn/gcc_asan.yaml diff --git a/.lgtm.yml b/.lgtm.yml deleted file mode 100644 index c9e8c196..00000000 --- a/.lgtm.yml +++ /dev/null @@ -1,9 +0,0 @@ -path_classifiers: - tag: - exclude: "ext" -queries: - exclude: "ext" -extraction: - cpp: - index: - build_command: "make nix" diff --git a/.sublime-project b/.sublime-project index 53041a23..aaf04876 100644 --- a/.sublime-project +++ b/.sublime-project @@ -9,7 +9,7 @@ { "ClangFormat" : { - "binary" : "clang-format-8", + "binary" : "clang-format", "format_on_save" : true, "style" : "file" } diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 39a20c3a..00000000 --- a/.travis.yml +++ /dev/null @@ -1,58 +0,0 @@ - -git: - depth: 3 -matrix: - include: - - os: linux - dist: bionic - sudo: required - compiler: gcc - addons: - apt: - sources: - - sourceline: 'ppa:ubuntu-toolchain-r/test' - packages: - - g++-8 - env: - - MATRIX_EVAL="CC=gcc-8 && CXX=g++-8" - - os: osx - sudo: required - osx_image: xcode11 - compiler: clang - -before_install: - - | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB - rvm get stable - fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - eval "${MATRIX_EVAL}" - fi - -script: - - | - export MKN_LIB_LINK_LIB="1" KUL_GIT_CO="--depth 3" KLOG="3" - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - ./res/ci/osx_travis.sh - fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - export CC CXX - ./res/ci/nix_travis.sh - fi - -deploy: - - provider: bintray - file: res/ci/mac_bintray.json - user: dekken - key: - secure: ZMfDtmzwNq60lbX3nCr2PIKYXMcb1p976TJFl/i//AsnraFhlwvn30Q48FG2uY1cWuXCtr6ATdtThMlUd01zq5WVktTmmf4Q5CYFy5kiOr7Rajyg/5dMgSK3butJyHUVCki7dM0ztIPc82zQaWSy6wNUMPxf12e73cgGwWTnT1jUpTs1kKB5LpfduI4lOzggNc08Q23mlNYGW9XReV14QAdPgULogL+T0ABy8GKBQ/0Hx4eaj6IM9FHrZpDbfkgaeSsSByIY9sFi8njOirQ4YAzXG7J/GiubqGcLVYYwegbD8E3wJLSXny0s61nEzsMigG2ZQKfxlFmxW1TAOklEOd+B/vF9QBHF0/NuPSNEXAT2miZ9QqHKeN+B5vEZJqCEJ19nmEA5WDTfyHIojH0ZgCBUUCqfIuSOaYLmU7pgk2KUHfFtvDEQx2uy7Afjzmn+Ho+H4LXUwLliYZPNq2yHcqk0zd1xwI+h3B2N4npTxdwCMxUlr6QOSuEAGAssUdZyIZyTWttho6CQSDWpVGAMQYwkAMCWLC7nq9qy11RtIV/yJhOKIlJMMHFQYJtXTysWQs9mIZwKOG6O3tHiLABXdw7D2kkjpdxN85qeYUHa5oHeaBVKQTsLrYG+z6p66N/w+/1hyj4fkcsTBOziJwtTU1Vse+c3bMuRdlsAA1ToIJA= - edge: - branch: v1.8.47 - - provider: bintray - file: res/ci/nix_bintray.json - user: dekken - key: - secure: ZMfDtmzwNq60lbX3nCr2PIKYXMcb1p976TJFl/i//AsnraFhlwvn30Q48FG2uY1cWuXCtr6ATdtThMlUd01zq5WVktTmmf4Q5CYFy5kiOr7Rajyg/5dMgSK3butJyHUVCki7dM0ztIPc82zQaWSy6wNUMPxf12e73cgGwWTnT1jUpTs1kKB5LpfduI4lOzggNc08Q23mlNYGW9XReV14QAdPgULogL+T0ABy8GKBQ/0Hx4eaj6IM9FHrZpDbfkgaeSsSByIY9sFi8njOirQ4YAzXG7J/GiubqGcLVYYwegbD8E3wJLSXny0s61nEzsMigG2ZQKfxlFmxW1TAOklEOd+B/vF9QBHF0/NuPSNEXAT2miZ9QqHKeN+B5vEZJqCEJ19nmEA5WDTfyHIojH0ZgCBUUCqfIuSOaYLmU7pgk2KUHfFtvDEQx2uy7Afjzmn+Ho+H4LXUwLliYZPNq2yHcqk0zd1xwI+h3B2N4npTxdwCMxUlr6QOSuEAGAssUdZyIZyTWttho6CQSDWpVGAMQYwkAMCWLC7nq9qy11RtIV/yJhOKIlJMMHFQYJtXTysWQs9mIZwKOG6O3tHiLABXdw7D2kkjpdxN85qeYUHa5oHeaBVKQTsLrYG+z6p66N/w+/1hyj4fkcsTBOziJwtTU1Vse+c3bMuRdlsAA1ToIJA= - edge: - branch: v1.8.47 diff --git a/inc/maiken/env.hpp b/inc/maiken/env.hpp index 76bd06fd..5b4f9f99 100644 --- a/inc/maiken/env.hpp +++ b/inc/maiken/env.hpp @@ -38,14 +38,12 @@ namespace maiken { template mkn::kul::cli::EnvVar PARSE_ENV_NODE(YAML::Node const& n, HasProperties const& hasProperties, - std::string hasProperties_id) { + std::string /*hasProperties_id*/) { using namespace mkn::kul::cli; if (n.IsScalar()) { auto bits = mkn::kul::String::ESC_SPLIT(n.Scalar(), '='); - if (bits.size() != 2) - KEXIT(1, "env string is invalid, expects one '=' only, string ") - << n.Scalar() << "\n in: " << hasProperties_id; + for (std::size_t i = 2; i < bits.size(); ++i) bits[1] += "=" + bits[i]; auto replace = [](std::string const& n, std::string& in, std::string f) { auto pos = in.find(f); diff --git a/mkn.yaml b/mkn.yaml index 0f316295..d6f8bb63 100644 --- a/mkn.yaml +++ b/mkn.yaml @@ -4,7 +4,7 @@ name: mkn # scm: https://github.com/mkn/mkn version: master property: - DATE: 12-DEC-2022 + DATE: 06-AUG-2023 parent: bin mode: none diff --git a/res/mkn/clang_asan.yaml b/res/mkn/clang_asan.yaml new file mode 100644 index 00000000..6fe8b573 --- /dev/null +++ b/res/mkn/clang_asan.yaml @@ -0,0 +1,18 @@ +property: + cxx_flags: -std=c++17 -fsanitize=address -fno-omit-frame-pointer +local: + repo: /mkn/r + mod-repo: /mkn/m +remote: + repo: git@github.com:mkn/ + mod-repo: git@github.com:mkn-mod/ +path: | + /usr/lib/llvm-14/lib/clang/14.0.6/lib/linux +env: | # replace with $(clang++ -print-file-name=libclang_rt.asan-x86_64.so) + LD_PRELOAD=/usr/lib/llvm-14/lib/clang/14.0.6/lib/linux/libclang_rt.asan-x86_64.so + ASAN_OPTIONS=detect_leaks=0 +file: + - type: cpp:cxx:cc:c:S + archiver: ar -cr + compiler: ccache clang++ ${cxx_flags} + linker: clang++ -Bmold -lclang_rt.asan-x86_64 diff --git a/res/mkn/clang_mold.yaml b/res/mkn/clang_mold.yaml new file mode 100644 index 00000000..b3274d96 --- /dev/null +++ b/res/mkn/clang_mold.yaml @@ -0,0 +1,13 @@ +property: + cxx_flags: -std=c++17 +local: + repo: /mkn/r + mod-repo: /mkn/m +remote: + repo: git@github.com:mkn/ + mod-repo: git@github.com:mkn-mod/ +file: + - type: cpp:cxx:cc:c:S + archiver: ar -cr + compiler: ccache clang++ ${cxx_flags} + linker: clang++ -Bmold diff --git a/res/mkn/gcc_asan.yaml b/res/mkn/gcc_asan.yaml new file mode 100644 index 00000000..bf48a224 --- /dev/null +++ b/res/mkn/gcc_asan.yaml @@ -0,0 +1,13 @@ +property: + cxx_flags: -std=c++17 -fsanitize=address -fno-omit-frame-pointer +local: + repo: /mkn/r + mod-repo: /mkn/m +remote: + repo: git@github.com:mkn/ + mod-repo: git@github.com:mkn-mod/ +file: + - type: cpp:cxx:cc:c:S + archiver: ar -cr + compiler: ccache g++ ${cxx_flags} + linker: g++ ${cxx_flags} diff --git a/src/maiken/create.cpp b/src/maiken/create.cpp index 0d637b8e..d481c55a 100644 --- a/src/maiken/create.cpp +++ b/src/maiken/create.cpp @@ -81,7 +81,7 @@ std::vector maiken::Application::CREATE(int16_t argc, char Args args(cli.cmds(), cli.args()); try { args.process(argc, argv); - } catch (const mkn::kul::cli::Exception& e) { + } catch (mkn::kul::cli::Exception const& e) { KEXIT(1, e.what()); } return CREATE(args); diff --git a/src/regex.cpp b/src/regex.cpp index 2ce859ee..e283007c 100644 --- a/src/regex.cpp +++ b/src/regex.cpp @@ -41,11 +41,16 @@ std::vector maiken::Regexer::RESOLVE(std::string str) KTHROW(mkn::k if (str.size() > 1 && str.substr(0, 2) == "./") str = str.substr(2); auto bits = mkn::kul::String::SPLIT(str, "/"); - str = bits[bits.size() - 1]; - mkn::kul::Dir d(mkn::kul::env::CWD()); + mkn::kul::Dir d(mkn::kul::env::CWD()); if (bits.size() > 1) d = mkn::kul::Dir(bits[0]); - for (size_t i = 1; i < bits.size() - 1; i++) d = d.join(bits[i]); + + str = bits[bits.size() - 1]; + + for (size_t i = 1; i < bits.size() - 1; i++) { + if (bits[i].find("(") != std::string::npos && bits[i].find(")") != std::string::npos) break; + d = d.join(bits[i]); + } auto regexer = [&](auto items) { for (auto const& item : items) { @@ -59,7 +64,7 @@ std::vector maiken::Regexer::RESOLVE(std::string str) KTHROW(mkn::k } } }; - regexer(d.files(1)); + regexer(d.files(/*recursive=*/true)); return v; }