Mercurial > hg > cc > cirrus_work
changeset 315:6c586bee6a50 trim
date-stamp OK, deal with OOB value, maybe
| author | Henry S. Thompson <ht@inf.ed.ac.uk> |
|---|---|
| date | Tue, 23 Dec 2025 20:08:26 +0000 |
| parents | 5c4d68911dd3 |
| children | 6c04c30c95d0 |
| files | lib/python/cc/lmh/shrink.py |
| diffstat | 1 files changed, 9 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/python/cc/lmh/shrink.py Tue Dec 23 17:14:19 2025 +0000 +++ b/lib/python/cc/lmh/shrink.py Tue Dec 23 20:08:26 2025 +0000 @@ -16,12 +16,12 @@ with open(ifn,'rb') as f, open(ofn,'wb') as of: for l in f: - of.write(l) + #of.write(l) (bb,od,oe) = l.rstrip().split(b':',2) (os1,os2)=bb[1:].split(b',') kl=int(os1) ll=int(os2) - print(od,dp,dpl,file=sys.stderr) + #print(od,dp,dpl,file=sys.stderr) for i in range(dpl): if od[i] != dp[i]: break @@ -31,16 +31,19 @@ nd = od[i:] else: nd = od - print(i,od,nd,file=sys.stderr) + #print(i,od,nd,file=sys.stderr) ol = oe[-ll:] nli = int(ol) - int.to_bytes(nli,4) - of.write(b'+%d,%d'%(kl-(len(od)-len(nd)),4)) + bad = (nli < 0 or nli > 2147483647) + of.write(b'+%d,%d'%(kl-(len(od)-len(nd)),len(ol) if bad else 4)) of.write(b':') of.write(nd) of.write(b':') of.write(oe[:-ll]) - of.write(int.to_bytes(nli,4)) + if bad: + of.write(ol) + else: + of.write(int.to_bytes(nli,4)) of.write(b'\n')
