Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
Ulrich Drepper committed Dec 5, 2006
1 parent 30a58e6 commit f0d5e1f
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 14 deletions.
14 changes: 14 additions & 0 deletions 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.
Expand Down
2 changes: 1 addition & 1 deletion io/Makefile
Expand Up @@ -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

Expand Down
42 changes: 42 additions & 0 deletions 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;
}
6 changes: 6 additions & 0 deletions 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.
Expand Down
4 changes: 2 additions & 2 deletions localedata/locales/cs_CZ
Expand Up @@ -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>"

Expand Down
2 changes: 1 addition & 1 deletion nis/nis_subr.c
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions sysdeps/unix/sysv/linux/ttyname.c
Expand Up @@ -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>
Expand Down Expand Up @@ -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';
Expand Down
11 changes: 6 additions & 5 deletions sysdeps/unix/sysv/linux/ttyname_r.c
Expand Up @@ -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>
Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit f0d5e1f

Please sign in to comment.