summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-05-02 22:15:35 +0200
committerPhilipp Gesang <phg42.2a@gmail.com>2013-05-02 22:15:35 +0200
commitc5837a5e38f2324ce7960840b609c290337ff160 (patch)
tree1cf5657c28e3620e7261aa89940f1cadf908407f
parent9bc0be2978b9c87eaf111d93339378a9e3b5bbc9 (diff)
downloadluatexbase-c5837a5e38f2324ce7960840b609c290337ff160.tar.gz
add warning if ``get_user_whatsit_name`` is called with unknown id
another of Stephan Hennig’s suggestions
-rw-r--r--luatexbase-attr.dtx10
1 files changed, 9 insertions, 1 deletions
diff --git a/luatexbase-attr.dtx b/luatexbase-attr.dtx
index 54c26f7..60ca026 100644
--- a/luatexbase-attr.dtx
+++ b/luatexbase-attr.dtx
@@ -560,6 +560,9 @@ luatexbase.get_user_whatsit_id = get_user_whatsit_id
% whatsit in question. First return value is the whatsit name, the second
% the package identifier it was registered with.
%
+% We issue a warning and return empty strings in case the asked whatsit is
+% unregistered.
+%
% \begin{macrocode}
--- int | node -> (string, string)
local get_user_whatsit_name = function (asked)
@@ -569,7 +572,12 @@ local get_user_whatsit_name = function (asked)
else --- node
id = asked.user_id
end
- return tableunpack(whatsit_ids[id])
+ local metadata = whatsit_ids[id]
+ if not metadata then -- unknown
+ warning("whatsit id %d unregistered; inconsistencies may arise", id)
+ return "", ""
+ end
+ return tableunpack(metadata)
end
luatexbase.get_user_whatsit_name = get_user_whatsit_name
% \end{macrocode}