changeset 362:d858ad223646 plus

handle missed negative case
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Thu, 19 Mar 2026 17:23:33 +0000
parents 97e049b06f69
children d921f4a569d8
files lib/python/cc/lmh/shrink_key.py
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lib/python/cc/lmh/shrink_key.py	Thu Mar 19 17:21:51 2026 +0000
+++ b/lib/python/cc/lmh/shrink_key.py	Thu Mar 19 17:23:33 2026 +0000
@@ -20,14 +20,17 @@
 
 def shrink_key(seg: int, fileno: int, offset: int, lm: int) -> tuple[bytes,bytes]:
   lmb: bytes
-  if (lm >= 0 and lm <= 2147483647):
-    lmb=int.to_bytes(lm,4)
+  if lm >= 0:
+    if lm <= 2147483647:
+      lmb = int.to_bytes(lm, 4)
+    else:
+      lmb = LAST_DATE
   else:
     if lm < -2147483647:
       lmb = FIRST_DATE
-    if lm > 2147483647:
-      lmb = LAST_DATE
-  #print(nd,uri[4:],file=sys.stderr)
+    else:
+      lmb = int.to_bytes(lm, 4, signed=True)
+
   return (int.to_bytes(seg,1)+int.to_bytes(fileno,2)+int.to_bytes(offset,4),lmb)
 
 def shrink_date(wdate: bytes, dp: bytes) -> bytes: