8000 gh-131725: Generate GNU hash table in `msgfmt.py` by StanFromIreland · Pull Request #131727 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-131725: Generate GNU hash table in msgfmt.py #131727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Address feedback
  • Loading branch information
StanFromIreland committed Mar 30, 2025
commit a92e6f1fc4e680c234eaf94644a70dcfee7eca37
12 changes: 7 additions & 5 deletions Tools/i18n/msgfmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from email.parser import HeaderParser
import codecs

__version__ = "1.3"
__version__ = "1.2"


MESSAGES = {}
Expand Down Expand Up @@ -121,7 +121,7 @@ def hash_insert_entry(string, i):
voffsets += [l2, o2+valuestart]
offsets = koffsets + voffsets
output = struct.pack("Iiiiiii",
0x950412de, # Magic
0x950412de, # Magic
0, 8000 # Version
len(keys), # # of entries
7*4, # start of key index
Expand Down Expand Up @@ -292,14 +292,16 @@ def main():

# Utilities for writing hash table

def hashpjw(str_param):
# Peter J. Weinberger hash function
# See: https://www.drdobbs.com/database/hashing-rehashed/184409859
def hashpjw(strs):
hval = 0
for s in str_param:
for s in strs:
if not s:
break
hval <<= 4
hval += s
g = hval & 0xF << 28
g = hval & (0xF << 28)
if g:
hval ^= g >> 24
hval ^= g
Expand Down
Loading
0