Modulo:mkomtbllin
Salti al navigilo
Salti al serĉilo
Dokumentado por ĉi tiu modulo povas esti kreata ĉe Modulo:mkomtbllin/dokumentado
--[===[ MODULE "MKOMTBLLIN" (kompleta tabelo kun lingvoj) "eo.wiktionary.org/wiki/Modulo:mkomtbllin" <!--2021-Apr-11--> "id.wiktionary.org/wiki/Modul:mkomtbllin" Purpose: brews a (huge) complete table with all supported languages Utilo: generas (egan) kompletan tabelon kun cxiuj subtenataj lingvoj Manfaat: membuat tabel lengkap (dan sangat besar) dengan semua bahasa yang didukung Syfte: skapar en (gigantisk) tabell med alla spraak som stoeds Used by templates / Uzata far sxablonoj / Digunakan oleh templat / Anvaent av mallar: - "montablng" (EO) / "mpltabbah" (ID) (called with param "komp", in turn only used this way by pagxo "Aldono:Listo kun lingvoj" / halaman "Lampiran:Daftar bahasa") Required submodules / Bezonataj submoduloj / Submodul yang diperlukan / Behoevda submoduler: - "mtbllingvoj" in turn requiring template "tbllingvoj" (EO) - "mtblbahasa" in turn requiring template "tblbahasa" (ID) - "mpiksubstrind" Incoming: - 1...3 parameters - anonymous obligatory parameter - string with 5 char:s (tristate options: "0" do not show | "1" show nochk | "2" show and check) - "d07" main lng cat - "d07" kap cat - "d08" vor cat - "d09" appendix - "d09" index - anonymous optional parameter - brew and show technical summary block on success (binary digit "0" or "1", default "0" ie false) - anonymous optional parameter - string with 2 decimal digits "02"..."98" reducing probability to call expensive parser functions, default is 1 ie 100% Returned: - one huge string This module is unbreakable (when called with correct module name and function name). Every imaginable input from the caller and from the imported module "mtbllingvoj" will output either a useful result or at least the string "Grava eraro". Cxi tiu modulo estas nerompebla (kiam vokita kun gxustaj nomo de modulo kaj nomo de funkcio). Cxiu imagebla enigo de la vokanto kaj de la importata modulo "mtbllingvoj" eldonos aux utilan rezulton aux almenaux signocxenon "Grava eraro". The function of this module is governed by the "Specification of the 2-dimensional table picking system". - y-index markers are obligatory and lowercase (numbers and "-" not yet allowed) !!!FIXME!!! - x-index markers are disallowed Column numbering in the source table: - numbering starts from ZERO - "cy" does not count (it has theoretically index "-1") - note that there is no comma between "cy" and "c0" - "mpiktbllki" with special input value "+" returns the complete table line including the y-index marker "cy", this means that unless the "cy" part is trimmed off, index ZERO fed into "mpiksubstrind" will return both "cy" and "c0", thus the indexes used by "mpiksubstrind" will NOT be OFF-by-ONE Structure of a row in the source table with 1+10 columns (soon 1+11): - cy : y-index marker (2 or 3 digits) - c0 : name of the language in the site language - EO: usually AJ lowercase, alternatively SB uppercase begin - ID: without "bahasa " and begins with uppercase letter - c1 : QID (for example "Q5432") !!!FIXME!!! not yet almost now "Q" + 3...9 decimal digits - c1 : name of the language in the language itself (may be rl-enclosed) - c2 : constructed and antique status (digit "0"..."3") - c3 : ISO 639-1:2002 2-letter code - c4 : ISO 639-3:2007 3-letter code - c5 : wiki access code (usually same as "cy" but may be different and longer, for example "zh-min-nan", up to 10 char:s), leave it "-" if code is same or unknown or does not exist - c6 : wiki availability code (2 digits "0"..."2" ie "00"..."22"), "-" causes redish background and no info about availability - c8 : name of ipedia article, base principle usually followed (there are some exceptions): - EO: core word usually AJ name with uppercased begin followed by " lingvo", no "la" article - ID: prefixed by "Bahasa " and core word begins with uppercase letter - c9 : category with our site language ("eo" or "id") in other tionary (with category prefix, but without language prefix, without "]]" or other nonsense, may be rl-enclosed) - c10 : number of pages in that category, apo:s ("16'384") are tolerable (this cannot be peeked automatically) Note that "cy" and "c0" are ultimately obligatory, the remaining ones are only desirable. Overall structure of the generated page: - top either fatal warning block or tiny block, both with purge link - huge destination table (not if fatal error) - technical summary block (without purge link) (may be omitted in some cases) - bottom either fatal warning block or tiny block, both with purge link Structure of a row in the destination table with 14 columns: - d00 : - index (in brackets, not bold) - space - language access code (bold) (literally peeked from "cy" y-index marker in the source table) # adjust background for "eo" only - d01 : - name of the language in the site language with link to the lemma page (name literally peeked from "c0" in the source table, must be available and valid, link augmented by "lfinsertultim" according to control string "contabpages[0]") - d02 : - QID (for example "Q5432") !!!FIXME!!! not yet used - d03 : - name of the language in the language itself (literally peeked from "c1" in the source table) - d04 : - constructed and antique status (expanded from digit "0"..."3" peeked from "c2" in the source table) # adjust background to greenish or grey if applicable - d05 : - "ISO 639-1:2002" 2-letter language code (literally peeked from "c3" in the source table) - d06 : - "ISO 639-3:2007" 3-letter language code (literally peeked from "c4" in the source table) - d07 : - link to the main lng category in own tionary if desired - EOL (if complaint below exists) - complaint about not existing if applicable - EOL (in any case) - number of pages (queried) or "??" if querying does not work - EOL (only if both cat:s are desired) - link to the "kap" category in own tionary with all words in the language (constructed from constant string "constrkatp" (category namespace prefix with ":") and "c0" augmented by "lfinsertultim" according to control string "contabpages[3]") - EOL (if complaint below exists) - complaint about not existing if applicable - EOL (in any case) - number of pages (queried) or "??" if querying does not work # adjust background to redish if the category (one of two) does not exist ! depends on variables "boolngsow" and "boolngexp" and "bookapsow" and "bookapexp" and includes expensive querying (2 or 4), column can be completely hidden if "bood07" is false - d08 : - link to the "vor" category in own tionary with all dictionaries in the language (constructed from constant string "constrkatp" (category namespace prefix with ":") and "c0" augmented by "lfinsertultim" according to control string "contabpages[4]") - EOL (if complaint below exists) - complaint about not existing if applicable - EOL (in any case) - number of pages (queried) or "??" if querying does not work # adjust background to redish if the category does not exist ! depends on variables "boovorsow" and "boovorexp" and includes expensive querying (2), column can be completely hidden if "bood08" is false - d09 : - link to the appendix page (constructed from constant string "constrapxp" (appendix namespace prefix with ":") and "c0" augmented by "lfinsertultim" according to control string "contabpages[1]") controlled by "booapxsow" - EOL (only if both pages are desired) - link to the index page in own tionary with the language (constructed from constant string "constrindp" (index namespace prefix with ":") and "c0" augmented by "lfinsertultim" according to control string "contabpages[2]") # adjust background to redish if at least one of them does not exist ! depends on variables "booapxsow" and "booapxexp" and "booindsow" and "booindexp" and includes expensive querying (1 or 2), column can be completely hidden if "bood09" is false - d10 : - quasi-external link to wikipedia in the language concerned (constructed from "c5" and "c6" and "cy", irrespective availability) - EOL (if note below exists) - note about bad availability if applicable # adjust background to redish if "c6" is not available # adjust background to grey according to bad availability ! no expensive querying here - d11 : - quasi-external link to tionary in the language concerned (constructed from "c5" and "c6" and "cy", irrespective availability) - EOL (if note below exists) - note about bad availability if applicable # adjust background to redish if "c6" is not available # adjust background to grey according to bad availability ! no expensive querying here & special rule ie blocking for own site language - d12 : - quasi-external link to the article in own ipedia about the language (article name constructed from "c7", or alternatively if "c7" is not available then it is guessed using "lfinsertultim" from "c0" and "contabpages[6]" and " (??)" is added) # adjust background to redish if "c7" is not available ! no expensive querying here - d13 : - quasi-external link to EO or ID category in the tionary in the language concerned (peeked from "c8" in the source table) - EOL (if number of articles below exists) - number of articles (peeked from "c9" in the source table) # adjust background to redish if "c8" or "c9" is not available ! no expensive querying here & special rule ie blocking for own site language Expensive querying: There are up to 8 expensive queries (3 cat:s plus appendix plus index, one cat costs 2 bucks ("ifexist" and "pagesincategory") per page, appendix and index cost one buck per page) per language and thus table row. This is a big problem in "mkomtbllin" but in "msngtbllin" it is no problem at all. The hard limit set by wiki software is 500. The totally fired number of calls can be reduced via parameters "boolngexp" "bookapexp" "boovorexp" "booapxexp" "booindexp" "numproba". We even have a fraud implemented. Error handling: - "booerr" set to true if we fail to import the source table, or the argument supplied from the caller is bad, output is minimal with huge error "#E07 Grava eraro" then, no huge table and no technical summary block, fatal warning YES, "numtblper" is NOT valid - "booearsyn" set to true if early syntax check fails (line ZERO with "[[eo]]" or "[[id]]" not found or not valid), output is minimal with huge error "#E07 Grava eraro" then, no huge table and no summary, fatal warning YES, "numtblper" is valid (can be ZERO or equal "numtblend") - "boomxwerr" is a "maxwidth" violation error or line without EOL, checked before and after row, abort immediately, huge error "#E06 Linio estas tro longa", summary YES, fatal warning YES - "boosinerr" set to true in a table row, the row is completed (risk for "-"), loop exited and table closed, huge error "#E05 Sintaksa eraro" is outside the table, summary YES, fatal warning YES - "boosorerr" temporarily set to true and "numsorerr" incremented for every sorting error (not possible in line ZERO), lagom error "Sortiga eraro" is in the table element at column 0, do not exit the loop, fatal warning YES - "numerrtru" (no bool) incremented for every truncated line in source table having "cy" and "c0", minimal error "Nekompleta linio" is in the table element at column 0, do not exit the loop, fatal warning NO - "numerrtlo" (no bool) incremented for every too long line in source table, lagom error "Tro longa (ele) linio" is in the table element at column 0, do not exit the loop, fatal warning YES - "numerrkec" (no bool) incremented for every minor error (possible in line ZERO), do not exit the loop, fatal warning NO - "numerrkap" (no bool) incremented for every missing "kapvorto" category error (possible in line ZERO), do not exit the loop, fatal warning NO - "numerrvor" (no bool) incremented for every missing "vortaro" category error (possible in line ZERO), do not exit the loop, fatal warning NO - "numerrind" (no bool) incremented for every missing index page error (possible in line ZERO), do not exit the loop, fatal warning NO - if "mw.title.getCurrentTitle().prefixedText" does not reveal our pagename (needed for purge link) then we don't whine but use a bad default "Special:Recent changes" instead ]===] local komtbllin = {} ------------------------------------------------------------------------ ---- CONSTANTS ---- ------------------------------------------------------------------------ -- uncommentable EO vs ID constant strings (core site-related features) local constrpriv = "eo" -- EO (privileged site language) -- local constrpriv = "id" -- ID (privileged site language) local construsmo = "Modulo:mtbllingvoj" -- EO (komp YES sng NO) -- local construsmo = "Modul:mtblbahasa" -- ID (komp YES sng NO) local constrpiks = "Modulo:mpiksubstrind" -- EO -- local constrpiks = "Modul:mpiksubstrind" -- ID local constrkatp = "Kategorio:" -- EO -- local constrkatp = "Kategori:" -- ID local constrindp = "Indekso:" -- EO -- local constrindp = "Indeks:" -- ID local constrapxp = "Aldono:" -- EO -- local constrapxp = "Lampiran:" -- ID -- constant table translating x-indexes for "lfseizesubstring" -- valid indexes 0...10 covering totally 11 columns "c0"..."c10" -- but "c1" is fake ie empty -- c0->c0 c1->?? c2->c1 c10->c9 local contabrxi = {[0]=0,nil,1,2,3,4,5,6,7,8,9} -- surrogate transcoding table (only needed for EO) local contabtransiltable = {} contabtransiltable[ 67] = 0xC488 -- CX contabtransiltable[ 99] = 0xC489 -- cx contabtransiltable[ 71] = 0xC49C -- GX contabtransiltable[103] = 0xC49D -- gx contabtransiltable[ 74] = 0xC4B4 -- JX contabtransiltable[106] = 0xC4B5 -- jx contabtransiltable[ 83] = 0xC59C -- SX contabtransiltable[115] = 0xC59D -- sx contabtransiltable[ 85] = 0xC5AC -- UX breve contabtransiltable[117] = 0xC5AD -- ux breve -- constant strings (HTML) local constrfrco = '2020E0' -- table frame color (blue) (use only here in this block) local constrbord = 'border:0.25em solid #' .. constrfrco .. ';' -- part of "style" element (use only here in this block) local constrbkco = 'FFFFD0' -- default cell background color (light yellow) (used in main) local constrhutabegin = '<table style="' .. constrbord .. 'margin:0.5em auto 0.5em auto;border-collapse:collapse;text-align:center;"><tr>' local constrtdbgtit = '<td style="' .. constrbord .. 'padding:0.4em;">' -- colspan NO color NO (title line) local constrtddf = '<td style="' .. constrbord .. 'padding:0.4em;background:#' -- colspan NO color YES (content) local constrtdfd = ';">' -- part of HTML table code after HEX color local constrtden = '</td>' -- constant strings (error circumfixes) local constremibg = '<span class="error">' -- mini whining begin local constremien = '</span>' -- mini whining end local constrelabg = '<span class="error"><b>' -- lagom whining begin local constrelaen = '</b></span>' -- lagom whining end local constrlaxhu = ' [] ' -- lagom -> huge circumfix " [] " local constrexcla = ' ' .. constremibg .. '!!!' .. constremien -- just " !!!" with some style (komp YES sng NO) -- uncommentable EO vs ID constant table (error messages) -- #E02...#E07, note that #E00 and #E01 are NOT supposed to be included here local contaberaroj = {} contaberaroj[2] = 'Nekompleta (ele) linio' -- EO (mini) neko #E02 -- contaberaroj[2] = 'Garis tidak lengkap (ele)' -- ID (mini) contaberaroj[3] = 'Tro longa (ele) linio' -- EO (lagom) trol #E03 -- contaberaroj[3] = 'Garis terlalu panjang (ele)' -- ID (lagom) contaberaroj[4] = 'Sortiga eraro' -- EO (lagom) sore #E04 -- contaberaroj[4] = 'Kesalahan sort' -- ID (lagom) contaberaroj[5] = 'Sintaksa eraro' -- EO (huge) sexe #E05 -- contaberaroj[5] = 'Kesalahan sintaks' -- ID (huge) contaberaroj[6] = 'Linio estas tro longa (sgn, maxwid) aux sen EOL' -- EO (huge) mxwe #E06 -- contaberaroj[6] = 'Garis terlalu panjang (kar, maxwid) atau tanpa EOL' -- ID (huge) contaberaroj[7] = 'Grava eraro' -- EO (huge) fate #E07 -- contaberaroj[7] = 'Kesalahan jahat' -- ID (huge) -- uncommentable EO vs ID constant table (titles for the table) -- see "lfbrewtitsel" and note that contabmisc[0] is needed too -- * "#" is expanded to end of bold + EOL + "and" -- * maximally ONE "#" is permitted -- * end of bold is added at the very end if no "#" is present -- * begin of bold is always added at the very beginning -- * "%" is border between 2 selectable items, it is expanded to -- end of bold + EOL + "and" + EOL + begin of bold if both items are active -- * maximally ONE "%" is permitted local contabdestit = {} contabdestit[00] = 'Alira lingva kodo' -- EO -- contabdestit[00] = 'Kode akses bahasa' -- ID contabdestit[01] = 'Nomo de la lingvo en EO kaj kapvorta pagxo' -- EO (all bold) -- contabdestit[01] = 'Nama bahasa dalam ID dan halaman lema' -- ID (all bold) contabdestit[02] = 'Vikidatumeja pagxo' -- EO -- contabdestit[02] = 'Halaman wikidata' -- ID contabdestit[03] = 'Lingvonomo propralingve' -- EO -- contabdestit[03] = 'Nama bahasa dalam bahasa itu' -- ID contabdestit[04] = 'Planlingva kaj antikva statuso' -- EO -- contabdestit[04] = 'Status buatan dan kuno' -- ID contabdestit[05] = 'ISO 639-1:2002 2-litera kodo' -- EO -- contabdestit[05] = 'ISO 639-1:2002 kode 2 huruf' -- ID contabdestit[06] = 'ISO 639-3:2007 3-litera kodo' -- EO -- contabdestit[06] = 'ISO 639-3:2007 kode 3 huruf' -- ID contabdestit[07] = 'CXefa kategorio%Kapvorta kategorio#kvanto da pagxoj' -- EO (colu can be hidden) -- contabdestit[07] = 'Kategori utama%Kategori lema#jumlah halaman' -- ID (colu can be hidden) contabdestit[08] = 'Vortara kategorio#kvanto da pagxoj' -- EO (colu can be hidden) -- contabdestit[08] = 'Kategori kamus#jumlah halaman' -- ID (colu can be hidden) contabdestit[09] = 'Aldono%Indekso' -- EO (colu can be hidden) -- contabdestit[09] = 'Lampiran%Indeks' -- ID (colu can be hidden) contabdestit[10] = 'Vikipedio en la lingvo' -- EO -- contabdestit[10] = 'Wikipedia dalam bahasa itu' -- ID contabdestit[11] = 'Vikivortaro en la lingvo' -- EO -- contabdestit[11] = 'Wikikamus dalam bahasa itu' -- ID contabdestit[12] = 'Artikolo pri la lingvo en EO vikipedio' -- EO -- contabdestit[12] = 'Artikel tentang bahasa itu dalam wikipedia ID' -- ID contabdestit[13] = 'Kategorio pri EO en vikivortaro en la lingvo#kvanto da pagxoj' -- EO -- contabdestit[13] = 'Kategori tentang ID dalam vikikamus dalam bahasa itu#jumlah halaman' -- ID -- uncommentable EO vs ID constant strings and tables (misc) local contabmisc = {} contabmisc[0] = "kaj" -- EO coordinator "&" -- contabmisc[0] = "dan" -- ID coordinator "&" contabmisc[1] = "ne ekzistas" -- EO status of category pages lng kap vor -- contabmisc[1] = "tidak ada" -- ID status of category pages lng kap vor local contabevilitem = {} contabevilitem = {'erara kodo','erara lingvonomo','erara titolo','erara kategorio','erara Q-umo','erara kvanto'} -- EO (index 1...6, no l&t spaces) -- contabevilitem = {'kode salah','nama bahasa salah','judul salah','kategori salah','butir Q salah','jumlah salah'} -- ID (index 1...6, no l&t spaces) contabevilitem[0] = ' en kolumno' -- EO (index 0, leading space needed) -- contabevilitem[0] = ' dalam kolom' -- ID (index 0, leading space needed) -- uncommentable EO vs ID constant table (pagenames to be constructed) -- syntax of the insertion and discarding magic string: -- "@" followed by 2 uppercase letters and 2 hex numbers -- otherwise the hit is not expanded, but copied as-is instead -- 2 letters select the insertable item from table supplied by the caller -- 2 hex numbers control discarding left and right (0...15 char:s) -- insertable items defined: -- * LN lng name (for example "dana" or "Ido") -- * LU lng name uppercased (for example "Dana" or "Ido") -- see "lfinsertultim" and "tabstuff" use space here and avoid "_" local contabpages = {} contabpages[0] = "@LN00" -- EO lemma page in NS ZERO -- contabpages[0] = "bahasa @LN00" -- ID lemma page in NS ZERO contabpages[1] = "@LU00" -- EO appendix-NS page -- contabpages[1] = "Bahasa @LN00" -- ID appendix-NS page contabpages[2] = "@LU00" -- EO index-NS page -- contabpages[2] = "Bahasa @LN00" -- ID index-NS page contabpages[3] = "Kapvorto (@LN00)" -- EO lemma cat -- contabpages[3] = "Kata bahasa @LN00" -- ID lemma cat contabpages[4] = "Vortaro (@LN00)" -- EO dict cat -- contabpages[4] = "Kamus bahasa @LN00" -- ID dict cat contabpages[5] = "@LU00" -- EO lng cat -- contabpages[5] = "Bahasa @LN00" -- ID lng cat contabpages[6] = "@LU00 lingvo" -- EO ipedia page guessing -- contabpages[6] = "Bahasa @LN00" -- ID ipedia page guessing -- uncommentable EO vs ID constant strings and tables (misc) local contabd03 = {} contabd03 = {'ne planita','parte planita','planita','antikva'} -- EO (index 1...4, no spaces) -- contabd03 = {'tidak buatan','agak buatan','buatan','kuno'} -- ID (index 1...4, no spaces) local contabd09d10 = {} contabd09d10 = {'fermita aux malplena','nedisponebla'} -- EO -- contabd09d10 = {'tertutup atau kosong','tidak ada'} -- ID local constrlnkpu = 'Klaku cxi tie (kaj sekve konsentu al "malplenigi kasxmemoron") por regeneri la tabelon.' -- EO (dot "." needed here) -- local constrlnkpu = 'Kliklah di sini (dan kemudian setujulah dengan "hapus singgahan") untuk menghasilkan ulang tabel.' -- ID (dot "." needed here) local constrsumbr = "[[%C5%9Cablono:tbllingvoj|la fontan tabelon]]" -- EO (no dot "." here) -- local constrsumbr = "[[Templat:tblbahasa|tabel sumber]]" -- ID (no dot "." here) local contabbigtiny = {} contabbigtiny[0] = "Gravaj eraroj trovigxas en la tabelo" -- EO (no dot "." here) ERR -- contabbigtiny[0] = "Ada kesalahan jahat dalam tabel" -- ID (no dot "." here) ERR contabbigtiny[1] = "Se la eraroj persistas tiam vi redaktu" -- EO (no dot "." here) ERR -- contabbigtiny[1] = "Kalau kesalahan masih ada jadi Anda harus menyunting" -- ID (no dot "." here) ERR contabbigtiny[2] = "kaj sekve revenu cxi tien por reinspekti rezulton" -- EO (no dot "." here) ERR -- contabbigtiny[2] = "dan kemudian datang ke sini sekali lagi untuk memeriksa hasilnya" -- ID (no dot "." here) ERR contabbigtiny[3] = "Gxustigu kaj reprovu gxis ke cxi tiu mesagxo malaperas" -- EO (no dot "." here) ERR -- contabbigtiny[3] = "Silakan memperbaiki dan mencoba ulang sampai pesan ini hilang" -- ID (no dot "." here) ERR contabbigtiny[4] = 'Vi povas redakti' -- EO (no dot "." here) OK (komp YES sng NO) -- contabbigtiny[4] = 'Anda bisa menyunting' -- ID (no dot "." here) OK (komp YES sng NO) local contabsum = {} contabsum[0] = "Eniga kontrolparametro, probablo: " -- EO -- contabsum[0] = "Parameter pengontrol masuk, probabilitas: " -- ID contabsum[1] = "Amplekso de la fonta tabelo (bitokoj): " -- EO -- contabsum[1] = "Ukuran tabel sumber (oktet): " -- ID contabsum[2] = "Kvanto da lingvoj: " -- EO -- contabsum[2] = "Jumlah bahasa: " -- ID contabsum[3] = "Kvanto da (gravaj) sortigaj eraroj: " -- EO -- contabsum[3] = "Jumlah kesalahan sort (jahat): " -- ID contabsum[4] = "Kvanto da nekompletaj (ele) linioj: " -- EO -- contabsum[4] = "Jumlah garis tidak lengkap (ele): " -- ID contabsum[5] = "Kvanto da tro longaj (ele) linioj: " -- EO -- contabsum[5] = "Jumlah garis terlalu panjang (ele): " -- ID -- integers "num" -- limits for single items local connummaxc0c2nlen = 48 -- safe values 16 ... 96 -- eval "nummaxnom" ("lad" is very long) local connummaxc8catlen = 100 -- safe values 64 ... 256 -- eval "nummaxkal" -- further tuning local conboofree = true -- cost for "lfifexist" local connumcatstyle = 1 -- category style: 0 raw | 1 "K:" | 2 <br> ------------------------------------------------------------------------ ---- SPECIAL STUFF OUTSIDE MAIN FUNCTION ---- ------------------------------------------------------------------------ ---- VAR:S ---- local qpiksubstri = {} -- type "table" with type "function" inside local qtbllingbaha = {} -- type "table" with type "string" inside local qbooguard = false -- only for the guard test, pass to other var ASAP local qconstrsr = "" -- huge sr table (320 (2*"maxwidth") ... 1'000'000 chars) ---- GUARD AGAINST INTERNAL ERROR & ONE IMPORT VIA REQUIRE ---- if ((type(constrpriv)~="string") or (type(construsmo)~="string") or (type(constrpiks)~="string") or (type(constrkatp)~="string")) then qbooguard = true -- "true" on error else qpiksubstri = require(constrpiks) -- can crash here despite guarding ?? if (type(qpiksubstri)~="table") then qbooguard = true -- "true" on error end--if end--if ---- SEIZE THE HUGE SOURCE TABLE VIA LOADDATA ---- -- maybe can delete "qtbllingbaha" in favor of "qconstrsr" but it is static if (qbooguard==false) then qtbllingbaha = mw.loadData(construsmo) -- can crash here (komp YES sng NO) if (type(qtbllingbaha)~="table") then -- seems to be always false qbooguard = true -- "true" on error else qconstrsr = qtbllingbaha [1] -- convert table -> string (with a small risk) qtbllingbaha = nil -- {{DELETE}} end--if end--if ------------------------------------------------------------------------ ---- ORDINARY LOCAL MATH FUNCTIONS ---- ------------------------------------------------------------------------ -- Local function MATHDIV local function mathdiv (xdividend, xdivisor) local resultdiv = 0 -- DIV operator lacks in LUA :-( resultdiv = math.floor (xdividend / xdivisor) return resultdiv end--function mathdiv -- Local function MATHMOD local function mathmod (xdividendo, xdivisoro) local resultmod = 0 -- MOD operator is "%" and bitwise AND operator lack too resultmod = xdividendo % xdivisoro return resultmod end--function mathmod ------------------------------------------------------------------------ ---- ORDINARY LOCAL CONVERSION FUNCTIONS ---- ------------------------------------------------------------------------ -- Local function LFDEC1DIGLM -- Convert 1 digit decimal to UINT8 with inclusive upper limit local function lfdec1diglm (num1dygyt,num1lim) num1dygyt = num1dygyt - 48 -- may become invalid if ((num1dygyt<0) or (num1dygyt>num1lim)) then num1dygyt = 255 end--if return num1dygyt end--function lfdec1diglm ------------------------------------------------------------------------ -- Local function LFDEC1DIGIT -- Convert 1 decimal ASCII digit to integer 0...9 (255 if invalid). local function lfdec1digit (num1digit) num1digit = num1digit - 48 -- may become invalid if ((num1digit<0) or (num1digit>9)) then num1digit = 255 end--if return num1digit end--function lfdec1digit ------------------------------------------------------------------------ -- Local function LFNUMTO2DIGIT -- Convert integer 0...99 to 2-digit decimal string "00"..."99". -- This sub depends on "MATH FUNCTIONS"\"mathdiv" -- and "MATH FUNCTIONS"\"mathmod". local function lfnumto2digit (numzerotoninetynine) local strtwodig = '' strtwodig = mathdiv(numzerotoninetynine,10) .. mathmod(numzerotoninetynine,10) return strtwodig end--function lfnumto2digit ------------------------------------------------------------------------ -- Local function LFNUMTODECBUN -- Convert non-negative integer to decimal string with bunching. -- This sub depends on "MATH FUNCTIONS"\"mathdiv" -- and "MATH FUNCTIONS"\"mathmod". local function lfnumtodecbun (numnomoriin) local strnomorut = '' local numindeex = 0 local numcaar = 0 numnomoriin = math.floor (numnomoriin) -- transcendental numbers suck if (numnomoriin<0) then numnomoriin = 0 -- negative numbers suck end--if while (true) do numcaar = mathmod(numnomoriin,10) + 48 -- get digit moving right to left numnomoriin = mathdiv(numnomoriin,10) if (numindeex==3) then strnomorut = "'" .. strnomorut -- ueglstr apo numindeex = 0 end--if strnomorut = string.char(numcaar) .. strnomorut -- ueglstr digit numindeex = numindeex + 1 if (numnomoriin==0) then break end--if end--while return strnomorut end--function lfnumtodecbun ------------------------------------------------------------------------ -- Local function LFONEHEXTOINT -- Convert 1 ASCII code of a hex digit to an UINT4 ie 0...15 (255 invalid) -- Only uppercase accepted local function lfonehextoint (numdigit) local numresult = 255 if ((numdigit>47) and (numdigit<58)) then numresult = numdigit-48 end--if if ((numdigit>64) and (numdigit<71)) then numresult = numdigit-55 end--if return numresult end--function lfonehextoint ------------------------------------------------------------------------ ---- ORDINARY LOCAL STRING FUNCTIONS ---- ------------------------------------------------------------------------ local function lftestuc (numkode) local booupperc = false booupperc = ((numkode>=65) and (numkode<=90)) return booupperc end--function lftestuc local function lftestlc (numcode) local boolowerc = false boolowerc = ((numcode>=97) and (numcode<=122)) return boolowerc end--function lftestlc ------------------------------------------------------------------------ -- Local function LFSPACUNDR -- Spaces to underscores or vice-versa. -- Incoming bool "true" for output underscores and "false" for spaces. local function lfspacundr (strxxin, boounderlig) local numleang = 0 local numandex = 0 -- ZERO-based local numcxarr = 0 local strkatrol = "" numleang = string.len (strxxin) while (true) do -- genuine loop if (numandex==numleang) then break end--if numcxarr = string.byte (strxxin,(numandex+1),(numandex+1)) if ((numcxarr==32) or (numcxarr==95)) then if (boounderlig) then numcxarr = 95 else numcxarr = 32 end--if end--if strkatrol = strkatrol .. string.char (numcxarr) numandex = numandex + 1 end--while return strkatrol end--function lfspacundr ------------------------------------------------------------------------ -- Local function LFCOUNTCHR -- Count occurrences of a char (given by ASCII code) in a string. -- Input : * strqq -- string (empty is useless but can't cause major harm) -- * numascii -- code of char to be counted -- Output : * numrezalt -- number of hits local function lfcountchr (strqq, numascii) local numrezalt = 0 local numciar = 0 local numukuran = 0 local numindxe = 0 -- ZERO-based numukuran = string.len (strqq) while (true) do if (numindxe==numukuran) then break -- done -- ZERO iterations possible end--if numciar = string.byte (strqq,(numindxe+1),(numindxe+1)) if (numciar==numascii) then numrezalt = numrezalt + 1 end--if numindxe = numindxe + 1 end--while return numrezalt end--function lfcountchr ------------------------------------------------------------------------ -- Local function LFCOUNTNDG -- Count occurrences of non-digits (from a customizable set) in a string -- Tolerable char:s that do not count are: -- * digits "0"..."9" -- * maybe apo for (trictl=1) or (trictl=2) -- * maybe space for (trictl=2) local function lfcountndg (strzzz,trictl) local numjrezalt = 0 local numcair = 0 local numjukuran = 0 local numjindxe = 0 -- ZERO-based numjukuran = string.len(strzzz) while (true) do if (numjindxe==numjukuran) then break end--if numcair = string.byte(strzzz,(numjindxe+1),(numjindxe+1)) if ((numcair==39) and (trictl~=0)) then numcair=48 -- apo OK end--if if ((numcair==32) and (trictl==2)) then numcair=48 -- space OK end--if if ((numcair<48) or (numcair>57)) then numjrezalt = numjrezalt + 1 end--if numjindxe = numjindxe + 1 end--while return numjrezalt end--function lfcountndg ------------------------------------------------------------------------ -- Local function LFREMOVENONDI -- Remove non-digits from a string, return "0" if no digits available. local function lfremovenondi (strmess) local strnumautnum = '' local numcchhrr = 0 local numwukur = 0 local numwindxe = 0 -- ZERO-based numwukur = string.len(strmess) while (true) do if (numwindxe==numwukur) then break end--if numcchhrr = string.byte(strmess,(numwindxe+1),(numwindxe+1)) if ((numcchhrr>47) and (numcchhrr<58)) then strnumautnum = strnumautnum .. string.char(numcchhrr) -- cpy digits only end--if numwindxe = numwindxe + 1 end--while if (strnumautnum=='') then strnumautnum = '0' -- result CANNOT be empty, always a valid number end--if return strnumautnum end--function lfremovenondi ------------------------------------------------------------------------ -- Local function LFVALIDATESTR -- Validate string according to a huge bunch of criteria -- Input : - stryn : string -- - varalt : alternative valid string (for example "??" or "-") -- that can "jump over" all other checks, note that empty -- string can be used here, use type "nil" if none -- - nummyn : minimal length -- - nummex : maximal length -- - numapo : apo rules -- 0 : no restrictions -- 1 : leading and trailing and multiple apo:s prohibited -- (no-wiki-bolding-policy) -- 2 : apo:s totally prohibited -- - numpoz : positive list of tolerable char:s -- 0 : none -- 1 : only ASCII digits and maybe -- apo:s (see also parameter "numapo" above) -- 2 : only ASCII uppercase letters -- 3 : only ASCII lowercase letters -- Output : - booisvalid : true if string is valid local function lfvalidatestr (stryn,varalt,nummyn,nummex,numapo,numpoz) local booisvalid = true -- for the caller local numlencx = 0 local numynx = 0 local numcxar = 0 local numcxur = 0 local vartnp = 0 while (true) do -- fake loop if (type(varalt)=="string") then if (stryn==varalt) then break -- to join mark -- string is valid end--if end--if numlencx = string.len(stryn) if ((numlencx<nummyn) or (numlencx>nummex)) then booisvalid = false break -- to join mark -- string is faulty end--if if (numlencx==0) then break -- to join mark -- string is empty but valid end--if if (numapo==1) then numcxar = string.byte(stryn,1,1) numcxur = string.byte(stryn,numlencx,numlencx) vartnp = string.find(stryn, "''", 1, true) -- plain text search for apo if ((numcxar==39) or (numcxur==39) or vartnp) then booisvalid = false break -- to join mark -- string is faulty end--if end--if (numapo==1) then if ((numpoz~=0) or (numapo==2)) then numynx = 0 -- ZERO-based index while (true) do if (numynx==numlencx) then break -- done search, all OK end--if numcxar = string.byte(stryn,(numynx+1),(numynx+1)) if ((numapo==2) and (numcxar==39)) then booisvalid = false break -- abort search, crime detected (apo) end--if if ((numpoz==1) and (numcxar~=39)) then if ((numcxar<48) or (numcxar>57)) then booisvalid = false break -- abort search, crime detected (non-digit) end--if end--if if (numpoz==2) then if ((numcxar<65) or (numcxar>90)) then booisvalid = false break -- abort search, crime detected (non-uppercase) end--if end--if if (numpoz==3) then if ((numcxar<97) or (numcxar>122)) then booisvalid = false break -- abort search, crime detected (non-lowercase) end--if end--if numynx = numynx + 1 -- ZERO-based index end--while end--if ((numpoz~=0) or (numapo==2)) then break -- finally to join mark end--while -- fake loop -- join mark return booisvalid end--function lfvalidatestr ------------------------------------------------------------------------ ---- ORDINARY LOCAL LOW LEVEL FUNCTIONS ---- ------------------------------------------------------------------------ -- Local function LFPREPROEQMI -- Preprocess "=" to "-" -- A table element may not be equal to the string "=" per spec local function lfpreproeqmi (strinnandout) if (strinnandout=="=") then strinnandout = "-" -- preprocess "=" to "-" end--if return strinnandout end--function lfpreproeqmi ------------------------------------------------------------------------ local function lfclamp (strclin,numlenlim) -- clamps string length, tripledot local strrezulto = '' local numinnlen = 0 local numlenlihaf = 0 numinnlen = string.len(strclin) if (numlenlim<8) then numlenlim=8 end--if numlenlihaf = mathdiv((numlenlim-3),2) -- at least 2 if (numinnlen<=numlenlim) then strrezulto = strclin -- copy as-is, do NOT add quotes else strrezulto = '"' .. string.sub(strclin,1,numlenlihaf) .. '"..."' .. string.sub(strclin,(numinnlen-numlenlihaf+1),numinnlen) .. '"' end--if return strrezulto end--function lfclamp ------------------------------------------------------------------------ -- convert integer to deciml string with digit bunching & warn unconditionally -- need constant string "constrexcla" ie just " !!!" with some style local function lftostwauc (numccrap) local strhaasil = '' strhaasil = lfnumtodecbun(numccrap) .. constrexcla return strhaasil end--function lftostwauc -- convert integer to deciml string with digit bunching & warn if non-ZERO -- need constant string "constrexcla" ie just " !!!" with some style local function lftostwaz (numcrap) local strhasil = '' strhasil = lfnumtodecbun(numcrap) if (numcrap~=0) then strhasil = strhasil .. constrexcla end--if return strhasil end--function lftostwaz -- convert integer to deciml string with digit bunching & warn if over limit -- need constant string "constrexcla" ie just " !!!" with some style local function lftostw2p (numcreap, numinklimit) local strhasiil = '' strhasiil = lfnumtodecbun(numcreap) if (numcreap>numinklimit) then strhasiil = strhasiil .. constrexcla end--if return strhasiil end--function lftostw2p ------------------------------------------------------------------------ ---- ORDINARY LOCAL UTF8 FUNCTIONS ---- ------------------------------------------------------------------------ -- Local function LFUTF8LENGTH -- Measure length of a single UTF8 char, return ZERO if invalid -- Does NOT thoroughly check the validity, looks at 1 octet only -- Input : * numbgoctet (beginning octet of a UTF8 char) -- Output : * numlen1234x (1...4 or ZERO if invalid) local function lfutf8length (numbgoctet) local numlen1234x = 0 if (numbgoctet<128) then numlen1234x = 1 -- $00...$7F -- ANSI/ASCII end--if if ((numbgoctet>=194) and (numbgoctet<=223)) then numlen1234x = 2 -- $C2 to $DF end--if if ((numbgoctet>=224) and (numbgoctet<=239)) then numlen1234x = 3 -- $E0 to $EF end--if if ((numbgoctet>=240) and (numbgoctet<=244)) then numlen1234x = 4 -- $F0 to $F4 end--if return numlen1234x end--function lfutf8length ------------------------------------------------------------------------ -- Local function LFCASEREST -- Adjust case of a single letter (restricted), only ASCII -- and 6 extra EO letters. -- Input : * strucinuut : single unicode letter (1 or 2 octet:s) -- * booupcas : for desired uppercase "true" and for -- lowercase "false" -- Output : * strucinuut : (same var, "ZZ" on failure) -- This will not give useful results for any non-ASCII char:s other -- than uppercase and lowercase EO letters (CX GX HX JX SX UX -- cx gx hx jx sx ux). Invalid non-ASCII input generates "ZZ". -- This sub depends on "MATH FUNCTIONS"\"mathmod" and -- "STRING FUNCTIONS"\"lftestuc" and "STRING FUNCTIONS"\"lftestlc" and -- "UTF8 FUNCTIONS"\"lfutf8length". local function lfcaserest (strucinuut, booupcas) local numlaengdn = 0 -- length from "string.len" local numchaerr = 0 -- UINT8 beginning char local numchaess = 0 -- UINT8 later char (BIG ENDIAN, lower value here) local numchareel = 0 -- UINT8 code relative to beginning of block $00...$FF local numdeta = 0 -- SINT8 +32 or -32 or +1 or -1 or ZERO local numtheemp = 0 local boowantlowr = false local booiisuppr = false local booiislowr = false local boovalid = true numlaengdn = string.len (strucinuut) boowantlowr = (not booupcas) boovalid = ((numlaengdn==1) or (numlaengdn==2)) if (boovalid) then numchaerr = string.byte (strucinuut,1,1) boovalid = ((lfutf8length(numchaerr))==numlaengdn) -- mismatch with length end--if if (boovalid and (numlaengdn==1)) then booiisuppr = lftestuc(numchaerr) booiislowr = lftestlc(numchaerr) if (booiisuppr and boowantlowr) then numdeta = 32 -- ASCII UPPER->lower end--if if (booiislowr and booupcas) then numdeta = -32 -- ASCII lower->UPPER end--if end--if if (boovalid and (numlaengdn==2)) then boovalid = ((numchaerr==196) or (numchaerr==197)) end--if if (boovalid and (numlaengdn==2)) then numchaess = string.byte (strucinuut,2,2) numchareel = (numchaerr-196)*64 + (numchaess-128) -- begins at $C4 numtheemp = numchareel -- temp var to protect "numchareel" from trashing numtheemp = numtheemp - (mathmod(numtheemp,2)) -- very bad way to do AND boovalid = ((numtheemp==8) or (numtheemp==28) or (numtheemp==36) or (numtheemp==52) or (numtheemp==92) or (numtheemp==108)) end--if if (boovalid and (numlaengdn==2)) then booiislowr = ((mathmod(numchareel,2))==1) -- UC even (ordinary) booiisuppr = not booiislowr if (booiisuppr and boowantlowr) then numdeta = 1 -- UPPER->lower end--if if (booiislowr and booupcas) then numdeta = -1 -- lower->UPPER end--if end--if if (boovalid) then if ((numlaengdn==1) and (numdeta~=0)) then strucinuut = string.char (numchaerr + numdeta) -- no risk of carry here end--if if ((numlaengdn==2) and (numdeta~=0)) then strucinuut = string.char (numchaerr) .. string.char (numchaess + numdeta) end--if else strucinuut = "ZZ" -- illegal non-ASCII char end--if return strucinuut -- same var for input and output !!! end--function lfcaserest ------------------------------------------------------------------------ -- Local function LFXCASEULT -- Adjust letter case of beginning letter or all letters in a word or group of -- words to upper or lower, limited unicode support (restricted LFCASEREST). -- See LFFIXCASE for a simple ASCII version. -- Input : * strenigo : word or group of words (may be empty) -- * booupcas : "true" for uppercase and "false" for lowercase -- * boodoall : "true" to adjust all letters, "false" only beginning -- This sub depends on "MATH FUNCTIONS"\"mathmod" and -- "STRING FUNCTIONS"\"lftestuc" and "STRING FUNCTIONS"\"lftestlc" and -- "UTF8 FUNCTIONS"\"lfutf8length" and "UTF8 FUNCTIONS"\"lfcaserest" -- (restricted LFCASEREST). local function lfxcaseult (strenigo, booupcas, boodoall) local numlein = 0 local numposi = 1 -- octet position ONE-based local numcut = 0 -- length of an UTF8 char local bootryadj = false -- try to adjust single char local strte7mp = "" local strelygo = "" numlein = string.len (strenigo) while (true) do if (numposi>numlein) then break -- done end--if bootryadj = (boodoall or (numposi==1)) numcut = lfutf8length(string.byte(strenigo,numposi,numposi)) if ((numcut==0) or ((numposi+numcut-1)>numlein)) then numcut = 1 -- skip ie copy one faulty octet bootryadj = false end--if strte7mp = string.sub (strenigo,numposi,(numposi+numcut-1)) -- 1...4 oct if (bootryadj) then strte7mp = lfcaserest(strte7mp,booupcas) -- (restricted LFCASEREST) end--if strelygo = strelygo .. strte7mp -- this can be slow numposi = numposi + numcut end--while return strelygo end--function lfxcaseult ------------------------------------------------------------------------ ---- ORDINARY LOCAL HIGH LEVEL FUNCTIONS ---- ------------------------------------------------------------------------ -- Local function LFBREWERRSV -- #E02...#E07, note that #E00 and #E01 are NOT supposed to be included here -- We need 5 const strings "constremibg", "constremien", -- "constrelabg", "constrelaen", "constrlaxhu" and const table "contaberaroj". -- severity level can be 0 mini 1 lagom 2 huge local function lfbrewerrsv (numerrorcode, numseverity) local stritsucks = '#E' if ((numerrorcode>=2) and (numerrorcode<=7)) then -- #E07 hardcoded here stritsucks = stritsucks .. '0' .. string.char(numerrorcode+48) .. ' ' .. contaberaroj[numerrorcode] else stritsucks = stritsucks .. '??' end--if if (numseverity==0) then stritsucks = constremibg .. stritsucks .. constremien else stritsucks = constrelabg .. stritsucks .. constrelaen end--if if (numseverity==2) then stritsucks = constrlaxhu .. stritsucks .. constrlaxhu end--if return stritsucks end--function lfbrewerrsv ------------------------------------------------------------------------ -- Local function LFINSERTULTIM -- Insert selected extra strings into a given string at given positions -- with optional discarding if the insertable item is empty. Discarding is -- protected from access out of range by clamping the distances. -- Input : * strmdata -- main data string with control cod (syntax see below) -- * tabinseert -- not-string is safe and has same effect as empty -- string, "nil" or empty string "" are preferred -- Output : * strhazil -- syntax of the insertion and discarding magic string: -- "@" followed by 2 uppercase letters and 2 hex numbers -- otherwise the hit is not expanded, but copied as-is instead -- 2 letters select the insertable item from table supplied by the caller -- 2 hex numbers control discarding left and right (0...15 char:s) -- Empty item in "tabinseert" is legal and results in discarding if some of -- the control numbers is non-ZERO. Left discarding is practically performed -- on "strhazil" whereas right discarding on "strmdata" and "numdatainx". -- If uppercasing or other adjustment is needed then the caller must take -- care of it in the form of 2 or more separate items provided in the table -- with separate names. -- This sub depends on "STRING FUNCTIONS"\"lftestuc" -- and "CONVERSION FUNCTIONS"\"lfonehextoint". local function lfinsertultim (strmdata,tabinseert) local varduahuruf = 0 local strhazil = '' local numdatalen = 0 local numdatainx = 0 -- src index local numdataoct = 0 -- maybe @ local numdataodt = 0 -- UC local numdataoet = 0 -- UC local numammlef = 0 -- hex and discard left local numammrig = 0 -- hex and discard right local boogotmagic = false numdatalen = string.len(strmdata) numdatainx = 1 -- ONE-based while (true) do -- genuine loop, "numdatainx" is the counter if (numdatainx>numdatalen) then -- beware of risk of overflow below break -- done (ZERO iterations possible) end--if boogotmagic = false numdataoct = string.byte(strmdata,numdatainx,numdatainx) numdatainx = numdatainx + 1 while (true) do -- fake loop if ((numdataoct~=64) or ((numdatainx+3)>numdatalen)) then break -- no hit here end--if numdataodt = string.byte(strmdata, numdatainx , numdatainx ) numdataoet = string.byte(strmdata,(numdatainx+1),(numdatainx+1)) if ((lftestuc(numdataodt)==false) or (lftestuc(numdataoet)==false)) then break -- no hit here end--if numammlef = string.byte(strmdata,(numdatainx+2),(numdatainx+2)) numammrig = string.byte(strmdata,(numdatainx+3),(numdatainx+3)) numammlef = lfonehextoint (numammlef) numammrig = lfonehextoint (numammrig) boogotmagic = ((numammlef~=255) and (numammrig~=255)) break end--while -- fake loop -- join mark if (boogotmagic) then numdatainx = numdatainx + 4 -- consumed 5 char:s, cannot overflow here varduahuruf = string.char (numdataodt,numdataoet) varduahuruf = tabinseert[varduahuruf] -- risk of type "nil" if (type(varduahuruf)~="string") then varduahuruf = '' -- type "nil" or invalid type gives empty string end--if if (varduahuruf=='') then numdataoct = string.len(strhazil) - numammlef -- this can underflow if (numdataoct<=0) then strhazil = '' else strhazil = string.sub(strhazil,1,numdataoct) -- discard left end--if numdatainx = numdatainx + numammrig -- discard right this can overflow else strhazil = strhazil .. varduahuruf -- insert / expand end--if else strhazil = strhazil .. string.char(numdataoct) -- copy char as-is end--if (boogotmagic) else end--while return strhazil end--function lfinsertultim ------------------------------------------------------------------------ -- Local function LFKODEOSG -- Transcode eo X-surrogates (without "\", thus for example "kacxo", -- NOT "ka\cxo") to cxapeloj in a single string (EO only). -- Input : * strsurr -- string (empty is useless but can't cause major harm) -- Output : * strcxapeloj -- UTF8 string -- We need const table "contabtransiltable". -- This sub depends on "MATH FUNCTIONS"\"mathdiv" -- and "MATH FUNCTIONS"\"mathmod". local function lfkodeosg (strsurr) local varpeek = 0 local strcxapeloj = '' local numinputl = 0 local numininx = 0 -- ZERO-based source index local numknark = 0 -- current char (ZERO is NOT valid) local numknarp = 0 -- previous char (ZERO is NOT valid) local numlow = 0 local numhaj = 0 numinputl = string.len(strsurr) while (true) do if (numininx==numinputl) then break end--if numknark = string.byte(strsurr,(numininx+1),(numininx+1)) numininx = numininx + 1 numhaj = 0 -- pre-assume no translation if ((numknarp~=0) and ((numknark==88) or (numknark==120))) then -- got "x" varpeek = contabtransiltable[numknarp] -- UINT16 or nil if (varpeek~=nil) then numlow = mathmod (varpeek,256) numhaj = mathdiv (varpeek,256) end--if end--if if (numhaj~=0) then strcxapeloj = strcxapeloj .. string.char(numhaj,numlow) -- add UTF8 char numknark = 0 -- invalidade current char else if (numknarp~=0) then -- add previous char only if valid strcxapeloj = strcxapeloj .. string.char(numknarp) -- add it end--if end--if numknarp = numknark -- copy to previous even if invalid end--while if (numknarp~=0) then -- add previous and last char only if valid strcxapeloj = strcxapeloj .. string.char(numknarp) -- add it end--if return strcxapeloj end--function lfkodeosg ------------------------------------------------------------------------ -- Local function LFKODEOTB -- Transcode eo X-surrogates to cxapeloj whole table with strings (EO only). -- This sub depends on "HIGH LEVEL FUNCTIONS"\"lfkodeosg". local function lfkodeotb (tabsurr) local varitem = 0 -- variable without type local tabcxapeloj = {} local numtblindex = 0 -- ZERO-based while (true) do varitem = tabsurr[numtblindex] -- expected type "string" or "nil" if (varitem==nil) then if (numtblindex~=0) then break -- index ZERO is valid (just proceed to index 1 in such a case) end--if else tabcxapeloj[numtblindex] = lfkodeosg(varitem) end--if numtblindex = numtblindex + 1 end--while return tabcxapeloj end--function lfkodeotb ------------------------------------------------------------------------ -- Local function LFRLSTRIP -- Strip "rl .. lr" if present and string length is at least 8 octet:s local function lfrlstrip (strrlinut) local numsoct = 0 local numsodt = 0 local numsoet = 0 local numsoft = 0 local numsogt = 0 local numsoht = 0 local numlaengd = 0 numlaengd = string.len(strrlinut) if (numlaengd>=8) then -- at least 2 Octet:s length "rl .. lr" after strip numsoct = string.byte(strrlinut,1,1) numsodt = string.byte(strrlinut,2,2) numsoet = string.byte(strrlinut,3,3) numsoft = string.byte(strrlinut,(numlaengd-2),(numlaengd-2)) numsogt = string.byte(strrlinut,(numlaengd-1),(numlaengd-1)) numsoht = string.byte(strrlinut,(numlaengd ),(numlaengd )) if ((numsoct==114) and (numsodt==108) and (numsoet==32) and (numsoft==32) and (numsogt==108) and (numsoht==114)) then strrlinut = string.sub(strrlinut,4,(numlaengd-3)) -- stri off 3+3 char:s end--if end--if return strrlinut end--function lfrlstrip ------------------------------------------------------------------------ -- Local function LFIFEXIST -- Check whether a wiki page exists. Caller must take care of cost tracking. -- Input : * arxinp3 -- arx -- * strpgname -- fullpagename (default NS 0, not template NS 10) -- Output : * boomemangada -- "true" on success -- Depends on const "conboofree" (use unofficial aggressive free algo). -- Extra colon is tolerable for non-NS-ZERO and non-template-NS-10 pages -- such as "{{msgnw::Help:TOC}}" and returns ...":Help:TOC"... if the -- page does not exist. local function lfifexist (arxinp3,strpgname) local boomemangada = false local metaa = 0 if (conboofree) then boomemangada = ( '[[:' .. strpgname .. ']]' ~= arxinp3:preprocess ('{{msgnw::' .. strpgname .. '}}') ) else metaa = mw.title.new (strpgname) -- 1 param boomemangada = metaa.exists -- expensive end--if return boomemangada end--function lfifexist ------------------------------------------------------------------------ -- Local function LFKATROL -- Peeks summary of a category. Caller must take care of cost tracking. -- Input : * strkatname -- without prefix -- Output : * numpages, numsubcats -- 2 values local function lfkatrol (strcatname) local metab = 0 local numpages = 0 local numsubcats = 0 metab = mw.site.stats.pagesInCategory ( strcatname, "*" ) -- expensive numpages = metab.pages numsubcats = metab.subcats return numpages, numsubcats end--function lfkatrol ------------------------------------------------------------------------ -- Local function LFNUMBERINKAT local function lfnumberinkat (varjumlah) -- "(16'384 pages)" or "(?? pages)" local strnothing = '' if (varjumlah==nil) then -- expected type integer or nil strnothing = '(??' else strnothing = '(' .. lfnumtodecbun(varjumlah) -- ZERO is valid end--if strnothing = strnothing .. ' pages)' return strnothing end--function lfnumberinkat ------------------------------------------------------------------------ -- Local function LFQUER2KAT -- Depends on const "conboofree" (use unofficial aggressive free -- algo), "constrkatp", "contabmisc". -- This sub depends on "HIGH LEVEL FUNCTIONS"\"lfifexist" and -- "HIGH LEVEL FUNCTIONS"\"lfkatrol" and -- "HIGH LEVEL FUNCTIONS"\"lfnumberinkat". local function lfquer2kat (arxpass,strkatt) -- calls 2 system functions local strkatoj = '' -- accumulate notes here local numjumlah = 0 local boomiss = false boomiss = not (lfifexist(arxpass,(constrkatp..strkatt))) if (boomiss) then -- incidents counted by caller strkatoj = '<br>(' .. contabmisc[1] .. ')' -- "does not exist" end--if numjumlah = lfkatrol (strkatt) -- discard 1 of 2 results strkatoj = strkatoj .. '<br>' if (numjumlah>=0) then strkatoj = strkatoj .. lfnumberinkat(numjumlah) else strkatoj = strkatoj .. lfnumberinkat(nil) -- does NOT count as error end--if return boomiss,strkatoj end--function lfquer2kat ------------------------------------------------------------------------ local function lfavailco (numava) -- translates number 2...0 to color (Y,grey) local strcolor = constrbkco -- pre-assume light yellow (default color) if (numava==1) then strcolor = 'D0D0D0' -- grey end--if if (numava==0) then strcolor = 'B0B0B0' -- darker grey end--if return strcolor end--function lfavailco ------------------------------------------------------------------------ -- Local function LFAVAILNT -- Translate number 2...0 to text with "br" -- We need table "contabd09d10" with 2 strings at indexes ONE and TWO local function lfavailnt (numalb) local strnote = '' -- pre-assume no extra complaint if (numalb==1) then strnote = '<br>(' .. contabd09d10[1] .. ')' -- closed or empty end--if if (numalb==0) then strnote = '<br>(' .. contabd09d10[2] .. ')' -- inaccessible end--if return strnote end--function lfavailnt ------------------------------------------------------------------------ -- Local function LFEVILITEM -- Brew complaint about faulty item in the source table. -- Input : * numitem -- type (0:code 1:langname 2:title 3:category -- 4:Q-item 5:number) -- * numcol -- column index (maybe 0...13) or special value 56 -- * strxx -- the faulty string already suitably clamped -- Output : * 2 lines separated by "<br>" -- We need table "contabevilitem" (1...6) OFF-by-ONE with special -- content at index ZERO. -- We need "constrelabg" and "constrelaen" (lagom error). local function lfevilitem (numitem,numcol,strxx) local strharang = '' local numquot = 0 strharang = constrelabg .. contabevilitem[numitem+1] .. contabevilitem[0] .. constrelaen .. ' "c' if (numcol==56) then strharang = strharang .. '5" "c6' -- special case else strharang = strharang .. tostring(numcol) end--if strharang = strharang .. '" :<br>' numquot = string.byte(strxx,1,1) if (numquot==34) then strharang = strharang .. strxx -- truncated string like <<"sh"..."ck">> else strharang = strharang .. '"' .. strxx .. '"' -- add quotes if not yet pres end--if return strharang end--function lfevilitem ------------------------------------------------------------------------ -- Local function LFKATTLAENK -- Brew link possibly saving screen space. -- Depends on const "constrkatp" (ends with colon) and -- "connumcatstyle" (0 raw | 1 "K:" | 2 <br>). local function lfkattlaenk (strkattnamn) local strkatter = '' local straltprefix = '' if (connumcatstyle==0) then strkatter = "[[:" .. constrkatp .. strkattnamn .. "]]" -- raw else if (connumcatstyle==1) then straltprefix = string.sub (constrkatp,1,1) .. ':' -- "C:" else straltprefix = constrkatp .. '<br>' -- "Category:" + EOL end--if strkatter = "[[:" .. constrkatp .. strkattnamn .. "|" .. straltprefix .. strkattnamn .. "]]" end--if return strkatter end--function lfkattlaenk ------------------------------------------------------------------------ -- Local function LFBREWURL -- Brew [] external link to a wiki. -- Input : - straxk : wiki access code (2...10 char:s) -- - bootip : type (false -> ipedia | true -> tionary) -- - varpage : pagename string (article or category with -- prefix) or type "nil" expected -- Here we replace spaces by underscore, no further encoding is performed -- We need "lfspacundr" local function lfbrewurl (straxk,bootip,varpage) local strurlkita = '' local strsite = '' if (bootip) then strsite = 'tionary' else strsite = 'ipedia' end--if strurlkita = '[http://' .. straxk .. '.wik' .. strsite .. '.org' if (varpage) then -- string (article or category with prefix) or nil strurlkita = strurlkita .. '/wiki/' .. lfspacundr(varpage,true) -- replace in URL end--if strurlkita = strurlkita .. ' ' -- separation space strurlkita = strurlkita .. straxk .. '.' .. strsite .. '...' if (varpage) then -- string (article or category with prefix) or nil strurlkita = strurlkita .. '<br>/' .. varpage -- do NOT replace here end--if strurlkita = strurlkita .. ']' -- done return strurlkita end--function lfbrewurl ------------------------------------------------------------------------ -- Local function LFBREWTITSEL -- Brew content of title cell (for column or row) from index -- number and two booleans. -- Input : * numindxe -- index number of column (ZERO-based) -- * bootopp, boobotm -- * "#" is expanded to end of bold + EOL + "and" -- * maximally ONE "#" is permitted -- * end of bold is added at the very end if no "#" is present -- * begin of bold is always added at the very beginning -- * "%" is border between 2 selectable items, it is expanded to -- end of bold + EOL + "and" + EOL + begin of bold if both items are active -- * maximally ONE "%" is permitted -- An entry in the table "contabdestit" is NOT supposed to contain -- "<b>" (even less triple-apo "'''"), nor "</b>" at end nor "<br>". -- We need const table "contabdestit" and contabmisc[0]. -- This sub depends on "CONVERSION FUNCTIONS"\"lfnumto2digit". local function lfbrewtitsel (numindxe, bootopp, boobotm) local strraw = '' local strdesc = '' local numlimiit = 0 local numoindex = 1 -- ONE-based local numpycker = 0 local numfragmm = 0 -- NOT relevant if both "bootopp" and "boobotm" are true local booslutbold = false local bootakeit = false strraw = contabdestit[numindxe] strdesc = '<b>' numlimiit = string.len (strraw) while (true) do if (numoindex>numlimiit) then break end--if bootakeit = true numpycker = string.byte(strraw,numoindex,numoindex) numoindex = numoindex + 1 if (numpycker==35) then -- 35 is "#" strdesc = strdesc .. "</b><br>" booslutbold = true bootakeit = false numfragmm = 2 -- following text taken unconditionally end--if if (numpycker==37) then -- 37 is "%" if (bootopp and boobotm) then strdesc = strdesc .. "</b><br>" .. contabmisc[0] .. "<br><b>" end--if numfragmm = numfragmm + 1 bootakeit = false end--if if ((numfragmm==0) and (bootopp==false)) then bootakeit = false end--if if ((numfragmm==1) and (boobotm==false)) then bootakeit = false end--if if (bootakeit) then strdesc = strdesc .. string.char(numpycker) end--if end--while if (booslutbold==false) then strdesc = strdesc .. '</b>' -- add "</b>" only if it is not yet in end--if strdesc = strdesc .. '<br>(d' .. lfnumto2digit (numindxe) .. ')' return strdesc end--function lfbrewtitsel ------------------------------------------------------------------------ -- Local function LFSEIZESUBSTRING -- special value for x-index "-" means count substrings -- we need "qpiksubstri.ek" ie imported "mpiksubstrind" -- we need "contabrxi" local function lfseizesubstring (strbigline,strxindex) local strsubstringum = '' local strxxii = '' local varxxxindex = 0 if (strxindex=="-") then strsubstringum = qpiksubstri.ek { args = { strbigline, "-" } } -- count else varxxxindex = contabrxi [tonumber (strxindex)] if (type(varxxxindex)=="number") then strxxii = tostring (varxxxindex) strsubstringum = qpiksubstri.ek { args = { strbigline, strxxii } } -- pi else strsubstringum = "=" end--if end--if return strsubstringum end--function lfseizesubstring ------------------------------------------------------------------------ ---- MAIN EXPORTED FUNCTION ---- ------------------------------------------------------------------------ function komtbllin.ek (arxframent) -- general unknown type ie "var" local vartmp = 0 -- variable without type multipurpose -- special type "args" AKA "arx" local arxourown = 0 -- metaized "args" from our own "frame" (NOT caller's) -- general "tab" local tabstuff = {} -- double-letter indexes for "lfinsertultim" -- general "str" local strpara = "" -- incoming parameter with 5 digi, reported at the end local strtmp = "" -- temp, even for "searcheol" local strtpm = "" -- temp other local strsrcrw = "" -- complete row from the source table local strret = "" -- huge output string with the table local strbkn = "" -- HTML HEX color (6 digits) local strt3d = "" -- HTML "td" element concatenated from 3 parts local strtblcy = "" -- src y-index marker (this is NOT the column "c0") local strtblc0 = "" -- src column 0 (this is NOT the y-index marker) (obli) local strtblc1 = "" -- src column 1 (nice to have) Q-item local strtblc2 = "" -- src column 2 (nice to have) propralingve local strtblc33 = "" -- src column 2 soon 3 (nice to have) 1 digit local strtblc44 = "" -- src column 3 soon 4 (nice to have) 2 letters local strtblc4 = "" -- src column 4 soon 5 (nice to have) 3 letters local strtblc5 = "" local strtblc6 = "" local strtblc7 = "" -- src column 7 soon 8 local strtblc9 = "" -- src column 9 local strtblca = "" -- src column 10 local strdeste = "" -- destinat table element with both "td" HTML elements local strpurge = "" -- purge quasi-external link complete with "[" and "]" local strsumbl = "" -- technical summary block -- general "num" local numproba = 100 -- probability from arxourown[3] (komp YES sng NO) local numafstbfcl = 0 -- string length aftr stripping rl lr before clamping local numoct = 0 -- temp some char local numodt = 0 -- temp other char local numtamp = 0 -- temp local numtump = 0 -- temp local numlong = 0 -- temp for decimal conversion (length of parameter) local numinxlen = 0 -- length of previous y-index marker (2 or 3) local numfoulen = 0 -- length of latest found y-index marker (2 or 3) local numc6pedi = 0 -- ipedia code "0"..."2" ("3" for "-" and redish) local numc6tion = 0 -- tionary code "0"..."2" ("3" for "-" and redish) -- table positions "num" local numposirr = 0 local numposiss = 0 local numminwidth = 0 -- safe values 8...1/2 * "maxwidth" def 11 local nummaxwidth = 0 -- safe values 40...40'000 and lower is bettr def 216 local numiwo0 = 0 -- previous local numiwo1 = 0 -- previous local numiwo2 = 0 -- previous local numipos = 0 -- Octet position in "qconstrsr", ZERO-based local numiprev = 0 -- Octet position of previous line in "qconstrsr" -- bunched info about the input table "num" local numtbllen = 0 -- length of huge source table seized via "mw.loadData" local numrowinx = 0 -- row index becoming number of rows & langs at the end local numsorerr = 0 -- sorting errors (fatal but do not abort) local numerrtru = 0 -- valid truncated lines in source table (minor) local numerrtlo = 0 -- too long lines in source table local numerrkec = 0 -- minor error (not fatal) local numtblbeg = 0 -- size of extra area before the table, begin of table local numtblend = 0 -- begin of garbage area after the table local numtblper = 0 -- position of the earliest abort syntax error local numminwyd = 0 -- evaluated minimal width local nummaxwyd = 0 -- evaluated maximal width local nummaxnom = 0 -- evaluated maximal bloat of language name (c0 and c2) local nummaxkal = 0 -- evaluated maximal bloat of category link local numexpife = 0 -- number of maybe expensive queries "ifexist" local numexppik = 0 -- number of expensive queries "pagesincategory" -- missing "num" local numerrlng = 0 -- missing lng main cat (not fatal) local numerrkap = 0 -- missing kap (not fatal) local numerrvor = 0 -- missing vor (not fatal) local numerrapx = 0 -- missing apx appendix page (not fatal) local numerrind = 0 -- missing ind index page (not fatal) -- general "boo" local booerr = false -- fatal error flag local booearsyn = false -- early syntax err flag (out table NO summary NO) local boosinerr = false -- syntax error flag (abort after the row) local boomxwerr = false -- maxwidth error (checked bef&aft row, abort imm) local boosorerr = false -- sort error flag (do not abort) local boolocerr = false -- local error flag within a table element local boolokeer = false -- other local error flag within a table element local boogtabort = false -- brewed from 3 vari by OR, "numtblper" is valid local boodofatal = false -- brewed from 6 vari by OR, show fatal block local boohavtbl = false local bootimp = false -- temp local boorussia = false -- set up randomly for every row from "numproba" -- dissatisfaction "boo" local booc0bad = false -- true if len(c0) out of rang, even "-" NOT valid local booc1bad = false -- Q-item local booc2bad = false -- propralingve local booc3bad = false -- 2-litera -- true if bad local booc4bad = false -- 3-litera -- true if bad local booc5c6bad = false -- true if c5 or c6 is bad local booc7bad = false -- ipedia article -- true if bad -- from arxourown "boo" local boolngsow = false -- f arxourown[1] show lng in d07 local boolngexp = false -- f arxourown[1] expensive on lng in d07 local bookapsow = false -- f arxourown[1] show kap in d07 local bookapexp = false -- f arxourown[1] expensive on kap in d07 local boovorsow = false -- f arxourown[1] d08 local boovorexp = false -- f arxourown[1] d08 local booapxsow = false -- f arxourown[1] d09 local booapxexp = false -- f arxourown[1] d09 local booindsow = false -- f arxourown[1] d09 local booindexp = false -- f arxourown[1] d09 local bood07 = false local bood08 = false local bood09 = false local boosummar = false -- f arxourown[2] do show on success -- only for built-in function "optconcat" local isubtabbunch = {} -- bunch strings here -- only for built-in function "searchdblchr" local isubnumlim = 0 -- octets to check (2 * "number of iterations") local isubnumchr = 0 -- char to search (91 for "[[" or 40 for "((") local isubboodwn = false -- "true" for downward search local osubboofnd = false -- "true" if the dblchar was found -- only for built-in function "searcheol" local isubnumlio = 0 -- octets to check local isubbootmp = false -- "true" to fill "strtmp" with copied chars local osubnmline = 0 -- length of found line local osubboofnf = false -- "true" if EOL was found -- only for built-in function "cmp2or3charsbi" local osubboobiger = false -- "true" if fnd idx marker bigger than "numiwo" ---- BUILT-IN GOSUB-STYLE FUNCTION "OPTCONCAT" ---- -- PURPOSE: workaround poor memory management in LUA during string -- concatenations, add incoming string to "strret" -- IN : parameter "varincom" either string or type "nil" -- CHG : isubtabbunch (table), strret (string) -- NOTE: the thing needs to be initialized by <<local strret = "">> -- and <<local isubtabbunch = {}>> -- NOTE: if the "strret" string has to be changed directly (concatenation -- or replace), then "optconcat (nil)" or "isubtabbunch = {}" -- must be done before !!! local optconcat = function (varincom) if (type(varincom)=="string") then if (#isubtabbunch>20) then strret = strret .. table.concat (isubtabbunch) .. varincom isubtabbunch = {} else table.insert (isubtabbunch, varincom) -- ONE-based numbering end--if end--if if ((varincom==nil) and (#isubtabbunch>0)) then strret = strret .. table.concat (isubtabbunch) isubtabbunch = {} end--if end--function optconcat ---- BUILT-IN GOSUB-STYLE FUNCTION "SEARCHDBLCHR" ---- -- PURPOSE: searches for a dblchar (91 for "[[" or 40 for "((") -- upwards or downwards -- IN : isubnumlim, isubnumchr, isubboodwn (unchanged) -- OUT : osubboofnd (not in) -- USE : qconstrsr (acts as a constant in the module) -- CHG : numipos (in and out) -- NOTE: if "isubboodwn" is "false" then we run upwards and check the limit -- upwards, thus with incoming position "numipos"=10 we start checking -- at positions 11&(12,10), with incoming "isubnumlim"=10 we will no -- longer check positions 23&(24,22) but will check 21&(22,20) ... we -- need 3 chars margin at the top of range -- NOTE: if "isubboodwn" is "true" then we run downwards but check the limit -- by separately counting upwards, thus with incoming position -- "numipos"=10 we start checking at -- positions 11&(12,10), with incoming "isubnumlim"=10 we will no -- longer check positions -01&(00,-02) but will check 01&(02,00) ... we -- need 3 chars margin at the top of range but nothing at the bottom -- NOTE: we are supposed to safely ignore single occurrences (ie continue -- searching), as opposed to the fact that triple and longer -- occurrences are prohibited local searchdblchr = function () local usubnumsrch = 0 -- search position checker counting always up local usubnumok = 0 -- single char (giving a f**k about UTF8) local usubnumincr = 2 -- de facto constant "+2" or "-2" osubboofnd = true -- pre-assume that we will find our dblchr if (isubboodwn) then usubnumincr = -2 end--if while (true) do -- iterate through octets searching for dblchr (up or dwn) if (usubnumsrch>isubnumlim) then osubboofnd = false -- give up, table broken, "numipos" irrelevant now break end--if usubnumok = string.byte (qconstrsr,(numipos+2),(numipos+2)) -- "+1" actu if (usubnumok==isubnumchr) then usubnumok = string.byte (qconstrsr,(numipos+3),(numipos+3)) -- "+2" ab if (usubnumok==isubnumchr) then numipos = numipos + 1 break -- found and "numipos" valid ... otherwise try to look below end--if usubnumok = string.byte (qconstrsr,(numipos+1),(numipos+1)) -- "+0" bl if (usubnumok==isubnumchr) then break -- found and "numipos" valid ... otherwise continue search end--if end--if usubnumsrch = usubnumsrch + 2 -- always upwards numipos = numipos + usubnumincr -- "+2" or "-2" end--while end--function searchdblchr ---- BUILT-IN GOSUB-STYLE FUNCTION "SEARCHEOL" ---- -- PURPOSE: searches for EOL, only upwards, and maybe copies -- text into "strtmp" -- IN : (both unchanged) : isubnumlio (limit), isubbootmp (control copying) -- OUT : osubboofnf (not in) and osubnmline (not in) -- USE : qconstrsr (acts as a constant in the module) -- CHG : - numipos (in and out) -- - maybe strtmp (in and out) filled with copied text, we do -- not clear it on entry, the caller is responsible local searcheol = function () local usubnumsrcz = 0 -- search position checker local numoqqt = 0 -- single char (giving a f**k about UTF8) osubboofnf = true -- pre-assume that we will find our EOL while (true) do -- iterate through octets searching for EOL (only up) if (usubnumsrcz>=isubnumlio) then osubboofnf = false -- give up, table broken, "numipos" irrelevant now break end--if numoqqt = string.byte (qconstrsr,(numipos+1),(numipos+1)) -- "+0" actual if ((numoqqt<32) and (numoqqt~=9)) then break -- found and "numipos" valid ... otherwise continue search end--if if (isubbootmp == true) then strtmp = strtmp .. string.char (numoqqt) end--if usubnumsrcz = usubnumsrcz + 1 numipos = numipos + 1 end--while if (osubboofnf) then osubnmline = usubnumsrcz end--if end--function searcheol ---- BUILT-IN GOSUB-STYLE FUNCTION "CMP2OR3CHARSBI" ---- -- PURPOSE: performs a comparison of 2 or 3 char:s testing for "bigger" -- IN : numipos, numinxlen, numfoulen, numiwo0...numiwo2 -- OUT : osubboobiger ("true" if found index marker is bigger than "numiwo") -- USE : qconstrsr (acts as a constant in the module) -- CHG : N/A -- NOTE: it is the caller's responsibility to ensure -- that "numinxlen" and "numfoulen" are 2 or 3 !!! -- NOTE: it is the caller's responsibility to ensure -- that we don't hit the limit here in -- NOTE: the 2 strings are expected not to be equal on entry here, -- but single letters may be, thus ("grc" and "grc") is impossible, -- but ("grc" and "gro") or ("grc" and "gr") can occur, actually, -- the code here itself tests for "bigger" vs "smaller or equal" local cmp2or3charsbi = function () local usubnum1char = 0 -- single char osubboobiger = false -- pre-assume smaller or equal, likely abort soon usubnum1char = (string.byte (qconstrsr,numipos+3,numipos+3)) if (usubnum1char>numiwo0) then osubboobiger = true -- bigger else if (usubnum1char==numiwo0) then usubnum1char = (string.byte (qconstrsr,numipos+4,numipos+4)) if (usubnum1char>numiwo1) then osubboobiger = true -- bigger else if ((usubnum1char==numiwo1) and ((numinxlen+numfoulen)>4)) then if (numfoulen>numinxlen) then osubboobiger = true -- (3:2 - found:previous) and bigger else if (numfoulen==3) then usubnum1char = (string.byte (qconstrsr,numipos+5,numipos+5)) else usubnum1char = 0 end--if if (usubnum1char > numiwo2) then osubboobiger = true -- bigger end--if end--if end--if end--if (usubnum1char>numiwo1) else end--if end--if end--function cmp2or3charsbi ---- GUARD AGAINST INTERNAL ERROR AGAIN ---- booerr = false if (qbooguard) then booerr = true -- sort of #E01 internal end--if ---- CHECK THE HUGE SOURCE TABLE ---- -- we do NOT have "nummaxwidth" yet so we check against 2 times the minimum -- of 22 ie against 44 and 1'000'000 bootimp = false if (type(qconstrsr)=="string") then -- important check numtbllen = string.len(qconstrsr) if ((numtbllen>=44) and (numtbllen<=1000000)) then bootimp = true end--if end--if if (bootimp==false) then booerr = true -- no valid source table end--if ---- SEIZE 1 ... 3 PARAMETERS ---- -- obligatory 5 digits about 5 items in 3 columns into 13 -- boolean:s (all preassigned to "false") -- optional 1 digit into 1 bool (default "false") -- optional 2 digits into 1 num (default 100 ie 100% ie 1) (komp YES sng NO) arxourown = arxframent.args -- "args" from our own "frame" if ((arxourown[1]==nil) or (arxourown[4])) then booerr = true -- need one obligatory param, four are not appreciated end--if if (booerr==false) then strpara = arxourown[1] -- 5 digits: lng kap vor apx ind numlong = string.len(strpara) if (numlong==5) then numoct = string.byte (strpara,1,1) numoct = lfdec1diglm (numoct,2) -- 255 if invalid booerr = booerr or (numoct==255) -- invalid input boolngsow = (numoct~=0) -- show lng boolngexp = (numoct==2) -- expensive lng numoct = string.byte (strpara,2,2) numoct = lfdec1diglm (numoct,2) -- 255 if invalid booerr = booerr or (numoct==255) -- invalid input bookapsow = (numoct~=0) -- show kap bookapexp = (numoct==2) -- expensive kap numoct = string.byte (strpara,3,3) numoct = lfdec1diglm (numoct,2) -- 255 if invalid booerr = booerr or (numoct==255) -- invalid input boovorsow = (numoct~=0) -- show vor alone in d08 boovorexp = (numoct==2) -- expensive vor alone in d08 numoct = string.byte (strpara,4,4) -- "apx" numoct = lfdec1diglm (numoct,2) -- 255 if invalid booerr = booerr or (numoct==255) -- invalid input booapxsow = (numoct~=0) -- show apx booapxexp = (numoct==2) -- expensive apx numoct = string.byte (strpara,5,5) -- "ind" numoct = lfdec1diglm (numoct,2) -- 255 if invalid booerr = booerr or (numoct==255) -- invalid input booindsow = (numoct~=0) -- show ind booindexp = (numoct==2) -- expensive ind bood07 = boolngsow or bookapsow bood08 = boovorsow bood09 = booapxsow or booindsow else booerr = true -- invalid input end--if (numlong==5) else end--if if ((booerr==false) and (arxourown[2]~=nil)) then -- optional param strtamp = arxourown[2] -- one binary digit expected "0" or "1" numlong = string.len(strtamp) if (numlong==1) then numoct = string.byte (strtamp,1,1) -- "boosummar" preassigned to false numoct = lfdec1diglm (numoct,1) -- 255 if invalid if (numoct==255) then booerr = true -- invalid input end--if if (numoct==1) then boosummar = true -- show technical summary block end--if else booerr = true -- invalid input end--if (numlong==1) else end--if if (booerr==false) then vartmp = arxourown[3] -- 2 decimal digits "02"..."98" expected if (type(vartmp)=="string") then bootimp = false if (string.len(vartmp)==2) then numoct = string.byte (vartmp,1,1) numodt = string.byte (vartmp,2,2) numoct = lfdec1digit (numoct) -- 255 if invalid numodt = lfdec1digit (numodt) -- 255 if invalid numproba = numoct * 10 + numodt -- was preassigned to default value 100 if ((numproba>=2) and (numproba<=98)) then bootimp = true -- valid value end--if end--if if (bootimp==false) then booerr = true -- param specified but invalid end--if end--if end--if ---- TRANSCODE EO IF NEEDED ---- if (constrpriv=="eo") then constrlnkpu = lfkodeosg(constrlnkpu) -- "Klaku cxi tie (kaj" ... contabd09d10 = lfkodeotb(contabd09d10) -- 1,2 -- "fermita aux malplena" contabdestit = lfkodeotb(contabdestit) -- 0...13 -- table headings contabbigtiny = lfkodeotb(contabbigtiny) -- 0...4 -- for big & tiny block end--if ---- SEIZE THE PAGENAME (NEEDED FOR PURGE LINK) AND BREW THE PURGE LINK ---- -- here we do NOT use the usual function "lfbrewurl" due to -- insurmountable differences in the link form -- we need "constrlnkpu" with complete sentence strtpm = "Special:Recent changes" -- bad default vartmp = mw.title.getCurrentTitle().prefixedText -- with namespace prefix !! if (type(vartmp)=="string") then if (string.len(vartmp)~=0) then strtpm = vartmp -- pagename here (otherwise "Special:Recent changes") end--if end--if strtpm = lfspacundr(strtpm,true) -- replace space by underscore in URL strtmp = 'http://' .. constrpriv .. '.wiktionary.org/wiki/' .. strtpm .. '?action=purge' strpurge = '[' .. strtmp .. ' ' .. constrlnkpu .. ']' -- complete sentence ---- SEARCH FOR TABLE BEGIN AKA THE 0TH Y-INDEX MARKER AND MINW MAXW ---- -- * start at position ZERO -- * check char after char -- * if end of table block or 80'000 octet:s reached then -- abort search (S-position is still "invalid", bad) -- * if string "[[" found then assign S-position to index and abort -- search (good so far) -- * if S-position is "valid" then -- * restart at position ZERO -- * check char after char -- * if (S-position - 21) reached then abort (good so far) -- * if string "minw=" found at earliest hit assign R-position to -- index, at further hit assign R-position to "invalid" -- and abort (bad) -- * if we do not have both R-position and S-position then give up -- * if ( ("R-position") + 22 > "S-position") then give up -- * check and evaluate the line found at R-position, if good then assign -- "minwidth" and "maxwidth", otherwise give up -- * if ("S-position" > "maxwidth") then give up -- * done: table content area begins at "S-position", "minwidth" and -- "maxwidth" are assigned (garbage area following the last table -- line must be evaluated separately) -- "minw=00010 maxw=00200" the length is 21 char:s plus EOL -- note that table size "numtbllen" guaranteed from above is at least 44 -- but the table may contain much padding and shrink considerably -- after padding is trimmed off or disregarded if (booerr==false) then numtblper = 0 -- risk of "booearsyn" error here, preventively assign posit numposirr = -1 numposiss = -1 numipos = 0 -- ZERO-based position in "qconstrsr" isubnumlim = 80000 -- 80K per spec if (isubnumlim>(numtbllen-3)) then -- margin of 3 char:s needed isubnumlim = numtbllen-3 -- cannot underflow end--if isubnumchr = 91 -- look for "[[" isubboodwn = false -- upwards searchdblchr () -- OUT: osubboofnd | USE: qconstrsr | CHG: numipos if (osubboofnd) then numtblbeg = numipos -- else ZERO numposiss = numipos -- else "-1" invalid end--if end--if if ((booerr==false) and (numposiss~=-1)) then numipos = 0 -- ZERO-based position in "qconstrsr" while (true) do if ((numipos+21)>=numposiss) then break end--if numoct = string.byte (qconstrsr,(numipos+1),(numipos+1)) if (numoct==109) then -- ASCII lowercase "m" strtpm = string.sub (qconstrsr,(numipos+2),(numipos+5)) if (strtpm=="inw=") then if (numposirr==-1) then numposirr = numipos -- good hit else numposirr = -1 -- more hits prohibited per spec break end--if end--if (strtpm=="inw=") then end--if numipos = numipos + 1 end--while end--if if (booerr==false) then while (true) do -- fake loop if ((numposirr==-1) or (numposiss==-1)) then booearsyn = true -- give up, line is not found break -- to join mark end--if if ((numposirr+22) > numposiss) then booearsyn = true -- give up, line is not valid break -- to join mark end--if strtpm = string.sub (qconstrsr,(numposirr+1),(numposirr+22)) -- 22 cha numoct = string.byte (strtpm,22,22) -- need EOL if (numoct~=10) then booearsyn = true -- give up, line is not valid break -- to join mark end--if strtmp = string.sub (strtpm,11,16) if (strtmp~=" maxw=") then booearsyn = true -- give up, line is not valid break -- to join mark end--if strtmp = string.sub (strtpm,6,10) if (lfcountndg(strtmp,0)~=0) then -- valid number ? booearsyn = true -- give up, number is not valid break -- to join mark end--if numminwidth = tonumber(strtmp) strtmp = string.sub (strtpm,17,21) if (lfcountndg(strtmp,0)~=0) then -- valid number ? booearsyn = true -- give up, number is not valid break -- to join mark end--if nummaxwidth = tonumber(strtmp) if ((numposiss>nummaxwidth) or (numminwidth<8) or ((numminwidth*2)>nummaxwidth) or (nummaxwidth<40) or (nummaxwidth>40000)) then booearsyn = true -- give up, number is not valid break -- to join mark end--if break -- finally to join mark end--while -- fake loop -- join mark end--if -- now ZERO-based "numtblbeg" maybe points to the found "[[" -- we will not touch "numtblbeg" since here but will update "numipos" ---- SEARCH FOR THE LAST Y-INDEX MARKER ---- -- will succeed if we find "[[" within "maxwidth" -- if we have only one line then found last index marker will -- be the same as the found 0th index marker if ((booerr==false) and (booearsyn==false)) then numtblper = numtbllen -- risk of "booearsyn" error here, preventively set numipos = numtbllen - numminwidth -- ZERO-based positi in "qconstrsr" isubnumlim = 2 * nummaxwidth - numminwidth -- allow full "maxwidth" of grb isubnumchr = 91 -- "[" isubboodwn = true -- downwards searchdblchr () ; -- OUT: osubboofnd | USE: qconstrsr | CHG: numipos if (osubboofnd==false) then booearsyn = true ; -- give up, table is broken, "numipos" irrelevant now end--if end--if -- now ZERO-based "numipos" maybe points to the found "[[" ---- SEARCH FOR END OF THE LAST Y-INDEX MARKER ---- -- the last line too long is an error -- missing EOL in the last line is an error if ((booerr==false) and (booearsyn==false)) then numtblper = numipos -- risk of "booearsyn" error here, preventively set isubnumlio = numtbllen - numipos -- NOT "+1" do NOT chk Octet above table if (isubnumlio>nummaxwidth) then isubnumlio = nummaxwidth end--if isubbootmp = false -- do not copy searcheol () ; -- OUT: osubboofnf | USE: qconstrsr | CHG: numipos only if (osubboofnf==false) then booearsyn = true ; -- give up end--if end--if numtblend = numipos -- now ZERO-based "numipos" and "numtblend" maybe point -- to the found EOL after last line ---- CHECK THE 0TH Y-INDEX MARKER ---- -- "[[" is already assured numipos = numtblbeg -- points to "[[" if ((booerr==false) and (booearsyn==false)) then numtblper = numipos -- risk of "booearsyn" error here, preventively set if ((numipos+6)>=numtbllen) then booearsyn = true end--if if (booearsyn==false) then numoct = string.byte (qconstrsr,(numipos+3),(numipos+3)) -- "e" or "i" if (numoct~=string.byte(constrpriv,1,1)) then booearsyn = true end--if numoct = string.byte (qconstrsr,(numipos+4),(numipos+4)) -- "o" or "d" if (numoct~=string.byte(constrpriv,2,2)) then booearsyn = true end--if numoct = string.byte (qconstrsr,(numipos+5),(numipos+5)) -- "]" if (numoct~=93) then booearsyn = true end--if numoct = string.byte (qconstrsr,(numipos+6),(numipos+6)) -- "]" if (numoct~=93) then booearsyn = true end--if numoct = string.byte (qconstrsr,(numipos+7),(numipos+7)) -- space if (numoct~=32) then booearsyn = true end--if end--if if (booearsyn==false) then strtblcy = constrpriv -- "eo" or "id" numfoulen = 2 -- string length of "eo" or "id" boosorerr = false -- sort error flag numminwyd = nummaxwidth nummaxwyd = 0 nummaxnom = 0 -- evaluated maximal bloat of language name nummaxkal = 0 -- evaluated maximal bloat of category link end--if end--if ((booerr==false) and (booearsyn==false)) then -- now ZERO-based "numipos "and "numtblbeg" maybe point to the found -- languange code ie "[[eo]]" or "[[id]]" ---- BEGIN TO GENERATE THE OUTPUT TABLE (14 COLUMNS) ---- -- using "constrtdbgtit" and "constrtden" for "<td"...">" and "</td>" -- here we start using "optconcat", the thing has been initialized -- by <<"local strret = "">> and <<local isubtabbunch = {}>> -- using function "lfbrewtitsel" som does NOT add "<td"...">" "</td>" if ((booerr==false) and (booearsyn==false)) then boohavtbl = true optconcat (constrhutabegin) -- "<table"... and "<tr>" do -- scope local numtaamp = 0 -- ZERO-based local booxxtop = false local booxxbtm = false local bootiimp = false while (true) do -- iterate over table columns if (numtaamp==14) then -- valid indexes 0...13 break end--if booxxtop = true booxxbtm = true booshowthiscol = true -- hide column if false if (numtaamp==7) then booshowthiscol = bood07 -- column "d07" "lng" "kap" can be hidden booxxtop = boolngsow booxxbtm = bookapsow end--if if (numtaamp==8) then booshowthiscol = bood08 -- column "d08" "vor" can be hidden end--if if (numtaamp==9) then booshowthiscol = bood09 -- column "d09" "apx" "ind" can be hidden booxxtop = booapxsow booxxbtm = booindsow end--if if (booshowthiscol) then optconcat (constrtdbgtit .. lfbrewtitsel (numtaamp,booxxtop,booxxbtm) .. constrtden) -- submit table cell end--if numtaamp = numtaamp + 1 -- count even hidden columns end--while optconcat ('</tr>') -- close line but keep table open end--do scope end--if ---- MAIN LOOP ---- -- at entry without error ((booerr==false) and (booearsyn==false)), -- we have from above: -- * "numipos" equal "numtblbeg" -- * "[[eo]]" or "[[id]]" assured & "strtblcy" filled with -- 2 char:s and "numfoulen" set to 2 -- * "boosorerr" set to false -- at reiteration, we have from below: -- * "numipos" already bumped -- * y-index marker assured & "strtblcy" filled with -- 2 or 3 char:s and "numfoulen" set to 2 or 3 -- * "boosorerr" set accordingly and possible inicident already counted -- in any case, we have: -- * "numipos" pointing to the "[[" and "numfoulen" set accordingly -- so we have to set "numiprev", jump over the y-index marker and pick -- a line from the table -- * both "boomxwerr" and "boosinerr" false if ((booerr==false) and (booearsyn==false)) then while (true) do -- iterate over all table rows numiprev = numipos -- backup for check far below numtamp = math.random(1,100) -- playing Russian roulette with LUA boorussia = (numtamp<=numproba) -- limit can be 2...98 or 100 optconcat ('<tr>') numipos = numipos + 5 + numfoulen -- jump over "[[" code "]]" space numtblper = numipos -- risk of "boomxwerr" or "boosinerr" here, preventi isubnumlio = numtblend - numipos + 1 -- here DO "+1" iot include EOL !! if (isubnumlio>nummaxwidth) then isubnumlio = nummaxwidth -- do NOT subtract here end--if isubbootmp = true -- do copy into "strtmp" strtmp = "" -- "searcheol" will fill it, start with empty searcheol () -- OUT: osubboofnf | CHG: numipos, osubnmline, strtmp if (osubboofnf==false) then boomxwerr = true -- EOL NOT found, NOT exit loop until table row fini else strsrcrw = strtmp -- complete row from the source table (without "cy") end--if -- begin "d00" -- index number and lng code strbkn = constrbkco -- color code without "#" cross if (strtblcy=="eo") then strbkn = '90FF90' -- green decoration end--if strdeste = '(' .. tostring (numrowinx) .. ') <b>' .. strtblcy .. '</b>' if (boosorerr) then -- reported only here but already counted below strdeste = strdeste .. '<br>' .. lfbrewerrsv(4,1) -- sort err (#E04 lagom) end--if if (boomxwerr==false) then numtamp = 0 strtmp = lfseizesubstring (strsrcrw,"-") -- count substrings if (string.len(strtmp)==2) then numtamp = tonumber(strtmp) end--if if (numtamp==0) then boosinerr = true -- this criminal, abort table generation after row else if (numtamp<10) then strbkn = 'FFD8D8' -- redish strdeste = strdeste .. '<br>' .. lfbrewerrsv(2,0) -- err (#E02 mini) numerrtru = numerrtru + 1 -- this is NOT fatal (not "kec" either) end--if if (numtamp>10) then strbkn = 'FFB0B0' -- red -- error overrides decoration strdeste = strdeste .. '<br>' .. lfbrewerrsv(3,1) -- err (#E03 lagom) numerrtlo = numerrtlo + 1 -- this is NOT fatal (but lagom) end--if if (numtamp~=10) then strdeste = strdeste .. ' (' .. tostring(numtamp) .. ')' end--if end--if (numtamp==0) else end--if if (boomxwerr or boosinerr or boosorerr) then strbkn = 'FFB0B0' -- red -- error overrides decoration end--if strt3d = constrtddf .. strbkn .. constrtdfd -- long "td" eleme with color optconcat (strt3d .. strdeste .. constrtden) -- dn dest column 0 if ((boomxwerr==false) and (boosinerr==false)) then -- begin "c0" -- lingvonomo in site language -- no rl-enclos possible strtblc0 = lfseizesubstring (strsrcrw,"0") strtblc0 = lfpreproeqmi (strtblc0) -- "=" -> "-" booc0bad = (not lfvalidatestr(strtblc0,nil,2,connummaxc0c2nlen,0,0)) numafstbfcl = string.len (strtblc0) -- no stripping here len befor cli strtblc0 = lfclamp(strtblc0,(connummaxc0c2nlen+4)) -- even "-" is bad if (numafstbfcl>nummaxnom) then nummaxnom = numafstbfcl -- new record establishd "connummaxc0c2nlen" end--if -- done "c0" tabstuff["LN"] = strtblc0 -- for "lfinsertultim" tabstuff["LU"] = lfxcaseult(strtblc0,true,false) -- lng name uppercase -- begin "d01" -- lemma page strbkn = constrbkco -- color code without "#" cross if (booc0bad) then strbkn = 'FFB0B0' -- red strdeste = lfevilitem(1,0,strtblc0) -- show the evil -- bad lng name boosinerr = true -- this criminal, abort table generation after row else strtpm = lfinsertultim(contabpages[0],tabstuff) -- augment and maybe uc strdeste = '[[' .. strtpm .. '|' .. strtblc0 .. ']]' -- wl to lem pg end--if strt3d = constrtddf .. strbkn .. constrtdfd -- long "td" eleme optconcat (strt3d .. strdeste .. constrtden) -- done "d01" -- begin "c1" -- Q-item -- no rl-enclos possible strtblc1 = lfseizesubstring (strsrcrw,"1") strtblc1 = lfpreproeqmi (strtblc1) -- "=" -> "-" strtblc1 = lfclamp(strtblc1,14) booc1bad = false numtamp = string.len(strtblc1) -- length after clamping -- done "c1" -- begin "d02" -- Q-item strbkn = constrbkco -- color code without "#" cross if (booc1bad) then strbkn = 'FFB0B0' -- red strdeste = lfevilitem(1,1,strtblc1) -- show the evil boosinerr = true -- this criminal, abort table generation after row else strdeste = strtblc1 if (strtblc1=="-") then -- nice to have, do not abort strbkn = 'FFD8D8' -- redish if not available numerrkec = numerrkec + 1 end--if end--if strt3d = constrtddf .. strbkn .. constrtdfd -- long "td" eleme optconcat (strt3d .. strdeste .. constrtden) -- done "d02" -- begin "c2" -- propralingve -- rl-enclos possible strtblc2 = lfseizesubstring (strsrcrw,"2") strtblc2 = lfpreproeqmi (strtblc2) -- "=" -> "-" strtblc2 = lfrlstrip(strtblc2) booc2bad = (not lfvalidatestr(strtblc2,"-",2,connummaxc0c2nlen,0,0)) numafstbfcl = string.len (strtblc2) -- no stripping here len befor cli strtblc2 = lfclamp(strtblc2,(connummaxc0c2nlen+4)) if (numafstbfcl>nummaxnom) then nummaxnom = numafstbfcl -- new record establishd "connummaxc0c2nlen" end--if -- done "c2" -- begin "d03" -- propralingve strbkn = constrbkco -- color code without "#" cross if (booc2bad) then strbkn = 'FFB0B0' -- red strdeste = lfevilitem(1,1,strtblc2) -- show the evil -- bad lng name boosinerr = true -- this criminal, abort table generation after row else strdeste = strtblc2 if (strtblc2=="-") then -- nice to have, do not abort strbkn = 'FFD8D8' -- redish if not available numerrkec = numerrkec + 1 end--if end--if strt3d = constrtddf .. strbkn .. constrtdfd -- long "td" eleme optconcat (strt3d .. strdeste .. constrtden) -- done "d03" -- begin "c3" -- constructed and antique status strtblc33 = lfseizesubstring (strsrcrw,"3") strtblc33 = lfpreproeqmi (strtblc33) -- "="->"-" but no rl-enclos possib strtblc33 = lfclamp(strtblc33,10) -- constructed and antique status numtamp = string.len(strtblc33) -- length after clamping -- done "c3" -- begin "d04" -- constructed and antique status strbkn = constrbkco -- color code without "#" cross boolocerr = false if (strtblc33=="-") then -- nice to have, do not abort strbkn = 'FFD8D8' -- redish strdeste = "-" numerrkec = numerrkec + 1 else if (numtamp~=1) then -- length after clamping boolocerr = true else numoct = string.byte (strtblc33,1,1) -- must be "0" ... "3" if ((numoct<48) or (numoct>51)) then boolocerr = true -- this will become "boosinerr = true" else if (numoct==49) then strbkn = 'D0FFD8' -- greenish end--if if (numoct==50) then strbkn = 'A0FFC0' -- more greenish (but not green) end--if if (numoct==51) then strbkn = 'D0D0D0' -- grey end--if strdeste = contabd03[numoct-47] -- "contabd03" is ONE-based strdeste = strdeste .. ' (' .. string.char(numoct) .. ')' end--if end--if (numtamp~=1) else end--if (strtblc33=="-") else if (boolocerr) then strbkn = 'FFB0B0' -- red -- error overrides decoration strdeste = lfevilitem(0,2,strtblc33) -- show the evil -- "bad code" boosinerr = true -- this criminal, abort table generation after row end--if strt3d = constrtddf .. strbkn .. constrtdfd -- long "td" eleme optconcat (strt3d .. strdeste .. constrtden) -- done "d04" -- begin "c4" -- 2-letter code -- no rl-enclos possible strtblc44 = lfseizesubstring (strsrcrw,"4") strtblc44 = lfpreproeqmi (strtblc44) -- "=" -> "-" strtblc44 = lfclamp(strtblc44,10) -- 2-letter code or "--" expected if (strtblc44=="--") then booc3bad = false -- 2 valid alternative values "-" and "--" exist else booc3bad = (not lfvalidatestr(strtblc44,"-",2,2,2,3)) end--if -- done "c4" -- begin "d05" -- 2-letter code strbkn = constrbkco -- color code without "#" cross if (booc3bad) then strbkn = 'FFB0B0' -- red strdeste = lfevilitem(0,3,strtblc44) -- show the evil -- "bad code" boosinerr = true -- this criminal, abort table generation after row else strdeste = strtblc44 if (strtblc44=="-") then -- nice to have strbkn = 'FFD8D8' -- redish if no ISO 639-1:2002 code numerrkec = numerrkec + 1 end--if end--if strt3d = constrtddf .. strbkn .. constrtdfd -- long "td" eleme optconcat (strt3d .. strdeste .. constrtden) -- done "d05" strtblc4 = lfseizesubstring (strsrcrw,"5") -- bg src "c5" strtblc4 = lfpreproeqmi (strtblc4) -- "="->"-" but no rl-enclos possib strtblc4 = lfclamp(strtblc4,10) -- 3-letter code or "---" expected if (strtblc4=="---") then booc4bad = false -- 2 valid alternative values "-" and "---" exist else booc4bad = (not lfvalidatestr(strtblc4,"-",3,3,2,3)) end--if -- nice to have -- done "c5" strbkn = constrbkco -- color code without "#" cross -- bg dest "d06" if (booc4bad) then strbkn = 'FFB0B0' -- red strdeste = lfevilitem(0,4,strtblc4) -- show the evil -- "bad code" boosinerr = true -- this criminal, abort table generation after row else strdeste = strtblc4 if (strtblc4=="-") then -- nice to have strbkn = 'FFD8D8' -- redish if no ISO 639-3:2007 code numerrkec = numerrkec + 1 end--if end--if strt3d = constrtddf .. strbkn .. constrtdfd -- long "td" eleme optconcat (strt3d .. strdeste .. constrtden) -- done "d06" -- begin "d07" -- "lng" + "kap" (!!! can be hidden !!!) if (bood07) then strbkn = constrbkco -- color code without "#" cross if (booc0bad) then strbkn = 'FFB0B0' -- red strdeste = "??" -- kat with words (we have already seen bad "c0") else strdeste = '' -- crucial if (boolngsow) then strtmp = lfinsertultim(contabpages[5],tabstuff) -- augment and maybe uc strdeste = lfkattlaenk (strtmp) end--(boolngsow) then if (boolngsow and bookapsow) then strdeste = strdeste .. '<br>' end--if if (bookapsow) then strtmp = lfinsertultim(contabpages[3],tabstuff) -- augment and maybe uc strdeste = strdeste .. lfkattlaenk (strtmp) if (bookapexp and boorussia) then bootimp,strtpm = lfquer2kat (arxframent,strtmp) strdeste = strdeste .. strtpm -- add 1 or 2 further lines numexpife = numexpife + 1 -- count expensive calls numexppik = numexppik + 1 -- count expensive calls if (bootimp) then strbkn = 'FFD8D8' -- redish if "kap" kat does not exist numerrkap = numerrkap + 1 end--if end--if (bookapexp and boorussia) then end--if (bookapsow) then end--if strt3d = constrtddf .. strbkn .. constrtdfd -- long "td" eleme optconcat (strt3d .. strdeste .. constrtden) -- done "d06" end--if (bood07) then -- done "d07" -- begin "d08" -- "vor" (!!! can be hidden !!!) if (bood08) then strbkn = constrbkco -- color code without "#" cross if (booc0bad) then strbkn = 'FFB0B0' -- red strdeste = "??" -- kat with dictiona (we have already seen bad c0) else strtmp = lfinsertultim(contabpages[4],tabstuff) -- augment and maybe uc strdeste = lfkattlaenk (strtmp) if (boovorexp and boorussia) then bootimp,strtpm = lfquer2kat (arxframent,strtmp) strdeste = strdeste .. strtpm -- add 1 or 2 further lines numexpife = numexpife + 1 -- count expensive calls numexppik = numexppik + 1 -- count expensive calls if (bootimp) then strbkn = 'FFD8D8' -- redish if "vor" kat does not exist numerrvor = numerrvor + 1 end--if end--if (boovorexp and boorussia) then end--if strt3d = constrtddf .. strbkn .. constrtdfd -- long "td" eleme optconcat (strt3d .. strdeste .. constrtden) -- dn dest column 7 end--if (bood08) then -- done "d08" -- begin "d09" -- Appendix + Index (!!! can be hidden !!!) if (bood09) then strbkn = constrbkco -- color code without "#" cross if (booc0bad) then strbkn = 'FFB0B0' -- red strdeste = "??" -- index page (we have already seen bad c0) boosinerr = true -- this criminal, abort table generation aftr row else strdeste = '' -- crucial if (booapxsow) then strtmp = lfinsertultim(contabpages[1],tabstuff) -- augme and maybe uc strtmp = constrapxp .. strtmp -- add the "Appendix:" prefix strdeste = '[[' .. strtmp .. ']]' -- wikili end--if if (booapxsow and booindsow) then strdeste = strdeste .. '<br>' end--if if (booindsow) then strtmp = lfinsertultim(contabpages[2],tabstuff) -- augment and maybe uc strtmp = constrindp .. strtmp -- add the "Index:" prefix strdeste = strdeste .. '[[' .. strtmp .. ']]' -- brew the wikilink if (booindexp and boorussia) then numexpife = numexpife + 1 -- count expensive calls if (lfifexist(arxframent,strtmp)==false) then strbkn = 'FFD8D8' -- redish if index page does not exist strdeste = strdeste .. '<br>(' .. contabmisc[1] .. ')' numerrind = numerrind + 1 end--if end--if (booindexp and boorussia) then end--if (booindsow) then end--if strt3d = constrtddf .. strbkn .. constrtdfd -- long "td" eleme optconcat (strt3d .. strdeste .. constrtden) end--if (bood09) then -- done "d09" booc5c6bad = false -- common for "c5" and "c6" strtblc5 = lfseizesubstring (strsrcrw,"6") -- bg src "c6" strtblc5 = lfpreproeqmi (strtblc5) -- "="->"-" but no rl-enclos possib strtblc5 = lfclamp(strtblc5,16) -- wiki access code numtamp = string.len(strtblc5) -- length after clamping if (strtblc5~="-") then -- nice to have numoct = string.byte(strtblc5,1,1) -- wiki access code if ((numtamp<2) or (numtamp>10) or (lftestlc(numoct)==false)) then booc5c6bad = true -- this will become "boosinerr = true" end--if else strtblc5 = strtblcy -- copy access code end--if -- done "c6" strtblc6 = lfseizesubstring (strsrcrw,"7") -- bg src "c7" strtblc6 = lfpreproeqmi (strtblc6) -- "="->"-" but no rl-enclos possib strtblc6 = lfclamp(strtblc6,10) -- availability 2 digits numtamp = string.len(strtblc6) -- length after clamping numc6pedi = 3 numc6tion = 3 if (strtblc6~="-") then -- nice to have (otherwise redish !!!) if (numtamp==2) then numc6pedi = string.byte(strtblc6,1,1) -- availability code numc6tion = string.byte(strtblc6,2,2) -- availability code numc6pedi = lfdec1diglm (numc6pedi,2) -- 0...2 or 255 if invalid numc6tion = lfdec1diglm (numc6tion,2) -- 0...2 or 255 if invalid if ((numc6pedi==255) or (numc6tion==255)) then booc5c6bad = true -- this will become "boosinerr = true" end--if else booc5c6bad = true -- this will become "boosinerr = true" end--if end--if -- done "c7" strbkn = constrbkco -- color code without "#" cross -- bg dest "d10" if (booc5c6bad) then strbkn = 'FFB0B0' -- red -- error overrides decoration strdeste = lfevilitem(0,56,strtblc5) -- show the evil -- "bad code" boosinerr = true -- this criminal, abort table generation after row else strdeste = lfbrewurl (strtblc5,false,nil) -- other ipedia main page if (numc6pedi==3) then strbkn = 'FFD8D8' -- redish if "c6" was empty or "-" else strbkn = lfavailco(numc6pedi) strdeste = strdeste .. lfavailnt(numc6pedi) -- <br>+notice or empty end--if end--if strt3d = constrtddf .. strbkn .. constrtdfd -- long "td" eleme optconcat (strt3d .. strdeste .. constrtden) -- dn dest "d10" strbkn = constrbkco -- color code without "#" cross -- bg dest "d10" if (booc5c6bad) then strbkn = 'FFB0B0' -- red -- error overrides decoration strdeste = lfevilitem(0,56,strtblc6) -- show the evil -- "bad code" boosinerr = true -- this criminal, abort table generation after row else if (strtblcy==constrpriv) then strdeste = ':-)' -- only for "d11" cell "other tionary" and "d13" else strdeste = lfbrewurl (strtblc5,true,nil) -- other tionary main page if (numc6tion==3) then strbkn = 'FFD8D8' -- redish if "c6" was empty or "-" else strbkn = lfavailco(numc6tion) strdeste = strdeste .. lfavailnt(numc6tion) -- <br>+notice or empt end--if end--if end--if strt3d = constrtddf .. strbkn .. constrtdfd -- long "td" eleme optconcat (strt3d .. strdeste .. constrtden) -- done "d10" strtblc7 = lfseizesubstring (strsrcrw,"8") -- begin "c8" strtblc7 = lfpreproeqmi (strtblc7) -- "="->"-" but no rl-enclos possib booc7bad = (not lfvalidatestr(strtblc7,"-",2,32,0,0)) strtblc7 = lfclamp(strtblc7,36) -- name of ipedia article -- done "c8" strbkn = constrbkco -- color code without "#" cross -- bg dest "d11" if (booc7bad) then -- "c7" is bad strbkn = 'FFB0B0' -- red strdeste = lfevilitem(2,7,strtblc7) -- show the evil -- "bad title" boosinerr = true -- this criminal, abort table generation after row else if ((strtblc7=="-") and booc0bad) then -- nice to have "c7" strbkn = 'FFB0B0' -- red if we have neither "c0" nor "c7" strdeste = '-' boosinerr = true -- this criminal, abort table generation aftr row else strtmp = strtblc7 -- name of wp article, BEWARE: may contain space bootimp = false if (strtmp=="-") then bootimp = true -- this is semi-evil, we have to guess strtmp = lfinsertultim(contabpages[6],tabstuff) -- augment and maybe uc end--if strdeste = lfbrewurl (constrpriv,false,strtmp) -- own ipedia article if (bootimp) then strbkn = 'FFD8D8' -- redish if we had to guess strdeste = strdeste .. ' (??)' numerrkec = numerrkec + 1 end--if end--if end--if strt3d = constrtddf .. strbkn .. constrtdfd -- long "td" eleme optconcat (strt3d .. strdeste .. constrtden) -- done "d11" strtblc9 = lfseizesubstring (strsrcrw,"9") -- bg src "c9" strtblc9 = lfpreproeqmi (strtblc9) -- "="->"-" and rl-enclos possible strtblc9 = lfrlstrip(strtblc9) -- category link numafstbfcl = string.len(strtblc9) -- length after strip before clamp if (numafstbfcl>nummaxkal) then nummaxkal = numafstbfcl -- new record establishd "connummaxc8catlen" end--if strtblc9 = lfclamp(strtblc9,(connummaxc8catlen+4)) -- cat link strtblca = lfseizesubstring (strsrcrw, "10") -- bg src "c10" strtblca = lfpreproeqmi (strtblca) -- "="->"-" but no rl-enclos possib numtump = string.len(strtblca) -- length before clamping strtblca = lfclamp(strtblca,12) -- number -- length variable is "tump" strbkn = constrbkco -- color code without "#" cross -- bg dest "d12" boolocerr = false boolokeer = false if (strtblc9~="-") then -- do NOT evaluate evilness of "-" in "c8" if ((numafstbfcl<8) or (numafstbfcl>connummaxc8catlen)) then -- "c8" bad boolocerr = true -- length out of range else if (lfcountchr(strtblc9,58)~=1) then -- c8 bad boolocerr = true -- bad number of colons, ONE is required end--if end--if end--if if (strtblca~="-") then -- do NOT evaluate evilness of "-" in "c9" if (numtump>8) then -- c9 bad boolokeer = true -- length out of range (no minimum) else if (lfcountndg(strtblca,2)~=0) then -- c9 bad boolokeer = true -- faulty char:s, a number is expected end--if end--if end--if if (boolocerr or boolokeer) then strbkn = 'FFB0B0' -- red if crime in "c8" or "c9" strdeste = '' -- preassign to empty, may be needed below if (boolocerr) then strdeste = lfevilitem(3,8,strtblc9) -- show evil "bad category" end--if if (boolocerr and boolokeer) then strdeste = strdeste .. '<br>and<br>' -- damn: 2 crimi err in 1 row end--if if (boolokeer) then strdeste = strdeste .. lfevilitem(5,9,strtblca) -- ev "bad number" end--if boosinerr = true -- this criminal, abort table generation after row else if (strtblcy==constrpriv) then strdeste = ':-)' -- only for "d11" cell "other tionary" and "d13" else if (strtblc9=='-') then strbkn = 'FFD8D8' -- redish if no category strdeste = '-' numerrkec = numerrkec + 1 else strdeste = lfbrewurl (strtblc5,true,strtblc9) -- other tionary cat strdeste = strdeste .. '<br>' if (strtblca=="-") then strdeste = strdeste .. lfnumberinkat(nil) -- NOT count as error else numtump = tonumber(lfremovenondi(strtblca)) -- apo:s tolerable strdeste = strdeste .. lfnumberinkat(numtump) -- apo:s added end--if (strtblca=='-') else end--if (strtblc9=='-') else end--if (strtblcy==constrpriv) else end--if (boolocerr or boolokeer) else strt3d = constrtddf .. strbkn .. constrtdfd -- long "td" eleme optconcat (strt3d .. strdeste .. constrtden) -- done "d13" end--if ((boomxwerr==false) and (boosinerr==false)) then optconcat ('</tr>') -- close table row if (boomxwerr or boosinerr) then break -- something is evil, abort now that table row is finished end--if if (numipos==numtblend) then numrowinx = numrowinx + 1 -- otherwise "numrowinx" is off-by-one break -- success !!! -- done with the table end--if numtblper = numipos -- risk of "boomxwerr" error here, preventively set isubnumlio = numtblend - numipos -- here do NOT "+1" NOT interested EOL if (isubnumlio>nummaxwidth) then isubnumlio = nummaxwidth -- do NOT subtract here end--if isubnumchr = 91 -- search for "[[" isubboodwn = false searchdblchr () -- OUT: osubboofnd | USE: qconstrsr | CHG: numipos if (osubboofnd==false) then boomxwerr = true break -- "[[" NOT found end--if numtamp = numipos - numiprev -- evaluated width from "[[" to "[[" if (numtamp>nummaxwidth) then boomxwerr = true break -- "maxwidth" violated end--if if (numtamp<numminwyd) then numminwyd = numtamp -- new negative record established !!! end--if if (numtamp>nummaxwyd) then nummaxwyd = numtamp -- new record established !!! end--if numtblper = numipos -- risk of "boosinerr" error here, preventively set if ((numipos+numminwidth)>=numtblend) then boosinerr = true break -- truncation end--if strtblcy = '' -- next access code numfoulen = 0 -- index 0...2 -- ZERO-based while (true) do -- check access code (2 or 3 letters) numoct = string.byte (qconstrsr,(numipos+3+numfoulen),(numipos+3+numfoulen)) if (numoct==93) then break -- "]" fnd -- good (numfoulen is 2 or 3) or bad (numfoulen<2) end--if if (numfoulen==3) then boosinerr = true break -- access code too long -- bad end--if if (lftestlc(numoct)==false) then boosinerr = true -- only lowercase letters accepted break end--if strtblcy = strtblcy .. string.char (numoct) numfoulen = numfoulen + 1 -- increment for every seized lowercase char end--while if ((numfoulen<2) or (numfoulen>3)) then boosinerr = true -- must be 2 or 3 letters end--if numoct = string.byte (qconstrsr,(numipos+4+numfoulen),(numipos+4+numfoulen)) if (numoct~=93) then boosinerr = true -- two "]" required (the former one checked earlier) end--if numoct = string.byte (qconstrsr,(numipos+5+numfoulen),(numipos+5+numfoulen)) if (numoct~=32) then boosinerr = true -- space required end--if if (boosinerr) then break -- coming line not valid end--if boosorerr = false -- maybe we will set it below and report it above if (numrowinx>0) then -- sorting NOT required after line 0 cmp2or3charsbi () -- OUT: osubboobiger | USE: qconstrsr, numiwo if (osubboobiger==false) then numsorerr = numsorerr + 1 boosorerr = true -- sorting error, report it later end--if end--if numiwo0 = string.byte (strtblcy,1,1) -- bkp next code for overnext check numiwo1 = string.byte (strtblcy,2,2) if (string.len(strtblcy)==3) then numiwo2 = string.byte (strtblcy,3,3) else numiwo2 = 0 end--if numinxlen = numfoulen -- backup next length for overnext check numrowinx = numrowinx + 1 end--while end--if ((booerr==false) and (booearsyn==false)) then ---- CLOSE THE OUTPUT TABLE IF IT EXISTS AND WHINE IF NEEDED ---- if ((booerr==false) and (booearsyn==false)) then if (boohavtbl) then optconcat ('</table>') end--if if (boomxwerr) then optconcat (lfbrewerrsv(6,2)) -- #E06 outside the table -- "maxwidth" violat end--if if (boosinerr) then optconcat (lfbrewerrsv(5,2)) -- #E05 outside the table -- other error end--if else isubtabbunch = {} -- crucial strret = lfbrewerrsv(7,2) -- #E07 -- replace content of the string, no tbl end--if ---- MERGE BAD NEWS ---- -- * "boogtabort" is brewed from 3 var and implies that "numtblper" is valid -- * "boodofatal" is brewed from 6 var and activates the fatal block -- * we become fatal if: -- - booerr (no table then) -- - booearsyn (no table then, but "numtblper" is valid) -- - boosinerr or boomxwerr (table generation aborted) -- - (numsorerr<>0) or (numerrtlo<>0) boogtabort = (booearsyn or boosinerr or boomxwerr) -- "numtblper" valid boodofatal = (booerr or boogtabort or (numsorerr~=0) or (numerrtlo~=0)) ---- BREW THE BIG FATAL BLOCK OR TINY SUCCESS BLOCK ---- -- * block is displayed in any case and enclosed in a "div" box in any case, -- but the style heavily depends on "boodofatal" fatality -- * font size 200% or 100% (default), text color red or black (default), -- align center if (boodofatal) then strtmp = '<div style="margin:0.5em auto 0.5em auto; padding:0.5em; border:0.5em solid #FF0060; text-align:center;">' strtmp = strtmp .. '<span style="font-size:200%; color:#FF0060">' strtmp = strtmp .. contabbigtiny[0] .. '. ' .. strpurge .. ' ' .. contabbigtiny[1] strtmp = strtmp .. ' ' .. constrsumbr .. ' ' .. contabbigtiny[2] .. '. ' .. contabbigtiny[3] strtmp = strtmp .. '.</span></div>' else strtmp = '<div style="margin:0.5em auto 0.5em auto; padding:0.5em; border:1px solid #000000; text-align:center;">' strtmp = strtmp .. strpurge .. ' ' .. contabbigtiny[4] .. ' ' .. constrsumbr .. '.</div>' end--if ---- BREW THE TECHNICAL SUMMARY BLOCK ---- -- * the technical summary block is enclosed in a single-cell table since -- a "div" box would fill the complete screen width -- * using a "ul/li" type list (note that wikicode "*" would NOT work here) -- * font size 80%, text color black (default), align left (default) -- * we use "lfnumtodecbun" for numbers with risk -- of >= 1'000 and partially "lftostwauc" and "lftostwaz" and "lftostw2p" if (boodofatal or boosummar) then strsumbl = '<table style="margin:0.5em auto 0.5em auto; padding:0.5em; border:1px solid #000000;">' strsumbl = strsumbl .. '<tr><td><span style="font-size:80%;"><ul>' strsumbl = strsumbl .. '<li>' .. contabsum[0] -- 2 parameters (one of them is optional) strsumbl = strsumbl .. '"' .. strpara .. '", ' .. tostring(numproba) .. '</li>' strsumbl = strsumbl .. '<li>' .. contabsum[1] .. lfnumtodecbun(numtbllen) .. '</li>' -- source strsumbl = strsumbl .. '<li>' .. contabsum[2] .. lfnumtodecbun(numrowinx) .. '</li>' -- lang strsumbl = strsumbl .. '<li>' .. contabsum[3] .. lftostwaz(numsorerr) .. '</li>' -- sort strsumbl = strsumbl .. '<li>' .. contabsum[4] .. lfnumtodecbun(numerrtru) .. '</li>' -- trunc (ele) strsumbl = strsumbl .. '<li>' .. contabsum[5] .. lftostwaz(numerrtlo) .. '</li>' -- too long (ele) strsumbl = strsumbl .. '<li>' .. 'errkec : ' .. lfnumtodecbun(numerrkec) .. '</li>' -- minor strsumbl = strsumbl .. '<li>' .. 'errkap : ' .. lfnumtodecbun(numerrkap) .. '</li>' -- kap strsumbl = strsumbl .. '<li>' .. 'errvor : ' .. lfnumtodecbun(numerrvor) .. '</li>' -- vor strsumbl = strsumbl .. '<li>' .. 'errind : ' .. lfnumtodecbun(numerrind) .. '</li>' -- missing index page strsumbl = strsumbl .. '<li>' .. 'srctblbeg : ' .. lfnumtodecbun(numtblbeg) .. '</li>' -- bloat strsumbl = strsumbl .. '<li>' .. 'srctblend : ' .. lfnumtodecbun(numtblend) .. '</li>' -- bloat strsumbl = strsumbl .. '<li>' .. 'srctblper : ' -- earliest abort syntax err if (boogtabort) then strsumbl = strsumbl .. lftostwauc(numtblper) else strsumbl = strsumbl .. 'N/A' end--if strsumbl = strsumbl .. '</li>' strsumbl = strsumbl .. '<li>' .. 'eval minwid, limit minwid : ' -- minwidth strsumbl = strsumbl .. tostring(numminwyd) .. ', ' .. tostring(numminwidth) .. '</li>' strsumbl = strsumbl .. '<li>' .. 'eval maxwid, limit maxwid : ' -- maxwidth strsumbl = strsumbl .. tostring(nummaxwyd) .. ', ' .. tostring(nummaxwidth) .. '</li>' strsumbl = strsumbl .. '<li>' .. 'eval maxlngname, limit maxlngname : ' strsumbl = strsumbl .. tostring(nummaxnom) .. ', ' .. tostring(connummaxc0c2nlen) .. '</li>' strsumbl = strsumbl .. '<li>' .. 'eval maxkatlink, limit maxkatlink : ' strsumbl = strsumbl .. tostring(nummaxkal) .. ', ' .. tostring(connummaxc8catlen) .. '</li>' strsumbl = strsumbl .. '<li>' .. 'expife : ' .. lftostw2p(numexpife,499) .. '</li>' -- expensive "ifexist" strsumbl = strsumbl .. '<li>' .. 'exppik : ' .. lftostw2p(numexppik,499) .. '</li>' -- expensive "pagesincategory" strsumbl = strsumbl .. '<li>' .. 'dsttblsiz : ' .. lfnumtodecbun(string.len(strret)) .. '</li>' -- dst bloat strsumbl = strsumbl .. '</ul></span></td></tr></table>' end--if ---- BREW THE FINAL HUGE STRING ---- optconcat (nil) -- crucial, finalizes "strret" if (boodofatal or boosummar) then strret = strret .. strsumbl -- add technical summary block end--if strret = strtmp .. strret .. strtmp -- add fatal warn or tiny block 2 times ---- RETURN THE JUNK STRING ---- return strret end--function ---- RETURN THE JUNK LUA TABLE ---- return komtbllin