This is the mail archive of the glibc-bugs@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]

[Bug regex/1236] regex.h violates POSIX name space rules in several places


------- Additional Comments From eggert at gnu dot org  2006-04-11 06:58 -------
I will attach a revised patch, now used in gnulib, which is much more
conservative.  The revised patch leaves almost all the names alone in
the normal case, and this addresses most of the objections.  If the
user compiles pedantically (e.g. by defining _POSIX_C_SOURCE), the
patched regex.h simply does not define the offending names; that
suffices to conform.

I didn't quite follow this objection, though:

> While true that this violates the name space, no other names are reserved
> either.

I take this to claim that names beginning with "re_" are not reserved.

However, XSI section 2.2.2 page 16 line 613
<http://www.opengroup.org/onlinepubs/000095399/functions/xsh_chap02_02.html>
says that <regex.h> implementations can define symbols with the
prefixes re_ and rm_, in the same sense that <errno.h> can define
symbols with the prefixes E[0-9A-Z].  Users therefore can't define
re_* and rm_* macros before including <regex.h>, just as they can't
define an E[0-9A-Z] macro before including <errno.h>.  So, in that
sense, the re_* and rm_* names are free for use within <regex.h>.
This may help to explain why Solaris 10 <regex.h> regex_t can have
members like "re_sc" and "re_len"; this is an allowed extension to the
standard.

PS.  For the record, the glibc <regex.h> identifiers that violate the
POSIX name space include macro names like
RE_BACKSLASH_ESCAPE_IN_LISTS, RE_SYNTAX_AWK, RE_DUP_MAX,
RE_TRANSLATE_TYPE, REGS_FIXED, and RE_NREGS; and member names like
buffer, allocated, start, and end.

For example, here is a program that strictly conforms to POSIX, and
works on Solaris 10, but doesn't work with glibc:

   #define _POSIX_C_SOURCE 200112L
   #define buffer 0
   #define start 0
   #include <regex.h>
   int RE_BACKSLASH_ESCAPE_IN_LISTS;
   int RE_SYNTAX_AWK;
   int RE_DUP_MAX;
   int RE_TRANSLATE_TYPE;
   int REGS_FIXED;
   int RE_NREGS;
   int main (void) { return 0; }


-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=1236

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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