ADDED generated/natools-smaz-original_hash.adb Index: generated/natools-smaz-original_hash.adb ================================================================== --- generated/natools-smaz-original_hash.adb +++ generated/natools-smaz-original_hash.adb @@ -0,0 +1,59 @@ +with Interfaces; use Interfaces; + +package body Natools.Smaz.Original_Hash is + + P : constant array (0 .. 3) of Natural := + (1, 2, 3, 4); + + T1 : constant array (0 .. 3) of Unsigned_16 := + (205, 471, 343, 362); + + T2 : constant array (0 .. 3) of Unsigned_16 := + (421, 215, 438, 437); + + G : constant array (0 .. 508) of Unsigned_8 := + (19, 63, 226, 0, 0, 25, 0, 69, 0, 0, 14, 0, 0, 0, 73, 207, 92, 0, 0, 0, + 48, 0, 62, 48, 123, 56, 0, 0, 11, 47, 0, 0, 167, 145, 0, 0, 0, 213, + 114, 15, 0, 2, 214, 0, 161, 162, 0, 0, 0, 50, 0, 0, 0, 0, 0, 133, 0, + 0, 54, 0, 0, 0, 33, 220, 0, 143, 1, 0, 0, 0, 0, 229, 0, 0, 0, 0, 0, + 226, 0, 0, 110, 0, 0, 0, 209, 165, 0, 0, 0, 0, 99, 0, 0, 0, 0, 0, 0, + 0, 0, 79, 0, 0, 235, 0, 0, 0, 195, 237, 0, 0, 0, 0, 238, 82, 0, 252, + 26, 4, 0, 0, 205, 0, 0, 0, 0, 188, 0, 168, 0, 242, 0, 0, 0, 99, 191, + 0, 103, 0, 230, 0, 0, 0, 0, 135, 0, 183, 21, 0, 11, 172, 119, 0, 208, + 137, 0, 0, 0, 0, 0, 0, 180, 10, 183, 203, 0, 0, 86, 132, 8, 17, 0, 32, + 0, 0, 92, 0, 0, 170, 0, 0, 94, 194, 50, 185, 0, 0, 42, 0, 185, 233, + 177, 0, 0, 0, 0, 0, 0, 237, 218, 0, 0, 0, 119, 0, 181, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 201, 0, 42, 0, 0, 0, 0, 216, 0, 0, 0, 0, 158, 0, 0, 0, + 141, 36, 51, 0, 27, 234, 242, 0, 43, 0, 219, 78, 169, 164, 0, 59, 33, + 0, 112, 0, 31, 0, 144, 40, 0, 0, 0, 0, 0, 158, 0, 0, 0, 227, 127, 0, + 154, 241, 0, 0, 209, 0, 248, 0, 0, 68, 0, 119, 0, 0, 104, 174, 79, 0, + 0, 0, 121, 0, 0, 0, 0, 0, 0, 0, 0, 206, 0, 202, 0, 0, 0, 0, 133, 71, + 209, 189, 134, 0, 69, 0, 0, 226, 68, 0, 0, 189, 0, 230, 16, 0, 0, 0, + 0, 181, 246, 97, 0, 88, 25, 0, 49, 0, 34, 77, 30, 210, 0, 0, 0, 0, + 128, 193, 0, 116, 2, 121, 16, 0, 214, 132, 22, 116, 68, 0, 148, 0, 0, + 90, 165, 218, 157, 24, 0, 0, 192, 0, 81, 0, 0, 177, 0, 98, 81, 183, 0, + 0, 0, 0, 7, 161, 0, 123, 106, 0, 0, 136, 82, 51, 48, 0, 0, 169, 5, + 170, 138, 66, 211, 0, 112, 1, 0, 0, 84, 220, 167, 0, 0, 161, 252, 46, + 175, 95, 170, 20, 216, 177, 0, 97, 76, 44, 0, 0, 20, 0, 0, 233, 0, 0, + 0, 47, 8, 116, 147, 0, 212, 0, 0, 118, 94, 0, 89, 183, 0, 0, 105, 0, + 0, 74, 196, 28, 4, 0, 103, 0, 5, 0, 131, 45, 0, 177, 232, 219, 19, + 228, 1, 0, 31, 90, 0, 0, 150, 23, 92, 120, 238, 48, 1, 0, 0, 37, 3, + 152, 0, 0, 110, 166, 35, 13, 115, 217, 0, 0, 0, 87, 0, 126, 163, 248, + 80, 9, 12, 0, 0, 52, 10, 11, 89, 0); + + function Hash (S : String) return Natural is + F : constant Natural := S'First - 1; + L : constant Natural := S'Length; + F1, F2 : Natural := 0; + J : Natural; + begin + for K in P'Range loop + exit when L < P (K); + J := Character'Pos (S (P (K) + F)); + F1 := (F1 + Natural (T1 (K)) * J) mod 509; + F2 := (F2 + Natural (T2 (K)) * J) mod 509; + end loop; + return (Natural (G (F1)) + Natural (G (F2))) mod 254; + end Hash; + +end Natools.Smaz.Original_Hash; ADDED generated/natools-smaz-original_hash.ads Index: generated/natools-smaz-original_hash.ads ================================================================== --- generated/natools-smaz-original_hash.ads +++ generated/natools-smaz-original_hash.ads @@ -0,0 +1,4 @@ +package Natools.Smaz.Original_Hash is + pragma Pure; + function Hash (S : String) return Natural; +end Natools.Smaz.Original_Hash; ADDED src/natools-smaz-original.ads Index: src/natools-smaz-original.ads ================================================================== --- src/natools-smaz-original.ads +++ src/natools-smaz-original.ads @@ -0,0 +1,88 @@ +------------------------------------------------------------------------------ +-- Copyright (c) 2016, Natacha Porté -- +-- -- +-- Permission to use, copy, modify, and distribute this software for any -- +-- purpose with or without fee is hereby granted, provided that the above -- +-- copyright notice and this permission notice appear in all copies. -- +-- -- +-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- +-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- +-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- +-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- +-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- +-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- +-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- +------------------------------------------------------------------------------ + +with Ada.Characters.Latin_1; +with Natools.Smaz.Original_Hash; + +package Natools.Smaz.Original is + pragma Pure (Natools.Smaz.Original); + + LF : constant Character := Ada.Characters.Latin_1.LF; + CR : constant Character := Ada.Characters.Latin_1.CR; + + Dictionary : constant Natools.Smaz.Dictionary + := (Dict_Last => 253, + String_Size => 593, + Variable_Length_Verbatim => True, + Max_Word_Length => 7, + Offsets => (1, 2, 5, 6, 7, 8, 10, 11, 14, 15, 16, 17, 19, 20, 23, 25, + 27, 29, 31, 32, 35, 37, 39, 40, 42, 43, 45, 47, 49, 50, 52, 54, 56, + 59, 61, 64, 66, 68, 70, 71, 73, 76, 78, 80, 85, 86, 87, 89, 91, 95, + 96, 99, 101, 103, 105, 107, 110, 112, 113, 115, 116, 117, 119, 121, + 124, 127, 128, 130, 137, 140, 142, 145, 147, 150, 152, 154, 156, + 159, 161, 164, 166, 168, 169, 172, 173, 175, 177, 181, 183, 185, + 188, 189, 191, 193, 197, 199, 201, 203, 206, 208, 211, 216, 217, + 219, 223, 225, 228, 230, 233, 235, 236, 237, 239, 242, 245, 247, + 249, 252, 254, 257, 260, 262, 264, 267, 269, 272, 274, 277, 279, + 283, 285, 287, 289, 292, 295, 298, 301, 303, 305, 307, 309, 312, + 315, 318, 321, 323, 325, 328, 330, 333, 336, 338, 340, 342, 344, + 347, 351, 354, 356, 359, 362, 365, 368, 371, 373, 375, 377, 379, + 382, 385, 387, 390, 392, 395, 397, 400, 403, 406, 409, 411, 413, + 415, 418, 420, 422, 425, 428, 430, 432, 435, 437, 440, 443, 445, + 448, 450, 452, 454, 455, 459, 462, 464, 467, 470, 473, 474, 476, + 479, 482, 484, 487, 492, 495, 497, 500, 502, 504, 507, 510, 513, + 514, 516, 518, 519, 521, 523, 524, 526, 529, 531, 534, 536, 539, + 541, 544, 546, 548, 550, 552, 555, 557, 559, 561, 563, 566, 569, + 572, 575, 578, 581, 583, 584, 587, 590), + Values => " theetaofoandinse r th tinhethhhe to" & CR & LF & "ls d a" + & "anerc od on ofreof t , isuat n orwhichfmasitthat" & LF & "wa" + & "sen wes an i" & CR & "f gpnd snd ed wedhttp://forteingy The " + & "ctir hisst inarnt, toyng hwithlealto boubewere bseo enthang th" + & "eir""hifrom fin deionmev.veallre rirois cof tareea. her mer p" + & "es bytheydiraicnots, d tat celah neas tioon n tiowe a om, as o" + & "urlillchhadthise tg e" & CR & LF & " where coe oa us dss" & LF + & CR & LF & CR & LF & CR & "="" be es amaonet tor butelsol e ss,n" + & "oter waivhoe a rhats tnsch whtrut/havely ta ha ontha- latien p" + & "e rethereasssi fowaecourwhoitszfors>otun Natools.Smaz.Original_Hash.Hash'Access); + -- Dictionary built by filtering the S-expression below in the `smaz` tool + -- The S-expression itslef comes for the original `smaz.c`, after removing + -- the commas. + -- (( + -- )" " "the" "e" "t" "a" "of" "o" "and" "i" "n" "s" "e " "r" " th" ( + -- )" t" "in" "he" "th" "h" "he " "to" "\r\n" "l" "s " "d" " a" "an" ( + -- )"er" "c" " o" "d " "on" " of" "re" "of " "t " ", " "is" "u" "at" ( + -- )" " "n " "or" "which" "f" "m" "as" "it" "that" "\n" "was" "en" ( + -- )" " " w" "es" " an" " i" "\r" "f " "g" "p" "nd" " s" "nd " "ed " ( + -- )"w" "ed" "http://" "for" "te" "ing" "y " "The" " c" "ti" "r " "his" ( + -- )"st" " in" "ar" "nt" "," " to" "y" "ng" " h" "with" "le" "al" "to " ( + -- )"b" "ou" "be" "were" " b" "se" "o " "ent" "ha" "ng " "their" "\"" ( + -- )"hi" "from" " f" "in " "de" "ion" "me" "v" "." "ve" "all" "re " ( + -- )"ri" "ro" "is " "co" "f t" "are" "ea" ". " "her" " m" "er " " p" ( + -- )"es " "by" "they" "di" "ra" "ic" "not" "s, " "d t" "at " "ce" "la" ( + -- )"h " "ne" "as " "tio" "on " "n t" "io" "we" " a " "om" ", a" "s o" ( + -- )"ur" "li" "ll" "ch" "had" "this" "e t" "g " "e\r\n" " wh" "ere" ( + -- )" co" "e o" "a " "us" " d" "ss" "\n\r\n" "\r\n\r" "=\"" " be" " e" ( + -- )"s a" "ma" "one" "t t" "or " "but" "el" "so" "l " "e s" "s," "no" ( + -- )"ter" " wa" "iv" "ho" "e a" " r" "hat" "s t" "ns" "ch " "wh" "tr" ( + -- )"ut" "/" "have" "ly " "ta" " ha" " on" "tha" "-" " l" "ati" "en " ( + -- )"pe" " re" "there" "ass" "si" " fo" "wa" "ec" "our" "who" "its" "z" ( + -- )"fo" "rs" ">" "ot" "un" "<" "im" "th " "nc" "ate" "><" "ver" "ad" ( + -- )" we" "ly" "ee" " n" "id" " cl" "ac" "il" "