NetBSD-Bugs archive

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

standards/39422: missing guards for wcslcat(), wcslcpy(), wcswidth() & wcwidth()

>Number:         39422
>Category:       standards
>Synopsis:       missing guards for wcslcat(), wcslcpy(), wcswidth() & wcwidth()
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    standards-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 28 10:00:01 +0000 2008
>Release:        NetBSD 4.0
System: NetBSD tiger 4.0 NetBSD 4.0 (GENERIC) #1: Thu Dec 27 15:39:36 CET 2007
Architecture: i386
Machine: i386
If _ISOC99_SOURCE macro is defined the definition of wcslcpy(),
wcslcat(), wcswidth() and wcwidth() is visible.  Thus it is unhandy
to use such definitions for basic portability checks.

More appropriate would be a behaviour that is given by other include
files where _NETBSD_SOURCE or the corresponding _POSIX_C_SOURCE macro
definitions have to be given to include wcslcpy()/wcslcat() resp.

The included fix should correct this.
The following code should compile fine, but doesn't because wcslcpy()'s
definition is visible.

#define _ISOC99_SOURCE
#include <wchar.h>

    /* foo */
--- wchar.h.orig        2008-08-28 10:16:03.000000000 +0200
+++ wchar.h     2008-08-28 10:22:44.000000000 +0200
@@ -132,11 +132,15 @@
 wchar_t        *wmemmove(wchar_t *, const wchar_t *, size_t);
 wchar_t        *wmemset(wchar_t *, wchar_t, size_t);
+#if defined(_NETBSD_SOURCE)
 size_t wcslcat(wchar_t *, const wchar_t *, size_t);
 size_t wcslcpy(wchar_t *, const wchar_t *, size_t);
+#if defined(_NETBSD_SOURCE) || (_POSIX_C_SOURCE - 0 >= 200112L)
 int    wcswidth(const wchar_t *, size_t);
-int    wctob(wint_t);
 int    wcwidth(wchar_t);
+int    wctob(wint_t);
 unsigned long int wcstoul(const wchar_t * __restrict,
        wchar_t ** __restrict, int);


Home | Main Index | Thread Index | Old Index