Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/gumbo-parser/genperf.py @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 import sys, re | |
| 2 | |
| 3 gperf_output = sys.stdin.read() | |
| 4 | |
| 5 hash_func = re.search( | |
| 6 "static unsigned int\s+hash\s+\((.*?)\)\s{(.*?)\n}", | |
| 7 gperf_output, re.DOTALL) | |
| 8 | |
| 9 if not hash_func: | |
| 10 raise "Failed to detect hash function in GPerf output" | |
| 11 | |
| 12 wordlist = re.search( | |
| 13 "wordlist\[\]\s+=\s+{(.*?)}", | |
| 14 gperf_output, re.DOTALL) | |
| 15 | |
| 16 if not wordlist: | |
| 17 raise "Failed to detect word list in GPerf output" | |
| 18 | |
| 19 def process_wordlist(text): | |
| 20 wordlist = [w.strip().replace('"', '') for w in text.split(',')] | |
| 21 taglist = [ | |
| 22 "\tGUMBO_TAG_" + (w.upper().replace('-', '_') if w else 'LAST') | |
| 23 for w in wordlist] | |
| 24 return taglist | |
| 25 | |
| 26 print "static unsigned int tag_hash(%s)\n{%s\n}" % ( | |
| 27 hash_func.group(1), hash_func.group(2)) | |
| 28 print "" | |
| 29 print "static const unsigned char kGumboTagMap[] = {\n%s\n};" % ( | |
| 30 ',\n'.join(process_wordlist(wordlist.group(1)))) |
