all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefankangas@gmail.com>
To: 72132@debbugs.gnu.org
Subject: bug#72132: Delete commented out code from fileio.c?
Date: Mon, 15 Jul 2024 23:58:55 +0000	[thread overview]
Message-ID: <CADwFkm=+wkqfW4MnGhgE0075g0EkE76ihKFa3oVzJNy34oawdA@mail.gmail.com> (raw)

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
 \f
 /* Put into BUF the concatenation of DIR and FILE, with an intervening
    directory separator if needed.  Return a pointer to the null byte





             reply	other threads:[~2024-07-15 23:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-15 23:58 Stefan Kangas [this message]
2024-07-16  2:30 ` bug#72132: Delete commented out code from fileio.c? Eli Zaretskii
2024-07-17 21:48   ` Stefan Kangas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADwFkm=+wkqfW4MnGhgE0075g0EkE76ihKFa3oVzJNy34oawdA@mail.gmail.com' \
    --to=stefankangas@gmail.com \
    --cc=72132@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.