bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

cannot build mbrtowc if EILSEQ not defined...


From: Joel Brobecker
Subject: cannot build mbrtowc if EILSEQ not defined...
Date: Fri, 7 Sep 2012 12:01:05 -0700
User-agent: Mutt/1.5.20 (2009-06-14)

Hello,

I was trying to cross-compile mbrtowc for a system where EILSEQ
is not defined (C99). The first attempt I made was to import
the errno module, and see if it would define it for me. But no luck.

I am unsure about the best way to fix this issue. The simplest
approach, would probably to change mbrtowc (and other modules
using EILSEQ) to set errno to a different value if EILSEQ does not
exist. EINVAL comes to mind.

But perhaps that's not necessarily the most satisfactory answer.

Perhaps, we'd like to enhance the errno module to also provide
EILSEQ if not provided by the system. And in that case, which
value should we give? Should we give an arbitrarily high value
that should never collide with a value already used by the system?
Or use an already existing value? For instance, GNU libiconv sets
it to ENOENT ("because iconv() callers want to distinguish EINVAL and
EILSEQ).

The additional issue with EILSEQ is that the libiconv configure
macro used to decide whether or not to define EILSEQ indicates
that this macro is sometimes defined in wchar.h rather than in errno.h.
In that case, libiconv still defines EILSEQ, but using the same
value as in wchar.h.

I think gnulib should probably try to handle the situation in
the same way, which means I wouldn't be able to use the
gl_REPLACE_ERRNO_VALUE macro, as we do for other value such as
ENOLINK, for instance.

Any suggestion as to which direction I should take? Attached is
the simplest of simple patches... It's only a quick prototype,
but it has the advantage of being ultra simple and I verified it
fixes the problem at hand. But it could cause trouble on platforms
where wchar.h defines it, as we'd end up with conflicting values.
That's why I'd go with something similar to what libiconv does:

    # The EILSEQ errno value ought to be defined in <errno.h>, according to
    # ISO C 99 and POSIX.  But some systems (like SunOS 4) don't define it,
    # and some systems (like BSD/OS) define it in <wchar.h> not <errno.h>.

    # Define EILSEQ as a C macro and as a substituted macro in such a way that
    # 1. on all systems, after inclusion of <errno.h>, EILSEQ is usable,
    # 2. on systems where EILSEQ is defined elsewhere, we use the same numeric
    #    value.

see libiconv's m4/eilseq.m4 for the implementation of the AC_EILSEQ
macro. What we would do in gnulib is adapt that macro slightly to
fit EILSEQ using the same pattern as the other macros.

Thank you,
-- 
Joel

Attachment: errno-eilseq.diff
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]