From df482c613a38c35b11c12c814fca0e4de6916445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20Garc=C3=ADa=20Cota?= Date: Fri, 12 Nov 2021 10:48:57 +0100 Subject: [PATCH 1/2] escape DEL character. fixes #40 --- inspect.lua | 7 ++++--- spec/inspect_spec.lua | 7 ++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/inspect.lua b/inspect.lua index e2e3806..dedd91f 100644 --- a/inspect.lua +++ b/inspect.lua @@ -46,12 +46,12 @@ local function smartQuote(str) return '"' .. str:gsub('"', '\\"') .. '"' end --- \a => '\\a', \0 => '\\0', 31 => '\31' +-- \a => '\\a', \0 => nil local shortControlCharEscapes = { ["\a"] = "\\a", ["\b"] = "\\b", ["\f"] = "\\f", ["\n"] = "\\n", - ["\r"] = "\\r", ["\t"] = "\\t", ["\v"] = "\\v" + ["\r"] = "\\r", ["\t"] = "\\t", ["\v"] = "\\v", ["\127"] = "\\127", } -local longControlCharEscapes = {} -- \a => nil, \0 => \000, 31 => \031 +local longControlCharEscapes = {["\127"]="\127"} -- \a => nil, \0 => \000, 31 => \031 for i=0, 31 do local ch = string.char(i) if not shortControlCharEscapes[ch] then @@ -59,6 +59,7 @@ for i=0, 31 do longControlCharEscapes[ch] = string.format("\\%03d", i) end end +--longControlCharEscapes["\127"]="\\127" local function escape(str) return (str:gsub("\\", "\\\\") diff --git a/spec/inspect_spec.lua b/spec/inspect_spec.lua index edea720..a6ddd00 100644 --- a/spec/inspect_spec.lua +++ b/spec/inspect_spec.lua @@ -43,7 +43,12 @@ describe( 'inspect', function() inspect('Here are some control characters: \0 \1 \6 \17 \27 \31')) end) - it('escapes unnamed control characters with 3 digits when they are followed by numbers', function() + it('escapes DEL', function() + assert.equals('"DEL: \\127"', + inspect('DEL: \127')) + end) + + it('escapes unnamed control characters with 4 digits when they are followed by numbers', function() assert.equals('"Control chars followed by digits \\0001 \\0011 \\0061 \\0171 \\0271 \\0311"', inspect('Control chars followed by digits \0001 \0011 \0061 \0171 \0271 \0311')) end) From f6c3f0b3673b5ba5f7220d08cb904dfbf4309304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20Garc=C3=ADa=20Cota?= Date: Fri, 12 Nov 2021 12:54:49 +0100 Subject: [PATCH 2/2] replace travis by github actions --- .github/workflows/test.yml | 29 +++++++++++++++++++++++++++++ .travis.yml | 36 ------------------------------------ README.md | 3 --- 3 files changed, 29 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..e4bd960 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,29 @@ +name: test + +on: [push] + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + matrix: + luaVersion: ["5.1.5", "5.2.4", "luajit-2.1.0-beta3", "luajit-openresty"] + + steps: + - uses: actions/checkout@master + + - uses: leafo/gh-actions-lua@v8.0.0 + with: + luaVersion: ${{ matrix.luaVersion }} + + - uses: leafo/gh-actions-luarocks@v4.0.0 + + - name: build + run: | + luarocks install busted + luarocks make + + - name: test + run: | + busted -o utfTerminal diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 91f7f93..0000000 --- a/.travis.yml +++ /dev/null @@ -1,36 +0,0 @@ -language: python -sudo: false - -env: - - LUA="lua=5.1" - - LUA="lua=5.2" - - LUA="lua=5.3" - - LUA="luajit=2.0" - - LUA="luajit=2.1" - -before_install: - - pip install hererocks - - hererocks lua_install -r^ --$LUA - - export PATH=$PATH:$PWD/lua_install/bin # Add directory with all installed binaries to PATH - -install: - - luarocks install luacheck - - luarocks install busted - - luarocks install luacov - - luarocks install luacov-coveralls - -script: - - luacheck --std max+busted *.lua spec - - busted --verbose --coverage - -after_success: - - luacov-coveralls --exclude $TRAVIS_BUILD_DIR/lua_install - -branches: - except: - - gh-pages - -notifications: - email: - on_success: change - on_failure: always diff --git a/README.md b/README.md index e9c6f86..319f83d 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,6 @@ inspect.lua =========== -[![Build Status](https://travis-ci.org/kikito/inspect.lua.png?branch=master)](https://travis-ci.org/kikito/inspect.lua) -[![Coverage Status](https://coveralls.io/repos/github/kikito/inspect.lua/badge.svg?branch=master)](https://coveralls.io/github/kikito/inspect.lua?branch=master) - This library transforms any Lua value into a human-readable representation. It is especially useful for debugging errors in tables.