From d575aeff5dc21fdb66c5f8c589bf5e694d320ea9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= <mpg@elzevir.fr>
Date: Fri, 5 Nov 2010 00:19:30 +0100
Subject: make priority_in_callback bhave as the doc says

---
 luatexbase-mcb.dtx | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

(limited to 'luatexbase-mcb.dtx')

diff --git a/luatexbase-mcb.dtx b/luatexbase-mcb.dtx
index 21786a3..c8c23b0 100644
--- a/luatexbase-mcb.dtx
+++ b/luatexbase-mcb.dtx
@@ -566,7 +566,7 @@ function add_to_callback (name,func,description,priority)
           name)
         return
     end
-    if priority_in_callback(name, description) ~= 0 then
+    if priority_in_callback(name, description) then
         warning("function '%s' already registered\nin callback '%s'",
           description, name)
     end
@@ -753,20 +753,20 @@ function priority_in_callback (name, description)
     if not name or name == ""
             or not callbacktypes[name]
             or not description then
-        return 0
+        return false
     end
     local l = callbacklist[name]
-    if not l then return 0 end
+    if not l then return false end
     for p, f in pairs(l) do
         if f.description == description then
             return p
         end
     end
-    return 0
+    return false
 end
 %    \end{macrocode}
 %
-%    Finally, overwrite \code{callback.register} so that bails out in error.
+%    Finally, overwrite |callback.register| so that bails out in error.
 %
 %    \begin{macrocode}
 callback.register = function ()
@@ -799,11 +799,11 @@ end
   luatexbase.add_to_callback("hpack_filter", sample, "sample function one", 1)
   luatexbase.add_to_callback("hpack_filter", sample, "sample function two", 2)
   luatexbase.add_to_callback("hpack_filter", sample, "sample function three", 1)
-  texio.write_nl(prio("hpack_filter", "sample function three"))
+  assert(prio("hpack_filter", "sample function three"))
   luatexbase.remove_from_callback("hpack_filter", "sample function three")
-  texio.write_nl(prio("hpack_filter", "sample function three"))
+  assert(not prio("hpack_filter", "sample function three"))
   luatexbase.reset_callback("hpack_filter")
-  texio.write_nl(prio("hpack_filter", "sample function one"))
+  assert(not prio("hpack_filter", "sample function one"))
 
   local function data_one(s)
     texio.write_nl("I'm data 1 whith argument: "..s)
@@ -818,7 +818,6 @@ end
     return s
   end
 
---[[
   luatexbase.create_callback("fooback", "data", data_one)
   luatexbase.call_callback("fooback", "default")
   luatexbase.add_to_callback("fooback", data_two, "my sample function two", 2)
@@ -828,7 +827,6 @@ end
   luatexbase.call_callback("fooback", "all but three")
   luatexbase.reset_callback("fooback")
   luatexbase.call_callback("fooback", "default")
-  --]]
 }
 %</testplain,testlatex>
 %<testplain>\bye
-- 
cgit v1.2.3

