--- rxvt-unicode/src/ptytty.C 2004/08/15 03:30:04 1.16 +++ rxvt-unicode/src/ptytty.C 2006/01/02 15:10:18 1.26 @@ -48,10 +48,15 @@ #ifdef HAVE_ISASTREAM # include #endif +#ifdef HAVE_PTY_H +# include +#endif -#if defined( __FreeBSD__) // better do this via configure, but.... +#if defined(__FreeBSD__) # include +#elif defined(__DARWIN__) || (defined (__MACH__) && defined (__APPLE__)) +# include #endif #include @@ -87,7 +92,6 @@ #endif #ifdef PTYS_ARE_GETPTY - char *ptydev; while ((ptydev = getpty ()) != NULL) @@ -331,33 +335,36 @@ void rxvt_ptytty::privileges (rxvt_privaction action) { + if (!name || !*name) + return; + rxvt_privileges (RESTORE); if (action == SAVE) { - //next_tty_action = RESTORE; # ifndef RESET_TTY_TO_COMMON_DEFAULTS /* store original tty status for restoration rxvt_clean_exit () -- rgg 04/12/95 */ if (lstat (name, &savestat) < 0) /* you lose out */ - ;//next_tty_action = IGNORE; + ; else # endif - { + saved = true; chown (name, getuid (), ttyconf.gid); /* fail silently */ chmod (name, ttyconf.mode); # ifdef HAVE_REVOKE revoke (name); # endif - } } else { /* action == RESTORE */ - //next_tty_action = IGNORE; # ifndef RESET_TTY_TO_COMMON_DEFAULTS - chmod (name, savestat.st_mode); - chown (name, savestat.st_uid, savestat.st_gid); + if (saved) + { + chmod (name, savestat.st_mode); + chown (name, savestat.st_uid, savestat.st_gid); + } # else chmod (name, (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)); chown (name, 0, 0); @@ -373,6 +380,9 @@ { pty = tty = -1; name = 0; +#ifndef NO_SETOWNER_TTYDEV + saved = false; +#endif } rxvt_ptytty::~rxvt_ptytty () @@ -436,5 +446,32 @@ return true; } +void +rxvt_ptytty::set_utf8_mode (bool on) +{ +#ifdef IUTF8 + if (pty != -1) + { + struct termios tio; + + if (tcgetattr (pty, &tio) != -1) + { + tcflag_t new_cflag = tio.c_iflag; + + if (on) + new_cflag |= IUTF8; + else + new_cflag &= ~IUTF8; + + if (new_cflag != tio.c_iflag) + { + tio.c_iflag = new_cflag; + tcsetattr (pty, TCSANOW, &tio); + } + } + } +#endif +} + /*----------------------- end-of-file (C source) -----------------------*/