GNU bug report logs - #72132
Delete commented out code from fileio.c?

Previous Next

Package: emacs;

Reported by: Stefan Kangas <stefankangas <at> gmail.com>

Date: Tue, 16 Jul 2024 00:00:02 UTC

Severity: wishlist

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 72132 in the body.
You can then email your comments to 72132 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#72132; Package emacs. (Tue, 16 Jul 2024 00:00:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Kangas <stefankangas <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 16 Jul 2024 00:00:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Delete commented out code from fileio.c?
Date: Mon, 15 Jul 2024 23:58:55 +0000
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 = SDATA (name);
-
-  /* If nm is absolute, flush ...// and detect /./ and /../.
-     If no /./ or /../ we can return right away.  */
-  if (nm[0] == '/')
-    {
-      bool lose = 0;
-      p = nm;
-      while (*p)
-	{
-	  if (p[0] == '/' && p[1] == '/')
-	    nm = p + 1;
-	  if (p[0] == '/' && p[1] == '~')
-	    nm = p + 1, lose = 1;
-	  if (p[0] == '/' && p[1] == '.'
-	      && (p[2] == '/' || p[2] == 0
-		  || (p[2] == '.' && (p[3] == '/' || p[3] == 0))))
-	    lose = 1;
-	  p++;
-	}
-      if (!lose)
-	{
-	  if (nm == SDATA (name))
-	    return name;
-	  return build_string (nm);
-	}
-    }
-
-  /* Now determine directory to start with and put it in NEWDIR.  */
-
-  newdir = 0;
-
-  if (nm[0] == '~')             /* prefix ~ */
-    if (nm[1] == '/' || nm[1] == 0)/* ~/filename */
-      {
-	if (!(newdir = (unsigned char *) egetenv ("HOME")))
-	  newdir = (unsigned char *) "";
-	nm++;
-      }
-    else  /* ~user/filename */
-      {
-	/* Get past ~ to user.  */
-	unsigned char *user = nm + 1;
-	/* Find end of name.  */
-	unsigned char *ptr = (unsigned char *) strchr (user, '/');
-	ptrdiff_t len = ptr ? ptr - user : strlen (user);
-	/* Copy the user name into temp storage.  */
-	o = alloca (len + 1);
-	memcpy (o, user, len);
-	o[len] = 0;
-
-	/* Look up the user name.  */
-	block_input ();
-	pw = (struct passwd *) getpwnam (o + 1);
-	unblock_input ();
-	if (!pw)
-	  error ("\"%s\" isn't a registered user", o + 1);
-
-	newdir = (unsigned char *) pw->pw_dir;
-
-	/* Discard the user name from NM.  */
-	nm += len;
-      }
-
-  if (nm[0] != '/' && !newdir)
-    {
-      if (NILP (defalt))
-	defalt = current_buffer->directory;
-      CHECK_STRING (defalt);
-      newdir = SDATA (defalt);
-    }
-
-  /* Now concatenate the directory and name to new space in the stack
frame.  */
-
-  tlen = (newdir ? strlen (newdir) + 1 : 0) + strlen (nm) + 1;
-  target = alloca (tlen);
-  *target = 0;
-
-  if (newdir)
-    {
-      if (nm[0] == 0 || nm[0] == '/')
-	strcpy (target, newdir);
-      else
-      file_name_as_directory (target, newdir);
-    }
-
-  strcat (target, nm);
-
-  /* Now canonicalize by removing /. and /foo/.. if they appear.  */
-
-  p = target;
-  o = target;
-
-  while (*p)
-    {
-      if (*p != '/')
-	{
-	  *o++ = *p++;
-	}
-      else if (!strncmp (p, "//", 2)
-	       )
-	{
-	  o = target;
-	  p++;
-	}
-      else if (p[0] == '/' && p[1] == '.'
-	       && (p[2] == '/' || p[2] == 0))
-	p += 2;
-      else if (!strncmp (p, "/..", 3)
-	       /* `/../' is the "superroot" on certain file systems.  */
-	       && o != target
-	       && (p[3] == '/' || p[3] == 0))
-	{
-	  while (o != target && *--o != '/')
-	    ;
-	  if (o == target && *o == '/')
-	    ++o;
-	  p += 3;
-	}
-      else
-	{
-	  *o++ = *p++;
-	}
-    }
-
-  return make_string (target, o - target);
-}
-#endif
 
 /* Put into BUF the concatenation of DIR and FILE, with an intervening
    directory separator if needed.  Return a pointer to the null byte




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72132; Package emacs. (Tue, 16 Jul 2024 02:33:01 GMT) Full text and rfc822 format available.

Message #8 received at 72132 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: 72132 <at> debbugs.gnu.org
Subject: Re: bug#72132: Delete commented out code from fileio.c?
Date: Tue, 16 Jul 2024 05:30:21 +0300
> From: Stefan Kangas <stefankangas <at> gmail.com>
> Date: Mon, 15 Jul 2024 23:58:55 +0000
> 
> 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?

I still find it useful to look at that old code from time to time.




Reply sent to Stefan Kangas <stefankangas <at> gmail.com>:
You have taken responsibility. (Wed, 17 Jul 2024 21:50:01 GMT) Full text and rfc822 format available.

Notification sent to Stefan Kangas <stefankangas <at> gmail.com>:
bug acknowledged by developer. (Wed, 17 Jul 2024 21:50:02 GMT) Full text and rfc822 format available.

Message #13 received at 72132-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 72132-done <at> debbugs.gnu.org
Subject: Re: bug#72132: Delete commented out code from fileio.c?
Date: Wed, 17 Jul 2024 14:48:08 -0700
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Stefan Kangas <stefankangas <at> gmail.com>
>> Date: Mon, 15 Jul 2024 23:58:55 +0000
>>
>> 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?
>
> I still find it useful to look at that old code from time to time.

OK, closing.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 15 Aug 2024 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 63 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.