From 00ba44f1939220af84ad885d1ba2f1f974bd7eb7 Mon Sep 17 00:00:00 2001
From: Philipp Gesang <phg42.2a@gmail.com>
Date: Thu, 2 May 2013 21:45:14 +0200
Subject: emit warning after 2^53 user whatsits

---
 luatexbase-attr.dtx | 6 ++++++
 1 file changed, 6 insertions(+)

(limited to 'luatexbase-attr.dtx')

diff --git a/luatexbase-attr.dtx b/luatexbase-attr.dtx
index 5a4960c..7c8f5b9 100644
--- a/luatexbase-attr.dtx
+++ b/luatexbase-attr.dtx
@@ -465,6 +465,7 @@ local user_whatsits       = {    --- (package, (name, id hash)) hash
     __unassociated = { },        --- those without package name
 }
 local whatsit_ids         = { }  --- (id, (name * package)) hash
+local whatsit_cap         = 2^53 --- Lua numbers are doubles
 local current_whatsit     = 0
 local anonymous_whatsits  = 0
 local anonymous_prefix    = "anon"
@@ -509,6 +510,11 @@ local new_user_whatsit_id = function (name, package)
         warning("replacing whatsit %s:%s (%d)", package, name, id)
     else --- new id
         current_whatsit     = current_whatsit + 1
+        if current_whatsit >= whatsit_cap then
+            warning("maximum of %d integral user whatsit ids reached",
+                whatsit_cap)
+            warning("further whatsit allocation may be inconsistent")
+        end
         id                  = current_whatsit
         whatsitdata[name]   = id
         whatsit_ids[id]     = { name, package }
-- 
cgit v1.2.3

