<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans-CN">
	<id>https://wiki.undertensai.cn/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=118.166.129.169</id>
	<title>天灾之下：危险连接资料站 - 用户贡献 [zh-cn]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.undertensai.cn/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=118.166.129.169"/>
	<link rel="alternate" type="text/html" href="https://wiki.undertensai.cn/%E7%89%B9%E6%AE%8A:%E7%94%A8%E6%88%B7%E8%B4%A1%E7%8C%AE/118.166.129.169"/>
	<updated>2026-11-17T08:17:36Z</updated>
	<subtitle>用户贡献</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://wiki.undertensai.cn/index.php?title=%E6%A8%A1%E5%9D%97:Crc32lua&amp;diff=27740</id>
		<title>模块:Crc32lua</title>
		<link rel="alternate" type="text/html" href="https://wiki.undertensai.cn/index.php?title=%E6%A8%A1%E5%9D%97:Crc32lua&amp;diff=27740"/>
		<updated>2019-07-13T14:25:35Z</updated>

		<summary type="html">&lt;p&gt;118.166.129.169：​Created page with &amp;quot;--[[  LUA MODULE    digest.crc32 - CRC-32 checksum implemented entirely in Lua.  SYNOPSIS    local CRC = require &amp;#039;digest.crc32lua&amp;#039;   print(CRC.crc32 &amp;#039;test&amp;#039;) --&amp;gt; 0xD87F7E0C or...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;--[[&lt;br /&gt;
&lt;br /&gt;
LUA MODULE&lt;br /&gt;
&lt;br /&gt;
  digest.crc32 - CRC-32 checksum implemented entirely in Lua.&lt;br /&gt;
&lt;br /&gt;
SYNOPSIS&lt;br /&gt;
&lt;br /&gt;
  local CRC = require &#039;digest.crc32lua&#039;&lt;br /&gt;
  print(CRC.crc32 &#039;test&#039;) --&amp;gt; 0xD87F7E0C or -662733300&lt;br /&gt;
  &lt;br /&gt;
  assert(CRC.crc32(&#039;st&#039;, CRC.crc32(&#039;te&#039;)) == CRC.crc32 &#039;test&#039;)&lt;br /&gt;
  &lt;br /&gt;
DESCRIPTION&lt;br /&gt;
&lt;br /&gt;
  This can be used to compute CRC-32 checksums on strings.&lt;br /&gt;
  This is similar to [1-2].&lt;br /&gt;
&lt;br /&gt;
API&lt;br /&gt;
&lt;br /&gt;
  Note: in the functions below, checksums are 32-bit integers stored in&lt;br /&gt;
  numbers.  The number format currently depends on the bit&lt;br /&gt;
  implementation--see DESIGN NOTES below.&lt;br /&gt;
&lt;br /&gt;
  CRC.crc32_byte(byte [, crc]) --&amp;gt; rcrc&lt;br /&gt;
  &lt;br /&gt;
    Returns CRC-32 checksum `rcrc` of byte `byte` (number 0..255) appended to&lt;br /&gt;
    a string with CRC-32 checksum `crc`.  `crc` defaults to 0 (empty string)&lt;br /&gt;
    if omitted.&lt;br /&gt;
&lt;br /&gt;
  CRC.crc32_string(s, crc) --&amp;gt; bcrc&lt;br /&gt;
&lt;br /&gt;
    Returns CRC-32 checksum `rcrc` of string `s` appended to&lt;br /&gt;
    a string with CRC-32 checksum `crc`.  `crc` defaults to 0 (empty string)&lt;br /&gt;
    if omitted.&lt;br /&gt;
  &lt;br /&gt;
  CRC.crc32(o, crc) --&amp;gt; bcrc&lt;br /&gt;
&lt;br /&gt;
    This invokes `crc32_byte` if `o` is a byte or `crc32_string` if `o`&lt;br /&gt;
    is a string.&lt;br /&gt;
  &lt;br /&gt;
  CRC.bit&lt;br /&gt;
&lt;br /&gt;
    This contains the underlying bit library used by the module.  It&lt;br /&gt;
    should be considered a read-only copy.&lt;br /&gt;
&lt;br /&gt;
DESIGN NOTES&lt;br /&gt;
&lt;br /&gt;
  Currently, this module exposes the underlying bit array implementation in CRC&lt;br /&gt;
  checksums returned.  In BitOp, bit arrays are 32-bit signed integer numbers&lt;br /&gt;
  (may be negative).  In Lua 5.2 &#039;bit32&#039; and &#039;bit.numberlua&#039;, bit arrays are&lt;br /&gt;
  32-bit unsigned integer numbers (non-negative).  This is subject to change&lt;br /&gt;
  in the future but is currently done due to (unconfirmed) performance&lt;br /&gt;
  implications.&lt;br /&gt;
  &lt;br /&gt;
  On platforms with 64-bit numbers, one way to normalize CRC&lt;br /&gt;
  checksums to be unsigned is to do `crcvalue % 2^32`,&lt;br /&gt;
  &lt;br /&gt;
  The name of this module is inspired by Perl `Digest::CRC*`.&lt;br /&gt;
&lt;br /&gt;
DEPENDENCIES&lt;br /&gt;
 &lt;br /&gt;
  Requires one of the following bit libraries:&lt;br /&gt;
&lt;br /&gt;
    BitOp &amp;quot;bit&amp;quot; -- bitop.luajit.org -- This is included in LuaJIT and also available&lt;br /&gt;
      for Lua 5.1/5.2.  This provides the fastest performance in LuaJIT.&lt;br /&gt;
    Lua 5.2 &amp;quot;bit32&amp;quot; -- www.lua.org/manual/5.2 -- This is provided in Lua 5.2&lt;br /&gt;
      and is preferred in 5.2 (unless &amp;quot;bit&amp;quot; also happens to be installed).&lt;br /&gt;
    &amp;quot;bit.numberlua&amp;quot; (&amp;gt;=000.003) -- https://github.com/davidm/lua-bit-numberlua&lt;br /&gt;
      This is slowest and used as a last resort.&lt;br /&gt;
      It is only a few times slower than &amp;quot;bit32&amp;quot; though.&lt;br /&gt;
&lt;br /&gt;
DOWNLOAD/INSTALLATION&lt;br /&gt;
&lt;br /&gt;
  If using LuaRocks:&lt;br /&gt;
    luarocks install lua-digest-crc32lua&lt;br /&gt;
&lt;br /&gt;
  Otherwise, download &amp;lt;https://github.com/davidm/lua-digest-crc32lua/zipball/master&amp;gt;.&lt;br /&gt;
  Alternately, if using git:&lt;br /&gt;
    git clone git://github.com/davidm/lua-digest-crc32lua.git&lt;br /&gt;
    cd lua-digest-crc32lua&lt;br /&gt;
  Optionally unpack:&lt;br /&gt;
    ./util.mk&lt;br /&gt;
  or unpack and install in LuaRocks:&lt;br /&gt;
    ./util.mk install &lt;br /&gt;
  &lt;br /&gt;
REFERENCES&lt;br /&gt;
&lt;br /&gt;
  [1] http://www.axlradius.com/freestuff/CRC32.java&lt;br /&gt;
  [2] http://www.gamedev.net/reference/articles/article1941.asp&lt;br /&gt;
  [3] http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/CRC32.html&lt;br /&gt;
  [4] http://www.dsource.org/projects/tango/docs/current/tango.io.digest.Crc32.html&lt;br /&gt;
  [5] http://pydoc.org/1.5.2/zlib.html#-crc32&lt;br /&gt;
  [6] http://www.python.org/doc/2.5.2/lib/module-binascii.html&lt;br /&gt;
 &lt;br /&gt;
LICENSE&lt;br /&gt;
&lt;br /&gt;
  (c) 2008-2011 David Manura.  Licensed under the same terms as Lua (MIT).&lt;br /&gt;
&lt;br /&gt;
  Permission is hereby granted, free of charge, to any person obtaining a copy&lt;br /&gt;
  of this software and associated documentation files (the &amp;quot;Software&amp;quot;), to deal&lt;br /&gt;
  in the Software without restriction, including without limitation the rights&lt;br /&gt;
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell&lt;br /&gt;
  copies of the Software, and to permit persons to whom the Software is&lt;br /&gt;
  furnished to do so, subject to the following conditions:&lt;br /&gt;
&lt;br /&gt;
  The above copyright notice and this permission notice shall be included in&lt;br /&gt;
  all copies or substantial portions of the Software.&lt;br /&gt;
&lt;br /&gt;
  THE SOFTWARE IS PROVIDED &amp;quot;AS IS&amp;quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR&lt;br /&gt;
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,&lt;br /&gt;
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE&lt;br /&gt;
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER&lt;br /&gt;
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,&lt;br /&gt;
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN&lt;br /&gt;
  THE SOFTWARE.&lt;br /&gt;
  (end license)&lt;br /&gt;
 &lt;br /&gt;
--]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local M = {_TYPE=&#039;module&#039;, _NAME=&#039;digest.crc32&#039;, _VERSION=&#039;0.3.20111128&#039;}&lt;br /&gt;
&lt;br /&gt;
local type = type&lt;br /&gt;
local require = require&lt;br /&gt;
local setmetatable = setmetatable&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
 Requires the first module listed that exists, else raises like `require`.&lt;br /&gt;
 If a non-string is encountered, it is returned.&lt;br /&gt;
 Second return value is module name loaded (or &#039;&#039;).&lt;br /&gt;
 --]]&lt;br /&gt;
local function requireany(...)&lt;br /&gt;
  local errs = {}&lt;br /&gt;
  for _,name in ipairs{...} do&lt;br /&gt;
    if type(name) ~= &#039;string&#039; then return name, &#039;&#039; end&lt;br /&gt;
    local ok, mod = pcall(require, name)&lt;br /&gt;
    if ok then return mod, name end&lt;br /&gt;
    errs[#errs+1] = mod&lt;br /&gt;
  end&lt;br /&gt;
  error(table.concat(errs, &#039;\n&#039;), 2)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local bit, name_ = requireany(&#039;bit32&#039;, &#039;bit&#039;, &#039;bit.numberlua&#039;)&lt;br /&gt;
local bxor = bit.bxor&lt;br /&gt;
local bnot = bit.bnot&lt;br /&gt;
local band = bit.band&lt;br /&gt;
local rshift = bit.rshift&lt;br /&gt;
&lt;br /&gt;
-- CRC-32-IEEE 802.3 (V.42)&lt;br /&gt;
local POLY = 0xEDB88320&lt;br /&gt;
&lt;br /&gt;
-- Memoize function pattern (like http://lua-users.org/wiki/FuncTables ).&lt;br /&gt;
local function memoize(f)&lt;br /&gt;
  local mt = {}&lt;br /&gt;
  local t = setmetatable({}, mt)&lt;br /&gt;
  function mt:__index(k)&lt;br /&gt;
    local v = f(k); t[k] = v&lt;br /&gt;
    return v&lt;br /&gt;
  end&lt;br /&gt;
  return t&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- CRC table.&lt;br /&gt;
local crc_table = memoize(function(i)&lt;br /&gt;
  local crc = i&lt;br /&gt;
  for _=1,8 do&lt;br /&gt;
    local b = band(crc, 1)&lt;br /&gt;
    crc = rshift(crc, 1)&lt;br /&gt;
    if b == 1 then crc = bxor(crc, POLY) end&lt;br /&gt;
  end&lt;br /&gt;
  return crc&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function M.crc32_byte(byte, crc)&lt;br /&gt;
  crc = bnot(crc or 0)&lt;br /&gt;
  local v1 = rshift(crc, 8)&lt;br /&gt;
  local v2 = crc_table[bxor(crc % 256, byte)]&lt;br /&gt;
  return bnot(bxor(v1, v2))&lt;br /&gt;
end&lt;br /&gt;
local M_crc32_byte = M.crc32_byte&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function M.crc32_string(s, crc)&lt;br /&gt;
  crc = crc or 0&lt;br /&gt;
  for i=1,#s do&lt;br /&gt;
    crc = M_crc32_byte(s:byte(i), crc)&lt;br /&gt;
  end&lt;br /&gt;
  return crc&lt;br /&gt;
end&lt;br /&gt;
local M_crc32_string = M.crc32_string&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function M.crc32(s, crc)&lt;br /&gt;
  if type(s) == &#039;string&#039; then&lt;br /&gt;
    return M_crc32_string(s, crc)&lt;br /&gt;
  else&lt;br /&gt;
    return M_crc32_byte(s, crc)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
M.bit = bit  -- bit library used&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
return M&lt;/div&gt;</summary>
		<author><name>118.166.129.169</name></author>
	</entry>
	<entry>
		<id>https://wiki.undertensai.cn/index.php?title=%E6%A8%A1%E5%9D%97:WikitextLC&amp;diff=27737</id>
		<title>模块:WikitextLC</title>
		<link rel="alternate" type="text/html" href="https://wiki.undertensai.cn/index.php?title=%E6%A8%A1%E5%9D%97:WikitextLC&amp;diff=27737"/>
		<updated>2019-07-13T13:44:53Z</updated>

		<summary type="html">&lt;p&gt;118.166.129.169：​Created page with &amp;quot;local p = {}  --- Construct an inline conversion from a table input. -- @param content table of the form --        { [&amp;quot;zh-cn&amp;quot;]=&amp;#039;foobar&amp;#039;, [&amp;quot;zh-tw&amp;quot;]=&amp;#039;firecat&amp;#039;, [&amp;quot;zh-hk&amp;quot;]=&amp;#039;&amp;#039; } --...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
--- Construct an inline conversion from a table input.&lt;br /&gt;
-- @param content table of the form&lt;br /&gt;
--        { [&amp;quot;zh-cn&amp;quot;]=&#039;foobar&#039;, [&amp;quot;zh-tw&amp;quot;]=&#039;firecat&#039;, [&amp;quot;zh-hk&amp;quot;]=&#039;&#039; }&lt;br /&gt;
-- @returns string&lt;br /&gt;
--       &amp;quot;-{zh-cn:foobar;zh-tw:firecat;zh-hk:&amp;lt;span&amp;gt;&amp;lt;/span&amp;gt;}-&amp;quot;&lt;br /&gt;
--&lt;br /&gt;
-- @fixme allow for generating output without &amp;quot;-{&amp;quot; &amp;quot;}-&amp;quot;, so that&lt;br /&gt;
--        it can be used with the last three wrappers.&lt;br /&gt;
function p.selective( content )&lt;br /&gt;
    local text = &#039;-{&#039;&lt;br /&gt;
    for variant, value in pairs( content ) do&lt;br /&gt;
        if value == &#039;&#039; then&lt;br /&gt;
            value = &#039;&amp;lt;span&amp;gt;&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
        end&lt;br /&gt;
        text = text .. variant .. &#039;:&#039; .. value .. &#039;;&#039;&lt;br /&gt;
    end&lt;br /&gt;
    text = text .. &#039;}-&#039;&lt;br /&gt;
    return text&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Write some text with a limited set of variants to convert to&lt;br /&gt;
--&lt;br /&gt;
-- @param content text to be written&lt;br /&gt;
-- @param variant a variant (string), or a list of variants&lt;br /&gt;
--        (semicolon-deliminated string, or table of strings)&lt;br /&gt;
-- @param[opt] force convert even under &amp;quot;zh&amp;quot; (no conversion) locale&lt;br /&gt;
function p.converted( content, variant, force )&lt;br /&gt;
    if type( variant ) == &#039;table&#039; then&lt;br /&gt;
        variant = table.concat( variant, &#039;;&#039; )&lt;br /&gt;
    end&lt;br /&gt;
    return &#039;-{&#039; .. ( force and &#039;&#039; or &#039;zh;&#039; ) .. variant .. &#039;|&#039; .. content .. &#039;}-&#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Wraps some &amp;quot;raw text&amp;quot; to not convert.&lt;br /&gt;
--&lt;br /&gt;
-- @fixme Is the &amp;quot;R&amp;quot; flag some undocumented/undefined no-op magic?&lt;br /&gt;
--        Are we using it instead of the old &#039;-{&#039; .. content .. &#039;}-&#039;&lt;br /&gt;
--        to avoid confusion caused by a flag in the &amp;quot;content&amp;quot;?&lt;br /&gt;
function p.raw( content )&lt;br /&gt;
    return &#039;-{R|&#039; .. content .. &#039;}-&#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Wraps a title conversion rule.&lt;br /&gt;
function p.title( content )&lt;br /&gt;
    return &#039;-{T|&#039; .. content .. &#039;}-&#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Wraps a (hidden) conversion rule definition.&lt;br /&gt;
function p.hidden( content )&lt;br /&gt;
    return &#039;-{H|&#039; .. content .. &#039;}-&#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>118.166.129.169</name></author>
	</entry>
</feed>