From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 1BEA81F8C6 for ; Sun, 8 Aug 2021 20:01:42 +0000 (UTC) Received: from localhost ([::1]:53756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mCozN-0000w3-0B for normalperson@yhbt.net; Sun, 08 Aug 2021 16:01:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36662) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCozK-0000vv-6s for bug-gnulib@gnu.org; Sun, 08 Aug 2021 16:01:38 -0400 Received: from mo4-p00-ob.smtp.rzone.de ([85.215.255.22]:35865) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCozI-0007iV-FG for bug-gnulib@gnu.org; Sun, 08 Aug 2021 16:01:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1628452893; s=strato-dkim-0002; d=clisp.org; h=Message-ID:Date:Subject:To:From:Cc:Date:From:Subject:Sender; bh=yEm/O9z/UhsJRrmgxFFqFMIHEWMfFULnYmCQ2QsAOKY=; b=nMAXRWjXJBMDipJpjoDR+yhhNTAaIwpfAGlsm0fQY9UF3fuHo0/ut97gg+HZq9MHSh eK3XbqRWDsfoi//PtAehnBXRkgE0EEphljjO5IYfEdvzfEcPjyjwgO7YCSDbv/qoP/8Q U2JEM55bnL8PIRV+ShZh2Ar7xJr9r2jRACAe9Nny7ZqJWUovr5ex+NIxpWOLUtrsqJaw EKmHCvanIqUOUxxNFkCC0pEMpNonV2vrh32OIZrn5P7igjOow/rP7bmHG783wfdTfiuW VabW2rqFTb0AnyKSX4NBGPMaln6b81cFrYpR+jrJbNa6h1piz3IWeiI/OmWryc97eF3j Zd6w== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH/DXj0JGsbh0vbrMZq" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 47.31.0 DYNA|AUTH) with ESMTPSA id I0a189x78K1WHsc (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Sun, 8 Aug 2021 22:01:32 +0200 (CEST) From: Bruno Haible To: bug-gnulib@gnu.org Subject: ptsname_r: Drop sync with glibc Date: Sun, 08 Aug 2021 22:01:32 +0200 Message-ID: <8151763.5YLNykMcqT@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-210-generic; KDE/5.18.0; x86_64; ; ) MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Received-SPF: none client-ip=85.215.255.22; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" The ptsname_r implementation in Gnulib and the ptsname and ptsname_r implementations in glibc have diverged over the years. Gnulib's lib/ptsname_r.c file bears no resemblence any more with any of the ptsname.c files in glibc. It was originally derived from glibc/sysdeps/unix/bsd/ptsname.c, which was deleted on 2013-12-17. 2021-08-08 Bruno Haible ptsname_r: Drop sync with glibc. * lib/ptsname_r.c: Drop _LIBC code. (__set_errno, __isatty, __stat, __ttyname_r, __ptsname_r): Remove macros. (ptsname_r): Rename local variable 'save_errno'. diff --git a/lib/ptsname_r.c b/lib/ptsname_r.c index 4043916..cca2215 100644 --- a/lib/ptsname_r.c +++ b/lib/ptsname_r.c @@ -16,6 +16,7 @@ #include +/* Specification. */ #include #include @@ -24,27 +25,11 @@ #include #include -#ifdef _LIBC -# include -#else -# ifndef _PATH_TTY -# define _PATH_TTY "/dev/tty" -# endif -# ifndef _PATH_DEV -# define _PATH_DEV "/dev/" -# endif - -# undef __set_errno -# undef __stat -# undef __ttyname_r -# undef __ptsname_r - -# define __set_errno(e) errno = (e) -# define __isatty isatty -# define __stat stat -# define __ttyname_r ttyname_r -# define __ptsname_r ptsname_r - +#ifndef _PATH_TTY +# define _PATH_TTY "/dev/tty" +#endif +#ifndef _PATH_DEV +# define _PATH_DEV "/dev/" #endif /* Get the major, minor macros. */ @@ -79,7 +64,7 @@ terminal associated with the master FD is open on in BUF. Return 0 on success, otherwise an error number. */ int -__ptsname_r (int fd, char *buf, size_t buflen) +ptsname_r (int fd, char *buf, size_t buflen) #undef ptsname_r { #if HAVE_ESSENTIALLY_WORKING_PTSNAME_R @@ -89,7 +74,7 @@ __ptsname_r (int fd, char *buf, size_t buflen) else return errno; #elif defined __DragonFly__ - int save_errno = errno; + int saved_errno = errno; char tmpbuf[5 + 4 + 10 + 1]; int ret; int n; @@ -116,16 +101,16 @@ __ptsname_r (int fd, char *buf, size_t buflen) memcpy (buf, tmpbuf, n + 1); /* Don't do a final stat(), since the file name /dev/pts/N does not actually exist. */ - errno = save_errno; + errno = saved_errno; return 0; #else - int save_errno = errno; + int saved_errno = errno; struct stat st; if (buf == NULL) { - __set_errno (EINVAL); - return EINVAL; + errno = EINVAL; + return errno; } # if defined __sun /* Solaris */ @@ -202,7 +187,7 @@ __ptsname_r (int fd, char *buf, size_t buflen) memcpy (buf, tmpbuf, n + 1); } # else - if (!__isatty (fd)) + if (!isatty (fd)) { # if ISATTY_FAILS_WITHOUT_SETTING_ERRNO && defined F_GETFL /* IRIX, Solaris */ /* Set errno. */ @@ -216,14 +201,14 @@ __ptsname_r (int fd, char *buf, size_t buflen) if (buflen < strlen (_PATH_TTY) + 3) { - __set_errno (ERANGE); - return ERANGE; + errno = ERANGE; + return errno; } - int err = __ttyname_r (fd, buf, buflen); + int err = ttyname_r (fd, buf, buflen); if (err != 0) { - __set_errno (err); + errno = err; return errno; } @@ -231,10 +216,10 @@ __ptsname_r (int fd, char *buf, size_t buflen) buf[sizeof (_PATH_DEV) - 1] = 't'; # endif - if (__stat (buf, &st) < 0 && errno != EOVERFLOW) + if (stat (buf, &st) < 0 && errno != EOVERFLOW) return errno; - __set_errno (save_errno); + errno = saved_errno; return 0; #endif }