From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#72132: Delete commented out code from fileio.c? Date: Mon, 15 Jul 2024 23:58:55 +0000 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26391"; mail-complaints-to="usenet@ciao.gmane.io" To: 72132@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jul 16 02:00:34 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sTVcP-0006hA-H4 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Jul 2024 02:00:33 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTVbw-0003tx-Qr; Mon, 15 Jul 2024 20:00:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sTVbt-0003sd-8g for bug-gnu-emacs@gnu.org; Mon, 15 Jul 2024 20:00:01 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTVbs-00083O-Vz for bug-gnu-emacs@gnu.org; Mon, 15 Jul 2024 20:00:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sTVbu-0006v9-V4 for bug-gnu-emacs@gnu.org; Mon, 15 Jul 2024 20:00:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 16 Jul 2024 00:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 72132 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.172108794626502 (code B ref -1); Tue, 16 Jul 2024 00:00:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 15 Jul 2024 23:59:06 +0000 Original-Received: from localhost ([127.0.0.1]:60603 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sTVaz-0006tN-GB for submit@debbugs.gnu.org; Mon, 15 Jul 2024 19:59:06 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:53352) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sTVaw-0006tD-Ub for submit@debbugs.gnu.org; Mon, 15 Jul 2024 19:59:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sTVau-0003f2-9e for bug-gnu-emacs@gnu.org; Mon, 15 Jul 2024 19:59:00 -0400 Original-Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTVas-0007t9-HO for bug-gnu-emacs@gnu.org; Mon, 15 Jul 2024 19:59:00 -0400 Original-Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-595856e2332so6415072a12.1 for ; Mon, 15 Jul 2024 16:58:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721087936; x=1721692736; darn=gnu.org; h=content-transfer-encoding:to:subject:message-id:date:mime-version :from:from:to:cc:subject:date:message-id:reply-to; bh=TVPpsH5HJgpbgf59rXZOhSSolZ9DHSmhjkVS1u+mI2E=; b=jrzX3NiCtYw1AJMYaT7pX/GYfZVpRQKkjNcdOYqilFsHZXVBpvtDermnX9HN+pXMXa hmZjbDtL/46bmwSoaQoYvN7PBvkC07BCTcS2LM7nLz5pd1aWY7P0DXH9a//dofj+1DYk NEpMdx9xIwASZJBAlAuIEbc30+c/O/ox4vrT7wPTQCR3MIlJIT9RJB9g78vRSZeKB8aT cCLqmj/+bY2us6dAwF+f+hAioiqYE/VbQHBYeKri5gIA2jH8sqBkV1ixqCdb8O5VQPHx AURHPdHpThfMoUZU2e/3U16v/nA4CXVKLN6GvIuqpsMSg8wHw6jvM0wwl+VPXnWzYJ/7 /5OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721087936; x=1721692736; h=content-transfer-encoding:to:subject:message-id:date:mime-version :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TVPpsH5HJgpbgf59rXZOhSSolZ9DHSmhjkVS1u+mI2E=; b=JwmFI2pEV76uk7RGGXatdg5EuXKIwfSrwiM/pRuovfeOf051PJLrNpM3uIKSKfmRVn 52nlsFymXH3xPZi/g6CVo4AkculVWIooBz5l+vGrMdnTzuG1vQ2Hf49+F86pbF/5ZSo2 MOjp/iKzMYUzQJidEAmrpaxZGZm1NmpnISDp9c+JYgzKz5kFUXMxYQDxU2vgNvivLnRI OrpdM36cr5ovqDW3wvTI31TCf84CJKgj2L680hu2oPY4rAMLCcKoCHIJjrsReGV03VIu lzp68TM16+lLp9KeVW6T3m+RZdbItc+8e3zOU7FI0Xa8D1NE9Ei7vB8QrssmwZ/tuLf0 ejxg== X-Gm-Message-State: AOJu0YwHDW0EJI9VU0tTVZT8K3mSsSVW1OnodKBS7Sm2ivLPN+kzLm/8 4d1GF8G3fUq4iWtCai6jKFjeOFRadcPc9K6dswxxHSqJB720hrwzF8+GBKUSyXhT0cXMqELHQg5 CM3B019gRODVyCt2Md9qrXGe07R1HSYAt X-Google-Smtp-Source: AGHT+IH9FBlbtshrpE2SQFlx+mkCrWu5hxaWNi+TSitQ9vctEZ7ZdRORLU0KU2cBBAcaL4aaqym39lxpKr/JycuNu58= X-Received: by 2002:a05:6402:5194:b0:57c:9ccd:c626 with SMTP id 4fb4d7f45d1cf-59ef0ccc489mr230633a12.39.1721087935724; Mon, 15 Jul 2024 16:58:55 -0700 (PDT) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 15 Jul 2024 23:58:55 +0000 Received-SPF: pass client-ip=2a00:1450:4864:20::532; envelope-from=stefankangas@gmail.com; helo=mail-ed1-x532.google.com 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:288873 Archived-At: Severity: wishlist The below code was commented out since Emacs 10.31, and there's a commit from 2001 saying that it might still be useful. Maybe things have changed in 23 years, and it's less useful than it used to be. How about removing it now? diff --git a/src/fileio.c b/src/fileio.c index 7afe3e75737..3433f471182 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -1758,166 +1758,6 @@ DEFUN ("expand-file-name", Fexpand_file_name, Sexpand_file_name, 1, 2, 0, return result; } -#if 0 -/* PLEASE DO NOT DELETE THIS COMMENTED-OUT VERSION! - This is the old version of expand-file-name, before it was thoroughly - rewritten for Emacs 10.31. We leave this version here commented-out, - because the code is very complex and likely to have subtle bugs. If - bugs _are_ found, it might be of interest to look at the old code and - see what did it do in the relevant situation. - - Don't remove this code: it's true that it will be accessible - from the repository, but a few years from deletion, people will - forget it is there. */ - -/* Changed this DEFUN to a DEAFUN, so as not to confuse `make-docfile'. *= / -DEAFUN ("expand-file-name", Fexpand_file_name, Sexpand_file_name, 1, 2, 0, - "Convert FILENAME to absolute, and canonicalize it.\n\ -Second arg DEFAULT is directory to start with if FILENAME is relative\n\ -\(does not start with slash); if DEFAULT is nil or missing,\n\ -the current buffer's value of default-directory is used.\n\ -Filenames containing `.' or `..' as components are simplified;\n\ -initial `~/' expands to your home directory.\n\ -See also the function `substitute-in-file-name'.") - (name, defalt) - Lisp_Object name, defalt; -{ - unsigned char *nm; - - register unsigned char *newdir, *p, *o; - ptrdiff_t tlen; - unsigned char *target; - struct passwd *pw; - - CHECK_STRING (name); - nm =3D SDATA (name); - - /* If nm is absolute, flush ...// and detect /./ and /../. - If no /./ or /../ we can return right away. */ - if (nm[0] =3D=3D '/') - { - bool lose =3D 0; - p =3D nm; - while (*p) - { - if (p[0] =3D=3D '/' && p[1] =3D=3D '/') - nm =3D p + 1; - if (p[0] =3D=3D '/' && p[1] =3D=3D '~') - nm =3D p + 1, lose =3D 1; - if (p[0] =3D=3D '/' && p[1] =3D=3D '.' - && (p[2] =3D=3D '/' || p[2] =3D=3D 0 - || (p[2] =3D=3D '.' && (p[3] =3D=3D '/' || p[3] =3D=3D 0)))) - lose =3D 1; - p++; - } - if (!lose) - { - if (nm =3D=3D SDATA (name)) - return name; - return build_string (nm); - } - } - - /* Now determine directory to start with and put it in NEWDIR. */ - - newdir =3D 0; - - if (nm[0] =3D=3D '~') /* prefix ~ */ - if (nm[1] =3D=3D '/' || nm[1] =3D=3D 0)/* ~/filename */ - { - if (!(newdir =3D (unsigned char *) egetenv ("HOME"))) - newdir =3D (unsigned char *) ""; - nm++; - } - else /* ~user/filename */ - { - /* Get past ~ to user. */ - unsigned char *user =3D nm + 1; - /* Find end of name. */ - unsigned char *ptr =3D (unsigned char *) strchr (user, '/'); - ptrdiff_t len =3D ptr ? ptr - user : strlen (user); - /* Copy the user name into temp storage. */ - o =3D alloca (len + 1); - memcpy (o, user, len); - o[len] =3D 0; - - /* Look up the user name. */ - block_input (); - pw =3D (struct passwd *) getpwnam (o + 1); - unblock_input (); - if (!pw) - error ("\"%s\" isn't a registered user", o + 1); - - newdir =3D (unsigned char *) pw->pw_dir; - - /* Discard the user name from NM. */ - nm +=3D len; - } - - if (nm[0] !=3D '/' && !newdir) - { - if (NILP (defalt)) - defalt =3D current_buffer->directory; - CHECK_STRING (defalt); - newdir =3D SDATA (defalt); - } - - /* Now concatenate the directory and name to new space in the stack frame. */ - - tlen =3D (newdir ? strlen (newdir) + 1 : 0) + strlen (nm) + 1; - target =3D alloca (tlen); - *target =3D 0; - - if (newdir) - { - if (nm[0] =3D=3D 0 || nm[0] =3D=3D '/') - strcpy (target, newdir); - else - file_name_as_directory (target, newdir); - } - - strcat (target, nm); - - /* Now canonicalize by removing /. and /foo/.. if they appear. */ - - p =3D target; - o =3D target; - - while (*p) - { - if (*p !=3D '/') - { - *o++ =3D *p++; - } - else if (!strncmp (p, "//", 2) - ) - { - o =3D target; - p++; - } - else if (p[0] =3D=3D '/' && p[1] =3D=3D '.' - && (p[2] =3D=3D '/' || p[2] =3D=3D 0)) - p +=3D 2; - else if (!strncmp (p, "/..", 3) - /* `/../' is the "superroot" on certain file systems. */ - && o !=3D target - && (p[3] =3D=3D '/' || p[3] =3D=3D 0)) - { - while (o !=3D target && *--o !=3D '/') - ; - if (o =3D=3D target && *o =3D=3D '/') - ++o; - p +=3D 3; - } - else - { - *o++ =3D *p++; - } - } - - return make_string (target, o - target); -} -#endif =0C /* Put into BUF the concatenation of DIR and FILE, with an intervening directory separator if needed. Return a pointer to the null byte