Skip to content

Commit

Permalink
Ignore Functions end/starts when applieng glue (#83)
Browse files Browse the repository at this point in the history
fixes #82

+ Bump version to v0.1.5
+ Bump workflow actions versions
+ glue newlines over `func_start/end`
+ strip tabs also as if a whitespace
  • Loading branch information
JBenda authored Apr 20, 2024
1 parent c930704 commit aa89daf
Show file tree
Hide file tree
Showing 9 changed files with 1,739 additions and 32 deletions.
49 changes: 25 additions & 24 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ jobs:
steps:

# Checkout project
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true

# Download inklecate
- uses: suisei-cn/actions-download-file@v1.4.0
- uses: suisei-cn/actions-download-file@v1.6.0
name: Download Inklecate
id: download_inklecate
with:
Expand All @@ -64,14 +64,14 @@ jobs:
echo "INKLECATE=${{ matrix.inklecate_pre }}$GITHUB_WORKSPACE/inklecate/inklecate${{ matrix.inklecate_post }}" >> $GITHUB_ENV
# Setup python
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
if: ${{ matrix.proof }}
with:
python-version: '3.7'
python-version: '3.x'

# Setup CMake
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v1.14.2
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.22.x'

Expand Down Expand Up @@ -103,7 +103,7 @@ jobs:
shell: bash
run: cmake --install . --config $BUILD_TYPE --prefix comp_cl --component cl
- name: Upload Cl
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}-cl
path: build/comp_cl/
Expand All @@ -113,7 +113,7 @@ jobs:
shell: bash
run: cmake --install . --config $BUILD_TYPE --prefix comp_lib --component lib
- name: Upload Lib
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}-lib
path: build/comp_lib/
Expand All @@ -123,7 +123,7 @@ jobs:
shell: bash
run: cmake --install . --config $BUILD_TYPE --prefix comp_clib --component clib
- name: Upload Clib
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{matrix.artifact}}-clib
path: build/comp_clib
Expand All @@ -135,7 +135,7 @@ jobs:
run: cmake --install . --config $BUILD_TYPE --prefix comp_unreal --component unreal
- name: Upload UE
if: ${{ matrix.unreal }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: unreal
path: build/comp_unreal/
Expand Down Expand Up @@ -172,15 +172,15 @@ jobs:
# Upload results artifact
- name: Upload Results Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: results
name: result-${{ matrix.artifact }}
path: proofing/ink-proof/${{ matrix.artifact }}.txt

# Upload website artifact
- name: Upload Ink-Proof Website Artifact
if: ${{ matrix.proof }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}-www
path: proofing/ink-proof/out
Expand All @@ -194,7 +194,7 @@ jobs:
with:
submodules: true
- name: Set upt Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install Doxygen
Expand All @@ -206,7 +206,7 @@ jobs:
cd doxygen-1.10.0/
sudo make install
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v1.14.2
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.22.x'
- name: Create Build Environment
Expand All @@ -220,7 +220,7 @@ jobs:
shell: bash
run: cmake --build . --target doc
- name: Upload
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: doxygen
path: Documentation/
Expand All @@ -234,7 +234,7 @@ jobs:
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: install build
Expand All @@ -247,7 +247,7 @@ jobs:
- name: Build python release
run: python3 -m build

- uses: suisei-cn/actions-download-file@v1.4.0
- uses: suisei-cn/actions-download-file@v1.6.0
name: Download Inklecate
id: download_inklecate
with:
Expand All @@ -268,7 +268,7 @@ jobs:
run: |
rm dist/*.whl
- name: Upload Python files
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: python-package-distribution
path: dist/
Expand All @@ -278,7 +278,7 @@ jobs:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'master' }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Fetch master branch
run: |
git fetch origin master
Expand All @@ -302,10 +302,11 @@ jobs:
pull-requests: write
steps:
# Download Ink Proof Results
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: results
pattern: result-*
path: "results"
merge-multiple: true

# Create comment text
- name: Create Comment Text File
Expand All @@ -325,7 +326,7 @@ jobs:
done
# Post Comment
- uses: marocchino/sticky-pull-request-comment@v2.8.0
- uses: marocchino/sticky-pull-request-comment@v2.9.0
with:
recreate: true
path: comment.txt
Expand All @@ -341,12 +342,12 @@ jobs:
- uses: actions/checkout@v4

# Download Ink Proof page for Linux
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: linux-www
path: www/proof

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: doxygen
path: www
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
id-token: write
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Download artifacts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.16)
enable_testing()

# Project setup
project(inkcpp VERSION 0.1.4)
project(inkcpp VERSION 0.1.5)
SET(CMAKE_CXX_STANDARD 20)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_INSTALL_LIBRARY_DIR lib)
Expand Down
7 changes: 6 additions & 1 deletion inkcpp/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ void basic_stream::append(const value& in)
if ((in.type() == value_type::glue || in.type() == value_type::func_end) && _size > 1) {
// Run backwards
size_t i = _size - 2;
int func_end_cnt = 0;
while (true) {
value& d = _data[i];

Expand All @@ -76,7 +77,11 @@ void basic_stream::append(const value& in)
// Nullify whitespace
else if (d.type() == value_type::string && ::ink::internal::is_whitespace(d.get<value_type::string>()))
d = value{};

else if (d.type() == value_type::func_end) {
++func_end_cnt;
} else if (d.type() == value_type::func_start && func_end_cnt > 0) {
--func_end_cnt;
}

// If it's not a newline or whitespace, stop
else
Expand Down
6 changes: 3 additions & 3 deletions inkcpp/string_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ inline constexpr ITR clean_string(ITR begin, ITR end)
auto dst = begin;
for (auto src = begin; src != end; ++src) {
if (dst == begin) {
if (LEADING_SPACES && (src[0] == ' ' || src[0] == '\n')) {
if (LEADING_SPACES && isspace(src[0])) {
continue;
}
} else if (src[-1] == '\n' && (src[0] == ' ' || src[0] == '\n')) {
} else if (src[-1] == '\n' && isspace(src[0])) {
continue;
} else if (src[0] == ' ' && ((src + 1 == end && TAILING_SPACES) || ((src + 1 != end) && (src[1] == ' ' || src[1] == '\n')))) {
} else if ((isspace(src[0]) && src[0] != '\n') && ((src + 1 == end && TAILING_SPACES) || ((src + 1 != end) && isspace(src[1])))) {
continue;
} else if (src[0] == '\n' && dst != begin && dst[-1] == '\n') {
continue;
Expand Down
15 changes: 15 additions & 0 deletions inkcpp_test/NewLines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,19 @@ SCENARIO("a story has the proper line breaks", "[lines]")
}
}
}
GIVEN("a complex story")
{
auto ink = story::from_file(INK_TEST_RESOURCE_DIR "TheIntercept.bin");
runner thread = ink->new_runner();
// based on issue #82
WHEN("run sequence 1 3 3 3 2 3")
{
for (int i : {1, 3, 3, 3, 2, 3}) {
thread->getall();
thread->choose(i - 1);
}
std::string text = thread->getall();
THEN("no newline before dot") { REQUIRE(text == "\"I don't see why,\" I reply.\n"); }
}
}
}
Loading

0 comments on commit aa89daf

Please sign in to comment.