fnv1a.inc 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. /**--------------------------------------------------------------------------**\
  2. ========================================
  3. y_stringhash - Fast string comparisons
  4. ========================================
  5. Description:
  6. Allows you to hash strings at compile time to use them in a switch.
  7. Legal:
  8. Version: MPL 1.1
  9. The contents of this file are subject to the Mozilla Public License Version
  10. 1.1 (the "License"); you may not use this file except in compliance with
  11. the License. You may obtain a copy of the License at
  12. http://www.mozilla.org/MPL/
  13. Software distributed under the License is distributed on an "AS IS" basis,
  14. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  15. for the specific language governing rights and limitations under the
  16. License.
  17. The Original Code is the YSI stringhash include.
  18. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  19. Portions created by the Initial Developer are Copyright (C) 2011
  20. the Initial Developer. All Rights Reserved.
  21. Contributors:
  22. ZeeX, koolk, JoeBullet/Google63, g_aSlice/Slice
  23. Thanks:
  24. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  25. ZeeX - Very productive conversations.
  26. koolk - IsPlayerinAreaEx code.
  27. TheAlpha - Danish translation.
  28. breadfish - German translation.
  29. Fireburn - Dutch translation.
  30. yom - French translation.
  31. 50p - Polish translation.
  32. Zamaroht - Spanish translation.
  33. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes
  34. for me to strive to better.
  35. Pixels^ - Running XScripters where the idea was born.
  36. Matite - Pestering me to release it and using it.
  37. Very special thanks to:
  38. Thiadmer - PAWN, whose limits continue to amaze me!
  39. Kye/Kalcor - SA:MP.
  40. SA:MP Team past, present and future - SA:MP.
  41. Version:
  42. 2.0
  43. Changelog:
  44. 06/03/11:
  45. Changed the order of some letters to better support numbers in _I.
  46. 01/03/11:
  47. Rewrote compile-time hashes to not require commas.
  48. 25/10/10:
  49. Updated comments.
  50. Added to YSI 1.0.
  51. Added FNV1 and FNV1a hashes to avoid collisions.
  52. 19/08/10:
  53. First version.
  54. Functions:
  55. stock:
  56. YHash - Generate a string hash at run time.
  57. Definitions:
  58. _H - Generate a string hash at compile time.
  59. _I - Generate a case insensitive string hash at compile time.
  60. \**--------------------------------------------------------------------------**/
  61. /*
  62. 888b 88 ,ad8888ba, 88
  63. 8888b 88 d8"' `"8b 88
  64. 88 `8b 88 d8' 88
  65. 88 `8b 88 ,adPPYba, 8b db d8 88 ,adPPYYba, ,adPPYba, ,adPPYba, ,adPPYb,88
  66. 88 `8b 88 a8P_____88 `8b d88b d8' 88 "" `Y8 I8[ "" a8P_____88 a8" `Y88
  67. 88 `8b 88 8PP""""""" `8b d8'`8b d8' Y8, ,adPPPPP88 `"Y8ba, 8PP""""""" 8b 88
  68. 88 `8888 "8b, ,aa `8bd8' `8bd8' Y8a. .a8P 88, ,88 aa ]8I "8b, ,aa "8a, ,d88
  69. 88 `888 `"Ybbd8"' YP YP `"Y8888Y"' `"8bbdP"Y8 `"YbbdP"' `"Ybbd8"' `"8bbdP"Y8
  70. */
  71. // =============================
  72. // New syntax (case sensitive)
  73. // =============================
  74. #define ha:%9()
  75. #define H_Da(%0,%5,%1,%6) ha:H_Na%5(%0)H_Sa:%6]ha:@A%5:H_Na%5(%1)
  76. #define H_Sa:%6]%7|||%8||| %7|||((%8^%6)*16777619)|||
  77. #define H_Ea:|||%0||| %0
  78. // Test for the current character.
  79. #define @Aa:H_Naa(%1a%0)%7||| H_Da(%1,a,%0,97)%7|||
  80. #define @Ab:H_Nab(%1b%0)%7||| H_Da(%1,b,%0,98)%7|||
  81. #define @Ac:H_Nac(%1c%0)%7||| H_Da(%1,c,%0,99)%7|||
  82. #define @Ad:H_Nad(%1d%0)%7||| H_Da(%1,d,%0,100)%7|||
  83. #define @Ae:H_Nae(%1e%0)%7||| H_Da(%1,e,%0,101)%7|||
  84. #define @Af:H_Naf(%1f%0)%7||| H_Da(%1,f,%0,102)%7|||
  85. #define @Ag:H_Nag(%1g%0)%7||| H_Da(%1,g,%0,103)%7|||
  86. #define @Ah:H_Nah(%1h%0)%7||| H_Da(%1,h,%0,104)%7|||
  87. #define @Ai:H_Nai(%1i%0)%7||| H_Da(%1,i,%0,105)%7|||
  88. #define @Aj:H_Naj(%1j%0)%7||| H_Da(%1,j,%0,106)%7|||
  89. #define @Ak:H_Nak(%1k%0)%7||| H_Da(%1,k,%0,107)%7|||
  90. #define @Al:H_Nal(%1l%0)%7||| H_Da(%1,l,%0,108)%7|||
  91. #define @Am:H_Nam(%1m%0)%7||| H_Da(%1,m,%0,109)%7|||
  92. #define @An:H_Nan(%1n%0)%7||| H_Da(%1,n,%0,110)%7|||
  93. #define @Ao:H_Nao(%1o%0)%7||| H_Da(%1,o,%0,111)%7|||
  94. #define @Ap:H_Nap(%1p%0)%7||| H_Da(%1,p,%0,112)%7|||
  95. #define @Aq:H_Naq(%1q%0)%7||| H_Da(%1,q,%0,113)%7|||
  96. #define @Ar:H_Nar(%1r%0)%7||| H_Da(%1,r,%0,114)%7|||
  97. #define @As:H_Nas(%1s%0)%7||| H_Da(%1,s,%0,115)%7|||
  98. #define @At:H_Nat(%1t%0)%7||| H_Da(%1,t,%0,116)%7|||
  99. #define @Au:H_Nau(%1u%0)%7||| H_Da(%1,u,%0,117)%7|||
  100. #define @Av:H_Nav(%1v%0)%7||| H_Da(%1,v,%0,118)%7|||
  101. #define @Aw:H_Naw(%1w%0)%7||| H_Da(%1,w,%0,119)%7|||
  102. #define @Ax:H_Nax(%1x%0)%7||| H_Da(%1,x,%0,120)%7|||
  103. #define @Ay:H_Nay(%1y%0)%7||| H_Da(%1,y,%0,121)%7|||
  104. #define @Az:H_Naz(%1z%0)%7||| H_Da(%1,z,%0,122)%7|||
  105. #define @AA:H_NaA(%1A%0)%7||| H_Da(%1,A,%0,65)%7|||
  106. #define @AB:H_NaB(%1B%0)%7||| H_Da(%1,B,%0,66)%7|||
  107. #define @AC:H_NaC(%1C%0)%7||| H_Da(%1,C,%0,67)%7|||
  108. #define @AD:H_NaD(%1D%0)%7||| H_Da(%1,D,%0,68)%7|||
  109. #define @AE:H_NaE(%1E%0)%7||| H_Da(%1,E,%0,69)%7|||
  110. #define @AF:H_NaF(%1F%0)%7||| H_Da(%1,F,%0,70)%7|||
  111. #define @AG:H_NaG(%1G%0)%7||| H_Da(%1,G,%0,71)%7|||
  112. #define @AH:H_NaH(%1H%0)%7||| H_Da(%1,H,%0,72)%7|||
  113. #define @AI:H_NaI(%1I%0)%7||| H_Da(%1,I,%0,73)%7|||
  114. #define @AJ:H_NaJ(%1J%0)%7||| H_Da(%1,J,%0,74)%7|||
  115. #define @AK:H_NaK(%1K%0)%7||| H_Da(%1,K,%0,75)%7|||
  116. #define @AL:H_NaL(%1L%0)%7||| H_Da(%1,L,%0,76)%7|||
  117. #define @AM:H_NaM(%1M%0)%7||| H_Da(%1,M,%0,77)%7|||
  118. #define @AN:H_NaN(%1N%0)%7||| H_Da(%1,N,%0,78)%7|||
  119. #define @AO:H_NaO(%1O%0)%7||| H_Da(%1,O,%0,79)%7|||
  120. #define @AP:H_NaP(%1P%0)%7||| H_Da(%1,P,%0,80)%7|||
  121. #define @AQ:H_NaQ(%1Q%0)%7||| H_Da(%1,Q,%0,81)%7|||
  122. #define @AR:H_NaR(%1R%0)%7||| H_Da(%1,R,%0,82)%7|||
  123. #define @AS:H_NaS(%1S%0)%7||| H_Da(%1,S,%0,83)%7|||
  124. #define @AT:H_NaT(%1T%0)%7||| H_Da(%1,T,%0,84)%7|||
  125. #define @AU:H_NaU(%1U%0)%7||| H_Da(%1,U,%0,85)%7|||
  126. #define @AV:H_NaV(%1V%0)%7||| H_Da(%1,V,%0,86)%7|||
  127. #define @AW:H_NaW(%1W%0)%7||| H_Da(%1,W,%0,87)%7|||
  128. #define @AX:H_NaX(%1X%0)%7||| H_Da(%1,X,%0,88)%7|||
  129. #define @AY:H_NaY(%1Y%0)%7||| H_Da(%1,Y,%0,89)%7|||
  130. #define @AZ:H_NaZ(%1Z%0)%7||| H_Da(%1,Z,%0,90)%7|||
  131. #define @A0:H_Na0(%10%0)%7||| H_Da(%1,0,%0,48)%7|||
  132. #define @A1:H_Na1(%11%0)%7||| H_Da(%1,1,%0,49)%7|||
  133. #define @A2:H_Na2(%12%0)%7||| H_Da(%1,2,%0,50)%7|||
  134. #define @A3:H_Na3(%13%0)%7||| H_Da(%1,3,%0,51)%7|||
  135. #define @A4:H_Na4(%14%0)%7||| H_Da(%1,4,%0,52)%7|||
  136. #define @A5:H_Na5(%15%0)%7||| H_Da(%1,5,%0,53)%7|||
  137. #define @A6:H_Na6(%16%0)%7||| H_Da(%1,6,%0,54)%7|||
  138. #define @A7:H_Na7(%17%0)%7||| H_Da(%1,7,%0,55)%7|||
  139. #define @A8:H_Na8(%18%0)%7||| H_Da(%1,8,%0,56)%7|||
  140. #define @A9:H_Na9(%19%0)%7||| H_Da(%1,9,%0,57)%7|||
  141. #define @A_:H_Na_(%1_%0)%7||| H_Da(%1,_,%0,95)%7|||
  142. //#define ha@:H_Sa(@%0,%1)%7||| H_Da(%0)%7|||
  143. // Find the next character to test.
  144. #define H_Naa(%0) @Ab:H_Nab(%0)
  145. #define H_Nab(%0) @Ac:H_Nac(%0)
  146. #define H_Nac(%0) @Ad:H_Nad(%0)
  147. #define H_Nad(%0) @Ae:H_Nae(%0)
  148. #define H_Nae(%0) @Af:H_Naf(%0)
  149. #define H_Naf(%0) @Ag:H_Nag(%0)
  150. #define H_Nag(%0) @Ah:H_Nah(%0)
  151. #define H_Nah(%0) @Ai:H_Nai(%0)
  152. #define H_Nai(%0) @Aj:H_Naj(%0)
  153. #define H_Naj(%0) @Ak:H_Nak(%0)
  154. #define H_Nak(%0) @Al:H_Nal(%0)
  155. #define H_Nal(%0) @Am:H_Nam(%0)
  156. #define H_Nam(%0) @An:H_Nan(%0)
  157. #define H_Nan(%0) @Ao:H_Nao(%0)
  158. #define H_Nao(%0) @Ap:H_Nap(%0)
  159. #define H_Nap(%0) @Aq:H_Naq(%0)
  160. #define H_Naq(%0) @Ar:H_Nar(%0)
  161. #define H_Nar(%0) @As:H_Nas(%0)
  162. #define H_Nas(%0) @At:H_Nat(%0)
  163. #define H_Nat(%0) @Au:H_Nau(%0)
  164. #define H_Nau(%0) @Av:H_Nav(%0)
  165. #define H_Nav(%0) @Aw:H_Naw(%0)
  166. #define H_Naw(%0) @Ax:H_Nax(%0)
  167. #define H_Nax(%0) @Ay:H_Nay(%0)
  168. #define H_Nay(%0) @Az:H_Naz(%0)
  169. #define H_Naz(%0) @A0:H_Na0(%0)
  170. #define H_NaA(%0) @AB:H_NaB(%0)
  171. #define H_NaB(%0) @AC:H_NaC(%0)
  172. #define H_NaC(%0) @AD:H_NaD(%0)
  173. #define H_NaD(%0) @AE:H_NaE(%0)
  174. #define H_NaE(%0) @AF:H_NaF(%0)
  175. #define H_NaF(%0) @AG:H_NaG(%0)
  176. #define H_NaG(%0) @AH:H_NaH(%0)
  177. #define H_NaH(%0) @AI:H_NaI(%0)
  178. #define H_NaI(%0) @AJ:H_NaJ(%0)
  179. #define H_NaJ(%0) @AK:H_NaK(%0)
  180. #define H_NaK(%0) @AL:H_NaL(%0)
  181. #define H_NaL(%0) @AM:H_NaM(%0)
  182. #define H_NaM(%0) @AN:H_NaN(%0)
  183. #define H_NaN(%0) @AO:H_NaO(%0)
  184. #define H_NaO(%0) @AP:H_NaP(%0)
  185. #define H_NaP(%0) @AQ:H_NaQ(%0)
  186. #define H_NaQ(%0) @AR:H_NaR(%0)
  187. #define H_NaR(%0) @AS:H_NaS(%0)
  188. #define H_NaS(%0) @AT:H_NaT(%0)
  189. #define H_NaT(%0) @AU:H_NaU(%0)
  190. #define H_NaU(%0) @AV:H_NaV(%0)
  191. #define H_NaV(%0) @AW:H_NaW(%0)
  192. #define H_NaW(%0) @AX:H_NaX(%0)
  193. #define H_NaX(%0) @AY:H_NaY(%0)
  194. #define H_NaY(%0) @AZ:H_NaZ(%0)
  195. #define H_NaZ(%0) H_Ea:H_Ra
  196. #define H_Na0(%0) @A1:H_Na1(%0)
  197. #define H_Na1(%0) @A2:H_Na2(%0)
  198. #define H_Na2(%0) @A3:H_Na3(%0)
  199. #define H_Na3(%0) @A4:H_Na4(%0)
  200. #define H_Na4(%0) @A5:H_Na5(%0)
  201. #define H_Na5(%0) @A6:H_Na6(%0)
  202. #define H_Na6(%0) @A7:H_Na7(%0)
  203. #define H_Na7(%0) @A8:H_Na8(%0)
  204. #define H_Na8(%0) @A9:H_Na9(%0)
  205. #define H_Na9(%0) @A_:H_Na_(%0)
  206. #define H_Na_(%0) @AA:H_NaA(%0)
  207. /*
  208. 888b 88 88
  209. 8888b 88 88
  210. 88 `8b 88 88
  211. 88 `8b 88 ,adPPYba, 8b db d8 88 ,adPPYb,d8 8b,dPPYba, ,adPPYba, 8b,dPPYba, ,adPPYba,
  212. 88 `8b 88 a8P_____88 `8b d88b d8' 88 a8" `Y88 88P' `"8a a8" "8a 88P' "Y8 a8P_____88
  213. 88 `8b 88 8PP""""""" `8b d8'`8b d8' 88 8b 88 88 88 8b d8 88 8PP"""""""
  214. 88 `8888 "8b, ,aa `8bd8' `8bd8' 88 "8a, ,d88 88 88 "8a, ,a8" 88 "8b, ,aa
  215. 88 `888 `"Ybbd8"' YP YP 88 `"YbbdP"Y8 88 88 `"YbbdP"' 88 `"Ybbd8"'
  216. aa, ,88
  217. "Y8bbdP"
  218. */
  219. // ===============================
  220. // New syntax (case insensitive)
  221. // ===============================
  222. #define hd:%9()
  223. #define H_Dd(%0,%5,%1,%6) hd:H_Nd%5(%0)H_Sd:%6]hd:@D%5:H_Nd%5(%1)
  224. #define H_Sd:%6]%7|||%8||| %7|||((%8^%6)*16777619)|||
  225. #define H_Ed:|||%0||| %0
  226. // Test for the current character.
  227. #define @Da:H_Nda(%1a%0)%7||| H_Dd(%1,a,%0,65)%7|||
  228. #define @Db:H_Ndb(%1b%0)%7||| H_Dd(%1,b,%0,66)%7|||
  229. #define @Dc:H_Ndc(%1c%0)%7||| H_Dd(%1,c,%0,67)%7|||
  230. #define @Dd:H_Ndd(%1d%0)%7||| H_Dd(%1,d,%0,68)%7|||
  231. #define @De:H_Nde(%1e%0)%7||| H_Dd(%1,e,%0,69)%7|||
  232. #define @Df:H_Ndf(%1f%0)%7||| H_Dd(%1,f,%0,70)%7|||
  233. #define @Dg:H_Ndg(%1g%0)%7||| H_Dd(%1,g,%0,71)%7|||
  234. #define @Dh:H_Ndh(%1h%0)%7||| H_Dd(%1,h,%0,72)%7|||
  235. #define @Di:H_Ndi(%1i%0)%7||| H_Dd(%1,i,%0,73)%7|||
  236. #define @Dj:H_Ndj(%1j%0)%7||| H_Dd(%1,j,%0,74)%7|||
  237. #define @Dk:H_Ndk(%1k%0)%7||| H_Dd(%1,k,%0,75)%7|||
  238. #define @Dl:H_Ndl(%1l%0)%7||| H_Dd(%1,l,%0,76)%7|||
  239. #define @Dm:H_Ndm(%1m%0)%7||| H_Dd(%1,m,%0,77)%7|||
  240. #define @Dn:H_Ndn(%1n%0)%7||| H_Dd(%1,n,%0,78)%7|||
  241. #define @Do:H_Ndo(%1o%0)%7||| H_Dd(%1,o,%0,79)%7|||
  242. #define @Dp:H_Ndp(%1p%0)%7||| H_Dd(%1,p,%0,80)%7|||
  243. #define @Dq:H_Ndq(%1q%0)%7||| H_Dd(%1,q,%0,81)%7|||
  244. #define @Dr:H_Ndr(%1r%0)%7||| H_Dd(%1,r,%0,82)%7|||
  245. #define @Ds:H_Nds(%1s%0)%7||| H_Dd(%1,s,%0,83)%7|||
  246. #define @Dt:H_Ndt(%1t%0)%7||| H_Dd(%1,t,%0,84)%7|||
  247. #define @Du:H_Ndu(%1u%0)%7||| H_Dd(%1,u,%0,85)%7|||
  248. #define @Dv:H_Ndv(%1v%0)%7||| H_Dd(%1,v,%0,86)%7|||
  249. #define @Dw:H_Ndw(%1w%0)%7||| H_Dd(%1,w,%0,87)%7|||
  250. #define @Dx:H_Ndx(%1x%0)%7||| H_Dd(%1,x,%0,88)%7|||
  251. #define @Dy:H_Ndy(%1y%0)%7||| H_Dd(%1,y,%0,89)%7|||
  252. #define @Dz:H_Ndz(%1z%0)%7||| H_Dd(%1,z,%0,90)%7|||
  253. #define @DA:H_NdA(%1A%0)%7||| H_Dd(%1,A,%0,65)%7|||
  254. #define @DB:H_NdB(%1B%0)%7||| H_Dd(%1,B,%0,66)%7|||
  255. #define @DC:H_NdC(%1C%0)%7||| H_Dd(%1,C,%0,67)%7|||
  256. #define @DD:H_NdD(%1D%0)%7||| H_Dd(%1,D,%0,68)%7|||
  257. #define @DE:H_NdE(%1E%0)%7||| H_Dd(%1,E,%0,69)%7|||
  258. #define @DF:H_NdF(%1F%0)%7||| H_Dd(%1,F,%0,70)%7|||
  259. #define @DG:H_NdG(%1G%0)%7||| H_Dd(%1,G,%0,71)%7|||
  260. #define @DH:H_NdH(%1H%0)%7||| H_Dd(%1,H,%0,72)%7|||
  261. #define @DI:H_NdI(%1I%0)%7||| H_Dd(%1,I,%0,73)%7|||
  262. #define @DJ:H_NdJ(%1J%0)%7||| H_Dd(%1,J,%0,74)%7|||
  263. #define @DK:H_NdK(%1K%0)%7||| H_Dd(%1,K,%0,75)%7|||
  264. #define @DL:H_NdL(%1L%0)%7||| H_Dd(%1,L,%0,76)%7|||
  265. #define @DM:H_NdM(%1M%0)%7||| H_Dd(%1,M,%0,77)%7|||
  266. #define @DN:H_NdN(%1N%0)%7||| H_Dd(%1,N,%0,78)%7|||
  267. #define @DO:H_NdO(%1O%0)%7||| H_Dd(%1,O,%0,79)%7|||
  268. #define @DP:H_NdP(%1P%0)%7||| H_Dd(%1,P,%0,80)%7|||
  269. #define @DQ:H_NdQ(%1Q%0)%7||| H_Dd(%1,Q,%0,81)%7|||
  270. #define @DR:H_NdR(%1R%0)%7||| H_Dd(%1,R,%0,82)%7|||
  271. #define @DS:H_NdS(%1S%0)%7||| H_Dd(%1,S,%0,83)%7|||
  272. #define @DT:H_NdT(%1T%0)%7||| H_Dd(%1,T,%0,84)%7|||
  273. #define @DU:H_NdU(%1U%0)%7||| H_Dd(%1,U,%0,85)%7|||
  274. #define @DV:H_NdV(%1V%0)%7||| H_Dd(%1,V,%0,86)%7|||
  275. #define @DW:H_NdW(%1W%0)%7||| H_Dd(%1,W,%0,87)%7|||
  276. #define @DX:H_NdX(%1X%0)%7||| H_Dd(%1,X,%0,88)%7|||
  277. #define @DY:H_NdY(%1Y%0)%7||| H_Dd(%1,Y,%0,89)%7|||
  278. #define @DZ:H_NdZ(%1Z%0)%7||| H_Dd(%1,Z,%0,90)%7|||
  279. #define @D0:H_Nd0(%10%0)%7||| H_Dd(%1,0,%0,48)%7|||
  280. #define @D1:H_Nd1(%11%0)%7||| H_Dd(%1,1,%0,49)%7|||
  281. #define @D2:H_Nd2(%12%0)%7||| H_Dd(%1,2,%0,50)%7|||
  282. #define @D3:H_Nd3(%13%0)%7||| H_Dd(%1,3,%0,51)%7|||
  283. #define @D4:H_Nd4(%14%0)%7||| H_Dd(%1,4,%0,52)%7|||
  284. #define @D5:H_Nd5(%15%0)%7||| H_Dd(%1,5,%0,53)%7|||
  285. #define @D6:H_Nd6(%16%0)%7||| H_Dd(%1,6,%0,54)%7|||
  286. #define @D7:H_Nd7(%17%0)%7||| H_Dd(%1,7,%0,55)%7|||
  287. #define @D8:H_Nd8(%18%0)%7||| H_Dd(%1,8,%0,56)%7|||
  288. #define @D9:H_Nd9(%19%0)%7||| H_Dd(%1,9,%0,57)%7|||
  289. #define @D_:H_Nd_(%1_%0)%7||| H_Dd(%1,_,%0,95)%7|||
  290. //#define hd@:H_Sd(@%0,%1) H_Dd(%0)
  291. // Find the next character to test.
  292. #define H_Nda(%0) @Db:H_Ndb(%0)
  293. #define H_Ndb(%0) @Dc:H_Ndc(%0)
  294. #define H_Ndc(%0) @Dd:H_Ndd(%0)
  295. #define H_Ndd(%0) @De:H_Nde(%0)
  296. #define H_Nde(%0) @Df:H_Ndf(%0)
  297. #define H_Ndf(%0) @Dg:H_Ndg(%0)
  298. #define H_Ndg(%0) @Dh:H_Ndh(%0)
  299. #define H_Ndh(%0) @Di:H_Ndi(%0)
  300. #define H_Ndi(%0) @Dj:H_Ndj(%0)
  301. #define H_Ndj(%0) @Dk:H_Ndk(%0)
  302. #define H_Ndk(%0) @Dl:H_Ndl(%0)
  303. #define H_Ndl(%0) @Dm:H_Ndm(%0)
  304. #define H_Ndm(%0) @Dn:H_Ndn(%0)
  305. #define H_Ndn(%0) @Do:H_Ndo(%0)
  306. #define H_Ndo(%0) @Dp:H_Ndp(%0)
  307. #define H_Ndp(%0) @Dq:H_Ndq(%0)
  308. #define H_Ndq(%0) @Dr:H_Ndr(%0)
  309. #define H_Ndr(%0) @Ds:H_Nds(%0)
  310. #define H_Nds(%0) @Dt:H_Ndt(%0)
  311. #define H_Ndt(%0) @Du:H_Ndu(%0)
  312. #define H_Ndu(%0) @Dv:H_Ndv(%0)
  313. #define H_Ndv(%0) @Dw:H_Ndw(%0)
  314. #define H_Ndw(%0) @Dx:H_Ndx(%0)
  315. #define H_Ndx(%0) @Dy:H_Ndy(%0)
  316. #define H_Ndy(%0) @Dz:H_Ndz(%0)
  317. #define H_Ndz(%0) @D0:H_Nd0(%0)
  318. #define H_NdA(%0) @DB:H_NdB(%0)
  319. #define H_NdB(%0) @DC:H_NdC(%0)
  320. #define H_NdC(%0) @DD:H_NdD(%0)
  321. #define H_NdD(%0) @DE:H_NdE(%0)
  322. #define H_NdE(%0) @DF:H_NdF(%0)
  323. #define H_NdF(%0) @DG:H_NdG(%0)
  324. #define H_NdG(%0) @DH:H_NdH(%0)
  325. #define H_NdH(%0) @DI:H_NdI(%0)
  326. #define H_NdI(%0) @DJ:H_NdJ(%0)
  327. #define H_NdJ(%0) @DK:H_NdK(%0)
  328. #define H_NdK(%0) @DL:H_NdL(%0)
  329. #define H_NdL(%0) @DM:H_NdM(%0)
  330. #define H_NdM(%0) @DN:H_NdN(%0)
  331. #define H_NdN(%0) @DO:H_NdO(%0)
  332. #define H_NdO(%0) @DP:H_NdP(%0)
  333. #define H_NdP(%0) @DQ:H_NdQ(%0)
  334. #define H_NdQ(%0) @DR:H_NdR(%0)
  335. #define H_NdR(%0) @DS:H_NdS(%0)
  336. #define H_NdS(%0) @DT:H_NdT(%0)
  337. #define H_NdT(%0) @DU:H_NdU(%0)
  338. #define H_NdU(%0) @DV:H_NdV(%0)
  339. #define H_NdV(%0) @DW:H_NdW(%0)
  340. #define H_NdW(%0) @DX:H_NdX(%0)
  341. #define H_NdX(%0) @DY:H_NdY(%0)
  342. #define H_NdY(%0) @DZ:H_NdZ(%0)
  343. #define H_NdZ(%0) H_Ed:H_Rd
  344. #define H_Nd0(%0) @D1:H_Nd1(%0)
  345. #define H_Nd1(%0) @D2:H_Nd2(%0)
  346. #define H_Nd2(%0) @D3:H_Nd3(%0)
  347. #define H_Nd3(%0) @D4:H_Nd4(%0)
  348. #define H_Nd4(%0) @D5:H_Nd5(%0)
  349. #define H_Nd5(%0) @D6:H_Nd6(%0)
  350. #define H_Nd6(%0) @D7:H_Nd7(%0)
  351. #define H_Nd7(%0) @D8:H_Nd8(%0)
  352. #define H_Nd8(%0) @D9:H_Nd9(%0)
  353. #define H_Nd9(%0) @D_:H_Nd_(%0)
  354. #define H_Nd_(%0) @DA:H_NdA(%0)
  355. /*
  356. ,ad8888ba, 88 88 ,ad8888ba, 88
  357. d8"' `"8b 88 88 d8"' `"8b 88
  358. d8' `8b 88 88 d8' 88
  359. 88 88 88 ,adPPYb,88 88 ,adPPYYba, ,adPPYba, ,adPPYba, ,adPPYb,88
  360. 88 88 88 a8" `Y88 88 "" `Y8 I8[ "" a8P_____88 a8" `Y88
  361. Y8, ,8P 88 8b 88 Y8, ,adPPPPP88 `"Y8ba, 8PP""""""" 8b 88
  362. Y8a. .a8P 88 "8a, ,d88 Y8a. .a8P 88, ,88 aa ]8I "8b, ,aa "8a, ,d88
  363. `"Y8888Y"' 88 `"8bbdP"Y8 `"Y8888Y"' `"8bbdP"Y8 `"YbbdP"' `"Ybbd8"' `"8bbdP"Y8
  364. */
  365. // =============================
  366. // Old syntax (case sensitive)
  367. // =============================
  368. // Signify the end with two "@" symbols.
  369. #define HASH@fnv1a(%0) _REHASH@a(%0,@,@)
  370. // Internal call.
  371. #define _REHASH@a(%0,%1) _HASH@a_%0(%1,)(2166136261)
  372. // The bit that actually does the work.
  373. #define _DOHASH@a(%0,%1,%2)(%8) _HASH@a_%1(%2)(((%8^%0)*16777619))
  374. // Space.
  375. #define _HASH@a_(%0)(%8) _DOHASH@a(32,%0)(%8)
  376. // Numbers.
  377. #define _HASH@a_0(%0)(%8) _DOHASH@a(48,%0)(%8)
  378. #define _HASH@a_1(%0)(%8) _DOHASH@a(49,%0)(%8)
  379. #define _HASH@a_2(%0)(%8) _DOHASH@a(50,%0)(%8)
  380. #define _HASH@a_3(%0)(%8) _DOHASH@a(51,%0)(%8)
  381. #define _HASH@a_4(%0)(%8) _DOHASH@a(52,%0)(%8)
  382. #define _HASH@a_5(%0)(%8) _DOHASH@a(53,%0)(%8)
  383. #define _HASH@a_6(%0)(%8) _DOHASH@a(54,%0)(%8)
  384. #define _HASH@a_7(%0)(%8) _DOHASH@a(55,%0)(%8)
  385. #define _HASH@a_8(%0)(%8) _DOHASH@a(56,%0)(%8)
  386. #define _HASH@a_9(%0)(%8) _DOHASH@a(57,%0)(%8)
  387. // Upper case letters.
  388. #define _HASH@a_A(%0)(%8) _DOHASH@a(65,%0)(%8)
  389. #define _HASH@a_B(%0)(%8) _DOHASH@a(66,%0)(%8)
  390. #define _HASH@a_C(%0)(%8) _DOHASH@a(67,%0)(%8)
  391. #define _HASH@a_D(%0)(%8) _DOHASH@a(68,%0)(%8)
  392. #define _HASH@a_E(%0)(%8) _DOHASH@a(69,%0)(%8)
  393. #define _HASH@a_F(%0)(%8) _DOHASH@a(70,%0)(%8)
  394. #define _HASH@a_G(%0)(%8) _DOHASH@a(71,%0)(%8)
  395. #define _HASH@a_H(%0)(%8) _DOHASH@a(72,%0)(%8)
  396. #define _HASH@a_I(%0)(%8) _DOHASH@a(73,%0)(%8)
  397. #define _HASH@a_J(%0)(%8) _DOHASH@a(74,%0)(%8)
  398. #define _HASH@a_K(%0)(%8) _DOHASH@a(75,%0)(%8)
  399. #define _HASH@a_L(%0)(%8) _DOHASH@a(76,%0)(%8)
  400. #define _HASH@a_M(%0)(%8) _DOHASH@a(77,%0)(%8)
  401. #define _HASH@a_N(%0)(%8) _DOHASH@a(78,%0)(%8)
  402. #define _HASH@a_O(%0)(%8) _DOHASH@a(79,%0)(%8)
  403. #define _HASH@a_P(%0)(%8) _DOHASH@a(80,%0)(%8)
  404. #define _HASH@a_Q(%0)(%8) _DOHASH@a(81,%0)(%8)
  405. #define _HASH@a_R(%0)(%8) _DOHASH@a(82,%0)(%8)
  406. #define _HASH@a_S(%0)(%8) _DOHASH@a(83,%0)(%8)
  407. #define _HASH@a_T(%0)(%8) _DOHASH@a(84,%0)(%8)
  408. #define _HASH@a_U(%0)(%8) _DOHASH@a(85,%0)(%8)
  409. #define _HASH@a_V(%0)(%8) _DOHASH@a(86,%0)(%8)
  410. #define _HASH@a_W(%0)(%8) _DOHASH@a(87,%0)(%8)
  411. #define _HASH@a_X(%0)(%8) _DOHASH@a(88,%0)(%8)
  412. #define _HASH@a_Y(%0)(%8) _DOHASH@a(89,%0)(%8)
  413. #define _HASH@a_Z(%0)(%8) _DOHASH@a(90,%0)(%8)
  414. // Underscore.
  415. #define _HASH@a__(%0)(%8) _DOHASH@a(95,%0)(%8)
  416. // Lower case letters.
  417. #define _HASH@a_a(%0)(%8) _DOHASH@a(97,%0)(%8)
  418. #define _HASH@a_b(%0)(%8) _DOHASH@a(98,%0)(%8)
  419. #define _HASH@a_c(%0)(%8) _DOHASH@a(99,%0)(%8)
  420. #define _HASH@a_d(%0)(%8) _DOHASH@a(100,%0)(%8)
  421. #define _HASH@a_e(%0)(%8) _DOHASH@a(101,%0)(%8)
  422. #define _HASH@a_f(%0)(%8) _DOHASH@a(102,%0)(%8)
  423. #define _HASH@a_g(%0)(%8) _DOHASH@a(103,%0)(%8)
  424. #define _HASH@a_h(%0)(%8) _DOHASH@a(104,%0)(%8)
  425. #define _HASH@a_i(%0)(%8) _DOHASH@a(105,%0)(%8)
  426. #define _HASH@a_j(%0)(%8) _DOHASH@a(106,%0)(%8)
  427. #define _HASH@a_k(%0)(%8) _DOHASH@a(107,%0)(%8)
  428. #define _HASH@a_l(%0)(%8) _DOHASH@a(108,%0)(%8)
  429. #define _HASH@a_m(%0)(%8) _DOHASH@a(109,%0)(%8)
  430. #define _HASH@a_n(%0)(%8) _DOHASH@a(110,%0)(%8)
  431. #define _HASH@a_o(%0)(%8) _DOHASH@a(111,%0)(%8)
  432. #define _HASH@a_p(%0)(%8) _DOHASH@a(112,%0)(%8)
  433. #define _HASH@a_q(%0)(%8) _DOHASH@a(113,%0)(%8)
  434. #define _HASH@a_r(%0)(%8) _DOHASH@a(114,%0)(%8)
  435. #define _HASH@a_s(%0)(%8) _DOHASH@a(115,%0)(%8)
  436. #define _HASH@a_t(%0)(%8) _DOHASH@a(116,%0)(%8)
  437. #define _HASH@a_u(%0)(%8) _DOHASH@a(117,%0)(%8)
  438. #define _HASH@a_v(%0)(%8) _DOHASH@a(118,%0)(%8)
  439. #define _HASH@a_w(%0)(%8) _DOHASH@a(119,%0)(%8)
  440. #define _HASH@a_x(%0)(%8) _DOHASH@a(120,%0)(%8)
  441. #define _HASH@a_y(%0)(%8) _DOHASH@a(121,%0)(%8)
  442. #define _HASH@a_z(%0)(%8) _DOHASH@a(122,%0)(%8)
  443. // String end.
  444. #define _HASH@a_@(%0)(%8) %8
  445. /*
  446. ,ad8888ba, 88 88 88
  447. d8"' `"8b 88 88 88
  448. d8' `8b 88 88 88
  449. 88 88 88 ,adPPYb,88 88 ,adPPYb,d8 8b,dPPYba, ,adPPYba, 8b,dPPYba, ,adPPYba,
  450. 88 88 88 a8" `Y88 88 a8" `Y88 88P' `"8a a8" "8a 88P' "Y8 a8P_____88
  451. Y8, ,8P 88 8b 88 88 8b 88 88 88 8b d8 88 8PP"""""""
  452. Y8a. .a8P 88 "8a, ,d88 88 "8a, ,d88 88 88 "8a, ,a8" 88 "8b, ,aa
  453. `"Y8888Y"' 88 `"8bbdP"Y8 88 `"YbbdP"Y8 88 88 `"YbbdP"' 88 `"Ybbd8"'
  454. aa, ,88
  455. "Y8bbdP"
  456. */
  457. // ===============================
  458. // Old syntax (case insensitive)
  459. // ===============================
  460. // Signify the end with two "@" symbols.
  461. #define HASHi@fnv1a(%0) _REHASH@ia(%0,@,@)
  462. // Internal call.
  463. #define _REHASH@ia(%0,%1) _HASH@ia_%0(%1,)(2166136261)
  464. // The bit that actually does the work.
  465. #define _DOHASH@ia(%0,%1,%2)(%8) _HASH@ia_%1(%2)(((%8^%0)*16777619))
  466. // Space.
  467. #define _HASH@ia_(%0)(%8) _DOHASH@ia(32,%0)(%8)
  468. // Numbers.
  469. #define _HASH@ia_0(%0)(%8) _DOHASH@ia(48,%0)(%8)
  470. #define _HASH@ia_1(%0)(%8) _DOHASH@ia(49,%0)(%8)
  471. #define _HASH@ia_2(%0)(%8) _DOHASH@ia(50,%0)(%8)
  472. #define _HASH@ia_3(%0)(%8) _DOHASH@ia(51,%0)(%8)
  473. #define _HASH@ia_4(%0)(%8) _DOHASH@ia(52,%0)(%8)
  474. #define _HASH@ia_5(%0)(%8) _DOHASH@ia(53,%0)(%8)
  475. #define _HASH@ia_6(%0)(%8) _DOHASH@ia(54,%0)(%8)
  476. #define _HASH@ia_7(%0)(%8) _DOHASH@ia(55,%0)(%8)
  477. #define _HASH@ia_8(%0)(%8) _DOHASH@ia(56,%0)(%8)
  478. #define _HASH@ia_9(%0)(%8) _DOHASH@ia(57,%0)(%8)
  479. // Upper case letters.
  480. #define _HASH@ia_A(%0)(%8) _DOHASH@ia(65,%0)(%8)
  481. #define _HASH@ia_B(%0)(%8) _DOHASH@ia(66,%0)(%8)
  482. #define _HASH@ia_C(%0)(%8) _DOHASH@ia(67,%0)(%8)
  483. #define _HASH@ia_D(%0)(%8) _DOHASH@ia(68,%0)(%8)
  484. #define _HASH@ia_E(%0)(%8) _DOHASH@ia(69,%0)(%8)
  485. #define _HASH@ia_F(%0)(%8) _DOHASH@ia(70,%0)(%8)
  486. #define _HASH@ia_G(%0)(%8) _DOHASH@ia(71,%0)(%8)
  487. #define _HASH@ia_H(%0)(%8) _DOHASH@ia(72,%0)(%8)
  488. #define _HASH@ia_I(%0)(%8) _DOHASH@ia(73,%0)(%8)
  489. #define _HASH@ia_J(%0)(%8) _DOHASH@ia(74,%0)(%8)
  490. #define _HASH@ia_K(%0)(%8) _DOHASH@ia(75,%0)(%8)
  491. #define _HASH@ia_L(%0)(%8) _DOHASH@ia(76,%0)(%8)
  492. #define _HASH@ia_M(%0)(%8) _DOHASH@ia(77,%0)(%8)
  493. #define _HASH@ia_N(%0)(%8) _DOHASH@ia(78,%0)(%8)
  494. #define _HASH@ia_O(%0)(%8) _DOHASH@ia(79,%0)(%8)
  495. #define _HASH@ia_P(%0)(%8) _DOHASH@ia(80,%0)(%8)
  496. #define _HASH@ia_Q(%0)(%8) _DOHASH@ia(81,%0)(%8)
  497. #define _HASH@ia_R(%0)(%8) _DOHASH@ia(82,%0)(%8)
  498. #define _HASH@ia_S(%0)(%8) _DOHASH@ia(83,%0)(%8)
  499. #define _HASH@ia_T(%0)(%8) _DOHASH@ia(84,%0)(%8)
  500. #define _HASH@ia_U(%0)(%8) _DOHASH@ia(85,%0)(%8)
  501. #define _HASH@ia_V(%0)(%8) _DOHASH@ia(86,%0)(%8)
  502. #define _HASH@ia_W(%0)(%8) _DOHASH@ia(87,%0)(%8)
  503. #define _HASH@ia_X(%0)(%8) _DOHASH@ia(88,%0)(%8)
  504. #define _HASH@ia_Y(%0)(%8) _DOHASH@ia(89,%0)(%8)
  505. #define _HASH@ia_Z(%0)(%8) _DOHASH@ia(90,%0)(%8)
  506. // Underscore.
  507. #define _HASH@ia__(%0)(%8) _DOHASH@ia(95,%0)(%8)
  508. // Lower case letters.
  509. #define _HASH@ia_a(%0)(%8) _DOHASH@ia(65,%0)(%8)
  510. #define _HASH@ia_b(%0)(%8) _DOHASH@ia(66,%0)(%8)
  511. #define _HASH@ia_c(%0)(%8) _DOHASH@ia(67,%0)(%8)
  512. #define _HASH@ia_d(%0)(%8) _DOHASH@ia(68,%0)(%8)
  513. #define _HASH@ia_e(%0)(%8) _DOHASH@ia(69,%0)(%8)
  514. #define _HASH@ia_f(%0)(%8) _DOHASH@ia(70,%0)(%8)
  515. #define _HASH@ia_g(%0)(%8) _DOHASH@ia(71,%0)(%8)
  516. #define _HASH@ia_h(%0)(%8) _DOHASH@ia(72,%0)(%8)
  517. #define _HASH@ia_i(%0)(%8) _DOHASH@ia(73,%0)(%8)
  518. #define _HASH@ia_j(%0)(%8) _DOHASH@ia(74,%0)(%8)
  519. #define _HASH@ia_k(%0)(%8) _DOHASH@ia(75,%0)(%8)
  520. #define _HASH@ia_l(%0)(%8) _DOHASH@ia(76,%0)(%8)
  521. #define _HASH@ia_m(%0)(%8) _DOHASH@ia(77,%0)(%8)
  522. #define _HASH@ia_n(%0)(%8) _DOHASH@ia(78,%0)(%8)
  523. #define _HASH@ia_o(%0)(%8) _DOHASH@ia(79,%0)(%8)
  524. #define _HASH@ia_p(%0)(%8) _DOHASH@ia(80,%0)(%8)
  525. #define _HASH@ia_q(%0)(%8) _DOHASH@ia(81,%0)(%8)
  526. #define _HASH@ia_r(%0)(%8) _DOHASH@ia(82,%0)(%8)
  527. #define _HASH@ia_s(%0)(%8) _DOHASH@ia(83,%0)(%8)
  528. #define _HASH@ia_t(%0)(%8) _DOHASH@ia(84,%0)(%8)
  529. #define _HASH@ia_u(%0)(%8) _DOHASH@ia(85,%0)(%8)
  530. #define _HASH@ia_v(%0)(%8) _DOHASH@ia(86,%0)(%8)
  531. #define _HASH@ia_w(%0)(%8) _DOHASH@ia(87,%0)(%8)
  532. #define _HASH@ia_x(%0)(%8) _DOHASH@ia(88,%0)(%8)
  533. #define _HASH@ia_y(%0)(%8) _DOHASH@ia(89,%0)(%8)
  534. #define _HASH@ia_z(%0)(%8) _DOHASH@ia(90,%0)(%8)
  535. // String end.
  536. #define _HASH@ia_@(%0)(%8) %8