On Tue, 25 Jul 2023 at 16:21, Werner LEMBERG <w...@gnu.org> wrote:

>
> In `luatex.pdf` (version 1.16 from April 2023), page 142, field
> `link_attr` of the `pdf_start_link` whatsit is described as being of
> type 'table'.  Is this correct?  It rather seems to me that it is of
> type 'string', at least according to what `debugger.lua` reports...
>
>
>     Werner
>

Both, I guess:

pdf_link_attr(n) = nodelib_gettoks(L, 3)
#define nodelib_gettoks(L,a)   tokenlist_from_lua(L, a)

int tokenlist_from_lua(lua_State * L, int index)
{
    const char *s;
    int tok, t;
    size_t i, j;
    halfword p, q, r;
    r = get_avail();
    token_info(r) = 0;
    token_link(r) = null;
    p = r;
    t = lua_type(L, index);
    if (t == LUA_TTABLE) {
        j = lua_rawlen(L, index);
        if (j > 0) {
            for (i = 1; i <= j; i++) {
                lua_rawgeti(L, index, (int) i);
                tok = token_from_lua(L);
                if (tok >= 0) {
                    store_new_token(tok);
                }
                lua_pop(L, 1);
            };
        }
        return r;
    } else if (t == LUA_TSTRING) {
        s = lua_tolstring(L, index, &j);
        for (i = 0; i < j; i++) {
            if (s[i] == 32) {
                tok = token_val(10, s[i]);
            } else {
                int j1 = (int) str2uni((const unsigned char *) (s + i));
                i = i + (size_t) (utf8_size(j1) - 1);
                tok = token_val(12, j1);
            }
            store_new_token(tok);
        }
        return r;
    } else {
        free_avail(r);
        return null;
    }
}

 --
luigi

Reply via email to