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

Bug#458749: strtod("INFINITY", &e) under tr_TR locale.



Package: libc6
Version: 2.3.6.ds1-13etch2

I found that strtod doesn't accept "INFINITY" under tr_TR
locale.

% cat strtod.c
#include <stdio.h>
#include <ctype.h>
#include <locale.h>
#include <stdlib.h>
#include <errno.h>

int main(int argc, char **argv)
{
  int i;
  double ret;
  char *e = NULL;

  setlocale(LC_ALL, "");

  errno = 0;
  ret = strtod(argv[1], &e);
  if (errno != 0) { perror("strtol"); }
  printf("%.18f [%s]\n", ret, e);
  return 0;
}
% gcc strtod.c               
% LANG=tr_TR ./a.out INFINITY
0,000000000000000000 [INFINITY]

It returns 0.0 and the string is not converted.

% LANG=C ./a.out INFINITY
inf []

It returns inf consumes "INFINITY" under C locale.

It is caused by Turkish case conversion rule.

strtod(3) has a description about the case of INFINITY as follows.

|        An infinity is either ``INF'' or ``INFINITY'', disregarding case.

I think it is not intentional to reject "INFINITY" under
tr_TR locale.

% dpkg -l|grep libc6
ii  libc6                            2.3.6.ds1-13etch2                        GNU C Library: Shared libraries
ii  libc6-dev                        2.3.6.ds1-13etch2                        GNU C Library: Development Libraries and Hea
ii  libc6-i686                       2.3.6.ds1-13etch2                        GNU C Library: Shared libraries [i686 optimi
-- 
Tanaka Akira



Reply to: