aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-rw-r--r--io/Makefile2
-rw-r--r--io/tst-ttyname_r.c42
-rw-r--r--localedata/ChangeLog6
-rw-r--r--localedata/locales/cs_CZ4
-rw-r--r--nis/nis_subr.c2
-rw-r--r--sysdeps/unix/sysv/linux/ttyname.c11
-rw-r--r--sysdeps/unix/sysv/linux/ttyname_r.c11
8 files changed, 78 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 6de3915..f24045e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2006-12-05 Jakub Jelinek <jakub@redhat.com>
+
+ * nis/nis_subr.c (nis_getnames): Revert last change.
+
+2006-12-04 Jakub Jelinek <jakub@redhat.com>
+
+ * 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 <kkojima@rr.iij4u.or.jp>
* sysdeps/unix/sysv/linux/sh/sys/io.h: Removed.
diff --git a/io/Makefile b/io/Makefile
index 4aadfbc..18287b2 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 0000000..8e2f30c
--- /dev/null
+++ b/io/tst-ttyname_r.c
@@ -0,0 +1,42 @@
+#include <errno.h>
+#include <error.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+
+static void do_prepare (void);
+#define PREPARE(argc, argv) do_prepare ()
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#include <test-skeleton.c>
+
+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 2d13f94..85b2d79 100644
--- a/localedata/ChangeLog
+++ b/localedata/ChangeLog
@@ -1,3 +1,9 @@
+2006-12-05 Jakub Jelinek <jakub@redhat.com>
+
+ * 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 <drepper@redhat.com>
* locales/mai_IN: New file.
diff --git a/localedata/locales/cs_CZ b/localedata/locales/cs_CZ
index 9667700..5d27918 100644
--- a/localedata/locales/cs_CZ
+++ b/localedata/locales/cs_CZ
@@ -2440,9 +2440,9 @@ abmon "<U006C><U0065><U0064>";/
week 7;19971201;4
-d_t_fmt "<U0025><U0061><U00A0><U0025><U0065><U002E><U00A0><U0025><U0042><U00A0><U0025><U0059><U002C><U00A0><U0025><U0048><U003A><U0025><U004D><U003A><U0025><U0053><U00A0><U0025><U005A>"
+d_t_fmt "<U0025><U0061><U00A0><U0025><U002D><U0064><U002E><U00A0><U0025><U0042><U00A0><U0025><U0059><U002C><U00A0><U0025><U0048><U003A><U0025><U004D><U003A><U0025><U0053><U00A0><U0025><U005A>"
-d_fmt "<U0025><U0064><U002E><U0025><U006D><U002E><U0025><U0059>"
+d_fmt "<U0025><U002D><U0064><U002E><U0025><U002D><U006D><U002E><U0025><U0059>"
t_fmt "<U0025><U0048><U003A><U0025><U004D><U003A><U0025><U0053>"
diff --git a/nis/nis_subr.c b/nis/nis_subr.c
index 258479c..c68189e 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 aed0fd8..1b79787 100644
--- a/sysdeps/unix/sysv/linux/ttyname.c
+++ b/sysdeps/unix/sysv/linux/ttyname.c
@@ -22,6 +22,7 @@
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <termios.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
@@ -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 bd415f1..cef8624 100644
--- a/sysdeps/unix/sysv/linux/ttyname_r.c
+++ b/sysdeps/unix/sysv/linux/ttyname_r.c
@@ -22,6 +22,7 @@
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <termios.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
@@ -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';