Feature #5346

locale independant strto* missing (as well as their wchar variants)

Added by Richard PALO over 4 years ago. Updated over 2 years ago.

Status:NewStart date:2014-11-15
Priority:NormalDue date:
Assignee:-% Done:


Target version:-
Difficulty:Medium Tags:needs-triage


The following seem to be "missing" :


Apparently they are gNUlib functions as opposed to POSIX.

NetBSD defines these (plus some additions) as

#if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE)
typedef struct _locale      *locale_t;
#  endif
double      strtod_l(const char * __restrict, char ** __restrict, locale_t);
float       strtof_l(const char * __restrict, char ** __restrict, locale_t);
long double strtold_l(const char * __restrict, char ** __restrict,
long     strtol_l(const char * __restrict, char ** __restrict, int, locale_t);
unsigned long
     strtoul_l(const char * __restrict, char ** __restrict, int, locale_t);
long long int
    strtoll_l(const char * __restrict, char ** __restrict, int, locale_t);
unsigned long long int
    strtoull_l(const char * __restrict, char ** __restrict, int, locale_t);


#if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE)
typedef struct _locale      *locale_t;
#  endif
size_t  mbsnrtowcs(wchar_t * __restrict, const char ** __restrict, size_t,
        size_t, mbstate_t * __restrict);
size_t  wcsnrtombs(char * __restrict, const wchar_t ** __restrict, size_t,
        size_t, mbstate_t * __restrict);

int wcscoll_l(const wchar_t *, const wchar_t *, locale_t);
size_t  wcsxfrm_l(wchar_t *, const wchar_t *, size_t, locale_t);
int wcsncasecmp_l(const wchar_t *, const wchar_t *, size_t, locale_t);
int wcscasecmp_l(const wchar_t *, const wchar_t *, locale_t);

size_t  wcsftime_l(wchar_t * __restrict, size_t, const wchar_t * __restrict,
        const struct tm * __restrict, locale_t);

float wcstof_l(const wchar_t * __restrict, wchar_t ** __restrict, locale_t);
double wcstod_l(const wchar_t * __restrict, wchar_t ** __restrict, locale_t);
long double wcstold_l(const wchar_t * __restrict, wchar_t ** __restrict,
long int wcstol_l(const wchar_t * __restrict, wchar_t ** __restrict, int,
unsigned long int wcstoul_l(const wchar_t * __restrict,
    wchar_t ** __restrict, int, locale_t);
long long int wcstoll_l(const wchar_t * __restrict, wchar_t ** __restrict, int,
unsigned long long int wcstoull_l(const wchar_t * __restrict,
                  wchar_t ** __restrict, int, locale_t);
int wcwidth_l(wchar_t, locale_t);
int wcswidth_l(const wchar_t *, size_t, locale_t);


#1 Updated by Garrett D'Amore about 4 years ago

These functions are not part of the POSIX specification, but are BSD additions (really inherited from Darwin I believe).

On the one hand, it seems like they would be convenient. But on the other hand, I'm moderately opposed to polluting the namespace with symbols that aren't part of standards yet -- it causes grief later if POSIX adopts a different definition.

Are there applications that actually need these symbols? Would their presence help application portability?

#2 Updated by Richard PALO about 4 years ago

As these were gnulib and not POSIX, I tabled working further on the packages when I posted the issue (a placeholder for discussion).
If I come across them or any other cases again, I'll drop mention here. thx

#3 Updated by Igor Kozhukhov over 2 years ago

try to build guile-2.0 , debian package guile-2.0-2.0.11+1 and build failed with:

gcc -DHAVE_CONFIG_H   -DBUILDING_LIBGUILE=1 -I.. -I.. -I../lib -I../lib  -I/myshare/builds7/dilos/dg-git/components/guile-2.0/d/guile-2.0-2.0.11+1.orig -D__USE_LEGACY_PROTOTYPES__ -D_REENTRANT -pthreads -Wall -Wmissing-prototypes -Wdeclaration-after-statement -Wpointer-arith -Wswitch-enum -fno-strict-aliasing -fwrapv -fvisibility=hidden -g -O2 -DPACKAGE_PACKAGER='"Debian"' -DPACKAGE_PACKAGER_VERSION='"2.0.11-deb+1-10"' -DPACKAGE_PACKAGER_BUG_REPORTS='"http://www.debian.org/Bugs/Reporting"' -m64 -c -o guile-guile.o `test -f 'guile.c' || echo './'`guile.c
/bin/sh ../libtool  --tag=CC   --mode=link gcc -D_REENTRANT -pthreads -Wall -Wmissing-prototypes -Wdeclaration-after-statement -Wpointer-arith -Wswitch-enum -fno-strict-aliasing -fwrapv -fvisibility=hidden -g -O2 -DPACKAGE_PACKAGER='"Debian"' -DPACKAGE_PACKAGER_VERSION='"2.0.11-deb+1-10"' -DPACKAGE_PACKAGER_BUG_REPORTS='"http://www.debian.org/Bugs/Reporting"' -m64 -D_REENTRANT -pthreads  -o guile guile-guile.o libguile-2.0.la -lsocket -lnsl -lm 
libtool: link: gcc -D_REENTRANT -pthreads -Wall -Wmissing-prototypes -Wdeclaration-after-statement -Wpointer-arith -Wswitch-enum -fno-strict-aliasing -fwrapv -fvisibility=hidden -g -O2 "-DPACKAGE_PACKAGER=\"Debian\"" "-DPACKAGE_PACKAGER_VERSION=\"2.0.11-deb+1-10\"" "-DPACKAGE_PACKAGER_BUG_REPORTS=\"http://www.debian.org/Bugs/Reporting\"" -m64 -D_REENTRANT -pthreads -o .libs/guile guile-guile.o  ./.libs/libguile-2.0.so -L/usr/lib/amd64 -lgc -lffi -lunistring -liconv -lgmp -lltdl -lsocket -lnsl -lm -pthreads -R/usr/lib/amd64
Undefined                       first referenced
 symbol                             in file
strtod_l                            ./.libs/libguile-2.0.so
strtol_l                            ./.libs/libguile-2.0.so
ld: fatal: symbol referencing errors. No output written to .libs/guile
collect2: error: ld returned 1 exit status

what will be workaround for it?
will be better to see it implemented in illumos because Linux and BSD not failed with these function, but illumos does.

#4 Updated by Richard PALO over 2 years ago

You may wish to try 2.0.12 (which is the version building fine in pkgsrc).
The changelog indicates patches to check for these (including one from Andy).

But since a test case came by again, I'm all for the implementation of these functions!

Also available in: Atom