From f0d5e1f67bf5d856f7dad926746ca7170560e65f Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 5 Dec 2006 21:28:15 +0000 Subject: * nis/nis_subr.c (nis_getnames): Revert last change. 2006-12-04 Jakub Jelinek * sysdeps/unix/sysv/linux/ttyname.c: Include termios.h. (ttyname): Use tcgetattr instead of isatty, don't set errno to ENOTTY. * sysdeps/unix/sysv/linux/ttyname_r.c: Include termios.h. (__ttyname_r): Use tcgetattr instead of isatty, don't set errno to ENOTTY. * io/Makefile: Add rules to build and run tst-ttyname_r test. * io/tst-ttyname_r.c: New test. --- ChangeLog | 14 +++++++++++++ io/Makefile | 2 +- io/tst-ttyname_r.c | 42 +++++++++++++++++++++++++++++++++++++ localedata/ChangeLog | 6 ++++++ localedata/locales/cs_CZ | 4 ++-- nis/nis_subr.c | 2 +- sysdeps/unix/sysv/linux/ttyname.c | 11 +++++----- sysdeps/unix/sysv/linux/ttyname_r.c | 11 +++++----- 8 files changed, 78 insertions(+), 14 deletions(-) create mode 100644 io/tst-ttyname_r.c diff --git a/ChangeLog b/ChangeLog index 6de39155ae..f24045e3e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2006-12-05 Jakub Jelinek + + * nis/nis_subr.c (nis_getnames): Revert last change. + +2006-12-04 Jakub Jelinek + + * sysdeps/unix/sysv/linux/ttyname.c: Include termios.h. + (ttyname): Use tcgetattr instead of isatty, don't set errno to ENOTTY. + * sysdeps/unix/sysv/linux/ttyname_r.c: Include termios.h. + (__ttyname_r): Use tcgetattr instead of isatty, don't set errno to + ENOTTY. + * io/Makefile: Add rules to build and run tst-ttyname_r test. + * io/tst-ttyname_r.c: New test. + 2006-12-03 Kaz Kojima * sysdeps/unix/sysv/linux/sh/sys/io.h: Removed. diff --git a/io/Makefile b/io/Makefile index 4aadfbca01..18287b201a 100644 --- a/io/Makefile +++ b/io/Makefile @@ -66,7 +66,7 @@ tests := test-utime test-stat test-stat2 test-lfs tst-getcwd \ tst-openat tst-unlinkat tst-fstatat tst-futimesat \ tst-renameat tst-fchownat tst-fchmodat tst-faccessat \ tst-symlinkat tst-linkat tst-readlinkat tst-mkdirat \ - tst-mknodat tst-mkfifoat + tst-mknodat tst-mkfifoat tst-ttyname_r distribute := ftwtest-sh diff --git a/io/tst-ttyname_r.c b/io/tst-ttyname_r.c new file mode 100644 index 0000000000..8e2f30c972 --- /dev/null +++ b/io/tst-ttyname_r.c @@ -0,0 +1,42 @@ +#include +#include +#include +#include +#include + +static void do_prepare (void); +#define PREPARE(argc, argv) do_prepare () +static int do_test (void); +#define TEST_FUNCTION do_test () +#include + +static int temp_fd; + +static void +do_prepare (void) +{ + char *temp_file; + temp_fd = create_temp_file ("tst-ttyname_r.", &temp_file); + if (temp_fd == -1) + error (1, errno, "cannot create temporary file"); +} + +static int +do_test (void) +{ + int ret = 0; + char buf[sysconf (_SC_TTY_NAME_MAX) + 1]; + int res = ttyname_r (-1, buf, sizeof (buf)); + if (res != EBADF) + { + printf ("1st ttyname_r returned with res %d\n", res); + ret++; + } + res = ttyname_r (temp_fd, buf, sizeof (buf)); + if (res != ENOTTY) + { + printf ("2nd ttyname_r returned with res %d\n", res); + ret++; + } + return ret; +} diff --git a/localedata/ChangeLog b/localedata/ChangeLog index 2d13f941dd..85b2d7948d 100644 --- a/localedata/ChangeLog +++ b/localedata/ChangeLog @@ -1,3 +1,9 @@ +2006-12-05 Jakub Jelinek + + * locales/cs_CZ (LC_TIME): Change d_fmt to %e.%m.%Y from %-d.%-m.%Y. + Change d_t_fmt to %a %-d. %B %Y, %H:%M:%S %Z from + %a %e. %B %Y, %H:%M:%S %Z. + 2006-11-02 Ulrich Drepper * locales/mai_IN: New file. diff --git a/localedata/locales/cs_CZ b/localedata/locales/cs_CZ index 9667700a93..5d279187eb 100644 --- a/localedata/locales/cs_CZ +++ b/localedata/locales/cs_CZ @@ -2440,9 +2440,9 @@ abmon "";/ week 7;19971201;4 -d_t_fmt "" +d_t_fmt "" -d_fmt "" +d_fmt "" t_fmt "" diff --git a/nis/nis_subr.c b/nis/nis_subr.c index 258479c857..c68189e541 100644 --- a/nis/nis_subr.c +++ b/nis/nis_subr.c @@ -178,7 +178,7 @@ nis_getnames (const_nis_name name) } /* Get the search path, where we have to search "name" */ - path = __secure_getenv ("NIS_PATH"); + path = getenv ("NIS_PATH"); if (path == NULL) path = strdupa ("$"); else diff --git a/sysdeps/unix/sysv/linux/ttyname.c b/sysdeps/unix/sysv/linux/ttyname.c index aed0fd8e0a..1b79787515 100644 --- a/sysdeps/unix/sysv/linux/ttyname.c +++ b/sysdeps/unix/sysv/linux/ttyname.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -118,12 +119,12 @@ ttyname (int fd) int dostat = 0; char *name; int save = errno; + struct termios term; - if (__builtin_expect (!__isatty (fd), 0)) - { - __set_errno (ENOTTY); - return NULL; - } + /* isatty check, tcgetattr is used because it sets the correct + errno (EBADF resp. ENOTTY) on error. */ + if (__builtin_expect (__tcgetattr (fd, &term) < 0, 0)) + return NULL; /* We try using the /proc filesystem. */ *_fitoa_word (fd, __stpcpy (procname, "/proc/self/fd/"), 10, 0) = '\0'; diff --git a/sysdeps/unix/sysv/linux/ttyname_r.c b/sysdeps/unix/sysv/linux/ttyname_r.c index bd415f167b..cef8624dc6 100644 --- a/sysdeps/unix/sysv/linux/ttyname_r.c +++ b/sysdeps/unix/sysv/linux/ttyname_r.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -115,11 +116,11 @@ __ttyname_r (int fd, char *buf, size_t buflen) return ERANGE; } - if (__builtin_expect (!__isatty (fd), 0)) - { - __set_errno (ENOTTY); - return ENOTTY; - } + /* isatty check, tcgetattr is used because it sets the correct + errno (EBADF resp. ENOTTY) on error. */ + struct termios term; + if (__builtin_expect (__tcgetattr (fd, &term) < 0, 0)) + return errno; /* We try using the /proc filesystem. */ *_fitoa_word (fd, __stpcpy (procname, "/proc/self/fd/"), 10, 0) = '\0'; -- cgit v1.2.3