Mercurial Hosting > luan
comparison core/src/luan/modules/Which_mod.luan @ 629:35dde32c02ab 0.15
change String.matches()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 18 Jan 2016 23:07:52 -0700 |
parents | 6510de302f95 |
children | ca169567ce07 |
comparison
equal
deleted
inserted
replaced
628:6510de302f95 | 629:35dde32c02ab |
---|---|
3 local ipairs = Luan.ipairs or error() | 3 local ipairs = Luan.ipairs or error() |
4 local pairs = Luan.pairs or error() | 4 local pairs = Luan.pairs or error() |
5 local type = Luan.type or error() | 5 local type = Luan.type or error() |
6 local String = require "luan:String" | 6 local String = require "luan:String" |
7 local literal = String.literal or error() | 7 local literal = String.literal or error() |
8 local match = String.match or error() | 8 local matches = String.matches or error() |
9 local Io = require "luan:Io" | 9 local Io = require "luan:Io" |
10 local print = Io.print or error() | 10 local print = Io.print or error() |
11 | 11 |
12 | 12 |
13 local M = {} | 13 local M = {} |
35 | 35 |
36 function M.which(name) | 36 function M.which(name) |
37 local ptn = "[:./]"..literal(name).."$" | 37 local ptn = "[:./]"..literal(name).."$" |
38 for _, uri in ipairs(M.uris) do | 38 for _, uri in ipairs(M.uris) do |
39 local mod = require(uri) | 39 local mod = require(uri) |
40 if match(uri,ptn) ~= nil then | 40 if matches(uri,ptn) then |
41 print(uri) | 41 print(uri) |
42 end | 42 end |
43 if type(mod) == "table" then | 43 if type(mod) == "table" then |
44 for key in pairs(mod) do | 44 for key in pairs(mod) do |
45 if key == name then | 45 if key == name then |