This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

suspicious uses of RETURN in obsolete <regexp.h>


In the <regexp.h> header file, which is kept in CVS as
<http://sourceware.org/cgi-bin/cvsweb.cgi/libc/misc/regexp.h?rev=1.13&content-type=text/x-cvsweb-markup&cvsroot=glibc>,
the compile function ends like this:

>       case REG_ERANGE:
>         RETURN (11);
>       case REG_ESPACE:
>       case REG_ESIZE:
>         ERROR (50);
>       }
>
>   /* Everything is ok.  */
>   RETURN ((char *) (__expr_ptr->__REPB_PREFIX (buffer)
>                     + __expr_ptr->__REPB_PREFIX (used)));
> }

Apparently, the argument of the RETURN macro can be either a
pointer or a small integer constant.  However, SUSv2 stipulates:

# RETURN(ptr)
#         This macro is used on normal exit of the compile()
#         function. The value of the argument ptr is a pointer to
#         the character after the last character of the compiled
#         regular expression. This is useful to programs that
#         have memory allocation to manage.

So the RETURN (11); statement and similar ones earlier in the
function don't seem conforming to me.  I suspect they should all
be changed to ERROR.

Alternatively, the entire <regexp.h> could perhaps be removed.

Attachment: pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]