Skip to content

Commit

Permalink
Revert "maint: leverage std.normalize."
Browse files Browse the repository at this point in the history
Fixes #25
Turns out we're not actually getting anything in exchange for
two additional dependencies, apart from some unnecessary pain
for non-LuaRocks users.

This reverts most of commit 22d2586.
  • Loading branch information
gvvaughan committed Mar 29, 2018
1 parent f16bc37 commit 0cb1eca
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 40 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Noteworthy changes in release ?.? (????-??-??) [?]

### Bug fixes

- Remove spurious dependency on `std.normalize` and `std._debug`
libraries.


## Noteworthy changes in release 6.2.1 (2018-02-20) [stable]

Expand Down
12 changes: 6 additions & 6 deletions lib/lyaml/explicit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@

--- @module lyaml.explicit

local _ENV = require 'std.normalize' {
'lyaml.functional.NULL',
'lyaml.functional.anyof',
'lyaml.functional.id',
'lyaml.implicit',
}
local functional = require 'lyaml.functional'
local implicit = require 'lyaml.implicit'

local NULL = functional.NULL
local anyof = functional.anyof
local id = functional.id


local yn = {y=true, Y=true, n=false, N=false}
Expand Down
2 changes: 0 additions & 2 deletions lib/lyaml/functional.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

--- @module lyaml.functional

local _ENV = require 'std.normalize' {}


--- `lyaml.null` value.
-- @table NULL
Expand Down
51 changes: 35 additions & 16 deletions lib/lyaml/implicit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,41 @@
--- @module lyaml.implicit


local _ENV = require 'std.normalize' {
'lyaml.functional.NULL',
'math',
'math.tointeger',
'string.find',
'string.gsub',
'string.sub',
}
local NULL = require 'lyaml.functional'.NULL
local find = string.find
local floor = math.floor
local gsub = string.gsub
local sub = string.sub

local tointeger = (function(f)
if not tointeger then
-- No host tointeger implementation, use our own.
return function(x)
if type(x) == 'number' and x - floor(x) == 0.0 then
return x
end
end

elseif f '1' ~= nil then
-- Don't perform implicit string-to-number conversion!
return function(x)
if type(x) == 'number' then
return tointeger(x)
end
end
end

-- Host tointeger is good!
return f
end)(math.tointeger)


local function int(x)
local r = tonumber(x)
if r ~= nil then
return tointeger(r)
end
end


local is_null = {['']=true, ['~']=true, null=true, Null=true, NULL=true}
Expand Down Expand Up @@ -72,14 +99,6 @@ local function bool(value)
end


local function int(x)
local r = tonumber(x)
if r ~= nil then
return tointeger(r)
end
end


--- Parse a binary token, such as '0b1010\_0111\_0100\_1010\_1110'.
-- @tparam string value token
-- @treturn[1] int integer equivalent, if a valid token was recognized
Expand Down
29 changes: 14 additions & 15 deletions lib/lyaml/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,19 @@
--- @module lyaml


local _ENV = require 'std.normalize' {
'math',
'string.find',
'string.format',
'string.match',
'string.gsub',
'yaml',
'lyaml.functional.NULL',
'lyaml.explicit',
'lyaml.functional.anyof',
'lyaml.functional.id',
'lyaml.implicit',
'lyaml.functional.isnull',
}
local explicit = require 'lyaml.explicit'
local functional = require 'lyaml.functional'
local implicit = require 'lyaml.implicit'
local yaml = require 'yaml'

local NULL = functional.NULL
local anyof = functional.anyof
local find = string.find
local format = string.format
local gsub = string.gsub
local id = functional.id
local isnull = functional.isnull
local match = string.match


local TAG_PREFIX = 'tag:yaml.org,2002:'
Expand Down Expand Up @@ -290,7 +289,7 @@ local parser_mt = {
-- Raise a parse error.
error = function(self, errmsg, ...)
error(format('%d:%d: ' .. errmsg, self.mark.line,
self.mark.column, ...), 0)
self.mark.column, ...), 0)
end,

-- Save node in the anchor table for reference in future ALIASes.
Expand Down
1 change: 0 additions & 1 deletion lyaml-git-1.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ source = {

dependencies = {
'lua >= 5.1, < 5.4',
'std.normalize > 2.0',
}

external_dependencies = {
Expand Down

0 comments on commit 0cb1eca

Please sign in to comment.