kkos/oniguruma

Documentation of onig_name_to_group_numbers is incorrect

alan-j-hu opened this issue · 1 comments

The documentation for onig_name_to_group_numbers claims that the function returns -1 when the name is not found:

oniguruma/doc/API

Lines 635 to 644 in 78ffad3

# int onig_name_to_group_numbers(regex_t* reg, const UChar* name, const UChar* name_end,
int** num_list)
Return the group number list of the name.
Named subexp is defined by (?<name>....).
return value
normal: number of groups for the name.
(ex. /(?<x>..)(?<x>..)/ ==> 2)
name not found: -1

However, it does not return -1:

  • oniguruma/src/regparse.c

    Lines 1170 to 1175 in 0517315

    onig_name_to_group_numbers(regex_t* reg, const UChar* name,
    const UChar* name_end, int** nums)
    {
    NameEntry* e = name_find(reg, name, name_end);
    if (IS_NULL(e)) return ONIGERR_UNDEFINED_NAME_REFERENCE;
  • #define ONIGERR_UNDEFINED_NAME_REFERENCE -217

I would make a PR to fix this, but I don't know Japanese and wouldn't be able to fix the Japanese docs...

kkos commented

Thank you. I will fix it.