Release 0.9.1-3 with RetroBrowser, PPC audio, XP diagnostics and LP64 repair
This commit is contained in:
26
upstream-adapter/fix-fixed-width.py
Normal file
26
upstream-adapter/fix-fixed-width.py
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Enforce legacy 32-bit wire/Bindery layouts on LP64; do not migrate live DBs."""
|
||||
from pathlib import Path
|
||||
import sys,re
|
||||
root=Path(sys.argv[1])
|
||||
p=root/'include/emutli.h';s=p.read_text()
|
||||
old='typedef unsigned long int uint32;'
|
||||
if old in s:s=s.replace(old,'#include <stdint.h>\ntypedef uint32_t uint32; /* MARS_FIXED_WIDTH_V1 */')
|
||||
elif 'MARS_FIXED_WIDTH_V1' not in s:raise SystemExit('Unsupported uint32 declaration')
|
||||
p.write_text(s)
|
||||
# Every long conversion in these sscanf calls targets the legacy uint32 typedef.
|
||||
for name in ['emutli.c','emutli1.c','nwserv.c','tools.c']:
|
||||
p=root/'src'/name;s=p.read_text()
|
||||
pattern=r'(sscanf\s*\([^;]+;)'
|
||||
def fix(m):
|
||||
call=m.group(0)
|
||||
# Only the known IPX/debug parser sites use long formats in this upstream.
|
||||
call=call.replace('%lx','%" SCNx32 "').replace('%ld','%" SCNu32 "')
|
||||
return call
|
||||
s=re.sub(pattern,fix,s)
|
||||
if '#include <inttypes.h>' not in s:s='#include <inttypes.h>\n'+s
|
||||
p.write_text(s)
|
||||
for name in ['nwroute.c','nwdbm.c']:
|
||||
p=root/'src'/name;s=p.read_text().replace('%08lX','%08" PRIX32 "')
|
||||
if '#include <inttypes.h>' not in s:s='#include <inttypes.h>\n'+s
|
||||
p.write_text(s)
|
||||
Reference in New Issue
Block a user